Last October, I learned about “key stretching” from Solar Designer’s “How to manage a PHP application’s users and passwords” — a concept that is applicable well beyond PHP. Combined with salting, it is effective at slowing down brute forcing attacks, and even against rainbow tables.
When CTRL-C in gdb shuts down a program insted of interrupting it
According to The Linux Programming Interface, a well-behaved multi-threaded UNIX program should use sigwait() or sigwaitinfo() instead of signal() or sigaction(). A linux-only program could even use signalfd().
Unfortunately, Linux/UNIX programs using sigwait() are hard to interrupt in the debugger. Instead of interrupting the program, it terminates the program. How does one work around this problem? See my answer on stackoverflow.
C++ initializer lists
One of the cool new features in C++ is initializer lists. Here’s an example from Wikipedia:
struct Object
{
float first;
int second;
};
Object scalar = {0.43f, 10}; // One Object, with first=0.43f and second=10
Object anArray[] = {{13.4f, 3}, {43.28f, 29}, {5.934f, 17}}; // An array of three Objects
There’s another example over at stackoverflow.
IBM has published the useful C++0x feature support in GCC 4.5.
Treating work like a race
Chad Fowler, in his book, My Job Went to India, made the following remarks about working effectively:
If you treat your projects like a race, you’ll get to the end a lot faster than if you treat them like a prison cell.
A sense of urgency, even if manufactured, is enough to easily double or triple your productivity.
I’d add that it needs to be an enjoyable race, and that urgency, sustained for too long, can wear a person out. Races are more enjoyable when run with a group of friends.
Autojump: Faster than ‘cd’
Here’s a cool tool: autojump, written by Joel Schaerer (thanks, Joel). I spend much of my day as a programmer navigating around in the linux filesystem. Built-in tools like ‘pushd’ and ‘popd’ are nice, as are subprocesses — e.g.
(cd ~/Download && wget http://somewhere.com/path/to/file)
… and when it finishes downloading, I’m still in the directory I was in before the download was started.
Now there’s autojump to add in to the mix. After I ‘cd’ to various directories, later, I can type ‘j Down’ to cd to my Downloads directory. Very convenient. I just wish it were built into every distribution of linux.