My Public DNS went Missing in my ec2 Instance

My Public DNS went missing in my Amazon ec2 Instance after I did the following: I set up an Elastic IP and associated it with the instance. I then disassociated and removed the Elastic IP. That’s when my Public DNS went missing! However, DON’T PANIC :) The solution is just to wait a few minutes [...]

Deploy to EC2 with Rubber on Rails 3

Rubber is a gem which makes it easy to make multi-instance deployments of your rails app to EC2. It uses capistrano to do this. Before proceeding, make sure you have your EC2 account created and have a keypair set up with Amazon. Here is recipe of what I’ve done so far. I’m running into issues [...]

Pseudo-Element Order Reminder

For best results, define your styles in this order: link, visited, hover, focus and active since order matters. Also always set :focus if you’re setting :hover. Hover is applied for mouseover events and Focus is applied for keyboard-only users.

Ruby Garbage Collection and Memory Profiling

These slides by Joe Damato and Aman Gupta explain Garbage Collection and the Ruby Heap really well. It talks about the following: How memory is managed in Ruby vs C All variables and all ruby code lives on the heap like any other object In ruby there’s no way to explicitly free memory How the [...]

Easily Replace Prototype and Scriptaculous with JQuery

There is a very cool gem called jquery-rails which provides you one rails generator which will replace your Prototype and Scriptaculous JavaScript libraries with JQuery, within your Rails app. It will download JQuery and install it for you under your public/javascripts directory. I believe this gem only works with Rails 3. I’ve only tested it [...]

Building a Simple Addressbook with Authentication using Devise

Assumptions: You are using Rails 3, even though I tried to accomodate Rails 2 as well. In this Tutorial / Recipe, l go through creating a very simple “Addressbook” with Devise as its Authentication system. This Addressbook only contains two fields name and phone. A User model is generated with authentication using the Devise gem. [...]

Extremely Clean Way to Preload all Images

Are your images flickering since you aren’t preloading them? This is kinda annoying. There’s a simple solution. Read below. If you want an extremely clean, DRY, unobtrusive way to preload all images which are defined in your CSS without having to re-specify those urls as arguments into another JavaScript function, check out A New & [...]

Search and Replace a Word in all Files within Directory

Use the following at your own risk. Save off your files within your directory somewhere first before running the following command. I’m posting these notes so I can refer back to them. If you want to search and replace a word in all files within a specified directory in Unix, do the following: For example, [...]

Authlogic vs Devise for Authentication in Rails

The following post has been written by Brian Morearty. Here he compares Authlogic to Devise. I’m posting the following with his permission. "Here’s my comparison. Please keep in mind this is after only having used Authlogic for a few months (I used it on another project) and Devise for a few hours: Authlogic and Devise [...]

Installing, Configuring and Troubleshooting PostgreSQL 9.0 in Rails 3 on OS X

The following may apply to other versions of PostgreSQL as well but I’m using version 9.0. I initially tried to install PostgreSQL via MacPorts but after running into issues I describe below, I ended up installing it via the Mac OS X package. If you want to skip issues I ran into with my macports [...]