Setting up a Git repo at Dreamhost

For some of the items I’m tinkering with lately, I’ve decided to have an offsite, secondary git repository. I followed the directions from this Dreamhost Wiki page to get everything up and running.

For the impatient among you (like myself), here are the absolutely essential parts:

?Download gitsetup.txt
# Setup SSH keys
[local ~]$ ssh-keygen -t rsa
[local ~]$ ssh-copy-id [user@]host
[local ~]$ eval `ssh-agent`
[local ~]$ ssh-add
# Create the local repository
[local ~]$ cd project
[local project]$ git init
[local project]$ touch .gitignore
[local project]$ git add .
[local project]$ git commit
# Create a bare remote repository
[local project]$ ssh [user@]host
[host ~]$ mkdir project.git
[host ~]$ cd project.git
[host project.git]$ git --bare init
[host project.git]$ exit
# Push to the remote repository
[local project]$ git remote add origin ssh://[user@]host/~/project.git
[local project]$ git push origin master
[local project]$ git branch --set-upstream master origin/master
# Clone from the remote repository (optional...from another machine)
[other ~]$ git clone ssh://[user@]host/~/project.git

Setting up VirtualBox Guest VM Server Networking via NAT

I recently took Atlassian up on their Starter Pak deal to help manage some personal projects I’m hoping to kick off. I’m a big fan of their work, and their entire suite has performed extremely well for us at work for the last 3 years.

While I could run the software directly off of my iMac, my preference (and the environment I’m ultimately most comfortable in) is to run them under Linux. To accomplish this, I downloaded the latest version of Xubuntu and installed it within VirtualBox for OS X. Being the lazy man that I am, I did a plain-vanilla VirtualBox install.

After a quick apt-get to install OpenSSHd (and trying to connect via the host OS back to the guest), I realized that the default network settings would not allow me to see back into the guest OS (Xubuntu) from the host (OS X) (The other way around works fine, btw).

The VirtualBox documentation presents a few different ways to resolve this (NAT, Bridged and Host-Only). Once again, I decided to take the path of least resistance…which is to do simple port-forwarding from the host OS to the guest OS. The result is that when a resource is requested on host OS port, it just forwards the request to the mapped guest OS port.

I have 3 primary services that I’m looking to forward: SSHd (22), Apache (80) and Tomcat (8080)….so my mappings look like this:

Host OS Port 2222 –> Guest OS Port 22 (SSHd)
Host OS Port 10080 –> Guest OS Port 80 (Apache)
Host OS Port 18080 00> Guest OS Port 8080 (Tomcat)

When VirtualBox is installed, it places a few command line utilities on the host OS. The command that is needed to setup port-forwarding is VBoxManage. There are 3 values that must be set for port-forwarding to work: Protocol, HostPort and GuestPort. Below are the commands I executed to setup SSH port-forwarding:

VBoxManage setextradata "Xubuntu"
  "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/Protocol" TCP

VBoxManage setextradata "Xubuntu"
  "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/GuestPort" 22

VBoxManage setextradata "Xubuntu"
  "VBoxInternal/Devices/pcnet/0/LUN#0/Config/guestssh/HostPort" 2222

The value “guestssh” is somewhat arbitrary…it just needs to be the same for all 3 values. The other difference you might have is if you have chosen a different virtual network adapter (pcnet) when you setup your VM. When in doubt, check the VirtualBox documentation.

That’s basically it…just rinse and repeat for any other services that you want to run on the guest OS and have visible from the host.

Setting up Haskell on OS X

I’m currently on a mission to get my brain wrapped around functional languages. My guys at work have convinced me that Haskell is the way to go. A group of us have decided to purchase the book “Real World Haskell” and meet regularly to discuss our progress.

As with any new development endeavor, I needed to setup my environment. The Haskell folks make it fairly easy to get things going. Below are the steps I took to get a working ghci (The command-line Haskell interpreter).

  • Downloaded the GHC OS X package from here:
  • Realized that I hadn’t read the documentation correctly and overlooked the fact that a prerequisite was to have XCode installed. So I hopped over to ADC and grabbed the latest iPhone SDK (which includes the latest XCode).
  • That should have basically been it, but since TextMate is my preferred editor on OS X, I sought out a Haskell bundle for it. Much to my chagrin, I would have to kick up my nerd action a step and check out the bundle via Subversion. The current SVN URL for the bundle is: It turned out to not be that big of a deal…they have pretty good documentation on the TextMate site. As luck would have it, they used the Haskell bundle as the canonical example (see Section 5.7).

That’s it. Now I can actually get my functional language geek on.

Git on OS X Quickstart

I’ve actually been doing a little coding lately, thanks to an upcoming language shoot-out at Lambda Lounge in May.  I’ve almost got my first (only quasi-groovy) implementation complete and before I start on any refactoring, I figured it was a good time to get my version control on.

Since git is the new scm hotness, I figured I should give it a whack.  What follows is my extremely basic “just-get-me-going” instructions for OS X.

Step 1: Get git for OS X.  This is a binary release for OS X Leopard.  As of this writing, the latest version is

Step 2: Do your normal OS X install action on the downloaded binary.

Step 3 (Optional): Download GitX if you want an OS X native git GUI.

At this stage in the game you should be good to go.  Now it’s just a matter of creating your local git repo for your project. To do that, just cd to your project’s directory and type:

git init

Next, you’ll want to add everything in that directory into your local repo by typing:

git add .

Lastly, just commit it all…

git commit -m 'This is my first commit...blah, blah'

That should have you rockin’ for initial commits. The next thing I did (and which is completely optional) was to push my local repo up to my free (and therefore open source) account on github.

Once you create an account (and share your SSH public key) on github, you can then start creating projects. I created my “Vending Machine” project, then followed their directions to push up my local repo. I just entered the following commands:

git remote add origin
git push origin master

A nice cheat-sheet on basic git commands can be found here.

More rsync’ing action

I’ve been doing some (light) development lately at night.  Depending on my mood, sometimes it will be from my desktop Mac, other times from my MacBook Pro.  I wanted to keep everything in my ~/Development directory in sync, so I figured I would whip up something hacky with rsync.

One of my main criteria was that I didn’t want the syncing process to keep around old files from one machine and copy them to the other.  To get around this, whenever I rsync from one machine to the other, I pass the –delete flag to the operation.  This can be dangerous…so I’m very careful that whenever I do a one-way sync (either “push” or “pull” in my parlance), I’m confident I’m not clobbering needed files on the target system.

I have 2 scripts that accomplish this:

The first one is my “pull” script.  This will pull all changes from the remote machine to my local machine.


# "Pull" changes from remote machine directory to target directory on
# local machine.
# This will destroy any changes in target directory on local machine not
# present on remote machine.
# Sync via ssh and compress the files over the wire
rsync -avz -e ssh --delete eric@lenny.local:~/Development/ /Users/eric/Development

The second script is my “push” script.  Basically the same as above, but in reverse.

# Sync the local directory to the remote server, this will "PUSH" the
# changes from local,
# destroying any changes in target directory on remote machine.
# Sync via ssh and compress the files over the wire
rsync -avz -e ssh --delete  /Users/eric/Development/ eric@lenny.local:~/Development

So there you have it.  Pretty basic pushing/pulling (remote mirroring) of files with rsync.

Moving closer to the cloud

The first time I used Google Maps (almost 4 years ago?), I clearly remember thinking “This is the start of moving applications off the desktop and into the browser”.  Since then it appears that we’ve made slow, but steady, progress in that direction.

email, in my opinion, is an application that makes the most sense “in the cloud”.  That being said, there are benefits to having some level of desktop integration: keyboard shortcuts, alerts, pretty icons to click on, etc.

I’ve played with a couple of applications today that fuse the GMail web interface w/ thick client functionality on OS X.  They are MailPlane and Fluid.

MailPlane is specifically written to work with GMail only.  The level of integration they have is quite astounding: Drag’n'Drop attachments, email-friendly (from the KB-perspective) photos straight from iPhoto, Growl notifications, hot key support and many others.  I used it for the better part of the day, and liked it quite a bit.  The only downside (which probably isn’t much to most folks) is that it costs $25.

Fluid, on the other hand, is not written specifically for GMail.  It creates “Site-Specific-Browsers” for any web app you like.  It also allows for extension via User Scripts (I think it has some relationship to GreaseMonkey…but I haven’t dug deep enough yet).  In very little time, I was able to customize my new to integrate with Growl (desktop notifications on OS X) to alert me anytime a new mail arrived.

I like where they’re going with Fluid.  Right now, GMail is the only “app” that I spend a significant amount of time in (basically occupies a browser tab 24/7).  I could see Google Calendar or Google Docs getting their own Fluid app on the Danker-desktop in the near future.

For now, I think I’ll stick with Fluid over MailPlane.  I’m mostly looking for alerting of new messages and the little “badge” that tells me how many new messages I have on my dock icon…both of which are accomplished with Fluid.  That being said, if you’re a GMail power-user, MailPlane is likely money well spent.

Reasons I cannot ditch Firefox

I’ve been a loyal Firefox user since the “Pheonix” days.  Throughout Firefox’s existence, it has seemed (to me) the brower’s greatest strength was also it’s downfall…plugins.  I’m a plugin (extension, add-on, whatever you may call it) junkie.  But it seemed that once I had Firefox loaded up with a dozen or so of my favorites, it started to get “wonky”, as a co-worker of mine would describe it.

Since I made the switch to OS X over the past year, I’ve noticed that Firefox doesn’t zip along quite as fast on OS X as Safari does.  So over the past few weeks, I’ve been trying to use Safari more…but it just hasn’t worked out.  Safari seems to be the antithesis of Firefox when it comes to customization/extension.  Yes, I’m aware of PimpMySafari, but it feels forced due to the lack of proper extension support in Safari.

The 3 features I seem not to be able to live without are:

If anyone is aware of drop-in replacements for the 3 features listed above for Safari, please leave comments below!

2009 Technical Resolutions

I began putting my personal 2009 Resolutions/Goals to paper today and by the time I was done found out that a good chunk (> 50%) were technology related.  I figure that I should make them public so that if nothing else, I feel just a little more pressure to not sluff them off.

The main focus for 2009 is learning new languages.  It’s all the action that I’ve seen develop over the past 2-3 years, but haven’t made a priority to learn given that at work I’ve moved out of being a developer and now manage developers (boo…hiss…).  So here they are, in order (with completion* dates for each):

* – I’m defining “complete” in that I should be able to do all of the following:

  • Give a 15-30 minute presentation on it
  • Write a small-ish app
  • Be comfortable enough with the language that if I needed to start a project, I would be able to hit the ground running in the language
  • Be able to intelligently decide where/if a certain technology/language could fit in our current exclusively Java environment.

If anyone has good book, site, newsgroup, etc recommendation, please let me know.

Getting Started with Textmate (and Groovy)

After attending last week’s inaugural Lambda Lounge meeting, I’ve had a renewed determination to get my Groovy/Grails learning on.

I had previously bought Scott Davis’ Groovy Recipes, and while that book is pretty awesome, I often felt like I didn’t have a good enough base in the Groovy language to realize the full potential of the material presented.

So this weekend, I went back to the Pragmatic Programmers website and picked up (in PDF form) Venkat Subramaniam’s Programming Groovy.  I’m not too terribly far into it, but so far it feels like I’m getting eased into the language quite well.  The table of contents also gives me comfort that a solid treatment of the language is to be had.

One of the first topics covered after installation of the Groovy binaries is choice of text editor or IDE.  For OS X users, TextMate is mentioned, along with the optional TextMate Groovy Bundle, created by Graeme Rocher (Grails Lead).  I also happen to be fairly new to OS X and therefore TextMate…but it seems like everybody who’s anybody uses it, so it must be good.

I was told very early in my career to pick a editor and stick with it.  The amount of mental energy that must be expended to keep all the different keybindings/macros/shortcuts in your head will detract you from the job at hand.  So I try to pick a side and just stick with it (sorry emacs).  This is most likely the reason I won’t move off of Eclipse anytime soon.  Back in the day, I could cruise around Eclipse pretty well…not as good as this guy, but pretty well.

Now that I’m exclusively Mac at Danker HQ, I feel pretty confident immersing myself in TextMate.  So with my new direction charted, I set out to put my Groovy learnin’ on the back burner for the afternoon and get my feet wet with TextMate.

After downloading the Groovy Bundle, I was a bit confused by the directions on the site, so I took a look at a blog posting by Jason Rudolph (check out his excellent tutorial on beginning Grails development).  His take was pretty much the same…so I ended up just double-clicking the 2 bundle files and TextMate automagically installed them into the proper directory.

Next up was a small tweak that Venkat mentioned on his blog.  This allows the output of your program to be shown as a tooltip instead of a pop-up.  Nothing big…but a nice tweak nonetheless.

I’ve probably got the most mileage out of this article.  Does a nice job explaining what makes TextMate special.  For reference, I assume the TextMate manual will come in handy.

The one area I haven’t explored yet is the TextMate book on the Pragmatic Programmers website.  If anyone has bought this book and found that it offered value above what’s freely available, please let me know.

Now that I’ve got my head wrapped around this new editor and have expanded my text editing bag-of-tricks, hopefully I’ll be able to keep my mind focused on the new goal of grokking Groovy.

Cheap backups with Dreamhost + rsync

In my last post (I know, it’s been a while), I was gushing about how my hosting provider ( was allowing 50GB of disk space for personal backups included with basic hosting plans.

The excitement was a bit premature at the time, because they only allowed backups via FTP. It instantly became problematic to regularly backup anything of significant size (i.e. 30 GB of MP3s) due to my lack of knowledge of doing incremental backups over FTP. If only they would allow rsync over ssh.

Apparently I was not the only person thinking this because the dorks of the internet united, Dreamhost listened, and today I got the monthly newsletter letting me know that rsync, scp and sftp were enabled….Sweet!

So I got crackin’ tonight on my new solution, which is thus:

1. Super-simple backup script (


# Sync the local directory to the remote server, limiting the
# upload bandwidth to 10KBps
# Sync via ssh and compress the files over the wire
rsync -avz -e ssh --delete --bwlimit=10 /Users/eric

2. Setup ssh keys so I can run the above script via cron..

lenny:~ eric$ ssh-keygen -t rsa

After typing the above in, I hit enter twice to accept the default directory for the keys and to choose a password-less key

Then I just copied the last (or possibly only) line from .ssh/ on my local machine (lenny) to the .ssh/authorized_keys file on the remote machine (

3. Test!

4. Setup the whole mess via cron, as noted in my previous post.