You're reading Mabsterama, the weblog of Matt Hamilton. Enjoy your stay.
Halfwit
The preview build of my new Twitter client, Halfwit, is now available.
Halfwit was designed to have as few features as possible, to keep the user interface clean and tight. The only feature I truly need is font scaling so I can read the tweets on my notebook monitor. Here’s a screenshot of the main window as it looks right now (click to embiggen):
I haven’t yet gotten a proper “home page” up for Halfwit here at Mad Props, so for now just jump straight to its placeholder install page to grab a copy. Leave me a comment (or a tweet) with any feedback!
A New Hobby Project
A few weeks ago I picked up my new netbook, an HP Mini 311. I almost hesitate to call it a netbook, because it has an 11.6” screen, 2GB of RAM, and runs Windows Home Premium. So it’s more like an ultraportable notebook. Still, it rocks and is a big step up from my five year old Dell D400!
The screen on the HP Mini has a resolution of 1366x768. That means it’s great for watching 720p videos or for running applications that take a lot of screen real-estate, but it also means that the default font size is rather small. Windows has never been very good at scaling font sizes, and while Windows 7 is an improvement, I still don’t like switching to “large fonts”. Something about having the larger fonts in the Window chrome as well as the content just doesn’t gel with me.
So anyway, I’ve been looking at the various Twitter clients that are out there, trying to find one that was simple (not too many features that I won’t use) and supported custom font sizes. The one I like best so far is Sobees Lite (formerly known as bDule), but its user interface is rather “busy”.
So in the spirit of flooding the market, I’ve decided to write my own Twitter client.
The idea is that I’ll steal the layout and some UI from Witty (my favourite Twitter client) but change the feature set. I’ll strip back most of Witty’s features, and add one or two new ones (like custom font scaling, and support for native retweets). Like Witty, this will be a .NET 3.5 WPF project, using Visual C# Express 2010 and TweetSharp. Since it’s a scaled-down version of Witty, I’ve decided to call it Halfwit.
I’ve made good progress on it so far, and hope to have a version I can publish for people to try on the weekend. Stay tuned!
My Week Offline
Friends and colleagues have noticed that I’ve not been online at all this entire week, and I thought I’d share the story behind that in a post.
Last Sunday afternoon I was sitting in the cinema about to watch The Lovely Bones, and all was well. About half an hour into the movie, though, I began to feel cold. Since Sal wasn’t cold, we figured I must’ve been sitting in line with the air conditioner. The theatre was busy enough that we couldn’t really change seats, so I put up with it. As the movie went on, I got colder and colder, and by its end I was physically shivering, teeth chattering, lungs sore from breathing in cold air. It was literally the coldest I had ever felt.
Well, it turns out that it had nothing to do with the cinema. When I got home I was no better. I didn’t stop feeling cold until an hour or two later when the fever kicked in.
Sunday night was sleepless as I wrestled with spikes in body temperature and general pain throughout my body, and of course I resolved not to go to work on Monday, figuring that this was some sort of 24-hour bug and that I’d be good by the next day.
Monday brought new surprises, and I’m sure you’ll forgive me for not going into any more detail than the following two words: Explosive Diarrhea.
Monday night saw me bouncing between the bed and the toilet every 40 minutes or so, so it looked like it was going to be two days off, and a visit to the doctor. The doctor immediately diagnosed it as an infection of campylobacter, which is a common cause of food poisoning. The third case he’d seen that week. He said it takes about five days to pass, and suggested two things in the meantime:
- Codeine
- Sports drinks
Weird, huh? The codeine was for the stomach cramps (which, by this stage, were brutal) and (his words) to “bundle me up” a bit inside. The sports drinks were for rehydration and electrolyte replenishment.
We got straight into the codeine, which worked pretty well, but unfortunately it was not until late Wednesday that I remembered about the sports drinks. I’d been trying, until then, to sip at glasses of water, but by Wednesday arvo I was dangerously dehydrated. I could barely move, and my skin (particularly my lips) was dry and flaky. They say you can last three days without water. I’d been drinking, but not nearly enough. Let me say that when Sal brought home a bottle of Gatorade, it was a revelation. It was like I’d been waiting for that drink since Sunday night.
By Thursday I was starting to come round. I hit the pain killers every four hours, and kept up with the sports drinks.
The doctor had given me a medical certificate through ‘til Thursday, but luckily my boss has given me the ok to work from home on Friday. I’m definitely still in no shape to drive for an hour to get to work, much less sit at a desk for a day.
The big news came last night on the local news on TV: It turns out that It’s not just food poisoning, it’s a salmonella outbreak that has struck the border region! So I’ve just gone through a week with salmonellosis. I can tell you that I lost about 7 kg in three days, and it’s without a doubt the sickest I’ve been since I contracted chicken pox back when I was 21.
The moral of the story: don’t get salmonella poisoning. Apparently local authorities have traced the source back to a retail outlet in town that we ate at on Saturday (Sal was lucky not to pick it up herself). My brother-in-law ended up in hospital on a drip, and I’m sure I could’ve been next to him if we’d gone there rather than to the doctor. What a week!
I Want a “while” Linq Keyword
The other day when I was playing with the coin change code kata, I thought I’d try doing it in the keyword-based “sql” style of linq coding. The hurdle I struck (well, not the only hurdle, but a major one) is that not all of the linq extension methods have keyword equivalents. Case in point, the TakeWhile() extension method.
What I’d like to see in a future version of C# is for the team to hijack the existing “while” keyword and let us use that. So the code would become:
var solution = from c in coins orderby c descending while amount > 0 select new { Coin = c, Number = amount / c, Remainder = (amount %= c) };
Now, this is missing the final “Where” clause from the previous posts (which filters out any coins that don’t apply), but that’s no big deal.
I’m not sure why the C# team didn’t include the “while” keyword in their longhand linq syntax from the get-go. Perhaps it was difficult to parse, or maybe they were concerned about making a query that “looks” set based use an iterative keyword like that. I think it fits right in! How about you?
Code Kata – Coin Change Problem
Remember the old problem you had to tackle when you were first learning to program, where you had to output how many of each coin denomination made up a given value? I thought I’d tackle it using Linq to see how it might look in modern C#.
Here’s my first attempt:
var coins = new[] { 1, 2, 5, 10, 20, 50, 100 }; var amount = 3347; var solution = coins .OrderByDescending(c => c) .TakeWhile(_ => amount > 0) .Select(c => new { Coin = c, Number = amount / c, Remainder = (amount %= c) }) .Where(i => i.Number > 0); foreach (var i in solution) { Console.WriteLine("{0} x {1}c", i.Number, i.Coin); }
This uses OrderByDescending so that the coins don’t need to be defined in any particular order, and reduces the “amount” each time inside the assignment to the “Remainder” property.
What do you think? It’s interesting, tackling these age-old problems with fresh approaches. If you search for “code kata” you’ll find many people writing modern code to do things like finding prime numbers etc. I haven’t seen this particular problem being attacked (perhaps because it’s so simple). If you have a better way to do it, let me know in a comment or a post of your own.
New PC Details
So here are the final specs of my new PC. They don’t match the original specs because some parts turned out to have a long wait on them, and I was happy to replace them with in-stock parts of a similar ilk.
CPU: Intel Core i7 920
Motherboard Gigabyte GA-X58A-UD7
RAM: Corsair 6GB Kit (3x2GB)
Video: PowerColor Radeon HD5770
HDD1: Western Digital 150GB, VelociRaptor
HDD2: Western Digital 1TB, Caviar Green
DVD: Pioneer DVR-218LBK
Case: Antec P183 Performance One
PSU: Cooler Master RS650-PCARE3
TV Tuner: Compro VideoMate Vista E700
… and the whole thing’s running Microsoft Windows 7 Home Premium x64.
Here’s a screenshot of my Windows Experience Index. I’m not sure why my “Aero” graphics performance index is so low when the gaming graphics index is so high, but I do know that the hard drive index would be much higher if I was running a solid state disk, which is an upgrade I intend on doing this year some time:

And finally, just for kicks, here’s a screen clipping of my task manager. I love seeing eight CPU graphs! :)

The Case of the Corrupt New Tab Page
Hello from my new PC! I wanted to write a blog post documenting the discovering and successful fix of a very strange problem I had right from the get-go with this installation of Windows Home Premium x64.
When I first plugged in my new PC and booted it up, it started in the “finalize Windows setup” stage; allowing me to create a first, administrative user and customize locale etc. I proceeded through the final steps of Windows Setup and eventually logged in for the first time.
Naturally one of the first things I did was open IE to check that my Internet connection was working ok. It was, and I did a bit of casual browsing. Inevitably I clicked the “New Tab” button to open a new tab, and was greeted with this monstrosity (click to embiggen):
WTF??? The “New Tab” page in IE8 was totally corrupt. Not only was it not showing me my recently closed tabs, it was populated with garbage characters at the bottom of the page!
After a few fruitless searches for help, I posted on Super User (as well as a few other places, like the IE8 newsgroup). You can read all my updates on the Super User post, but eventually it came down to running a little command-line utility called sfc.
I dropped into an administrative cmd prompt and ran “sfc /scannow”. SFC reported that it had found errors, and pointed me at a log file. Inside the log file I discovered that a file called “ieframe.dll.mui” had failed its hash check, meaning it was corrupt in some way.
It turns out that “ieframe.dll.mui”, which lives in “C:\Windows\SysWOW64\en-us”, contains the English localization of the “new tab” page in IE8. No big surprise there!
After a few more searches I learned that you can run sfc from the Windows install DVD, and I had an unopened copy of the DVD that had come with my PC. I cracked it open, booted from it, and dropped to a command prompt to run the tool. Unfortunately it simply doesn’t work. No matter how many times I rebooted, it kept telling me that there was a “system repair pending” and that it couldn’t run.
Eventually I decided to take matters into my own hands. Using Windows Live Sync, I download ieframe.dll.mui from work PC (which also runs Windows 7 x64, and has a perfectly functional “new tab” page). I then dropped to my admin cmd prompt, and typed the following:
cd \Windows\SysWOW64\en-us takeown /f ieframe.dll.mui icacls ieframe.dll.mui /grant Administrators:F ren ieframe.dll.mui ieframe.dll.mui.old copy %USERPROFILE%\Downloads\ieframe.dll.mui .
So I have taken ownership of the file and granted all Administrators full access to it, then renamed it and copied down my correct version.
I’m pleased to announce that my PC now works perfectly. I’ll post some more details about it (including a screenshot of its impressive Windows Experience Index) later!
Xmas Haul 2009
That time again! Time for Mabster’s Christmas Haul! A day late this year because yesterday was a bit hectic, with several different family events to host and travel to.
I’m fairly certain that the haul is getting a little smaller each year as I become more difficult to buy for. That doesn’t diminish the spirit in any way! This year was as good a Christmas as any! To the haul!
From Sal
Battlestar Galactica season 4 part 1 DVD
Battlestar Galactica season 4 part 2 DVD
Dave Matthews Band - Big Whiskey and the GrooGrux King CD
Fallout 3 GoTY Edition for Xbox 360
Diesel “Only the Brave” gift set
... and some clothes, including some tee-shirts and work shirts, and a night shirt so I can pretend to be Wee Willie Winkie (all I need now is the matching hat)!
From the Family
We got a whole bunch of movie tickets from various family members, which we will put to good use over the coming year. From Sal’s mum and dad we received a couple of nice fake plants and some pots to display them in, as well as a work shirt for me.
Mum and dad this year gave us a voucher for the Colonial Tramcar Restaurant in Melbourne. The food looks good, so we’ll have to book in a night for that ASAP.
I also scored quite a bit of food, including my favourite Christmas fare, shortbread.
The Aftermath
Now begins the Boxing Day shopping! Sal gets to spend the gift vouchers I included with her haul, and I get to see if there’s anything waiting out there for me that I didn’t get! :)
Hope you had a great Christmas in 2009! Leave me a comment with your own haul (or better yet, a link to your own Xmas Haul blog post)!
A New PC for 2010
Today I finally ordered a PC to replace my nearly-five-year-old desktop/media centre machine at home. I’ve ordered this one from Scorpion Technology, a Melbourne-based group with two physical stores and an impressive online system.
Here’s the spec:
- Intel Core i7 920 CPU
- Gigabyte GA-X58A-UD7 motherboard
- Corsair 6GB Kit (3x2GB) RAM
- Gigabyte Radeon HD5770 video card
- Western Digital 150GB, VelociRaptor HDD for C drive
- Western Digital 1TB, Caviar Green for D drive
- Pioneer 218LBK DVD writer
- Antec P183 Performance One case
- Corsair 650W TX-650 ATX Power Supply
- Compro E700 Dual DVB-T TV PCI Express TV tuner
- Windows 7 Home Premium 64bit
All told it comes to just under $2500, which is my usual budget for a PC since they typically last me a long time. I’m really looking forward to playing with this PC! Should be a great media centre and a great Comicster development box!
foreach Over Multidimensional Arrays
Think fast! What will this code print?
int[,] nums = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; foreach (var num in nums) { Console.WriteLine(num); }
If you’re like me, you probably thought you’d see this output:
System.Int32[] System.Int32[] System.Int32[]
That is, you figure that the “foreach” will iterate over the array of arrays, and try to print out each array.
I can tell you now that that’s not the case. If you compile the code and run it, you’ll find it prints this:
1 2 3 4 5 6
WTF? Iterating over an array of arrays actually flattened the array for me? Why yes, yes it did! Have a look at this article from the MSDN C# Programming Guide called Using foreach with Arrays. When you iterate over a multidimensional array, you get each element of the array rather than each “row”.
I figured I’d try something else after discovering this, and wrote this piece of code:
int[,] nums = { { 1, 2 }, { 3, 4 }, { 5, 6 } }; for (int i = 0; i < nums.Length; i++) { for (int j = 0; j < nums[i].Length; j++) { Console.WriteLine(nums[i, j]); } }
Surely that’s reasonable? A nested “for” loop over my multidimensional array? Guess what? It doesn’t even compile! You get this error on the “nums[i]” line:
Wrong number of indices inside []; expected '2'
So it turns out that multidimensional arrays in C# are not the same as arrays of arrays (also called jagged arrays because each element of the array might be an array of any size). The compiler treats these two objects very differently:
int[,] array1; int[][] arrays2;
I’d love to hear from a C# guru on this one. I guess I just don’t use arrays enough to have known this, preferring instead to use generic collections and the like.


The Prestige blu-ray