Friday, 30 May 2008

Pex

From one of the original creators of MbUnit comes Pex - automated unit test generation.

"Pex generates Unit Tests from hand-written Parameterized Unit Tests through Automated Exploratory Testing based on Dynamic Symbolic Execution"

I've read bits and pieces about Pex before, but now there's something to download.

Jeff Brown shows how you can use Pex with the latest Alpha release of MbUnit's Gallio test runner.

Thursday, 29 May 2008

Home Theatre PC (Components)

For a while now, I've been thinking about building my own Home Theatre PC (HTPC). I've got an unused Vista Ultimate license that I'd like to put to good use, and using it for a Media Centre fits the bill. While you can buy a prebuilt HTPC, but I thought it would be both fun and educational to build one from scratch.
There are a number of good resources when planning to build a HTPC, but I've found the most useful are:
After throwing around various combinations of parts I've come up with the following list:
CPU AMD Athlon X2 4850e
Case Antec Fusion 430 Silver (includes power supply)
Tuner Hauppauge HVR-2200
Fan Noctua NH-U9B Quad Heatpipe
Motherboard GA-MA78GM-S2H
RAM    Kingston (2x1G 800) KVR800D2N5K2/2G
Drive 1 3.5" HDD SATA-300 250GB 16MB Seagate
Drive 2 Western Digital 1TB (WD10EACS)
Keyboard Shintaro wireless
Remote Microsoft MCE Remote Control
DVD LG GGC-H20N/L Blu-ray/HD reader, DVD & CD writer
I posted this list to the forum (like a lot of others do) just to check it was reasonable.
The main criteria I've worked from are quiet operation (and hence 45W CPU) and provision for the future (high definition).
I made use of the Static Ice price comparisons to gauge what were good prices. If I lived in Sydney I'd probably buy most of the bits from IT Estate, however once you factor in shipping, the local retailers MATS Systems and MSY are pretty competitive.
I was originally planning to get the Pioneer BDC-S02, but opted for the cheaper (and in-stock) LG instead.
The other curious thing is that we've got a very old TV that used to belong to my parents - an early 1980's Philips model that only has an RF (aerial) socket. Not exactly what most home theatre systems are made of, but it works, and I'd prefer not to have to replace it before it completely dies!
So my plan is to use a cheap video card (a Gigabyte 8400GS 256MB GV-NX84G256HE) that unlike the onboard video has a TV-OUT socket, and use an RF Modulator to convert that to something the TV should like. If that fails, then maybe we'll just have to buy a new TV.
Once I've purchased all the components, I'll post an update on the build progress.

Tuesday, 27 May 2008

New workplace checklist

There's nothing like changing employers (eg. leaving UniSA for the world of contracting) to make you realise there's lots of things you need to (or should) know, either before you start or very soon after.

Each workplace is different - some things will be common (eg. provision of toilets!), but there can be differences or variations.

In no particular order, here are some things that came to mind:

  • Where is the light switch? Especially if you are the first to arrive and it's still dark!
  • Where are the toilets?
  • Are there shower facilities? Essential should you wish to ride to work.
  • Speaking of bike riding, is there somewhere you can leave your bike (and smelly bike clothes)? Sheltered and secure would be nice.
  • What kind of workstation will you have? How many monitors, processors/cores, RAM, Vista or XP, etc.
  • Are tea and coffee provided?
  • Is it family friendly - specifically do they accommodate flexible work hours? Handy if you need to pick up or drop off kids.
  • What facilities (shops, banking, food) are close by?
  • Does a "social" culture exist? Are there morning/afternoon teas, birthday celebrations, team lunches, sporting or interest groups, movie nights, barbecues, etc.
  • Do your workmates have a sense of humour? Do they appreciate yours!
  • Is occupational health and safety taken seriously? Is the non-obvious boiling water tap in the kitchen appropriately labelled, or is it a scalding accident waiting to happen!
  • What is the most common form of communication - face-to-face, email, IM, phone, pigeons? If not face-to-face, how quickly do people respond - immediately, within the hour, next day, etc.
  • Are workmates encouraged to give "read" access to their calendars so you can easily find where people are, or is there some other facility (whiteboard, in/out board) used to indicate where someone is.
  • Do you know what to do if there's an evacuation or you need first-aid?
  • Where is the fax machine and the printer?
  • Is there full or restricted access to the Internet? Are there  restrictions on using IM, Skype etc.
  • Are there extra duties or rosters you are expected to fulfil? Washing dishes, cleaning the fridge, buying the milk.
  • Is there a helpdesk? And do they actually help!
  • Can you make STD (interstate) or mobile phone calls from your office phone?
  • Is it generally safe and secure? Can you leave your wallet on your desk and expect it to be there later.
  • Is there an ID card or sign-in process to control physical access?
  • Can you work remotely or do they expect you to be physically in the office? If working remotely, what security requirements need to be met to connect into the work network.
  • What's the car parking like and how close is it to public transport?
  • Where is the stationery cupboard?

Can you think of anything else I've forgotten?

Thursday, 22 May 2008

Amelia is home

Ashford Hospital have a scheme called "Baby Bliss" where you can transfer to the Adelaide Hilton and finish your hospital stay there. They provide a midwife onsite, but it's only suitable for mothers and babies that are doing really well and don't require other medical attention.

View from our hotel room across Victoria SquareWe found out on Saturday that the Doctors were happy for us to take this up, so that night the five of us spent our first night together as a family. The older kids enjoyed the experience - watching the trams and the fountain in Victoria Square from our room, Chinese takeaway and breakfast at the Pancake Kitchen. Narelle particularly enjoyed the room service (which is included for the mother).

 

Amelia asleep on the couchMonday morning Narelle and Amelia were able to come home. Narelle is recovering quickly and Amelia is feeding and sleeping really well. She's also doing the other thing that babies do a lot of as well :-)

I don't plan to blog anymore about Amelia at this stage. I prefer to be cautious about publishing details of our kids online (I know there are people out there that would misuse this information). When they're old enough I'll let our kids make that choice themselves.

Thursday, 15 May 2008

Amelia Jane Gardiner

I'm extremely proud to announce the birth of our third child - Amelia Jane Gardiner. She was born yesterday morning at Ashford Hospital, weighing in at respectable 7lb 4oz (in the old money).

David holding Amelia

Narelle and Amelia are both doing very well.

Amelia with her big brother and sister

Tuesday, 13 May 2008

ADO parameterised queries and return values

Back before ADO.NET, we used good old ADO to do our data access in our ASP pages. To improve performance and avoid SQL injection attacks, it is good practice to use parameterised queries or stored procedures. Usually these are interchangeable but I've noticed today that ADO throws up the following error if you try and set up a return value parameter:

Microsoft OLE DB Provider for SQL Server error '80040e21'

Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.

For example, the following code gives that error:

Set Cmd = Server.CreateObject("ADODB.Command")
Cmd.ActiveConnection = conn

Dim ParamReturn
Set ParamReturn = Cmd.CreateParameter("Return", adInteger, adParamReturnValue)
Cmd.Parameters.Append ParamReturn
Cmd.CommandText = "INSERT INTO table (col1) VALUES (?); RETURN SCOPE_IDENTITY()"
Cmd.CommandType = adCmdText

Cmd.Parameters.Append Cmd.CreateParameter("p1", adInteger, adParamInput, , "value")

Cmd.Execute 

I haven't found any solution, other than to use a stored procedure instead. Presumably return values aren't supported for plain parameterised queries, though I haven't seen that documented anywhere (yet).

Friday, 9 May 2008

GMail contacts and Thunderbird

For a while now I've been using the Sync Kolab extension for Mozilla Thunderbird to synchronise changes to the Thunderbird Address Book.

This works quite well, but it only synchronises with other Thunderbird sessions. What I really wanted was to use the Contacts from GMail and synchronise with that. That way, whether I'm using Thunderbird, or just the GMail web interface, I'll have the same details available for all the people in my contacts list. The problem is that Google hadn't provided an API for accessing the Contacts data, but that all changed last month.

The good news is that Zindus are already working on a new extension for Thunderbird to synchronise with Google Contacts. I plan to try this out very soon.

There's also support for the Contacts API in Google's .NET Client Library, should you wish to use this in a .NET application.

SQL 2008 Reporting Services renderers

Yesterday I caught Keith's talk on new features in SQL Server 2008 Reporting Services at the monthly meeting of the Adelaide SQL Server User Group. I must say, as someone who's only just started using the original SQL 2000 Reporting Services a few weeks ago, I was drooling at the pretty new designer. Not to mention the new features and enhancements. Very nice!

Talking with my DECS colleagues this morning, the question of renderer support arose. Specifically will 2008 natively render reports as a Word document? (I understand that to do this previously, you needed to purchase 3rd party addins)

Turns out the answer is "Yes!". As of the February 2008 CTP, the following renderings are supported:

  • Windows Forms
  • Web Forms
  • CSV
  • XML
  • PDF
  • Image
  • Excel
  • Word

More details of the new features (grouped by CTP release) are published on the SQL Server 2008 TechNet site.

Thursday, 8 May 2008

Tech-Ed 2008 Registration

Chuck mentions that the Australian Tech-Ed 2008 conference site is now live. Not sure if it's a firewall issue, but I tried clicking on the 'Register Now' link, and it doesn't work.

The only time I've missed attending in previous years was when family commitments coincided (eg. birth of children). That's also why I decided I wouldn't travel to Wagga for this year's CodeCampOz - the timing was too close to the due date for G3, and I didn't want to risk being stuck in regional NSW should my wife suddenly go into labour!

The other big difference is that previously I had the support of my work paying for registration, travel and accommodation.

So if I did attend this year I'd have to cover the costs all by myself. $AU1,749 just for early-bird registration sounds like a lot of money, especially when it's your own!

One thing at a time though. G3 is due next week, so by mid-June I might have a clearer idea of whether popping off to Sydney in early September is a good idea (or not!)

Wednesday, 7 May 2008

Converting minutes from midnight

Jane asked me how to convert "minutes from midnight" into hours and minutes in Excel.

Turns out the TIME() function can do this for you.

Say you have 585 minutes. Use it like this:

=TIME(0, 585, 0)

Then format the cell for time, eg. "h:mm", and you get

"9:45 AM"

Just what the doctor ordered!

Before you ask, no I'm not an Excel expert, but I am pretty good at knowing where to find the answer most of the time.

Tuesday, 6 May 2008

Hotmail rejecting forwarded email

I've been using ZoneEdit to manage the DNS for our domain gardiner.net.au with reasonable success. About the only problem I've had is every few months, I'd discover that email sent to my wife's Hotmail account (via her @gardiner.net.au address) is rejected with a message like the following:

<xxxxxxx@hotmail.com> (expanded from yyyyyyy@gardiner.net.au): 
host mx4.hotmail.com[65.54.244.232] said:
550 SC-001 Mail rejected by Windows Live Hotmail for policy reasons.
Reasons for rejection may be related to content with spam-like characteristics or IP/domain reputation problems. If you are not an email/network admin please contact your E-mail/Internet Service Provider for help. Email/network admins, please visit   http://postmaster.live.com for email delivery information and support (in reply to MAIL FROM command)

To their credit, the Live Hotmail guys are pretty quick off the mark to resolve this once you submit a request via their support page.

I think the problem is that because ZoneEdit hosts so many domains, some of those turn out to be used (or hijacked) by spammers, and so inevitably their IP ranges end up on spam black lists. ZoneEdit don't have any SPF records for their mail servers either which probably doesn't help.

So tonight I bit the bullet, and signed up with Google Apps to manage the mail for our domain. I'm hoping that pointing my MX records to Google will mean that things all look legitimate when Hotmail goes to verify that the domains match up with the SPF record.

Signing up was pretty straight forward. After verifying that I control the DNS records, I added accounts for all the people who have @gardiner.net.au email addresses, then logged in and configured their email to forward to their preferred address. There's even a 'test' email address so you can try things out before you update all the MX record information.

We'll see if this turns out to be a good idea or not.

Book prices

I recently ordered MCPD Self-Paced Training Kit (Exam 70-547): Designing and Developing Web-Based Applications Using the Microsoft .NET Framework from Amazon and it cost me about $AU 60 (including postage).

MS Press have just launched their Australian web site, and the same book is listed as $AU 120. Dave Glover mentions that user group members can get a 50% discount, but only for this month. So for this month at least they are comparable.

It isn't just MS Press though. I've seen other Australian booksellers listing this same title at equally uncompetitive prices. About the only reason you'd buy local is if you didn't want to wait a couple of weeks for Amazon's standard delivery to arrive.

Certainly, the Australian dollar is very high at the moment, so that helps with the exchange rate, but I still don't get why there's such a huge price difference.

Monday, 5 May 2008

Ready, Steady, Code

Once or twice while I was on leave recently, I happened to have the TV on during the daytime. One of the programs that was on was Ready, Steady, Cook (originally a BBC show apparently).

The basic format of the show is as follows:

  • In the first half, two chefs (each with a regular assistant) create a meal from some random ingredients that they haven't seen before.
  • The audience then votes on the completed dishes.
  • The second half sees both chefs then suggest a meal from another lot of ingredients, but this time the audience votes on which idea they like the best. Then both chefs work together to make that meal.

So what I was thinking was whether you could adapt this format to a user group setting?

Have two teams (ideally with two data projectors so the audience can see what they're doing), and give each of them 3-4 random technologies and they have to come up with an application that uses all of them in a fixed time period.

At the conclusion the audience can vote on which they think is the best.

You might need a little more time, and the audience could get involved shouting out suggestions if they get stuck.

Thursday, 1 May 2008

Ordering data using dynamic SQL versus temporary tables

Here's a scenario that's not that uncommon:

You have a query and the user wants to be able to choose at run-time which column to sort/group by.

The problem is you can't use a variable to indicate the column name in the ORDER BY or GROUP BY clauses.

If the query itself is very simple, then you could just repeat the query with specified ordering using IF. eg.

IF (@order = 'Column1')
SELECT * from Table1 ORDER BY Column1
ELSE IF (@order = 'Column2')
SELECT * from Table1 ORDER BY Column2

If the query is non-trivial, you probably wouldn't want to use this however, as maintenance becomes problematic.

There are two obvious solutions to this:

Dynamic SQL

Assemble the query into a varchar variable and then execute it using sp_executesql.

DECLARE @sql varchar(4000)

SET @sql = 'SELECT * FROM Table1'

IF (@order = 'Column1')

	SET @sql = @sql + ' ORDER BY Column1'

ELSE IF (@order = 'Column2')

	SET @sql = @sql + ' ORDER BY Column2'

sp_executesql @sql

Temporary Tables

Split the query into two parts. First of all, retrieve the data into a temporary table (this is one of the few times you can't use a table variable). Next, use the original IF .. ELSE IF method to return the data from the temporary table.

SELECT * INTO #Stuff FROM Table1

IF (@order = 'Column1')
	SELECT * FROM #Stuff ORDER BY Column1
ELSE IF (@order = 'Column2')
	SELECT * FROM #Stuff ORDER BY Column2

So which is better? Great question, and I'm not really sure of the answer. I suspect it could well be "it depends".