OS X Lion and WLAN

It seems since my Lion upgrade my MBP has been randomly failing to connect to my wlan. This was fairly annoying and usually had me rebooting a good few times until it seemed to see the wlan network and connect, once connected it was fine, until the next time i booted the MBP or resumed from sleep. It would occasionally see the network in the wifi list, and when I clicked it would return a failure to connect, with 'connection timed out' error. Very useful! My iphone and other devices connect fine, also booting the MBP into windows works fine too, so looks like a Lion problem!

I didn't think too much of it, but today I received my Mac Mini and had exactly the same problem connecting that to the WLAN.

After a bit of digging I found this discussion, and some suggested it was to do with WPA vs WPA2 on 802.11n networks.

So, I swapped my Billion router from WPA/WPA2-PSK to WPA2 and now my MBP connects every time!

Crazy, it seems lion prefers WPA2 rather than WPA, but the shit error message it gives when it decides (randomly i might add) that it won't connect doesn't help diagnose the issue!

Windows Environment Vars for curl

After regularly forgetting these proxy env vars when setting up my machine to use curl, thought I'd post them here:




Either set the them in the advanced system settings control panel, or use the SET command at the command prompt.

Service Broker

If you want to clear all the messages from all queues in a database you can use the following SQL:


If the command fails its possible that there are open dialogs, so try this command:


Mercurial & a global ignore file

So I've been using mercurial for a while now, and each of my repositories has had it's own .hgignore file. After reading the hgrc/mercurial.ini docs I noticed that you can specify an 'ignore' setting in the [ui] section and point it at a file that all repos will use as an ignore file. Great! I only need a single ignore file now. So I set the value to:

ignore = "D:/source/hgignore.txt"

However, when running "hg st" it showed up all the files that should be ignored as missing from the repo. Seems hg wasn't loading the ignore file (and i had removed the file from the repo itself).

Turns out if there is any whitespace at the start of the path mercurial will ignore the file. Changing the line to:


allows the ignore file to be read by hg and it correctly ignores the files in my repository.

Setting up the command prompt

Since getting used to the terminal in ubuntu and on my mac, I have got used to using ls and ll and other unix commands, which by default don't work in the windows 7 command prompt.

Well, with a combination of a few applications, and some configuration I've got nicely coloured terminal output, and unix style commands in my windows 7 command prompt.

I use the fantastic Console2 application as my main console application, I've also installed ansicon which is an ansi escape sequence processor that helps to show the ansi colour codes in the command prompt. To enable the unix style commands I installed cygwin, and added the cygwin\bin folder to the system path environment variable.

If you run ansicon with the -i/-I parameter it will install itself into the command prompt by modifying the registry as follows, -i will modify HKCU and -I will modify HKLM:


"Software\Microsoft\Command Processor\AutoRun"

It will set the data property to the path to ansicon. These reg keys get run every time a command prompt is started. I moved the command to a bat file I created called "startup.bat", and replaced the data property with the full path to the bat file.

"doskey" is the command prompt equivalent of the unix "alias" command, it needs to be run at startup as well, and pointed at a file that contains the macros it should load. So that can go in the startup.bat file as well. The bat file looks like this:

"D:\Program Files\AnsiCon\x64\ansicon.exe" -p
doskey /macrofile="D:\Program Files\Console2\doskey.txt"

Then my macrofile looks like this so far:

ls=ls -F --color=tty
ll=ls -laF --color=tty
edit=notepad $*

It'll be easy to add more aliases into the doskey.txt file as I need them, or to add more commands to startup.bat as I need them too.


I edited the notepad line in the doskey file above and added the $* parameter, which tells doskey to pass whatever is on the command line that is not the macro name and has not been assigned to numbered parameters. Essentially it passes the rest of the command line to notepad so it will open the file you specify.

I also modified another registry key: HKCR\Directory\shell\cmd\command, and set the default value to "D:\Program Files\Console2\x64\Console.exe -d %1"

This changes the 'Open Command Window Here' context menu to open Console2 rather than the default command prompt.

Windows Home Server 2011 and RDP direct to desktop of the server

So I have gone back to WHS on my "EX485 HP Mediasmart Server" file server from Ubuntu, decided to try out WHS2011 for a while.

The install went smoothly, files have all been copied back over, and I am particularly impressed by the remote desktop gateway that tunnels the RDP connections over HTTPS.

One little problem is that when you rdp to the server it only takes you into the dashboard, and not directly to the servers desktop. This was 'worked around' in WHSv1 by editing an aspx file, but that approach doesn't work in 2011.

After using dotpeek to dig around in the rdp assemblies, I noticed that it is checking a reg value when it builds the rdp file, and if the value is not set (or is 0) it adds an app alias to the dashboard. The name of this value is "EnableServerRemoteDesktop". So, I opened reg edit and added a DWORD value at "HKLM\Software\Microsoft\Windows Server\RDP" with the aforementioned name, and set it's value to 1, and reconnected to the WHS machine from the remote web page.

This promptly connected me to the windows home server desktop, rather than the dashboard.

Thought I'd post this here, because it seems that most people that are asking this are being told that it's not supported and that they should open port 3389 through the firewall and rdp directly to the server... (or alternatively, rdp via the remote web site to a machine on the network, then rdp from there to the server).

I prefer this method because it means less ports open through the router, and also if you are behind a proxy/firewall you can still access the server desktop over https.


Recently I had been battling with adorners in WPF. I have a watermark service adapted from the code in this SO answer, which works great, adding watermarks to my text boxes.

However sometimes user controls that are shown above a textbox with a watermark on it would show the watermark above everything else, which became pretty annoying.

After some research with google and snoop, I discovered how adorners work, and the fact that when an adorner is added to an element, it is in fact added to the first adorner decorator up the tree, and because by default the adorner decorator is right at the top of the tree the adorners appear over everything.

The simple fix is to add an adorner decorator around the specific element with the watermark, that way the watermark stays with the element.

For example:

<AdornerDecorator Grid.Row="0" Grid.Column="1">
	<TextBox x:Name="UsernameTextbox" Text="">
			<TextBlock Text="Username"/>

Visual Studio 2010 Handy Hints

Discovered this today, I knew it could be done, but hadn't bothered to google for the right shortcut:

Ctrl-Shift-F12 - Navigate to the next error in the error list.


Arrgh! MouseEnter & MouseLeave with grid

Have been messing around with my wpf application today, specifically trying to animate a button's opacity when the mouse is over the whole user control that the button is in.

This is a relatively straightforward bit of xaml to build, however it worked almost as expected. The mouse leave event seemed to be triggered when the mouse was still over the user control's main grid, but only when it wasn't over any actual content. As long as it was over textblocks etc, it was fine. After some googling I discovered that the mouse 'drops through' if the element doesn't have a background. Set the main grid background property to transparent and "Hey Presto!" no more mouse leave events in the middle of my control.

Kris & Hayley's Wedding

Just got back to Sydney from a fantastic (but hectic) weekend in the UK at Kris & Hayley's wedding. Yes, you read it right, a weekend in the UK. I left thursday morning, and arrived early on Friday, spent the arvo with Andy H chilling in St Albans before Dave, Christy and I drove up to Belper.

Saturday was the day of the wedding, a fantastic day, it was a great service and reception, H's dad's speech was great, as were the best men's (there were 2 of em!), and as was Kris's, including an emotional and respectful toast to Stuart. Oh, and the weather was good too (if a little windy at times).

We were suited and booted, and I know that doesn't happen often for me, but I suspect even less so for Dave Dev, in fact, I can't recall ever seeing him in a suit... so here's evidence:


Here's H&K cutting their cake:

Here's a vid of H&K arriving at the reception:

After a quiet sunday recovering from my hangover, watching the grand prix (well the end of it anyway) and having a chat with James P who was camping with the family up near Ripley (in Codnor I believe, and if that's the case I'm surprised he didn't come back to find his car and his tent on bricks :) we headed back down to Christy & Dave's place ready for my flight back on Monday morning. We squeezed in a little curry at a local curry house, which was great!

Then it was the start of the long flight back (well shorter than when I came, as I messed up and ended up with a 6hr wait in Singapore on the outward journey), and I arrived back home at 9pm-ish on Tuesday, just managed to start the washing machine going before I nodded off.

It was well worth the trip back, and great to catch up with people who I hadn't seen for a long time. Although the travelling was pretty gruelling and I don't plan to do it again any time soon!

Thanks must go to my Sis and her hubby for spending the bank holiday weekend ferrying me up to Belper and back, I'll return the favour when you come over to Sydney, Christy :)