Archive for open-source

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

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.

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.

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.

OSCON 2008 – Day 3

I’ll spare the reader the session-by-session account ala yesterday’s post, but will lean more toward the general theme that seems to have run through the majority of the session’s I’ve attended the last three days.

There seems to be a huge buzz around all things cloud and mobile.  I won’t be as bold to say that the desktop is dead, but it sure doesn’t seem nearly as sexy as it once was.  It kinda feels like back in the late 90′s when everybody said that the internet would kill newspapers…but then it didn’t happen….but now fast-forward 10 years and that truly is the case.  It has become apparent to me that the days of a desktop being most user’s primary computing device are numbered.

It appears that as we get closer to network ubiquity, devices like the iPhone and EEE PC start to make a ton of sense.  It’s not that far-fetched that for a good segment of users, that a netbook will become their primary computing device.  With a flood of new devices now coming online, someone is going to have to deal with the issue of managable scaling…thus the cloud computing push.

There was a large contigent of cloud computing vendors/providers pushing their wares.  I had some interesting discussions with folks from the following services:

Personally, I’m going to try to spend some time with RightScale/AWS.  Currently Google App Engine only supports python (perl stuff in the works possibly?) and Engine Yard is Ruby/Rails focused.  RightScale+AWS lets me do whatever I want because they’re just running a XEN virtual machine image.

I have to wonder if folks care anymore about Microsoft’s dominance on the desktop.  It feels like most people have moved on.  Microsoft has virtually no presence in the MID and Netbook (yes, I know that the EEE PC can have XP installed on it) segment.  It feels like the mobile phone segment is about the same.  Please do not try to make an argument that WindowsMobile is in any way a serviceable mobile/phone OS.  With a billion mobiles being sold a year, that’s a damn big market that Microsoft doesn’t dominate.

One more thing…

I would be remiss to not mention another topic that has kept popping up throughout the week.  That is Open Data ( or Data Portability).  So far, it’s not been a straightforward process to share all this data that users are creating by Digg’ing, Flickr’ing, etc, etc.  RSS feeds can only get us so far.  The Open Web Foundation was announced today to help move down that path.  Some other items that have been discussed in a similar vein have been: OpenID and OAuth.