Multiple deploy keys with git

Before I forget, and some may find this useful too.
If you are deploying a few projects to the same server you will run into this, you need to use unique deploy keys to access each project unless you want to add the server’s public key to your account. For security reasons I did not want to do that.

First generate some deployment keys with ssh-keygen. Here’s some more info on adding your deploy keys to your git repo

So I need to set up my ssh config file in ~/.ssh/config like so…

Host project-a
  HostName github.com
  User git
  IdentityFile ~/.ssh/deploy_key_a_rsa
  IdentitiesOnly yes

Host project-b
  HostName github.com
  User git
  IdentityFile ~/.ssh/deploy_key__b_rsa
  IdentitiesOnly yes

Let’s say your two project git urls look like this:

  git@github.com:anon/project-a.git
  git@github.com:anon/project-b.git

You can now clone with the correct keys using..

  $> git clone project-a:anon/project-a.git
  $> git clone project-b:anon/project-b.git

Unable to find a $JAVA_HOME at … on Mac OSX

I recently switched my Java versions from 1.5 to 1.6 and I’ve been hitting some issues with the java path.
I tried setting the environment variable JAVA_HOME=/usr and that worked for some stuff but I still saw this error when running java.
eg:
>java -version
Unable to find a $JAVA_HOME at "/usr", continuing with system-provided Java

I solved the problem by doing the following.
First I found out where java actually was with:
>ls -l' `which java`
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

I noticed a command called java_home in that same directory. Running that command yields the correct java home directory.
>/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home

To correctly set the my JAVA_HOME environment variable in future, I added the following to my ~/.profile

export JAVA_HOME=`/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home`

Once you have done this you can restart your terminal window or run >. ~/.profile to reload you profile into the current terminal session.

Simple Tabbed Navigation with CSS

I had to create some tabbed navigation for a project at work recently. Not anything new really, lots of people implement it in lots of different ways. A colleague recommended a method demonstrated on SimpleBits for creating simplified css tabs however it uses background images to get the tab effect and I don’t like that.

I’d much prefer to use a pure CSS method that doesn’t involve editing an image if I want to make changes. So here I have it, a simple CSS only method of doing tabbed navigation. I’ve tested it in IE6, IE7, FF2, Opera 9 and Safari 3.1, all fine.
Continue reading

Broken Build when not using ActiveRecord?

Just a quickie.

I ran into this problem before, then forgot about it after finding the solution. Then one of my colleagues ran into the same problem today which prompted me to post this.

If you’re rails app doesn’t use ActiveRecord you may find yourself scratching your head wondering why your build fails with ActiveRecord related problems. I obseverd this even though I had turned off ActiveRecord in my environment.rb. CruiseControl.rb still tried to run rake tasks like test:db:purge etc.

The quick and easy solution is to remove database.yml from your config directory. CruiseControl.rb should ignore any database related rake tasks then.

I liked Dashcode

I’ve been using Dashcode for the last two weeks or so while creating my Build Status Monitor widget. First impressions are not too bad. As IDE’s go, it does the job. You can write your html, css and javascript, all in one place, there’s a wysiwyg view, that’s all to be expected. To be honest I thought the code view could have done with better syntax highlighting, I found myself yearning for TextMate or Coda at times.

The winning feature for me though was the debugging facility. I found it to be extremely efficient, I’m sure I saved hours as it reliably showed me where the problems were in my code, allowing me to jump in at the offending line. When I’m developing for the web I can’t live without Firebug, when it comes to Dashboard widget development, Dashcode’s debugging abilities were a pleasure to use.

Deploying a widget couldn’t have been simpler. File > Deploy Widget, File > Deploy Widget to Dashboard. I did see one issue where I tried deploying the widget to my Dashboard at work and the widget simply wouldn’t initialise. All I saw was the default widget image. However I deployed the same code at home and the widget worked fine. I’ve installed that same widget in work now and I have no trouble with it now. I can’t figure out what the problem was. Perhaps all I needed was a restart.

Anyway, thats my Dashcode lowdown. I do recommend getting stuck in if you like that sort of thing.

CruiseControl.rb Dashboard Widget

I hated skipping back and forth to CruiseControl.rb at work to keep an eye on various builds so I’ve put this widget together to make life a little easier. The Builds Status Monitor Dashboard widget takes the build rss feed and displays the current build status. Does what it says on the tin.

Screenshot:

Build Status Monitor Screenshot

Download:
Click here to download the Build Status Monitor. Just unzip and install, minimum requirements MacOS 10.4.x. This is my first Dashboard widget so some of the code is a bit untidy. I’ve tried to keep the look and feel clean. Please let me know if you have any problems or suggestions.

Maintaining Scope in Javascript Callbacks

As a web developer I can’t avoid using Javascript. Not that I would want to or anything. I love Javascript. I’m happy enough with my JS coding skills but there was one thing that always found a way to leave me scratching my head. Callbacks!

I had no problem with the concept of callbacks, but something was missing. I always had trouble maintaining scope in callback methods. I haven’t had to pay too much attention to the problem until today as jQuery has met the majority of my Javascript needs to date. Anyway after a quick search I found the solution, which is so easy I deserve a kick in the ass. Continue reading

Jaxer.Web.post and XMLRPC

I've been playing around a little with Jaxer lately. I really like the ease of Cross Domain javascript calls. Just a quick note though. I've been testing the Jaxer.Web.post call against the wordpress XMLRPC.
I kept getting responses saying that the the server only accepted POST requests. But I was using Jaxer.web.post.
So I scratched my head for a while. And then some.
Eventually I figured that the body of the post request was not being set. Then I discovered that Jaxer.Web.post defaults it's content type header to "application/x-www-form-urlencoded" which, as far as I know, passes the data in a querystring format and not in the post body. The simple fix was to change the content type to "text/xml" like so :

JAVASCRIPT:
  1. Jaxer.Web.post(url,body,{contentType: "text/xml"});

The call worked perfectly after that.