Red Velvet Cake

There’s nothing that says Christmas Time in the South like a Red Velvet cake. Made from the same goodness that powers Santa’s suit itself,
it’s the centerpiece of your Christmas party, that one dessert that everyone will leave talking about

This recipe is tried-and-true. Ms. Sharon’s original recipe - the one that people from Dothan to Huntsville request each year. In her heyday,
my wife would make twenty or more of these in a day. Now, just a few neighbors and very close friends get one each year.

MongoDB
has a very rich regular expression (regex) interface. Regex is available in many of
the places that ordinary character strings are accepted. While convenient to use,
I had some questions about how MongoDB regex performance stacks up to regex performance in other
(SQL) Databases.

The difference is, double quotes require a full, exact string match. Forward slash (regex) will match
rows where the string matches the pattern given. If no special regex characters are given columns
that contain the search string anywhere in the column are considered positive matches.

The first query will only find rows that exactly match the IP Address of
"66.249.65.20"
The second query will find rows that match that IP address at the beginning of the line
and with any (or none) characters following. The
"^"
character is an
anchor
which means that it helps the regex engine restrict the search to the beginning of a string.

mkduino
is a small ruby script for building a GNU Automake environment for your
Arduino development.

A couple of years ago I grew tired of using the Arduino IDE. I realized that there was nothing special about
a “sketch” - it was just regular C/C++ code. Having written C++ code professionally for several years, I had
arrived at an environment that worked for me. This Arduino IDE bore no resemblance to that environment.
Everything about it seemed to cause me problems

It’s Java heritage

Neither emacs nor vi key-bindings

The strange file hierarchy

Line numbers on errors didn’t match up

and I’m sure there are others.

I started doing all of my Arduino development using the avr-g++ with my own hand crafted Makefile. The problem
was that it was hard to give these to any of my friends. I started working on a
rvm-like
system to download all of the Arduino requirements, build them and then use that for development. That took
hours (literally) to compile and seemed a little much for the typical Arduino hacker.

So, I quickly hacked together this ruby script to spit out the required files for a barebones
gnu automake system.

Usage

mkduino
will overwrite your code if you already have a Makefile.am or any of the files it
generates. You probably wouldn’t be running this utility if you already had a makefile
or any of the files it generates.

Go ahead, use emacs or vi to do development for arduino. These tools have evolved over time
to provide professional developers with the power they need to get stuff done.

The Intel Sandybridge i7-2620M processor is capable of overheating Linux

I’ve been plagued for the last few months with problems with my
Intel Graphics
on my
Lenovo T420.
I originally bought this laptop specifically because of traditionally great Linux support
for Thinkpad hardware. I had the option of Intel vs Nvidia graphics, and I chose Intel
because
Gnome3
was reputed to work better with the Intel graphics.

This laptop has pretty impressive
specs
An excerpt from
/proc/cpuinfo
on Linux

I’ve also got plenty of ram (excerpt from
/proc/meminfo:

My problems were:

Overheating

Poor performance when overheating

Overheating

Frequently the temperature as reported by
system monitor
would register around 95C degrees, which is uncomfortably warm to both the lap and hands.
I did a lot of probing around and eventually wrote a script to just detect when the
graphics card was in a wierd state

After a lot of mailing list and Google research (months, not days or hours) I finally stumbled
on this tidbit on the
ArchWiki

The Arduino has a simple to use PWM interface and other implementations should
strive to have a similarly developer friendly interface. The “analogWrite”
Arduino interface is both easy to understand and implement. For instance the
following code implements a 50% duty cycle on digital pin 5:

One problem with the Arduino interface is the learning curve required to venture beyond
the primary interface. For instance, the above code doesn’t specify the PWM period.
Many motors (servos..) function best within a specific PWM period.

This implementation doesn’t allow specification of the signal polarity either. If the hardware interface
requires an inverted signal, then duty will have to be computed as 1/duty manually.

12345678910111213141516171819

voidTimerOne::setPeriod(longmicroseconds)// AR modified for atomic access{longcycles=(F_CPU/2000000)*microseconds;// the counter runs backwards after TOP, interrupt is at BOTTOM so divide microseconds by 2if(cycles<RESOLUTION)clockSelectBits=_BV(CS10);// no prescale, full xtalelseif((cycles>>=3)<RESOLUTION)clockSelectBits=_BV(CS11);// prescale by /8elseif((cycles>>=3)<RESOLUTION)clockSelectBits=_BV(CS11)|_BV(CS10);// prescale by /64elseif((cycles>>=2)<RESOLUTION)clockSelectBits=_BV(CS12);// prescale by /256elseif((cycles>>=2)<RESOLUTION)clockSelectBits=_BV(CS12)|_BV(CS10);// prescale by /1024elsecycles=RESOLUTION-1,clockSelectBits=_BV(CS12)|_BV(CS10);// request was out of bounds, set as maximumoldSREG=SREG;cli();// Disable interrupts for 16 bit register accessICR1=pwmPeriod=cycles;// ICR1 is TOP in p & f correct pwm modeSREG=oldSREG;TCCR1B&=~(_BV(CS10)|_BV(CS11)|_BV(CS12));TCCR1B|=clockSelectBits;// reset clock select register, and starts the clock}

The Linux OS and expanded ram of the cubieboard make possible a much more rich
interface than the arduino affords. File based programming interfaces are
available to extend the PWM control to many more languages. One possible implementation
might include the following interface (examples in shell script):

/sys/class/pwm-sunxi/pwmX

This is the sysfs directory that contains the PWM interface. X is the PWM channel.
The Allwinner A10 has 2

I recently purchased a pcDuino because of it’s plenitude of I/O (5v) GPIO pins.
My Raspberry Pi was an interesting board, but it lacked the GPIO and Analog to Digital inputs that make the Arduino so useful.
The Arduino, while imminently useful, lacks the power to handle images and other
high-bandwith tasks so it’s relegated to motor control and simple I/O.

The pcDuino comes well-outfitted compared to both the Raspberry Pi and the Arduino:

Once I saw the horrid version of Lubuntu that came pre-installed on the device, I started looking for a Fedora port. Luckily Hans de Goede has published a Fedora port for the Allwinner 10 chip. Loading this was simple and straightforward – just follow the README

Then came the task of accessing the GPIO. The Lubuntu image that came with the device exposed some GPIO pins at /sys/devices/virtual/misc/gpio, but Fedora did not show any pins there. After a couple of days of probing the Internet for the source, I stumbled across the amazing GPIO sysfs capabilities of Linux.

After following the guide on elinux.org, I was still unable to access *any* GPIO. Then I remembered that I chose “cubieboard” when I loaded the port by Hans. More hunting revealed uboot, sunxi-tools and the script.bin file. Following are the rough instructions on how to get access to the GPIO on your pcDunio in Fedora…

Pic or it didn’t happen

I had a heck of a time getting a Rails + Unicorn + nginx deployment going on Fedora 17. The problem was, I could get it running using TCP sockets but not using unix sockets. I loosely followed these instructions for deploying a Rails 3.2 app but kept having problems with the unix sockets.

The Solution:

Don’t put the socket file in the /tmp directory.

The Why:

Fedora has this in /etc/systemd/system/multi-user.target.wants/nginx.service

And if you look over on the Unicorn site, you’ll see this as the documentation for the listen method / configuration setting

Adds an address to the existing listener set. May be specified more than once. address may be an Integer port number for a TCP port, an “IP_ADDRESS:PORT” for TCP listeners or a pathname for UNIX domain sockets.

So, after a couple of hours of head scratching and WTF’ing, I remembered that systemd did some crazy shenanigans
to mysql, preventing me from setting the file limit higher. As soon as I saw the PrivateTmp=true line in the
nginx.service file, I knew that systemd was the culprit.