April 22nd, 2009
Just released a new Ruby library on Github called Gattica . Gattica is a gem that lets you talk to the newly released Google Analytics API . Check it out and let me know what you think!
March 3rd, 2009
Just picked up a new book and found the following advice in the forward:
“While learning something new, many students will think, ‘Damn, this is hard for me. I wonder if I am stupid.’ Because stupidity is such an unthinkably terrible thing in our culture, the students will then spend hours constructing arguments that explain why they are intelligent yet are having difficulties. The moment you start down this path, you have lost your focus.
“I used to have a boss named Rock. Rock had earned a degree in astrophysics from Cal Tech and had never had a job in which he used his knowledge of the heavens. Once I asked him whether he regretted getting the degree. ‘Actually, my degree in astrophysics has proven to be very valuable,’ he said. ‘Some things in this world are just hard. When I am struggling with something, I sometimes think “Damn, this is hard for me. I wonder if I am stupid,” and then I remember that I have a degree in astrophysics from Cal Tech; I must not be stupid.’"
February 20th, 2009
Up until now I have never had a passport. But we’re starting to travel more and with the new laws in effect it’s about time I got one.
The requirements to get a passport are: a valid US birth certificate and photo ID. No problem, just get my “official documentation” folder and I’m good to go. I get out the folder and there’s no birth certificate. Uh oh. When was the last time I saw it? On our cruise back in February. I used it as a bookmark so that I could keep track of it. But for which book?
Then my wife remembered taking a photo of that book while on our cruise. I quickly opened up iPhoto and scanned through the photos from the cruise:

Jackpot! I couldn’t read the spine but remembered the color: In Defense of Food (which I have yet to finish). I went to the bookshelf…search…no book. I went up to the loft and went through the additional boxes of books we don’t have shelf space for. Flip, flip ,flip…green cover, black spline, got it! And look what’s sticking out of the top:

February 17th, 2009
Another release today, this time it’s a small Ruby library for searching a Google Appliance Server called Gasohol . I’ve been working on a prototype search at my job as a full Rails app, but I removed the part that searches and parses results from the GSA and open sourced it.
As always, check out the readme for usage instructions. I plan to turn this into a gem eventually, but for now you’ll need to pull the files down manually and drop into the rest of your code. More to come!
February 16th, 2009
I’ve just released an extension for Radiant CMS which lets you search flickr and returns an unordered list of the thumbnails that match. The extension is listed in the Radiant Extension Registry and is hosted on its own page on Github . Just create a directory in /vendor/extensions called something like flickr and drop the extension in there. Restart Radiant and you’re good to go!
Check out the README for usage.
January 28th, 2009
Parts 1 and 2 of the getting started tutorials are now up on Sketchup for Woodworkers Check ’em out!
January 25th, 2009
For the past year and a half now I’ve taken up woodworking as a pretty serious hobby. I’m currently enrolled in my second woodworking class at Palomar College and a major part of the class will be designing our own project from scratch. Using Google Sketchup is an option but not many of the students know it (and I don’t envy someone using a 3D software package for the first time). I’ve been using Sketchup for a while now and wanted to share what I’ve learned with the class.
So this past weekend I hunkered down with Sketchup and Photoshop and put a site together. Sketchupforwoodworkers.com will be a resource of tutorials and more that are specifically designed for woodworkers just starting out, or ready to move to the next level, with Sketchup. Even if you’re not interested in building your own bedroom set but have always wanted to dip your toes into 3D, check it out!
Technical Details The site is powered by Radiant and hosted by the fine folks at Linode.
January 15th, 2009
As I’ve mentioned recently, my blog is built with Jekyll. I put together a little script (actually just an alias since I didn’t need any logic) that builds the site and pushes it to my server. My directory structure looks like this:
/jekyll is the Jekyll source, /raw contains my posts and source files for the site, /site contains the generated code that Jekyll produces.
My alias is called “rtc” and I can just type that at a prompt to build the site and rsync it with my server. Add this to your home directory’s .bash_login or .bash_profile (if you’re on a Mac, the name may be different on Linux but it’s the file that will run each time you bring up the terminal and add all of your custom paths, aliases, etc.). This should all be on one line:
alias rtc="echo 'Building...' && ~/Sites/rtc/jekyll/bin/jekyll
--pygments ~/Sites/rtc/raw ~/Sites/rtc/site &&
echo 'Pushing...' && rsync -avz --delete ~/Sites/rtc/site/
user@myserver.com:/var/www/rtc/"
You’ll need to replace the directories and user@myserver.com of course. If you have your public ssh key on your remote server then you won’t need to provide a password each time you run this command.
When I run it here’s what I see at the terminal:
Building...
Successfully generated site in /Users/rob/Sites/rtc/site
Pushing...
sending incremental file list
atom.xml
index.html
robots.txt
... big long list of files ...
sent 5344 bytes received 24392 bytes 19824.00 bytes/sec
total size is 5268345 speedup is 177.17
Done!
January 14th, 2009
I found a neat app this evening called GeekTool for your Mac. It lets you add a few neat things to your desktop:
- the contents of a plain text file (like a log)
- the output of any command run in the terminal
- an image from the local drive or the web
There are a few sample desktops on the site. Here’s a really tightly integrated example.
For those that use git here’s a neat way to keep an eye on the status of a directory. Add the following command as a new “shell” entry in GeekTool (all on one line):
/opt/local/bin/git --git-dir=/Users/rob/Sites/my_project/.git
--work-tree=/Users/rob/Sites/my_project status

In my case I installed git via Macports so I’m using /opt/local/bin/git to call git. Do a which git and change the above script to use that location. Since GeekTool calls to the terminal from who-knows-where, we’re giving git the full path to our project. After you add the command to GeekTool hit tab to enable it and then F11 to move all your windows out of the way. You should now see the output of the command at the upper left of your desktop. You can move it, or drag the handle in the lower right corner to resize.
I changed my font size and color to make it a little more readable on my desktop. I’ve got uptime and top -l1 -u -o cpu -S, as well as cpu, bandwidth and io graphs from my Linode vps.

January 8th, 2009
When I first heard about memcached I was excited because of the promise of a very fast caching mechanism that could store anything, but was a little frightened by the idea of dipping my toes into the caching world. Isn’t caching hard? Not the actual process of storing something. Expiring from cache is a different story. I’m only going to deal with the first problem.
So, how easy is it? First, get memcached. If you’re running something like Ubuntu this is as easy as:
sudo apt-get install memcached
Of if you have Macports on your Mac then:
sudo port install memcached
Once you have memcache you’ll want to start it running:
The -vv puts memcache in Very Verbose mode so you get to see all the action. You’ll run this as a daemon once you’re ready to go for real (replace -vv with -d).
My example below uses Ruby and Rails but there are memcache libraries for just about every language out there . For Ruby we’re using memcache-client and you’ll need the gem:
sudo gem install memcache-client
Okay, all the hard stuff is out of the way. Rails already tries to require 'memcache' so you don’t need to worry about that at all. At the end of your config/environment.rb file create an instance of memcache and assign it to a constant so it’s around whenever we need it:
CACHE = MemCache.new('127.0.0.1')
Now we’ll add a simple method to our application controller so that this new caching mechanism is available to all of our controllers. Make sure this method is private:
private
def cache(key)
unless output = CACHE.get(key)
output = yield
CACHE.set(key, output, 1.hour)
end
return output
end
memcache stores everything as simple key/value pairs. You either ask memcache if it has something for a given key, or give it a value along with a key to store. This method will attempt to get the value out of cache and only if it’s not found then will run the block you use when calling it (that’s next) and store the results of that block into cache with the given key and telling it to expire after 1.hour. Every time you ask for that key within the next hour you’ll get the same result from memory. After that memcache will store it again for another hour.
As a very simple example, you could use this in your controllers like so:
result = cache('foo') { 'Hello, world!' }
So, if the cache contains a key called ‘foo’ it will return it to result. If not, then it will store Hello, world! with the key foo and also return to result. Either way, result will end up with what you want (the contents of the block). If you take a look at the output of memcache back at the terminal you’ll see it trying to get and store data by the key.
Storing a simple string doesn’t do us much good, so let’s try a real world example. At work I’m working on a new search with a Google GSA . We get some keywords and other search parameters from the user, send them over to the GSA, parse the result, and display to the user. We only update our search index once per day, so if more than one person searches for “running san diego” there’s no reason to go to the GSA each and every time—the result hasn’t changed since it was asked for the earlier in the day. So we cache the result for 24 hours.
A search result on our system can be uniquely identified by the URL that was generated from the user’s search parameters. We use this URL as the key to memcache. A regular URL can be pretty long so we take the MD5 hash of it and use that as the key:
md5 = Digest::MD5.hexdigest(request.request_uri)
output = cache(md5) { SEARCH.search(keywords, options) }
SEARCH is the library that talks to the GSA and parses the result (which I open to open source soon). What did this do for our response times? Our GSA box is currently located in Australia (it’s a loaner). Between the network latency of talking to the GSA and receiving and parsing the huge XML file it returns (50kb), most requests were taking 1500 to 2000 milliseconds (not including going through the regular Rails stack to get the page back to the user). With memcache in place the same results come back in 1 millisecond. One. That’s three orders of magnitude difference!
As you can see, adding memcache to your Rails app is stupidly simple and you can start benefiting from it right away. Don’t be scared of caching!