Posts

The Special Offer Problem
A problem for the unsuspecting programmer. Makes for a great interview question.

ProTip: Automagically setup PhantomJS for Capybara+Poltergeist
This ProTip explains how to install PhantomJS automatically on program start. This way, running oneoff programs that exercise your web application becomes super easy.

How to do before(:all)/after(:all) in minitest
Minitest does not come with before(:all)/after(:all). For flat describe blocks, extension minitesthooks is the way to go. For nested describe blocks, minitesthooks may not behave as you want. This article provides two alternatives to minitesthooks for nested describe blocks and points to examples that you can run for 16 cases, 11 of them not covered here.

Correole: The minimum feature newsletter in Ruby
Correole is a minimum feature newsletter written in Ruby. Correole is ideal for a new blog when you just want to offer a minimal newsletter service. Correole plays nice with Heroku and only requires a confirmation page on the side of your blog.

Why does Heap's algorithm work?
Heap's algorithm for constructing all permutations is efficient and simple but not easy to understand. This article explains Heap's algorithm by example.

How to count cycles in a complete graph
An example of a question whose answer is an exponential function.

Arbitrage
Do you want to make easy money? Maybe currency trading is what you are looking for.

Release ActiveRecord connections in Sinatra + Thin
Are you experiencing database connection timeouts in your Sinatra + Thin + ActiveRecord application? Then you want to have a look at this.

Stacking Boxes
Finding a way to fit a given set of boxes one inside the other is easy even for more than 3 dimensions. Finding a way to fit those boxes by contorting them, not so.

Ecological Bin Packing
Group bottles with the least movements possible.

The Blocks Problem
Interpret a language of four commands to model the interaction of a robot arm with its environment. An exercise in keeping your solution simple.

The 3n + 1 Problem
A classical programming problem. The problem statement will tell you an answer, just not a fast one.

ProTip: Redirect stdout and stderr to console and different files in Bash
When you troubleshoot command execution, sometimes you need to analyze standard output and standard error side by side. Here is how to distribute output amongst multiple files and the console.

Jill Rides Again
Jill wants to know where to bike. Can you see past the straightforward solution to figure out the fastest solution possible?

The Captured Wise Men
Two wise men are prisoners in a tower in solitary confinement. Each holds half of an answer that would save their lives. Eventually, they put together the answer. But how?

The Adjacent Coins Problem
Choose a coin that maximizes your gain or minimizes your loss, but you have to do it in linear time and constant memory.