Bent up truck

I got a rude surprise on my way home from work last night when somebody decided to make a U-turn across my lane. I made a valiant attempt to avoid a collision, but I wasn’t completely successful. I did manage to minimize the impact, though. The left side of my truck collided with the right side of a Toyota Sequoia SUV.

truck1.jpg

As you can see, the major impact was on the left front fender. It ripped off my mirror, leaving a big black streak on the window. The bed side is also dented in a few places, especially behind the rear wheel (hard to see in this picture). Something also bent my ham radio antenna. Perhaps the other truck’s mirror. I don’t think I decelerated fast enough for the antenna to have bent on its own.

Neither I nor the driver of the other vehicle (its only occupant) was injured. We got lucky and drove away (after exchanging information, of course) fully intact, with just a bit of bent sheet metal to show for it. I’m now in the process of determining how much it will cost to fix the truck, and hoping that the insurance company doesn’t decide to write it off as a “total loss.” We’ll see how that works out.

I’m fine. No injuries. Not even the soreness I expected as a result of the unexpected impact.

One thing: anti-lock brakes are a Godsend. When I saw that truck coming across my lane, I applied the brakes as hard as I could. The ABS did what it was supposed to do: prevented me from going into a skid. As a result, I was able to maneuver the truck and prevent what could have been a very nasty crash. As annoying as the ABS can be from time to time, I don’t think I’ll buy another vehicle without it.

Charlie helps in the yard

Yesterday was beautiful: calm, sunny, and 80 degrees. I had a few hours of outside work to do, what with rearranging the compost pile and vacuuming dirt out of the pool, and Charlie said he’d come out to help. Some help he was. I took a break after a couple of hours and caught him lounging in the grass:

ch1.jpg

“Charlie! I thought you were supposed to be helping me work. Or at least patrolling the yard to keep the squirrels and cats out.”

Uh oh. He caught me.

ch2.jpg

“But, Dad! It’s such a nice day. And I’m cute! Scratch my belly?”

ch3.jpg

“No, Charlie. You have work to do.”

ch4.jpg

“Nope. I think I’d rather just lie here and enjoy the sun.”

ch5.jpg

Hard to argue with that logic, ain’t it?

I can’t serve you ’cause you’re too fat

I’ve ranted a few times over the years about people trying to hold fast food establishments liable for making them fat. I thought that craziness had faded after Super Size Me disappeared from public consciousness. And it mostly has.

And then a friend sent me a link to House Bill 282, introduced in the Mississippi Legislature. The title:

AN ACT TO PROHIBIT CERTAIN FOOD ESTABLISHMENTS FROM SERVING FOOD TO ANY PERSON WHO IS OBESE, BASED ON CRITERIA PRESCRIBED BY THE STATE DEPARTMENT OF HEALTH; TO DIRECT THE DEPARTMENT TO PREPARE WRITTEN MATERIALS THAT DESCRIBE AND EXPLAIN THE CRITERIA FOR DETERMINING WHETHER A PERSON IS OBESE AND TO PROVIDE THOSE MATERIALS TO THE FOOD ESTABLISHMENTS; TO DIRECT THE DEPARTMENT TO MONITOR THE FOOD ESTABLISHMENTS FOR COMPLIANCE WITH THE PROVISIONS OF THIS ACT; AND FOR RELATED PURPOSES.

Full text (pdf). Full text (text).

Maybe I should get a patent on that fictional Body Mass Index calculator thing hooked to the cash register (see the linked rant, above). They’d definitely need something like that if they want to use objective criteria to determine if somebody is obese.

We’re fortunate that this bill was killed in committee, but I’m very disappointed that the thing was actually written and submitted to the Legislature. Imagine if it were passed: “I’m sorry, Sir, but according to State Law, you’re too fat to eat here.” Somehow, I just can’t see that happening. I hope I’m right this time.

The default is default

Some days I just don’t understand what people are thinking when they write documentation. Yesterday I installed a simple caching DNS server. That was easy enough with Ubuntu, and the thing is up and running. But my experience with these things tells me that I’d better look into its configuration. We do a lot of DNS resolutions, and I want to make sure that the server doesn’t run out of memory or something.

So I thought I’d start by determining how much memory BIND (the DNS server software) is configured to use. Simple enough, right? As it turns out, no.

According to the BIND Manual (search for “datasize” on that page):

The maximum amount of data memory the server may use. The default is default. This is a hard limit on server memory usage. If the server attempts to allocate memory in excess of this limit, the allocation will fail, which may in turn leave the server unable to perform DNS service. Therefore, this option is rarely useful as a way of limiting the amount of memory used by the server, but it can be used to raise an operating system data size limit that is too small by default. If you wish to limit the amount of memory used by the server, use the max-cache-size and recursive-clients options instead.

That’s nice to know (and I’ll come back to it in a minute), but what is default? I’ve searched up and down through the manual, in the Pro DNS and BIND book, and uncounted Web sites. I even downloaded the BIND source code and spent some quality time with grep. Not a clue. I still have no idea what default is.

“Okay,” I thought, “so I don’t really need to know what the default is. How do I set the cache size?” On the face of it, that turns out to be pretty easy. After all, there’s a max-cache-size option that I can set. The BIND manual says:

The maximum amount of memory to use for the server’s cache, in bytes. When the amount of data in the cache reaches this limit, the server will cause records to expire prematurely so that the limit is not exceeded. In a server with multiple views, the limit applies separately to the cache of each view. The default is unlimited, meaning that records are purged from the cache only when their TTLs expire.

That’s all well and good. I’ll go set my datasize and max-cache-size so that the thing won’t run out of memory. But thinking about the descriptions of those two variables, I got to wondering if the default configuration of BIND is a crash waiting to happen. Consider:

  • The default datasize is some unspecified default value. If the server attempts to allocate memory in excess of this limit, the allocation will fail, which may in turn leave the server unable to perform DNS service.
  • The default max-cache-size value is unlimited.

The only logical conclusion from those two statements is that the default configuration will lead to a crash if the cache grows large enough. Doesn’t seem too reliable to me. [Note: It occurs to me that if the cache handles the failed allocation reasonably–by purging older records–then the thing won’t crash. I have no idea if that’s how it actually behaves.]

In any case, if you’re using BIND for a DNS cache, you might want to change your datasize and max-cache-size values, just to be on the safe side.

[Additional info added 2008-02-21]

According to Cricket Liu in DNS & BIND Cookbook:

Some administrators are tempted to use the datasize options substatement to limit the size of the data segment the named process uses. Unfortunately, when named reaches the datasize limit, it exits. And then, of course, you have no name server running at all — though I guess that minimizes its memory utilization.

If that’s true, then it’s probably a very good idea to change the default configuration if you’re running a large DNS cache.

Take back the desktop!

I know, I’ve dipped into this well before. But this bears repeating.

At some point in the 30 years or so that I’ve been working with computers, we’ve lost sight of the most important fact: computers are supposed to be tools that serve us. All too often these days, I feel like I’m the one serving the computer. At other times, the computer reminds me of an over-eager employee who comes running to the office after completing every minor task, enthusiastically telling me how impressed I should be that he managed to find and actually work the photocopier.

You know what I’m talking about. When was the last time you spent an entire day not being annoyed by some pop-up message that Windows or some application program decided was important enough to interrupt whatever you’re working on? The last time I spent such a day was when I went on vacation and didn’t have access to a computer. If I’m working on the computer, I’m subjected to a never-ending barrage of pop-up messages and sounds that amount to little more than, “Hey! Look at me!”, and do nothing but interrupt my train of thought and annoy me.

You want examples? Oh, I have plenty:

  • The Firefox Web browser will automatically download updates and then pop up a message box asking if I want to restart.
  • When new Windows updates become available, Windows displays one of those notification balloons down near my task bar.
  • If I tell Windows Update to download and install updates, all too often when it’s done it pops up a message box asking if I want to reboot.
  • I minimize Windows Media Player to my task bar. Whenever it starts a new song, Media Player displays a little information box for a few seconds: “Look what I’m playing now!”
  • The default configuration of Yahoo Messenger will pop up a message window in the middle of the screen when somebody sends me a message.
  • If somebody else takes control of a machine that I have in Windows Remote Desktop, Remote Desktop pops up a message box telling me that my desktop session has ended.
  • Norton Antivirus (which I don’t use any more) would forever be displaying mostly meaningless notifications at the bottom of the screen.
  • Email clients can play sounds or flash the screen when you receive mail. In some programs, such actions are enabled by default.
  • If you’re running a program under Visual Studio and the program hits a breakpoint, Visual Studio will bring itself to the front, regardless of what you’re working on.

I know, some of you are wondering what I’m complaining about. Let me give you an example of why I get annoyed. If I happen to be typing (an activity that occupies a large part of my day) when one of those pop-ups grabs the keyboard focus, whatever I’m typing will end up in the new window. This is not good. I’ve actually re-booted the computer accidentally because I was typing while looking out the window when the “Reboot now?” confirmation box appeared.

Let me repeat that. I suffered a very annoying interruption and lost some important work because somebody decided that their program was more important than whatever I was working on at the time. That’s unforgiveable.

Let’s be clear about this one: a program should never grab the keyboard focus from the window that I’ve selected. I can’t think of a single instance in which I want some random program to pop up in front of my text editor and start swallowing what I’m typing. There is no excuse for such rude behavior. Designers who create such things should be shot, right along with any programmers who have the poor sense to actually implement the designs.

I’m slightly more forgiving of the ostensibly innocuous notifications that pop up in balloons all over the place, but not much more. It’s nice that programs keep me informed of what they’re doing: security updates are available, new updates were downloaded, a friend messaged me, there are unused icons on my desktop, etc. But most of those things just aren’t important, with the exception of a text message from my friend, none are important right now. Those messages should be placed in a notification queue that I can check at a time of my own choosing. If it requires immediate attention (like my friend messaging me), it should display a message on the corner of the screen to get my attention, but under no circumstances should it grab my keyboard focus.

Like many other people, the work I do requires intense concentration. Most people require a certain amount of time (five to 30 minutes, typically) to “get into the groove” where they’re concentrating deeply and able to be productive. Any interruption will snap them out of that groove, and it takes time to get back into it. So a “brief interruption” can cost 30 minutes in lost productivity. Is it any wonder I get annoyed by all the crap that Windows and other programs throw at me?

To the designers and programmers responsible for these atrocities: The desktop is my workspace, dang it. Popping your idiotic message on top of it and stealing my keyboard focus is akin to throwing a rotting fish in the middle of my desk. It disrupts my work, makes a mess of things, stinks the whole place up, and ticks me off.

And don’t tell me, “You can turn those notifications off if you want.” That’s exactly the wrong attitude. The default configuration should be to leave me in charge of my desktop. I should have the option of turning those notifications on if I want them. I shouldn’t be forced to go hunting through your overly complicated user interface options dialog box to figure out how to teach your program its place on my desktop.

If, like me, you’re tired of being interrupted by inconsequential messages and having your keyboard focus stolen by rude programs, I suggest you start filing bug reports against the offending applications. That includes Windows, Visual Studio, and any other program that takes the attitude that its status messages are more important than your work. Filing those bug reports is the only way we can get software developers to re-think their attitudes and build software that does its job without nattering at us.

LINQ: I’m a believer

Language-integrated query (LINQ) is a new technology introduced with .NET 3.5. The C# 3.0 language has been extended to support it. LINQ is, in essence, a query language for in-memory data. Think of SQL for your data structures and you get the idea.

Sometimes you have to see a thing in action before you understand just how powerful it is. The other day I had the opportunity to learn that about LINQ.

Suppose you have a Dictionary of inventory items. For example:

class InventoryItem
{
    public string StockNumber {get; private set; }
    public int Count { get; set; }
    public int ReorderThreshold { get; set; }
    // other fields here
}

Dictionary<string,InventoryItem> inventory =
    new Dictionary<string, InventoryItem>();

Now, imagine you want to want to go through the list and select all the items whose Count is less than the ReorderThreshold, and output the list sorted in StockNumber order. The traditional way to do this is to go through the Dictionary one item at a time (using foreach) and create a List of items. Then, sort the list and output. Like this:

// Select items to reorder
List<InventoryItem> reorderList = new List<InventoryItem>();
foreach (var kvp in inventory)
{
    if (kvp.Value.Count <= kvp.Value.ReorderThreshold)
      reorderList.Add(kvp.Value);
}

// sort the list by stock number
reorderList.Sort(delegate(InventoryItem i1, InventoryItem i2)
{
    return i1.StockNumber.CompareTo(i2.StockNumber);
});

// Now output all the items
foreach (var item in reorderList)
{
    OutputItem(item);
}

All that goes away with LINQ. The new way to do things is build a query and let the runtime deal with selection and sorting:

var reorderList =
    from item in inventory
    where item.Count <= item.ReorderThreshold
    orderby item.StockNumber
    select item;

foreach (var item in reorderList)
{
    OutputItem(item);
}

Sure, I understand that I’m not saving any execution time. It’s even possible that the runtime generated code for selecting and sorting is less optimal than what I could write myself. But most of the time I don’t care. In a majority of cases, I won’t even notice a few milliseconds or even seconds in something like this. And it makes the code much easier to write.

I’m definitely a convert. LINQ is cool.

Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.