Blog Image


Tar specific file(s) recursively

Linux Posted on Fri, July 04, 2008 12:27:01

find . -name regfeat_cbl.dat > list.txt
tar zcvf regfeat_cbl.tar.gz –files-from=list.txt

Recursively delete files

Linux Posted on Wed, June 18, 2008 13:19:13

Back again with a handy command I forget all the time…

find /from/this/directory -name \*.tmp -exec rm {} \;

this will recursively delete all *.tmp files from /from/this/directory and higher.

To let find ask for a confirmation for each file, do this:

find /from/this/directory -name \*.tmp -ok rm {} \;

Replace tabs with spaces

Linux Posted on Wed, May 21, 2008 08:01:31

To convert all tabs to 5 spaces you can use the following perl command line:
(replace ___ to spaces)

perl -e ‘($_ = join “”,<>) =~ s/(\t)/_____/g; print;’ < input.txt > output.txt

Copying symbolic links from remote PC

Linux Posted on Mon, March 31, 2008 12:24:59

Normally you would use scp to copy files between PC’s, but it will follow every symbolic link and copy the data instead of the symbolic links themselves. With rsync however you can copy symbolic links.

rsync -azuv -e ssh user@host:/remote/directory /local/directory

Searching within files

Linux Posted on Tue, March 11, 2008 08:31:16

To search for files recursively containing a certain string (not in the filename, but in the file itself):

find . -name ‘filename’ -exec grep -H -i “searchstring” {} \;

Broken links

Linux Posted on Mon, March 10, 2008 08:20:46

To get a list of broken links on your system, do a

( find / -type l | xargs file ) | grep ‘broken symbolic link’ | cut -d”:” -f1

to get a filelist of broken links.

kNN in Weka

Linux Posted on Wed, January 30, 2008 12:02:52

To use the kNN classifier in Weka (Waikato Environment for Knowledge Analysis) you have to click on the label under
‘Classifier’, and then choose ‘IBk’ from the drop-down menu.

The option ‘KNN’ defines the number of neighbors.
‘distanceWeighting’ option allows to adapt the influence of the
neighbours according to their distance, and ‘crossValidate’ searches for the best “k” value using crossvalidation.

Location floating images

LaTeX Posted on Fri, January 18, 2008 11:20:34

To avoid that floating images are located after a certain point, e.g. you don’t want the image between the references, you can use the following statement that places a barrier beyond which floats may not pass.


The following package have to be included:


Two figures side by side

LaTeX Posted on Wed, December 19, 2007 11:43:39

To put two figures side by side you can use minipages inside the figure environment.

\caption{\label{fig:pic1}Caption 1}
\caption{\label{fig:pic2}Caption 2}

Exporting Messages from Evolution

Linux Posted on Wed, October 24, 2007 14:26:46

There is a File | Import… menu item in Evolution, but no corresponding Export menu item. However, you can export messages from Evolution into the well known mbox format, by doing the following steps:

– Select the folder in Evolution you want to export
– Select Folder | Select All Messages from the menu.

– Select File | Save Message… from the menu.
– Choose location and filename where to save the emails,
preferably with extension .mbx
– Click OK

Disadvantage is that it needs to be repeated for every folder.

No icons in evolution

Linux Posted on Tue, October 16, 2007 11:11:46

If you get the following warnings, and there are no icons in Evolution, you probably have a non-existent theme selected in the gnome theme manager.

Gtk-WARNING **: Unable to locate theme engine in module_path: “qtengine”

One of the probable causes is that some themes get deleted/updated when installing gnome updates.

This can be fixed by running gnome-theme-manager and select a different, existing theme.

SSH Tunnel

Linux Posted on Thu, September 06, 2007 10:28:26

To tunnel IMAP via SSH to localhost if you are using xs4all:

ssh -C <usernaam> -L

Your mailclient should then be configured to read mail on server localhost:11143

Layouts Qt3 -> Qt4

Qt Posted on Mon, September 03, 2007 08:22:27

Converting layouts in Qt3 to Qt4 involves:

The old-style QLayout(QLayout* parent) needs to be replaced by a new
empty contructor and a subsequent parent->addLayout(child) statement.

Example Qt3:

QVBoxLayout *vbox = new QVBoxLayout ( this );
QHBoxLayout *box3 = new QVBoxLayout ( vbox );
QVBoxLayout *box4 = new QVBoxLayout ( box3 );
QVBoxLayout *box5 = new QVBoxLayout ( box3 );
QHBoxLayout *box6 = new QVBoxLayout ( vbox );

Ported to Qt4:

QVBoxLayout *vbox = new QVBoxLayout( this );
QHBoxLayout *box3 = new QHBoxLayout;
QVBoxLayout *box4 = new QVBoxLayout;
QVBoxLayout *box5 = new QVBoxLayout;
QHBoxLayout *box6 = new QHBoxLayout;


Memory management C/C++

C++ Posted on Thu, August 30, 2007 08:40:25

In C++ we have the operator new and operator delete. These are intended to replace malloc() and free() in the C standard library.

Allocating a array of 100 integers is done in C as follows:

int* is;
is = (int*)malloc(sizeof(int) * 100);


With new/delete in C++, it can be rewritten as:

int* is;
is = new int[100];

delete is;

External library dependency

Qt Posted on Thu, August 30, 2007 08:19:49

When you change an external library, your Qt project is not recompiled. By default, qmake does not include external libraries in the dependencies for the final executable, because they are not part of the project itself. This can easily be solved by adding a forced dependency in the .pro file:

POST_TARGETDEPS += /libpath/libCAD.a

QVTKWidget BadWindow

Qt Posted on Thu, August 30, 2007 08:09:41

Using VTK (QVTKWidget) in combination with Qt 4.2.0 or Qt 4.2.1, which is included in the SuSe 10.2 distribution, can cause the following errors:

X Error: BadWindow (invalid Window parameter) 3
Major opcode: 3 (X_GetWindowAttributes)
Resource id: 0x0
X Error: BadValue (integer parameter out of range for operation) 2
Major opcode: 1 (X_CreateWindow)
Resource id: 0x0
X Error: BadWindow (invalid Window parameter) 3
Major opcode: 20 (X_GetProperty)
Resource id: 0x0
X Error: BadWindow (invalid Window parameter) 3
Major opcode: 3 (X_GetWindowAttributes)
Resource id: 0x3c00002
Segmentation fault

This is a bug introduced in Qt 4.2.0 where they delete all descending underlying windows when reparenting a widget. This is fixed in Qt 4.2.2. More information here.