Use the booktabs package when creating tables in latex

Wed, 2009-06-17

Instead of using latex’s default tables I recommend using the booktabs package. It allows the production of tables as they should appear in published scientific books and journals. Take a look at the documentation.


Sort directories by number of files contained

Sat, 2009-05-09

Here is a one-liner which sorts all the directories under ‘/’ by the number of files contained:

find / -type d -exec sh -c 'ls -a1 "$1" | wc -l' \"{}\" {} \; -print | \
sed  '$!N;s/\n/ /' | sort -gr

I recently needed this on a linux server where the inode quota was exceeded. Through the one-liner I discovered where most of the inodes where consumed.

Tabs in vim

Wed, 2009-01-21

You can open several files in tabs from the command line with vim, just type:

vim -p file1 file2 file3

And each file specified on the command line will be opened in a new tab.

To open a file in a new tab inside vim use :tabe file

To close a tab do :tabc

You can quickly switch between tabs typing gt or gT in normal mode. To switch to a particular tab prepend the tab number to gt, i.e. type #gt, where #gt is the tab number.

Avoid the need to escape parenthesis, brackets… in vim regexes

Sat, 2009-01-17

Vim has a so called “very magic” mode for regexes which allows you to use parenthesis, brackets, the alternative separator (i.e. ‘|’), pluses, etc. with their special meaning but without the need to escape those characters.

(see :help /\v)


Let’s say you have the following in your buffer:


If you execute


you will get


but it required a lot of backslash escaping in the regex. You can avoid the need to escape parenthesis, curly braces, pluses, etc. using vim’s “very magic” mode for regexes. The following would do exactly the same as the previous substitution command but with fewer escaping required:


Cycle through the last argument of previous commands in Bash

Wed, 2009-01-07

In Bash, when I want to repeat the last argument of the previous command, I usually type !$. I just discovered that you can also use ALT+. to cycle through the last argument of previous commands.

ESC-g for glob expansion in bash

Tue, 2009-01-06

Just like <TAB> expands a filename given a prefix you can also expand a file name given the middle part of a file name.


$ ls
abc1def  abc2def  abc3def  abc4def  abc5def
$ ls *2*<ESC>g

Which will expand to:

$ ls abc2def

via a stackoverflow question

How to view realmedia streams in ubuntu hardy

Tue, 2008-12-30

$ sudo wget -O \

$ sudo aptitude update

$ sudo aptitude install medibuntu-keyring

$ sudo aptitude install w32codecs

$ mplayer -playlist

Where is the url to a realmedia stream.