Archive for 2006

Updated Collapsible Amazon

Just a quick heads up that I’ve uploaded a new version of Collapsible Amazon. It’s a Greasemonkey script that lets you collapse any section of the standard Amazon detail page. This update makes it work on a lot more sections - the only one it can’t collapse that I’ve found is the Customer Discussions section. Basically, wherever you see an orange header, you can click it and its content will disappear - and the script will remember that you want that type of section collapsed everywhere.

An Example Screenshot of Collapsible Amazon

Honestly, I’m no fan of Jane Austen - I was just looking for a screenshot! If you like this script, you should check out some of my other Greasemonkey scripts.

Creating nested custom configuration sections in ASP.NET 2.0


This weekend I decided to go through the hodgepodge of common code that’s shared between a lot of my ASP.NET websites and refactor it a bit. I’d only just learned about the magic of HttpModules and HttpHandlers, and I immediately saw a lot of canidates in my copy-paste code and global.asax handlers where a HttpModule would be a better solution. One of these was the code I was using to redirect old pages to new pages whenever I moved them. For example, at some point I had moved to, and I wanted anyone who visited the old URL to get redirected to the new one. Previously, I just had some code in global.asax that hooked Application_OnError, checked to see if it was an HttpException (a 404 file not found, specifically), and then redirected if it knew where the file really was. Pretty simple, but not very general. So I broke it out into an HttpModule that basically did the same thing, but no longer required me to cut and paste code into my global.asax. However, one improvement I wanted to make was to allow for configuration through my web.config file, instead of having to hardcode an if/else tree for each redirect. I basically wanted to have a section in my web.config like this:

    <sectionGroup name="brh.web">
       type="Brh.Web.RedirectConfigurationHandler, Brh.Web.Utility"

      <redirect filePattern="tools.aspx" url="~/tools/" />
    <redirect filePattern="strategy.aspx" url="~/strategy/" />
    <redirect filePattern="military_people.aspx" url="~/people/" />
    <redirect filePattern="history.aspx" url="~/history/" />
    <redirect filePattern="teacher.aspx" url="~/teacher/" />

To do this, I needed to create a custom configuration handler. There’s plenty of documentation out there on how to create a single-tag configuration handler using the new ConfigurationSectionHandler class, and all of the sites I could find talked about how much easier it was to do things the new .NET 2.0 way instead of using IConfigurationSectionHandler. However, nothing I could find would tell me how to make a config section with sub-elements. It’s certainly easy to decorate a property with the ConfigurationProperty attribute, but setting up the collection of subelements is significantly harder. Finally, after chancing upon a forum post, I was able to hack together something that worked:

using System;
using System.Collections.Generic;
using System.Text;
using System.Configuration;

namespace Brh.Web
    class RedirectConfigurationHandler : ConfigurationSection
        [ConfigurationProperty("", IsDefaultCollection=true, IsKey=false, IsRequired=true)]
        public RedirectCollection Redirects
                return base[""] as RedirectCollection;

                base[""] = value;

    class RedirectCollection : ConfigurationElementCollection

        protected override ConfigurationElement CreateNewElement()
            return new RedirectElement();

        protected override object GetElementKey(ConfigurationElement element)
            return ((RedirectElement)element).FilePattern;

        protected override string ElementName
                return "redirect";

        protected override bool IsElementName(string elementName)
            return !String.IsNullOrEmpty(elementName) && elementName == "redirect";

        public override ConfigurationElementCollectionType CollectionType
                return ConfigurationElementCollectionType.BasicMap;

        public RedirectElement this[int index] {
                return base.BaseGet(index) as RedirectElement;

    class RedirectElement : ConfigurationElement
        [ConfigurationProperty("filePattern", IsRequired=true, IsKey=true)]
        public string FilePattern
            get { return base["filePattern"] as string; }
            set { base["filePattern"] = value; }

        [ConfigurationProperty("url", IsRequired=true, IsKey=false)]
        public string RedirectUrl
            get { return base["url"] as string; }
            set { base["url"] = value; }

The important parts here are that I overrode the CollectionType on RedirectCollection, which allows me to use a simple mapping instead of the more complex add/remove/clear pattern that the new Configuration API selects by default. Also, I overrode the parts about the element name, so that it would recognize a series of “redirect” tags as my collection. The last bit that hung me up for a long time was that my ConfigurationElement, RedirectElement, needs to store its data in the base property collection. I had been storing them as properties, thinking that the configuration framework would populate them via reflection, but all that got me was a “Invalid key value” error, since the collection was exposing RedirectElement.FilePattern as the “key” (whatever that means) and it was null. I still don’t really understand all the craziness about this new configuration system, but at least I got it working. I wish there was better documentation out there (or at least better error messages). In general I think this is way too complex a way to go about handling configuration - I’ll stick with simply serializing/unserializing a custom settings object in my Windows apps.

One last bit: to use this in your app, simply do this:

RedirectConfigurationHandler config = (RedirectConfigurationHandler)System.Configuration.ConfigurationManager.GetSection("brh.web/redirectOldUrls");

Now you have a strongly typed config object that you can use to read your settings.



It seems these days that everyone has a blog (or two). There are big news blogs, little blogs with useful articles (such as the many C# blogs I read), the countless teenagers with MySpace or livejournal blogs. There are blogs about tech, politics, clothing… there are even blogs about blogging! Even I have been sucked into the blogging scene. Even my Xbox 360 has a blog. So why shouldn’t my hedgehog have a blog?

On the Wheel
So that’s what I did. Right after we got Pliny and got him set up with a nice cage and a big wheel, I started thinking about how I could get him to blog. I thought about teaching him how to type and operate Wordpress, but as cute as he is, he’s not very smart. So I took the technological route. I built a little sensor out of a magnet and a reed switch and attached it to his wheel. After about 4 months of on-off (mostly off) C# coding, I had a client built up that would poll the sensor, log Pliny’s wheel activity, and post to his blog. The Hogblog was born! It posts his activity, along with charts and occasionally a pic from Flickr. It’s all automatic, and I’m subscribed to his RSS feed to find out just how much running he’s been doing while I was asleep. It’s already brought up some interesting information. For two days his wheel was stuck - the little log he sleeps in was jammed up against it. In the two days since he’s run almost half a mile!

This has been a really fun project that has tied together a lot of fun aspects - playing with physical elements like the sensor, coding in C# (and interacting with the parallel port to get the stats!), and making web services calls to Wordpress and Flickr. I’m already thinking up more ways to improve his blog, but for now I’m going to sit back and watch for a bit!

How to save power from your gaming devices

A few weeks ago I watched the Al Gore slideshow-in-a-theater “An Inconvenient Truth”. Al Gore parts aside, I thought it was very good, and while it didn’t tell me much I didn’t already know, it did make me think about my power usage. In general, I hate waste - wasted money, wasted time, wasted material, wasted code. Wasting energy is just as bad. This is sort of at odds with my tech-heavy lifestyle, though. I realized that my entertainment center probably wastes a lot of energy while I’m sleeping, what with the TV, the stereo, the powered subwoofer, the Xbox 360, the PS2, the Xbox, and who knows what else casually sipping electricity just to stay in “standby” mode. I don’t know what standby mode does, but I don’t think it’s worth having power flowing into those devices for the 18-odd hours I’m not using them each day. So I went to Target and bought a remote switch - the one I got cost less than $25 and included two remote switches that are controllable by one remote. All I needed to do was put this between the wall outlet and my power strip, and now I can just push a button on a remote when I go to bed to save energy. The other switch now controls the lamp over in the corner. It’s perfect. And I bet within a year I’ll have saved enough on my electricity bill to pay off the switch. In that time I’ll be using just that much less electricity, saving that much carbon dioxide, and sparing my equipment that much wear and tear. Seems like a win overall.

Passport changes screw up XBList 2.2

I’m still working on XBList 3.0 (though not as much as I’d like, between work and a social life). However, I noticed today that XBList won’t auto-signin to Passport anymore. Bummer. It has to do with the new ID stuff. I promise this will be fixed in XBList 3.0, but in the meantime, you can just fire up Internet Explorer, log in to, and XBList will start working again.

Status Update on XBList 3.0

So an update on how things are going with the next version of XBList. I’ve gotten a few questions about when I’ll support the new ability to do messaging between and Xbox 360, and I put out a bunch of questions in my last post, talking about how much overhaul to do to XBList. Well, I’m going full in. I’ve already done a lot of work on it, and there’s a lot to be done. I think the end result will be a cleaner, faster, prettier XBList. The bad news is that this is going to take time. The worse news is that I’ve gotten distracted with other projects, and other things (like Burnout Revenge, and enjoying the beautiful Northwest). It’s just been hard to sit down and crack open Visual Studio these days. I do expect to have a nice new version of XBList out before too much longer, however.

Why don't more games get online multiplayer right?

It should be no surprise to people who have looked over, or who know me even in passing, that I love Halo 2. The game is a lot of fun, and was obviously built with a lot of care. However, I’m always on the lookout for a good online game, especially one for the Xbox 360, since I really like what Microsoft has done with Live on their next-gen platform. However, no matter what game I’ve played, I’ve been disappointed. Halo 2’s approach to multiplayer has essentially spoiled me to all lesser implementations. From here on out, I expect three things from Live-enabled games. These three things have so far been present only in Halo 2:

  1. Matchmaking Parties
  2. Playlist Matchmaking
  3. Split Screen over Live
Matchmaking parties are a group of friends, who get together online to move through the matchmaking system as a unit. For example, me and three of my buddies can get together and join the Team Skirmish playlist in Halo 2. We’ll always be in the game together, no matter who else gets matched with us. This means we get to play 8-player matches, but we don’t need to set up a custom match. As a result, we get into matches quickly, and enjoy all the benefits of playlist matching. In contrast, while The Outfit allows me to play 2 on 2 and 3 on 3 team matches, it doesn’t allow me to enter the quick matchmaking with a friend as my teammate! This brings the likelyhood of me playing a team game down to about 0.

Playlist matchmaking was a feature of Halo 2 that actually received a lot of scorn early after the release of the game. The old way of getting a match going (and still the default way for many games) was to create a room, select the options, wait for people to join your room, wait for everybody to get ready, then play. With this strategy, getting a game together took a while, you have to make decisions about gametypes or maps or options, and you’re not very likely to switch things up between rounds, or play with different people. In Halo 2 (and some newer games) you simply select a playlist that contains the general type of games you want to play. A random, preconfigured game gets chosen from the playlist, you get matched with other people wanting to play that playlist, and you’re off. Combined with matchmaking parties, this means more time in the game, more variety, and a more diverse group of opponents.

Split screen over Live is one of those features that for the life of me I can’t understand why it isn’t default everywhere. In Halo 2, or Crimson Skies, or a small handful of other games, you can have two or more people connected to your console, on your TV, while you are online playing with other people. This means, for example, that me and my girlfriend can both play Halo 2 online with our friends back East simultaneously. Amazingly, this capability is rare in Live games. X-Men Legends 2, the online successor to a great party game, allows only one person online at once, even though it doesn’t even need to split the screen for multiple people. Burnout Revenge is the same way. The game has split screen multiplayer, and online multiplayer, but never the two shall meet. Perhaps it’s a good assumption that most gamers only play games by themselves, but I would imagine a situation where the Xbox is shared between members of a household is pretty common.

The lack of any one of these three features basically kills an online game for me. And I really can’t understand it - most game developers must have played Halo 2. Why can’t they just rip off these ideas? Why aren’t these features part of the Microsoft livensing guidelines? Can it really be that the designers of a great game like The Outfit, which is really a multiplayer-only game, never tried to play their game online with friends?

Here’s hoping the next generation of games truly understands online multiplayer the way Bungie does. And here’s hoping Bungie comes up with 3 new indispensable features for Halo 3.

Thinking about the next XBList

Well, the new Live update is out. It mostly introduces a Message Center for, where you can send and recieve messages just like on your Xbox. Of course, I’m already thinking about how best to integrate this into XBList, which is starting to see some strain from all the features I’ve added to it. Actually, it’s still pretty lean, but it’s more complicated now than I had ever intended.

I have two choices now. I can do what I usually do, and stay up all night cranking out a quick implementation of Message Center integration. You’ll be able to see how many messages you have from each friend, and send them messages and whatnot. Not exactly Adium level messaging, but it would get the job done. The other option is to go straight to XBList 3.0. By that I mean a bunch of new features, and a rewrite for a lot of the older stuff. Here are some of my ideas:

  • Message Center integration, as I mentioned
  • A new friends list display that’s not based on TreeView, which could be prettier and also include larger icons, gamer points, etc.
  • Remove the IE control from the system, or at least everything but the gamertile popup. I’ll get back to this one later.
  • Upgrade to the .NET Framework 2.0
  • Plugin support, so people could write their own providers for pictures or other neat things.
Those last three require more explanation. Removing the IE ActiveX control would be the biggest change. If I can remove it completely (the Gamer Tile popup uses it to draw the tile, and it would be a bit of work to draw it by hand), the XBList download will be smaller and the program will take a lot less memory. Even if I can’t get rid of it completely, removing it in favor of a custom approach would mean XBList would be faster, more stable, and less prone to throwing up weird dialog boxes or making clicking sounds. In general, I think it would make the program much nicer. The down side is that I’d have to start prompting for your Passport login/password from XBList. While I know that I’m not going to take advantage of your info, or even store it anywhere, it’s a lot easier to convince people if they get to sign into from IE instead of entering their info into some random, possibly untrustworthy program. I’ve resisted this in the past, but I’d like to know what people think about the idea of switching to an XBList login dialog, maybe with some clear text that promises no harm will come to your information.

Upgrading to .NET 2.0 is mainly a perk for me. It would make XBList run faster, and would make it easier to develop, since I could use Visual Studio 2005. In addition, I could use the new managed WebBrowser control instead of Torsten Rendelmann’s excellent but undocumented IEControl wrapper. I could also use things like the new BackgroundWorker control to improve the admittedly shaky multithreading in XBList. The downside here is that you’d need the .NET Framework 2.0 installed. I hate to force people to download yet another thing, though I suspect most people will already have it by now.

The last one, plugin support, has been a pipe dream of mine since XBList 1.0. It could be used to support things like, who could create a plugin to use your real photo instead of your gamer picture. This one is pretty open-ended, and I’d like to see more ideas of what sort of plugins people would want before I commit to putting a complicated infrastructure in place.

So, if you’re reading this, what I’d love is if you’d post in the comments here, or in my forums, what you think about these ideas. I’ll go back to trying to beat my high score in Geometry Wars until the comments start flooding in…

Windows Vista leads me to the Mac


I’ve been meaning to write about my impressions of the various Windows Vista previews since I first tried it out in January. My thoughts (and my feedback to Microsoft’s beta site) have been piling up since then, but I never got around to putting virtual pen to even more virtual paper. However, Paul Thurrott’s recent article on where Vista fails really sums up a lot of my feelings here. Thurrott’s always been the type who’ll try his hardest to find the positive in even the worst Microsoft releases, but as a long time reader, I can tell that he’s very, very frustrated with Vista, and as a Windows journalist it really pains him to see something that promised so much deliver so little. He’s not alone. I’ve tried my hardest to like what I’ve seen of Vista so far, but it’s nearly impossible, especially when Mac OS X is out right now, and in many respects better than Microsoft’s late update to XP.

This is going to be a pretty long rant, so if you want more you’ll have to click inside.

I’ve been assured that under the hood, Vista is a vast improvement over XP. Rewritten kernel, better network, revamped graphics, etc. The problem is that nobody really cares. Even for the hardest of the hardcore, Vista’s myriad annoyances, design snafus, and general clutter are what’s going to make the biggest impression. For example, UAP (User Account Protection), is at best infuriating, and at worse useless as users quickly learn to ignore (or disable completely). Even within an hour of using the Vista previews I’m about to tear my hair out at the frustration of having to click away three and four dialogs just to install an ActiveX control. While UAP is the most egregious of the user experience blunders, it isn’t the only one. As Thurrott points out, the “Aero glass” look is terrible, and confusing. Even Apple has backed away from their overused candy bubbles and transparent menus, settling on a more mature, restrained look for OS 10.4 Tiger. Aero glass just looks amateurish, though I wouldn’t know firsthand - I’m stuck with the “Scrap Metal” theme on my laptop, which is a step down from the very pretty Royale theme for XP. And don’t get me started on the new Media Center - even for a company with a reputation for screwing up their branding, the new Media Center is bad. I liked the old blue/green look of Media Center, and the new dreary color scheme doesn’t hold a candle to the Xbox 360 Dashboard. While we’re at it, the new Windows Explorer interface is godawful - it’s so full of differently-colored bars and panels and buttons that it’s almost impossible to look directly at it.

Vista's Windows Explorer

What I don’t understand is why they’re working on making file browsing more complicated when there are some existing scenarios that need a lot of improvement. Installing and uninstalling programs still sucks, and it isn’t improved much in Vista. Installing and uninstalling applications is a pretty basic PC function. Why not focus some development time on making installs/uninstalls one-click (or one-drag, in the style of Mac OS X)? Why not let Windows handle checking for and applying updates to applications, instead of the hodgepodge of custom update schemes. That’s not the sort of thing that should be left to individual applications to handle. Will this be another area where we’ll have to rely on third-party applications to perform a basic function of the desktop environment? Or what about notifications? That’s another thing developers have to roll on their own. I remember when this was even rumored to be a part of the Windows Sidebar concept. Mac OS X users have Growl, which not only provides good-looking notifications, it gives the user control over when and how they’re notified. I’m surprised Apple hasn’t built this into OS X yet - it’s certainly miles above the Navi-style bouncing dock icons. Or maybe we should focus on little things - it’d be worth my $200 just to have keyboard shortcuts everywhere - especially for creating a new folder.

And that isn’t all Vista is missing. WinFS is out. The Monad shell, while promising, won’t be mature when Vista launches. Virtual Folders have been abandoned. Virus scanning is AWOL. Basically all we’re getting is Windows XP with Microsoft’s idea of a shinier shell, and fixed file search (OK, and the cool new RSS engine, but that’s coming out for XP too). Even more disappointing, it looks like Vista won’t launch with WPF (formerly Avalon) or WCF (formerly Indigo) right out of the box. That means that when other people get around to using these cool technologies to make real next-generation apps, they’ll have to get their users to download a whole bunch of stuff just to get the experience that Vista was supposed to be synonymous with.

So after a long wait, I’m ready to give up on Vista. It’s just impossible to stay excited about it, especially when Mac OS X Tiger is out right now. Some history: I’ve never been a fan of the Macintosh. However, ever since OS X debuted, with its slick UI, UNIX backend, and total disrespect for legacy applications, I’ve been intrigued. But Apple’s smug marketing and zealous acolytes have kept me from really trying OSX, and honestly, I grew up building PCs and configuring Windows - the Mac seems more like a consumer electronics device than a real computer. Having a sealed box that “just works” seems like easy mode. That said, the 5-year-old Athlon T-Bird box I built for college is still humming along just fine. My plan was to upgrade when Vista shipped, but even as Vista’s release date has gotten pushed back, my trusty PC has failed to become obsolete. Being a tech geek, I still want a reason to get a new computer, though. The Mac Mini seems to fit my bill. I get a well, designed modern OS with all the “comforts” of a UNIX command line. The only software tying me to Windows at all is Visual Studio and .NET (sad, really, that I need to keep Windows around just to develop Windows apps, but .NET is just so much fun). So I think I’m going to hop over to Amazon and pick up a Mac Mini. Who knows, maybe I’ll switch. If I do, it won’t because of Apple’s advertising or gorgeous product design. It’ll be because Microsoft seriously dropped the ball.

Apple Finally Speaks to Me with BootCamp

The big news out of Cupertino this morning is BootCamp. It’s Apple’s beta bootloader for Windows on their previously-closed Mac platform. Now you can dual-boot Mac OSX and Windows XP, complete with drivers for the important bits of the system.

Win Mini
Putting aside why this is a great move for Apple, this really puts the company in a new light for me. I’ve never liked Apple’s marketing - they’ve always seemed more like a cold white plastic monolith than a warm fuzzy people company to me. To me the Mac, and Apple, is about lack of choice. They give you something, and that’s what you get. It’s good, but things are going to be their way or no way at all. I tend to think a lot of their growing success lies with the fact that their defaults (a stock OSX install and standard Mac hardware) are fantastic, while the default install of Windows or Linux (and the standard OEM boxes) are rather dismal. While this makes a Mac great for most people, I’ve never really cared. I can make Windows do what I want, and aside from my Thinkpad I’ve never bought a computer that was pre-assembled in a factory.

The first thing Apple did that made Macs interesting to me was embracing UNIX with OSX. That was not the sort of decision I expected from a company that had made previously shipped operating systems that show you frowny-faces on error. The fact that the Mac now had a command line suggested that it wasn’t just for playing that sliding-puzzle game anymore. Since then I’ve had a little bit of interest in the Mac, and I even have a rescued-from-the-garbage 350Mhz iMac that I test Safari on. The OS is interesting, but the hardware lockin has always stayed my had mere moments from the “Place Order” button at the Apple Store. Recently I’ve become enamoured of the Mac Mini, whose diminuative size makes it seem more like buying a toy than a computer. Coupled with the fact that it’s the cheapest Mac that comes without a built in display, it seems like the best choice for my tinkering, though the price hike for the new Intel models makes me wish for some additional customization options - do I really need to pay for Airport Express when it’ll be sitting 5 inches away from an ethernet switch?

Today’s introduction of BootCamp really got me though. All of a sudden the guys at Apple HQ are speaking directly to me - they’re letting me make a choice! Not just any choice, but the choice to run software from their sworn enemy, Microsoft, on their pristine white hardware. This from the iTunes company! It’s not really a choice, of course. I wouldn’t dream of putting XP on a Mac Mini when I could build a cheap PC for half the price. It’ll be nice for people who want a great laptop but can’t give up Windows. But for me it’s the fact that they’re opening up and letting me do something as radical as replace the operating system. I feel now that if I were to buy a Mini, I’d be getting it from Apple, a company full of cool engineers with good design sense, not Apple, a company full of snobby elitists who know what’s best for me.