Code
Here I put any interesting piece of code that I ever came across. I keep
them here for educational purposes, so that I can copy and paste them again
when I have forgotten the details :-).
That means that some of the code is of myself, but most of it have copied/pasted
from other people's sources. So please do not hestiate to
mail me if you think some of the code if from you. I will put a copyright
under your code or remove it, whatever you like.
If you need parts of the code for your own projects please feel free to
copy and paste whatever you like :-).
For coloring the source code I use the commandline tool webcpp which is
hosted at Sourceforge.
- [Personal Cheat Sheet]
In this file I write tips and tricks I found out while working with computers.
Yeah, I don't want to spend my time twice on the same stuff ...
- [Generic C++ Makefile]
A very generic Makefile that is able to generate all the
dependencies and objects files of all *.cc or *.cpp files in one directory.
I use it very often for small projects or testcode, since I just have to
supply it with the target name and some flags, and it works almost all the
time out of the box.
-
[Preprocessor debug macro]
Example shows how to use a preprocessor macro for debug
output. The debug code does not appear when not beeing compiled with the
-DDEBUG switch or a #define DEBUG in the code itself .
-
[Binary String]
C++ string class that let's one easily handle binary data.
For examples have a look in the main.cc file.
-
[Singleton Template]
Templated version of the singleton design pattern.
-
[Functor Template]
Templated version of a C++ Functor.
-
[Cgi with C++]
Interesting example on how to use C++ for cgi scripts.
Copyright is by Thomas Wieland.
-
[Tokenize a String]
The C++ way of splitting strings into tokens.
Works only with gcc 3.0 since the older gcc has problems with the templates.
-
[Trim String]
C++ code that removes white spaces like " \t\r\n" from beginning and end of string.
Also the preprocessor definitions for including the debug
code and the gettext stuff for internationalization is quite interesting.
-
[Convert Numbers to Strings]
The example shows one way in C++ howto convert a number to a string.
-
[Differences in large datasets]
Example shows how to effectively use the std::set_difference
function in order to find out the differences in large datasets, which is
useful if you want to compare or synchronize them. I actually used it when
I had to synchronize the data on two large ftp servers.
-
[Message QueQues]
The example shows the usage of message queques for IPC.
-
[Berkely DB]
The example shows the usage of Berkely DB version 1.
-
[Becoming a daemon]
The example shows how to create an unix daemon properly.
-
-
[Creating arp packets]
Creating arp packets for finding out wheter an ip address exists on network or not.
[Regular Expessions]
The example shows howto use regular expressions in C++.
( with the help of the regex.h library )
-
[Python and Telnet]
Little example shows how to use python in order to telnet a server.
I used it to put load on a testserver.
You also can see how to use for and while loops and the log
of a telnet session in the python shell.
-
[Python and Threads]
Example shows how to create threads in pyhton.
I copied almost all of this example out of a tutorial on IBM's developer zone.
( Great tutorials there! )
-
["Cat" command in Assembler]
The "cat" programm in linux assembler. I used nasm to compile it.