Archive for September, 2006

setting css float with javascript in IE

Friday, September 29th, 2006

Just a quick reminder to self:
IE 6 (7) don’t seem to render style.float when set with javascript,
so when you want a div to float left *dont* try using:

 div.styleFloat = 'left';
 div.style['float'] = ‘left’;
 div.style.float = ‘left’;

(more…)

POSIX timeout bogosity

Tuesday, September 26th, 2006

Grace uses pthread conditionals to facilitate communication between threads. Worker threads waiting for new events can either wait indefinitely for an event or sleep on it for a determined number of milliseconds. The latter is implemented using the pthread_cond_timedwait() call. And this is where design-by-committee has gone completely insane. Someone thought he was being clever and specified the resolution for this call to be set in nanoseconds. Just what you need if you want to trigger conditionals in your particle accelerator. A bit of a bummer, though, if you want to use this call in, you know, actual real world conditions.

(more…)

If XML is a Rock, Liberal Parsing is a Hard Place

Thursday, September 21st, 2006

Historically, the Grace library has been really forgiving, if not lax, in parsing XML formats. In an ideal world, every document is well-formed, but sometimes it’s a seller’s market (take RSS feeds) and you have to work with what you get. Although this worked out well in general, we were having a lot of problems with less-than-well-formed documents every time a new module was checked in. Each OpenPanel module comes with an XML file that contains information about the object classes it represents, their relationships to other classes and their impact on the user interface. It’s easy to make a mistake here, but hard to understand what goes wrong if things don’t work out and you get unhelpful errors.

(more…)

IE css empty div extra padding bug

Thursday, September 21st, 2006

Most webdevelopers will have been in the situation that you want to use a background-image in an empty div and there is this whitespace padding at the bottom of the image.
Your stylesheet may look like

#mtdiv {
    position:relative;
    height:8px;
    width:12px;
    background-image: url(/images/bg_small.png);
    background-repeat: no-repeat;

    /* dit i tell you i hate IE? */
    border:1px solid;
}

(more…)

parsing XML with python

Friday, September 15th, 2006

Today I’ve tried parsing XML with xml.dom.minidom and xml.sax that both come with recent Python distributions. It made me want to kill people.

Then someone on irc pointed me to xmltramp, a wonderful (and small!) piece of python code that no amount of googling had turned up for me. xmltramp is absolutely brilliant, and was easy to hack for my subversive purposes.

People also tell me ElementTree is good.

stable interfaces

Friday, September 1st, 2006

Yesterday I wrote a db4file implementation for grace’s dbfile interface, using version 4.3 of Sleepycat’s db4 library.

Then my coworker tried it on 4.0, and it broke. Turns out the DB->open call got a bloody extra argument, for transaction support. Why the hell change a signature; what’s wrong with just creating a new function name. You can always pull it back together in 5.0…