Monday, January 26, 2009

अचार 5 पचरंगा

I have decided to write as frequently as possible on offbeat subjects which I have come across in my life. I did my graduation in NIT Kurukshetra. The best and easiest way to reach Kurukshetra is to board a bus from ISBT Bus Depo and get down at Pipli. Now what has the bus journey to do with the title of this post ?
I am pretty sure, no one would have heard this term ever ! "Pachranga" is a brand of pickle very famous in northern India. If you are travelling on GT Road you would find infinite shops selling this pickle. I checked on Google Patent Search and no patent has been filed till now. If there is no patent, how can it be an international quality without being exported ? I am still wondering how pickle can be such a highly consumed item in households! I still do not have a concrete answer. I asked some of my friends, but I found none of the answers satisfactory. It can't be due to appetite of Jaats or the dominance of a single brand of Pickle. One of the most probable reason for putting the "5 Pachranga" dashboards can be the advertisement value the company pays.
The context is similar to having a freeze sponsored by Coca Cola and stocking all kinds of Cola's in it.Marketing and advertising has penetrated every industry by far greater proportion than is thought of but the figures look deceptive.

Bus Ride in Bangalore

If anyone asks me what is the least expensive medium to commute in Bangalore, I would say it has to be a Rick. I am not nouveau riche for making such a statement. AFAIK, if you consider the actual cost of travel, the cheapest medium has to be a BMTC Bus. However, we can't neglect the other hidden expenditures involved when you travel by bus. For example losing your mobile phone, getting your purse flicked. If we apply Hess's law of summation, Rickshaw works out to be the cheapest medium to commute. I am not so good at mathematics, so I am leaving the statistics part for you to work out.
I own a motorbike, and my work timings are flexible. So I prefer to go out on my own. It had been a year since I got my motorbike serviced. I was riding it in a broken-down state for some time. Finally I made up my mind to get my motorbike serviced. I went to the Bajaj showroom from where I had bought it and finished the formalities. I had to reach office somehow! It was damn hot on that day. So I thought an AC Volvo bus is going to be the best option as I had never traveled by AC Volvo before ( and a bus for the last 2 years). You know, all great Laws of Nature always have exceptions. That's the reason we have Exception Handling. Another reason for boarding a AC bus is because they have the signboards written in English. I had to reach MG Road from Manipal Hospital. The people sitting around me seemed to be regular users of AC bus service. No one had patience to even look at me. It took me not more than 15 minutes to reach my destination. I got down at Trinity Circle and walked to my office( barely 5 min walk ). It was a fairy ride.

गणतंत्र दिवस मुबारक हो

I would like to wish "Happy Republic Day" to everyone. On 26th January 1950 the constitution of India came into force and India became a truly Sovereign, Democratic and Republic. I was in Delhi a few years back on Republic Day. Though I could not attend the grand parade, the atmosphere made me feel so good. Kite Flying in Delhi adds a different flavor to the celebrations.
One of my friend, Praveen, sent me a self-composed Poem. It was very touching, so thought of putting it here.

My dear land,
I bow before you, for,
You have filled my stomach, for,
You have provided me shelter, for,
You have satisfied my thirst,
I will carry you in my heart,

Till thy last breath, for,
You carried me like a butterfly underneath a leaf.

My mother,
I will be one among your children who lived only for you.
Till my last breath I will protect you and be one among your children who died only for you.

Oh Mother! you are my lovely mother, for,
You wept so much for me, for,
You bare so much for me.

I have sowed you at the depth of my heart, for I can see you grow everyday,
I nourish you with good thoughts, for you blossom everyday.

Jai Hind.

Sunday, January 25, 2009

Interesting journey of Pink Color

I am not here to be an activist nor a chauvinist. I am here just to express freedom of thought. This post is most targeted towards the male community. All female readers are free to read it and LYAO. What comes to your mind, when you think of Pink color ? I would like to get as many replies to this post to make it more interesting.
Well, I associate Pink color with a guy who sends me mails with a Pink colored font. !!! Here are the basic qualifications.

Pink is so gay
. This is what I feel when I see such stuff. Pink color has been associated with Gay Community from early 20th Century. In professional life, its considered impolite to command over someone to get something done. Email is rather more sensitive as compared to face-to-face talk as there are more chances that some things can be misinterpreted. Its better to be safe than sorry. I have already talked about Email Ethics in my previous post. In an evolving atmosphere I don't recommend everyone to follow the rules strictly. However, if promoting Pink color is a way of propagating the existence of Gay Community, please stay away from official communication.

Saturday, January 24, 2009

Cost cutting Idea

I work as a Developer in a reputed organization. Due to the ongoing financial crisis, declining operating margins and profits, companies are using every possible way to cut the expenditure. Starting from toilet-paper to air conditioner, you wouldn't know what will be off the store as every day passes. Some companies are even resorting to pay cuts. I thought of a noble idea which can be implemented in daily life by every individual to help save company's money just by refining you email sending habits. I would say its not all about money, it can save time of many people who rely on the fast speed of download for work.
I use email on the fly. I would be paralyzed if I don't check my email for more than a day. Could you give up email and go green ? That's not my intension! On an average I get 4 emails with attachments (photos, videos and what not - which I never bother to read or watch) per day. In my office every user has limited storage space on the server, so 10 people sending me forwards can surely fill up the allocated space for my account and all others important mails get bounced. Some of the obvious mistakes which can be avoided are
-> Do not send attachments in email unless necessary. Upload it in a central server if it is a official document and people who desire to read can download it. Believe me, 90% of the audience doesn't even read such emails.
-> Avoid HTML mails and fancy content as much as possible.
-> Use a Forgotten Attachment Detecter
-> Watch your habits. You can get into trouble.
If the file you're about to attach to your Internet email can be found elsewhere on the net, it maybe better to send the address of that location rather than attaching a copy of the file itself. If nothing else, this will save you some time because your system doesn't have to transfer the large attachment. Also, your recipient(s) can decide whether to download the file or not, where as if you had attached it, they may not have any option but to take the time to download it even if they don't want to. The organization can tie up with premium services like YouSendIt which does the heavy lifting for you. Another option is to use an alternative service like Domino Lotus for intranet email and Microsoft Outlook for other email and have strict attachment policies in place.
HTML Email isn't rich. Some of the things I hate the most is "Good Morning" mails. I don't care a shit about how many "Good Morning" mails I get. It takes me a whisker to delete all of them (add a rule), but at the end of the day, company is paying for all the stuff and everyone blames the corporates for cost-cutting measures. Here is a list of Common Email pitfalls and how to avoid them. It's hard to win an argument about saving bandwidth these days. Still, the next time you're about to send an email with large attachments, think twice!. In my next articles I will discuss about the Carbon footprint of email, benefits of using Google Apps and comparison of Outlook vs. Gmail.

Office spam

Its very tough to imagine getting spam in office mails. I categorize all unwanted mails( specially intended for very big mailing lists) as spam. The problem is sometimes I get useful mails from the people who are responsible for spam in office. The Reply to All option in Microsoft Outlook should be used with caution, else it qualifies to be a sin like 'rm -rf'. Last week the company HR sent a mail to "All Employees list" that accommodation has to be arranged to a new recruit. Fortunately, the offer letter in the mail wasn't part of the mail. On an average I get 3 to 4 mails every week due to such mistakes.
My suggestion is to disable the shortcuts for "Reply to All" and have policies who is authorized to send mails to certain mailing lists. If you are using Outlook 2007 or Outlook 2003, you can customize outlook to disable "Reply to All" with ease. Another very simple option is to defer delivery of sent mail.

rm -rf can't be forgiven

This week, I did a blunder. I did 'rm -rf' on a directory. Can this act be forgiven ? In my case, yes but not all the time. If its not, you qualify for a mention on The Daily WTF. Its because I take regular backups and I use some tools to automatically back up data for me. The reason for writing this post is to make linux users aware of the harm you can do to yourself and the system by issuing a single command.

Lets dig more into some trivial mistakes you can make.
rm -rf * .cpp // Intended to remove all cpp files.
rm -rf / // WTF ?
rm -rf .* // Remove all hidden files

If you are using ext2, recovery is easy. Also, if you want to use any tools for data recovery make sure that you don't write anything to the disk. For safety, unmount all partitions and connect your drive to some other computer and try recovering data. The freed blocks will be the first one to be used by the system so data recovery becomes increasingly difficult the longer the time partition is mounted.

The best option is to use an alias for rm command.
alias rm 'rm -i'

However the -f option will override the alias. Improving it further,
mv /usr/bin/rm /usr/bin/rm.bak


mkdir ~/.Trash &> /dev/null

while [ ! -z "$1" ]; do
mv "$1" ~/.Trash/

You can put a
rm -f ~/.Trash/*
in .logout in home dir. The disadvantage of this approach is, you will become dependent upon this behaviour of "rm", and you will find yourself someday on a normal system where "rm" is really "rm", and you will get yourself in trouble. So its better to define an alias mydelete for 'rm -rf'.

If you have none of the options implemented as described above, you can refer to Recover from rm and Recovering Linux files and filesystems for more info.


Follow me on Twitter

Memory leak Detection tools

If you are a developer, you would know how important it is to make sure there are no memory leaks in your code. I tried a few tools to examine the leaks in the code. I have tried to group all the information in this post.

A memory leak tracking tool should be
-> Platform Independent and can be cross-compiled for different architectures
-> Should support multi-threaded environment
-> Can be statically or dynamically linked
-> Should be able to generate call stack or line number in the code
-> Should be able to detect double free, memory overwrite, buffer overrun and underrun errors

Valgrind is the most powerful for catching leaks in C/C++ however, it can't be cross-compiled on different architectures. Valgrind also has a inbuilt Heap-Profiler called Massif.
dmalloc is a very useful tool and satisfies all requirements on embedded systems and is supports mips architucture. dmalloc requires source recompilation which is an overhead.
Electric Fence effectively catches overwrites but could not even find even a single memory leak in my test code.
Google Perftools has a excellent heap-profiler. I have not used this framework extensively as it can't be cross-compiled for mips architecture.
Bounds Checker is a very good tool for development with Microsoft Visual Studio.

I did a bit of googling and found some very helpful links. Do visit Memory Leak Detection in Embedded Systems, Memory Checker comparison and my favorite Google-perftools

Kernel Profiling

I got an opportunity to try my hands on a proprietary OS ( lets call it OS-XYZ, If I call it OSX, Steve would sue me)and when I compared the performance with a normal linux machine, OS-XYZ seemed to slow down the system by a factor of 3. The test program runs in userspace and library calls ( eg. glibc ) are translated to system calls in kernel space. The best approach to investigate is bottoms-up approach. See if everything is going fine in the kernel.
The next step is to do "kernel profiling" to find the exact difference and see if the kernel patches in OS-XYZ are affecting the system performance. Please see introduction to kernel profiling.
You need to make sure that the following points are taken care before starting off -
1) Kernel should be compiled in debug mode by executing
make menuconfig
Check the kernel .config file for

2) Copy the
file to say

3) Boot with the new kernel with profile=2 option. This will generate a profile file

Execute the following commands to do the profiling when running the test_program.

readprofile -r
readprofile -M1
readprofile -v -m /boot/ | sort -n +2 | tail -40

This will print the functions called in kernel space, number of ticks, and number of times each function is called. Also see man readprofile

Once you are done with the profiling, examine the data and compare the sources in
and get going.

Checklist -
-> Make sure all kernel modules ( *.ko) are present in the patched kernel.
-> Think of ways to restore the box, in case kernel fails to load up or on kernel panic.

One less tooth

It's been a long time I have updated my blog. I don't want to give any excuses, rather would like to clarify that I am not as passionate blogger as some of you may be. I love the concept of blogging, but one has to be dedicated and should devote some time regularly to blog. This is my third attempt. Only time will tell whether I make it this time.
Last few days, I was having immense pain in my right-upper jaw while eating. I had been told earlier that the wisdom tooth hasn't erupted properly and has to be removed. I wasn't so brave at that time and kept my decision of hold (Thanks to some antibiotics which relieved the pain). I remembered the poem by Ogden Nash This Is Going To Hurt Just A Little Bit. I still fear the dentist, because of the sharp pointed tools they use and the way they use them.
The next thing was getting the best consultation. I got the reference of a well known dentist in Jayanagar. I called him up to fix up an appointment. He told me that its a complex procedure, and he cant operate ( I had to go to Oral Surgeon ) on me on the same day I take the first appointment. Finally I made up my mind to visit the dentist . So called him and told him approximate time when I ll be coming.
I had to leave office early to make it on time. It took me a while to find the place ( I don't travel so often in Bangalore and South Bangalore is one of the rarest places where I go ). I was pretty relaxed. He examined my teeth and told me that the wisdom tooth is decayed and has to be removed. He also showed me the injury done to my cheek. I could see a small hole ( kinda ulcer). He gave me an option to get the tooth removed right away or some other day. Considering the fact that traveling in Bangalore city is a PITA, I thought that this is the time to go for it. The dentist had to give local anesthesia for doing the extraction. Believe me, it pains a lot when the doctor administers the anesthesia. Its like getting poked in a bone. It took 5 minutes for the anesthetic to take effect. The doc pulled a nice and sharp instrument. He did something and told me to spit. It was all blood. Doc started the operation again. He made a lining on the outer boundary of the gum, picked up a pair of tweezers and pulled the teeth right away. I was happy that it didn't pain.
The doc offered some advice and a prescription of pain killer ( in case it hurts ). The doc was confident that its not gonna hurt. It took max 15 min the finish the whole procedure. I was fortunate that it was the upper wisdom tooth. If it was lower the procedure is very complex and as per my understanding the bone has to be cut to get it extracted. I took the extracted tooth with me, thanked the doc and left.
I had to come to office for some work. It was still bleeding and I had to swallow everything. In an hour I could feel the pain and as time passed it got more painful. I left for home, picked up some curd rice and medicines on the way. I could barely open my mouth and it was paining like hell. I called up my cousin who is a dentist and asked her for advice. I finished my dinner and took the painkiller. I slept in 30 min or so. I couldn't sleep, but still tried. When I got up today, it was all fine. As a precaution I decided not to eat anything hard.