All posts in 'Shortcuts'

Java: Creating a Stream on a ByteBuffer

18-Oct-07

This example is plain wrong. The InputStream will cause an endless loop as it always returns a value >= 0. Working code as follows: private static InputStream _newInputStream(final ByteBuffer buf) { return new InputStream() { public synchronized int read() throws IOException { return buf.hasRemaining() ? buf.get() : -1; }   public synchronized int read(byte[] bytes, […]

Read the complete article »

Sad things in germany

31-Aug-07

Haltet die Fresse! Glotzt mehr TV! “Shut up and watch tv”: Martin Schmitt ends his witty blog as a result §202c StGB that forbids “Hackertools” like wireshark, nmap and co as well as instructions for penetration tests for example. German Heise News. The post is well and sad written and i can totally understand him, […]

Read the complete article »

Don’t make that sad smilie cry even more

22-Aug-07

Escaping single quotes in ruby is the same mess as in java: puts ":'(".gsub(’\”, ‘\\\\\”)puts ":'(".gsub(‘\”, ‘\\\\\”) I needed this to make the smilies after my comment box (here) clickable. Shortly after that, i found escape_javascript, maybe it still comes in handy.

Read the complete article »