Arrow Endianness: How GNOME got sorting backwards

Conventions are important, even when it seems like it doesn’t matter one way or the other. Just look at all the people who complain about the nerve of Steve Jobs to place the close-window button on the left.

There’s no reason why the left side is better than the right side. Convention, however, says that you must choose one way and live with it, or else you’ll be forever forced to constantly convert between left-handed and right-handed traditions. Just ask anyone who’s ever had to write low-level networking code. When sending an integer, it doesn’t matter whether the big end or little end goes first, but if you don’t agree with the other party, your message will come out garbled.

So imagine my discomfort when I have to sort files in Nautilus or sort processes in System Monitor.

Continue reading Arrow Endianness: How GNOME got sorting backwards

HTML <legend> tag is broken in WebKit

All I wanted was for a legend tag to fill up its box horizontally, much like an h1 or div does by default. Apparently, legend tags are special and don’t follow the same rules as other tags in WebKit, and what I wanted to do was simply impossible. Since I wasn’t the one to choose to use the legend tag (it’s a CakePHP default), I simply replaced all instances of it with <div class="legend"> and went on with life.

Here’s an example in which the same display: block style is applied to an h3, a span, and a legend tag, each sitting in identical divs.

Gecko renders the legend tag as a block element correctly, and it fills up the div.

WebKit does something special about the width, and so it fails to fill up the div.

Given WebKit’s lineage, it’s not surprising that KHTML does even worse at the exercise.

Try it for yourself: legend width js-fiddle. Other people have had similar issues as well: StackOverflow: Cannot add margin to Legend element in Safari & Chrome.

Reading a USB scale

Update: I now have an improved C version of this program: usbscale.

I got suckered into one of those hard-to-cancel trials. The upside is that they give you a $10 USB 5 lb. scale to use with their software. The downside is that they want you to only use it with their software, and the company that makes the scale has since taken down their free USB-scale program.

The good news, as Nicholas Piasecki and some Linux users figured out, is that the USB scale conforms to the USB HID specifications, which helpfully standardize how USB scales should work (no joke).

So, this little Perl hack reads from the scale by accessing the hidraw# interface that Linux provides. In my case, I have hidraw4 hard-coded into the script itself. Basically, it loops until it reads a good value from the scale, at which point it prints out the weight and exits.

Edit: This code is now a Gist on GitHub.

Continue reading Reading a USB scale

It was me. 'Twas I.

“I” is a subject pronoun.  “Me” is an object pronoun.  ‘K?


I hit the car.
The car hit me.

Right?  “I” goes before a verb, and “me” goes after a verb.

But… if somebody asks who ate the cake, you would be tempted to say, “It was me.”  Nope.  Wrong.  Fail.

As any grammar nazi would tell you, that sentence is more properly rendered, “It was I.  I stole the cake.”  Duh.  How could you not know that pronouns after a “to be” verb have to be in the subject form?

“Who stole the 2000 presidential election?”

“It was him he!”

Don’t you love English?

Lost in translation

CAD file formats are a mess.

I’m trying to get a part made in Autodesk Inventor into Mastercam.

IGES is borked. Half the surfaces don’t come in.

SAT has a version mismatch or something, and it refuses to import.

I don’t have a license for STEP import, apparently, and STL (even if it isn’t NURBS) is messed up like IGES.

This is obviously an attempt by Autodesk to dominate the world.