Sunday, January 19, 2014

Not posting for a year

Will start this post with an apology. Its been more than a year since I last posted. Lots of things have happened since my last post. {got married, moved to a different work team, changed house twice}. The principle reason however is different.

My recent posts have been mostly along lines of "how to do X" where X is some interesting thing which I stumbled upon recently. There is no central them to X. Mostly it revolves around Linux/Unix, Internet and ML; basically my work. With the popularity of Q/A sites like stackoverflow, "how to" kind of posts have been rendered unnecessary. A look at my blog statistics convey the same theme. My original contents like GATE solutions still attract majority of visitors to the blog; mostly from search engines.

Hence, from now onwards I will try to refrain from posting simple how-to questions from my work related fields. But original content is rare. I will continue posting on  topics like:


Anyways, will be posting more regularly now.

Saturday, August 25, 2012

Colors in bash

Bash is capable of generating a huge spectrum of colors for text. Here is a small code in shell script which generates all the 256 different colors bash can render:
for i in {0..255}; do printf "\x1b[38;5;${i}mCLR-${i}\t"; done; echo; reset;

The last echo is for printing a blank like after the output, without that the command prompt would appear at the end of the output. More import is reset present at the end, without which your terminal might not go back to the original settings.

In case you are wondering how to print colored output in terminal, please read:
Now you have a number to color mapping which you can use to specify your favorite color in config files of various command like applications like vi and tmux.

Sunday, July 22, 2012

ROC Curve

My recent work related to Text Classification got me introduced to ROC Curve which is a very effective way to compare classifiers against each other and decide on the cutoff value for classes.
Its best defined with a simple example. Say you have a binary classification problem. You have generated 3 train-test datasets from the original data. Say you are using Support Vector Machine (SVM) as the classifier. After training SVM on all the three sets, you want to select the "best" of these three. How do you go about it?

Here's where ROC comes into rescue. Sort the output of the SVM and compute True Positive %tage and False Positive %tage so far for each data point and plot this in x-y graph. The area under the curve will give you a way to measure the effectiveness of each classifier. Moreover you can use the nature of the graph to establish your positive and negative class boundary.

Here are a few links to know more about ROC curve:

Thursday, May 24, 2012

tmux, a Better Terminal Multiplexer than screen

Recently I encountered a program called tmux which claims to be better at "terminal multiplexing" than screen. I did not have any idea about "terminal multiplexing", but I had been using screen for quite a few years now. tmux promises to be better that screen according to the tmux sourceforge page. This got me interested.

I installed tmux, and have been using it since last 2 weeks. My experience has been great except for a minor hiccup between vi and tmux. I thought of writing a small tutorial, but I feel there are better and more detailed ones that I would have the patience to write; not to mention we all "stand on the shoulders of giants". So I am going to point you to the online resources:
Finally, tmux is quite good and it gives some features not in GNU screen. Unfortunately, tmux is not as popular as screen, so you should be able to use both. Here is my contribution to the community, a cheat sheet with popular commands for both tmux and screen together. Please note that I use Ctrl+a as my tmux hotkey rather than the default Ctrl+b. Here is the thing you have to add to your ~/.tmux.conf to achieve this:
unbind C-b
set-option -g prefix C-a
Copy-pasting in tmux is also quite easy. You can copy from any part of the command window. Go to the copy mode by Ctrl+a PageUp. Move around the terminal using arrow keys. Ctrl+Space to start marking the text from where you want to copy. Use arrow key to select text. Alt+w to copy the text. Paste text using Ctrl+a ].

Thanks for reading.

Wednesday, May 23, 2012

Reload .inputrc at runtime

If you have been playing around with bash for some time you must have changed the file .inputrc sometime. I have changed it several times mostly for Del key and auto-completion trick. However every time I change it I have to logout of bash for it to take effect. Here are two different ways to do the same without logging out of the shell.
  1. Keyboard shortcut : Ctrl+x followed by Ctrl+r
  2. Script : bind -f ~/.inputrc
Here is an excerpt from my .inputrc which many others might find useful:
"\e[1~": beginning-of-line          # home
"\e[3~": delete-char                # delete
"\e[4~": end-of-line                # end
"\e[5~": history-search-backward    # page-up
"\e[6~": history-search-forward     # page-down
Hope this helped you.