Archive for September, 2006

Emacs – Highlight selected text

September 30, 2006

In order to set emacs to highlight the block of text selected using C-SPACE, add the following to your .emacs file:

(transient-mark-mode t)

See also Delete selected text.

Emacs – Simple comment syntax

September 30, 2006

If you are editing a type of file that has a simple comment syntax (e.g., lines that start with # are considered comments), you can let emacs know about it and get ride of the “No comment syntax is defined” error message when you try to comment a block of text.

Here is what you have to do (we asume that lines that start with # are considered comments):

M-x conf-unix-mode RET
M-: (setq comment-start “#”) RET

Databases/SQL — PostgreSQL — get databases

September 22, 2006

In order to get the list of all the available databases in PostgreSQL, connect to any database (e.g., postgres) and run:

SELECT datname FROM pg_database;

Linux – print system information

September 12, 2006

To print system information in Linux, you can use:

uname

E.g.,

uname -a

will print the kernel version.

C/C++ – GCC create a static library

September 1, 2006

You can create a static library from object files using the following command:

ar rcs libfunc.a func1.o func2.o func3.o

To link the libary to your code you can use use:

g++ -o exe_file exe_file.o -L. -lfunc