Older blog entries for movement (starting at number 281)

Setting up JACK on Fedora 12

Audacity is somewhat of a broken joke these days, so I needed to use Ardour to record. And that meant setting up JACK. Since JACK insists on exclusivity, I also needed to route pulseaudio through JACK so I could use other apps at the same time. Unfortunately, this is a bit of a pig to figure out. I hacked it as follows:


First edit /etc/pulse/default.pa, you need to add two lines:


load-module module-jack-sink
load-module module-jack-source

In theory now, a restart of pulseaudio should start using JACK for recording and playback, if jackd is running. However, it tends not to work very well: you might find PA hanging and you have to kill -9 it.

This isn't enough of course, now when you log in again, gnome-session will try to start pulseaudio, but not jackd, so nothing works. It's far from the right way, but I edited /usr/bin/start-pulseaudio-x11 (which is started from a /etc/xdg/autostart/ script), as follows:

amixer -c 0 sset 'Input Source' 'Line'

nohup jackd -d alsa &

sleep 5

/usr/bin/pulseaudio --start "$@"

Note that I have to set the input source by hand: something in desktop start up used to do this for me, but now I'm going through JACK it has to be done by hand.

Syndicated 2010-01-26 17:28:00 (Updated 2010-01-26 17:46:23) from John Levon

Liferea strict feed validation tip


New versions of Liferea refuse to parse any feed that fails to validate, even for relatively "minor" problems (the libxml2 recovery facility is no longer used; besides, it abandons the rest of the feed when it hits such problems). I don't want to use Google Reader, since I don't like the interface.


Typically bad feeds have things like high-bit chars or bare ampersands. Thankfully, there's a "conversion filter" feature that you can use to work around the bad feeds. On the two bad feeds, I run this filter:


[moz@pent ~]$ cat bin/fix-ampersands
#!/bin/bash

sed 's/\o226/&/g' | sed 's/& /\&/g' | sed 's/\o243/GBP/g'

Syndicated 2010-01-17 16:33:00 (Updated 2010-01-17 17:08:35) from John Levon

The main indicators of egotism as I intend it here are are loud self-display, insecurity, constant approval-seeking, overinflating one’s accomplishments, touchiness about slights, and territorial twitchiness about one’s expertise. My claim is that egotism is a disease of the incapable, and vanishes or nearly vanishes among the super-capable.


I’m the crippled kid who became a black-belt martial artist and teacher of martial artists. I’ve made the New York Times bestseller list as a writer. You can hardly use a browser, a cellphone, or a game console without relying on my code. I’ve been a session musician on two records. I’ve blown up the software industry once, reinvented the hacker culture twice, and am without doubt one of the dozen most famous geeks alive.


No prizes for guessing who this was.

Syndicated 2009-11-10 16:27:00 (Updated 2009-11-10 16:30:05) from John Levon

A horrible little ElementTree gotcha

What does this print:


from lxml import etree
doc = etree.fromstring('<a><b><c/></b></a>')
newdoc = etree.ElementTree(doc.find('b'))
print newdoc.xpath('/b/c')[0].xpath('/a')


The answer is: [<Element a at 817548c>]. The first point to note is that xpath() against an element is only relative to that element: any absolute XPaths enumerate from the top of the containing tree. The second point is that the shallow copying of etree means that _Element::xpath, unlike _ElementTree::xpath, evaluates absolute paths from the top of the original underlying tree! So even though there's no <a> in newdoc, an absolute XPath on a child element can still reach it.
Yuck.

Syndicated 2009-10-20 15:42:00 (Updated 2009-10-20 15:50:34) from John Levon

YouTube annoyance

How much time would it really take to order multi-part videos, so the suggestion at the end of the video is the next part? Please!

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

An annoying Python gotcha

Imagine you have this in mod.py:


import foo

class bar(object):
...

def __del__(self):
foo.cleanup(self.myhandle)

Seems fine right? In fact, there's a nasty bug here. If I try to use this module in client.py like so:

import mod
mybar = bar()


Then you're likely to get an exception when the program exits. This is because Python, for some bizarre reason, Nones out the globals in mod.py when taking down the interpreter. The actual __del__ method can be called sometime after this, and it ends up trying None.cleanup(), with the resultant AttributeError. It seems extremely bizarre that it happens in this order, but it does (a real example).

Syndicated 2009-10-10 16:05:00 (Updated 2009-10-10 16:12:43) from John Levon

Kernel solipsism

Thomas Gleixner:


Exactly that's the point. Adding dom0 makes life easier for a group of users who decided to use Xen some time ago, but what Ingo wants is technical improvement of the kernel... The kernel policy always was and still is to accept only those features which have a technical benefit to the code base.


It boggles the mind that someone could get things so backwards. The kernel exists to provide services to the outside world, not the other way around. By all means criticise the details of the Xen dom0 code, but this argument makes zero sense. How precisely did x86_64 support provide a technical benefit to the code base?

Syndicated 2009-06-04 12:11:00 (Updated 2009-06-04 12:18:44) from John Levon

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

272 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!