Older blog entries for movement (starting at number 274)

BNP

Charlie Brooker on the BNP party political broadcast:

Nick Griffin's first line is "Don't turn it off!", which in terms of opening gambits is about as enticing as hearing someone shout "Try not to be sick!" immediately prior to intercourse.

Syndicated 2009-05-18 12:24:00 (Updated 2009-05-18 12:25:35) from John Levon

26 Mar 2009 (updated 26 Mar 2009 at 04:08 UTC) »

Outputting XML in standard Python

Is it really this ugly? I expected something like this:


doc = xmldoc()
doc.start('foo', { 'id': 'blah' })
doc.start('sub')
doc.text('subtext')
doc.close('sub')
doc.close('foo')
print doc


and I thought I had it in SimpleXMLWriter. However, I have to jump hoops to get it to output to a string, and it doesn't have any pretty-print. I tried using ElementTree, but that also doesn't pretty print! libxml2 is horribly low-level. lxml seems to do pretty printing, but it's still just as ugly as the best option I've found so far, xml.dom.minidom:


from xml.dom.minidom import Document
foo = doc.createElement('foo')
foo.setAttribute('id', 'blah')
doc.appendChild(foo)
sub = doc.createElement('sub')
sub.appendChild(doc.createTextNode('subtext'))
foo.appendChild(sub)


Yuck! If I'm building up a document, I almost always want to append directly at the last point: why do I have to keep track of all these elements by hand? I presume I'm missing some small standard helper module, but #python didn't know about it. Anyone?

Syndicated 2009-03-26 02:43:00 (Updated 2009-03-26 03:20:31) from John Levon

Scoble sets a new record

I really hate the word “friend.” It has no meaning anymore. No one can define what a friend is. Believe me, I’ve asked dozens of people to define it for me. My wife is my most “true” friend, for instance but if you trust her with picking a great wine (she doesn’t drink much) or picking a great sushi restaurant (she hates the stuff) you’ll be very disappointed. You’d be better off asking @garyvee about the wine even though you’ve never met him and he probably wouldn’t be listed among your “true” friends.

- Scoble

Might I gently suggest friendship isn't about wine recommendations?

Syndicated 2009-03-22 22:55:00 (Updated 2009-03-22 22:58:17) from John Levon

16 Mar 2009 (updated 16 Mar 2009 at 22:10 UTC) »

Sheesh

Apparently applications should be prepared to lose 60 minutes of data to work around the file system now.

Of course the notion that application should have explicit load/save operations is a nonsense already. Now we should "fix" one of the few places that never had this (ever seen a browser where you have to save your bookmarks explicitly when you quit?) to expose this implementation detail in a data-losing way again.

Syndicated 2009-03-16 20:31:00 (Updated 2009-03-16 21:26:42) from John Levon

Amazon

It's a shame that it's basically impossible to compete with Amazon when it comes to online book selling, because their website is so horribly awful to use. Not fair.

Syndicated 2009-03-16 01:25:00 (Updated 2009-03-16 01:27:26) from John Levon

It's not just atol(), Nicholas

Nicholas Nethercote warns us against atol(). Sadly, he recommends using strtol() instead. This interface is almost as bad. If atol() is impossible to get right, strtol() has to be classified under the obvious use is wrong.

As a perfect example of how horrible strtol() is, let's look at his example code:


int i1 = strtol(s, &endptr, 0); if (*endptr != ',') goto bad;
int i2 = strtol(endptr+1, &endptr, 0); if (*endptr != ',') goto bad;
int i3 = strtol(endptr+1, &endptr, 0); if (*endptr != '\0') goto bad;
...
bad: /* error case */

Can you spot the bug? What about an input like ",2,3" ? Nicholas does mention that this code is broken for underflow or overflow (you must wrap every singe call like this: "errno = 0; strtol(...); if (errno...)") but either missed this or considered it irrelevant. It's just too hard to get right.

Just use the *scanf() family (yes, that's hard to use too). Be suspicious of any code using either strtol() or atol().

Syndicated 2009-03-14 12:03:00 (Updated 2009-03-14 12:16:29) from John Levon

Comics I Don't Understand

Comics I Don't Understand. One for Seinfeld fans. What I don't understand is how someone can have a Wordpress design that has no "Previous" button. Blech.

Syndicated 2009-03-10 02:15:00 (Updated 2009-03-10 02:47:34) from John Levon

Heston Blumethal's Feasts

I've just watched last week's episode of this series, Heston Blumenthal's Victorian Feast. The guy is the epitome of the mad scientist (his dessert was strawberry, elderflower and absinthe dildo jelly with earl grey ice cream).

I had one of his inventions a while back: strawberry, olive and leather vanilla sundae. It was pretty nice, though the rather more staid chocolate wine popsicle was much nicer.

You should watch Tuesday's...

Syndicated 2009-03-09 22:47:00 (Updated 2009-03-09 22:55:44) from John Levon

Tomcat on Centos 5.2: just don't

If you were thinking of trying to use CentOS 5.2's tomcat packages: don't. You just get a silent 400 Bad request error on the holding page for no reason. Download it from upstream, and use that directly. It's very poorly documented, sadly, so to get started:

  1. Install the Sun JRE and set $JAVA_HOME appropriately - gcj is ... lacking
  2. Grab the Tomcat 'core' tarball and unpack it in place
  3. edit conf/tomcat-users.xml to add a user that has the 'manager' role
  4. start Tomcat with ./bin/startup.sh
  5. Go to http://yourhost:8080/ and log in to "status" with the manager user you added
  6. This will list any of the apps you installed (by dumping their .war file in webapps/)
I also set up a virtual host with Apache (for OpenGrok) like this:

<VirtualHost *.80>
ServerName grok.example.org
ProxyPreserveHost On
ProxyPass / http://example.org:8080/
ProxyPassReverse / http://example.org:8080/
</VirtualHost>

Syndicated 2009-03-07 19:10:00 (Updated 2009-03-07 19:16:51) from John Levon

Gas no gas abadie pizza please

Well this makes no sense:

Me: "Hi, your letter said I needed to arrange a visit with you to check the gas safety of my flat."
Them: "That's right, what's your details?"
*gives them*
Me: "There's no gas supply in the building, but apparently you have to come see that in person yourselves."
Them: "Yes, that's true. .... OK, we'll send you a letter with the appointment details."
Me: "Uh, I can't just do any time, it needs to be arranged."
Them: "That's OK - if you can't make the appointment on the letter, then you can ring us up after you receive it and tell us."
Me: "..."

Syndicated 2009-02-27 00:49:00 (Updated 2009-02-27 00:52:36) from John Levon

265 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!