Category Archives: Code Poetry

A Distributed Mutex and Semaphore using Redis

Redis has some really neat atomic multi-operation commands that can be used to create a distributed mutex. Check out the documentation for the SETNX command for an example. This example is based on polling and unfair: waiting processes are not … Continue reading

Posted in Algorithms, Code Poetry | Tagged , | 8 Comments

Expanding a leading tilde in C/C++

If you’re writing an app that accepts a path to a filename as user-input or in config-files, you’ll have to be able to parse the famous leading tilde and expand it to the correct home directory of the correct user. … Continue reading

Posted in Code Poetry, How To | Tagged , , | Leave a comment

Gmail Carbon Copy

Today I’d like to introduce Gmail Carbon Copy, an application I’ve coded during the last couple of months. The latest version is stable and works, so I’m deeming it fit for public consumption. Gmail Carbon Copy, or Gmailcc simply creates … Continue reading

Posted in Code Poetry, Gmailcc, Linux | 1 Comment

Fatal error: Allowed memory size exhausted

Fatal error: Allowed memory size of 8388608 bytes exhausted Ever got that error? It’s PHP telling you you’ve gone overboard on memory usage, and then dying (…pussy). When you’re running WordPress, you might have encountered this error when trying to … Continue reading

Posted in Code Poetry, PHP, Wordpress | Tagged , , | 3 Comments

IRC Quote (1)

Here’s a small puzzle: There’s a file with an unknown number of lines. From that file, I want to read and display 1 line. The line needs to be picked completely at random, so that every line has an equal … Continue reading

Posted in Code Poetry | Tagged , , | 7 Comments

Religion and Programming Languages

One Michael Kimsal put up a survey to determine the correlation between what religion you believe in and what programming language is your favorite. Although of little real use, and probably not to be taken seriously, it’s going to be … Continue reading

Posted in Code Poetry, Madness | 2 Comments

Scratching an itch: Cocaine

Ever have a file you need to quickly upload to a remote location so that you can share it with others? I have. For example, some photo I want to show someone, real quick. So I wrote a script to … Continue reading

Posted in Cocaine, Code Poetry | Leave a comment