– we create awesome web applications

Lately, my prefered Postgres distribution of choice for OSX is Postgres.app.

Its very easy to download and install (just drag-n-drrop, like most other OSX Apps), no need to wait for it to compile, and it comes with a nice menubar icon for control.

In its default configuration it only listens on a port, but not on a unix socket. The problem is, Rails recipes with postgres create a config/database.yml file that assumes a socket presence.

Of example:

✗ rails new test1 -d postgresql
      create  README.rdoc
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
✗ cd test1
✗ rake db:create
could not connect to server: No such file or directory
        Is the server running locally and accepting
        connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?

This problem was bothering me for a while as I tried to use rails_apps_composer to bootstrap new applications and it was failing on those database errors.

I didn’t want to mess with Postgres.app configs, as I suspected they’d be overwriten on each version upgrade, so at first I tried to somehow trick it to stop and let me replace the config/database.yml file in time. The solution turned out to be much simpler though.

The Rails Postgres driver recognizes standard Postgres environment variables, one of which is PGHOST. When set to localhost Rails will go for the port instead of the Unix socket, even if there is no host: localhost setting in the YAML file.

✗ PGHOST=localhost rake db:create
✗ _

So just add export PGHOST=localhost to your shell start file, e.g. ~/.zshrc and you are set.

Im actually went further with it, and now I have shell aliases to reset postgres env config, configure it for localhost, or read current application Heroku configs and pre-set Postgres environment for a direct access to Heroku db, but that is a topic for another blog post.

A while back Vitaly wrote a post about LaunchBar. One of the feedbacks we got was to try out Alfred.

After checking it out we switched.

Alfred is an app launcher and then some for OSX. In the version 2 released not that long ago they added brilliant feature - possibility to create your own workflows using nice and simple UI and share them with everyone.

The one workflow I find particularly useful is the Alfred Github Workflow.

The instructions to download and install are provided at the Github page linked above. Once installed you will be asked for your github credentials. The password is not stored, instead the they store your github session cookie.

It’s activated with gh command and you get the list of your repos. Looks like that:

Github workflow

Once you choose one of the repositories you get a list possible actions:

Github workflow repository commands

And that about it. Basically, together with Alfred’s fuzzy filtering and always being a keystroke away, it gives me a fast and convenient way to access any of my github repositories.

About half a year ago Vitaly posted a post about how simple it is today to use ruby patches bundled with rvm installation to dramatically reduce big rails app loading times and make your dev environment a much happier place.

Since then Ruby advanced with new patchlevels and there are new patches to use, so let’s go over this once again.

First, we start with upgrading the rvm to latest and hopefully greatest

rvm get head

Since Vitaly wrote his post it seems that the railsexpress patch superseded the falcon one. At least that what i got from browsing over the patches repository.

So, next step is to compile our Ruby version with railsexpress patchset applied

rvm install 1.9.3-p392-railsexpress --patch railsexpress

Ok, now for some trivial benchmarking to ensure we made things better and not the other way around. Now, note that the say in the interwebs goes that the bigger your application and amount of gems it has to load the more happy you will be. Also, the usual disclaimer about those performance things, YMMV.

I took a random application from my dev folder. It loads 147 gems. Let’s check out some numbers

✗ rvm use 1.9.3
Using /usr/local/rvm/gems/ruby-1.9.3-p392
✗ time rails runner "puts :OK"
rails runner "puts :OK"  16.28s user 1.70s system 98% cpu 18.185 total

✗ rvm use 1.9.3-p392-railsexpress
Using /usr/local/rvm/gems/ruby-1.9.3-p392-railsexpress
✗ time rails runner "puts :OK"
rails runner "puts :OK"  8.56s user 1.22s system 99% cpu 9.820 total

Just to make a comparison to the previous blog post, here are the numbers for the same application with ruby 1.9.3-p327 with falcon patches set:

✗ rvm use 1.9.3-p327-falcon
Using /usr/local/rvm/gems/ruby-1.9.3-p327-falcon
✗ time rails runner "puts :OK"
rails runner "puts :OK"  9.89s user 1.34s system 98% cpu 11.374 total

So, comparing to falcon patches it’s not that big of an improvement, but still, another 1.5 seconds win.

And yes, i know that both before and after times are slow. But still, i see a nice around 50% time save on any environment loading. And what i really like is that this improvement demanded the whole 7 minutes of my time.

I just recently reinstalled my MacBook Pro, this time with Snow Leopard.

So I’m again going through various installation problems I already forgot about from few years back when I installed Leopard.

Anyway, just had to hunt down a problem with mysql gem installation on Snow Leopard.

Apparently if you just do ‘gem install mysql’ it seems to install fine, but doesn’t work.

You get “uninitialized constant MysqlCompat::MysqlRes” error when trying to run rails.

The solution is to pass it some arguments for installation:

ARCHFLAGS="-arch x86_64" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config

Oh, and of course install 64bit mysql version before that. I usually just download the binaries from mysql.com.

We just started a project for a client that involves Cassandra.

If you’ve been living under a rock and don’t know what Cassandra is let me tell you :)

Cassandra is a “second-generation distributed database” that was built for web scale.

Its is one of the many distributed nosql databases that appear everywhere lately like mushrooms after a heavy rain :).

What sets Cassandra apart is that it comes from a recognizable entity - Facebook.

But I digress.

This is not meant to be a Cassandra introduction, there are enough of those on the net. I Just created a new nosql section on this blog where I’m going to post various tidbits of information about cassandra (and probably others) as I learn them while working on this new project.

Here is the first one: Cassandra gem is just an installer

If you are on Mac OSX and interested in Cassandra you probably know that its just a gem installation away (almost):

gem install cassandra

First thing to note though is that this will not install Cassandra. It will install cassandra installer!

I got bitten by this when I took my laptop with me to my doughter’s dancing class. You see, parents are not allowed “in the room” to not interfere with the process :), so I have 45 minutes to find myself something to do each time. I installed cassandra gem at home and intended to play with Cassandra while there.

Not so fast.

When I tried to run cassandra_helper cassandra which is supposed to start a test cassandra instance it went to connect to a github repository to download and install the actual database.


and the 2nd one: Use java preferences

When I got back and finally built Cassandra I got the following message when starting it for the first time:

~ > cassandra_helper cassandra
Set the CASSANDRA_INCLUDE environment variable to use a non-default cassandra.in.sh and friends.
(in /Library/Ruby/Gems/1.8/gems/cassandra-
You need to configure your environment for Java 1.6.
If you're on OS X, just export the following environment variables:

First thing to note is that just typing JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home" in the terminal wont help.

You need to export it:

export JAVA_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home"

No need to export PATH as its already exported.

But there is a better and simpler way!

Start “Java Preferences” (find it in /Applications/Utilities, or just use spotlight):

Java Preferences: Java 6 2nd

Then reorder the entries in the bottom “Java Applications” section so that Java 6 will be the 1st:

Java Preferences: Java 6 1st

Now cassandra starts right away w/o any exports:

~ > cassandra_helper cassandra
Set the CASSANDRA_INCLUDE environment variable to use a non-default cassandra.in.sh and friends.
(in /Library/Ruby/Gems/1.8/gems/cassandra-
CASSANDRA_HOME: /Users/vitaly/cassandra/server
CASSANDRA_CONF: /Library/Ruby/Gems/1.8/gems/cassandra-
Listening for transport dt_socket at address: 8888

Cool, now go write your killer application!

I just did something pretty stupid. I edited /etc/sudoers file directly from within my non-root user account.


RRDtool is the OpenSource industry standard, high performance data logging and graphing system for time series data. Use it to write your custom monitoring shell scripts or create whole applications using its Perl, Python, Ruby, TCL or PHP bindings.

Let’s run it with Ruby on Leopard.

sudo port install rrdtool

Default ports installation comes without ruby bindings.


Thanks a lot to Amit Hurvitz for providing a file of Virtual Disk Image (VDI) of VirtualBox, containing an up and running JRuby on Rails on Glassfish with Mysql. Image also contains some examples (actually solutions to the code camp exercises), all running on top of an OpenSolaris guest OS (can be run on many host systems).

Grab the image ~1.5GB archive.

Grab the exercises ~9.7MB archive.


We recently moved our DNS to dnsmadeeasy.com from godaddy.com name servers.

After the transfer some internal CNAME records had a problem. So after fixing the problem and checking in the terminal that the changes propagated to the DNS server (host xxx.astrails.com) I tried to type the address in the browser, but it kept giving me the “can’t find host” error.


We participated in JRuby on Rails with GlassFish Code Camp hosted by Sun Microsystems Inc. I was speaking about the framework in general trying to infect Java developers with Ruby On Rails. Slides are available.

Amit Hurvitz gave exciting presentation about GlassFish and short introduction into DTrace. Find out more details about the Code Camp.


Recently we looked for video transcoding/hosting solution to use in one of our client’s projects.

The best thing we’ve found is Panda. It runs on Amazon stack of services including ec2, s3, and simpledb.

Using amazon has many advantages. no contracts, pay as you go, easy and fast scaling in case your site explodes :)

Unfortunately the image that is refered in the Getting Started (ami-05d7336c) is not safe for production - it has openssh version with a serious security bug, but don’t worry, we will explain how to fix it.


This blog-post is mostly targeted at non-Rails developers. Rails devs should know all this by heart :) Many times we need to explain to our customers what is ‘proper deployment’ and why their current one sucks :) Now we’ll be able to just point them to this post…


We really like Debian and we usually use the current “stable” distribution for our production servers.

It all works great with one little problem: if you need very current soft it is probably not in the ‘stable’ yet.

The current Debian stable (“etch”) includes rubygems 0.9.0-5 which is way too old.

We needed to upgrade to at least 1.2.


Once again I’ve hit a problem of installing gems on a machine with very little memory.