Archive by Author

ActiveRecord destroy method

Once you destroy a record, the object becomes frozen. Call the frozen? method on the referenced object before and after calling destroy to see the difference. If you try to manipulate the object after the object is ‘frozen’, you’ll get a TypeError: can’t modify frozen hash

jQuery Makes Writing JavaScript Fun Again

Nick Pink attended the Silicon Valley HTML5 Users Group meeting recently and here are his notes which I am posting with his permission. Last night I went a meetup sponsored by the Silicon Valley HTML5 Users Group called “jQuery Makes Writing JavaScript Fun Again”. The speaker, Dr. Doris Chen of Microsoft, talked specifically about AJAX […]

Ruby vs Python

Python vs. Ruby: A Battle to The Death

How to Create a Shorter Alias for Public DNS Hostname

After you’ve created your Amazon EC2 instance, set up Security Groups for ssh, set up your key pair, you will realize that your Public DNS for your EC2 instance is super long and very hard to remember. You also wish you could exclude having to type the "username@" prefix when you ssh to the server. […]

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. […]