Pimp my COREBlog

September 27, 2005
5 comments Zope

I've started using lovely COREBlog by Atsushi Shibata at work recently as a "work blog". It's not going live because it's company internal stuff such as "Don't forget to send the invoice to Foobar Ltd".

I think COREBlog has a lot of potential. One of the best features is that it supports the Blogger, MovableType and MetaWeblog APIs which means that I can very quickly jot down new blog items without disrupting my workflow.

There are still some little issues that annoy me but not really stopping me from doing what I want to do. The one thing that annoys me the most is the design. It's better than nothing but it really isn't great in my opinion. Where can I find some other existing neat looking COREBlog instances willing to share their stylesheet? I wish there was a way that I can search Google for all blogs generated by COREBlog and then just open them one by one.

Ruby and Python benchmarked

September 25, 2005
27 comments Python

Some Ruby (the programming language) blogger has tried to implement the Edit-Distance algorithm in three different ways in both Python and in Ruby. His conclusion is more steered towards the difference between the algorithms and not so much the language. I guess that's fair because the implementation might be done better in Python than it was in Ruby. But, please notice that this is a Ruby coder and yet his Python implementations are always faster.

A quick glance tells me that the Python programs run about 3 times as fast as the Ruby ones. See the benchmarks

Smurl from Python

September 22, 2005
1 comment Python

If you thought the Web Service example on the about page of Smurl.name was complicated, here's a much simpler version. I use this code on my very own site for the email notifications which will contain long URLs.

Feel free to steal this code into your own projects:


from urllib import urlopen, quote

# variable 'url' is defined elsewhere
if len(url) > 80:
    url = urlopen('http://smurl.name/createSmurl?url=%s' % quote(url)).read()

Was that hard?

Python regular expression tester

September 19, 2005
1 comment Python

retest I've just discovered retest by Christof Hoeke which is a developers tool for testing and experimenting with regular expressions. It doesn't have a GUI so it uses SimpleHTTPServer to serve a web interface on http://localhost:8087 that uses AJAX to make the interface snappier. You use this if you feel uncertain how to write your regular expression syntax and need a helpful sandbox for playing in.

This is cool because as an application it's very modern. The source code is only 100 lines python code, some javascript code for the AJAX and a relatively simple HTML page. A genuine GUI app would be considerably much more code but would admittedly run faster. However, considering how "basic" this application is, speed is not an issue.

Truncated! Read the rest by clicking the link below.

'Cache-Control' or Expires

September 16, 2005
3 comments Zope

Dieter Maurer was as kind as he always is one the Zope mailing list and explained to me the difference between using the Cache-Control and the Expires header for inducing browsers to cache your web elements. He explains:

Cache control is the modern (HTTP 1.1) way, "Expires" the old (HTTP 1.0) one.

My problem is that I've know about each but never bothered to find out why there are two ways of doing the same thing. In most of my projects I've used the oldschool method of setting RFC822 formatted future dates on the Expires header, but from now on I'll use both. Dieter continues on my question "What is best to use and for what?":

Use them both:

HTTP 1.1 clients will honour "Cache-Control" (which is easier to use and much more flexible).

HTTP 1.0 clients will ignore "Cache-Control" but honour "Expires". With "Expires" you get thus at least a bit control for these old clients.

Truncated! Read the rest by clicking the link below.

Misstake or hidden Nazi message?

September 13, 2005
6 comments Politics

Timesonline.co.uk Times Online has at the bottom of its menu three little pics that links to Travel, Cars and Jobs. In case the images have changed since I wrote this, see my screenshot here.

Notice anything special?

Truncated! Read the rest by clicking the link below.

firstChild.nodeValue vs. innerHTML

September 10, 2005
15 comments Web development

I inherited some old Javascript the other day that looks something like this:


document.getElementById('msg').firstChild.nodeValue = message;

Inside the document there's a span tag that this writes to:


<span id="msg"></span>

Why use this arcane firstChild.nodeValue when you can use innerHTML??:


document.getElementById('msg').innerHTML = message;

It was not until I made this fix that the Javascript started to work in my Firefox. How could that ever have worked? All Javascript gurus out there, what am I missing?

Announcing Smurl - a free URL compressor

September 7, 2005
12 comments Zope

Today I formally launch a new website: http://smurl.name

Smurl lets you generate aliases for looong URLs that you might want to paste into your emails (emails are often width-size limited) or SMS. Imagine sending this SMS to a friend:


Hi mate. Pls check out my new flat on the net: 
http://www.foxtons.co.uk/search?md5=908a5a01192
c89ed37d7a3ed7edbcdb1&amp;currency=UKP&amp;search_form
=map&amp;search_type=SS&amp;inst_ref=ir_myfr000056608&amp;
submit_type=search

which could with a Smurl name be shortened to:


Hi mate. Pls check out my new flat on the net:
http://smurl.name/9c

The bad news is that this hasn't been done before. The most famous "competitor" is probably tinyurl.com and my hope isn't to become the worlds dominant short-url-forwarder. No, the purpose of building this is the underlying technology which is now released as Open Source which is called Smurler. This is a Zope product that anybody can install and then use how they like it with their own domain name or other settings. At work we might soon need something like this and since many of our commercial sites use Zope it will be a breeze to install and benefit from the Smurl functionality for various other applications.

With the default set of sample characters used for the Smurl names there are 1024 different 2-character Smurls, 32,768 different 3-character Smurls and 1,048,576 different 4-character Smurls which will last my quite long on that domain name alone.

There isn't much fluff to it yet. The smurl.name site has only one special user function and that is that it remembers all previous Smurls you have created. The next thing I might add is some basic statistics for the overall use. If you have any other ideas, let me know.

Amazon bug in shopping basket

September 5, 2005
2 comments Web development

My colleague Jan discovers a nasty bug on Amazon.co.uk that I believe anybody can reproduce. It's actually a real showstopper that prevents a shopper from ordering the things they want to order.

The problem is that on the View Shopping Basket page, only 10 items are shown per page. The 11th and 12th and so on, those items can't be changed (such as removed). So what do you do if you've decided not to buy that 11th book? Since you can only see the first 10 on the View Shopping Basket page, you might think that if you can delete the top couple of items, thus shrinking your list to say 8 items. What happens then is that you get a blank View Shopping Basket :) The total price is correct but apparently your shopping basket is empty. (see screenshot) It also appears, that the only way to see your shopping basket list again is to add some more items so that you have more than 10 items in the basket. And remember, what happens when you have more than 10 items in the basket? Correct, you can't reach the 11th which you originally wanted to remove. D'oh! Amazon.

Truncated! Read the rest by clicking the link below.

Random ID generator for Zope

September 2, 2005
0 comments Python

I was working on a little application that is similar to tinyurl.com (where any URL gets a unique random id that can be used to redirect with long clumsy URL strings) and came up with this little algorithm that I wanted to share with the world for some feedback.

There are two loops, one nested inside one big loop that goes on for infinity. The inner loop creates a list of possible combinations from a sample of letters and numbers eg (abc, acb, bac, bca, cab, cba). For each such found combinations it does a check to see if this has been saved before and if not it exists the loop like this:


if not hasattr(self, combination):
    return combination

Truncated! Read the rest by clicking the link below.