The blagotube home of Sune Kirkeby. Here are rambling rants and some bits of code.

19. Apr
2005

Next/previous links and gmail-style keyboard navigation

I’ve now added rel='next' and rel='previous'-links and visible next/previous links to the blog-post pages. Also, I added gmail-style keyboard-navigation to the entire site. It works for 'u' for Up, 'j' for Previous and 'k' for Next. It was pretty simple to implement:

document.onkeydown = function(event) {
    if(!event) var event = window.event;
    if(event.keyCode == 85 /* 'u' */) {
        document.location = '..';
    } else if(event.keyCode == 74 /* 'j' */) {
        var e = find_link_rel('previous');
        if(e) document.location = e.href;
    } else if(event.keyCode == 75 /* 'k' */) {
        var e = find_link_rel('next');
        if(e) document.location = e.href;
    }
};
function find_link_rel(rel)
{
    var children = document.getElementsByTagName('link');
    var i, child;
    for(i=0; i<children.length; ++i, child=children.item(i))
        if(child && child.tagName == 'link' && child.rel == rel)
            return child;
}
This post was written by Sune Kirkeby on 2005-04-19, and claimed to be mostly about rambling.
29. Feb
2004

Interesting Brooks quote

Today I began rereading Brooks’s The Mythical Man Month, and in the first chapter, where Brooks talks about the craft of programming, there is an interesting passage:

The dependence upon others has a particular case that is especially painful for the system programmer. He depends upon other people’s programs. These are often maldesigned, poorly implemented, incompletely delivered (no source code or test cases), and poorly documented.

What a lovely idea, that source code is part of the complete software package. Even though Brooks is only talking about delivering source code to system programmers, I think the idea is much more broadly applicable. The world of computing would be a much nicer placer, if source code was a part of the software package normally, and not exceptionally as it is today.

This post was written by Sune Kirkeby on 2004-02-29, and claimed to be mostly about rambling.
28. Feb
2004

Breaking the If-Modified-Since header

Some HTTP proxies unilaterally add a length argument to the If-Modified-Since HTTP header, breaking the defined form of the the If-Modified-Since header. Even if adding arguments to the If-Modified-Since header works with most HTTP servers, there are several reasons why it should be avoided:

  1. According to the HTTP RFC (both 1.0 and 1.1) it is wrong, adding arguments to arbitrary headers is not allowed. If you ask me this ought to be all the reason one could possibly need.
  2. It assumes that HTTP servers ignore unknown arguments on arbitrary headers (even those defined as not having arguments). If the arguments are not ignored the conditional requests will not be conditional anymore (invalid If-Modified-Since headers must be ignored, according to the HTTP RFC), negating the reason for adding the If-Modified-Since header.
  3. Even if a HTTP server knows about the length argument, the server will often ignore the argument; calculating the length of a document is often much too expensive, and often much more expensive than calculating a Last-Modified date for a document.
  4. The exact semantics of the length argument is not defined anywhere (e.g. is it the length before or after a transfer encoding is applied, and is it the length before or after line-ending conversions?). So, there is no guarantee that any given HTTP client and HTTP server will implement the same semantics for If-Modified-Since-with-length requests.

In these situations (there is a perfectly clear document describing what you may and may not do, and some idiot decides that it is quite allright for his software to do something verboten), I am often very much tempted to throw up my arms in despair, and declare the offending software persona non grata.

This post was written by Sune Kirkeby on 2004-02-28, and claimed to be mostly about rambling.
22. Feb
2004

This Travesty

This travesty was constructed and manipulated by Aaron Williams. Feel free to be amazed that it’s actually comprehendable. If you came in search of information, enlightenment, or anything useful, you probably need to re-think how you use the internet.

From Nodvick. I like it.