TIP: How to Play a Sound Whenever You Commit to Git

Posted on June 12, 2013 by David Hilowitz

Writing code alone at home can be an isolating experience. There you are, day in day out, quietly making magic with your mind (sarcasm, obv.) only to silently commit the fruits of your labor into the void of your source control repository, appreciated by no one. If only a crowd of children could be retained for the sole purpose of cheering you on every time you complete something.

Amazingly, Brandon Keepers over at Collective Idea had the same exact same thought (almost; he was substantially less melodramatic in his blog post about it).  Anyway, here is what my version of his script looks like:


toplevel_path=`git rev-parse --show-toplevel`
afplay -v 0.1 $toplevel_path/.git/hooks/happykids.wav > /dev/null 2>&1 &

I put this in a file called .git/hooks/post-commit.playsound. I then trigger this from the main .git/hooks/post-commit script as follows:


toplevel_path=`git rev-parse --show-toplevel`

Where the post-commit.tweet script is the script from this blog post. If you aren’t also tweeting your commit posts, you’ll want to delete that line.

If you want this to work for every single Git repository from now on, add these scripts to your git-core templates. You’ll have to figure out where these are (it’s different for every setup). For my Mac, they’re located here: /opt/local/share/git-core/templates/hooks/post-commit.


TIP: Installing Ruby on Rails on Mac OS X 10.6.8

Posted on October 4, 2011 by David Hilowitz

1. Install XCODE 4. This is actually trickier than it seems. You have to:

a) download XCode;
b) run the .dmg.
c) quit iTunes, then go into Activity Monitor and force quit on anything iTunes related (iTunesHelper as well);
d) go into the Applications folder and find the “Install XCode” app, and run that. (Yes, you have to run a second Install XCode app…and I had to run it twice. It failed the first time. If you want to watch it fail, drop into Terminal and type this: tail -f /var/log/install.log.

2. Install MacPorts.

3. Test MacPorts by installing joe. Type:

$ sudo bash
$ port install joe.

Enter your password.

4. A bunch of things will be preinstalled with the wrong architecture. We’re trying to get ruby as an x86_64 architecture. So…uninstall libiconv and zlib (you may have to tinker with this a bit because it will ask you which version you want to uninstall — the answer is “all of them”)

$ sudo port uninstall -f libiconv @1.13.1_0
$ sudo port uninstall -f libiconv @1.14_0
$ sudo port uninstall -f zlib
$ port uninstall -f readline
$ port uninstall -f openssl
$ port uninstall -f ncurses @5.8_1
$ port uninstall -f ncurses @5.9_0
$ port uninstall -f ncurses @5.9_1
$ port uninstall -f gdbm

5. Install ruby by doing:

$ port install ruby

7. Update your gems:

$ gem update --system

8. And, finally, install Rails:

$ gem install rails --pre

Useful links:

TIP: How to make .htaccess files work on OS X 10.5

Posted on January 23, 2011 by David Hilowitz


To make .htaccess files work as expected, you need to edit /etc/apache2/sites-available/default. Look for a section that looks like this:

        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
                # Uncomment this directive is you want to see apache2's
                # default start page (in /apache2-default) when you go to /
                #RedirectMatch ^/$ /apache2-default/


You need to modify the line containing AllowOverride None to read AllowOverride All. This tells Apache that it’s okay to allow.htaccess files to over-ride previous directives. You must reload Apache before this change will have an effect:

sudo /etc/init.d/apache2 reload