Tuesday, March 10, 2009

Thanks to a colleague who I shall refer to only as "Mr. Picky", I've just been playing with decimals.

I know they're the slowest numeric data type, but we're talking XML and xs:decimal, and classes created thereof.

Mr. Picky's complaint was that of all of the values (prices, in fact) in the XML file, some were formatted with 2 decimal places, and some with none, and he'd like to see them all with 2.

Now, after a bit of fiddling about, I couldn't see any obvious reason why we had these differences.  The prices all originated in the same fields in the database, and they all ended up as XML attributes declared as xs:decimal, and passed through VB.Net classes as Decimal variables.

The heart of the issue is VB.Net's Decimal handling.  By default a Decimal has zero decimal places, but if it acquires any along the way then it will keep them.  Some of my values had spent part of their life as a string (something like "£12.34", and don't ask why!) and some were just plain Decimals.  All the attributes where the values had been strings had their 2DP, as they'd been parsed from strings like "12.00" and so when the VB.Net class went ToXml() they appeared as "12.00", but those that were never strings stayed as "12".

My solution?  (and I ain't proud of this)

Dim decimalWith2DecimalPlaces As Decimal = decimalValueFromDb * Decimal.Parse("1.00")

...and I can't find any better way of doing this.  I've spent frankly far too long on a trivial bug as it is, and I've got plenty more to be working on, so that's that!

EDIT: Ignore me - if you do that you can end up with this: "12.300", which is clearly nonsense. I've abandoned all pride and started doing this instead:

Dim decimalWith2DecimalPlaces As Decimal = Decimal.Parse(decimalValueFromDb.ToString("0.00"))

Coding | Work
Tuesday, March 10, 2009 4:30:32 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Thursday, February 19, 2009

I take Scribble’s challenge!

Charlie Brooker - I agree with Scribbles.  The weekly column I look forward to.


Tom Waits - Wish he's play live over here more often, but at least I saw him in Hammersmith a few years ago.  Genius.


Richard Dawkins - If he didn't exist, it would be necessary to invent him.


Stephen Fry - No comment required.

Terry Gilliam - Brazil is one of my favourite movies.

The Coen Brothers (can I count them as 1 person?) - So is Fargo.  And The Big Lebowski.

Iain (M!) Banks - My favourite author.  It's been a while since he did anything I liked as much as Use of Weapons, or The Bridge, but I still buy everything in hardback as soon as it's out.

Howe Gelb - Who introduced me to the whole Americana thing.  Giant Sand, Calexico, Lambchop, The Handsome Family, the divine Neko Case, M Ward, Sparklehorse, Jim White, and so on and on...

David Simon - The Wire.  The best TV show ever made.

Bill Gates - Ok, evil empire and all that.  But he's indirectly responsible for my income for the last decade, and whatever the faults of, say, Vista (from which I'm writing this), I still can't get on with Linux (and can't, frankly, be bothered to put the requistite time in).

Thursday, February 19, 2009 11:50:20 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, January 30, 2009

An interesting discussion on The Quackometer: Is Chiropractic X-raying Illegal?

V and I went to a "What is chiropractic" talk in town before xmas - I can't say I was exactly impressed. I may blog about it in more detail later.

It seems entirely appropriate to me that the magazine that was given to us at the end of the presentation, and the association behind it, are known as Whopper.  Sorry, I mean wopaa.

Friday, January 30, 2009 4:31:26 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, December 03, 2008
Is your cat plotting to kill you?

I knew it!

Wednesday, December 03, 2008 9:52:38 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Wednesday, August 06, 2008

I've just bought the Netgear Wall-Plugged HD Ethernet Starter Kit from Novatech (the product page is here). For the first time since I've been using them I was bit disappointed in Novatech's service: the website showed 8 in stock available to collect from Reading withing 24 hours, and it stayed that way until I got the email telling me it was available to collect, 4 working days later. I know it's only a few days more, but it annoys me that the stock availability message was inaccurate. I'm sure it won't stop me using them, mind you...

Anyway, the kit contains a pair of HDX101 ethernet-over-powerline adapters. The HD part of the name is meant to tell you that they can provide enough bandwidth for streaming high-def movies, as the adapters have a (theoretical) maximum speed of 200Mbps.

I had been finding that while I could stream standard def movies over my wifi link, high def was impossible, and it's just not practical to route ethernet cable between my office (where the ADSL line comes in, and the Windows Home Server sits) and the living room, so I thought I'd give the latest generation of powerline adapters a go.

I have to say I'm impressed. Set-up is mindlessly easy: just plug them in and you're away. High def (720p) movies are streaming flawlessly - I haven't got any 1080p movies to try, but when I get hold of something I'll give it a go.

The control panel app included on the installation CD allows you to check the speeds you're getting, and it's showing that I'm getting 72Mbps from my server to my laptop, and 54Mbps in the other direction. Yes, this is a lot less than the notional 200Mbps, but then I'm not using gigabit ethernet yet, so my maximum was always going to be 100Mbps anyway. Since gigabit switches have become so cheap these days I'll probably pick one up and see if that makes a difference - though I'll need a new card in my homeserver as the on-board network card is 10/100.

The control panel app also allows you to set QoS priority, even to the level of selecting a specific port, so if you're using it mainly for streaming media you can tune it to match. The default setting appeared to be priority for UDP, which seems fine so far for me.

When copying a large file from a WHS share to my Vista laptop I was getting speeds of 3MB/s reported by TeraCopy, which isn't exactly blazing, but still better than I got over wireless. I can probably get that rate up with QoS tuning, but I'll not bother as it will mainly be used for media streaming anyway.

So: highly recommended!

Wednesday, August 06, 2008 4:52:14 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 

As if to make up for Scarlett Johansson's Waitsian waste of space, Zooey Deschanel's album with M. Ward under the name She & Him is an absolute delight of summery pop. I've been listening to Volume 1 quite a lot recently, and I'm even happier to find that Aqarium Drunkard has a live set from this year's Newport Folk Festival available to download.

So it's true: not all actors should avoid the recording studio. Helps when you have someone as good as M. Ward behind you, mind...

Wednesday, August 06, 2008 10:21:05 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Monday, July 28, 2008
twosilvertrees

Calexico's new album Carried To Dust is due on September 9th on Touch and Go records.  A taster can be found here: Two Silver Trees

From what I've read so far, and listening to this track, it's sounding good, and a move back to something more like their core sound than Garden Ruin's more mainstream sound (mainstream in a very relative way, obviously!).

I've got my tickets to see them at The Forum in October - they must be getting close to being the band I've seen the most, and I've yet to be disappointed...

New albums are due later this year from Giant Sand and Lambchop, too, so all in all it's a good year for alt-country/americana/whatever-the-hell-it-is... (no, I've never been able to answer the question "what kind of music do they make" about any of these bands!)

Bonus tracks:

Lambchop's "Slipped Dissolved And Loosed"

For a free download of Giant Sand's "Increment of Love" go to http://www.yeproc.com/stash, sign in (or sign up, all you need is an email address!), and enter the code PROVISIONS.

Monday, July 28, 2008 11:18:55 AM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Friday, July 25, 2008

I don't tend to make political or religious posts on my blog. Let's be honest, I don't make many posts on any subject on my blog! So, please feel free to ignore this post.

However, I wanted to post on this subject. P Z Myers, the author of the blog Pharyngula and biologist at the University of Minnesota, Morris, has (intentionally) got himself into the cross-hairs of Bill Donohue's Catholic League, for the (according to Donohue) heinous crime of desecrating a cracker. The back-story can be found quite easily on Pharyngula, and many other places around the web, so I won't go into it here.

Myers has been taking a lot of abuse for his threats against crackers, with many idiots describing his behaviour as inciting hatred of Catholics, and calling for his dismissal from his position at UMM. As you may be able to tell from my tone so far, I'm entirely on Myers side in this. It is not inciting hatred to say that someone's beliefs are nonsense. It is not inciting hatred to say that they're idiots for believing something ridiculous. It is not inciting hatred to damage a cracker.

It may be inciting ridicule, or scorn, or contempt. But so what? There's no opinion, belief, or practice that people shouldn't be able to treat with ridicule, scorn or contempt. Someone may fervently and honestly believe that the cracker in question is the actual body of their god. Who knows, David Icke may believe the nonsense he spouts as well. I'm also sure that plenty of Daily Mail readers believe the tripe printed in their paper. And I don't see why any of them should be exempt from having the piss taken or their beliefs mocked. No one should.

I completely fail to see why a religious belief is priviledged over any other belief (and there are plenty of far more eloquent discussions on this subject at Butterflies & Wheels than I can make). I see no difference at all between saying that the Bible is a dangerous book, stuffed full of appalling immorality, and providing a lousy guide for how to behave, and making the same statement about the Daily Mail or the Independant, say. I see no difference at all between saying that people are idiots for having religious beliefs and saying that people are idiots for being Tories, Greens, or Socialists.

I'm also with Dawkins in his point that it makes no more sense to talk about a Christian child than it does a Conservative child; both are systems of belief that people either absorb as they're growing up (and in many cases fail to throw off), or they're belief systems that they adopt as adults. In either case, it's a very different thing to an innate characteristic such as the colour of their skin, or their gender, or their sexual orientation, and certainly shouldn't be protected in the same way through anti-discrimination legislation.

Anyway, vent over. This blog shall now return to its normal program of sporadic posting on non-controversial subjects.

Friday, July 25, 2008 3:04:51 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 

I can't believe I got a couple wrong...

92%DRUNKARD
Created by OnePlusYou - Online Dating

Via Living the Scientific Life (Scientist, Interrupted)

Friday, July 25, 2008 2:20:16 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  | 
 Tuesday, July 01, 2008

Two different bands, two different sets, two very different atmospheres...

On Friday night V and I, and a couple of our friends, went to see Bon Jovi at Twickenham Stadium.  As you'd hope, it was very much a greatest hits set, kicking off with Living on a Prayer, and containing almost everything from the Crossroads greatest hits album.

Bon Jovi

Bon Jovi photo by beckygarratt

I couldn't say I was a huge fan; I know the obvious hits, and since V is a fan I'm getting to know more of the album tracks, but I could sing along with at least the choruses on easily more than half the set, so I was quite happy!

Even though I far prefer Springsteen as an artist, I'd have to admit that I enjoyed Bon Jovi's show even more that I did Bruce's last month at the Emirates: the sound was better, the stage set better and more interesting, and the setlist itself was better (even though I think Magic is a better E-Street album than any he's done for many years, it all seems a bit Bruce-by-numbers to me - give me the early stuff any day!).

And then there was last night.

Lou Reed.

Performing Berlin, in its entirety, at the Royal Albert Hall.

Berlin, Live

Slated on its release, Berlin has proved to be Reed's masterpiece, and its live performance lived up to every expectation I had.  I had wondered if it would be as moving and harrowing live as it is on record, and the sense of release after the cathartic ending of Sad Song let me know that it had been...  the rest of the audience seemed to agree with me: the performance earned a standing ovation.

At first I thought the sound was a bit on the politely-quiet side, but when the full band played that certainly wasn't the case.  Behind the band was a simple set (with greenish walls!), onto which was projected images and films to complement the music - so I now know what Caroline looks like.

Reed was joined by a huge band that included a 12-piece choir, 8-piece orchestra, his current touring band, and some faces from the past: Michael Rathke and Steve Hunter on guitar, Rob Wasserman on upright bass, Fernando Saunders on a selection of bass, and Tony "Thunder" Smith on drums.  Steve Bernstien and Jane Scarpantoni provided keyboards and backing vocals.

Berlin took about an hour to perform, and after a short break the band came back for an encore of Satellite of Love, Rock and Roll, and his new song The Power of the Heart (which can be downloaded over here).

Got to get the DVD when it comes out!

Lou Reed

Lou Reed photo by joshkritter

Tuesday, July 01, 2008 1:12:36 PM (GMT Standard Time, UTC+00:00)  #    Disclaimer  |  Comments [0]  |