12  Next page

News 7 years Ago
Published by packi on

Since the beginning of this year (that’s 2012, in the case I’m not writing any articles for a year, again) I’ve been working with Python. It took some time getting used to the indentation but since then I’m really enjoying it. One reason is that it allows you to do complex things extremely simple.
I had to write a pool for some objects that needed to be thread-safe. Thats what I came up with:

class Pool(object):
    def __init__(self, items):
        self.queue = Queue(len(items))
        for item in items:

    def item(self):
        item = self.queue.get()
            yield item


p = Pool([SomeObject()])

with item = p.item():

The item gets returned right after it has been used, without any knowledge about the pool.

News 9 years Ago
Published by packi on

…you might want to check if you’re calling pthread_detach somewhere along the lifetime on that thread. If you don’t detach the thread the internal pthread structures will keep being allocated and leaked until you hit PTHREAD_THREADS_MAX threads.
At this point pthread_create will fail on each call.

News 10 years Ago
Published by packi on

Today I had to code something up that checks if a socket got closed on the other end, without touching the data if it’s still up and running. I came up with the following lines:

  bool isSocketAlive(const int _socketHandle) {
    uint8_t tmp;
    bool result = true;
    int res = recv(_socketHandle, &tmp, 1,  MSG_PEEK | MSG_DONTWAIT);
    if(res == -1) {
      if((errno != EAGAIN) && (errno != EINTR) && (errno != EWOULDBLOCK)) {
        log("lost connection", lsInfo);
        result = false;
    } else if(res == 0) {
      // if we were still connected, recv would return -1 with an errno listed above or 1
      log("lost connection", lsInfo);
      result = false;
    return result;
  } // isSocketAlive
Published by packi on

Cool page that pictures the state of the SVG support in today’s and tomorrows browsers:

IE is lagging way behind while the nightly-builds of WebKit and Opera are moving on to near complete support. Firefox lacks most of the animation features but I was surprised that 3.0 already supports features like filters.

Published by packi on

If you’re ever running out of diskspace on your gentoo system, be sure to remove old kernel sources. I just removed > 20 and freed about 10 gigabyte.

Published by packi on

Last night I was tinkering with the source-code of kdelibs to make the thumbnail generation optional/configurable. No point in having truecrypt if your documents get thumbnailed and stored directly in your home. It ruins your deniable encryption[1] if your desktop tracks every move you make. Except if your desktop cleans up after it has run.
But then you’ve got the problem of files still lying around in unallocated inodes on your hard-drive.

One solution to this problem is to create a file containing all zeroes or just random data, fill your partition up till the brink and delete the file. This will overwrite everything you wanted to hide from the eyes from your room-mates, your geek-girlfriend or your oppressive government. And as recent studies have shown[2] [3] it’s perfectly secure to overwrite the data just once.
The problem is, it takes forever to write gigabites of zeroes to our hard drives.

This morning I’ve had this idea:

  • All inodes that get deallocated have to be stored in the free inodes table to be reused (nothing new here).
  • If an inode gets deleted put it in tthe table but flag it as “dirty” (as in still containing data).
  • If your filesystem needs to allocate inode it should prefer the dirty ones.
  • On shutdown (or periodically) go through your “dirty” inodes and fill them with zeroes.
  • Life life in happiness and peace.

The performance impact should be minimal as you don’t need to zero out the inodes that you’re reusing[4].

[4] Well that’s no entirely true, an inode that’s not used up fully may still contain compromising data. But this might be fixed by zeroing the last block of a continous inode-allocation (e.g. if the request is for 10 inodes, just zero out the last one).
Published by packi on

I’ve emerged[1] my copy of KDE 4.2 last saturday and I’ve been using it since then at work as well as at home. Apart from the occational crashes (it’s a .0 release after all) it’s running really smooth. It’s way better than 4.1.x which I was running for the last year on my notebook at work.

What I’m mostly missing are configurable items. Like remembering last used directories and disabling the generation of thumbnail-files directly into the root of your home directory.
But these things are easily fixed (and give me an excuse too look into the KDE sources a little bit closer).

And the one thing I really like is the new KDevelop with DUChain. It’s really cool to have your meta-template programs evaluated directly in your IDE. It still lacks support for documentation and gdb but these things seem to be coming along in the next two or three weeks (from what I’ve read on the kdevelop-development mailinglist[2]).

[1] I’m still a Gentoo user but I don’t know for how much longer. The hassle of compiling everything by hand and re-emerging stuff because of missing use-flags is sometimes just too time consuming.
[2] The mailinglists archive is private though, I had to subscribe. Talk about openness.
Published by packi on

Last week I’ve had to port some software I wrote to an ARM9 development board (I’ve been working on a part of digitalSTROM for the last year). I figured that this would be a mostly painless task and learned that it is — if you know which files to adjust. Thats why I’m documenting it for you all here.

The libraries I had to compile were:

  • Boost
  • LibXML
  • LibICAL
  • gsoap++
  • libjs (yeah JS on a small ARM9 board, ain’t that cool?)


Well boost was a bitch to compile. Until I found a post in a mailinglist from someone who did something similar. I might have been easier with 1.37 but I’m stuck at 1.35 for now.

export PATH=/opt/emlix/picocom1/bin:$PATH
echo "using gcc : arm : arm-linux-gnueabi-g++ ;" > user-config.jam
BOOST_BUILD_PATH=. tools/jam/src/bin.linuxx86/bjam -d2 
--toolset=gcc-arm '-sBUILD=release static multi/single' link=static 
--prefix=../sysroot/ --layout=system --with-filesystem 
--debug-configuration install

The --debug-configuration command line switch was a life-safer. I discovered it a little late though.


LibXML2 was straight forward:

export PATH=/opt/emlix/picocom1/bin:$PATH
export CC=arm-linux-gnueabi-gcc
./configure --target=arm-linux-gnueabi --host=arm-linux-gnueabi \
--build=i586-linux --prefix=/home/patrick/test/sysroot/ \
--with-minimum --with-writer --with-sax1
make install

The only hassle was to find out that i had to include sax1 and writer for my program.


Straight forward as well:

export PATH=/opt/emlix/picocom1/bin:$PATH
export CC=arm-linux-gnueabi-gcc
./configure --target=arm-linux-gnueabi --host=arm-linux-gnueabi \
--build=i586-linux --prefix=/home/patrick/test/sysroot/ \
make install


The problem with gsoap is that it needs to generate files to compile, but
it’s basically following the pattern:

export PATH=/opt/emlix/picocom1/bin:$PATH
export CC=arm-linux-gnueabi-gcc
export CXX=arm-linux-gnueabi-g++
./configure --target=arm-linux-gnueabi --host=arm-linux-gnueabi \
--build=i586-linux --prefix=/home/patrick/test/sysroot/

Then you’re greeted by this error message:

../../gsoap/src/soapcpp2: ../../gsoap/src/soapcpp2: cannot execute binary file

Which is obvious considering we’re compiling for ARM9. No you can either copy the files over to your board and execute them there or just call your native soapcpp2

cd wsdl
../soapcpp2 -SC -pwsdl -I../import ./wsdl.h

After that you’re compile-run should run smooth through until the end:

make install

SpiderMonkey (libjs)

Since SpiderMonkey is usually embedded in the Mozilla build-process it just has a simple Makefile. Either that or they’re just lazy at Mozilla. Here are the steps to compile that beast:

mkdir mozilla
cd mozilla
tar xzf js-1.7.0.tar.gz
cd js
make -f Makefile.ref CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld

The build comes to a grinding halt since we’re having the “running ARM9 binaries on a x86 platform”-issue again. This time it might be a good advice to run these binaries your target-processor since it’s checking the size of various types. Copy over jscpucfg and run it like that:

./jscpucfg > jsautocfg.h

Continue the build:

make -f Makefile.ref CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld

Next stop: [...]jskwgen: cannot execute binary file. Again copy over jskwgen and run it on your target (it might work with your native copy if you’ve got one lying around, as far as I can tell it just generates parts of the parser):

./jskwgen > jsautokw.h

And continue the build:

make -f Makefile.ref CC=arm-linux-gnueabi-gcc LD=arm-linux-gnueabi-ld

Your binaries should be located in the Linux_All_DBG.OBJ sub-directory.

News 11 years Ago
Published by packi on

Yesterday I’ve released version 0.02 of HTML::WikiConverter::XWiki to CPAN.


- Fixed tests to reflect the improved block handling in HTML::WikiConverter
- Render <p> elements as blocks

Thanks to Stefan for reporting the block issue. There is still something wrong with but as it’s only a minor issue and not contained in the CPAN distribution it will have to reside in its current state for now.

Published by packi on

While searching for an update for the “Leopard challenged” OpenVPN gui Tunnelblick, I’ve stumbled over a blog post from Justin over at Mozilla. He rebuilt Tunnelblick and included an update tun/tap module.

The link to the .dmg is located at the end of his post.

Published by packi on

The field tm.tm_mon is zero based.

News 12 years Ago
Published by packi on

Maybe you shouldn’t code with a hangover, but I think its not just me who’s stumped while looking at the following linker message:

linking xyz (g++)
myfile.o: In function `MyFile':
/home/patrick/projects/xyz/trunk/src/myfile.cpp:608: undefined reference to `vtable for xyz::MyFile'

This happens if you declare an overriden (virtual) function but haven’t implemented it. Thank you ld for your clarity…

Published by packi on

I’ve just published the first part of my article about our internal Wiki move operation. Read it here.

Published by packi on

…doesn’t mean I’m not busy. While finishing the winter semester and the semester project (on WLan positioning) I’ve had a run-in with Perl. Read about my CPAN adventure here.

News 13 years Ago
Published by packi on

While rummaging through my projects folder I’ve discovered the following script, I’ve written some time ago. It’s a script that rips the longest track from a DVD, but doesn’t compress them. That preserves all the languages, subtitles and doesn’t introduce new compression artifacts. But at the expense of disk space, that’s not too valuable nowadays, a DVD needs about 5 to 7 GB.
You’ll need lsdvd and transcode installed in order to run this script.

# − Copyright © 2006 by Patrick Staehlin <>
# Rips the vob's from a DVD in 1 GB chunks.
# Usage:
# ./ [tracknr] [target_dir]
# The default tracknr is the longest track on the disk.
# If you don't specify target_dir, the dîrectory will be the dvd's title.

lsdvd /dev/dvd > tmpout 2> /dev/null
title=`grep "Disc Title" tmpout | cut -c 13-`
trackToRip=`grep "Longest" tmpout | cut -c 16-`
rm tmpout

if [ "x$2" != "x" ]; then


if [ "x$1" != "x" ]; then
  if [ $trackToRip = $1 ]; then
    mkdir $title;
    cd $title;
    mkdir $title;
    cd $title;
    mkdir $1;
    cd $1;
  mkdir $title;
  cd $title;

echo "DVD: $title will rip $trackToRip";
dr_exec tccat -t dvd -T $trackToRip,-1,1 -i /dev/dvd 2> /dev/null | 
dr_splitpipe -f $titleAbs/nav.log 1024 $titleAbs/$title vob 2> /dev/null | 
tcextract -a 0 -x ac3 -t vob | tcdecode -x ac3 | tcscan -x pcm

 12  Next page