Andrew Channels Dexter Pinion

Wherein I write some stuff that you may like to read. Or not, its up to you really.

October 28, 2003

Comment Spammed

I've started spotting spam in the comments here. Which amuses me because I can't think why anyone would want to use what is essentially my web notepad to advertise pr0n.

But it's a pain to search out and remove manually, so I've installed MT-Blacklist. Lets see what happens now shall we.

Posted by Andy Todd at 09:32 AM | Comments (2)

October 20, 2003

Bad E-Commerce Web Site

Inspired by NTK I'm going to start keeping a list of sites that have bad usability. The primary criteria for inclusion is not embracing web standards.

The biggest crime, in my book at least, is designing your web site so that it only works with Internet Explorer.

Our first two candidates our both in the retail business, in fact they're both wine sellers. Say hello to Oddbins and Virgin Wines.

The really bad thing, from my point of view, is that you can browse the catalogue on both sites and even add things to your basket at Virgin Wines. But they have made assumptions that you are running IE which only become apparent when you try and order. There is, sadly, no accessibility statement or list of supported browsers that I can find on either site. Bad, bad web sites.

I'm sure they won't notice the lack of my custom, but its the least I can do in the circumstances. That and send them an email pointing them to the Web Standards Project and the writings of Mr Zeldman.

Posted by Andy Todd at 05:04 PM | Comments (1)

October 19, 2003

iTunes v MusicMatch Jukebox

I just downloaded iTunes for Windows, played with it and uninstalled it.

There is no compelling reason to use it, unless you have an iPod or are buying music from the Apple Music Store. Which I can't because I'm not in merka. I've got a copy of MusicMatch Jukebox and it works like a charm, thanks very much.

It seems that my sentiments are shared by some other people.

Posted by Andy Todd at 05:20 PM | Comments (2)

October 16, 2003

Sum the squares of a sequence of numbers

There has been a long, long thread on comp.lang.python recently about the joys of lisp. I'm steering well clear of the discussion myself, but one thread-ette caught my attention.

The discussion was how to sum the square of a sequence of numbers. The pseudo code flew fast and furious in both functional and imperative styles. Which prompted a little dabbling, and I came up with this. Given a list of numbers in myList you can calculate the sum of their squares using;

sum([x*x for x in myList])

Posted by Andy Todd at 10:48 AM | Comments (3)

Kata 2, Revisited

Reviewing the definition of Kata Two I'm a little unsure what constitutes another algorithm. Is another search algorithm allowable, or should I implement another flavour of the binary chop?

All the specification states is that the code has to pass the unit tests. If this is the case then my second submission (in Python, naturally) is;

def chop(item, collection):
    for index, element in enumerate(collection):
        if item==element:
            return index
    return -1

It will work, but I make no claims about efficiency. Oh, and you will need at least Python 2.3, because that is the first version that included the enumerate function.

Posted by Andy Todd at 10:23 AM | Comments (1)

October 15, 2003

Kata 2, Pass 1

Now I've skipped to Kata 2. My first pass is a fairly standard, procedural, binary search;

def chop(item, collection):

    while ( start <= end ):
        if item==collection[middle]:
            return middle
        elif item < collection[middle]:
            end = middle-1
            start = middle+1
    return -1

For my next exercise I'm going to try either a recursive solution or something with generators. I'm just hoping it will take slightly less than the two hours it took me to come up with this one.

Posted by Andy Todd at 09:45 PM | Comments (0)

October 14, 2003

Kata 18

A while ago, I mentioned Dave Thomas' Kata. Well, I've taken the plunge in a vain attempt to stretch my brain and had a bash at his latest. My solution is in Python and doesn't (yet) use generators, but its a good start. The code is here and;

A module trying out Kata Eighteen (,v)

For ease of readability I've included the two classes in the same module.

import unittest

class depend(object):
    def __init__(self):

    def add_direct(self, item, dependencies):
    def dependencies_for(self, item, results=[]):
        if self.dependencies.has_key(item):
            for dep in self.dependencies[item]:
                if dep not in results:
                    children=self.dependencies_for(dep, results)
        return results

class testDepend(unittest.TestCase):
    def setUp(self):
        self.mine = depend()
        self.mine.add_direct('A', 'B')
        self.mine.add_direct('B', 'C')
        self.mine.add_direct('C', 'A')

    def testA(self):
        "Make sure that A depends on B and C"
        self.assertEqual(self.mine.dependencies_for('A', []), ['B', 'C', 'A'])

if __name__ == '__main__':

Corrections and comments are, as always, welcome.

Posted by Andy Todd at 11:14 PM | Comments (0)

October 09, 2003

Date Utilities

One here for Simon who I promised a review of the differences between the new Python standard Date module and mxDateTime. Luckily now I don't need to bother as Gustavo Niemeyer has just announced python-dateutil which not only covers the differences but also offers a few more things whch aren't possible even in mxDateTime.

Posted by Andy Todd at 12:15 PM | Comments (3)

October 07, 2003

Almost perfect

This t-shirt is almost perfect, except we need to replace the word "shell" with the word "Python"

Posted by Andy Todd at 01:49 PM | Comments (2)

October 06, 2003

Database Metadata

I'm quite intrigued by XML Résumé Library (found courtesy of Jeremy Zawodny) . I'm always frustrated when I have to write my cv in Microsoft Word and then literally cut and paste it if I want to, for instance, turn it into a web page. Hopefully this will speed the process up somewhat, whilst allowing me to play with XML.

It also nicely intersects with a problem I've been thinking about, if not actually doing much with. I'm trying to come up with a decent XML format to describe the structure of a relational database. Google for database and XML and you'll get lots of references to storing XML documents in relational databases, or XML databases. Ask for metadata and XML and the subject matter is DTDs and XML-schema references.

There are also a number of object-relational mapping tools avaialable, such as torque, but they concentrate on the object relational impedance mismatch.

All I require is a simple, standard way of describing my schema - specifying that it contains a number of tables, each made of a number of columns, stored in tablespaces and related to each other in specific but interesting ways. I'd like to have a vendor neutral format that I can turn into DDL statements for any number of varieties of relational database, starting with the usual suspects of MySQL, DB2, Oracle and SQL Server.

The closest things I can find are the XML metadata interchange specification and the relational section of the common warehouse metamodel. I'll have a look at these two and report back. In the meantime please feel free to let me know via the comments of other standards that I may have overlooked.

Posted by Andy Todd at 09:41 PM | Comments (5)

October 01, 2003

Just When You Think You Know Everything

People laugh at you. The humble amongst us are always hungry for knowledge and these VIM Tips are full of nuggets. The tips for using buffers and ftp were particularly interesting to me.

I'll confess to having had a play with the other editor recently. I was mainly trying to find out what all of the fuss was about. After my noodling about I can see why it was a much better choice than vi all those years ago when I first started using computers in anger. But in the meantime VIM has bridged the functionality gap to such an extent that choosing between the two is largely a matter of preference. As I've been using :wq! and ZZ for more years than I care to count I'll be sticking with "The Best Editor in the World" thanks very much.

Posted by Andy Todd at 04:17 PM | Comments (1)