Friday, March 20, 2009

The Name of the Wind

What a great book! I've not been following the fantasy scene closely, since most fantasy these days is complete dreck. The last good novel I read was Susanna Clarke's Jonathan Strange and Mr. Norrell, and then I happened upon Patrick Rothfuss' work in a rather roundabout way that landed me on this page:

http://www.patrickrothfuss.com/blog/2009/02/concerning-release-of-book-two.html

I found it entertaining, but when I got to "P.S. Your tears are delicious to me", I realised I simply had to read this book.

And wow, what a book. Kvothe is inhumanly good, like Superman, but without being tiresomely superior[*], and seeing the world through his eyes makes him enormously more sympathetic than he might have been in the third person.

The great thing about Rothfuss is the sense of wonder that he manages to capture. I loved the interludes of music the most, far more than the descriptions of "sympathy". Looking back at the book, I can't say I remember any outstanding characters - most of them are two-dimensional compared to the hero - but I did like Master Elodin the Namer.

I read the book in two sittings, maybe around 12-14 hours, and loved almost every minute, and I now get to join the giddy throng waiting for "The Wise Man's Fear."

The waiting sucks, but I can wait. I had to wait years for Stephen King to finish the Dark Tower (that might have been better if left unfinished at say, Wizard and Glass). I'm already nine years older than I was when I read Martin's Game of Thrones, so I think the wait for Wise Man's Fear isn't going to kill me yet.

Recommend: BUY!
The Name of the Wind
Patrick Rothfuss
ISBN 978-0756404079
[*] Batman so totally kicks Superman's ass in the likeability department.

Thursday, March 19, 2009

Truncated date row in AjaxControlToolkit CalendarExtender

Recently I and a friend have been moonlighting building an ASP.NET web site. This was our first time using C#, and my first time doing any real work in Visual Studio.

I'm no Microsoft lover (I ran Visual Studio in a VM on my Linux laptop), but I have to admit Visual Studio is slick. It's light (compared to Eclipse, at least), its autocomplete is great, and the code-deploy-test cycle is gratifyingly quick.

To my surprise, I quite liked C#. Properties, delegates and var foo = new Bar() alone would make it better than Java, but its lambda expressions simply blow Java away. The only catch with lambda expressions that I could see is that you can't declare a Func that returns void (Func). You either have to declare a delegate, or make the poor Func return a junk object just to keep the compiler happy.

One of the things I needed in this web app was to use date choosers. A little Googling suggested that the AjaxControlToolkit's CalendarExtender control was the way to go. It took me a while to figure out how to actually use it in a page after including the assembly reference in the project. This involved:


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>


and then attaching a calendar extender to a date input text field as:


<asp:TextBox ID="SomeDate" runat="server" />
<ajaxToolkit:CalendarExtender ID="SomeDateCalendar"
TargetControlID="SomeDate" runat="server" />


This worked great, right up until I noticed that the date chooser was missing the last row of dates, pretending that every month had 28 days or less. I checked the example project for the date chooser, and the date chooser looked fine there, so I guessed that the AWOL last row involved something in my webapp's CSS. After some mad Googling for a quick fix, and much cursing, I decided to investigate the matter with Firebug, which revealed that the calendar was likely barfing on the extra padding and margins that the page's CSS used for divs and table cells.

For posterity, here's the CSS style I had to add to my page to make the calendar behave correctly:


.ajax__calendar * {
font-family: "Tahoma", "Verdana", "Helvetica", "Sans-Serif";
padding: 0;
margin: 0;
}


(This is probably a bug in the calendar's own CSS - it should certainly reset margins and padding if it doesn't want it.)

Thursday, March 5, 2009

Lagwifi

For a while now, I've been dissatisfied with the performance of my laptop, a Macbook Pro running x86_64 Arch Linux. Everything worked great most of the time, but every now and then, the laptop would go nuts and become horribly unresponsive.

When in this weird condition, the laptop had trouble even keeping up with keyboard and mouse input. I could hold down a key and I'd get "kkkk (long pause) kkkk (long pause) kkkk...". It was so bad I couldn't use the laptop at all once it hit this snag, and I'd usually have to reboot, because I couldn't work out what was causing the problem (no userspace CPU usage, no I/O activity).

Finally, several days back, I accidentally happened on the cause of the problem - my Madwifi wireless drivers. I caught the laptop in the throes of another fit of lag and did an rmmod -f of the ath* modules, and bingo! Input was smooth as silk again. I blacklisted the ath* modules, and I haven't run into the spastic-laptop syndrome since, so I'm reasonably sure that madwifi was the culprit.

Amusingly, I wasn't even _using_ my wireless connection at the time - I prefer cabled ethernet where available.

The question: how do you troubleshoot such problems, in general? I have no good material for a bug report to the madwifi folks and I'm not sure how to go about gathering evidence for this. syslog[*] had nothing to say about madwifi's woes.

[*] I've recently moved to Arch, and it took me a while to figure that /var/log/everything.log had the stuff I might look for in /var/log/syslog on Debian.

Wednesday, February 18, 2009

Dead Mac Fans

The right fan on my Macbook Pro died last week, and my mac promptly went into mourning, moodily switching itself off whenever I asked it to do a long compile session (bad), or watch a long movie (worse). The fan had been making discontented noises for the past few days, so diagnosis was easy - I googled for fan speed tools, found and installed smcFanControl, and it duly identified my right fan (0 rpm) as the slacker.

This Macbook Pro is my primary laptop, and I have no spare. To make matters worse, I'd carelessly forgotten to take the 3 year extended AppleCare protection, which meant the laptop was no longer under warranty. I didn't mind giving the laptop to Apple, but if there is one thing that I've learned about laptop repairmen, it is that they are not in a hurry.

Hand a laptop in for repair, and you can be sure that the job - whatever it is - will take lots of time. First, someone has to "evaluate" the laptop to see what the matter with it is (and telling them "The right fan isn't spinning" will not speed up this process). Once the laptop has been evaluated (after several days have passed, and your patience has worn very thin), somebody will call you up to give you valuable information ("We've examined your laptop very carefully, and discovered that - wait for it - your right fan is dead!"). Then they have to order a replacement part, choosing the cheapest possible shipping option, and after a few weeks have passed, and you have aged a few decades trying to use some other computer to do all your work, you might get your laptop back.

I might have handed in my laptop anyway if it were under warranty, but it wasn't, and I thought I could save a lot of time and money if I ordered a new fan and installed it myself. Or rather, if I ordered a new fan, and got somebody who was good at fixing things to install it. It so happened that I have a good friend who's brilliant at fixing stuff, so I went ahead and ordered a replacement right fan assembly from WeLoveMacs ($59 for the fan, $50 for Fedex International Express shipping). Fedex promised 2-5 days for delivery, but WeLoveMacs took two days to process my order, so it was 5 days before I got hold of the fan. Those were five long days, too. I'd borrowed a Compaq laptop from this same friend, and I found it trying. Its screen was too small, and the keyboard was decked out with stiff, proud, independent keys, disinclined to yield to anything less than sharp hammerblows.

Armed with the shiny new fan, my friend and I disassembled the Macbook Pro. We split the work evenly - he did all the physical work of unscrewing the case and unplugging cables, while I watched and made constructive suggestions ("This is taking frightfully long. Can't you speed it up a bit?") The laptop came apart without incident (we followed the iFixit guide), we removed the old fan and put in the new one. The insides of the laptop were filled with lots of dust - visible heaps of dust around the stalled fan -so we cleaned it up a bit, then closed it up and reassembled the Mac, switched it on, and ... it wouldn't come on.

This surprised and vexed us ("WTFF is going on?!") and we took everything apart again and looked at it, and it was all good. My suspicions centered on the keyboard cable, but we took a sharp look at it, and it looked as blameless a keyboard cable as anyone might want. My friend, having spent some time in thought, suggested that it was probably something quite minor, like a blown logic board.

I looked at the prices for replacement logic boards - iFixit quoted $999 for a replacement (used) logic board. At this point, I wondered whether I should just have given the damn laptop in to the Apple folks to start with, and cursed myself for being a thrice-damned moron.

After some dispirited discussion ("$999? DEAR GAWD!"), we decided to turn in the laptop to the Apple folks for expert review.

As expected, it took two days for the repair folks to "evaluate" the laptop, but, to my enormous relief, they found that the power button was defective and the logic board itself was fine. They had to replace the upper case (Rs. 10000 for the case and Rs 750 for labour, or about $215). Oh, and they found both fans working just fine.

Next time, I think I'll just take that 3 year extended AppleCare.