The Good Old Displays

Last week, the hard drive in my MacBook Pro went kablooie (2 years and 11 months into my 3-year AppleCare warranty, woohoo) so I spent several days on my backup, the old PowerBook. Damned if I didn't find it a relief to go back to the PowerBook's display. It's not as bright, which is a bummer, but the great thing is that it's lower res -- 1440x900 instead of 1680x1050. The MBP just makes everything too small.

At least they're both matte, though.

posted 2010-Oct-19 18:01 :: permalink

Valgrind overrides pointer to integer promotion.

Today, a test file was segfaulting on Linux halfway through its run, so I ran it under Valgrind, expecting to be informed where the memory error occurred. Surprise! Not only did Valgrind not tell me what I needed to know, the test completed successfully. Huh?

Using old-fashioned binary searching, I tracked down the bug to an improper promotion of pointer to integer. Converting C pointers to integers is tricky business -- you have to make an intermediate cast to the integer type that is exactly the same byte size as the pointer type. Casting to a larger integer type doesn't necessarily work, even though intuitively it seems like it should because the larger type has enough room.

   /* On certain 32-bit Linux systems... */
   i64_t wrong        = pointer - another_pointer;
   i64_t still_wrong  = (i64_t)pointer - (i64_t)another_pointer;
   i64_t right        = (i64_t)(u32_t)pointer - (i64_t)(u32_t)another_pointer;

What I hadn't realized was that in addition to overriding malloc(), free(), and so on, Valgrind overrides the system's pointer-to-integer conversion routines. I hadn't even realized those routines were dynamic! The test completed correctly under Valgrind because it used the promotion algo the code was expecting. But Valgrind's behavior differed from the system's, so it was blind to the bug.

posted 2009-Jan-22 19:30 :: permalink

overload overload

Searchable is an interface in Java Lucene's org.apache.lucene.search package. It defines six different methods called search().

Searcher is an abstract class which implements the Searchable interface. It defines eight more methods called search().

The IndexSearcher class subclasses Searcher, so it inherits all eight of Searcher's search() methods. It also implements three of the search() methods defined by Searchable. Then there's the aptly named MultiSearcher, which, like IndexSearcher, inherits from Searcher and implements three search() methods of its own.

I wonder what it would take to rewrite all of Lucene using only methods called overload().

posted 2008-Dec-19 18:31 :: permalink

Perl on Rails

"People ask me, 'Why don't you get married?', and I tell them, 'I am married!' They say, 'You are?! When did you get married?', and I say 'I've been married since I was five years old! I'm married to the trains.'" -- somebody I met on the Amtrak Coast Starlight Express

I love the Coast Starlight, especially when it's late -- which it always is. When traveling north, you wake up somewhere in southern Oregon, and the later the train is, the more of that dramatic countryside you get to take in. Last time I was lucky -- the train was over four hours late, and I woke up in northern California!

I just wish the Coast Starlight had more electrical outlets.

posted 2008-Dec-19 18:31 :: permalink

My name is Variable.

The subject of variable naming came up on the KinoSearch mailing list a little while back. This blog entry started off as part of an email reply to that thread, but then I thought better of it...

As a base, I agree with all the general rules regarding names laid out in the Slash Style Guide:

The only qualification I would make is that the preference for underscores over CamelCase is language-dependent — for instance, CamelCase is preferable for Java and JavaScript.

On top of those, here are a few more:

Each of these rules is made to be broken, of course... but collectively, they seem to have served me well.

posted 2008-Dec-19 18:31 :: permalink

Once more time from the top.

Two posts in a year and a half! I knew I was never going to be the world's most prolific blogger, but... wow.

Let's try this one more time from the top.

posted 2008-Dec-19 18:31 :: permalink

Comment 22

So... after some undisclosed amount of time screwing around with various comment plugins, I'm dissatisfied. I don't feel an affinity with the Blosxom plugin architecture.

None of the available plugins seem to do what I want. Some of them are close, but not close enough, and they aren't like quite Perl modules. If they were CPAN distros, I would know exactly how to extend, test, and debug them. Since they're ad hoc files, it's less clear, and the code quality seems to be lower on average than you'd see on CPAN. They might be easier for the less skilled hacker to prepare, but they're more troublesome for me to work on.

I glanced at Bryar, and it looks more like what I'm used to -- but not many people seem to have hacked on it. Movable Type, maybe?

I'd ask y'all out there for advice... but first I'll need to turn on comments.

posted 2008-Dec-19 18:31 :: permalink

This blogging software's too little! This one's too big!

Blosxom: a few hundred lines of Perl.

Angerwhale: when I tried to install it from CPAN, it asked me if I wanted to install its forty dependecies. Forty! And I already had Catalyst installed!

How about something functional in between those two extremes, please?

posted 2008-Dec-19 18:31 :: permalink

Copyright © 2004-2007 Marvin Humphrey