Clearing OS cache

Run the following command as root
echo 3 > /proc/sys/vm/drop_caches

Adding libpq in Contrib module

To include libpq functions in the contrib module the following header should be included:
#include "libpq-fe.h"
However, it throws the following error:
error: libpq-fe.h: No such file or directory
This can be solved by including the following in Makefile of that contib
PG_CPPFLAGS = -I$(libpq_srcdir)
This includes the option -I../../src/interfaces/libpq during make and hence the header file becomes accessible. 

gdb commands

Future breakpoints

Set break point on future shared library:
set breakpoint pending on

Debug fork

To hold the forked process by gdb and not allow it to run independently:
set detach-on-fork off 

Vim - Change case

Open the document in vim, press v and move to select text and then press one of the following:

U - converts to upper case
u - converts to lower case
~ - toggles the case of selected

To change text of entire file to lower case run the following
ggVGu
replace u with U for uppercase and ~ to toggle.

Postgresql - Set timing on by default

For the psostgres user create file in the home folder:
vim ~/.psqlrc
and add the following to the file
\timing
When you connect to database and run  a query, the time is also displayed:

postgres=# SELECT current_timestamp;
               now              
----------------------------------
 2014-03-11 10:34:40.378455+05:30
(1 row)
Time: 43.821 ms

Vim - Replace with incremental value

:let @a=1 | %s/<old_word>/\='<new_word>'.(@a+setreg('a',@a+1))/g

If the <old_word> is replaced with abc
and <new_word> with xyz

:let @a=1 | %s/abc/\='xyz'.(@a+setreg('a',@a+1))/g

The command will replace all abc with xyz.<number>. The <number> will start with 1 and increment by 1.

1st abc will be replace by xyz.1
2nd abc will be replace by xyz.2
.
.
.
so on


Find the list of directories with their Sizes

Get Size of all sub-directories

Command: 
du -sh <directory_path>/*

Example:
$ du -sh /home/Beena/*

4.0K /home/Beena/Desktop
4.0K /home/Beena/Documents
64M /home/Beena/Downloads
4.0K /home/Beena/Music
4.0K /home/Beena/Pictures
4.0K /home/Beena/Public
4.0K /home/Beena/Templates
4.0K /home/Beena/Videos


Get all files and sub-directories More than a specified size

Command: 
find <dir_path> -size +<size> -ls

Example:
find /home/Beena/ -size +10M -ls


Get all files and sub-directories Less than a specified size

Command: 
find <dir_path> -size -<size> -ls

Example:
find /home/Beena/ -size -10M -ls