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: http://hackage.haskell.org/platform/
  • 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: http://svn.textmate.org/trunk/Bundles/Haskell.tmbundle/. 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 1.6.1.3

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@github.com:danker/vendingmachine.git
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.

#!/bin/bash

# "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.

#!/bin/bash
# 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 since “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 Gmail.app 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 (dreamhost.com) 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 (offsiteRsync.sh)

#!/bin/bash

# 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 b159xxx@backup.dreamhost.com:~

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/id_rsa.pub on my local machine (lenny) to the .ssh/authorized_keys file on the remote machine (backup.dreamhost.com)

3. Test!

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

OS X Cron Coolness

I just found out today that my webhosting provider, Dreamhost, is now officially adding 50GB of storage to each hosting account to be used as offsite backup for free (well, technically included with the cost of hosting)!

I figured that was a sign that I should get off my butt and setup a cron job that would tar/gz files on my home server (where the important stuff resides) and send it over to my Dreamhost acct on a monthly basis.

Cruising through the OS X cron man page, I saw this little gem:

Instead of the first five fields, one of eight special strings may appear:

           string          meaning
           ------          -------------------------
           @reboot         Run once, at startup.
           @yearly         Run once a year, "0 0 1 1 *".
           @annually       (same as @yearly)
           @monthly        Run once a month, "0 0 1 * *".
           @weekly         Run once a week, "0 0 * * 0".
           @daily          Run once a day, "0 0 * * *".
           @midnight       (same as @daily)
           @hourly         Run once an hour, "0 * * * *".

So my cron command ends up looking (mostly) like the following:

@monthly $HOME/scripts/createbackup.sh

How easy is that? I know that most modern linux distros have /etc/cron.monthly, /etc/cron.daily, etc…but the OS X way just seemed really nice.

Anyone know if this exact same shorthand is available on other systems?

Testdrive: OpenSolaris on OS X with VirtualBox

I finally got around to installing VirtualBox (read more about it here and here) on my Mac earlier this week.  Last night I installed the OpenSolaris (2008.5) disc that I picked up at the Sun booth at OSCON last week.

So far, everything has been going swimmingly.  I could walk you through the installation, but this dude at MacWorld did a much better job than I could.

The only trouble I’ve had thus far was learning some Solaris-specific commands (pkgadd, btw) to install the “VirtualBox Additions”.  The VirtualBox Additions are a small selections of add-ons that you install within the guest OS to ease integration with the host OS (mouse control, shared folders, etc).  While I’m not familiar with Parallels, I can say that VMWare (Workstation/Player) has a very similar guest additions installation procedure.

I’ve been using VirtualBox on my Vista desktop for a few months to virtualize a Xubuntu server (sshd, apache, mysqld, etc) with great success.  Typically, the VM is utilizing less memory than iTunes, which I find utterly ridiculous.  I decided to give it a spin on my MacBook Pro because the latest update of VirtualBox has brought the Intel Mac version out of beta.

While I don’t think that VMWare has much to fear from VirtualBox in the enterprise arena, for the average developer/desktop user, VirtualBox should suit you well.  I’ll be interested to see if Parallels and VMWare will be able to continue charging $80 for their consumer versions with such a capable free competitor (backed by Sun, no less) available.

OpenSolaris Impressions

Playing with OpenSolaris has generally gone well.  It helps that the UI is Gnome and the default shell is BASH, two things that most Linux folks should be comfortable with.  Cruising around the filesystem answered one of my main questions, which was that JDK6 (not OpenJDK, mind you) is installed by default.  I still haven’t figuresd out what mechanism, if any, OpenSolaris uses for automatic updates.  If anyone has some good “OpenSolaris for a Linux Guy” articles…please pass them my way.

OpenSolaris guest running on OS X host.

OpenSolaris guest running on OS X host.

Recent Tweets

Powered by Twitter Tools.