Wednesday, March 17, 2010

Power of UNIX

UNIX/Linux is a very powerful operating system with a lot of simple commands for small tasks. Power of UNIX lies in its ability to handle very complex, huge data requirements which would bring other operating systems to a screeching halt.


For example from my personal experience, simple utilities like grep, gzip, gunzip, split are able to handle data varying from 1 KB to GBs with the same elegance and accuracy.

Say we have a file of size around 36 GB.

Follwing operations are performed on that file:
1. gzip   : size comes down to 4.2 GB.
2. gunzip : size grows back to 36 GB.
3. grep   : Search a pattern in this file and create a new file of size around 32 GBs => happens in around half an hour!
4. gzip   : compress it back and file size becomes 4.1 GB.

Alternately, you can use split command between step 2 and 3 to split the big file in no. of small chunks and then perform the remaining operations.



The operations we performed above are quite simple. However, the huge data set on which they are applied is what makes the problem hard. That's where power of UNIX comes...




Tuesday, March 09, 2010

Vim Tips

Very useful  Vi Tips:

* # g* g#        find word under cursor (forwards/backwards) or word completion in insert mode
guu                  lowercase line
gUU                uppercase line
~                     invert case (upper->lower; lower->upper) of current character
'.                      jump to last modification line
`.                     jump to exact spot in last modification line
:reg                 display contents of all registers
:"1p                 paste from register 1
gf                    Open the file under cursor
ctrl+w f          Open the file under cursor and split screen horizontally.
vim -O file1 file2    open file1 and file2 side by side
:command              runs named command
Ctrl+w {left,right,up,down}    move to window
''                        move to previous position
Ctrl+o  move to previous position (recursively, in history)
CTRL-I jump to next location (recursively, in history)

Jumping to diffs:
[c  Jump backwards to the previous start of a change.
]c  Jump forwards to the next start of a change.


Wednesday, March 03, 2010

The Duct Tape Programmer


My Summary:

1. Duct tape programmers are pragmatic. They know that shipping is a feature. A really important feature. Your product must have it. :-)

2. It’s great to rewrite your code and make it cleaner and by the third time it’ll actually be pretty. But that’s not the point—you’re not here to write code; you’re here to ship products.

3. "One principle duct tape programmers understand well is that any kind of coding technique that's even slightly complicated is going to doom your project."

4. If there’s no unit test the customer isn’t going to complain about that.

5. One principle duct tape programmers understand well is that any kind of coding technique that’s even slightly complicated is going to doom your project.

6. Duct tape programmers have to have a lot of talent to pull off this shtick. They have to be good enough programmers to ship code, and we’ll forgive them if they never write a unit test, or if they xor the “next” and “prev” pointers of their linked list into a single DWORD to save 32 bits, because they’re pretty enough, and smart enough, to pull it off.

Its not necessary to apply everything mentioned in the article in letter and spirit. But you get the point.