Skip to main content

Benjamin Oakes

Photo of Ben Oakes

Hi, I'm Ben Oakes and this is my geek blog. Currently, I'm a Ruby/JavaScript Developer at Liaison. Previously, I was a Developer at Continuity and Hedgeye, a Research Assistant in the Early Social Cognition Lab at Yale University and a student at the University of Iowa. I also organize, ICRuby, OpenHack Iowa City, and previously organized NewHaven.rb. I have an amazing wife named Danielle Oakes.

Filtering for the month April, 2014. Clear

Recipe: git bisect

by Ben

This post originally appeared on Continuity’s engineering blog. I’ve cross-posted it here for posterity.

Git ships with an awesome, underused utility called git-bisect. I had a bug to track down today that already had a spec, so it was a perfect fit. Normally our continuous integration (CI) service would have alerted us earlier, but unfortunately the failure was masked by another problem.



Prepare the test executable

In this case, I’ve called it private/ and filled it with this:

# Don't forget to `chmod +x` this file.
# You can add more steps here if necessary, e.g. installing dependencies.
rspec spec/services/my_service_spec.rb

Find the bad commit

I’m going to assume HEAD is a bad commit (meaning that the test executable fails).

Find a good commit

Go back a reasonable amount of time (e.g. make an educated guess, like 1 month) and find a commit that doesn’t fail the test executable.


After you have your good commit, just run a set of commands and git bisect will track down the source of the problem for you:

git bisect start $bad_commit $good_commit
git bisect run private/

Eventually, it will have bisected back to the source of the problem, producing output like this:

3f23680fefb5302c780ccc68b5d3006e9f37dd92 is the first bad commit
commit 3f23680fefb5302c780ccc68b5d3006e9f37dd92
Author: He Who Shall Not Be Named <>
Date:   Wed Apr 23 11:40:48 2014 -0400

    just change something small, no big deal... honest!

:040000 040000 088559324ff27ec7be6967e8c50934a9837b8f55 e7f89bede815904bb79d5b01807e4e01c8378f14 M      app
bisect run success

That first line identifies SHA 3f23680fefb5302c780ccc68b5d3006e9f37dd92 as the source of the problem, which was right in my case. Yay for automation!

Clean up

Now that I’m all done, I can:

git bisect reset

Git cleans up, and puts me back where I started.


Normally just running git show $first_bad_commit will reveal something useful. Tracking down the problem depends on the situation, of course. (Keep in mind that the “first bad commit” might not be the one you’re looking for.)

Good hunting!



Sleeping longer during business hours

by Ben

This is just a simple trick to sleep longer during business hours. Useful if there’s a long running task that needs to avoid hammering a resource (e.g. a shared database) during the day, but not during the night.

sleep (7..18).include?( ? 3 : 0

The Internet’s Telltale Heartbleed

by Ben

The Internet's Telltale Heartbleed : The New Yorker.

This is by far one of the most approachable and accurate descriptions of Heartbleed that I’ve seen. Definitely worth reading if you keep wondering what this thing is.

Vegetable Gardener Videos

by Ben

Video: Planting Out – Vegetable Gardener Videos.

I’m getting ready to move some plants I started inside out to our yard, so this video was helpful. They have a lot of good information in their video series. Here’s a quick list:

Also, it looks like they’re somewhere in southern Connecticut, which was a funny coincidence, since I used to live there.

First Look – AWS WorkSpaces

by Ben

First Look – AWS WorkSpace.

My comment:

I keep wondering if they’ll try a Linux-based desktop for certain use cases. It could be offered for a cheaper price, perhaps.

Hard to say if it would happen, but it would fit in with Amazon’s previous AWS offerings. Definitely good to start with Windows, however.

The New Rubygems Index Format

by Ben

The New Rubygems Index Format.

Should hopefully improve Rubygems installation time. I’m a bit amazed Marshal was used for so long.

Multi-line Memoization

by Ben

Multi-line Memoization.

Memoizing with Ruby’s ||= is ugly when there’s more than one line of code.  The kind folks over at Viget Labs shared this trick:

def foo
  @foo ||= begin
    arg1 = expensive_method_1
    arg2 = expensive_method_2
    expensive_method_3(arg1, arg2)

How did I not already know about this? What a readable solution.