Miscellany

Random things that defy categorisation

12
Apr

Trying out speech recognition in Windows Vista

Over the past few months I’ve been rather intrigued by some of the reports that I’ve read about Windows Vista speech recognition.  For example, Scott Hanselman claims an increase in speed from approximately 72 words per minute when typing to about 125 words per minute with voice recognition—an improvement of approximately 75%.

Now Hanselman works for Microsoft, so it is only natural that he would give something to do with Windows Vista a glowing report, and let’s face it, a typing test is actually a very artificial way of trying out this kind of thing—you’re not chopping and changing all the time but reading verbatim off the screen.  Other people are less complimentary.  Microsoft’s ill fated demonstration of Vista’s speech recognition went down in history, with the immortal phrase “Dear aunt, let’s set so double the killer delete select all” appearing on the evening news and geek T-shirts.

I haven’t actually used Windows Vista that much until recently.  My old laptop only had Windows XP on it, and I use Windows Server 2003 at work.  However, a couple of weeks ago I got a new laptop, complete with Windows Vista, so I thought I might as well put it through its paces, and so today, I’ve been trying it out.  I’ve set myself the goal of writing a complete blog entry without using the keyboard or the mouse: opening Windows Live Writer, navigating Firefox and Google Reader, finding other pages that I want to reference, and inserting hyperlinks, using speech alone.

My experience so far has been more along the lines of the ill fated demonstration than Hanselman’s glowing report, but to be fair, it’s still early days.  Initially it was painfully awkward, and after a few hours it’s still pretty clunky, but it does seem to be learning from its mistakes and it does get it right about 80% of the time.  The problem is that the 20 per cent of the time when it doesn’t get it right, or when you want to chop and change things, it is very slow and fiddly.  Some things don’t even work: “show numbers” doesn’t show numbers correctly for hyperlinks on Ajax enabled sites in Firefox, and your blog’s category names don’t appear in the “categories” drop down list in Windows Live Writer.

Yes, it’s more comfortable than using the keyboard, but it does take a lot longer, and thoughts only trickle from your brain into your document rather than flowing.  It is also pretty frustrating if you keep chopping and changing things, as I do when I’m writing. Perhaps if I persevere at it I might find it improves, but I don’t think we’re going to be dispensing with our keyboards anytime soon. 

10
Apr

Windows upgrades break Media Player 6.4

One of the systems that we have developed serves up WMA files dynamically and plays them in an embedded Windows Media Player. Because this system has been around for a few years now, it still uses the old classID for Windows Media Player 6.4 rather than the newer one for versions 7-11. That was all very well: this works fine with the later versions, it doesn’t have to do anything particularly fancy, and besides, it did the job admirably well.

Until Microsoft rolled out their latest set of Windows updates this week, that is. All of a sudden, users were reporting that Internet Explorer was crashing all over the place. However, if they rolled back to IE6, everything worked fine.

It turned out that we were serving up some of our sound files with a content type of “application/octet-stream” rather than with the expected “audio/x-ms-wma”. This was fair enough: Postel’s Law says that you should be liberal in what you accept, but conservative in what you do. So even if we weren’t getting it quite right, Windows Media Player was forgiving us.

Unfortunately, on Patch Tuesday, Postel’s Law went out the window at Microsoft’s end as well as ours. And rather rudely, to boot. No “invalid content type” messages or anything: Internet Explorer would just freeze.

To fix the problem, you need to do one of the following (preferably all three, despite the fact that there may be certain logistical issues with the third):

  1. Make sure you are serving up the correct MIME type with your media files. For WMA audio files it should be “audio/x-ms-wma”. For other media types see here.
  2. Change your web pages to use the newer class ID for Windows Media Player. It should be 6BF52A52-394A-11D3-B153-00C04F79FAA6 rather than 22D6F312-B0F6-11D0-94AB-0080C74C7E95. Note that some properties change names between versions: in particular, you use “url” rather than “src” in the later version.
  3. Tell your users to jettison Internet Explorer altogether and switch to Firefox or Safari.

Talking of point 3: can someone please explain why the Windows Media Player Firefox Plugin doesn’t install on Windows Server 2003? Windows Server 2003 is just supposed to be Windows XP on steroids with a bunch of configuration tweaks and extra bells and whistles and an inflated price tag, surely? Or is there some genuine good technical reason for this seemingly inexplicable design decision?

07
Feb

恭喜发财, now give me some Unicode

Since it is the Chinese New Year, I thought I would say 恭喜发财 to all my Chinese readers and entertain you with a little tidbit of information about C# that you may not be aware of.

You would undoubtedly expect this code to compile correctly:

string HappyNewYear = "恭喜发财";

However, did you know that this will compile correctly as well?

string 恭喜发财 = "Happy New Year";

As an explanation: If the Unicode standard considers something to be a letter, C# allows it in identifiers. This means that Chinese ideographs are all fair game. Unfortunately, however, this is likely to make you rather unpopular in code reviews with any of your co-workers who can’t read Chinese.

Incidentally, 恭喜发财 (pronounced “gong xi fett choi”) translates approximately as “Live long and prosper.” If you are a Trekkie, remember to give a Vulcan salute when you say it.

04
Feb

Seventy-one

I surpassed 70 words per minute on Colemak for the first time today. I have now all but abandoned qwerty…

(For those of you who are getting bored with me being a noisy Colemak fanboy, this will be the last of it round here — promise. I’ve started up a separate blog for that.)

03
Feb

Published

My blog entry on Volta, GWT and leaky abstractions has been reproduced in the .NET Developers’ Journal.

This was a particularly interesting post because a lot of people are pretty impressed with Volta, and on the face of it, I was pointing out what I saw as its potential shortcomings. It has also attracted some comments from fairly accomplished developers — Bruce Johnson of Google’s GWT team, and Mats Helander, who wrote one of the first O/R mappers for the .net framework. However, while I may have come across a bit negatively, my opinion is not actually so much an anti-Volta/GWT/RJS one as a pro-JavaScript one. Since I started taking JavaScript seriously a year or so ago, I’ve really started to appreciate it, and to be honest, I think that developers who hide from it altogether behind abstraction layers of whatever nature are really losing out.

I’ve also had an e-mail from a journalist asking me for my opinion on MySpace for an article that she’s writing. I’m not sure I’m the best person to ask on that one to be honest: my experience of MySpace is pretty much limited to opening an account, discovering it doesn’t work with Windows Live Writer, closing it again, getting spammed, and experiencing all the yuk-that-is-gross reactions that any respectable, standards compliant, XHTML addicted web developer experiences on seeing your average profile page with gratuitous background images, animated GIFs, thrash metal background music, and broken rendering in Firefox.

It’s interesting where blogging can take you…

11
Jan

On Colemak

Over the past week or so I’ve been trying out the Colemak keyboard layout again. I’ve been a bit ambivalent about it up to now, partly because I found some Colemak users a bit too enthusiastic, but more because I was getting thoroughly disillusioned with ye olde Kinesis keyboard, so my attention to it has been rather intermittent, to say the least.

However, unlike Michael Kaplan of Microsoft’s International Fundamentals team (that’s the mob that decide which keyboard layouts get included with Windows and which don’t), who dismisses it out of hand because he thinks they’re too zealous, I have actually tried it out, and on Ryan Heise’s typing test the other day I managed about fifty words per minute with it. That is about as fast as most people type, and faster than anything I managed with Dvorak. Impressive, even if it is only about two thirds of my qwerty speed.

Since Colemak is so similar to qwerty, and many of the keys stay in the same place, it is vastly easier to learn than Dvorak if you are an existing qwerty typist, and it is also much easier to retain fluency in qwerty while you’re at it. I’ve managed to get this far with surprisingly little effort using a “qwerty by day, Colemak by night” approach, which has the added advantage that it doesn’t interfere with your productivity while you’re learning.

So will I stick with it? I don’t know at this stage. It certainly seems more comfortable and disciplined for normal text, but I’ve found that it tends to get in the way a bit when I’m trying to write code, especially in C# or JavaScript. However, I now find it pretty easy to switch to and fro between the two layouts depending on which one takes my fancy at any given time, so I may well do. Colemak for text-based work and qwerty for code seems to be a strategy with quite a lot of mileage in it.

Quite how much you stand to gain from learning it I am not sure: the rough impression that I get from people’s reports is that speed gains are of the order of 20% or so at best, so your mileage may vary. Personally, I don’t consider qwerty to be the disaster area that its detractors make it out to be — loads of people use it without complaint, and I can manage a fairly respectable, if indisciplined and inaccurate, 80 words per minute or so with it. However, if you are particularly frustrated with it — and emphatically if you’re thinking of learning Dvorak — Colemak may be worth a try. Since it is dramatically easier to learn, it renders Dvorak a total waste of time. Colemak is also well known for its enthusiastic and lively community, who, although some of them can get a bit carried away with themselves at times, are actually quite helpful and supportive, and more than willing to give advice if you need it.

Alternatively, of course, there is always voice recognition software

17
Dec

Mrs Immery

I went to the dentist this afternoon.

She poked around my teeth briefly and said, “They’re looking pretty healthy. I’m quite impressed, given all the work I had to do on them initially,” then told me that one of my root fillings was chipped and needed to be repaired.

Not to worry, that was pretty quick and painless, and ten minutes later I was on my way back to the reception for The Extraction.

The Extraction, I hear you ask? Why do the receptionists do extractions when your teeth are healthy?

It’s actually the most painful bit of the lot. They may not extract anything from your mouth, but they certainly leave plenty gaps in your bank account. Forty-three pounds and sixty pence, to be precise. Ick. Seems dental fees have gone up a bit.

“Thank you, Mr Mac-EH,” said the receptionist, mis-pronouncing my name.

I don’t know why so many people insist on mis-pronouncing my surname. Listen up, folks, it’s pronounced Mac-EYE, not Mac-EH. Just think “iMac” with the syllables the wrong way round. If you’ve ever watched Porridge or Stargate Atlantis you should be well aware of the fact. Unfortunately, however, most people haven’t watched Porridge for years, and only geeks watch Stargate Atlantis, let alone know that it has a character in it with the same surname as yours truly. So, I think it’s forgivable.

I made eye contact. “Actually, it’s Mac-EYE. Everyone gets that wrong,” I said to her with a little laugh.

Getting the laugh right is important, as is the eye contact. You can’t take this kind of thing too seriously, after all. After all, she herself probably has a name whose pronunciation or spelling is even more ambiguous, as is the case for about half the names in the phone book. However, while I can generally get away with casually mentioning it to a dental receptionist, if I had been talking to a group of ten year olds, it would have been nothing short of cataclysmic. After all, one key rule of working with children is: if something makes you cringe, never let the little blighters know it.

I know this because once upon a time I was one such little blighter myself, as one Mrs F.M. Imrie found out.

When I was ten years old, one of our teachers, Mr P.F. Mann, broke his leg or something and ended up having to take half a term of sick leave. This was something of a disappointment, because “Puff Mann”, as we used to call him, was one of the most popular teachers in the school. He had a quirky sense of humour and a gift for making the dullest subjects come to life — talents that are absolutely essential for any school teacher.

The supply teacher who took his place was a stern, middle aged woman with horn rimmed glasses, her hair in a bun, a handbag with the initials “FMI” on the front, and less sense of humour than Darth Vader on a bad day. The first thing she did on walking into the room was to turn and write on the board.

“Im/rie.” With a large, distinctive, slash between the two syllables.

She turned back to face us. “Two syllables,” she said sternly. “Not three.”

Of course, this temptation is just too much for your average ten year old mind to bear, and right from the start, she was firmly entrenched in our minds as Mrs Immery.

Now every lesson at this particular school would start with the same ritual. The teacher would walk in. The class would stand up. “Good morning, boys,” the teacher would say. “Good morning, Sir/Mrs <insert name of teacher here>,” we would reply. The lesson would generally be preceded by five minutes or so waiting for the teacher to arrive. Ample time for one particular boy, in a bout of mischief, to turn to the kid behind him and say, “Immery. Pass it on.”

“Immery. Pass it on.”

“Immery. Pass it on.”

By the time the door opened, and Mrs Imrie walked in, the message had worked its way right round the class.

“Good morning, boys.”

“Good morning, Mrs Imm-ER-ry,” chimed out twenty-five pre-adolescent voices in unison, making the interstitial syllable as deliberate and obvious as possible.

Her reaction was most satisfying.

“I heard you practising in the library,” she said, with a look of total indignation. “Just how would you like it if I mis-pronounced all your names?” She then proceeded to read through the register, deliberately, systematically and sulkily mis-pronouncing all our names. When my turn came, she called me “McKite.”

Lame, I thought, struggling to keep a straight face. How are you supposed to take a teacher seriously when she gets as petulant as that?

However, there is a twist in the tale. You see, the mischievous boy who started this whole escapade that day was, in fact, me. And while there may not have been any immediate repercussions, a few years later we moved to the south of England, where 99% of the population are living with the delusion that “McKay” is pronounced “Mac-EH.” Some of them even persist in this misguided belief after I have pointed out their mistake to them. Mind you, the main offenders there are telemarketers, and I gather that telemarketers have scripts that they have to stick to, and they get fired if they deviate from them, e.g. by pronouncing your name correctly.

So perhaps I’ve been reaping what I sowed all those years ago. However, I’ve learned to just laugh it off. After all, perhaps one day I could end up having to work with ten year olds who read my blog.

Sorry, Mrs Immery.

17
Dec

Making the "zoom" slider on the Microsoft Natural 4000 keyboard do something useful

Unapologetic mindless link propagation time — this is just way too useful to let it slip: Olivier Dagenais on a hack to make the "zoom" slider on the Microsoft Natural 4000 keyboard function as a "scroll" slider. (Hat tip: Ayende).

14
Dec

How to list the sizes of the tables in a SQL Server database

Scott Mitchell gave some instructions on 4GuysFromRolla a while back on how to list the sizes of all the tables in a SQL Server database.

His solution uses a mixture of SQL and ASP.NET, but some people will want an alternative in pure SQL. So, with no further ado, here you go:

create procedure sp_get_table_usage
as
begin
    create table #t (
        name varchar(100),
        rows int,
        reserved varchar(100),
        data varchar(100),
        index_size varchar(100),
        unused varchar(100)
    )

    declare @name varchar(100)

    declare c cursor
        for select name from sysobjects where type='U'

    open c
    fetch next from c into @name
    while @@FETCH_STATUS = 0
    begin
        insert into #t
            exec sp_spaceused @name
        fetch next from c into @name
    end
    close c
    deallocate c
    update #t
        set reserved = rtrim(replace(reserved, 'KB', '')),
            data = rtrim(replace(data, 'KB', '')),
            index_size = rtrim(replace(index_size, 'KB', '')),
            unused = rtrim(replace(unused, 'KB', ''))

    alter table #t
        alter column reserved int
    alter table #t
        alter column data int
    alter table #t
        alter column index_size int
    alter table #t
        alter column unused int

    select * from #t
        order by name
end

You can change the sort order by changing the order by clause at the end. For instance, order by data desc will list them in descending order of size.

01
Dec

Britain’s best motorway service station

For anyone on the road heading to (or from) Scotland, Tebay services (Westmorland Farm Shops) on the M6 is the place to stop. It’s Britain’s only privately owned motorway service station and you really notice a difference. The food is way nicer for starters, and it has a much more homely atmosphere than the enterprisey corporate blandness of all the other places.

I’m writing this post from the above establishment, where we’ve stopped off for a meal en route to Scotland for a week’s holiday. We’ll be getting some much needed rest as well as celebrating my granny’s birthday on Tuesday. She will be 91.