30 30 Second Songs In 30 Days

June 30th, 2009

My friend Judah and I are going to collaborate on an album of 30 30 second songs, and will be releasing it August 1st, 2009.

The Universal Law of Deadlines

June 29th, 2009

A friend and I were talking about deadlines, as we’re often thrown into a rushed project together, and I came up with this equation which seems to accurately model a coming deadline in the information industry.

Scivally-Nagler’s Law

workload + stress = 1/(deadline - now);

AS3 – Drawing Circles With IGraphicsData

June 19th, 2009

Lately I’ve been working on a game with some of my free time. It’s a slow process made a little bit faster through the use of Box2D, which is a great 2D physics lib. In my game the user controls a robot that wheels around and smashes other robots. I decided that I would write some functions for drawing geometric primitives, and that I would draw everything into one sprite, or two, depending on how many layers I’d need. In an attempt to squeeze out some more frames per second I switched these functions over to use flash 10+ IGraphicsData API. It’s interesting, to say the least. When using the new API we loose the ability to easily draw rectangles and circles. We can still use familiar functions like moveTo, lineTo and curveTo – so I’ve written a function that draws a circle using these. It uses some fun almost calculus [parametrization of a curve in so many points] minus any derivatives or integrals. Is that still calculus? Meh. Here’s what happens:

We create a new GraphicsStroke [the line], a new GraphicsSolidFill [the fill], a new GraphicsPath [the path] and an IGraphicsData Vector to store them all in.

var _stroke :GraphicsStroke         = new GraphicsStroke(1);
    _stroke.fill = new GraphicsSolidFill(0xFF00FF, 1);
var _fill   :GraphicsSolidFill      = new GraphicsSolidFill(0xF0F0F0, 1);
var _path   :GraphicsPath           = new GraphicsPath();
var _graph  :Vector.<IGraphicsData> = new Vector.<IGraphicsData>()

Now what we’ll need to do is populate the path with some commands and some points. To do this, we can use GraphicsPath’s familiar functions moveTo, lineTo and curveTo. These functions will fill path.command and path.data with commands and data, respectively. The parameters to each command are stored in the data array, where as a number representing each command are stored in the command array. You can read more about it here. So here is a function that will fill your path with points and commands to form a circle.

private function r_addCircle(_x:Number, _y:Number, r:Number, path:GraphicsPath, numPoints:int = 8):void
{
    var twoPI:Number = Math.PI * 2;
    var curve:Number = 1 + 1/(numPoints*1.75);
    path.moveTo((_x + r), _y);
    for (var i:int = 1; i <= numPoints; i++)
    {
        var th  :Number = twoPI * i/numPoints;
        var thm :Number = twoPI * (i-0.5)/numPoints;
        var px:Number = (_x + r * Math.cos(th));
        var py:Number = (_y + r * Math.sin(th));
        var hx:Number = (_x + r * curve * Math.cos(thm));
        var hy:Number = (_y + r * curve * Math.sin(thm));

        path.curveTo(hx, hy, px, py);
    }
}

In this function _x and _y represent the center of the circle, r is the radius and path is your GraphicsPath. numPoints refers to the number of points you’d like to use for approximating your circle. The more points, the more “perfect” the circle will look, although more points will tax your frameRate. We can get a pretty nice looking circle with 8 points. 4 looks a little boxy, but around 8 is nice. Experiment. Here’s the next step – we’ll add the points to our path and then add the stroke, fill and path to our Vector and then have a sprite draw our graphics data:

r_addCircle(50, 50, 50, _path, 2);
r_addCircle(150, 50, 50, _path, 4);
r_addCircle(250, 50, 50, _path, 6);
r_addCircle(350, 50, 50, _path, 8);

_graph.push(_stroke, _fill, _path);
   
var sprite:Sprite = new Sprite();
addChild(sprite);  

sprite.graphics.drawGraphicsData(_graph);

This should draw 4 circle approximations of different resolution. This is what it looks like:

approximated circles

approximated circles

You can see that as n [numPoints] increases, the closer to an actual circle our object becomes. I hope this entry helps some of you out there save a little time.

Hannspree HF237 + Macbook Pro 2.16Ghz

June 17th, 2009

I bought a new monitor today – a Hannspree 23″. I only paid about $180 for it, so it seemed like a sweet deal. TOTALLY WRONG. This thing hurts my eyes it’s so sh*tty. Some pixels are sharp, others are blurry. It’s like the monitor itself is stretching and interpolating the pixel points from my video card. Text is UNREADABLE on most resolutions and no amount of settings fidgetry seems to fix it. The pixels just don’t line up. This thing is auto-dithering my pixel art. I’m taking it back tomorrow and getting my money back. I’d rather have a used, scuffed up LCD from two years ago. Tried and true.

Altered States

May 2nd, 2009

I just saw this movie called Altered States, it’s pretty interesting – a little cheesy at times, but check out these screen shots:










Man, they don’t make movies like they used to.

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.

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