Wednesday, November 10, 2010
Saturday, November 06, 2010
- independence of JAVA
- popularity of WINDOWS
- security of LINUX
- luxury of .NET
- efficiency of C
- simplicity of HTML
- vastness of GOOGLE
- robustness of IBM
Saturday, October 09, 2010
Most of us who use the bash shell in *nix environments, often find the Tab-key auto-completion to be a very helpful timesaver. But one of the main problems is that he feature is not adaptive, i.e. it does nothing to learn from my previous commands. For example in my home directory I have two folders: “picture” and “programming”. Usually there is no reason for me to traverse the “picture” folder using bash, I’d rather use nautilus for that. So when I type something like “cd p” and press Tab, I would ideally like to get “programming” rather than “picture”. What if we could somehow use the history of commands to help this auto-complete feature?
Here is a cool bash trick that I have been using for quite sometime. It helps me search the history of typed commands that begin with what I have typed so far. Here is the way to enable it in your system.
Edit the “~/.inputrc” file by appending the following lines to it and save it:
Note that the file “~/.inputrc” might not be present in your system, so in that case you will have to create it.
Now to use this feature, open a new instance of the shell and type something like “cd p” and press the PageUp and PageDown keys to search the history of commands that begin with “cd p” backwards or forwards and cycle through them.
Personally I find this quite a time saver. However note that the completion feature is not directory aware, so like in the previous example it might just give you the name of a directory that does not exist in your current path.
Sunday, October 03, 2010
The puzzle goes like this:
A set of 12 coins of similar shape and size contains one counterfeit coin, whose weight is different from that of the other coins. Find the coin using a balance and minimum number of weighing.
The catch of the problem is that it is not mentioned whether the counterfeit coin is lighter or heavier than the rest of the normal coins.
Let us first examine what is the minimum number of weighing required to find the coin. We use information theory based approach for getting this.
Each weighing can have three different outcomes,
- left_side < right_side
- left_side = right_side
- left_side > right_side
Thus min number of weighing >= ceiling (log 12 base 3) = ceiling ( log(12)/log(3) ) = 3
Well, as it turns out, we need exactly 3 weighing. The method is kind of confusing to describe, so I drew a flowchart (PDF) for the same (click on the image for the full sized image):
Campus recruitments were about to commence so I was in hunt for good puzzles to hone my problem solving skills. A friend of mine sent me this gem. I was used to tackling coin puzzles, but this was unique as the weight of the counterfeit coin was not given. I tried it and getting the 4 weighing solution was quite easy to get.
Next I gave this problem to my friends at IISc, Dyut, Abhiskek and Arghya. After a lot of attempts Dyut and Abhiskek could not improve upon my solution. After a few days I tried it again. Particularly the case where the first two groups were unequal. After a couple of attempts with a fresh mind, I cracked it. Later I found out that my friends had also figured out the solution from some other friend, who solved it at the very first go. Well there are no dearth of brilliant guys IISc !
Thursday, September 09, 2010
I had been introduced to the C language in the very first day of my B.Sc. course back in 2003. Since then I have been using it for doing quite some varied kinds of programming jobs. But even after so many years, its every now and then that I find out something I did not know before. Here is one such thing that I encountered few days back.
I was taught by both my C teachers in B.Sc. as well as in B.Tech. that the modulus operator in C (denoted by the “%” sign) behaves exactly similar to the mod function that is defined in Mathematics. However here is something weird that I saw recently. Better to show it by code:
The output given is:
( 1)%( 6) = 1
(-1)%( 6) = -1
( 1)%(-6) = 1
(-1)%(-6) = -1
This does not match at all with the definition of the modulus operation that we have learnt in Mathematics classes. Specifically, modulus can never be negative. So something must be wrong. As it turns out C’s modulo operator behaves differently from the mathematically defined ones when we apply it for negative numbers.
The C90 standard does not define the result of modulus applied on negative numbers, so the result is compiler dependant. But C99 clearly says that the sign of the result is the same is that of the dividend, so in essence for something like:
c = a%b;
The actual operation done is:
c = sign(a) * ( abs(a) % abs(b) );
- sign(a)=1 for a>=0
- sign(a)=-1 for a<0
Wednesday, September 08, 2010
I am a big fan of free online storage for my backups. So far Microsoft Skydrive seems to be the best one in terms of space. But the one thing which I hate about Skydrive is its incompatibility with any application. Ideally I would have liked to use the online folders as easily as my local folders. For example had the folder been openable in Explorer, then we could have used the “copy-paste” and “save in” features available for any local directory. Surely the latency would be higher, but at least there would be no need to do thing separately.
Anyways, here is a hack (not yet perfected but works so far) devised from various sources which allows anybody to mount his/her Skydrive folders in a local directory. This is formally called network mounting. The trick is simple enough for novice users too. Just follow the simple steps:
- Log-in to your sky-drive account from http://skydrive.live.com/
- Look into the address bar, you should see something like “https://cid-xxxxxxxxxxxxxxxx.skydrive.live.com/”, where the ‘x’s would be replaced by your unique customer-id. Copy the 16 characters of customer-id.
- Now open Notepad and do the following very carefully:
- and paste this 16 characters
- Note down the name of the folder that you would like to mount, say “MyOwn”
- In notepad create this URL (without quotes): “\\docs.live.net@SSL\xxxxxxxxxxxxxxxx\MyOwn”, replace the ‘x’s by your unique 16 character customer-id and replace “MyOwn” by the folder name (as it appears in Skydrive) that you want to mount.
- If you are trying to mount the default folders “Public” or “Documents”, then you have to use “^2Public” and “^2 Documents” in place of “MyOwn”.
- Now copy the final URL that you made.
- Open Explorer
- On the left side-bar, right click on “Network”, and select “Map network drive”
- Paste the URL you copied from Notepad.
- Select a drive letter, preferably something at the end of the English alphabet like “Z”, and hit the “Finish” button.
- You would be asked for your Windows Live-ID and password, which you must provide.
- Voila, you can now see the contents of that drive inside explorer by going to the drive you selected.
- Now you can use this folder just like any other local hard-drive folders. Open files from this drive by double clicking, save files, cut-copy-paste files to and from this directory.
Try it out, I’m sure you will stop using the online version after using this trick.
Now, a word of caution. This is NOT an official method, so Microsoft does not give you any guarantees of any kind for this method to work. So one fine morning this method might just give a lot of errors and rendered ineffective. But till then (and I believe chances of that happening is quite slim), utilize this feature.
Lastly the file size restriction still applies (50Mb per file). So unless you are felling adventurous, do not try this out with files lager than 50Mb. Sadly this thing does not work for non-Microsoft OS (Linux, to be specific). If I get something working on Linux, I will post it here.
If you have any questions/recommendations please post it here. I usually reply within a day.
Saturday, June 05, 2010
An Old Story:The Ant works hard in the withering heat all summer building its house and laying up supplies for the winter. The Grasshopper thinks the Ant is a fool and laughs and dances and plays the summer away.
Come winter, the Ant is warm and well fed. The Grasshopper has no food or shelter so he dies out in the cold.
Indian Version:The Ant works hard in the withering heat all summer building its house and laying up supplies for the winter. The Grasshopper thinks the Ant's a fool and laughs and dances and plays the summer away.
Come winter, the shivering Grasshopper calls a press conference and demands to know why the Ant should be allowed to be warm and well fed while others are cold and starving. NDTV, BBC, CNN show up to provide pictures of the shivering Grasshopper next to a video of the Ant in his comfortable home with a table filled with food.
The World is stunned by the sharp contrast. How can this be that this poor Grasshopper is allowed to suffer so?
Arundhati Roy stages a demonstration in front of the Ant's house.
Medha Patkar goes on a fast along with other Grasshoppers demanding that Grasshoppers be relocated to warmer climates during winter .
Mayawati states this as 'injustice' done on Minorities.
Amnesty International and Koffi Annan criticize the Indian Government for not upholding the fundamental rights of the Grasshopper.
The Internet is flooded with online petitions seeking support to the Grasshopper (many promising Heaven and Everlasting Peace for prompt support as against the wrath of God for non-compliance) .
Opposition MPs stage a walkout. Left parties call for ' Bengal Bandh' in West Bengal and Kerala demanding a Judicial Enquiry.
CPM in Kerala immediately passes a law preventing Ants from working hard in the heat so as to bring about equality of poverty among Ants and Grasshoppers.
Mamta Bannerji allocates one free coach to Grasshoppers on all Indian Railway Trains, aptly named as the 'Grasshopper Rath'.
Finally, the Judicial Committee drafts the ' Prevention of Terrorism Against Grasshoppers Act' [POTAGA], with effect from the beginning of the winter.
Kapil Sibbal makes 'Special Reservation ' for Grasshoppers in Educational Institutions & in Government Services.
The Ant is fined for failing to comply with POTAGA and having nothing left to pay his retroactive taxes, it’s home is confiscated by the Government and handed over to the Grasshopper in a ceremony covered by NDTV.
Arundhati Roy calls it ' A Triumph of Justice'.
Mamta calls it 'Socialistic Justice '.
CPM calls it the ' Revolutionary Resurgence of the Downtrodden '
Koffi Annan invites the Grasshopper to address the UN General Assembly.
Many years later ...The Ant has since migrated to the US and set up a multi-billion dollar company in Silicon Valle. 100s of Grasshoppers still die of starvation despite reservation somewhere in India.
As a result of loosing lot of hard working Ants and feeding the grasshoppers, India is still a developing country !
Last WordsUsually I stay away from publishing other people's contents on this blog. However, this post actually breaks the rule. The above is an email forward sent to me by my my uncle Dr. Tamal Deb. I do not know the original author, but the story made a lot of sense to me.
Friday, May 28, 2010
- Go to "System Preferences"
- Select "Sharing"
- Unlock the lock symbol at the bottom-left corner
- Check "Remote Login"
- Now close this window and try out ssh-ing to your machine. In case you do not know the IP of your machine, type "ifconfig" in the terminal to get it.
Disclaimer: I am a Mac newbie, its only since last one week that I have been using it. The above procedure is what I figured out after some attempts in my Mac Book Pro running OS X. I do not really know if it would be the same for other Macs as well.
Friday, May 07, 2010
- Download the template from the IEEE Manuscript Template page. Presently the file-name for Unix is "IEEEtran2.tar.gz".
- Extract this file in a folder IEEEtran.
- Within that create a subdirectory "bibtex"
- Download the bibtex file "IEEEtranBST1.tar.gz" from the same IEEE Manuscript Template site to this directory and extract.
- For Ubuntu users:
- Move IEEEtran directory to /usr/share/texmf-texlive/tex/latex/
Move IEEEtran directory to /usr/share/texmf/tex/latex
- After following these steps, you have to restart LyX.
- Go to Lyx > Tools > Reconfigure
- Restart LyX
- To use this template just select IEEEtran from the Document Settings.
Friday, April 16, 2010
Thursday, April 15, 2010
I got a few poems/couplets on sms/email today wishing me "শুভ নববর্ষ ১৪১৭", which in Bengali is "happy new year 1417". Usually these poems have a very short life-span. They stay in the phone/mailbox and are very soon forgotten. So I decide to share two of them with everybody, in an attempt to increase their life-span a bit.
Both the poems are naturally in Bengali, although I got them in the English font. I decided to put them up in their original fonts.
First poem (sent to me by my friend Arijit):
নতুন আশা, নতুন গান,
নতুন করে মনের টান,
আমার সুভেচ্ছা সাথে রেখো,
নতুন বছর ভালো থেকো
শুভ নববর্ষ ১৪১৭
Second poem (from my uncle Dr. Tamal Deb) :
পুরোনোকে দিয়ে ফাকি,
নতুন ভোরের আলোর সাথে
নতুন সাজে উঠবে মেতে.
শুভ নববর্ষ ১৪১৭
I do not know the original sources of these lines. It would be interesting if anybody can find out something about it.
Sunday, April 04, 2010
So this year also Googlers have gone out of their way to put up some April Fool jokes. Being a fan of Google, I tried to collect the set for 2010. Initially it was in the form of a April Fool buzz, with only the links. Then I thought of putting up this article.
Chrome with 3DWe all know about Chrome, a browser from Google that claims to renders "web pages and applications with lightning speed". This year Google put up a page for a 3D version of Chrome, dubbed as Crome 3D, there was a official post in the Chrome blog about this release . Users had to run the application on their normal screens and they would need a special set of glasses to enjoy the 3D effect.
|Googlers testing out Chrome 3D|
Vowel OutageThe official GMail Blog reported a vowel outage at 0649 hrs on April 1st. The post says:
... during routine maintenance at one of our datacenters, the frontend web servers in that particular datacenter started failing to render the letter 'a' for a subset of users.This was very funny. Some of my friends upon receiving this link from me me even replied that they kind of felt something wrong with the interface ! Two of them replied whether this was technically feasible !
... we're experiencing Gmail’s first temporary vowel outage.
Google changes its name to TopekaThis was not as elaborate in execution as the Chrome 3D joke which involved someone actually coding and testing the whole thing and then putting it up. This was limited to just a simple blog post titled "A different kind of company name" in the official Google blog. Apparently Google was changing its name to "Topeka", for some weird reason.
|New Company Name|
They even published a guide to the proper usage of the word Topeka.
|Proper usage of the new name Topeka|
Capability to Store Physical Objects in GoogleGoogle is offering to store any physical items with them for a charge of $0.10 per kg. This was put up in the main Google site as a coming soon stuff. The page also includes a few user testimonials. This is one of those things that would be great if it happened in real life. This hoax was also put up in Google Docs blog on March 31st.
Translate Animal Speech
Google UK put up this awesome joke as a web page for a futuristic application that could Translate Animal Speech. This was complete with tours and video demos of the application.
ConclusionThis year Google seems to have gone out of their ways to create so many of these jokes for April Fool's day. I am sure there were a few more which I might just have missed. Personally the Chrome 3D was the most gullible one. I managed to convince one of my friends to install Chrome 3D and take a print out of the glasses.
If you come across some of the other things that I might have missed, do drop me a line.
Saturday, March 13, 2010
Basically it generates equations which when plotted will generate the word that someone has typed.
Here are some other articles that caught my attention in that blog:
- Be a self-teacher
- Swapping + and - signs
- Are you living inside a computer simulation?
- Experience with computer programming
The computer simulation article was like straight out of Matrix trilogy. I have thought about this a lot, and its kind of weird. The mind says its impossible, but logically this could be a possibility. In 2001 Prof. Nick Bostrom published a paper with same title. You could read the paper and look into the website that the Prof has created.
Wednesday, March 03, 2010