Who’s Calling Me?
This is really bad, but here might be a situation where you’ll have to handle a method differently depending on method it’s being called from. Here’s a demo of how you can identify the name of the caller.
Watchr Script That Works
Video – Inside Pivotal Labs
Deploying Rails 3 App – Step 1, Server Preparation
I use only LTS version of Ubuntu, so it’s Ubuntu 10.04 at this time. No, I don’t use RVM in production, it’s just my own personal preference.
1) Server Basics
sudo apt-get install build-essential bison openssl libreadline-dev zlib1g-dev libssl-dev libncurses5-dev ruby wget curl subversion
2) Install Ruby
svn export http://svn.ruby-lang.org/repos/ruby/tags/v1_9_2_0/ ruby
cd ruby
autoconf
./configure –prefix=/usr –enable-pthread
make
sudo make install
3) Install Git
wget http://kernel.org/pub/software/scm/git/git-1.7.3.1.tar.bz2
tar xvjf git-1.7.3.1.tar.bz2
cd git-1.7.3.1
./configure –prefix=/usr/local –without-tcltk
make
sudo make install
4) Install Bundler
sudo gem install bundler passenger
5) Install Nginx & Passenger
sudo passenger-install-nginx-module
After this, create a deploy account and generate ssh key for Git repository.
Next, capifying the app!
API Tips – Removing HTML From String in Model/Controller
strip_tags method really comes in handy when you have to render out a string in DB. However, what if you have to return that from a controller or a model, which is often the case when you’re developing an API.
In Rails, here’s a simple way to do it.
> HTML::FullSanitizer.new.sanitize("<b>Hope</b> <a href='whatever'>my link</a>")
=> "Hope my link"
My Project Management Tool
Few years ago, I was interviewing for a development manager position and was asked what tools I use to manage my projects. I told the interviewer that I use Mind Manager and mind mapping to effectively manage my projects. He looked at me like a deer in headlights and asked why not use a spreadsheet? I explained why but was told that I had to use a spreadsheet. Needless to say, I didn’t get that job.
Rather than go into details about how I do it here, take a look at this video from Mindjet, the maker of Mind Manager. I’ve been doing similar for years, but the tool now makes it much easier.
Upgrading Ruby in RVM
Screencast on simple way to upgrade existing Ruby in RVM.
Upgrading Ruby in RVM from Joon You on Vimeo.
Service-Oriented Design with Ruby and Rails
Paul Dix wrote a book titled “Service-Oriented Design with Ruby and Rails” and it’s available on Amazon at here. The book is also available on Safari, so check it out if you’re interested in developing API’s.
I’ve been working with SOA for years now and developed couple of API’s using both Rails and Sinatra. The book appears to cover both of them. I have not read the book cover to cover, but only glanced at certain sections. However, based on the sections I read, the book appears to be a good one.
Rails 3 App Deployment Observations
I already have two Rails 3 apps that are in production. While deploying these, I observed the following.
- Painfully obvious, you need to add a task to perform bundle install in your Capistrano script.
- When deploy hangs, it’s usually because Bundler is prompting for password.
- Haven’t found anything significant different from Rails 2.x.
- Ruby 1.9.2 really is much faster.
- While it solves a ton of problems, Bundler manages to piss me off on regular basis.
- Having multiple Ruby versions with Passenger is not a good idea. Besides, VPS’s are cheap these days.
I’m sure you guys are feeling the Capistrano screencast coming. However, the reason why I’m holding up the screencast is that PeepCode has that subject covered rather thoroughly. Check out Geoffrey’s good work, it’s only $9 and if you can’t invest that little in yourself, then I have nothing good to say.
Working From Home vs. Onsite
Since I use pomodoro, I decided to see how many pomodoros I can get done between working from home vs. in the office. For my experiment, I wanted to do it over a period of several days since in the course of human events… well, you get the idea.
I’ve heard some stories where people just couldn’t get anything done at home, especially with a wife and kids. Sure, they can be distracting, but I wouldn’t think about working at home unless I have a quiet office and sheltered from my personal life. I have my office in the basement where it’s quiet and somewhat sound-proofed from upstairs.
Well, to make the long story short, here’s the result. On average, I get little less than twice pomodoros done at home than in the office. You also have to be aware that I have two hour commute each way to NYC, so that’s 4 hours total that I can put to good use. Here are some of the factors I observed.
- At the office, I have very interesting conversations with others and get insights to other areas of development.
- I can bounce off ideas and get immediate feedbacks.
- When I’m home, I can get things done without much interruption and can take shorter breaks.
- I’m more comfortable at my home office. Usually puts me in good, productive mood.
- There are less meetings at home.
- The concentration level is extremely high at home.
- I miss people at home.
- People should turn on the video when using Skype.
I now firmly believe that companies should not choose just one over the other. Instead, there should be a balance between facetime and working remotely. Considering how expensive office spaces are, especially in NYC area, I think it’s silly to have a large offices for technology-related positions. We have Skype, IM, GoToMeeting/WebEx/Yugma, and VNC among other tools.