The following code (estimated 150 lines of code) implements a simple multithreaded Web Server in Java. The code is easy to read and contains no (really) complicated stuff. There are 5 classes: HTTPException.java This class extends Exception and overrides the getMessage(String) Methode, which is responsibe for example for the Error 404 Not Found message. MimeTypeResolver.java This… Continue reading Simple multithreaded Java Webserver
Category: Linux
Concatenate multiple files
Sometimes data comes split into several files. It might be a table from a database exported to several csv files. You could use the cat tool in linux to combine the files: cat table_file1 table_file2 table_file3 > full_table
Concatenate multiple files
Sometimes data comes split into several files. It might be a table from a database exported to several csv files. You could use the cat tool in linux to combine the files: cat table_file1 table_file2 table_file3 > full_table
Concatenate multiple files
Sometimes data comes split into several files. It might be a table from a database exported to several csv files. You could use the cat tool in linux to combine the files: cat table_file1 table_file2 table_file3 > full_table
Run processes when not logged-in with SSH
Scenario: I want to run a process on a remote computer, but don’t want to keep the SSH connection open during its execution. Even using the & after a command does not make a running process presist / survive a SSH disconnect. For these cases you can use screen. When logged-in in a remote computer,… Continue reading Run processes when not logged-in with SSH
distribute shared library with your binary (set rpath)
When a Linux binary is started, the run-time linker uses three sources for finding the needed libraries. First it is possible to set the LD_LIBRARY_PATH environment variable, second the “rpath” (this is a path encoded into the binary while compile time) and last but not least the systems’ default directory like /usr/lib. Now consider the… Continue reading distribute shared library with your binary (set rpath)
compile C and C++ code into one binary in Linux
Sometimes you have a project written in C and you want to add some code (may be open source software) which is provided in C++. So you may want to call a function written in C++ from C. For that purpose, you have to change the function prototype of the concerned C++ function like: #ifdef… Continue reading compile C and C++ code into one binary in Linux
Create MATLAB readable avi from bmp frames
Use the following command ffmpeg -vframes 200 -f image2 -i airport1%03d.bmp -f avi -vcodec rawvideo -pix_fmt bgr24 -acodec pcm_s16le airport.avi This will convert all the files airport1000.bmp to airport1200.bmp to an avi file. Using mencoder will allow you to chose the framerate: mencoder “mf://*.bmp” -mf fps=12 -o out.avi -ovc lavc -lavcopts vcodec=msmpeg4v2:vbitrate=800
make terminal case insensitive (debian linux)
Open / create the inputrc file by typing pico ~/.inputrc And add the line: set completion-ignore-case on
switch off cpu cores in ubuntu/linux
For some benchmarks it can be important to have a system operating on just a specific number of CPU cores. To find out how many you have, just count them by: $ ls -l /sys/devices/system/cpu/ Switching a core off is just as easy as echo 0 > /sys/devices/system/cpu/cpu7/online which would switch off core 7. For… Continue reading switch off cpu cores in ubuntu/linux