Ylan Segal

Conway's Game of Life

I recently read a blog post recently about Conway’s Game Of Life: Since I had not written an implementation myself, I decided to give it a go.

It was a fun exercise. I did not use any external library other than ruby’s stdlib and used TDD for most of the classes. The interface uses curses. Not knowing how to test it, I took a page from Gary Bernhardt in Functional Core, Imperative Shell and didn’t test the shell at all :)

Here it is: My Take on Conway’s Game Of Life

Testing With Multiple Ruby and Gem Versions

I found myself writting a gem for internal use that needed to run in several different ruby versions and MRI. In addition, the projects that it would be used in had other dependencies which also meant that it would need to function with different versions of dependencies. Here is how I ensured I was testing all scenarios.

Unicorn vs. Puma: Redux

UPDATE: The benchmarks have been updated for new versions of ruby, jruby, puma and unicorn


Previously I wrote about the difference in performance between using thin, puma and unicorn on heroku’s cedar stack. At the time, heroku’s recommendations where to use thin as a server. They now recommend unicorn for better performance and concurrency.

Additionally, I received some very valid criticism on the previous benchmark: Puma is designed to be used on a ruby implementation that does not have a Global Interpreter Lock: Namely Rubinius or jRuby. With that in mind, I decided to test again.

Forget Vim: Learn Your OS' Shortcuts for Productivity

I follow a certain number of ruby-related blogs and have noticed regular of calls to use Vim as an editor, usually with claims of unbridled productivity to follow. One one hand, I see the appeal: I use a bunch of UNIX tools and scripts in my daily work-flow and it makes sense to use a editor that works inside my terminal. I have tried a few tutorials, screen casts and what not, but I have never felt really comfortable. Something has always been off. I always assumed it was due to the big learning curve others talk about.

On the other hand, when I switched from TextMate to Sublime Text, there was almost no drop in productivity. Part of it has to do with similar functionality being mapped to the same keys, like command-t. However, I believe that there is more to it.

Faster Rspec: jRuby, Spork, Nailgun and Bundler Binstubs

I recently discovered that bundler has a feature to create binstubs, so I decided to redo my benchmarks of running a single pending spec (but including the complete spec_helper for my project).

To create rspec binstubs:

1
$ bundle binstubs rspec-core

Here are my findings:

Description Command Avg. Time (3 runs)
Bundled Rspec bundle exec rspec 61.76 s
Binstubs bin/rspec 50.24 s
Binstubs + Spork bin/rspec –drb 17.43 s
Binstubs + Spork + Nailgun jruby –ng -S bin/rspec –drb 6.65 s

It is still slower than I would like, but well worth the effort. Since I didn’t want to remember the specific invocation depending on what I have running, I have a script that will use binstubs, nailgun and/or spork if available:

smart_rspec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /bin/bash

# Looking for binstubs
if [ -f ./bin/rspec ]; then
  RSPEC="bin/rspec"
else
  RSPEC="bundle exec rspec"
fi

NAILGUN_PORT=2113
SPORK_PORT=8989

# Looking for nailgun
lsof -i :$NAILGUN_PORT > /dev/null
if [ $? == 0 ]; then
  RSPEC="jruby --ng -S $RSPEC"
fi

# Looking for spork
lsof -i :$SPORK_PORT > /dev/null
if [ $? == 0 ]; then
  RSPEC="$RSPEC --drb"
fi

CMD="$RSPEC $@"
echo $CMD
$CMD