talideon.com

Blackout Ireland

Entries for May 2005

May 4, 2005 at 4:29PM Fortran and Perl

Something struck me at the weekend.

Fortran and Perl are two sides of the same coin: While you can write Fortran in any language, you can write any language in Perl. [wink]

May 16, 2005 at 5:18PM Blast, Blast, Blast!

I’d meant to move the site over to the other server over the weekend, but completely forgot. I will do it tonight however.

Also, I’ve removed by account from blo.gs, so the Exeunt page should work properly anymore. I’m going to replace it with the contents of my Sage OPML file. Until then, it’ll just report that it can’t update the blogroll.

That is all.

May 16, 2005 at 7:14PM Are surpluses in STV a pointless complication?

Triggered by this post on Bram Cohen’s blog, I posted up this reply . I think I’d better outline what I’m talking about.

Ireland uses the Single Transferrable Vote for just about everything, including by-elections and presidential elections. However, it’s always struck me that the concept of the quota complicated the whole affair somewhat. Redistributing the votes of eliminated candidates is quite simple: strike off their first preference, and promote the others. However, redistributing the surplus is another matter. Here, a random sample is taken of the votes the size of the surplus, and it’s redistributed identically to eliminated candidates. But surely this isn’t fair, and it’s prone to inaccuracy, and the alternatives are all a bit unsatisfactory.

So why not just get rid of it! Instead, the count would go something like this:

  1. Assign votes;
  2. Eliminate the lowest ranking candidate;
  3. Distribute their votes, striking off their first preference and bumping up the preferences of the other candidates on their ballot;
  4. Repeat until any surplus candidates are removed.

Et voilĂ ! Now, I haven’t studied the mathematics behind voting systems--obvious caveat--so I’m not quite sure how this would perform. All I have is anecdotal evidence from what I see happening during Irish elections, which is that the surpluses are far from big and only really figure when it comes down to the last seat, if at all. So, comments?

May 16, 2005 at 9:27PM The so-called Dungeon Siege II ‘Beta’

Beta, my ass! When exactly did the words ‘demo’ and ‘beta’ get mixed up? Back in the old days, a demo version was an incomplete version of the game, given out to drum up interest in the end product, whereas a beta version was a complete version of the game, most probably riddled with bugs, given out so that people could help find flaws in it.

But nowadays, this seems to have changes. Beta = Demo.

I really liked Dungeon Siege. Sure, it’s just a roguelike with fancy-ass graphics, but it was a fun, albeit overly linear, fancy-ass roguelike. (Aside: I never really got Angband for some reason.) If I saw it in the shops tomorrow, I’d snap it up.

So imagine my joy when I came across what proported to be a beta release of the game! Joy! I’d happily hack and slash my way through it, reporting anything dodgy I found along the way. So I installed it, anticipation welling up inside, and started playing.

A few hours later, I’d managed to complete everything up as far as the Elven Whatchamacallit, whipped by way through, and then got ambushed by a bunch of Hak’u who made my life a living hell by keeping my characters unconscious for the best part of two hours, giving me only brief moments to leather the living daylights out of them.

Eventually I managed it, and headed back to the Dryad village, and... you bastards!

Yup, that’s exactly what I said when I was confronted by the message, “Thank you for playing Dungeon Siege II Beta Review”. It was a bloody demo all along!

Grrr!

May 17, 2005 at 5:15PM The DOM HTMLFormElement Interface Should Have a getElementsByName() Method

While useful on the HTMLDocument interface, getElementsByName() would be much more useful if it was included in HTMLFormElement interface. Every time I want to look up elements by their names, it’s usually on form elements rather than the document as a whole. Come to think of it, I don’t think there’s ever been a time I wanted to look elements up by name on the document, whereas I’ve wanted to do it on forms quite a bit. What a pain.

Oh, and here’s some code to get the same effect.

function GetElementsByName(frm, name) {
    var elements = [];
    for (var i = 0; i < frm.elements.length; i++) {
        if (frm.elements[i].name == name) {
            elements[elements.length] = frm.elements[i];
        }
    }
    return elements;
}

It’s trivial, but hey!

May 18, 2005 at 1:13PM A Message to My Bank

F*ck you, AIB you bunch of f*cking morons. You’ve made it so f*cking difficult to access my online banking in the past that I am very, very close to changing banks.

Yes, ye might make it next to impossible to transfer my account to another bank, but if ye don’t stop acting like the bunch of useless jobsworths that ye are and get my online banking working by the end of the day, I’m doing it anyway.

So f*ck you all.

Update: They fixed it. Damn, that was painful. I’m thinking of tearing apart the utterly useless interface to their online banking system in a bit.

May 24, 2005 at 3:52PM My C++ wrapper for the Expat XML parser.

Last year when I was writing Orpheus, I knocked out a C++ wrapper around Expat to make using it easier.

It consists of two classes. XMLParser is the Expat wrapper and sets up the event handlers and automates setup and tear-down of the parser itself. XMLEvtHandler consists of a set of callback methods triggered when some parsing event occurs, such as encountering a block of text, a start tag, or an end tag. You just subclass it, overriding any methods you need, and Robert’s your father’s brother.

It’s small and dead simple, and there’s next to no overhead except for that involved in the dynamic dispatch of the virtual members on the event handler class. In the big scheme of things, this overhead is minimal, though it could be got rid of completely if it were to be reimplemented using templates.

Download XMLParser and XMLEvtHandler here.

May 30, 2005 at 5:53PM An Appeal to Windows Programmers

Please, do not store stuff, especially if it’s user-specific, in the Registry unless you really need to. There’s an environment variable called APPDATA that gives the path to a directory in the user’s home directory where you can store your settings. Use this.

Also, don’t use the USERPROFILE variable to figure out where to put your settings--I’m looking at you, GSView, GVim, PuTTY and Delphi--using APPDATA is much cleaner.

Thank you.

P.S. If you’re wondering why I’m saying this, it’s because I ought to be able to make a copy of the “Application Data” folder to back up my personal settings in one go.

P.P.S. Store your settings such that if you store your settings under “Application Data” as you should, you should have some way of indicating that a path is relative to the “Application Data” directory or your own one beneath it. Firefox and Thunderbird are offenders on this count.

P.P.P.S. Use text files. Something like INI files or Java-style property files are best in most cases. If your application has a built-in scripting language, using that’s a good idea. Use XML if you really have to. But please don’t use binary data unless you can’t avoid it.