18 January 2008

Processing instructions and Microsoft XML DOM

If you're using Microsoft's XML DOM you'll find it strips out the encoding attribute from your processing instruction (the <?xml ... ?> bit) when you get the value of the Xml property. This is because it always returns unicode regardless of what the input encoding was. As unicode is the default for the XML specification, no encoding attribute is required.

The Save method, which writes the contents of the DOM document to a file, maintains the original encoding. If you need your XML in the original encoding after some manipulation in the DOM then you can do this:

xmldoc.Save("c:\blah.xml")
Set fs = Server.CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile("c:\blah.xml")
strXml = ts.ReadAll

Programmatically changing a processing instruction

Looks a bit dodgy but this is the way to do it:

Set pi = xmldoc.createProcessingInstruction("xml", "version=""1.0"" encoding=""UTF-16""")
xmldoc.replaceChild pi, xmldoc.childNodes.Item(0)

12 January 2008

Mapstraction "to do" list

I've been using Mapstraction to implement draggy maps in our platforms at work for the past month or so and thought I'd share some of the problems I came across so, should you decide to do the same, you know what to watch out for. The issues I've come across below I've fixed for the APIs with which I was working and I'll be submitting the changes back to the project in the near future.

I should say first that Mapstraction is an awesome piece of work that frees you from having to commit to one mapping provider. When clients don't want to pay for maps so you give them Google and then change their mind when Google start inserting advertisements, all you have to do is change one line of code.

The List

1. Patchy implementations

Mapstraction abstracts the lowest common denominator set of functionality for its supported APIs. I've been working primarily with Multimap and have discovered that, for this API at least, some API classes are missing methods or have non-working implementations.

In the Multimap case this is just a few methods here and there but the thing I found annoying was that, rather than the method just being empty or throwing a "not implemented" exception, the method was populated with the code for one of the other APIs.

2. Incomplete events

The only events catered for by Mapstraction are "move end" and "click" which is severely limiting considering the vast array of events available through the native APIs. Events like "zoom", "open bubble", "change map type" etc aren't there.

Arguably, abstracting events is probably the most difficult part of the process as you have to take into account differences in when similar events fire, orders that they fire and event arguments that are passed back to the handler.

The event implementation for the two events also doesn't cater for overriding the scope in which the handler function is to be executed via the call method which is essential if you're working with methods of JavaScript objects.

3. No namespacing or prefixing

The Mapstraction code is not namespaced, scoped or prefixed in any way so is dangerous when used with a lot of JavaScript code from different sources as you'll likely end up with name clashes and global variables being overwritten.

4. No standards enforced on the source code

There appear to be no coding standards enforced on the source. It's full of undelared variables, dodgy constructs and some bits that just aren't formatted well, making the code difficult to follow.

The likes of Yahoo! run all their code through JSLint before it goes anywhere near deployment and with a library of this type I think at least a loose Linting is a must.

To sum up

If your integration is complex and requires a lot of event handling and dynamic manipulation of the map artifacts then Mapstraction isn't quite there yet but for most other things it's worth filling in any holes yourself for that freedom of API.

24 December 2007

What Hi-Fi disappoint on Lossless

In the Sound Advice section of the Jan 2008 issue of What Hi-Fi a reader asks what the best portable player and file format is for maximising digital audio quality. The response is essentially buy an iPod and use Apple Lossless. Whilst I agree the iPod's audio hardware is very good, I don't think its virtually proprietary encoding algorithm is something What Hi-Fi should be encouraging people to use.

They later go on to say that you could buy a device from Creative and use "one of the other lossless formats" but they don't give any examples of other formats or mention that the only lossless formats the current Creative products support are WMA (Microsoft Lossless) and AAC (Apple Lossless).

All in all I'm disappointed that a magazine that professes to be unbiased and impervious to the corporates is so casual about recommending proprietary formats which facilitate consumer lock-in. In my opinion they should be promoting the open source formats and marking the products they review down for only supporting propretary technologies. Decreasing consumer choice is, after all, a negative factor and the corporates shouldn't be allowed to get away with it.

On the plus side, from 31st Dec, 7 Digital will be offering Radiohead's In Rainbows in FLAC format click here for more.

10 December 2007

Reference types in prototype declaration - JavaScript gotcha

I've recently started doing some heavy duty JavaScript, including messing around with constructors, prototypes, lamdas, closures etc. I started off creating a few classes by creating a constructor function and then defining its prototype using object-literal notation as it means your code looks quite like class declarations in other OO languages.

Here is a simple example without any methods, just with two member variables:

function MyClass(){}
MyClass.prototype = {
 iNum: 0,
 sStr: 'Derek'
};

var oA = new MyClass();
var oB = new MyClass();

// oA: iNum -> 0, sStr -> Derek
// oB: iNum -> 0, sStr -> Derek

oA.iNum++;
oA.sStr += ' Fowler';

// oA: iNum -> 1, sStr -> Derek Fowler
// oB: iNum -> 0, sStr -> Derek

All seems well, however, upon adding some reference types to the prototype things get a bit strange:

//...

MyClass.prototype = {
 iNum: 0,
 sStr: 'Derek',
 aAry: []
};

//...

// oA: aAry.length -> 0
// oB: aAry.length -> 0

oA.aAry.push('test');

// oA: aAry.length -> 1
// oB: aAry.length -> 1

Adding an element to aAry of oA has added it to oB's aAry too. "Odd", I thought, so I did a little more investigation:

// MyClass.prototype.aAry.length -> 1

The array property of the instances is pointing back to the property of the prototype. In other OO languages all member variables within the class declaration are copied into the instances, it is only static variables and method implementations that are shared between them. These JavaScript variables seem to be neither member nor static, they are member if value types and static if reference types. Next I tried looping though the properties and testing hasOwnProperty:

for(var sProp in oA){
 // oA.hasOwnProperty(sProp)
}

Before the assignments all the properties return false, that they are not member properties but reside within the prototype. Following the assignment however iNum and sStr return member and only aAry still claims to be prototype.

This behaviour isn't a bug in an implementation either, it is consistant in all the browsers but after having a quick look in the ECMA-262 doc i'm still none the wiser about why this is the case. Anyone who can shed light on this please comment below.

The solution

The solution to this is to create all member variables using the this keyword in the class constructor thus:

function MyClass(){
 this.aAry = [];
}

This ensures that the variable is created upon the new instance and you don't get any sharing problems.

27 October 2007

ALA Web Design Survey 2007 Results

The results from this year's A List Apart Survey of Web Design Professionals are in.

The findings are in an 82 page PDF which makes some interesting reading. You can also get an anonymised version of the 33,000 raw responses if you want to do some number crunching of your own.

Links

20 October 2007

Winamp 5.5 - 10th Anniversary Edition

That's right, 10th Anniversary, the first version of Winamp came out in 1997. Interestingly, on the 6th of August that year, Microsoft bought a $150 million share of the "financially troubled" Apple.

Since I bought my iPod (2004) I've pretty much exclusively used iTunes however, my foray into the world of FLAC has meant that it's not really meeting my requirements any more and I've been looking for a media library application with better format support.

I'll be posting a feature comparison and which one I've decided to go with in the coming weeks but until then I'll just say that I'm impressed with Winamp 5.5 so far. I'm only using the free version however it seems to have come a long way since the last time I used it. Features I'm particularly enjoying are:

  • Album art
  • Advanced SQL query style smart playlist generation
  • iPod support
  • Ripping to FLAC

Links

17 October 2007

Ripping to FLAC with Exact Audio Copy

In a previous post I talked about the convenience of having your CD collection archived to a hard disk. I weighed up the options for a archiving format and decided FLAC met my needs the best.

Anyone who has done and serious ripping on a Windows PC in the past will likely know that there are two big players; CDex and Exact Audio Copy. While EAC is not open source it seems to me to be the more complete solution and in a like for like comparison ripped far faster than CDex without any loss of quality. Mac or Unix users can check out the download page on the FLAC site for the ripping options availabe to them.

Getting it set up

After downloading and installing EAC you'll be presented with the very handy setup wizard which does a lot of the hard work for you. Unfortunately in my case the drive setup parts of the wizard didn't work first time which was down to EAC defaulting to using a third party ASAPI drive interface which i didn't have installed. This is easily fixed after the setup finished by going to:
EAC > EAC Options... > Interface(tab)
and selecting "Native Win32 interface for Win NT/2000/XP". Re-run the wizard again from the EAC menu to configure your drives.

Once you're finished with the wizard it's best to run through the settings it's chosen anyway as in some cases they aren't optimal. Main things to check, from the EAC menu:

EAC Options:

  • Extraction tab
    • Extraction and compression priority
      Setting this to "High" will ensure that EAC is prioritised above other applications when its ripping.

Drive Options:

  • Extraction Method tab
    • Mode
      Ideally you want "Secure".
    • Examine C2 Feature...
      You can use this tool along with a suitably scratched CD to determine whether your drive supports C2. This is worth doing as it will increase the speed of your rips.
  • Drive tab
    • Drive read command
      Hit the "Autodetect read command now" button as the wizard doesn't seem to set this.
  • Offset/Speed tab
    • Allow speed reduction during extraction
      Ideally you want this checked but some drives don't speed up again once they've slowed down.
    • Use AccurateRip with this drive
      You want this checked as it will look up the checksums of your rips against a database of other people's thus ensuring they're accurate.
  • Gap Detection tab
    • Gap/Index retrieval method
      It's worth putting a CD in and running a Detect Gaps once for each one of these options to see which is quickest.
    • Detection accuracy
      Set this to "Secure".

Compression Options:

The configuration wizard should have configured your FLAC settings for you so long as you picked the right option. You can check this in "Compression Options...". If it hasn't then run the wizard again and chose the FLAC option when prompted rather than trying to set the command line and all its parameters yourself.

freedb/Database Options:

  • freedb tab
    • Your e-mail address
      Enter your e-mail address to use freedb.
    • Get active freedb server list
      Hit this to get the list of freedb servers.

Ripping a CD

  1. Put a CD in and select the right drive from the drop-down list, the list of track should appear.
  2. Hit F4 (Action > Detect Gaps) to run the gap detection.
  3. Hit Alt-G (Database > Get CD Information From > Remote freedb) to get the album and track info.
  4. Check the album info is right and if not update it.
  5. Hit Ctrl-A (Edit > Select All) and the Shift-F5 (Action > Copy Selected Tracks > Compressed...) to begin ripping.

After this finishes you get a status log that gives you a quality percentage, AccurateRip confidence and and errors for each track.

Track quality indicates what percentage of the track was ripped first time with no problems. If everything is set up properly and you have a scratch free CD will normally be 99.9% or 100%.

AccurateRip confidence is the number of people in the AccurateRip database who have submitted the same checksum for a particular track as you. The higher the confidence the better however, a low confidence doesn't necessarily mean it is a bad rip, especially if you're ripping a lesser known CD.

Finally

Fire up Winamp, have a listen and then kick yourself for ever thinking MP3s sounded good!

01 October 2007

Amazon MP3 downloads

Today's top two MP3 artists on Amazon MP3 are Richard Wagner and Pink Floyd. I find this odd considering that the audiences for these two artists i.e. the classical lot and the prog lot are probably the most demanding when it comes to audio quality.

After it went public beta last week I have to admit I'm very impressed with Amazon's offering; comparing its service to a few others:

iTunesHMVWalmartAmazon
StandardPlus WMAMP3
Format AACAACWMAWMAMP3MP3
Quality 128kbps256kbps?128kbps256kbps256kbps
DRM YesNoYesYesNoNo
Price
Feist - The Reminder
$9.99$12.99$16.22$9.44$9.22$8.99

I'm not sure how many people consider things like quality and DRM when downloading music but one thing they will consider is price and Amazon is the clear leader here. Especially seeing as the album I chose for the comparison is one of the more expensive ones; you can download the whole of Pink Floyd's Wish You Were Here for $4.45, that's £2.20!

The fact that Amazon offer DRM-free MP3s means that they will play on pretty much anything. In addition to computers and portable music players, these days you'd be hard pushed to find a CD or DVD player that doesn't play MP3s. The AAC and WMA offerings of the competitors very much limit your choice of player; for example AAC work on iPods, WMA work on Creative Zens but not vice versa. MP3s, however, will work on both.

Amazon already has a massive share of the music retail market so its existing customers are more likely to download from them than go with one of the alternatives. Although they don't offer this yet, something that would seal up the Christmas market would be a "Buy an MP3 player preloaded with albums of your choice" service.

It all seems to stack up in Amazon's favour, I'd wager iTunes are going to see their market share slipping away in the coming months.

27 September 2007

FLAC on your iPod with Rockbox

The list of hardware with native FLAC support on the FLAC website includes quite a few home systems; Slim Devices' Squeezebox and Transporter, the Sonos Music System and wireless media players from the likes of Netgear, Olive and Helios. The list of portable players with native support is less impressive however, Cowon and Rio being the only names I recognise.

Thankfully the very nice people responsible for the Rockbox firmware had the foresight to include a FLAC codec meaning if you own an iPod or one of the other supported players listed below then all is not lost.

  • Apple: 1st through 5.5th generation iPod, iPod Mini and 1st generation iPod Nano (not the Shuffle, 2nd/3rd gen Nano, Classic or Touch)
  • Archos: Jukebox 5000, 6000, Studio, Recorder, FM Recorder, Recorder V2 and Ondio
  • Cowon: iAudio X5, X5V, X5L, M5 and M5L
  • iriver: H100, H300 and H10 series
  • SanDisk: Sansa c200, e200 and e200R series
  • Toshiba: Gigabeat X and F series (not the S series)

I'm normally skeptical of any such warranty voiding activities however, as my iPod is third generation its warranty days are long gone, I thought I'd give it a go. The firmware itself runs alongside the Apple one in a very nifty dual boot setup and the installation couldn't really be simpler. All you do is download one of the builds, copy it to the root of your iPod's hard disk, run a flash utility and it's done.

There are a lot of benefits to Rockbox over the native firmware including folder browsing, playlist editing, skinning and one the audiophiles will love, a proper parametric EQ so you can even out your headphones' response. There does seem to be one disadvantage too in that battery life seems somewhat reduced, possibly due to the increased disk access required for FLAC playback. This is a small price to pay for an impeccable performance from the full quality tracks going through the iPod DAC though.

Links

23 August 2007

.NET Performance Counter Problems

I've recently been doing some work with performance counters in .NET and discovered the support for them in the framework is a bit nasty.

One example is that the only way to add counters is through the PerformanceCounterCategory.Create method so you can't append a new counter to an existing category. You have to copy all the counters from the old category, add you new counter, delete the old category and then recreate the category with the new list of counters.

Another example is that in order to use any of the fraction based counters like averages you have to add two separate counters, one for the numerator and one for the denominator.

All very long winded anyway so I decided that I'd wrap up the creation of the counters and categories along with a few other bits in a helper class. That was the plan but it fell at the first hurdle - trying to create categories.

The symptom

This, seemingly innocuous bit of code...

if(!PerformanceCounterCategory.Exists(categoryName))
{
 PerformanceCounterCategory.Create(categoryName, categoryName, new CounterCreationDataCollection() );
}

if(!PerformanceCounterCategory.CounterExists(counterName, categoryName))
{
 //add a counter
}

...was yielding the following error on line 6:

System.InvalidOperationException: Category does not exist.
   at System.Diagnostics.PerformanceCounterLib.CounterExists(String machine, Str
ing category, String counter)
   at System.Diagnostics.PerformanceCounterCategory.CounterExists(String counter
Name, String categoryName, String machineName)
   at System.Diagnostics.PerformanceCounterCategory.CounterExists(String counter
Name, String categoryName)

i.e. three lines after the statement creating a category it says the category doesn't exist. Odd, I thought, so I knocked together a quick Snippet Compiler script:

string categoryName = "foo";
string counterName = "bar";
  
if(PerformanceCounterCategory.Exists(categoryName))
 PerformanceCounterCategory.Delete(categoryName);
  
WL("Category " + categoryName + " exists? " + PerformanceCounterCategory.Exists(categoryName));
  
PerformanceCounterCategory.Create(categoryName, categoryName, new CounterCreationDataCollection() );
  
WL("Category " + categoryName + " exists? " + PerformanceCounterCategory.Exists(categoryName));
      
try
{
 WL("Counter foobar exists? " + PerformanceCounterCategory.CounterExists(counterName, categoryName));
}
catch(Exception ex)
{
 WL(ex.ToString());
}
  
RL();

Further oddness arose from this because the call to PerformanceCounterCategory.Exists after the Create actually gives the correct response, it is only the CounterExists method that fails. I immediately suspected some sort of caching issue.

The cause

After having a poke around with Lutz Roeder's .NET Reflector I discovered that all the Performance Counter classes make use of an internal class called PerformanceCounterLib which has a few hashtables it uses to cache information about the categories and their counters.

The hashtable concerned here was the CategoryTable which, on adding a category for he first time, does not update properly. When the CounterExists call runs this line:

if(this.CategoryTable.ContainsKey(category))

it fails throwing the error however the Exists call has this line:

return (PerformanceCounterLib.IsCustomCategory(machineName, categoryName) 
   || PerformanceCounterLib.CategoryExists(machineName, categoryName));

the right part of this calls the same CategoryTable.ContainsKey however the IsCustomCategory on the left accesses the registry directly and returns the correct answer - true.

Why the CounterExists doesn't call this method itself and opts instead to provide its own implementation i've no idea.

The solution

Luckily the PerformanceCounter.CloseSharedResources() method flushes all these internal caches so the calls all return the same answer. Adding a call to this straight after my PerformanceCounterCategory.Create solved the problem.

19 August 2007

Archiving your CD collection

This post could probably be considered to be the second part of my very first post on this blog entitled Freeing your digital media in which I talked about the DLNA standards and how they allowed you to store all your media on a NAS device and stream it around your house over your network.

I'd been considering this more seriously and realised that a large proportion of my MP3 collection were low bitrate poor quality rips which just sound awful played though a half decent hi-fi.

Storage space is only getting cheaper and today you can pick up a 500GB external hard disk, enough for 700 uncompressed albums, for less than £80; the Western Digital My Book series proving to be a popular choice. There really is no reason why, with this much space, we should be sticking to lossy compression formats for our music archiving. So, with that in mind, what are the options?

The main contenders

WAV
Microsoft's uncompressed audio format
AIFF
Apple's uncompressed audio format
WMA Lossless
Microsoft's lossless audio compression format
Apple Lossless
Apple's lossless audio compression format
FLAC
Open source lossless audio compression format - now part of the Xiph.org Foundation, originally developed by Josh Coalson
Monkey's Audio
A lossless audio compression format developed by Matt Ashland
Shorten
An old open source lossless audio compression format developed by Tony Robinson at SoftSound

Hydrogen Audio have prepared a good comparison table of lossless formats. Uncompressed 44.1kHz 16bit audio uses up about 10MB of space per minute. The lossless compression formats listed above all reduce file sizes to about 6MB per minute. Not bad but compared to the 1 - 2MB per minute we're used to with lossy formats this still seems like a lot. My justification for this space usage is that I want the convenience of being able to carry 700 albums around with me and I've paid for the CDs so i might as well be listening to them in full CD quality.

My criteria for a format were; open source, good compression and good hardware and software support. This already removes all the Microsoft and Apple options and Monkey's Audio. Shorten is old and has poor support so the natural choice is FLAC which, being part of the Xiph.org Foundation, has a large developer base behind it and support in all the major software and hardware music players albeit via new firmware in some cases. Not to mention that it's now packaged with arguably the best CD ripper, Exact Audio Copy.

A quick download, set up and a few rips later and I'm rather astounded by the results. To my ears the FLAC files actually sound better than playing the original CD through the same system, delivering a far more punchy and detailed sound. I have to admit I wasn't expecting this and I'm assuming it's down to my CD-ROM reading the audio data poorly when playing the CD directly.

Links

23 July 2007

Mobile madness

I've recently been going through the yearly trauma of picking a new phone as my free upgrade. It's the same every time - there is never one phone that meets all my criteria so I have to go for the best compromise. The phone I'm upgrading is a Nokia 6680 which is a rather large Symbian smartphone, lacking in both the processor speed and memory stakes. The criteria for my new phone are therefore:

  • Features - preferably a smartphone with a camera (40%)
  • Usability - a decent size keypad and quick processor (30%)
  • Size - not a brick but not very thin either (20%)
  • Design - least important but something that looks reasonable (10%)

I've only ever had Nokia phones and have stuck with them mainly because they were a lot more usable than other brands. Nokia's current offerings were leaving me a bit cold however so I've been thinking "surely the other brands must have caught up" and indeed Sony Ericsson's sales are topping Nokia's in the UK at the moment. Anyway I thought I'd give another brand a try so I went for a Samsung U600 as I like the look of their sliders and although it's not a smartphone it is from their new "Ultra Edition 2" line so I thought it would meet my needs.

I'm currently awaiting the Jiffy bag from Orange to send it back in so needless to say it fell at the first hurdle. A hopelessly inadequate phonebook, annoying predictive text set-up requiring constant swapping between keypad and navigation key, and some very questionable calling and hanging up behaviour were my main grievances.

So now I'm back to square one and thinking I'm either going to get a Nokia or another brand only if it's running Symbian so I can be assured of a certain amount of base functionality. So the next two candidates were the Nokia 6300 or the Sony Ericsson W950i - the Sony is missing the all important camera and the Nokia isn't running Symbian so not clear cut by any means. I may have finally found the answer with the Nokia 6120 which is a smartphone, has a camera and is a centimetre narrower and half a centimetre thinner than the 6680. Only problem with this one is that it's not currently available on Orange so I've got to wait for it - Doh!

Links

20 June 2007

500 Geeks + 1.21 Jigawatts = ?

Well, i'm back. Thanks to Yahoo! and the BBC for a great weekend. It didn't get off to the best of starts what with the lightning and broken WiFi and all but everyone made the best of it.

A total of 73 hacks were presented on the Sunday evening however ours wasn't finished in time which was a shame because no-one else had made anything similar. If 500 geeks went and were in teams of five then there should have been 100 hacks so i'm guessing we weren't the only people who didn't finish.

Hack-tastic, looking forward to the next one!

28 May 2007

Hack Day UK 2007

Thought a quick post was in order as I've just received the e-mail confirming my place at this year's Hack Day UK.

I'll be there along with the fellows from my blogroll - current and former colleges - and we'll likely be attempting our own hack as well as pimping our skills to the highest bidder!

13 May 2007

ALA Web Design Survey 2007

Just a quick post to point you all in the direction of A List Apart's survey of Web Design Professionals. It's been up for a while now and I've only just remembered to fill it in myself. I look forward to the results and hope at least some of them are plotted on a nice graph.

02 May 2007

Why don't Google support SyncML?

I use quite a few of Google's online services and recently I've started exclusively using Mail and Calendar for managing all my e-mail accounts and calendars. Both are brilliant applications and it's great to be able to access this data from any computer without worrying about remote access or setting up something like MS Exchange. One thing I'd really like to be able to do however is have a two way sync between my Google services and my mobile phone.

Thom Shannon's PocketGCal does just that on a device running Windows Mobile and I toyed with the idea of writing a similar Java app for my Symbian device. Having got as far as downloading Eclipse and all the various projects and SDK's I'd need I happened upon a Sync app already installed on my phone.

The app uses the Data Synchronisation standard from the Open Mobile Alliance which was formerly called SyncML. It allows you to sync over Bluetooth or HTTP and supports different profiles specifying which access point to use and whether authentication is required etc.

"Great, an open standard. I bet Google support that, they're the champions of free data!", I thought naively. Alas it is not the case, Google seem to be pushing their proprietary GData as the means for programmatically updating the data you hold with them and nothing else.

Google do seem to have missed a trick here as I'm sure there are a lot of business types who'd see native support for SyncML as a very useful feature. This whole episode is at least going to make me look around at the other Mail and Calendar providers out their to see if any of them have better support.

Update - 09/05/2009

Google does now support SyncML for syncing of contacts, it also supports various other syncing methods including ActiveSync for Windows Mobile devices which allows you to sync your calendar entries as well. Check out Google Sync for details.

01 May 2007

Silverlight, Microsoft on the bleeding edge yet again

I jest.

It's odd to think that 12 years on from the introduction of Java applets Microsoft are giving the whole thing another go. Their marketing clout is a given but Silverlight won't be successful through that alone.

The two major limiting factors for the uptake of Java applets were the need for a Java Virtual Machine being installed and the security restrictions placed upon the applet. While the JVM isn't a big download by today's standards, on the modems of 1995 it took forever. An applet's access to the local machine was very limited unless the user trusted it which was an instant hit to how useful it could be.

The first factor has been removed as broadband connections are now widespread and the Silverlight installer is only a few megabytes depending on your platform. As for security it remains to be seen whether Silverlight is full of holes but seeing as it runs from within a browser, and not just Internet Explorer, it will be interesting how the other browser vendors react if this turns out to the the case and whether they implement their own measures to restrict its access.

All that doom and gloom aside security issues don't stop you being able to use all the awesome XAML based visual trickery available in Silverlight. Using Java applets it was pretty difficult to make anything that looked nice let alone doing things like performing image manipulation on videos as they're playing. Powerful stuff indeed and I'm looking forward to being able to make great looking, feature rich UI's that should just work on any platform.

28 March 2007

Keeping your data secure online

There is a growing trend among the Web 2.0 sites of asking you to enter a username and password for some other site in order to perform an action. Two recent examples of this i've come across are Technorati which asks for your Blogger username and password in order to verify you own a particular blog and Facebook which asks for your e-mail account username and password in order to match you contact list against existing Facebook members.

As an IT professional i'm naturally skeptical of any such demand and in the case of Technorati chose to verify my blog ownership in a different way. Terms and Conditions and Data Protection declarations are one thing but you've no guarantee your details won't be stored in a database and if they are there's all the more chance they may at some point fall into the wrong hands. The only way to be sure is not to type them in in the first place.

A Blogger user account is one thing but Facebook asks for something totally different. I wonder how many people actually consider what data is stored in their e-mail inbox before they submit their details with the promise of being shown how many of their friends are already signed up.

When you sign up to the majority of sites you're e-mailed a confirmation containing all your details, including things like home and work addresses, phone numbers, date of birth, passwords and perhaps the most crucial of all, answers to secret questions e.g. mother's maiden name. If some unscrupulous person gets hold of your e-mail account password it will likely take them little effort to steal your identity, empty your bank accounts and max out your credit cards.

This article from the BBC Many net users 'not safety-aware' serves to reaffirm the point that a large number of net users simply do not think before typing their sensitive information into random websites.

12 March 2007

Reference type keys and .NET dictionaries

The default implementation of the Equals method for reference types is to call ReferenceEquals i.e. to test whether two variables reference the same instance of an object.

When using a ListDictionary the Equals method is used so you can be sure you will be accessing the correct item. However if you use a HybridDictionary, which will swap to a Hashtable for collections of more than 10 items, you can get inconsistent results. This is all down to the fact that the Hashtable uses the GetHashCode method to get a code which represents an object and this is then used as the key. As you will read here the GetHashCode method does not always return a unique code for dissimilar objects so you can end up accessing the wrong item of your dictionary.

To get around this you can either stick to using the ListDictionary or implement your own IHashCodeProvider for the classes used as keys in your dictionary.

20 February 2007

32-bit Windows Script Components under 64-bit Windows

We're currently setting up a new suite of 64-bit web and database servers at work all running Windows Server 2003 x64 Edition. We've got quite a few legacy 32-bit Windows Script Components we need to use which by all accounts should run fine in the 32-bit environment provided by WOW64.

Imagine our surprise when, on registering the components, none of them worked - throwing errors at the point of instantiation.

WOW64 is rather an odd beast; residing as it does in it's own SYSWOW64 folder in the Windows directory. This folder essentially contains the 32-bit versions of all the DLLs and things that are available in a 32-bit version of Windows. The caveat being that in order to get your 32-bit fare to work you need to call on the services of these SYSWOW64 versions rather than the ones in the folder still called SYSTEM32 (note the stupid naming convention).

When registering WSC's you actually register the hosting service, scrobj.dll with regsvr32.exe, passing the path to your WSC as the command line for scrobj.dll using the /i switch e.g.

regsvr32 /i:"C:\Components\Display.wsc" "C:\WINDOWS\SYSTEM32\scrobj.dll"

Oddly the Register option in the file association for WSC's seems to mix versions, calling the 64-bit version of regsvr32.exe and the 32-bit version of scrobj.dll.

"C:\WINDOWS\system32\REGSVR32.EXE" /i:"%1" "C:\WINDOWS\SYSWOW64\scrobj.dll"

I'm not sure of the significance of this mixed version thing, however it didn't work in our case so we added a 32-bit Register option which called the 32-bit versions of both files from the SYSWOW64 folder e.g.

"C:\WINDOWS\SYSWOW64\REGSVR32.EXE" /i:"%1" "C:\WINDOWS\SYSWOW64\scrobj.dll"

and a 32-bit Unregister e.g.

"C:\WINDOWS\SYSWOW64\REGSVR32.EXE" /u /n /i:"%1" "C:\WINDOWS\SYSWOW64\scrobj.dll"

which sorted the issue.