I’m just not cool enough for tumblr, so I finally got around to sorting out a “proper developer” blog hosted on github using the amazingly effective jekyll (http://jekyllbootstrap.com/).
Hope to see you there!
Formatting those sql_exec profiler outputs..
I was debugging some long running queries the other day, using SQL Server profiler (BTW - here is a very decent free equivalent of this for those of you using SQL Express - which doesn’t come with the profiler: https://sites.google.com/site/sqlprofiler/)
Anyhoo, one thing that has always been a pain for me is that the output you get from a sql_exec command - which is how most ORMs execute SQL against the database. Take this example command:
exec sp_executesql N'SELECT [t1].[CableSweepChangeId], [t1].[FrontEndId], [t1].[FrontEndPortNum], [t1].[IncomingTime], [t1].[Description], [t1].[ChangePoint], [t1].[OldLength], [t1].[NewLength], [t1].[EquipmentId], [t1].[DataLinkStateChange], [t1].[IsLink], [t1].[IsConnection], [t1].[IsLaptopChange], [t1].[EquipmentPortNum], [t1].[EquipmentName], [t1].[CableId], [t1].[CableLabel], [t1].[InstallType], [t1].[ConnectionSide]
FROM (
SELECT ROW_NUMBER() OVER (ORDER BY [t0].[IncomingTime] DESC) AS [ROW_NUMBER], [t0].[CableSweepChangeId], [t0].[FrontEndId], [t0].[FrontEndPortNum], [t0].[IncomingTime], [t0].[Description], [t0].[ChangePoint], [t0].[OldLength], [t0].[NewLength], [t0].[EquipmentId], [t0].[DataLinkStateChange], [t0].[IsLink], [t0].[IsConnection], [t0].[IsLaptopChange], [t0].[EquipmentPortNum], [t0].[EquipmentName], [t0].[CableId], [t0].[CableLabel], [t0].[InstallType], [t0].[ConnectionSide]
FROM [CableChangeDetail] AS [t0]
) AS [t1]
WHERE [t1].[ROW_NUMBER] BETWEEN @p0 + 1 AND @p0 + @p1
ORDER BY [t1].[ROW_NUMBER]',N'@p0 int,@p1 int',@p0=0,@p1=15
Now, if I want to tweak this or play around with it, it’s not much fun having it in this format.. I would prefer it in a format with all those params as DECLARE statements at the top. Which is why I wrote, and present to you now….. SQLEXEC FORMATTER!!!
And here it is in action.

At the moment the copy to clipboard button is a bit bad at formatting the text, but I’ll sort that one day, and you can always just copy the text manually.
Enjoy!
Test post from live writer…
Well this is a very dull post, I’m simply trying to post to tumblr from live writer. That is all.
WCF and netTcpBindings
Is it just me that hates the way that WCF seems to break if you just look at the config file the wrong way?
Anyway, after spending a couple of hours fighting with WCF trying to get it to work with netTcpBindings, I thought i’d share this blog post with some tips on what to check:
http://goneale.com/2010/04/01/error-connecting-to-was-enabled-net-tcp-wcf-service-hosted-through-iis/
I’d pretty much done everything in this list except enable ” Windows Communication Foundation Non-HTTP Activation ” in windows features. After I found that and enabled it, and then fixed the port bindings (it will revert your tcp port bindings back to the default of 808), all was working well for me in WCF land once more. Hooray.
PS: If you do tick the non-http activation, and you already have .net 4 installed on your system, and you need to make use of the wcf from a web application using .net 4, then you’re going to hit some more problems and you’ll need to re-register .net 4 with iis - see http://blogs.iis.net/webtopics/archive/2010/04/28/system-typeloadexception-for-system-servicemodel-activation-httpmodule-in-asp-net-4.aspx
I found this post really refreshing, since I’ve been guilty of blindly following what is deemed to be best practice without fully understanding why I was doing it. Well worth a read.
Something I’ve been playing with and decided to release into the wild - this little site and API attempts to give you a postcode from a lat/lon location. The geo-location side of it can be a little off, since it all depends what you’re using to access the site.

It was fun to create technically, I used node.js with Express (although in hindsight Express was overkill), and I store all the UK postcodes with their lat/lon location in a hosted mongoDB database (with MongoHQ). MongoDB has some handy Geospatial features that made this all a doddle.
Hopefully it’s useful to someone out there!
Zombies Oh My Zsh!
I was at Preston Geekup last night last week and came across a very nice looking terminal on Martin Rue’s mac. Turns out he was running zsh, and “oh my zsh” for additional functionality and themes.
I decided to check it out, and now I’m totally hooked on zsh, theres no going back to bash for me. As a total scripting n00b, I can’t comment on how well it does or doesn’t make scripting easy, but I can comment on the nice looking interface you get with the combo of zsh and oh my zsh:

Pretty nice right? As well as the multi-coloured prompt, it’s telling me that I’m using git in the current folder, and that I’m on the master branch. Nice! That all comes from the oh-my-zsh project. As for zsh itself, so far I can say I’m loving:
- That tab-complete lists commands not only in the current folder (e.g. mv<tab> would bring up mvim)
- That it tries to correct my many spelling mistakes (type lls, it asks if you meant ls. Type sl, it just does an ls anyway!)
- Secondary tab completion (Type brew install <tab>, it will list all avail brew tools, and you can even scroll through them all - sweeeet!)
That’s all I’ve discovered now, I’m sure they’ll be loads more.
Now, back to the day job, on windows, with no zsh. Sigh.
Some Node.JS resources
I’ve been messing about with node.js a little bit recently and thought i’d post some of the resources I found particularly helpful, in case anyone else finds them of use
Then I realised that Stack Overflow probably had this covered, and sure enough:
The only thing I’d add that isn’t in there is Eloquent Javascript
Go here and grab the torrent for some pretty good sessions recorded at the Norwegian Developers Conference. That is all.
Ayende and _that_ Microsoft N Layer App Sample Architecture.
Ayende has finished with his review destruction of the domain oriented n-layered .net 4 sample app (http://microsoftnlayerapp.codeplex.com/)
Well worth a read if you have time - the last in his series of reviews can be found here. In it, he summarises with this advice:
I can’t emphasize this enough, avoid this codebase, don’t look at it, and never try to follow anything shown there, it will end in tears, pain and suffering.
No sitting on the fence there then :) Mostly I agree with the comments Ayende makes in his posts - this architecture says all the right things, and makes all the right noises, but in the end it looks rather like a good example of architecture for architectures sake. Without a good discussion of the context of the problem and why the various architecture pieces were chosen, and the benefits they bring to the codebase versus the downside of further complicating the architecture, it falls short. That said, I’ve not checked the “updated” version of the guidance, so perhaps they’ve addressed a lot of these issues…
Anyway, I found it to be a useful exercise to read through Ayende’s reviews, and check that I wasn’t doing any of the things he was talking about :) Luckily I wasn’t, although I have plenty of problems with my own architecture that I’m sure Ayende would point out if he ever got hold of my code :)