Protos Musings

In the long run men hit only what they aim at -- Thoreau.

Setting Up My Linux Box and Ruby on Rails - Ubuntu 12.04 Edition

About an year back, I had posted in depth about my love for Ruby, and how I set up my Linux box on Ubuntu 10.10, including how to set up Ruby on Rails in that environment.

Well the time has come for an update for Ubuntu 12.04 LTS that came out during the last week of April.

Since I had written that previous post in such detail, I will just jot down the steps in this one. This is more for my reference, but may be it will be of use to someone as well. Also, that post came in quite handy during the current setup and so I hope I would refer back to this one as well in future.

I was on Ubuntu 10.10, whose support came to an end during April and I was looking forward to the final release version of 12.04 ever since.

Now, there were only two ways to upgrade – from 10.10 to 11.04, then to 11.10, and finally to 12.04. Or, take backups, take a deep breath, and wipe your disk clean and install 12.04. I chose the later path since the former sounded a terrible idea. Also, interestingly had I been on 10.10 (another LTS version), I could have directly upgraded to 12.04 (which is again an LTS version). So, a good lesson learned there – I will think twice before upgrading to non-LTS versions from here on.

So, here I had a blank machine one more time, and this time too I decided to jot down the things I had to do to get the machine to a state that I would be happy about. I am a bit finicky about things like colors and fonts.

Compared to the 10.10 days, there are some changes - some of the apps now come pre-installed (Firefox 12.0) or is no longer supported on Linux (Picasa)

So, once the OS is installed, here are the things I did:

Basic Machine Set Up

A. Installing my favorite fonts

1
2
3
4
5
6
7
8
9
[Inconsolata](http://kevin.vanzonneveld.net/techblog/article/install_the_best_coding_font/)
  sudo apt-get install ttf-inconsolata

[Inconsolata-dz](http://goo.gl/Hhbxg), an even better looking Inconsolata

[Inconsolata-g](http://goo.gl/R54Mp), another derivative of Inconsolata though I prefer the dz version more.

Droid family of fonts, designed by Google for Android phones
  sudo apt-get install ttf-droid

B. Configure gEdit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
enable
  View
    Display line numbers
  Editor
    Tab Stops
      Tab width: 2
      Insert spaces instead of tabs
    Automatic indentation
      Enable automatic indentation
  Font
    Remove "Use the system fixed width font"
    select "Inconsolata 11" as font
  Color Scheme
    Oblivion
  ... # and so on 

C. Configure Nautilus

1
2
3
4
5
View
  Default view Compact
  Arrange Items by Modification Date
  Zoom 50%
  ... 

D. Configure Terminal

1
2
3
General tab
"Inconsolata 11" as font
Color: White on black  

E. Install Chrome Dev Channel

Thankfully Chrome remembers all my settings and plugins and so this was pretty hassle free. The only setting I remembered doing was to set the font to Droid.

Of course, Chrome doesn’t remember any userscripts that you installed, and so I had to reinsall the following userscripts:

1
2
3
4
[Google Reader - Even More Compact Design (Nov 2011)](http://userscripts.org/scripts/show/116888)
[O'Reilly Safari Minimalist Tweaked](http://userscripts.org/scripts/show/76653)
[Resurrect Google Cache & Related links](http://userscripts.org/scripts/show/114455)
[Google Plus Right Side Bar Remover](http://userscripts.org/scripts/show/106671)

F. Install aptitude

This would come in handy to install stuff that needs aptitude rather than the default apt-get package manager.

1
sudo apt-get install aptitude

G. Install Pinta (equivalent of Paint.net)

I am someone who takes a number of screenshots in a month for various things, and so not having the equivalent of Paint is not acceptable. I usually crop the screenshots and so I need a decent, basic editor. Enter Pinta

1
2
3
sudo add-apt-repository ppa:moonlight-team/pinta
sudo apt-get update
sudo aptitude install pinta

H. Configure Reliance NetConnect

Unfortunately, my Reliance Netconnect just doesn’t work with the out-of-the-box method (of adding a new mobile network connection), and what works is the steps outlined by Harbhag at his blog: Reliance Netconnect Broadband+ on Ubuntu

O. Further tips and tricks to customize Ubuntu

Refer any of these awesome resources or google for more.

Developer tools and other tools Setup

A. Install LAMP via instructions at Installing LAMP on Ubuntu 12.04 Precise Pangolin Like last time, I stopped short of installing phpAdmin which is mentioned at the end.

B. Install vim

I have become a big fan of both terminal vim over the last year, and this time decided to compile and install vim with ruby support. I followed the steps outlined in this post, including installing mercurial to clone the vim source code. Of course I used Ruby 1.9.3 on Ubuntu 12.04, but other than that the steps outlined in that post works. Of course, I still can’t get Command-T to work on my box, and that is something I will have to check one of these days.

I ended up installing version 7.3.509, which was the latest version available while I was installing.

For Vim plugin management, this time I decided to do away with my manual style, and was almost going to use the highly rated Pathogen plugin. But googling revelaed an even simpler (dare I say better) way of doing that using Vundle.

For more on Vundle, do read these two posts. I assure you it is worth your time!

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Note: From here on, the installation process was done based on a bunch of resources:

Installing RoR in Ubuntu by my good friend and colleague, Arun Vydianathan

The excellent and free Ruby on Rails Tutorial book

Of course my previous post :)

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

C. Install git

1
sudo apt-get install git-core

D. Set up tab completion for git

I had backed up the file “contrib/completion/git-completion.bash” and so this was pretty painless - I just had to copy the file into my home (~) folder.

1
2
3
4
5
6
7
8
9
10
$ cd folder/having/git-completion.bash
$ cp contrib/completion/git-completion.bash ~

# Open the .bashrc file for editing
$ gvim ~/.bashrc 

# NOW, Paste the contents from [this Rails tutorial page](http://ruby.railstutorial.org/bashrc) into the file.

# NEXT, run the following to source the bashrc file.
$ . ~/.bashrc

If you don’t have that file, you might have to download the latest git source. Please refer my previous installation post for more on this.

E. Install curl

1
sudo apt-get install curl

F. Install Ruby Version Manager (RVM)

Refer the RVM installation page and follow along.

G. Install Ruby

1
rvm install 1.9.3 

Create the required rvm gemsets as per your requirement.

H. Install the latest version of Rails

1
gem install rails

If you run into the strange bundle-install-fails-on-every-gem issue due to handshake problem (Gem::RemoteFetcher::FetchError), please refer either of these two posts for a solution.

To complete the set up of Rails development environment along with the required test setup and deployment (using heroku) environment, refer to the excellent Ruby on Rails Tutorial, chapters 1 and 3. Chapter 2 is about using scaffold to create a sample app, and doesn’t add any value towards our current goal: setting up the environments.

I. Install the databases

If you had followed along from the top (referring to the different sources, you would have already installed both mysql and sqlite3). If you haven’t, please refer the “Databases” step of this post.

For me, what is left to do is to install postgresql

1
2
3
# Install postgresql and deps
sudo apt-get install postgresql libpq-dev
gem install pg 

Of course, you would then have to then try to log into the postgresql db server, create the required users/roles etc. Google if you don’t how to do it.

J. Install “Open Terminal [Command-Prompt] Here”

This allows you to open a terminal from any path in the file manager Nautilus, and for me it is an indispensable tool. From this SuperUser thread:

1
sudo apt-get install nautilus-open-terminal

K. Install tmux

Tmux is a terminal multiplexer and ensures that every time I open it I have all the windows I need (multiple terminals, rails server, rails console, rails db server and so on) are up and running.

Here are some references and a book that would be useful to get started.

1
sudo apt-get install tmux

Since the apt-get repository had an old version, I downloaded and compiled the source. But the above should get you started.

Of course, to make it even more easier, I use the Tmuxinator gem as well:

1
gem install tmuxinator

L. Install the indicator-weather applet

1
sudo apt-get install indicator-weather

M. Install Ack, which is of course better than grep

1
sudo apt-get install ack-grep

N. Install Kazam for recoring videos for screencasts.

1
2
sudo add-apt-repository ppa:kazam-team/stable-series
sudo apt-get install kazam

O. Install xsane for the scanner

1
sudo apt-get install xsane

P. Install VLC player

1
sudo apt-get install vlc vlc-plugin-pulse

Q. Install lo-menubar to make LibreOffice play nicely with Unity

1
sudo apt-get install lo-menubar

R. Install Nautilus Image converter to have a quick option to resize images from Nautilus

1
sudo apt-get install nautilus-image-converter

S. Install xclip to use the clipboard from the commandline

1
sudo apt-get install xclip

T. Install ImageMagick

1
2
3
sudo apt-get install libqt4-dev
sudo apt-get install libmagick libmagickcore-dev
sudo apt-get install libmagickwand-dev

U. Install Exuberant Ctags (for Vim)

1
sudo apt-get install exuberant-ctags

V. Install MyUnity to tweak Ubuntu.

1
sudo apt-get install myunity

The best part for me is that I can easily tweak the unity launcher bar from this.

W. Install Ubuntu Tweak to tweak Ubuntu.

Can be downloaded from http://ubuntu-tweak.com/

X. Install Compiz Config Settings Manager

1
sudo apt-get install compizconfig-settings-manager

This allows me to continue to use the Super(Windows key)+N combination to invert the monitor colors - an indispensable tool for reading using the browser.

=================

Of course, my ideas about what constitutes my preferred configuration is bound to change over time, and so would the tools required to do the job. If I come across something great, I will try to update this post with that info.

Thanks for reading and I hope at least some of it would have been useful for you.

Update Thu, 03-May-11: Cleaned up the code snippets’ layout.

Vim at 20: Simply the Best Text Editor

Earlier this week, on November 2, 2011, the awesome Vim text editor turned 20 years old. Vim started its life, as many of you might be aware, as the clone or imitation of the venerable vi editor created by Bill Joy – who went on to cofound Sun Microsystems – for Unix. It is a tribute to the genius of Bill Joy that his core ideas are kicking and thriving even 35 years after he created vi.

Vim was created by Bram Moolenar to fill a necessity – the version of Unix OS he was working on couldn’t use vi (due to strict copyright of vi) and so Bram had the option of either using one of the existing clones (all of which, as per him, sucked) or port vi. He, luckily for the rest of us, opted for option 2 and the rest as they say is history.

My interest in Vim was piqued sometime during the last 3 years thanks to the programming blogs I was reading via Google Reader. However since there was this notion that it is hard to learn, and since the benefit was not that evident (unless you stick with it for at least 4-8 weeks doing programming or text editing), I never took it seriously.

The turning point, at least for me, was July 29, 2010 when I read two awesome posts on Vim that not just made me very interested, but also reassured that there perhaps is no just one way to learn to using Vim. The first post was by Yehuda Katz: Everyone Who Tried to Convince Me to use Vim was Wrong. The second was by Rob Conery, an ex-Microsoft guy: Moving Your Mind Into Vim Mode. In fact Rob wrote that after getting inspired by Yehuda’s post. And after a few weeks, when I read Steve Losh’s post Coming Home to Vim, I was certain this is a skill that I should master - some day. Of course, I should not forget to mention another post that really caught my attention, by Derick Bailey: Using Vim As Your C# Code Editor From Visual Studio

Some time during last August or September I did download and install Vim, opened it, and didn’t spend too much time with it before giving up on it. But I did try out the Vim Kata posted by Rob: Vim Kata Number One. I must admit I found the going a bit tough and that was one of the reasons for giving up. Plus, there was the Visual Studio editor beckoning me to go back and use it to ”rot my mind” further, as Charles Petzold would say!

Anyways, long story short, I chickened out and didn’t take the time to learn or befriend Vim.

In 2011, I started focusing a lot on Ruby and Rails as the main programming platform. And no matter where I turn to, the default editor of choice in the Ruby and Rails world is Vim. I thought this was a good opportunity to at last start using and learn properly. During late February, I attended a Chennai Geeks session at ThoughtWorks, Chennai, by Vagmi Mudumbai on Rails followed by Siddharta Govindaraj on Django. Both of them are craftsmen and great programmers and both of them were using Vim for their live coding. I was sort of sucked right in and blown away at the same time!

Over the last seven months, I have been doing all my programming work (and now even this blog post writing) on Vim. Whenever I switch to Gmail to compose a long mail, I miss the power of Vim. I must say that I am both lucky and thankful to have finally discovered the power and sheer joy of using Vim. It is after all the only editor that is guaranteed to be available on almost any system [vi comes pre-installed in the Unix family of Operating systems (Unix, Linux, Mac OSX). On Windows we can download and install it.].

If you are someone who writes text or code for a number of hours every day, learning Vim would be a gamechanger for you. I am still learning Vim and people who have been using it for 10 years say that they are still learning something new every day, and I think I am a long way away from mastery.

I will leave you with a few more great articles, some of which came out on the occassion of Vim’s 20th birthday:

Two decades of productivity: Vim’s 20th anniversary

Two Decades of Excellence: Vim Turns 20!

Why, oh WHY, do those #?@! nutheads use vi?

Tim O’Reilly on 20 years of Vim

And last, but not the least, this awesome, inspiring story about how Mark O’Connor programs using just an iPad hooked to the cloud: I swapped my MacBook for an iPad+Linode

Happy 20th birthday, Vim!

And Happy Vim-ing, friends!

PS: I haven’t gone into why Vim is great or how it will make you uber-productive. For that you can click through and read the mostly awesome posts I have linked to above :).

PS2: If you have ever used j/k or n/p in Gmail or Google Reader for navigation, you can thank Bill Joy and vi for that awesome experience!

Google Reader Redesign: The Way Forward

This week Google rolled out the redesign of my favorite Google product - Google Reader. This was a much needed face-lift, no doubt – though I am not a fan of the new UI – and more importantly, from Google’s perspective, they were integrating one more service with Google+, the future of Google. This was supposed to make Reader more social, but ironically, in a perplexing move (at least, from the perspective of power users of Google Reader), Google ended up making Reader a less social, and a less useful product overall.

I am not going into the details of how Google fared, and what they could have done better, as many more knowledgeable people have written about that, and I will link to some of them here:

The Google Reader Redesign is an Ugly, Lonely User Experience on Forbes

Google Reader Changes And Feeds Go Missing by Rob Diana

Wherein I try to explain why Google Reader is the best social network created so far by Courtney Stanton

The Google Reader Downgrade by Michael Heilemann

The biggest loss for me is the missing personal curated feed of items shared by awesome folks like Jesse Stay, Rob Diana, Louis Gray, Phil Ashman, and closer home, folks like Mahendra Palsule and Dhananjay Nene, and last but not the least, my friends like Arun and Pradeep.

I would rather read something that is read and shared by these folks than read some item popping up the stream from some source that I follow. Why? Because, I know that these guys had taken the time out to read something and found it worthwhile to share it. Also, when I want to search for something that I had seen/read in Reader, I mostly search Google Reader first, and only if I can’t find the relevant answer, do I resort to a generic Google search.

So, what was the way forward to get back the social aspect I lost? Well, as a first step, I remembered that I read in the morning what Alex had posted about reclaiming your shared items from inside the Reader. That was a first sigh of relief (I would have shared at least 500 items in the last 5 years and so getting that back intact was a big plus!). It then struck me that I can now recreate the shared items from the people I was following using the same technique.

For that, I had to first get hold of the list of people I used to follow. One can get that from “Settings | Import/Export” tab in the Reader, and from there I downloaded the JSON for the list of people that I follow. Though it contained some 50 names, only 10-20 were very important for me (those were the people who were into active reading and sharing on Reader).

I subscribed to their “thus-far” shared items (so that I can still do meaningful searches from within the Reader). Next, thanks to the suggestion from Phil, I followed the steps outlined by Tony Scelfo and ran the script he provided, that parsed the JSON and opened up Google+ profile for each of the users in the JSON. Yes, that opened about 50 tabs for me, and I had to close about 30, but I ended up with the 20 people whom I want to follow for their “shared” items. I added each of them to a new Google+ circle that I called “greader”.

Yes, most of them will not use Google Reader for sharing any more (or with the same intensity) as before, but at least I can easily keep abreast of both what they shared earlier, and what they choose to share publicly on Google+ from now on.

Of course, it would have been best if people taking decisions at Google were a bit more considerate, and had studied a little closer how power users were using the service. But, hey, at least I have something instead of nothing. And hopefully, in the next few months, Google would rethink/evolve the integration further and that might render my effort today a waste. But till then I have my personal shared items and those from my friends safe!

And, is there any silver lining? Yes, there is. First is the hope that someone in Google would listen to what I consider to be very genuine concerns of power users like me, and second is the fact that people like Dave Winer and Francis Cleary are working on making feed reading products better or making better products!

HiveMined Update by Francis Cleary

The Sharebros Are Building a Google Reader Replacement on The Atlantic Wire

What is RWW actually saying? by Dave Winer

Indeed, may be Dave Winer was right all along about both RSS and Google! :)