Basketball, Part Deux

The NBA sanctions (or, at least, the first part) are in. They’re pretty harsh to the Pacers, and considerably less so to the Pistons. My co-worker Darrin says that they were unjust. I’m not sure I’d go that far, though I do think that gutting the playoff chances of the Pacers, while doing relatively little to the Pistons, ignores the responsibility the Detroit fans face.

Eugene Volokh notes that soccer authorities will ban fans from games in some circumstances. Perhaps it would be appropriate to issue a suspension to the Detroit fans for their part in this mess.

But the best article yet comes from Dan Le Batard, a sports columnist (via Volokh’s post). It might be a little one-sided against the fans; I am hesitant to defend the kind of brutality Artest showed under any circumstances. But it highlights how fan problems are much harder to deal with, even as they become more important.

UPDATE: Changed link for the Le Batard column from the San Jose Mercury News (which requires registration) to the Duluth News-Tribune (which does not). I don’t know how I got through to the Mercury News without registering.

Basketball, European Style

Sports fans are, I’m sure, already aware of the fight that broke out between Indiana Pacers players and Detroit Pistons fans on Friday night in Detroit. Ron Artest, the Pacers player at the center of the controversy, has already been in trouble this year for allegedly putting his record label before his basketball contract, as well as for a controversial flagrant foul which the NBA overturned.

Jon and I attended the game immediately preceding the fateful one, here in Indy against the Atlanta Hawks. While Indiana won, it was a close match, with Atlanta leading for the majority of the game. Given Atlanta’s record (two wins, five losses–the mirror image of the Pacers record), I had expected the game to be fairly one-sided. It was clear then that the Pacers were not operating at full strength; the loss of their last three starters still able to play will, I fear, gut the team.

Not that the team hasn’t already, it seems, been gutted of the one thing I consider most important: their integrity. The Pistons have had a long reputation as the NBA’s bad boys, with the Pacers often held up in contrast. Have those times come to an end? I would rather see the loss of players like Artest–and the accompanying game losses–than to see the home team of the most basketball-crazy state in the USA degrade so. Good players are easier to find than good reputations.

The Ebenezer Scrooge of Retail

Target has implemented a nationwide policy to ban the Salvation Army bell ringers from the front of their stores. The cited reason: they found it inconvenient to not allow other charitable organizations to do similar fundraisers outside their stores.

That would never do; after all, one reminder to be kind to the unfortunate is bad enough, but two or three would be simply inexcusable. Why, people might be persuaded to give their money to someone besides a Target cashier! And what kind of Christmas would it be without a spectacular holiday retail boom? Humbug!

We have already been reluctant to shop at Target because of their atrocious return policy; in particular, because of this policy, we never inflict Target-bought gifts on people. While return fraud is a problem for all retailers, Target’s inflexibility has puzzled me; one of the reasons stores tend to put up with a level of fraud is to avoid alienating customers, something their policies have done on several occasions.

With this new policy, I’m convinced that their inflexibility is just a manifestation of the management’s irrational need for control and uniformity. They got in trouble a few years ago for refusing to donate to a veterans group because their policy required that all groups jump through a set of bureaucratic hoops before receiving charitable contributions. (Ironically, the corporate office did support that particular charity, but they destroyed all credit they might have gotten with their ham-fisted approach.) They seem to be forgetting that their policies and procedures have goals, and that the goals, not the policies, are what you should strive to preserve when things don’t work out the way you thought.

Target is jerking their support of the Salvation Army during Christmas, in a way that doesn’t even save Target money, during a fundraiser that is responsible for 70% of the Army’s budget. In my eyes, when it comes to hard-heartedness, Ebenezer Scrooge doesn’t hold a candle to these guys. Next time you think about shopping at Target, ask yourself which of these services you think should take the hit for the $9 million of the Army’s budget they think they’ll lose because of Target’s paranoia, and then make your way to a Wal-Mart or K-Mart instead. And on your way in, listen to the bells ringing, and drop a little extra into that kettle. I’m sure they could use the help.

UPDATE (2004-11-20): Hugh Hewitt says it better than I; go read it. James Lileks is not convinced, probably because he’s a huge fan. I will admit that my previous attitude towards Target certainly inclined me to this decision; I’m not sure I would have shopped there anyway. But Target is the closest department store to us, and convenience has overcome our attitudes before. I’m no retail wizard, but it doesn’t seem smart for them to foster more bad impressions among their customers.

Electronic Voting Incompetence

The long-awaited debut of electronic voting came in our just-completed election. Despite the initial controversy, things seemed to go well; the few fraud rumors floating around seem to be motivated out of partisan fanaticism rather than evidence.

The actual evidence, or lack thereof, is dealt with in this column. It’s a good justification for the legitimacy of the election, but it also sounds an important caution about electronic voting. For example:

Broward’s central vote-counter was not programmed to expect more than 32,000 votes in any single precinct.

With the limit exceeded, the running totals in four races (all constitutional amendments) did, indeed, start declining.

Observers quickly noticed it. It got fixed. The accuracy of the individual voting machines was never in question. Nobody’s vote was a “negative” that subtracted from the vote totals.

An experienced programmer will immediately notice the vote count at which things started going in reverse. The 32,000 figure is almost certainly a rounded or estimated figure; the real number is certainly 32,767 votes. Why? That’s the highest number a 16-bit signed integer (signed: able to store negative as well as positive numbers) can hold.

One of the most common bugs in programming is the mistake of treating a signed integer as unsigned. Most of the time, this works, since signed positive integers are stored in memory the same way as unsigned integers–up to a point. But if you’re making this mistake, and (with 16-bit integers) you add 1 to 32,767, you get -32,768 instead of 32,768. This may seem odd, but it’s an artifact of how negative numbers are stored in signed integers. After that, adding 1 does what you’d expect: makes the result less negative (-32,767, -32,766, and so on). By stripping off the negative sign before displaying it (which isn’t terribly uncommon either), you get counts that appear to be going down.

So what does all this tell us? It tells us that the vote-counting system was not tested nearly well enough, either by the manufacturer or the county. The manufacturer should have been technically competent enough to test for this very common bug, and the county should have made sure the counting system could handle the expected turnout long before Election Day.

Bruce Schneier, one of the leading experts on information security, discusses some of the continuing problems with electronic voting here. It’s important to note that Schneier’s essay assumes basically competent manufacturers and customers (election authorities). If it’s difficult to get proper counts when everyone is competent, imagine the state of affairs when everyone shirks basic quality assurance responsibilities.

It’s easy to see this as a partisan issue, especially after the CEO of one e-voting vendor confessed his involvement in Republican politics. The problems with getting accurate and undoubtable results from elections, though, is only a Democratic issue by accident this election. Republicans should be able to assert the basic soundness of this election while acknowledging how easily things could have been otherwise.

Besides Schneier’s recommendations, I would add that we should require that test results be made public. Had such results been made public in the case above, an outside observer could have noticed the above shortcoming of the tests and drawn attention to them, thus possibly averting the issue entirely.

A Free Base64 Codec

I’ve recently had need of a base64 codec for one of my projects. (For those who don’t know, a codec is a piece of software that encodes and decodes data using a certain encoding algorithm. If you’ve ever ripped to MP3 and/or played it back, you’ve used MP3 codecs. The base64 algorithm is one used in a lot of places to get binary data into places where binary data isn’t usually welcome.)

Anyway, the base64 algorithm is simple, standardized, and popular. Its use is mandated for certain tasks, and is a strong alternative in others. So, one would think, there should be plenty of good free implementations floating around that I could use, right?

Apparently not.

All the base64 code I could find in Google suffered from at least one of several deficiencies. Quite a few examples were in languages I wasn’t interested in, such as Java. Some looked good, but had licensing difficulties, including a few which had no discernable license grants at all from the original author. (Why even put such things out on the net?) Some had serious dependencies on data structures or other features of the larger projects they were a part of. Codecs that assumed stream-based operation were very common. And, sprinkled among the various code references, were glimpses into the frustration other projects have felt when performing the same search I was.

Clearly, there is a niche here left to be filled.

Well, at least there was. Those searching for such a thing can now use my base64 codec, implemented in base64.c and base64.h. The license is XFree86-like, and is 100% original code. It should be suitable for in-memory or streaming en/decoding, and does not attempt to allocate memory on its own. Being context-based, it can support multiple simultaneous transformations. I believe it to be fairly frugal regarding system resources.

Being a new implementation, I’m sure it has bugs. It’s not thread-safe, both because of a lack of locking mechanisms on contexts and because of the use of a single global variable internally. Additionally, I’m fairly sure the decode operation could be a lot smarter, and thus could perform much better. I’d like to think I’ve been careful regarding buffer management, though I’m not so stupid as to be confident of it. And it seems to be faithful to the spec, at least according to my testing. If I get a chance, I might improve on it later; alternatively, patches and other feedback are welcome!