About

James Golick

James Golick's software experience ranges from artificial intelligence to web front-end and JavaScript development. Most recently, James has fallen back in love with web development thanks to Ruby on Rails.

Since discovering Rails, James has become a prolific contributor to its open source ecosystem. He is the author of several popular plug-ins and gems, and a contributor to countless others, including the framework itself.

James is an advocate for well-written, well-tested code and he blogs regularly about the practice of developing software. He speaks regularly at software development conferences and user groups. James is a partner in Nine Lives, Inc.

Latest Tweets

follow me on Twitter

James on the Web

Introducing Trample: A Better Load Simulator

Jun 04 2009

Most load sim tools make requests to a static list of urls. They spawn n threads and make requests to the urls on the list in succession, in each thread. Unfortunately, though, if your applicaition makes use of any kind of caching (including your database's internal caching facilities), this kind of load simulation is unrealistic.

The data required to serve a single set of urls is likely to fit nicely in the database server's cache (even on a small server). So, having a single user hammer a finite set of pages will make your application look much faster than it really is.

Unless your load patterns really look that way, you're testing for a scenario that you'll never see.

Introducing Trample

Trample is a more flexible load simulator. Instead of a static list of urls, trample's configuration language is ruby. Using ruby's blocks (lambda functions), it's possible to randomize the requests that get made in each thread, as well as the user that logs in.

Let's look at an example config:

Trample.configure do
  concurrency 20
  iterations  10
  login do
    post "http://mysite.com/login" do
      {:username => User.random.username, :password => "swordfish"}
    end
  end
  get "http://mysite.com/posts/:id" do
    {:id => Post.random.id}
  end
  post "http://mysite.com/posts/:id/comments" do
    {:id => Post.random.id, :author => "James Golick", :body => "lorem ipsum"}
  end
end

This config will cause trample to spawn 20 threads. In each thread:

  1. Trample will begin by sending a POST request to http://mysite.com/login with the result of the block as its POST body.
  2. Then, trample will GET http://mysite.com/posts/(some interpolated value here, based on the result of the block).
  3. Then, trample will POST http://mysite.com/posts/(interpolated value here)/comments with a POST body that includes the remainder of the parameters returned from the block
  4. Repeat steps 2-3 nine (iterations - 1) more times.

It's possible to create fairly realistic load simulations with a configuration like this. Each thread will start by logging in as a different user. And, the threads will each visit different URLs. The ratio of cache hits to misses should be far closer to what they look like under real load.

Running Trample

To run trample:

$ trample start /path/to/your/trample/config.rb

I've tested trample on ruby 1.8.x, ruby 1.9, and JRuby. JRuby has the advantage of native threading, but the drawback of JVM warmup times. So, theoretically, JRuby should be the best platform for running long tramples. Ruby 1.9 should be fastest for shorter tramples. I could be wrong, though. YMMV.

Get It!

Get trample as a gem:

$ sudo gem install giraffesoft-trample

Or get the source from github.


How to Watch Hulu From Canada (or Anywhere Else)

May 24 2009

I live in Canada. We don't have guns. But, we do have health care.

Okay, so there are a few other things we don't have — one of them being hulu. Yeah, there's always watchtvsitcoms.com. But, it's slow, full of annoying flash ads, and the quality of the shows is spotty.

A while back, I tried to beat hulu's geofencing (fuck geofencing) by creating an SSH tunnel. That was a miserable failure. Then, recently, I saw somebody tweet about using OpenVPN. So, I gave it a shot, and it worked!

How To Do this Yourself

Now, I could tell you to go and read the official tutorial on setting up OpenVPN. But, I've got something better.

I put together a chef[1] recipe for installing OpenVPN on a virtual machine. The whole process is automated. So, you don't really need to know anything about OpenVPN to get up and running.

Here's the guide:

  1. Get a linode (or equivalent virtual machine, located in the US).
  2. Setup your vm with Ubuntu.
  3. Install ruby & rubygems on the vm:
    sudo apt-get install ruby rubygems
    
  4. On your local machine, clone the cookbook repository:
    git clone git://github.com/giraffesoft/openvpn-recipes.git
    
    Or, if you don't have git installed, grab a tarball from github. Then, unarchive it:
    tar zxvf giraffesoft-openvpn-recipes-xyz.tar.gz
    
  5. You'll also need capistrano (on your local machine).
    sudo gem install capistrano
    
  6. Now, cd in to the dir you cloned or extracted. Then, edit config/deploy.rb to match your settings.

    You'll want to set :host to your server's domain name or ip address. You'll also want to set user to the name of the user you're going to get ssh'd in as. Finally, set the country, province, city, etc variables. Those are for generating the signing authority.

    You'll want to setup an ssh keypair on your server, too, to make this easier.

  7. Now that everything is all configured, run chef, by typing this command at the root of the openvpn recipes project:
    cap run_chef
    
    OpenVPN is now installed and configured!
  8. Now, create a client package by typing:
    cap generate_client_package
    
  9. There should now be a file at build/client.tar.gz. Unarchive this file to wherever you want to keep your OpenVPN configuration. Then, start OpenVPN on your local machine. That's it!

    Note: if you're using a mac, you'll want to use Tunnelblick to manage your vpn connection. Just unarchive the client package to ~/Library/openvpn and Tunnelblick will take care of the rest.

You should now have a working VPN. Enjoy hulu!

Also, if you're interested, checkout the code at github.

[1] Incidentally, if you do absolutely any work with servers or systems configuration and you haven't had a look at chef yet, you're doing yourself a disservice. Chef allows you to keep all of your servers' configuration in a git (or other scm) repository, edit it locally and deploy it out to your server (or cluster thereof). It also does a lot of other awesome stuff. Check it out!


The New and Improved James on Software

Apr 08 2009

I finally got around to having this site redesigned — something I've wanted to do for a while. James on Software plays a large role in my personal brand. So, having great design is of paramount importance.

There's not much more to say about the new design, except that I did want to mention the designers.

When I arrived at a good company's site for the first time, I knew I had found my designers. Their work really speaks for itself. Definitely check out their portfolio.

In addition to being awesome designers, they do great XHTML/CSS and even know some rails. They're spearheading The League of Movable Type, an open source font movement. So, if you read this blog, there's a good chance you have a lot in common with them.

If you're looking for a design firm for your next project, you should really check this duo out.


Bringing Computer Savvy & Web 2.0 to Pre-Teen Girls

Mar 30 2009

I'm a huge fan of screencasting. It's a great way to learn about software development. Screencasting is also starting to be used to teach general daily computing topics. Nevertheless, it remains something of a niche. The general public still doesn't really know about screencasting.

There certainly isn't a whole lot of screencast content aimed at kids, except maybe a programming tutorial or two. There's nothing (I can find) aimed at young girls.

Hailey Hacks aims to fill that void in the market. Hailey is a savvy pre-teen girl. She's fun — and a little bit rebellious. You might think of her as a cross between Bart and Lisa Simpson.

In the first episode, titled April Fools, Hailey teaches you how to play pranks, low tech and high. First, she suggests that you fill your father's shampoo bottle with ketchup. Later in the episode, she recommends using wakerupper.com to incessantly ring your father's phone while you're at school. I'll let Hailey show you the rest of them.


So far, we've got one other episode up there, in which Hailey teaches you to make your own lolcats. Lots more are coming. Hear first by following @HaileyHacks or subscribing to Hailey's blog.

Despite the fact that this is web 2.0, we're selling the videos for 2$ each over at the Hailey Hacks site. We'd love to hear what you and your kids think of them!


Firefox-style cmd-1 through cmd-9 shortcuts for switching tabs in Safari!

Feb 26 2009

Safari is by far the best browser on OS X. It's fast, has an awesome UI, and just feels better integrated in to the Mac experience.

As former die-hard firefox users, though, I couldn't live without cmd-1 through cmd-9 for switching tabs. Thanks to Safari Commander, now, I don't have to!

For 5$, one person can use Safari Commander on as many of *their* computers as they like. Two members of the same family with separate computers should purchase two copies.

WARNING: REQUIRES SAFARI 4 BETA. Available for download here. So far, I've found it very stable and worth it for this extension alone.

Buy it at the giraffesoft store!