Archiv für die Kategorie „Allgemein“

Everbody hates Java. Jax 2012.

Mittwoch, 2. Mai 2012

Here are the slides for my talk at Jax. I’ve not written anything up yet, so here’s a link to the interview the JAX team did with me before the conference: interview (German). The slides probably don’t make much sense without me clowning around in front of them, sorry.

No loopback interface on Windows (XP)

Mittwoch, 22. Oktober 2008

Learned today that Windows doesn’t support a loopback interface for localhost. In consequence, network packets destined for the local machine are never passed to any interface and therefore can’t be captured by a packet sniffer. Unfortunately, looking at the network is my preferred way of diagnosing network problems, so this behavior gets in the way. An easy workaround is to route packets to a local address to the standard gateway instead. The gateway then sends the packets back to the local machine. This is a bit of a detour, but at least the traffic shows up. This dramatically changes how the packets are being moved around, so it might not help… But just in case:

  1. grab your IP address and Gateway using ipconfig in a DOS box.
  2. route add $LOCAL_IP mask 255.255.255.255 $GATEWAY_IP metric 1
  3. when you’re done, use route delete $LOCAL_IP to get things back to normal

Visualizing Ant Redux.

Dienstag, 14. Oktober 2008

I’ve written a small update to my ant-file visualization tool. The only visible change is that the default task is now marked in the output.

You can either download the jar containing everything you need, or build it yourself from the source available via:

svn co http://a2800276.googlecode.com/svn/branches/antvis

If Antvis is run from the command line like so:

$ java -jar antvis.jar
usage: [jre] antvis.AntVis -f inputFile [-t format] [-o outfile]
	format: format supported by dot. Default: `dot`
	outfile: Default stdout
call [jre] antvis.AntVis -l for a list of supported formats

It prints out the available options. If it’s called correctly:

$ java -jar antvis.jar -f build.xml -t png -o self.png

It will produce graphical representations of the provided build.xml file like this one

self.png

for Antviz’s own build.xml or this one

jpos_ant.png

The above is an example of a more complicated build.xml script, it ships with jpos.

Backslashes in C includes…

Samstag, 27. September 2008

Who’d have thought:

  1. that DOS backslashes in C include paths aren’t only ugly and a pain, but also not legal* C:

    If the characters ‘, \, “, //, or/* occur in the sequence between the < and > delimiters, the behavior is undefined. Similarly, if the characters ‘, \, //, or /* occur in the sequence between the ” delimiters, the behavior is undefined. A header name preprocessing token is recognized only within a #include preprocessing directive.

    (C99 6.4.7.3)

  2. … the C99 Standard is available for free online This links directly to the pdf containing the current standard, which lives here.
  3. It’s easy to fix:

    find . -name '*.[c|h]' -print0 | xargs -0 \
       ruby -i.bak -pe 'scan(/^\s*#include.*/){ gsub(/\\/, "/") }'
    
  4. * yeah, I know, it’s legal just undefined.
    ** this post inspired by this.

Backing up MacOSX Address Book without MaxOSX Address Book

Dienstag, 9. September 2008

I recently installed a new harddrive on my Macbook. Before proceeding, I made a backup of my entire drive using SuperDuper. I wanted a fresh install, so instead of just dumping the old disk image on the new drive, I installed Leopard and started selectively copying what I needed.

Everything went well until I wanted my Address Book back. Unfortunately, all advice concerning backing up Address Book is along the lines of “Start Address Book and select ‘Back up’ from the ‘File’ menu”, but no one tells you where Address Book actually saves the addresses. The easiest way to find out turned out to be using Instruments to monitor what files Address Book opened on startup.

To make a long story short: to transfer entries from one computer to another, just copy the Folder:

/Users/.../Library/Application Support/AddressBook

You may not be able to overwrite some files, because they are in use by other programmes (in my case the culprit was Safari). You can figure out which programme currently has files open using fuser in the Terminal.

“Ruby Cryptography: TINFM”

Dienstag, 22. Juli 2008

TINFM meaning “there is no fine manual”, of course. Just as with digest, Ruby’s openssl documentation is missing just the bits you’ll need to get started. In order to encrypt or decrypt something, you’ll first need to instantiate the approriate cipher:

        require 'openssl'
	cipher = OpenSSL::Cipher::Cipher.new NAME_OF_CIPHER

So how do I know the name of the cipher if it’s not documented? You’ll need to refer to the OpenSSL documentation, or refer to this handy list:

base64 Base 64
bf-cbc Blowfish in CBC mode
bf Alias for bf-cbc
bf-cfb Blowfish in CFB mode
bf-ecb Blowfish in ECB mode
bf-ofb Blowfish in OFB mode
cast-cbc CAST in CBC mode
cast Alias for cast-cbc
cast5-cbc CAST5 in CBC mode
cast5-cfb CAST5 in CFB mode
cast5-ecb CAST5 in ECB mode
cast5-ofb CAST5 in OFB mode
des-cbc DES in CBC mode
des Alias for des-cbc
des-cfb DES in CBC mode
des-ofb DES in OFB mode
des-ecb DES in ECB mode
des-ede-cbc Two key triple DES EDE in CBC mode
des-ede Two key triple DES EDE in ECB mode
des-ede-cfb Two key triple DES EDE in CFB mode
des-ede-ofb Two key triple DES EDE in OFB mode
des-ede3-cbc Three key triple DES EDE in CBC mode
des-ede3 Three key triple DES EDE in ECB mode
des3 Alias for des-ede3-cbc
des-ede3-cfb Three key triple DES EDE CFB mode
des-ede3-ofb Three key triple DES EDE in OFB mode
desx DESX algorithm.
idea-cbc IDEA algorithm in CBC mode
idea same as idea-cbc
idea-cfb IDEA in CFB mode
idea-ecb IDEA in ECB mode
idea-ofb IDEA in OFB mode
rc2-cbc 128 bit RC2 in CBC mode
rc2 Alias for rc2-cbc
rc2-cfb 128 bit RC2 in CFB mode
rc2-ecb 128 bit RC2 in ECB mode
rc2-ofb 128 bit RC2 in OFB mode
rc2-64-cbc 64 bit RC2 in CBC mode
rc2-40-cbc 40 bit RC2 in CBC mode
rc4 128 bit RC4
rc4-64 64 bit RC4
rc4-40 40 bit RC4
rc5-cbc RC5 cipher in CBC mode
rc5 Alias for rc5-cbc
rc5-cfb RC5 cipher in CFB mode
rc5-ecb RC5 cipher in ECB mode
rc5-ofb RC5 cipher in OFB mode
aes-[128|192|256]-cbc 128/192/256 bit AES in CBC mode
aes-[128|192|256] Alias for aes-[128|192|256]-cbc
aes-[128|192|256]-cfb 128/192/256 bit AES in 128 bit CFB mode
aes-[128|192|256]-cfb1 128/192/256 bit AES in 1 bit CFB mode
aes-[128|192|256]-cfb8 128/192/256 bit AES in 8 bit CFB mode
aes-[128|192|256]-ecb 128/192/256 bit AES in ECB mode
aes-[128|192|256]-ofb 128/192/256 bit AES in OFB mode

A list of the currently supported cipher strings, without the explanation can also be produced by calling OpenSSL::Cipher.ciphers

After you’ve instantiated the proper cipher, you tell it to either encrypt or decrypt, give it the key to use (and possibly an IV) and then pass in data using update:

	cipher.encrypt
	cipher.key = KEY_DATA
	ciphertext = cipher.update plaintext
	
	cipher.reset
	cipher.decrypt
	cipher.key = KEY_DATA
	plaintext = cipher.update plaintext

That’s all. Not really difficult, once you’ve pieced everything together.

London Underground Typeface

Donnerstag, 22. Mai 2008

Monday 2nd July 1979, straight after five years of student life in the UK, was my first day at Banks and Miles, a London based graphic design company. That morning was a bit of a shock. I was given a few large broadsheets with litho printed Johnston type. I was definitely confounded by being asked straightaway to design a new Johnston family with three weights — Light, Medium and Bold — within a month or two. (…) Colin Banks, an external assessor for the LCP, had asked me if I would be interested in redesigning a typeface. I was grateful for the job (…), but the prospect was daunting because I had no experience in type design and very little English language. (…) I expected that in the office there would be at least a kind of preliminary training or guidance for a novice designer — what drawing tools to be used, what size the original artwork should be, how to typeset with newly drawn letters. I remembered one college day in 1975 when our tutor took us to the drawing office of the Monotype Corporation in Salfords. They had impressive purpose-built drawing equipment, precision machines and many skilled draughtsmen and women. In contrast, my tools were very basic: pencils, felt tip pens, a Rotring pen with 0.1 mm nib, Winsor & Newton’s fine brushes and some photographic equipment in the darkroom.

type
Interesting article about Eiichi Kono’s1979 redesign of the “Johnston” typeface that London Transport has been using in the Underground since 1913.

Removing PDF Restrictions.

Montag, 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.

Montag, 12. Mai 2008

Introducing Weave

Introducing Bytes

Bit-twiddling with Ruby

Dienstag, 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:

   |8|7|5|4|3|2|1|Desc
   ================================
   |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 = Bytes::Byte.new "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 
   b.channel     # 7
   b.channel = 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
end

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.