about web development and such

Centralized Multi-deployment Approach With Capistrano

Capistrano is most often used for deploying a single Rails application but with a few libraries you can use it to deploy multiple applications or “services” in a service oriented architecture. In this article I’ll walk through how to build this type of deployment application with Capistrano.

Undo Git Commit

I just made a commit to a public project and pushed the changes up to github. Then I realized that I left some confidential information in one of the files. Searching online lead to a couple of different ways to fix this (git rebase, and git filter-branch), neither of which were working well for me.

I finally figured out that doing the following would work as long as the confidential information were only included in the last commit.

First update the file and remove the confidential info.

git add my-file-with-confidential-info
git commit --amend

(this will add what’s in your current staging area to the last commit)

git push origin +master

(force push your changes to github)

Hope this helps someone else.

Open Source Wedding


I’m getting Married this October and so I’ve created a wedding site for my personal use (http://www.fairbarneswedding.com). I thought, why should I use it once and leave it to rot in source control somewhere? So I’m releasing it under the GNU GPL.

At the time of this writing the project has news articles, events calendar with rsvp, paypal integrated donation meter, wedding party members, wedding stories, and static pages. If you fork the project and make it better, send me a push request. You can find the source at http://github.com/randomutterings/wedding

Changing Images With JQuery and the Fade Effect

me and lydia

Photo by me!

It took me a bit of digging to figure out how to fade out a picture, change the src, then fade it back in. I started out trying to use Scriptaculous but I got stuck trying to get the queue setup to wait until the image was faded out to change the src. I ended up using jQuery which also gave me a bonus, the solution is unabtrusive.

Here are the application.js and show.html.haml files from my project.

Pool-party, Auto-scaling With EC2

jump in

Photo by hrlndspnks

Having a great time at Railsconf08. Meeting some great people and learning a lot. I plan to post in more detail about a lot of this after the conference but I wanted to go ahead and mention one of the coolest presentations I’ve seen so far.

Ari Lerner has created a ruby gem called pool-party. It auto-scales your ec2 cluster based on criteria you set in the config file like average requests per second. Set your minimum requests per second and if the average of all the servers on your cluster goes over the maximum, pool-party will launch another instance for you. It scales down in the same way. It doesn’t care what you’re using your cluster for and a its going to support plugins soon so you can add in your own hook like functionality. Pool-party is using s3fuse to mount an s3 bucket on the instance at startup. Specify a bucket in pool-party and it gets mounted at /data on each instance. This solves the data persistence issue with ec2. You’re not required to use it though, just don’t specify a bucket in pool-party and nothing gets mounted.

Ari open-sourced Pool Party as of 2 days ago. Check it out at poolpartyrb.com. If you want to contribute, its on github at http://github.com/auser/pool-party.

Installing Git on Linux

Trying to install git from source on our linux server (we’re running RHEL4 at work) and I was getting an error running make.

undefined reference to `libiconv'

Running make like this worked.

make install CFLAGS="-liconv"

But after the install was finished, running git barfed at me about loading a shared library libiconv.so.2.

I had to edit /etc/ld.so.conf and add /usr/local/lib and run ldconfig.

Credit Mark Turner for the ldconfig tip. Thanks man.

Fixed Length Random Numbers in Ruby

My latest project is almost complete and we’re setting up a demo site with lots of fake data already included so I used the faker gem to generate most of it.

One issue I had that I couldn’t do with the faker gem out of the box is get a fixed length random number. I need this for license numbers, credit card numbers, phone numbers and others. The faker gem does offer a random phone number but the ones in my project don’t support extensions or punctuation so rather than generating the number then using string functions to strip out the stuff I didn’t want, I decided to find an easier way.

Mysql Backup Script

Need a way to backup all your mysql databases in seperate files without eating up your hard drive, then this is the script you need.

Its a bash shell script that will export all your databases with mysqldump into seperate files named like ‘database-date.sql’. It will also delete your old backups so you don’t fill up your hard drive.