All posts by Tom Chapin

Tricks with Pry – Live Editing

When I’m programming in Ruby, one of the most indispensable tools I’ve found is an awesome little ruby gem called Pry.

Pry lets me debug my code, pausing and giving me a live REPL wherever I put a breakpoint (‘binding.pry’) in my code.

Recently, I learned about Pry’s editor integration, which gives you the ability to open your code in an external editor, make changes to it, then go back to debugging in your Pry REPL. This is super handy, because it means you don’t have to restart your Pry session every time you make a code change!

My favorite Ruby editors at the moment are RubyMine and Sublime Text. As such, I wanted to set RubyMine as my default Pry editor.

To do this, edit (or create) the “~/.pryrc” file in your home directory, and put this code in it:

My buddy, Jason Waldrip also came up with this nifty little addition, which will let you easily open methods in an external editor (although any changes you make won’t be live-updated in your Pry session without reloading the class files that you edited):

Sous Vide Supreme – Cooking Experiment #1 – Beef Tenderloin

I recently purchased a Sous Vide Supreme cooker (“Sous Vide” is French for “under vacuum”), and my very first cooking attempt was Beef Tenderloin, which I will share here.

The end result was the most tender beef tenderloin I’ve ever had, perfectly pink all the way through, with a nice crust on the edges. The meat could be cut effortlessly with a fork, and just melted in my mouth. I will definitely be making this recipe again!

1. Salt and pepper the beef tenderloin

2014-11-14 20.01.45

2. Vacuum seal in cooking-safe plastic bags, with 1 tablespoon of butter

2014-11-14 20.06.03

2014-11-14 20.06.56

3. Cook at 138 F for 3 hours

2014-11-14 20.19.13  2014-11-14 23.26.42

4. Remove from bags and drain the juices.

2014-11-14 23.53.39

2014-11-14 23.55.13

5. Preheat cast iron skillet to just under the smoke point for butter

2014-11-14 23.57.11

5. Briefly sear tenderloin on each side in butter (I used a cooking torch, too, just for fun)

2014-11-14 23.57.40

2014-11-14 23.57.44

2014-11-14 23.58.49

2014-11-15 00.00.21

6. Slice, plate, and enjoy

2014-11-15 00.01.39

2014-11-15 00.14.05

2014-11-15 00.13.56

2014-11-15 00.14.11


Sous Vide Supreme Demi Water Oven, Black, SVD-00101

Waring Pro PVS1000CGB 1-Gallon Pistol Vac Reusable Bags, 24 Count

Waring Pro PVS1000 Pistol Vac Professional Vacuum Sealer System

Rust (game) – AutoHotKey Script – Click Middle Mouse to Run

In the video game, “Rust“, if you want to run you have to hold down both the SHIFT key and the W key at the same time. This has the unfortunate effect of causing hand cramps for certain people, so I whipped together this little AutoHotKey script so those people can simply hold down their middle mouse button to run:

To use this script, you will need to install AutoHotKey, then copy and paste the script into a text file. Save the text file on your Desktop as “rust_middle_mouse_run.ahk”, then double click on it to run it.

Alternatively, if that sounds like a lot of work, you can just download the compiled AutoHotKey script as an executable file, by clicking here (rust_middle_mouse_run.exe).

After launching the rust_middle_mouse_run script, you will have a green “H” icon in your system tray (where the script can be toggled on or off), and when you are playing Rust, your middle mouse button will now make you run!

How to Re-run RSpec Tests Again After Failures

In the course of working with Selenium and Appium via RSpec tests (while testing iOS apps), I occasionally was running into issues where Appium would lose its connection with the iOS simulator and the RSpec test would fail.

The test failures had nothing to do with the iOS app itself, or even with the RSpec tests. The problems existed somewhere between Selenium, Appium, and the iOS simulator. Something would just randomly break on one of those layers, and my code’s connection to the iOS simulator would essentially be lost. The only way to fix this problem is to manually close the iOS simulator and re-launch it via Appium. After that, all the RSpec tests would proceed merrily along their way without problem… or at least until Appium glitched again.

As you can imagine, with a large test suite, this can be rather annoying. If the driver glitches halfway through, you end up having to reset everything and re-run the entire suite from scratch.

This made me wonder… Would it be possible to catch the random driver errors and random Appium glitches, then programmatically reset the iOS simulator and re-run the failing test?

I did a bit of research and came up with a solution, which I will share here. Hopefully someone out there will get some benefit out of it:

spec_helper.rb (partial):

Essentially, what we are doing is running each RSpec test inside of an “around” block, and if the example fails for some driver-related reason, we reset and retry (up to three times) before moving on to the next test in the suite. Nifty, eh?


01/30/2015 – Update to account for recent rspec changes

There have been some recent changes to the way how rspec handles examples and exceptions, so I have updated my code accordingly:

Golden Bubbles

Just because something is finite or rare doesn’t necessarily make it valuable. That’s a classic mistake people make when talking about currency.

Something has “real” value when it meets an actual human need or a desire.

Food and water, for example, have “real” value, because you would die without them. Shelter from the elements (such as a house) may also have some degree of “real” value (although much of what people refer to as “shelter” is mostly them flaunting their social status in the form of unnecessarily large houses). Land has “real” value because you can do things with it (growing food, building shelter, etc).

Gold has been seen as having value for millennia because of its inherit usefulness. For starters: It’s a very malleable metal which is resistant to oxidation and corrosion. It’s also shiny. This makes it ideal for making jewelry. Where there are people, there are always going to be people who want to show off their social status, and rare jewelry has a way of fulfilling that social need.

In the modern era, however, gold is a little less useful. We have all sorts of composite materials and advanced metals that are perhaps just as functional as gold for many purposes.

So much of the world’s gold supply has been hoarded up in vaults and is not even being used for anything anymore. The fact that the average person can get along just fine without it in their everyday lives (and yet the price is insanely high) means that the value of gold is currently suffering from a giant perception bubble. People think it’s worth more than it actually is, and because it’s rare, the price goes up, and since the price keeps going up, people want to buy it as an investment vehicle, and so the price keeps going up, and so people want to buy more, and it’s basically just a cycle that feeds on itself.

Plus, there are all the people who currently own gold and want the value to keep going up, so they are constantly going out of their way to tell people just how valuable gold is (and how it’s a foolproof investment). For the longest time, all you had to do was listen to any major talk radio station and you would hear countless ads about how you should “invest” in gold and blah blah blah.

In my opinion, the price of gold in the past couple of years has basically just been a giant bubble that demonstrates humanity’s greed and complete inability to assess the true value of things.

You can ride these sorts of bubbles for a while, but they will eventually always crash.

Resources for Learning Ruby & Ruby on Rails

Over the past couple of months, I’ve been “hitting the books” pretty hard when it comes to Ruby and Ruby on Rails. Here are a number of resources which I have found to be useful and would recommend to other Ruby newcomers:

Tutorials/Guides and Documentation:

Screencasts, etc:

Good programs to code with:


Sublime Text 2

Github Tools:

Tower (mac)

Console Tools:

iTerm 2 (mac):

I highly recommend zsh (used in conjunction with prezto) for your shell

Piping find to cp to recursively copy files

I have a bunch of font files organized within nested folders (along with all sorts of other stuff like text files).

I want to copy *just* the .ttf font files from within all of the folders. They need to be copied to a flat folder on my desktop that is named “Font Folder” (with spaces).

This turned out to be a lot more difficult than I originally anticipated, due to the fact that some of the files had spaces in their names. None of the guides or forum posts I found would work. I must have tried ten different “solutions” before I finally figured this one out. The key, as it turned out, was to enclose the {} in quotes:

find . -maxdepth 3 -type f -name \*.ttf -exec cp "{}" "/Users/tchapin/Desktop/Font Folder" \;

For All The Redditors Out There

On, there’s a phenomenon known as the “Cake Day“, which is the yearly anniversary of a member’s original sign-up date. When this magical day rolls around, a little cake icon appears next to your name, and people usually tend to be more generous with their up-votes towards your content.

Unfortunately, if you are a member of, you will probably notice that it’s actually rather difficult to determine the exact date of your “Cake Day” (unless you actually marked your calendar when you created your account). Instead of showing your actual, exact sign-up date on your profile, Reddit just tells you a vague figure something along the lines of, “you’ve been a member for 10 months”. The actual day is hidden, which means that the only way to know if it’s your cake day is to log in every single day that month, post a comment on something, and look for the cake icon to show up.

I got to thinking, and I realized there had to be a better way! Surely the sign-up information for a member could be found somewhere and exposed?

Sure enough, I tracked down a dynamic JSON file on the Reddit servers which could be accessed remotely. The JSON file path is: (where you can replace “johnsmith” in the URL with whatever user you were trying to look up).

This JSON file contains a number of information items about the particular user, one of which is titled “created_utc” and happens to be a Unix timestamp (a date format which uses the number of seconds since the Unix “epoch”, or January 1, 1970, to represent an exact point in time). PHP has a number of built-in functions which can easily translate Unix timestamps into human readable formats (such as Sunday, October 31, 2010, at 22:54:24 UTC), and PHP also has some nice built-in functions for grabbing and parsing remote JSON files.

Using all of this knowledge, I whipped together a quick tool for looking up reddit user information (including their exact Cake Day). This web-based tool is free to use and can be found at

Ideas for Potentially Solving Highway Traffic

1. Variable brake lights that inform following cars as to how light/heavy you are actually pressing your brake pedal.

2. Sensors on the front of the car which monitor how closely you are following the car in front of you. When this information is combined with your current speed and the knowledge of average braking distances and human response time, a buzzer or dashboard light could notify you to increase your following distance.