|
Sunday, November 29. 2009
I needed to plot data from a program in real-time for a demo, that is, as the program generates the data, I wanted it to show in some nice diagram.
A friend pointed me to Visualize real-time data streams with Gnuplot by Thanassis Tsiodras, which is very nice: you specify the number of streams to plot and where to plot them, and feed it with lines like '0:1.23', '1:2.3', etc. defining the data points for the individual streams (here: first point on stream 0 is 1.23, first point on stream 1 is 2.3, etc.).
However, I needed to plot several streams in a single window, which that version lacked. So I extended that program with the ability to plot several streams into a single window (download).
For this, you specify both the number of streams you want to plot and the number of windows you want to show. Furthermore, you specify in which window each stream is plotted. I kept as much as possible of the original command line interface to ease the transition to this new version. The result looks like this:
Continue reading "Plotting data with gnuplot in real-time"
Friday, January 30. 2009
Who's designing the error messages of g++? Anyways, here is a translation:
error: request for member ‘foo’ in ‘((Test*)this)->Test::_bar’,
which is of non-class type ‘C_bar*’
means: in class Test, you've written _bar.foo, but _bar is a pointer; you need to write _bar->foo, that is, change the dot to an arrow.
Happy C++ coding!
Tuesday, January 27. 2009
I just stumbled over my python code, similar to the following one, which raises an UnboundLocalError in the first line of push:
def func_stack1():
stack = []
def push(num):
print "stack before: ", stack
stack = stack + [num]
print "stack after: ", stack
return push
push = func_stack1()
push(1)
Continue reading "Global and local variables in python"
Thursday, November 6. 2008
I wanted to 'upgrade' my python from 2.5 to 2.6 on Ubuntu. Unfortunately, I could not find .deb packages for Ubuntu. Fortunately, the Python 2.6 sources (sig) are available, so I can compile it from source. Here's what I had to do to get it running. (Short version: apt-get build-dep python2.5 and apply this patch to disable unavailable and outdated modules.)
Continue reading "Installing Python 2.6 on Ubuntu 8.04"
Saturday, May 17. 2008
I gvim, if you set
:setlocal spell spelllang=en_us
gvim will spell-check your file and underline wrongly spelled words with a red line much like you know it from OpenOffice. If you
:set mousemodel=popup
you can even right click on any misspelled word to get a list of suggested corrections.
However, this sometimes did not work for me. I could not figure out a reason, until I read the help docs again, which clearly say:
Note for GTK: don't release the right mouse button until the menu appears,
otherwise it won't work.
They actually mean what they say: if I release the right mouse button too fast, the menu appears, but it does not replace the misspelled word with the corrected word. Only if keep the right mouse pressed until the menu appears, it works, for whatever reason. RTFM!
Tuesday, May 6. 2008
If you link a static library to your executable, the GNU linker ld (as many others) only adds those symbols that ld thinks are actually used in your executable (that's a feature). Unfortunately, ld can only check if the symbol is in use, but not if the side effects of the symbol's initialization is used. Thus, your program will fail if it depends on the initialization of an unused static object.
In my case, I have a factory (class module::factory<T> : public factory_plant {...} factory;) at which classes can register themselves with a name (module::factory<Group> f("Group")). If I call the factory with a name (factory.create("Group")), the factory returns a pointer to a newly created class associated with that name. The class registers itself via a static object (here: f) whose initialization code does the actual registration.
The problem arises if the class is not used directly and the linker throws the static object away. The registration does not happen and thus I can't use the factory to create an object of the class. There are several possibilities to work around this feature:
Use --whole-archive to tell the linker to include all symbols, no matter what (with gcc use -Wl,--whole-archive -lmylib -Wl,--no-whole-archive). The drawback is that symbols that I neither use nor care about are also included, resulting in increased code size.
Use -u<symbol> to tell the linker to treat <symbol> as if undefined and thus include it in the executable, even it is not used. The drawback here is to know what <symbol> looks like. Easy for C files, difficult (and not portable) for C++ files (see Name mangling in Wikipedia).
Use static initializers (thanks to Alex for this). This is my preferred method. I use a throw-away class, which I add to the header file:
static struct Init {
Init() {
static module::factory<Group> init("Group");
}
} init;
Friday, December 14. 2007
I've just found a nice, small C compiler: tinycc. The compiler includes the actual compiler and the linker, so you don't need other external tools. The executable is only 122KB in size on my system (Fedora Core 6). I like tcc because it allows you to create C-scripts.
Continue reading "TinyCC -- a fast C compiler"
Friday, December 14. 2007
Today I've installed a program with checkinstall. Although I gave the --strip=no --stripso=no options, the executable was still stripped.
First I thought, rpm strips the executables, only to find out that the Makefile of the program I wanted to installed stripped the executables.
So, if you install a programm with checkinstall, the --strip=no option only helps if the original Makefile does no stripping.
Thursday, December 13. 2007
I always have to look it up how to restrict access to some files or directories on my web server, so I write it down here. Two steps:
- You need a password file
- You must specify the restrictions
Continue reading "Restricting access to directories and files in Apache's httpd"
Wednesday, December 12. 2007
That's really cool: Johnny Lee uses the Wii remote to create a low-cost multi-touch screen, either on a whiteboard or your laptop or any other surface you like. You can even download his software at his homepage. That's great, check it out!
Tuesday, December 4. 2007
Imagine your computer plays "Fur Elise" or "It's a Small, Small World" seemingly at random via your PC speaker. This may be not a virus, but a feature! It indicates that something is wrong with your motherboard.
You don't believe me? Check out Microsoft's support page on this issue. I guess the designer thought the motherboard must do something more interesting than just beeping and you don't have to pay license fees for classical music. Instead of trying to describe the kind of beeping he hears, the customer can just name the music and customer support knows what's wrong. Brilliant!
Sunday, November 25. 2007
When you connect to a host that you have not connected to before via ssh, ssh prints a message like
lava:~$ ssh lava
The authenticity of host 'lava (134.2.14.48)' can't be established.
RSA key fingerprint is 9e:1a:5e:27:16:4d:2a:13:90:2c:64:41:bd:25:fd:35.
Are you sure you want to continue connecting (yes/no)?
Usually, you say yes and enter your password. With this, you accept the encryption key the server sent you as the actual encryption key of the server (as opposed to an encryption key some eavesdropper might have sent you who sits between you and the server you connect to). You are supposed to accept the encryption key only if you compared the received encryption key with the actual encryption key of the server by comparing their fingerprints. However, how do you get the fingerprint of the actual encryption key?
Continue reading "How to get ssh server fingerprint information"
Tuesday, August 14. 2007
I found the Howto on the gcc inline
assembler
difficult to understand, so I wrote up the major parts here and
created some kind of summary.
Continue reading "Gcc inline assembler howto summary"
Tuesday, July 24. 2007
David Carr posted an interesting report on deadlines, overtime and undertime he observed in his programming team while developing a product for a customer.
The most interesting observation to me was that after a period of overtime (programmers worked more than what they usually work) came a period of undertime (programmers worked less than what the usually work). In David's study, the amount of work done by each programmer dropped from three days a week to one day a week. So, if your project leader tells you to do overtime work, you may let him consider the rebounce effect of undertime (and maybe post him to David Carr's post).
PS: You may find it surprising that the programmers usually work only three days a week. However, this is the usual amount of work you get. Almost every time management book tells you that you usually can plan only for 60% of the time you have available. The remaining 40% are used by unforseen events, talking to coworkers, time for 'context switch' between different working phases, general friction, and other stuff.
Update: The original webpage is unfortunately offline and I could not find a copy of it. David Carr seems to have moved his blog to http://david-carr.blogspot.com. You may enjoy reading his articles there.
Friday, July 13. 2007
|