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:

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

Firefox 6.0 – Gray Colored URL in Address Bar

If you have upgraded to Firefox 6.0 recently, you might have noticed a change in your URL address bar.

Now, instead of the web address being in all black like you might have grown accustomed to over the past 10 years, the powers that be have decided it would be better to color all of the URL gray (except for the primary domain name, which still appears in black).

Firefox 6.0 Address Bar

I can see how this could be helpful to the ignorant masses who get scammed by phishing emails, but I’m a relatively intelligent internet user, and I have been browsing the net long enough to know what the primary domain name is in the URL without needing to have it colored different.

If you are like me and wish to set the address bar colors back to the way they used to be in prior versions of Firefox, simply follow these easy steps:

  1. In your Firefox address bar, type “about:config” (sans quotes), and press enter.
  2. In the filter search box, enter “browser.urlbar.formatting.enabled
  3. Right-click on the “browser.urlbar.formatting.enabled” line item in the listing and select “Toggle” to switch it to false

Firefox 6.0 Address Bar - about:config

Facebook Authentication and a Potential Security Risk

The idea of a “universal login” is not new by any means. Since the early days of the internet, many people have longed for the ease of having to only remember one login and password to access all of their favorite member-based sites.

Over the years, there have been a number of companies/organizations that have tackled this problem, and recently a couple of solutions have bubbled to the top in popularity. OpenID, Google Friend Connect, MySpaceID, and even the Twitter Login API have all been used as “universal login” methods which can be integrated with a web site.

None of these solutions, however, have even come close to the adoption rate boasted by the Facebook Authentication system. Practically everyone has a Facebook account these days, regardless of age, gender, education level, location, favorite web browser, email address, or internet provider! Facebook embraced this fact and built a nicely packaged authentication system which enables developers to integrate Facebook Authentication into pretty much any app or web site they can imagine. You can now find the Facebook universal login method in everything from iphone apps and desktop applications, to normal run-of-the-mill web sites.

This brings me to my point: Potential Security Risks

While logging into my Facebook account via all the different web sites and various applications which I use on a daily basis, I became acutely aware of a glaring security risk with the Facebook Authentication system. Basically, the way how Facebook instills a sense of security is via a recognizable blue bar which has a gray bar and diagonal stripes underneath it. This familiar imagery is displayed whenever you are asked to provide your Facebook login information. The idea that is consequently trained and reinforced in end-users’ minds is that the familiar imagery represents a genuine Facebook login screen. As such, if you are being asked for your Facebook information in a login popup, but the unique blue and gray bar is missing, you would immediately suspect that something was wrong.

Notice, however, that the Facebook URL is nowhere to be seen in the login popup. There is literally no easy way to verify where the contents of the login form are actually going. This is especially true in the countless iphone applications and computer programs which are making use of the Facebook Authentication system. A rogue developer could easily create a form which displayed the blue and gray bar, but that actually transmitted the login information somewhere else entirely (such as a database on their own server) before it sent the information to Facebook.

The exact same thing could be easily accomplished by any semi-competent web developer with 15 minutes worth of spare time. All they would have to do is make a mock-up copy of the legitimate Facebook login popup, but have it submit somewhere else entirely. The end user wouldn’t know the difference.

In summary: Facebook’s way of instilling a *false* sense of security via their blue/gray bar is totally flawed and easily exploited. They need to come up with some sort of method which enables end-users to verify the form’s authenticity before they enter their login information.