Posts in October, 2007

Tag clouds look better sorted!

I like the idea of tag-clouds and tags in general, but I had problems making them look good in I experimented with changing the relative size and blending colors, as well as with the huge number of visual tweaks you can do with CSS, but the amorphous blob of words just didn't seem to fit with the nice neat columns I had. Until, that is, I sorted the tags by popularity, which made it a lot neater and enhanced the effect of blending the font size / color. I don't know why it didn't occur to me before. I don't see many sites doing this, most tag clouds are sorted alphabetically.

The image below shows a tag-cloud sorted by popularity (left) and just alphabetically (right). Which one do you think looks better?

(Click for a larger image.)

Creating debates open to everyone

I've added the ability to becontrary for users to add their own debates. The debate regarding Python templates was quite successful so I hope Pythonistas will take advantage of this new feature to discuss Python-related topics. There's no restrictions on topics though, so feel free to create a debate on any topic. I think it is a great way of gathering opinions.

Is there a CSS expert in the house?

I've noticed that links in that have have a fragment (i.e. something after a #) don't always go to the exact location of the named anchor. I figured this was a Firefox bug originally, but I see the same thing in other browsers. I believe I have figured it out though. The browser changes the scroll position after the html is read, but before the stylesheets have been read. Once the browser has the CSS information the page updates, but because the CSS contains the dimensions of some elements, the named anchor changes position -- but the scroll position doesn't update accordingly. At least thats my working theory.  The only solution I can think of for this is to make all my style sheets inline -- but that would mean I wouldn't have the cache-related benefits of having them external. I can't be the first developer to be irritated by this. Can anyone offer a solution?

You heard it here first!

They say that in every day, you will use at least one sentence that has never been uttered before. I think this may be true of the Internet as well. According to google, the phrase 'telepods of doom' was used on the Internet for the very first time by me! Now if only I could somehow get it in to common usage and be immortalized... Telepods of doom you later!

BeContrary out of Beta

The site was also the subject of a bit of vandalism. One user was repeatedly posting page after page of garbage text. Another user posted an argument where he professed his desire to perform fellatio (in slightly different terminology), which was kind of off-topic. So I hurriedly had to implement some anti-jerk technology to prevent flooding. I also had to add the ability to the admin page to completely wipe a users arguments / comments, something which I had naively thought I wouldn't need. The truth is though, that this type of site is vulnerable to vandalism, and if somebody wanted to make a nuisance of themselves then it wouldn't be difficult. All I could do is retroactively clean up the mess. I've had no problems with spam so far, because I implemented a number of anti-spam measures that using javascript to present different content to users than would be seen by a bot. It would be quite easy circumvent, but I can change the technique if spam becomes an issue -- or implement a captcha solution. continue reading…

XML or Text for Python Templates

There are a number of (very good) templating systems and languages available for Python. They fall in to one of two camps; either they are XML based, like Genshi, or they are text based, like Mako. Most programmers favour one or the other, but there is far from a consensus over which is better.

I'd like to use this debate to gather reasons for using one over the other in the context of web development. I suspect there will be no clear winner, but it should serve as a useful resource for those faced with the decision!

Timed Caching Decorator

Here's the caching decorator I mentioned in my previous blog entry about optimizing the front page of It is pretty simple to use, you supply the same parameters to it as timedelata. So @timed_cache(minutes=30) would cache the result for half an hour. It is thread safe, so you can happily use it in the context of a web application, such as Turbogears. For many things it is a magical one-line speed-up, but there are some issues to be aware of. You can't use it to cache anything where the return value is context sensitive, such as SQLObject class instances -- because they are tied to a database context that wont exist at the second call. If you do want to cache such objects, then you should copy the information you need to a dictionary. Genshi templates make the difference completely transparent, so it is not much of a problem. Another issue is that parameters must be immutable, because they are used as keys in a dictionary.

Caching Aggregated News Feeds

Did some work on today. The front page was a little dull and had a bounce rate of 49.8% according to Google Analytics, which means that almost half of the visitors that land there don't go any further. Previously the front page just displayed a news feed and some recent arguments and comments, I change it so that the feed in the main column aggregates the content from the debates so that in addition to news, it also displays new debate topics and arguments. The result is that it the front page should contain much more interesting content that will tempt visitors to explore the site. continue reading…

I Sold Out!

I have officially sold out, by enabling adverts on I think I have made them quite subtle by using the same color scheme as the site and fitting them in to existing column sizes. There is a fine line between collecting some revenue to pay for expenses and scaring away the people that provide the content, so I would be interested in hearing peoples opinion on adverts in general.

Convince Me to Be Contrary

I just came across a site that is remarkably similar in concept to, called I don't think it existed when I started work on my site. Like, they have dual columns for arguments and voting, but it is more competitive than my debating concept, which about arguing purely for the hell of it. They also have a slicker looking design, obviously created by a real web designer rather than a coder working on it in his living room. Oh well. I guess competition isn't necessarily a bad thing!