Occupy Portland Photos

0 Comments | This entry was posted on Oct 06 2011

Making music from machines – Hacking for the sake of music.

0 Comments | This entry was posted on Feb 10 2011

It never ceases to amaze me the ways that people will find to make music. Who would ever think that an old floppy drive could be used to make music? What about a scanner? Or a dot matrix printer? Amazing, and cool.

Javascript fun.

0 Comments | This entry was posted on Nov 18 2010

Figure it out…


If Kids Were Computers and Parenting By Code

1 Comment | This entry was posted on Sep 14 2010

I started thinking tonight, how I wish kids were more like computers. I’d totally write a “take a bath, brush your teeth and go to bed” function. What’s even better, is I’d only have to tell it to run once! It would be a whole lot easier to parent by code. Certainly more efficient and less frustrating.

The following examples are not exactly syntactically correct, but they were made up to fit into a twitter post.

while(!teeth.brushed) {
print "for the " + ( i++ ) + "time, go brush your teeth!";

kid.addEventListener("MomOrDadSaysSomething", doIt);

I’m sure I’ll be adding more and updating as I think of them…

iTunes + iPhone = Pure suck

0 Comments | This entry was posted on Sep 09 2010

I’ve had it with iTunes, and about had it with my iPhone. There’s many reasons why, but here’s an example.

I wanted to transfer a 30 second song to my phone. 30 seconds, 432K. Should be as simple as drag and drop. Few seconds worth of time. But here it is two hours later, and I still haven’t gotten the file on there.

This is ridiculous.

First iTunes tells me it’s synced to a different library and must erase all my data, even though I only have one library and sync on only one computer. Then it has to backup everything on the phone before syncing. And we all know how long that can take sometimes. 50 minutes later, the sync starts. But then iTunes stops responding and then crashes. My phone then decides to reboot. I restart iTunes and plug the phone back in. Click sync, and now, it is backing up again.

So, it’s going to take over two hours to transfer a 432K file over USB? Seriously?

Fuck you Apple, right in your Steve Jobs butt.

Force Apple Mail to display plain text by default

1 Comment | This entry was posted on Jun 10 2010

Testing multipart emails can be a pain when you can’t choose whether you want to see the plain text vs the html version of the email. If you use Apple’s mail client however, you can set a preference on which version you’d like to see by default.

Just open up a terminal window and enter the following:
defaults write PreferPlainText -bool TRUE

To return back to normal, just enter the same thing, but set it to FALSE.

Running PHP cron jobs on a MediaTemple DV server

1 Comment | This entry was posted on Jun 08 2010

Recently I was attempting to create some cron jobs to run PHP scripts on a DV server or at MediaTemple, with PHP installed as an Apache module (rather than CGI). I was able to execute the php file, however all of my include and require statements were totally failing.

My first idea was to set the include paths in PHP. This failed and the scripts still reported errors. My next attempt was to use absolute paths for my includes. This correctly found the includes, but resulted in safe mode errors.

I finally resolved the issue by creating a custom .ini file for PHP, making the appropriate setting changes and then supplying that ini file as an argument to PHP in the cron command.

SSH into the server, and copy the ini file. Something like:
#cp /etc/php.ini /var/www/vhosts/domain/includes/cron/php.ini

Now open up the new ini file in vi or emacs (I’m not getting into that debate). First you’ll want to disable safe mode by changing the line “safe_mode = On” to “safe_mode = Off”. Next, you can comment out the openbase_dir setting by changing the line “open_basedir = “/usr/share/pear” to be “; open_basedir = “/usr/share/pear”. And finally, set the includes path for your php scripts.

The last step is to make sure you execute the correct command in cron. Remember, you’ll need to pass the custom .ini file as an argument to PHP. Something like:

php -c /var/www/vhosts/domain/includes/cron/php.ini /var/www/vhosts/domain/includes/cron/test.php

This isn’t rocket science, and probably a no brainer to some. But, I found it useful and hope someone else does too.

The best thing about this, is I can leverage existing PHP code without having to write a ton of junk in PERL (yuck). Less code = less frustration.

Best gift ever

0 Comments | This entry was posted on Jun 06 2010

What’s better than a monkey taking a grumpy? A monkey taking a grumpy while reading a book and banging his head to heavy metal. This fantastic little gem is solar powered too. This is way better than a lame-ass bobble head.

I just received this gift from a friend upon his return from a trip to Korea. I’m not sure if I should be proud of the fact that he said he thought of me when he saw this or not. Nonetheless, I love this thing. My kids love it too. The fun doesn’t stop with the toy itself. Reading the instructions can provide a laugh or two as well.

And of course, I couldn’t resist. It just begged the sound track.

Spilling Coffee on your MacBook Pro

0 Comments | This entry was posted on May 20 2010

I did it. After hearing all the horror stories and thinking it would never be me, I managed to dump a very full cup of coffee on my 17″ MacBook Pro. While attempting to squeeze in a few minutes of work this morning before I left for the office, I accidentally bumped my coffee cup. My reflexes fired and I tried to catch the cup. In the process of doing so I only made matters worse and thus sealing the fate of my beloved MPB. Luckily my instincts kicked in and I immediately tilted the laptop in such a way that hopefully all of the coffee that made it inside went to the bottom towards where the track-pad is, and away from the logic board.

So what next…

I’m not sure if what I did and what I am about to tell you next is the correct way to deal with the situation, but I guess in a few days we’ll see if I’m the proud owner of a worthless hunk of aluminum.

Step 1

Tilt the laptop so the moisture drains away from where the logic board is. The board is approximately located towards the back and extends down to about where the space bar is. It starts on the left side and ends about where O and P keys are.

Step 2

Unplug and power down as quickly as you can. The faster you do this, the more likely you are save your system from getting fried. Don’t worry about shutting down your system properly at this point. You’ll probably survive that, it’s the hardware we’re worried about. So – press and hold that power button until the screen goes black.

Step 3

Set your laptop on top of something absorbent like a towel, and get some air moving. Heat is probably a bad idea, so it’s probably best to just use a fan. Remove the back cover to expose the components inside. There are 10 screws holding the back plate on. It is probably a good idea at this point to find a small container to place all of your screws in, so you avoid losing them.

Step 4

Warning the next step will void your warranty.

Remove your battery from the system. Apple, being the jackasses they are, use special screws to hold the battery in place. After a trip to RadioShack, the MacStore and my local hardware store I found that nobody carries the correct screw driver for this. However, I found that my cheapo precision screwdriver set has a flat head 2.4mm one that will work anyway.

Make sure your warranty isn't important to you before proceeding! :)

Step 5

Dry up any excess moisture you can. And keep that fan running

Mmmm. Coffee...

Step 6

Finally, and most importantly, DO NOT give in to the temptation of putting things back together and firing up your laptop before it’s had a chance to completely dry out. If you do, you might fry something (if it isn’t already). I plan on leaving my as is for a few days just to make sure.

Gratuitous nerdy shot. Hey, I thought it looked neat and was curious how well my macro settings worked on my Cannon XSi Rebel.

The best tractor fight scene evar.

0 Comments | This entry was posted on May 18 2010

I think that if you looked up the word awesome in the dictionary, it would reference this video.

Adobe responds to Apple’s attacks on Flash

0 Comments | This entry was posted on May 14 2010

Adobe responded to Apple’s attacks on flash with a new ad campaign:

Picture 1

A colleague of mine just forwarded this hilarious (and fake) response from Apple.


Personally I think both Apple and Adobe can suck it.

Templating/Page Decoration

0 Comments | This entry was posted on Apr 20 2010

I believe I’ve got my templating working the way I want. It needs to be refactored, but it works. FYI – my terminology can be confusing, but when I say decorate the page, I essentially mean apply the template to the requested content. I guess was originally thinking I was going to model templating after the decorator design pattern.

Essentially this is how things flow:

Request gets redirected to the controller
The front controller gets forwarded the request with the original path passed as a GET parameter. So, a request to localhost/test/ basically ends up as localhost/controller.php?params=test/. All of the site content pages are located in a directory called content (configurable so you could put all content outside of the web root). So the controller looks for /content/test/index.php and then renders the html into a buffer.

Controller attempts to decorate page
The controller has a PageDecorator class instance. When the PageDecorator class is instantiated, it loads the decorators config. In hindsight, this should probably only happen once per session for performance reasons, but whatever. I’ll get to that later. The controller then asks the PageDecorator to decorate the page, and passes the previously buffered HTML as an argument. The PageDecorator looks to see if the requested path matches any of the decorator directives in the config. If so, it decorates the page and returns the modified HTML. If the page doesn’t get a decorator, it simply returns the original HTML. Then controller can then output the page contents (or perform other actions if needed)

I’m not sure I like how I have the template wrapping working. I’d love to hear suggestions. Essentially I load the content page into a buffer. Before the template gets rendered, I use regular expressions and pull out the <head/> and the <body/> tags, and then stuff those both into an associate array. I then call a static method on a Page class to load the HTML, with the associate array as an argument. Inside of that method I than extract the associate array arg into the local scope, parse the template, and then return the rendered HTML. Seems messy, but I didn’t like the idea of putting the content of the page into the global scope before parsing it, and this was the quickest way I could come up to do it.

It’s kind of backwards how you might typically do includes where the outer page would get called first and then an include inside of that would render the inner content. I’m actually rendering the content first (so I can rip out the head and body content) and then rendering the outer page.

I know that these are incoherent ramblings that probably won’t get read by anyone, but it helps to put my thoughts down in words…


0 Comments | This entry was posted on Apr 19 2010

In thinking about how I want to implement a templating system in my homegrown php framework, I guess it would be good to start with some basic requirements. The goal is a simple and easy to use templating system.

Base requirements:

  1. Content pages are simple and only contain necessary markup for the content
  2. Ability to target content areas in the template page
  3. Simple way to designate which pages get decorated with which template to use

Content pages are simple and only contain necessary markup for the content

I want my content to only contain the necessary markup for the content and not be cluttered with page structure HTML, framework PHP fragments and the likes. I also want to be able to markup fully valid HTML pages, or simple HTML fragments. As a bonus, I think the templating should even work for things like HTML emails if needed.

Ability to target content areas in the template page

One of the things that annoys me about many templating engines is that your content pages can’t target specific areas in the template page. I guess by good OO design, this may be valid. However – I find that many times I have pages that need to include their own stylesheets. Rather than including these stylesheets in the master layout, I want to be able to include them from the content level. Most likely your content page is being rendered into the body of the page. By placing the <link> tags in the body would result in invalid XHTML.

Simple way to designate which pages get decorated with which template to use

In a few front control examples I looked at, template designation was hard coded into the PHP itself. That leaves a bad taste in my mouth, and so does dog shit (and that is why I don’t eat it and neither should you). I’m thinking of borrowing the way I’ve seen it handled in a stripes/sitemesh stack. There’s simple XML configuration that uses basic URL patterns to match to templates and some exclude tags for handling pages you don’t want decorated.

Seems simple enough. Then again, everything is easier said than done.

Front Controller Pattern

1 Comment | This entry was posted on Apr 19 2010

I’m not a huge fan of tons of repetitive code and mark-up. I find it inefficient, sloppy and difficult to maintain. So, I’ve never been a fan of using includes on every page of a site for the headers, footers, blah blah blah in PHP. It’s also very difficult (to me) to implement good templating this way. It’s something that has continuously bothered me when developing sites in PHP.

So I turn to the Front Controller Design Pattern. By modifying the .htaccess file in the root of the site, you can redirect all requests to a single place: the front end controller. Now all of the requests are being handled by single PHP script. This controller can now handle all authentication, templating, redirection, etc. all in one easy place.

Now I realize many frameworks out there utilize this pattern already, and probably to a much greater success than I ever will. Symfony, Zend Framework, Cake and Drupal just to name a few. However, I find some of these frameworks are often very heavy and overly complicated for a lot of uses. Also, I don’t like being forced to work within their paradigms. I want to work in my own. (Not to mention the fact that I like writing my own frameworks!)

So I’ve decided to write a very lightweight and simple front controller framework that I can reuse across sites. Nothing too fancy. Just enough to get the job done. I find for many simple sites, all I need is some simple templating, maybe some authentication, and some sort of navigation system. I don’t need a huge framework for doing this. I just need a simple front controller to route requests and enable me to implement those features.

I’m sure as I get into development, I’ll start adding more and more features. Discover many benefits to using well established frameworks over the roll-your-own ones. I’ll post some code soon so people can start beating me down.

Next up – templating. I have a few ideas on how I want to implement this, just need to spend some time hashing it out. More on this later.

Tron Legacy Trailer

0 Comments | This entry was posted on Jul 27 2009

Oh man. I was super excited to see that there’s a Tron 2 in the works. I was a huge fan of the original movie. I hope they don’t disappoint.

Official Site trailers:

Controlling iTunes remotely

1 Comment | This entry was posted on Jun 16 2009

So I just got this shiny new MacBook Pro. Absolutely love the thing. I’ve been away from the Macintosh platform for far too long…

Anyway – I’m sitting in my office listening to music and realized that the speakers, while okay for what they are, suck by most standards. So I pop over to my PC and fire up iTunes, hit play, and use my sound system that’s hooked up to it. Sounds great. But, I’m lazy and I got tired of switching over to it change tracks, stop, pause, etc. I figured there had to be a way to control iTunes remotely from the Mac. Doing a bit of research, I found some stuff for the Mac and a PHP script that did me no good.

Finally I came across a Perl script (can’t remember where…) that simply runs a Daemon. Everything that I needed was already there! All I needed to do, was point a browser at the box and it had a nice simple stripped down interface for play, pause, stop, next, etc…

After some time, I realized I hated having to keep the browser window open. Enter MacOS dashboard widgets.

After some quick fiddling with Dashcode, I came up with this little dashboard widget to send the requests to the PC. The current track name only updates after a command is sent, so it isn’t updated dynamically.


Now my iTunes controls are at my fingertips, and I don’t have to spend the time moving my hands the whole 24 some inches to the right to do it on the PC.

gZip your JavaScript

0 Comments | This entry was posted on Mar 17 2009

Most browsers these days (with the exception of Safari, I think?) will accept gzip encoded content. This means you can drastically reduce the size of all those bloated javascript libraries you might be using on your web site.

So how do you serve gzipped js files?

There a few methods out there. I chose the one below since it was fast, easy and I’m hella freakin’ lazy.

The first step is to gzip all of the javascript files that you might be serving up. The fastest way I found was to just telnet into the server, and execute the following bash command:

gzip -cr <javascript directory>

Of course you’ll need to replace <javascript directory> with the correct directory that your javascript files are located in. The -c option tells gzip to keep the originals. This is important so that you can still serve non gzipped versions to browsers that don’t handle gzip! The -r option tells it to recurse through the directory. Now you should have a directory full of javascript files and their gzipped counterparts.


Yay. How exiciting, no?

The next step is to modify .htaccess to do some URL rewriting.

AddEncoding gzip .gz
RewriteCond %{HTTP:Accept-encoding} gzip
RewriteCond %{HTTP_USER_AGENT} !Safari
RewriteCond %{REQUEST_FILENAME}.gz -f
RewriteRule ^(.*)$ $1.gz [QSA,L]

Essentially your telling the web server to server up gzip files, if the browser accepts them and the user is not on Safari and if there is a compressed version of the file available.

That’s really about it.

Here’s the difference in file sizes:

File Size Size (gZip)
init.js 7628 1992
jquery-ui.js 127787 50756
jquery.easing.js 8097 2003
jquery.history.js 5079 1771
jquery.js 31033 15666
swfobject.js 6722 2233

Pretty significant size difference!

IE and responseXML issues

0 Comments | This entry was posted on Mar 13 2009

After working on a small AJAX library, I decided to test it in IE. Everything worked great, except when requesting XML. The responseXML property of the XHR was null. I’ve had this issue in the past where the server isn’t returning the appropriate Content-Type (text/xml). But that wasn’t the issue this time. I checked my resin config and everything was correct.

So, I uploaded to a remote server and tried again. Blammo. Chit just worked the way it was supposed to. This left me scratching my head however.

I installed Charles (, which is a great debugging HTTP proxy/monitor, to see what was going on. Everything worked as it should in FireFox, but still no dice in IE.

Then I noticed that traffic wasn’t being captured for Localhost when using IE. After a bit of stumbling around the net I found that if you add a period right after localhost, Charles will capture the traffic.




When I reloaded the page, I got a very nice surprise. Not only did Charles capture the traffic, but the XHR returned with a proper responseXML property!

I’m no network engineer, so I’m not even going to try and guess as to WTF. But, I’m happy it works as expected and thought I’d post about it in case someone else ever runs into this issue.

Force directed node interface 2

0 Comments | This entry was posted on Feb 17 2009

Here’s an example of the force directed node interface that I’ve been talking about. It’s not complete. It’s just a working prototype. You still cannot load project details, but I’m waiting to add that if I decide I want to take this any further.

Since the dimensions of the interface have been reduced to fit in this blog post, things might be a bit small (try zooming in). You can also drag nodes around. Helpful when things get pushed off the screen. Nodes can be opened and closed by clicking on them.

Get Adobe Flash player