New Hosting

April 29th, 2009

Over the past month or so I’ve been having some hosting issues – my cats would attack the server, some how it would get unplugged, etc. So now I’ve switched everything over to hosting at Mediatemple.net, which seems pretty awesome so far. So here’s to no more downtime, 404s or 500s and hopefully instead we’ll get some 808s. *cheers*

I updated my gcc formatting php script.

March 24th, 2009

A while ago I wrote a script that formats gcc output to link errors back into TM. I updated that script with support for warnings and added some cool looking construction theme colors for the errors and warnings. Have a look see.

Formatting gcc and g++ output for TextMate.

Wordpress Auto-Update Script For A Linux Server

March 16th, 2009

I wrote a little update script for my server to auto update my wordpress installation and figured it might help some other people as well. To use it you simply supply as arguments to the script three things:

1. the directory where your wordpress install lives
2. the name of the backups you’d like to create for that directory
3. the version of the wordpress install you’d like to upgrade to

For example, on my server I use this command to update my wp version:

sudo ./updateWordpress.sh /path/to/wordpress/installation efnx 2.7.1
[enter password]
[watch output]

done!

Here is the code to my script:

#!/bin/bash
DIR2UPDATE=$1
NAME=$2
VERSION=$3

echo "Beginning update of $DIR2UPDATE to version $VERSION..."

if [ -d wordpress_svn ]
then
    day=`date | cut -d" " -f3`
    tme=`date | cut -d" " -f4`
    hour=`echo ${tme} | cut -d":" -f1`

    fileday=`ls -lh | grep wordpress_svn | cut -c 37-39`
    filehour=`ls -lh | grep wordpress_svn | cut -c 40-41`

    if [ ${fileday} != ${day} ]; then
            echo "SVN directory not up to date, [ file's date ${fileday} != today ${day} ] deleting and updating"
        rm -rf wordpress_svn/*
        cd wordpress_svn
            svn co http://svn.automattic.com/wordpress/tags/${VERSION} .
    else
            if [ "$filehour" != "$hour" ]; then
                    echo "SVN directory not up to date, [ file's hour ${filehour} != now ${hour} ] deleting and updating"
                rm -rf wordpress_svn/*
                    cd wordpress_svn
                    svn co http://svn.automattic.com/wordpress/tags/${VERSION} .
        else
                    echo "SVN directory is up to date, skipping update"
                cd wordpress_svn
        fi
    fi

else
    echo "Creating new svn directory and checking out version $VERSION...";
    mkdir wordpress_svn;
    cd wordpress_svn;
    svn co http://svn.automattic.com/wordpress/tags/${VERSION} .;
fi

cd ..

if [ -d wordpress_int ]
then
    echo "Removing old intermediate container...";
    rm -rf wordpress_int;
fi

echo "Creating new intermediate container..."
mkdir wordpress_int
echo "Moving version $VERSION files into intermediate container..."
cp -rpf wordpress_svn/* wordpress_int

echo "Moving config and custom files from $NAME into intermediate container..."

cp -p ${DIR2UPDATE}/wp-config.php wordpress_int
cp -rpf ${DIR2UPDATE}/wp-content/* wordpress_int/wp-content/
cp -p ${DIR2UPDATE}/.htaccess wordpress_int
echo 'Updating svn for wp-content'
svn update wordpress_int

echo "Backing up $DIR2UPDATE..."
mkdir ${NAME}_backup
#mv -f ${DIR2UPDATE}/* ${NAME}_backup   # if you'd like to mv instead of cp
cp -rpf ${DIR2UPDATE}/* ${NAME}_backup
tar -czvf ${NAME}_backup.tar.gz ${NAME}_backup
rm -rf ${NAME}_backup

echo 'Removing svn data from intermediate container...'
rm -rf `find wordpress_int/ -type d -name .svn`
echo "Moving intermediate container contents to $DIR2UPDATE..."
cp -rpf wordpress_int/* ${DIR2UPDATE}

Or you can just download the script here [rightclick + 'save as']->
updateWordpress.sh

My Bike

February 22nd, 2009

My bike up until this point has been a borrowed SR Maxima sr_max

Figure (A)

which belongs to my friend Chris [Chrispy Finch Fry!]. While he was living as a nomad I became the caretaker of two of his prized possessions: his bike and his goldfish [see Figure (B) ]. Since then I’ve continued to use his bike and take care of his goldfish.

Chris Finch's goldfish, Sampson

Figure (B)

Until today! My parents came up North [from LA] this weekend to deliver my grandfather’s washer/dryer tower and brought with them my Dad’s old road bike. It’s an Austro-Daimler SuperLeicht from somewhere in the 70’s. Vintage ace. I went to the shop today and picked up a nice Brooks saddle for it. Looks sharp.

My SuperLeicht
Drilled out brake handles. Awesome.

Check out these drilled out brake handles.

Originally it was a 10 speed, I believe, but one day my Father had some problems with the shifter while riding and when he got home he took it down to a single speed. I like it. The simpler the better. I don’t live in SF, so I don’t need a ton of gears.

Not a fixed gear, phew.

The accessories are all vintage Campagnolo, aquired piece by piece in the 70s by my Dad. The next step to making this guy look really nice is some new tan bar tape.

My current inactivity.

January 13th, 2009

Hey all, I’ve been visiting my blog less and less these past few months, and as a result I have the lowest traffic rates in over a year. It’s all because of a rather good event. I’ve been recruited by a web firm in San Rafael, CA, called Synapse Group, to develop some undisclosed projects which have been taking all of my development time. When I code flash + web services all day, I hardly feel like spending my waning night hours coding my own flash projects. Rightfully so I’ve taken up more C++. I’ve found solice in OpenFrameworks, a bundle of classes that wrap OpenGL, rtAudio, FreeType, FreeImage and QuickTime together in a “user-friendly” [read: reduced programming headache] format. Earlier last year I found OF, then decided to dive into OpenGL and rtAudio on my own, but now I’ve gone back, why re-invent the wheel?
So, expect some C++ projects to get thrown up here soon. One thing I would really like to do, is get a Flash API-like display list system running in OpenGL. I have a crude working concept of OpenGL, but it suffices to display my 2D musings. Any gurus out there available for pointers? No pun intended.

OLPC Give One, Get One

November 16th, 2008

The OLPC [One Laptop Per Child] Foundation is starting their annual Give One Get One campaign on November 17th! Last year I donated a laptop and got mine in the mail a few months later. It’s not the fastest computer, but it’s cute and rugged and novel [did I mention hackable?]. One laptop only costs $199, and I’m sure a lot of you out there are self-employed, which means you can benefit from the write off. You get a tax break and a kid gets a computer. Sweet deal.

OLPC Equation

OLPC Equation

Pure Actionscript 3 Window Class

November 13th, 2008

I’ve been working on an easily skinnable windowing system, and this is what I have so far. I’ve attempted to mimic mac’s theme for Leopard.

Actionscript 3 Leopard GUI

Actionscript 3 Leopard GUI

The source and documentation are in their usual spots -> My classes. I’ll be updating them pretty regularly. Here’s the source for the project itself -> project source

You know you’re a programmer if…

November 7th, 2008

I just stuck “you know you’re a programmer if” into google to see what popped up, who knows, maybe I’m not a real programmer? Looks as if I meet the standards. I’m going to be compiling a list of my favorites:

You know you’re a programmer…

  • when noone understands WTF you’re talking about.
  • when you stop coding to look at the clock and realize it’s Saturday.
  • if your idea of fun is coding something you don’t get paid for.
  • if you have to stay up “just a while longer” to fix ALL the bugs.
  • if you have to remember that when people say “or” they mean “exclusive or”.
  • if you respond faster to email than voicemail.
  • if you use brackets in place of parenthesis [way better, btw].

More to come when I think of them. Feel free to add to this list!

Flash Actionscript 3 Waveform Generation Class

October 24th, 2008

In my last post, Plotting a Sound Wave in Flash AS3 I detailed a method to use when displaying audio data. The method itself works great, but due to Flash’s frame-based code execution and event processing the user looses input capabilities while the flash player chugs through millions of numbers adding, rounding and comparing. In order to make displaying an audio waveform easier on both the programmer and the user I wrote a class that analyzes a Sound object progressively, and dispatches a special event containing the analyzed data. The class will construct a left and right channel Vector, each containing one data point [a number between 0 and 1] for a given number of windows, between two positions in the sound. The left and right position are measured in samples and two types of analyzation are offered. Here is a demo of the class in action:

Screen Capture of Waveform Plot

Screen Capture of Waveform Plot


The calculated data can be reached incrementally through the WaveformEvent object which is dispatched every frame, or at the end of all analyzation in the Waveform object’s leftChannel and rightChannel properties. The details are listed in the documentation below.

Thanks to the Summit Projects Flash Blog and Thibault Imbert at ByteArray for their posts on the different techniques that went into my class.

Source
Here is the source for my TextMate project: Sources
Documentation: class and event

And here is a Flex version (made in windows): // Thanks dem!
Sources (Flex version)

Plotting a Sound Wave in Flash AS3

September 26th, 2008

I’ve always been really into wave editors. I used to make songs in Amadeus by piecing together samples from other songs. Tedious but very rewarding. In a post I made not a long time ago I detailed a little Theremin project which included some wave data visualization. In this post I”ll be going further into detail about plotting sound data.

Digital audio in it’s rawest form [PCM wave data] is a long list of numbers from 1 to -1, which represent the sound’s amplitude. Another way of thinking about this is that each number represents your speaker’s distance away from it’s rest position. At 1 the speaker is fully extended, blowing out your ears and scaring your cats, while at -1 it is fully retracted, blowing out your ears and scaring your cats. To make a meaningful visual out of this we just set up a graph where time is plotted on the horizontal axis and amplitude on the vertical. So at a really high resolution, that might look like this:
80's Oscilloscope
Okay, maybe it would look like that if you were living in the 80’s. Or if you were really into oscilloscopes. In reality with most popular songs being two to five minutes long, we’d be looking at HUGE graphs. One three minute song sampled at 44.1kHz/s comes out to be eight million samples per channel. Per channel. Since most modern music is in stereo, we’re looking at two graphs now. So how do we compress this data and view it in a meaningful way? We cheat a little. We kinda scrap the whole graph/function thing. Well kinda. Let’s say you have a window 1000 pixels wide and a sound 3 minutes long. We have to compress enough samples together in order to represent them using each pixel [about 7,938 samples per pixel]. Averaging doesn’t work because with values oscillating between -1 and 1 the mean is usually zero. We could take one sample every so often to represent an entire chunk and plot that, but that’s just resampling at a much lower resolution, which results in aliasing and all sorts of bogus stuff. Take this video for instance:

Just instead of helicopter blades not moving, it’ll be your data points. No, instead what we do is we scan every single sample and pick out the largest and the smallest numbers from the chunk, which in our case means running through every 7,938 samples and picking the biggest and smallest ones. Then we plot them on top of each other, maybe with a line connecting them. Flash gets a little slow working with lists and arrays this big, but I’m sure we’ll figure out some neat tricks to get this stuff working fast. That said, here’s a little demo. If you can figure out the song I’ll give you a million bucks. [Let it chug for a while, Flash is a slow beast]:

pcm wave data plotted in flash

pcm wave data plotted in flash

Project Source

ps – don’t cheat, guess the song before you download the source, goofball.