~:: kalyan ::~

November 1, 2009

Yet another post!!

Filed under: life — skalyanasundaram @ 7:30 am

I have been missing almost ten months now. :) I should wait for two more month to make a record of not writing blog for a year? Right after I joined the new team at work, i have been busy. It would be a lie if I say i did not have time to write blog.

Recently my friend had suggested me a book called “Nilamellam Ratham” by p.Ragavan, this book is really appreciable. This book is about the history of palastin-Israle problem since from Roman’s time to till today. The important point is that he did not write his opinion alone, rather he wrote it as facts. At the end he had summarized all the events was nice. I coulnt stop reading once I started.  Now reading another book called “Vantharkal Venrarkal” by the cartoonist Madhan. This is again a blood report of the North India till to British time. Right now I am on the TajMahal’s history. Poor Shajahan didnt get his dream of a black TajMahal which is ignored by his son. The one thing I couldnt forget is “Feros Tuklak’s” Minister “Khan Jagan Magbul”, he is a very talented guy.  He had habit of collecting  beautiful girls around the world. He had collected 2000 girls. :O He must be a guy with a lot of taste and enormous testosterone ;)

Apart from that there is one more blog which attracted my attention.  He is writing lot of about the tamil Literature and historical events of India and mostly Tamil Nadu. I think he and his friends make visits to those historical places sometime. I would be happy If I can join them next time.

Today woke up at 5 in the morning and gone for a ride alone. It is about 25km. My target was to meet Mr.Hanuman. Hanuman temple is in the TCpalya village. I drew a map around. But when I am almost there i lost the path. There was new paved road just before my route. I just jumped on it. But that lead to me a graveyard. :). Death and evil is always more facinating than the good and god. Later I was sure I am lost. But I had taken a printed map along with me. But I couldnt  figure out, because I could not beleive that google maps actually show up the sand roads where no one lives. So i thought the paths shown in the map is someother different route. Latter I decided to do the military rule of “Burn the map” and follow the instinct. I could a hear loud speakers of a temple from long distance. I followed it up and after passing few rough roads it connected me to Hanuman Temple. There after everything was smooth.  Since I was navigating myself and felt like lost, forgot to take snaps. Next time!!. It was short ride though. But its perfectly fine.

January 29, 2009

emacs tweak

Filed under: emacs, Linux, Script — Tags: — skalyanasundaram @ 5:34 pm

Backspace
While programming in emacs have you ever felt, you have a tab character (it is “\t” and not 8 contiguous space) and when you press backspace, instead of deleting the “\t” character, it deletes the characters one by one. It happens atleast in c, c++ mode and but not in python-mode. So you press a tab character to undo that press backspace 8 times. Isnt that tedious?

In the background the backspace character is attached to a function called “backward-delete-char-untabify”. This first converts the tab to chars and delete one character.

Lets fix it,

put this in your .emacs

(gloabl-set-key [backspace] ‘backward-delete-char)

This function does only one job, just delete the preceding character, including “\t”.

This gets applied globally everywhere in emacs. But we want to do this only when do programming. Lets do this only when we load the c-mode by doing the following

(add-hook ‘c-mode-hook ‘(lambda ()
(local-set-key [backspace] ‘backward-delete-char)))
Add this to the specific mode’s hook where ever you want to fix.

Update

Ofcourse, the above was a poor man’s solution. I did not mention it fully. When c-mode gets loaded the backspace is bound to c-electric-backspace. This take two direction based on the inputs and a variable.

first it checks the variable c-hungry-delete-key, if its true, it calls c-hungry-delete-backward which delete all the whitespace including the new line. By default this is set to nil. If you want this do M-x c-toggle-hungry-state.

Otherwise it calls the function pointed by the variable c-backspace-function. By default it points to backward-delete-char-untabify. This is where we reach if you have not modified any variable.
Now we have two solution,

1. set the variable “c-backspace-function” to “backward-delete-char”
2. The backward-delete-char-untabify again operate based on the variable “backward-delete-char-untabify-method” by default its untabify. It can take 4 values,
“untabify” – convert tab to space and delete one char
“hungry” – delete all the tabs, space backward
“all” – delete all the tabs, space and newline backward
nil – delete only one character whatever it is.

Our expectation is to delete one tab at a time. So set the variable backward-delete-char-untabify-method to nil. That should do the job

January 27, 2009

emacs tweak

Filed under: emacs, Linux, Script — Tags: — skalyanasundaram @ 8:36 pm

If you are working on a perl file and using emacs then emacs can really help. By default the perl-mode is loaded. Thats bit old I guess. Instead use cperl-mode which is much more improved than the perl-mode. With the cperl-mode you can get

  • Electric mode, its when you type if it automatically generate if () {}…
  • Better font-lock mode for perl
  • Help. Keep your cursor on some keyword for example use after a few seconds the minibuffer will show the help of use operator.

So make sure to replace the perl-mode by cperl-mode by doing the following in your .emacs

(defalias 'perl-mode 'cperl-mode)
and also load all the functionality by,
(setq cperl-hairy t)

Apart from this I also use flymake-mode which compiles your program as you type and mark it when there
is an error found. Load the file,
(load "~/.emacs.d/flymake.el") and enable the flymake mode.

I also see this flymake can work for c,c++,java, but haven't tried that. I also see some php extensions.

live dance programs chemistry

Filed under: General, life — skalyanasundaram @ 8:17 pm

Every live dance program starts from sun tv’s “manada mayilada” to AXN”s “you think you can dance”, every judge never forgets to say that the chemistry was good. Isn’t that the physiological factor that they are talking about? Why they are calling it as chemistry. Or is it that Androgen/Testosterone that they are talking about. What about botony, zoology then?

January 23, 2009

emacs tweak

Filed under: emacs, open-source, Script — Tags: — skalyanasundaram @ 5:58 pm

In my old project there used to be many #if 0 .. #endif which does not fall in to the comment-face of the c-mode. This always confuses me. It would be good if that block is colored like a comment. So that i can just ignore that place.

I wrote the following elisp code which adds the #if 0 section to the comment section keywords of the c-mode.
(font-lock-add-keywords
'c-mode
'(("\s-*#\s-*if\s-*0\s-*n\(.*n\)*?\s-*#\s-*endif\s-*" 0 font-lock-comment-face append)))

I have left \s-* in many places as it is because even using back reference does not improve any readability.

December 27, 2008

Christmas Holiday

Filed under: General, life — Tags: — skalyanasundaram @ 7:02 pm
  • Solved Rubix cube
  • Could solve the rubic cube. Dont know what method its. Right now taking lot of time to solve. 
    I guess i will end up breaking my cube some time, still need to practice for the nice movement.
    Look at my solved cubes, :)
    rubix
  • Finished reading Veronika Decided To Die
  • After reading The Alchemist, johnny suggest this one. This is indeed good. I liked it.
    The whole story was moving inside villete. "Every one is mad, the one whos not mad is
    whos not showing others that he/she is mad" is nice. Inspiring book. So, What next?
    Rich dad Poor dad? or Seven Ancient Wonders?
  • Watching TV a lot
  • Children of Heaven movie is cute, slow movie though.

And Advanced Happy new Year.

December 25, 2008

LOC counter

Filed under: open-source, Script — Tags: — skalyanasundaram @ 6:19 pm

I moved to a new project at work. I thought i would count the loc. AWK is cool for this job.

BEGIN {x=0}
{
if ($0 ~ /^[[:blank:]]*/*/ )  {x=x+1}
if(x > 0 && $0 ~ /.**/[[:blank:]]*$/) {x=x-1}
else if(x==0 && $0 !~ /^[[:blank:]]*/// && $0 !~ /^$/) {
print $0
}
}

There are lot of free loc counters available. May be i am re-inventing the wheel. Anyway it is my version. Comments are welcome. This does not count the single line comment and multiline nested comments and all blank lines are ignored.

You need to call this explicitly like, > find . -name *.c -or -name *.h | awk -f ./abovefile.awk | wc -l

Merry Christmas!!

Filed under: General — skalyanasundaram @ 5:47 pm

Did absoutly nothing today other than waiting for santaclause and watching TV at home ;)

November 2, 2008

AWK After Diwali

Filed under: General, Script — Tags: — skalyanasundaram @ 6:55 am

Took a long break for Diwali, six days stay at home. After Diwali settled down at home had nothing to do other than sleeping and eating. TV was boaring. So sat with awk manual. I have had problem in managing my music library. The provider always add his name to the song name like “Sitename – Songname.mp3″. The meta data like album,composer can be managed all together with iTunes, but the name has to be renamed one by one manually. I was struggling to write a shell script. I knew there is some way with awk. And finally i found a way with awk script. Here it is.

ls -l | grep -v "total*" | awk '{val=($(NF-2)" "$(NF-1)" "$(NF)); printf("mv "%s" "%s" n",val, $NF)|"sh"} END{close("sh")}'

I have started using mutt, ppl are moving from text based application to desktop application and now to browser application. Johnny says i am going in the opposite direction. True! anyway this is just fun. I was configuring the addressbook for mutt. Though there are multiple options like lbdb, abook, I still wanted to use the simple mutt alias. But the command add-alias is interactive. I wanted to write a macro which just takes the from field and add to the alias without any interaction. Here is the macro which i wrote

macro index,pager <Esc>a "<enter-command>unset wait_key<enter><pipe-message> awk '{if($1=="From:") { sub(/^"/, "", $2); sub(/"$/, "", $(NF-1)); name=tolower($2) tolower($(NF-1)); print "alias", name, name, $NF >> "/home/tree/.mutt/Mutt-alias" }}' <enter> <shell-escape> awk '{lst[$2] = $0} END{ for(x in lst) print lst[x]  >> "/home/tree/.mutt/Mutt-alias.temp" ;}' /home/tree/.mutt/Mutt-alias;  mv /home/tree/.mutt/Mutt-alias{.temp,} <enter> <enter-command>set wait_key<enter> <enter-command>source /home/tree/.mutt/Mutt-alias<enter>" "Mutt Add address to alias file with no intraction"

This macro takes the first name and last name (middle name is ignored) and strips the any double quote at the beginning and in the ending and add the alias to the alias file and also the alias will be available immediatly. The problem was duplicate entries. The second awk script removes the duplicate entry. It just works fine for me. awk is cool.

update: The above script did not work when song name contain spaces too. So the new one looks like this,

ls -l Sitename* | grep -v "total*" | awk -F "Sitename.Com - " '{val=("Sitename.Com - "$(NF)); printf("mv "%s" "%s" n",val, $NF)|"sh"} END{close("sh")}'

The “sitename.com – “is the string i wanted to strip.

September 17, 2008

Back to Normal

Filed under: life — skalyanasundaram @ 6:45 pm

After more than a month things are back to Normal.

  • Shifted my house. Near to my office, walkable distance, it gives me a kind of my college experience where techpark is like departments and classrooms and my home and near by places are a like hostels and the DRDO township is like staff quarters.:)
  • Johnny completed his course on July itself. If he had been sincere so far now he should be able to indentify the famous tamil actor and actress atleast. Right now me and Nikanth share the house.
  • As usual Airtel slot is overloaded. Back to same reliance wi-max 400kbps. Just one block away Reliance have their tower. Hoping there wont be much of problem.
  • Local cable signal is extremely good. Watching my favorite channel sun-music all the time. If sun network dedicate K tv for comedy and sun music for songs around 9:30-11:30 PM it will be good. Me is lacking of music during that time.
Older Posts »

The Silver is the New Black Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.