Playing with Reverend Bayesian

October 19, 2005
0 comments Python

I've been playing around with Reverend a bit on getting it to correctly guess appropriate "Sections" for issues on the Real issuetracker. What I did was that I downloaded all 140 issuetexts and their "Sections" attribute which is a list (that is often of length 1). From list dataset I did a loop over each text and the sections within it (skipped the default section General) so something like this:


data = ({'sections':['General','Installation'], 
         'text':"bla bla bla..."}
        {'sections':['Filter functions'], 
         'text':"Lorem ipsum foo bar..."}
        ...)
for item in data:
    secs = [each for each item['sections'] if each != 'General']
    for section in secs:
        guesser.train(section, item['text'])

Truncated! Read the rest by clicking the link below.

Furious and deprived by 'rm *'

October 15, 2005
2 comments Linux

In years I haven't accidentally deleted important stuff with rm * when what I mean is rm *~ to delete backup files, until...

Yesterday I accidentally deleted all templates for a work project when I wanted to delete the backup files which look like this foo.zpt~. In the haste I did:


$ rm *

When I meant:


$ rm *~

Today I did it again. I didn't want any backup files in my ~/bin directory which just screws up tab completion. Again, in the haste I accidentally deleted all my bin scripts :( Most of it recoverable or easily rewritable but still a f**ing nuisance. What to do? Do people have any good suggestions to make the rm work more like the Trash can does on the desktop?

table-layout: fixed

October 13, 2005
1 comment Web development

I've learnt something interesting today worth thinking more about. The "table-layout" selector in CSS2. Long story short... if you specify it like this:


<table style="table-layout:fixed">

then the whole table will be shown slightly faster because the browser doesn't have to load the whole table into memory and then use the "automatic table layout algorithm" where it needs to find out what widths to use on the table based on the content inside. With the fixed algorithm the widths are either defined by:

  • a width != auto on any of the columns
  • a width != auto on any of the columns found in the first row
  • the remainder width found from rendering the first row by also considering the tables margin to other side-elements such as the whole window

Truncated! Read the rest by clicking the link below.

Dream: python bindings for squidclient

October 11, 2005
3 comments Python, This site

At the moment I'm not running Squid for this site but if experimentation time permits I'll have it running again soon. One thing I feel uneasy about is how to "manually" purge cached pages that needs to be updated. For example, if you read this page (and it's cached for one hour) and post a comment, then I'd like to re-cache this page with a purge. Setting a HTTP header could be something but that I would only be able to do on the page where you have this in the URL:


?msg=Comment+added

which, because of the presence of a querystring, is not necessarily cached anyway. The effect is that as soon as the "?msg=Comment+added" is removed from the URL, the viewer will see the page as it was before she posted her comment. squidclient might be the solution. ...sort of.

Truncated! Read the rest by clicking the link below.

Best Image Replacement Technique guide

October 7, 2005
0 comments Web development

If you ever need to use the "Image Replacement Technique" in CSS which is what you do when you want to have a perfectly valid document with a title but to style the title with an image. This is very common on web standardised pages like any of the css Zen Garden pages

This summorised tutorial by Dave Shea is one of the best ones I've seen in a long time. As a layman it's difficult to know which one of the many methods I should use. Like many other techniques I rarely remember which one is better than the other. Usually my only guide is to look at the date of the article and assume that the newer the better. (than and other credentials such as who wrote it)

Truncated! Read the rest by clicking the link below.

Gmail catching up with the IssueTrackerProduct

October 4, 2005
0 comments Web development

I am aware that I might sound pompous in saying this, but it appears that Gmail is being inspired by the IssueTrackerProduct now that they too have an auto-save function.

The IssueTrackerProduct has had an auto-save feature for several months now and it's been working very well. Perhaps it's been done before and I congratulate those who've done it chronologically before me but hand-on-heart: I have never used website form that has auto-save until I did one for the IssueTrackerProduct.

Now, back to earth and do some work.

Wanted: good Javascript for handling key events

October 4, 2005
0 comments Web development

I've searched and searched but can't find anything that is good enough. What I'm after is some Javascript/ECMAScript code that let's me control what keys the user presses on a particular page. One page that does this well is Gmail but their code is so damn hard to debug because of all the "obfuscation".

So, do you know any pages where they've really got keyevents going with javascript? I mean for the whole page, not just a simple onkeydown on a form input. The only stuff I've found either doesn't work in IE or doesn't work at all in Mozilla.

I know that it's considered bad usability to fiddle with the keys because it can break something native to the browser but I know what I'm doing and Gmail as an example that it is possible.

UPDATE

I've found something that works now. At least in Firefox and MS IE 6. It uses the onkeypress event like this:


function body_onkeypress(evt){
   if (!keyboard_shortcuts_enabled) return;
   function S(k) { return String.fromCharCode(k); }
   if (window.event) key=window.event.keyCode;
   else key=evt.which;
   var s = S(key);
   // then do something with 's'
}
document.onkeypress = body_onkeypress

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.