Category Archives: Hacking

int modulus(int n, int m) { return n < m ? n : n % m; }

Real Programmers will love this! (Except that they always knew…)

At CppCon’15, Chandler Carruth, lead of the Clang team at Google, gave a great talk titled Tuning C++: Benchmarks, and CPUs, and Compilers! Oh My!. The talk that is mostly live-coding and micro-benchmarking is both, informative and entertaining. Among other things, Chandler presents an optimized version of the good old modulus. Let n be a non-negative and m a positive integer. Then he proposes replacing n % m by n < m ? n : n % m because – after all – if n is less than m, there is nothing to compute.

What supposedly was meant to be a joke, proposing a dumb micro-optimization that actually makes the code run slower, turned out to be in fact an improvement. This is astonishing because it violates just about every principle we’ve learned about writing fast code. Continue reading


A Simple Script for Generating Printed Sheets With Your OpenPGP Fingerprint

For some time, I have used printed sheets with my OpenPGP key and a short summary of the most important commands needed to fetch it from a key server, check its fingerprint and sign it. These I handed to people who wish to use and potentially sign my key as a secure means of exchanging my key’s fingerprint. It turned out that people liked these sheets and I have been asked how to generate them. The versions I have used in the past were just hand-crafted TeX documents but for your convenience, I have now written a simple shell script that will generate such sheets. Here is an example.

In the most simple case, you can simply run

Continue reading

Die Hacker sind an gar nichts schuld

Sehr geehrte Damen und Herren beim Deutschlandfunk,

seit Tagen berichten Sie immer wieder von dem Angriff auf die IT-Systeme des Deutschen Bundestags. Während ich der Berichterstattung bislang nur äußerst wenige technische Details zu Art und Umfang des Angriffs entnehmen konnte, ist mir aufgefallen, dass Sie regelmäßig von „Hackern“ sprechen, die den Angriff ausgeführt haben sollen. Während es nach meinem aktuellen Kenntnisstand nicht gänzlich auszuschließen ist, dass dem tatsächlich so gewesen sein könnte, halte ich es doch für äußerst unrealistisch, und bitte Sie, von dieser unbegründeten Anschuldigung in Zukunft Abstand zu halten.

Continue reading

Infinite Scrolling

Among the more recent diseases of web design are the so-called infinite-scroll pages; websites that (apparently) have no end so you can continue scrolling down until you get frustrated and give up. (Lately, there has been a nice xkcd comic about those pages, too.)

While – with a few notable exceptions like, say, picture results in search engines – personally, I think these pages are just another annoyance to the web user, I was still interested how they could be implemented. Not very surprisingly, Continue reading

Happy Hacking

Photo of a gnu made from various autum stuff standing on the keyboard of a laptop showing a GNU Emacs session.

Photo: Copyright (C) Moritz Klammler 2012; CC-BY-SA 3.0

Chestnut, acorn, wood sticks, bark and beeswax.