Source code from the #Codegasm series on http://barnnerd.com