February 27, 2011

Honda motorcycles: some tidbits

Being the Honda fan I am, I saw a series of videos about Honda Motorcycles on Discovery Channel.  4th video in the series is about their Gold Wing bikes, and I am sold on it already!  Don't be surprised if I buy one at some point ;-)  A few interesting tidbits from the videos:
  • Honda CB750, launched in 1969, was the first ever bike to use a disk brake and a 4-cylinder engine.
  • Honda's Gold Wing motorcycle has more parts than a Honda Civic.
  • Honda Gold Wing 6-cylinder 1800cc engine is so smooth you can balance a nickel on it while the engine is running.

February 19, 2011

Controlling screen brightness in Linux

3 years ago, I had a Lenovo laptop whose screen brightness keys didn't work on an old version of Ubuntu.  I wrote a blog post on how I worked around the limitation.  Now I have a Samsung N450 laptop running the most recent version of Ubuntu (10.10) and the screen brightness keys don't work again.  Like the last time, I am going to document how I am changing screen brightness on my laptop now.

I learned this from a comment Goksu left on an Ubuntu bug report.  The command that changes screen brightness is:
sudo setpci -s 00:02.0 f4.b=90

The 90 in this command is the brightness value in hexadecimal.  Valid range for this value is hexadecimal values between 0 and ff inclusive.  For instance, to set brightness to 75% replace "90" in the command with "bd" (i.e. sudo setpci -s 00:02.0 f4.b=bd).  Likewise use "7f" for 50%, and "3f" for 25% brightness.  Never set this value to 0 though, because that turns the display completely off and resetting the brightness can be hard.  (If you manage to accidentally set this to 0, reboot the machine, before you load Linux, i.e. while on the boot menu use brightness hot keys to set brightness back to normal.)

You may want to look at my old blog post to see how to avoid having to enter your password every time you change the brightness and to bind a shortcut key to adjust brightness.

Now, some details on how this works so you can adjust the command arguments to suit your computer.  Using setpci command, we are directly setting the brightness configuration on the graphics card.  -s flag says which device to control.  Running lspci shows all devices connected to the system via PCI.  On my machine this is what lspci prints:
% lspci | head -3
00:00.0 Host bridge: Intel Corporation N10 Family DMI Bridge
00:02.0 VGA compatible controller: Intel Corporation N10 Family Integrated Graphics Controller
00:02.1 Display controller: Intel Corporation N10 Family Integrated Graphics Controller
As you can see "00:02.0" is the identifier for the display controller.  Brightness is controlled by the number in f register of the VGA controller.  This register is 8 bits long and hence the range 0 to ff.  With the setpci command we change the value of the f register and that results in the brightness change.

Update (Oct 2, 2011): I have written a Go program to change the brightness from command line.  I have uploaded a 32-bit compiled binary as well, if you don't want to compile it yourself.  You can install this program to /usr/local/bin with setuid bit set so that you won't need to 'sudo' every time you run it.  (Search for "chmod" in my previous post for detailed installation instruction.)

February 16, 2011

Tracking clicks on blog widgets

I play around with the layout and widgets used in my blog all the time.  Every time I make a change I believe that the change makes the blog better, for example by providing more useful links on the sidebar.  All this while I had to blindly hope that the sidebar links are useful.  But today I made a change so I can measure the usefulness of the sidebar widgets.

Side note: Google Analytics has a feature called event tracking that can be used to track events that happen within a single page.  Let's say you have built an awesome game hosted on a single URL on your web site.  Your game might be so addictive that many users open it first thing in the morning and keep playing all day.  If you measure only page views you won't know that people are playing the game all day because technically the game is loaded only once (though it's kept open for much longer).  To get more accurate usage data you can add some event tracking code and record an event every time the game begins.

I decided to add event tracking to several widgets in my blog so I can know which widgets are being clicked by the visitors and which are not.  But adding event tracking to Blogger's built-in widgets was not very obvious.  I navigated to Design > Edit HTML tab of my blog's dashboard and selected Expand Widget Templates check box to see the code for widgets.


I had to locate each widget's code within the template.  Searching for the widget title text was sufficient.  Code for the label cloud widget, for example, starts like this:
<b:widget id='Label1' locked='false' title='labels' type='Label'>
<b:includable id='main'>
  <b:if cond='data:title'>
  ...
The widget code had different sections of HTML pertaining to different configurations provided by the widget (show list vs. cloud, show post count, etc).  I added onclick event handlers to the links so every time a link is clicked an event will be recorded.  Here's one such modification I made:
<a expr:dir='data:blog.languageDirection' expr:href='data:label.url' onclick='_gaq.push(["_trackEvent", "label-cloud", "follow-link"])'><data:label.name/></a>

Now that event tracking is in place, decision making in the future will be easy.  Hopefully :)

February 13, 2011

Clarity

The world is clear in our eyes only when it has enough bright parts and enough dark parts.  If brightness is all that matters we will all be seeing the sun most clearly.

My experience with the Kindle

Few of my friends have considered buying a Kindle and are hesitating because they are not sure what they are getting into.  They aren't sure, for example, if the Kindle can give them a good reading experience without the "feel" of holding a paper book.  This post is a short summary of my experience with the Kindle.  (I have a Kindle 2, by the way.)

First, the negatives.  Turning pages is slow.  It works pretty well when we are reading normally, so you won't notice it most of the times.  But it feels very slow when we want to hop back 2 pages to take a momentary look and continue reading from the current position immediately after.  Books with complex layouts (e.g. books with code) can be difficult to read.  It's just not possible to lend books to your friends.  And not all books are available in the Kindle format.

Now the positives.  It's amazingly light and extremely portable.  I read Anna Karenina using the Kindle.  I can't imagine carrying a fat heavy paper book everywhere I go.  Because Kindle lets me take notes on the device itself, collecting quotes is really simple.  I'd just highlight interesting quotes as I read and they'd magically appear on my Kindle page on the Amazon's site.

It might sound strange but I choose books based (also) on their typography.  If a book uses an ugly font (Arial!) or very small text size, I usually won't buy it.  Long back, I bought a copy of The Fountainhead but never could read more than a few pages until I gave it away a few weeks back.  All because of its tiny font size.  Kindle, because it allows me to change the text size to suit my eyes, solves this problem completely.

True, Kindle doesn't have a backlight so it's not possible to read when it's dark.  There are several solutions to the problem.  You can buy a case with an attached reading light.  Or you can read using the Kindle app on any of your other devices.  Because the Kindle and these apps always sync to the cloud, they automatically take you to the last page you were reading across all devices -- this is a pretty cool feature.

I am not a native English speaker, and my vocabulary isn't great.  Every time I read a book in English I need to look up hundreds of words on the dictionary.  Either that would be a distraction and would take up a lot of time.  Or I'd read on without fully appreciating what's being said.  Kindle has a built-in dictionary that's very well integrated with the device.  It's fast and doesn't require net connection.  It saves me a lot of time and provides an improved reading experience.

I once thought I would miss paper books after using the Kindle as my primary reading device.  On the contrary, I often miss the Kindle now when I have to read paper books!

February 11, 2011

What should we give kids?

Maybe all we need to give our kid is freedom[*] and respect[**].  Kids are smart enough to figure out life by themselves.  Maybe just being available to them when they need us, and staying out of their way otherwise is what we should do.

[*] In addition to parents giving them freedom, they should also ensure that they get freedom from other people too.  For example, by not sending the kids to schools that would punish them for speaking to their classmates in a non-English language.

[**] By "respect" I mean several things.  Believing that they know what's a right choice and what's not.  When they say something to us listening to them seriously.  Treating them like we'd other adults: when we have a problem with their behaviour we tell them to stop it; we don't have to give them the "freedom" to burn our houses down.

February 08, 2011

Can't customize ad placement in Blogger?

Are you trying to add ads to your Blogger blog, but the blog Layout doesn't show the ad gadget at all?  Maybe you're running an ad blocker extension (like AdBlock for Chrome or Firefox).  Do the following to get going:
  • Disable your ad blocker extension on blogger.com and draft.blogger.com domains.  Otherwise you cannot customize where ads are placed on your blog.
  • You will want to see how your blog looks to others without ad blocking.  So, whitelist all your blogs so that ads won't be blocked on your own blogs.

February 03, 2011

Commuting is more than getting to work

I visited Sydney in the beginning of January, and stayed there for two weeks.  Since returning I have been using the office cab for commuting to work.  Today, I had to run some errands on the way to work, so I took my bike.  There's nothing new about my riding to work, and nothing new happened on the roads today.

However, I could see how angry and upset I became because of the (reckless) traffic.  It made me feel so negative, I could not focus on work!  It took me more than 4 hours before I could start wanting to do any work.  It wasn't like that till yesterday.  But it has been like this for a really long time in the past.  Now I know why I couldn't perform well at work: I was spending most of my energy in nursing my anger with Hyderabad instead of doing productive work.

I am transferring out of Hyderabad pretty soon.  In the light of this revelation, I am thinking I'd then stay very close to office and walk to work.  It might be expensive, I may not get to spend an hour reading news during commute, etc., but it definitely would keep me in good spirits to get the real work done.  (I know many people don't, but I like the time spent in commuting.)  Getting real work done will make me proud, sulking about things beyond my control will not.

February 02, 2011

Gmail in Droid Sans font

Like Gmail, but not the Arial font it uses?  There's a way to make Gmail use a more readable font!  Here's what you have to do:
  1. Install Droid Sans font on your computer:
    • If you use Windows or Mac OS, download Droid Sans font from Font Squirrel (or any other source you can find).
    • If you use Ubuntu, run sudo apt-get install ttf-droid from command line.  (Only apps that are started after the installation will see the new fonts.  You may try restarting your programs, or if that doesn't work just log out and log back in.)
  2. Change your Gmail theme to Android.  (It can be done through Gmail settings page.)
That's all!  Here's how my Gmail looks in the Droid font.  (Click on the image to see a bigger version.)