Removing PDF Restrictions.

19. Mai 2008

Adobe’s PDF file format comes with the possibility to restrict the things you’re allowed to do with a PDF document. This has nothing do do with encrypting the document to keep unauthorized people from reading it. Instead, authors may want to disallow printing, modifying or copy&pasting parts of a document. It’s still possible to view the documents on the screen.

Apparently, on older versions of Mac OSX’s Preview, it was possible to just „Save as …“ a restricted PDF, the resulting saved file would be a PDF without restrictions. This was fixed, but the ColoySync utility still had the possibility to use the „Save as …“ trick. Apparently at some point, they fixed ColorSync as well.

As far as I can tell, the easiest way to print a restricted document nowadays is to use ColorSync to „Export …“ the PDF to a TIFF file, open the TIFF (it will be huge) in Preview and either print it directly, or print to a PDF. Of course, the resulting PDF won’t be searchable, but as far as I know, Adobe hasn’t come up with a „disallow search“ restriction (which no doubt, a lot of publishers would use) so you can search in the original, restricted PDF.

Slides for LRUG tonight.

12. Mai 2008

Introducing Weave
Introducing Bytes

Bit-twiddling with Ruby

6. Mai 2008

I’ve always wanted to write some routines that help out with bit twiddling. Since I’m working on some byte level stuff recently (Smartcards, ISO7816 to be precise) I’ve finally gotten around to writing an API to make handling bytes easier and self-documenting. Basically, it’s a –attention buzzword– DSL for bitfield description. Not really gotten very far, but this is how it looks up to now: if you’ve got a byte composed of bits with the following semantics:

   |1|-|-|-|-|-|-|Channel Encrypted
   |-|0|0|0|-|-|-|Method A
   |-|1|0|0|-|-|-|Method B
   |-|0|0|1|-|-|-|Method C
   |-|-|-|-|X|X|X|Channel Number 

I can use the following ruby code to represent it:

  require "bytes"
   b = "1......." => :enc,
                       ".000...." => :a,
                       ".100...." => :b,
                       ".001...." => :c,
                       ".....vvv" => :channel
   b.value = 0xff
   b.enc?        # true 
   b.b?          # false
   b.b           # `b.value` is now 0xCF / "11001111"
   b.b?          # true     # 7 = 0 # `b.value` is now 0xC8 / "11001000"

Instead of using the Byte class and instantiating it with the byte’s pattern, it’s also possible to include the module Bytes which adds a attr like class function (called byte_accessor) which adds the same sort of functionality to classes. Take this –vaguely contrived– implementation of the first two bytes of an IP Packet:

require "bytes_ng"
class IPPacket
  include Bytes
   byte_accessor :ver_ihl , "vvvv ...." => :version
                           ".... vvvv" => :ihl

   byte_accessor :tos, "111. .... | Precedence" => :network_control,
                       "110. ...."              => :inet_control,
                       "101. ...."              => :critic_epc,
                       "100. ...."              => :flash_override,
                       "011. ...."              => :flash,
                       "010. ...."              => :immediate,
                       "001. ...."              => :priority,
                       "000. ...."              => :routine,
                       "...0 .... | Delay"      => :normal_delay,
                       "...1 ...."              => :low_delay,
                       ".... 0... | Throughput" => :normal_throughput,
                       ".... 1..."              => :high_throughput,
                       ".... .0.. | Reliability"=> :low_reliability,
                       ".... .1.."              => :high_reliability,
                       ".... ..1. | RFU"        => :rfu_err_1
                       ".... ...1 | RFU"        => :rfu_err_2

This adds two instance variables (and their respective accessors) named ver_ihl and tos to the class IPPacket. These contain the actual byte value. It also adds a bunch of methods (like in the example above) that can be used to query and set the individual bits.

I’ve not gotten around to properly releasing it yet, but it works quite well so far. In case you’re interested, you can currently get it here.

Future plans are to package it and (maybe) add multi-byte functionality.

Visualizing Ant Scripts.

8. April 2008

XML is generally not only tedious to write, but also hideous to look at, yet sometimes you gotta bite the bullet and use an ant build script.

I’ve written a little tool that renders a dependancy graph of all the tasks in a ant build.xml file. The result looks like this:


The above was generated from this xml file which is too long and ugly to include here.

In case you’d also like to generate nifty little pictures like the above, to beef up skimpy documentation, for example, you can download the tool here. Just call:

java -jar antvis.jar

And all the rest should be self-explanatory. You’ll need to have a copy of Graphviz installed in order to render the pictures. In case you are interested in the source, you can grab a copy using subversion here:

svn co

Erste Fahndungserfolge bei Soko „Brücke“

3. April 2008

Nach der Ausstrahlung des Phantombildes der mutmaßlichen Brückenmörder im ZDF Dauerbrenner „Aktenzeichen XZ: ungelöst“ konnte sich die Oldenbürger SOKO „Brücke“ kaum noch vor Anrufen aufgereger Tokio Hotel Fans retten:

Bereits eine Stunde nach Ende der ZDF-Sendung „Aktenzeichen XY … ungelöst“ konnten rund 200 Anrufe verbucht werden, bis heute stieg die Zahl auf 350.

Quelle: Spiegel Online


Werbung, furchtbar im Arsch.

31. März 2008

Es gibt normale Werbefachleute und es gibt die Vollprofis von Werbetechnik Dick in Köln:


Nein, da hat nicht irgendein obzöner Betrunkener einen Aufkleber zwischen die Arschbacken geklebt, „das soll so sein“.

EURUKO 2008: Native Extensions

30. März 2008


You were expecting cats?

Here are the code examples in case you want to try them out yourself.

Here is a copy of the slides, unfortunately, they’re quiet huge at the moment, I’ll try to get smaller one as soon as I figure out keynote…

Suggestions from the audience

  • Ruby Hacking Guide : more detailed information about Ruby internals.
  • RubyInline : allows you to write C code in the middle of Ruby code
  • Somebody said the videos of the talks would be put up here
  • Dr. Nic was kind enough to write a generator to handle native extensions for his newgem tool. newgem is definitely worth trying out, it generates a LOT of boiler plate, which is sort of overwhelming. But it’s more fun to figure out what his tool does than to type boilerplate code.

Arguments vs. Parameters

19. März 2008

Just friendly reminder from the language police. The terms argument and parameter aren’t synonyms. Parameters are the variables declared in a function definition, as in:

    void range(int to, int from)

„the function range has two int parameters named to and from„. Arguments on the other hand are the values being passed in when the function is called:


„the function range is being called with the arguments 0 and x.“

Neues vom Tibet

17. März 2008

Pranken wie ein Klodeckel
Heiner Brand („Handball Manager 4“) spricht sich jetzt in einem großen Spiegel-Online-Gespräch gegen ein Olympia-Boykott aus Anlass der Unruhen im Tibet aus. Ihm ist das 1980 mit der Olympiade in Moskau schon einmal passiert. Sein Argument:

„Wir soffen uns 1980 gerade auf Vatertagstour durch Gummersbach, da habe ich von dem Boykott erfahren. Das hat mir im Ernst den ganzen Vatertag verdorben. Da war die Kacke am Dampfen. Ein Boykott bringt garnichts, abgesehen davon, dass darunter auch die chinesischen Prostituierten zu leiden haben, die wir schon durchgebucht haben fürs Mannschaftshotel.“

Das ganze Interview:,1518,541949,00.html

ruby main idiom

20. Februar 2008

Because I keep forgetting, it’s

if $0 == __FILE__
  puts "main"

where __FILE__ contains the name of the file that the currently executing code is located in and $0 is the name of the currently executing program.