Making Chrome Canary the default browser [OS X]

This post is for Apple OS X users. This is a nice trick for setting Google Chrome Canary as the default browser in your OS X. You can’t do this within Canary itself. Since this is a nightly build edition of Chrome browser, the developers have intentionally disabled this feature. So to have Canary as your default browser:

  1. Launch Safari
  2. Click on Preferences
  3. Under the tab General, choose Google Chrome Canary as the value for Default web browser
That should do the trick!
Update: Since this post is getting quite a lot of attention I figured I should update this with a cautionary tale. You should know the Canary is an unstable and untested build of Google Chrome. When the browser gets updated behind the scene, you may be introduced to a few bugs. One such bug deleted all the links in the Bookmark bar! And since my bookmarks are synced across browsers and devices using Xmarks, I lost the bookmarks in all my browsers in all my machines! I launched Firefox and watched the links disappear before my eyes and cried out in horror! Fortunately Xmarks keeps backups of your links in the cloud, so I was able to download the backup files and restore them. But I stopped using Canary since then.
Morale of the story: use with caution!
Advertisements

Masters of Doom: A book you should read if you’re a programmer

Masters of Doom Book Cover

You’re probably surprised I haven’t mention “Code Complete” or “Pragmatic Programmer” or any of those books you’ve read reviews of in numerous programming blogs. Those are great books by the way, and should take the time to read at least some of them.

Masters of Doom will not teach you how to be a better programmer, it won’t preach the best practices of software development. Because it’s not a book about programming at all! It’s a biographic tale of two great programmers, John Carmack and John Romero, how their passion for playing and creating games drove them to achieve superb mastery at programming and produce legendary games, like Doom, Quake, Wolfenstein 3D and so on.

Neither Carmack, nor Romero had what you would call a healthy upbringing. They were from broken families, at odds with their surroundings. Playing games was one of the few things they would enjoy, and eventually they started learning how to create them. They had dreams of making it big in the gaming industry, creating and publishing under their own names.

These two brilliant minds met each other at their youth as coworkers. Each admired the unique qualities in the other one. Carmack was more adept in technical details of game development, while Romero had a knack for the creative direction. Together, along with some like minded programmers and designers, they founded id Software, and set out to produce hugely popular franchises. Not only were these games commercially successful, they achieved technological breakthrough in PC gaming. Commander Keen was the first side-scrolling game in PC. Wolfenstein 3D had immersive 3D graphics never before seen in games, And Doom set the bar even higher. These were the games that drove innovation in graphics programming, and established gaming as a part of pop culture.

So what do you, a programmer, are likely to gain from reading this book? The simple message that this book conveys, is that if want to succeed in the field of programming(or any other field) you must have passion for what you do. No amount of training would make you a better programmer if you lack this key ingredient. If you are a start-up founder(or work in a start-up) and have started your journey in the scary world of entrepreneurship, this book will prove to be inspirational to you.

So if you are a programmer who is looking for something to get him inspired, I strongly urge you to read it. Or read it anyway, it’s fun.

Getting started with pip/virtualenv

If you find yourself in a situation where you have to work with multiple Django projects on the same system, where each one requires a specific version of Django(and some other libraries), or even specific version of Python(2.5/2.6..), the combination of virtualenv and pip will make your life easier.

virtualenv is tool to create isolated Python environments.

pip is a Python package installer, much like easy_install. It’s complementary with virtualenv; you’ll use pip to install, upgrade, or uninstall packages in isolated virtualenvs.

In this post, I’ll show a simple workflow that will give you the basics on how to use these tools to manage multiple Django projects.

Installation

First, get these tools installed on your machine. If you have easy_install set up, you can install pip by just issuing the following command

sudo easy_intsall pip

Now install virtualenv, using pip itself

sudo pip install virtualenv

Creating virtualenvs

Now that you have them installed, let’s try creating some virtualenvs. It’s good to have a specific location on your machine where you would have all the virtualenvs. I personally like to have them under ~/.virtualenvs directory.

Create the directory

mkdir -p ~/.virtualenvs

Navigate into it

cd ~/.virtualenvs

Create a virtualenv

virtualenv -p python2.5 --no-site-packages projectA

The ‘-p’ option specifies which version of the Python interpreter you want to use for the virtualenv(In case you have multiple in your system). If not specified, the default interpreter will be used.

The ‘–no-site-packages’ option means do NOT inherit any packages from /usr/lib/python2.5/site-packages (or wherever your global site-packages directory is). Use this if you don’t want depend on the global packages and want more isolation.

Finally ‘projectA’ is the name of the virtualenv, named after the project itself(not a rule, just a good convention).

You’ll see the directory projectA created once the command prompt returns. This is the virtualenv, feel free to explore it.

Activating/Deactivating the virtualenv

Once pip have finished downloading and installing the packages, hopefully without any glitches, activate the virtualenv

source ~/virtualenvs/projectA/bin/activate

You should see “(projectA)” in your command prompt.

To deactivate it type ‘deactivate’ in your prompt and hit enter. The “(projectA)” should disappear.

So now you have an isolated and functional environment for your Django project. You should go ahead and create a new virtualenv with more recent versions of Python/Django as your homework.

I hope you’ve got the basics properly. Check out the online docs to learn more advanced usages of these tools.

In the next post, I’ll talk about virtualenvwrapper, a tool that makes managing multiple virtualenvs a little easier.

Use the Force, Unixuser42!

DISCLAIMER: Don’t get confused by the title. This post won’t teach you any advanced UNIX trickery stuff. If you’re expectation is such, you’ll be pissed after reading the article. You’ve been warned!

I had quite a laugh watching the Volkswagen Superbowl commercial, where this kid dressed up in Darth Vader Ccostume trying to control everything using the Force.

Then I got a (lame)idea! What if the powerful ‘sudo’ command in UNIX, which enables you to perform task as the superuser, was replaced by ‘force’! So you can type things like “force halt” in the terminal and shutdown the system. The Star Wars fan inside me got excited, and the Unix fan set out on a (very short)path to figure out how to achieve that.

The obvious way to do this is create to an alias for command ‘sudo’ and set it to ‘force’. Here’s how this can be done:

  1. Fire up your terminal program
  2. Move to your $HOME directory: cd ~/
  3. Open the .bash_profile file: vi .bash_profile (I’m on OS X. On other systems, like Ubuntu, this file will be .bashrc)
  4. Add this line to the end of the file and save: alias force=’sudo’
  5. Reload .bash_profile: source .bash_profile
  6. Try it: force reboot (System will reboot after authentication)

Don’t worry about ‘sudo’, you’ll still be able to use it. You didn’t exactly ‘replace’ sudo, you just gave it another name.

Also, it’s good idea to check if your system somehow already not using the ‘force’ command. (Type force in the shell to see whether it responds ‘command not found’ message.)

On Programming and Craftsmanship

I’ve just finished reading the article “Programming is not Craftsmanship” and couldn’t help but share my own views on this topic. If you haven’t read the article, I urge you to do so right away.

I agree with the author’s view in summary. As a programmer, you may take pride in your knowledge and skills, but the hard truth is the real world hardly distinguishes you from a plumber(may be a more literate plumber, if I dare say). They don’t care if the pipes are laid out in an elegant manner, or not, as long as the water is running. They focus on results, neither the process nor the tools. I’ve tried to share this point of view in the feedback section of every “Why programming language X rocks and Y sucks” blog post I’ve encountered.

But let’s consider the hypothetical situation where you are an entrepreneur, who has an idea of an amazing software. You hire some smart engineers. They build it out and the sales guys close deals. Customers are satisfied, and they ask for more features. The programmers code some more, you bill your customers for their work. Everyone’s happy.

Now a few years later, you’re techies are bored. They are looking for new challenges, as any good hacker would do. You recruit some smart guys to take over their work. They enter a painful transition period. The greenhorns have to learn the intricate details of your feature bloated software their predecessors have built; so they can fix, change or add stuff as demanded by the customers.

And here’s where the architecture of the software comes into play. If your early programmers have laid out a solid groundwork, keeping in mind the readability of the code and the extensibility of the software itself, the new guys will have less of a hard time getting things done. On the other hand, if the programmers have never cared about those things, and  just produced code to meet the deadlines, the new guys will go through hell figuring out which part of the software does what and how do they all come together. You’re customers are still waiting for those bugs to be fixed, those features to be added. They get impatient at the delay, and displeased at the higher than usual billing hours upon delivery. At this point you may think having a good “Documentation” helps, but it hardly does. If the programmers never had the time or will to build the software right, odds are against the fact that would have so for documenting it.

I’ve seen(and am continuing to see) it happen. Management and customers were happy playing with the pretty UI. But when I popped the hood out of curiosity, I was surprised(to say the least) to see, along with other things, the spiderweb-like intricacies of the if-else branches, and left with sympathy for the poor soul who would have to ‘maintain’ this codebase(praying that I wouldn’t be the one).

I’ll draw my conclusion with the personal opinion, that a successful programmer(or product manager) knows how to strike a balance between the two extremes. Being the prima donna programmer who whines about the elegance of code should be discouraged by all means. But the coder who pays the slightest attention to quality, must be avoided. For a software shop whose sole business plan is to “build, ship and forget”, the later breed may prove profitable. But not for the enterprise who seeks to deliver innovative and useful products.

(Joel Spolsky, one of my favorite bloggers, gave a presentation on a similar topic. You can watch it here.)

Blog stats 2010

The stats helper monkeys at WordPress.com mulled over how this blog did in 2010, and here’s a high level summary of its overall blog health:

Healthy blog!

The Blog-Health-o-Meter™ reads Wow.

Crunchy numbers

Featured image

About 3 million people visit the Taj Mahal every year. This blog was viewed about 33,000 times in 2010. If it were the Taj Mahal, it would take about 4 days for that many people to see it.

In 2010, there were 3 new posts, growing the total archive of this blog to 38 posts. There were 23 pictures uploaded, taking up a total of 6mb. That’s about 2 pictures per month.

The busiest day of the year was May 9th with 336 views. The most popular post that day was Modifying PDF files with PHP.

Where did they come from?

The top referring sites in 2010 were dzone.com, golang.tumblr.com, ict-blue.be, twitter.com, and facebook.com.

Some visitors came searching, mostly for rocket launcher, hammer, swiss army knife, gun, and lightsaber.

Attractions in 2010

These are the posts and pages that got the most views in 2010.

1

Modifying PDF files with PHP February 2010
5 comments

2

What kind of weapon is a programming language? April 2008
29 comments

3

Installing Python on Nokia N73 phone January 2009
8 comments

4

Installing Go on Ubuntu November 2009
17 comments

5

Deploying Rails Application on Apache with Phusion Passenger September 2009
3 comments

How to piss off a …

I found some really funny posters over the Net. Each one is designed to anger fans of multiple Sci-Fi/Fantasy franchises, be that Star Wars/Trek, Harry Potter or Lord of the Rings.

The first one.

Get it? Picture of Captain Mal from Firefly, next to it the famous line of Spock from Star Trek. Signed by Han Solo of Star Wars?!

The next one will surely irritate a fantasy novel aficionado, and a Star Wars fan.

Gandalf  the wizard, is given credit for a quote by Master Yoda, and he’s signing off as Dumbledor!

Fucking hilarious!

You’ll have to be a programmer to get the next joke.

Did it piss me off? No way. This one was so amusing that finally decided a post a blog after a long time!

You don’t get it? Did you say you’re a programmer?

Now you are pissing me off.

Photo Courtesy: Reddit.