tab exension for hostnames in ssh

Using the tab extension is a nice thing. To make ssh know your hosts, add three lines in the ~/.ssh/config folder:

access (lot of small) functions residing in one MATLAB m file

Usually, you create one m-file for one MATLAB function. But what to do if you have many small functions? It’s odd to create a lot of files which just contain some lines of code. The other approach is to put the small functions just inside the m file where they are called from. This is a good solution, as long as you don’t have to access the same functions from multiple m-files!

So if you need to access many functions, which all reside in one m-file, just use the object oriented approach, by defining a Class and static methods:

Now, wherever you need to call any function of MyClass, just use:

send big chunk of data over linux sockets

Sending a big chunk of data over linux sockets can  be tricky, because we need to call the write function multiple times. The following snippet assumes a valid socket filedescriptor “socketfd”, after the connection is established. Make sure that PACKETSIZE is smaller or equal to 2^16 and that nbytes equals the amount of bytes of the data variable (which is a pointer to your data which has to be sent).

The typecast to void* is needed to have “i” impacting on the amount of bytes of the data an not of the actual type it is! For the receiving side, the code is quite similar.

Compile MATLAB functions in C and link them with Intel MKL CBLAS

The MATLAB utility “mex” (enter “help mex” in command window in MATLAB) is a wrapper for your actual compiler, like gcc. It does not support intels icc. But this is no reason not to use the Intel MKL libraries! Write your code and compile it with:

Looks ugly, but is just a matter of copy pasting from the following website. Then gcc will compile your code and link the Intel libraries! The linking process is somewhat tricky, therefore use

to determine everything after the file name in the compiling command. Remember to select static linking on the website.

start MATLAB in command line mode from bash/linux console

Sometimes I want to start matlab without having the (lame) X interface. Instead of, I just use the command line. For this purpose, just run:

Or even easier, by adding a small script in /$MATLAB_HOME/bin maybe named “matlabnoX” with the content above. Make sure to chmod the file such that it is runnable!

Sort collections in java

Usual problem: When you pass a java list to Collections.sort(List list), the elements are sorted according to their returned values retrieved by calling the objects compareTo() methods. Well, what to do if you suddenly want to sort the same list by another criteria? Then a comparator is your friend.  A comparator knows how to compare two objects in the list to sort, and is basically defined by:

Restart tomcat (the rude way)

To restart tomcat, fill the following two lines in a .sh file and make it executable (chmod +x [filename]):

Warning: It kills all other java processes as well!

Use ETH SMS service for sending texts abroad

The following simple website demonstratates how to send texts using the free SMS service of the ETH (you need to be member of). The core task of the website is to send a HTTP post request to the following website:

The documentation is found here:

The header data consists out of your ETH username and password, the action you want to perform, the message you want to send and some further stuff. In the following code I use the libcurl library to send the request. If you have enough permissions on your server you can install it by typing:

Take a look at the code. You might ask, why I use a fixed destination number. Well the webinterface was just meant to send SMS to my phone! The service even transmits text to other countries. I don’t know whether it is working wordwide:


If you put this script on a webserver, make sure the file is not readable for other people, because it contains sensitive data! (your password)