Back to Work

Christmas is over; read two books — Dead Air by Iain Banks, a decent book if not among his best, and Red Dog by Louis de Berniéres, a fun and fast read — did a couple of jigsaws with my gf, ate way too much, drank some very nice wines — like Masi Mezzanella and Bollinger Special Cuvée — and had a very good time in other respects, too.

Now it's back to work. It would probably have been a good idea to be on vacation for this week, too.

Article page

Base64

I have this base64 implementation (both decoding and encoding) in Common Lisp available on my web page. I have had some very nice feedback about it, but I've been a lazy maintainer; KMR sent me some patches for ACL compatibility many moons ago but I never got around to integrating them. Um. I think. Or maybe I did... Well, anyway, it took ages.

Now it turns out that a) Edi Weitz created a page for it in CLiki and b) KMR forked base64, now calling it cl-base64, giving it some undoubtedly much-needed optimizations (I never benchmarked my implementation and speed wasn't much of a concern when coding it) and adding some nice extra functionality.

Thanks, guys, both of you.

Article page

Zope sessions documentation

Zope has built-in sessions support, has had since 2.5.0. However, in the best Zope tradition, the documentation has been a bit spotty, and I was experiencing some major frustration because of this. Someone else on #zope was just asking about this too.

Not to worry: there is, this time, documentation. You just have to find it. The correct solution is the Zope Book, 2.6 Edition, under development. It's not easy to find; I found it via a mailing list archive where there was a link to it, and after that located the link at Zope.org.

So, the correct path is: Zope web site -> The Zope Book (2.5 Edition) -> Other versions of this book -> The Zope Book (2.6 Edition) -> Chapter 19: Sessions. Congrats, you are there.

Article page

CLCL rising

Teemu writes: I woke up the other day and said to myself: "There does not seem to be a cross-platform natively multithreading common lisp with sources available for me to play garbage collection games with, so why don't I write one?".

The working name is CLCL.

Article page

Short gtkhtml2 tutorial

GtkHTML2 is a sorely undocumented widget. I still occasionally get trouble with it, and I know I'm not the only one. While its future may be in question — gtkhtml1 replacing it is still a possibility, because the Ximian hackers are committed to maintaining it — it's the HTML widget of choice for Gtk2/GNOME 2 hacking today. Few notes on it follow, examples in Python:

Initializing the widget.

# I assume there's a scrolledwindow widget called html_scrolled_window

# in a glade widget tree available

scrolled_window = glade_widget_tree.get_widget('html_scrolled_window')

htmlview = gtkhtml2.View()

document = gtkhtml2.Document()

scrolled_window.set_hadjustment(htmlview.get_hadjustment())

scrolled_window.set_vadjustment(htmlview.get_vadjustment())

document.clear()

htmlview.set_document(document)

scrolled_window.add(htmlview)

scrolled_window.show_all()

IIRC doing things in the wrong sequence could cause segfaults.

There are a few signals that are useful to connect to:

# The document object's link-clicked signal is emitted when the user

# clicks a link.

document.connect("link-clicked", link_clicked)

# The document emits request-url when it needs data from an url.

# This is used for at least image fetching.

document.connect("request-url", request_url)

# Htmlview emits on_url (yes, this is spelled with an underscore

# unlike the two others) when the mouse is on an url. This is useful for

# displaying the URL somewhere.

htmlview.connect("on_url", on_url)

link_clicked receives the document object and link href as arguments. request_url receives the document, URL and a stream to write the data to. You should just fetch the data from the URL and write it to the stream. on_url receives the htmlview object and the url.

To display data in the widget, you need to write to the document object's stream. Something like this:

document.clear()

document.open_stream("text/html") # this is the only mime type recognized

document.write_stream("<html><head><title>title</title>" +

"</head><body>body</body></html>")

document.close_stream()

Note that this — I think — assumes ISO 8859-1 encoding. If you want something different, you have to specify that... wait for it, try to guess... with a meta header. There is apparently no API to do that; it must be specified in the document stream itself. So, for UTF-8, you want to add this to the head part:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

That's it. Now you can display HTML documents in your GNOME 2 applications. I'll probably write some more once I have something to tell about using CSS with gtkhtml2.

Article page

Tilde on the web

Mark Pilgrim expounds on the history of the tilde.

One of the unanswered questions was "When did it migrate into the world of web servers to provide a cheap and simple way of giving individual users their own web sites?"

You could just email Rob McCool or someone and ask them when this was introduced, but it's much more fun to play archaeologist, isn't it?

The CERN/W3C web server added support for ~username in 1994. Change notes (sorry, no direct link to the relevant version, they don't have anchors on that page) for version 2.15beta, released 11 February 1994, say this: "User-supported directories enabling URLs starting with /~username".

NCSA's web server is more difficult. The version history page first mention of the feature, I think, at version 1.0a4, but that was already a bug fix. It doesn't mention release dates, either. Grabbing the old versions from their ftp server, the feature wasn't in 0.5 but it was in 1.1 (obviously), which was apparently released somewhere around March 25th, 1994. At least that's the date of the newest files. Sadly none of the versions between those two are available for download.

Quick Googling didn't find version history for Plexus.

Switching to Google Groups,

Article page