Toggle Zope's debug mode

October 1, 2005
0 comments Zope

This is far from rocket science but since I personally many times find it useful I thought I could share it with other Zope developers/users who find themselfs often editing the etc/zope.conf file to change the debug-mode key.

This script opens the zope.conf file and changes it to say debug-mode off if it said debug-mode on before and changes it to debug-mode on if it said debug-mode off before.

Truncated! Read the rest by clicking the link below.

Jed looking like Emacs

September 28, 2005
0 comments Linux

Thanks to the author himself of Jed (my favourite programming editor) I can now make my Jed look like a colour theme very common on Emacs

The end result, so far, looks like the thumbnail right here. I've taken John's good start and fine-tuned it a bit myself to make it suit me even more. Unfortunately I don't yet know how to get my console to take up these colours so I've had to add the following hack to my .jedrc because colours are defined differently in X as they are in xterm/konsole/Eterm:


#ifdef XWINDOWS
set_color_scheme ("peter-emacs");
#else
set_color_scheme ("black3");
#endif

(if you're a Windows user, replace #ifdef XWINDOWS with #ifdef XWINDOWS MSWINDOWS) The console I use is Eterm and I'm sure it's going to be possible to set it up to use these colours even over SSH.

Truncated! Read the rest by clicking the link below.

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?