Ugliest site of the month - The Backyard Comedy Club

September 21, 2007
15 comments Misc. links

Ugliest site of the month - The Backyard Comedy Club It's been a while since I last ranted about some website looking not only totally unappealing but also barely usable. This time it's called The Backyard Comedy Club and it's a quite simply, a comedy club near where I live. The sad thing about this site unlike other sites that I've criticized as being butt-ugly in the past, this one is actually quite new. The footer says "Copyright Backyard Comedy Club 2007 ©".

Maybe the intention is that the whole website is a joke. Kind of to get you in the right mood for the comedy acts.

Vertically expanding textarea input boxes

September 19, 2007
0 comments JavaScript

I've recently improved the IssueTrackerProduct so that when you start to write in the little textarea it expands and grows vertically as the text gets larger and larger. Other sites like Highrise do this too for note taking.

Long story short, here's the demo and here's the solution:


function _getNoLines(element) {
  var hardlines = element.value.split('\n');
  var total = hardlines.length;
  for (var i=0, len=hardlines.length; i<len; i++) {
     total += Math.max(Math.round(hardlines[i].length / element.cols), 1) - 1;
  }
  return total;
}

$(function() {

  // First, for all the textareas that have lots of lines of text 
  // in them, we want to double their number of rows
  $('textarea.autoexpanding').each(function() {
     while (_getNoLines(this) > parseInt(this.rows))
       this.rows = '' + Math.round((parseInt(this.rows) * 1.5));
  });

  // When a user enters new lines, if they have entered more
  // lines than the textarea has rows, then double the textareas rows
  $('textarea.autoexpanding').bind('keyup', function() {
     if (_getNoLines(this) > parseInt(this.rows))
       this.rows = '' + Math.round((parseInt(this.rows) * 1.5));
  });

}

Truncated! Read the rest by clicking the link below.

Nasty human error in Zope ZEO setup

September 14, 2007
0 comments Zope

Together with my colleague Jan we today tried to fix a problem with Zope ZEO server that wouldn't start. Very strange we thought since another ZEO server on the same machine was working fine. We compared zope.conf files and found nothing obvious. Here was the error you get with 'bin/runzeo':


root@da-ovz-vm99182:/var/lib/zope-2.8.9/aragdb-zeo1# ./bin/runzeo 
Error: error opening file //var/lib/zope-2.8.9/aragdb-zeo1/etc/zeo.conf: 
[Errno ftp error] no host given

What?? ftp error??

Long story short, the error was this line in 'runzeo':


CONFIG_FILE="/${INSTANCE_HOME}/etc/zeo.conf"

which should have been this:


CONFIG_FILE="${INSTANCE_HOME}/etc/zeo.conf"

Not so easy to spot because the CONFIG_FILE line is something you rarely look closely at.

Fun Python error message

September 7, 2007
0 comments Zope

I saw this today on the Zope mailing list:


TypeError: open() takes at least 1946389116 arguments (4 given)

For anybody who's ever used Python you'll find this funny.

What art is ...according to Don Van Vliet

September 7, 2007
5 comments Art

What art is ...according to Don Van Vliet I finished a wonderful book about Don Van Vliet called "Captain Beefheart" by Mike Barnes and being a huge Beefheart fan this was a very interesting book. To be honest, I found out things about Don that I'm not sure I even wanted to know. I feel both sorry for and jealous of the musicians he worked with. The book is full of little mind bogging quotes by Don all worth a blog each but one that I did write down was this:

"[Don Van Vliet] told John Yau what painting was to him: 'Fulfilling the absence of space between the opposite meanings. I think that's essentially what I think. That came the other night. It cam blasting into my head. I quickly wrote it down. Yes, that's what painting is.'"

I've thought about it a bit too now and although I don't have to agree or disagree I think it's a very good answer.

Not just the bikini event

August 31, 2007
0 comments Misc. links

Not just the bikini event I've always considered the "personality" test even of beauty competition such as Miss World as a chance to go away and get some food or a toilet break and it's really only the bikini event that matters. It's time to revise that now maybe. Until this clip I've always thought what the beauties say just stupid, now I'm going to consider it amusing instead.

What's South Africa got to do with it?

Proud to be a Swedish atheist

August 29, 2007
0 comments Sweden

I have nothing against religious people and have both friends and family that are religious and I have absolutely no intention of converting them.

Although I've lived most of my adult like in Britain I'm still Swedish at heart and when I see stats like these I feel proud to be Swedish. Not only because of the liberal and modern thought but also the fact that "non-religiousness" is apparently a measure of social wealth.

"[authors of report] who argue that in societies characterized by plentiful food distribution, excellent public healthcare, and widely accessible housing, religiosity wanes."

UPDATE 2018

I am not an atheist. At least not any more. Not religious either.

Printer usability problem

August 24, 2007
1 comment Linux

Printer usability problem I booked an appointment for a computer repair today and there was a reference number and summary that I was told to print two copies of. One to go with the computer and one to keep myself as a reference. The page was one page long. So, in Firefox I clicked to print two copies. Our printer here at work is one of those that prints on both pages and that's where the problem lies. It printed the two copies one of each side. So only one piece of physical paper. Totally stupid.

I don't know what or who to blame for this. Is it my Firefox? My Dell printer? My Linux printer drivers? Surely there was a chance for someone working on this some time ago who chose not to think for a moment.

rfc822() vs. rfc1123_date()

August 16, 2007
0 comments Zope

To set the Expires header in my web application I used to use the Zope DateTime function rfc822() which doesn't return the date in GMT format. Here's how I used it:


>>> from DateTime import DateTime
>>> hours = 5
>>> then = DateTime() + hours/24.0
>>> then.rfc822()
'Thu, 16 Aug 2007 20:43:59 +0100'

Then I found out (from using YSlow) that it's better to use the GMT format (RFC 1123), and here's how to do that in Zope:


>>> from App.Common import rfc1123_date
>>> from time import time
>>> rfc1123_date(time() + 3600*hours)
'Thu, 16 Aug 2007 19:45:12 GMT'

(notice that even though my locale is here in London, because of the summer time an hour is added)

Truncated! Read the rest by clicking the link below.

html2plaintext Python script to convert HTML emails to plain text

August 10, 2007
12 comments Python

From the doc string:


A very spartan attempt of a script that converts HTML to
plaintext.

The original use for this little script was when I send HTML emails out I also
wanted to send a plaintext version of the HTML email as multipart. Instead of 
having two methods for generating the text I decided to focus on the HTML part
first and foremost (considering that a large majority of people don't have a 
problem with HTML emails) and make the fallback (plaintext) created on the fly.

This little script takes a chunk of HTML and strips out everything except the
<body> (or an elemeny ID) and inside that chunk it makes certain conversions 
such as replacing all hyperlinks with footnotes where the URL is shown at the
bottom of the text instead. <strong>words</strong> are converted to *words* 
and it does a fair attempt of getting the linebreaks right.

As a last resort, it strips away all other tags left that couldn't be gracefully
replaced with a plaintext equivalent.
Thanks for Fredrik Lundh's unescape() function things like:
   'Terms &amp;amp; Conditions' is converted to
   'Termss &amp; Conditions'

It's far from perfect but a good start. It works for me for now.

Version at the time of writing this: 0.1.

I wouldn't be surprised if I've reinvented the wheel here but I did plenty of searches and couldn't really find anything like this.

Let's run this for a while until I stumble across some bugs or other inconsistencies which I haven't quite done yet. The one thing I'm really unhappy about is the way I extract the body from the BeautifulSoup parse object. I really couldn't find another better way in the few minutes I had to spare on this.

Feel free to comment on things you think are pressing bugs.

You can download the script here html2plaintext.py version 0.1

UPDATE

I should take a second look at Aaron Swartz's html2text.py script the next time I work on this. His script seems a lot more mature and Aaron is brilliant Python developer.