Too many MSDN DVDs?

Much that I don’t like rocking the boat, I have to admit, I agree with Phil’s comments about excess MSDN language content DVDs. It seems that most of us here in the UK have an MSDN DVD mountain -Phil has a good photograph to demonstrate this!

I’d like to see the money that could be saved being ploughed into UK Community Events, perhaps being used to purchase 8 * HDD camcorders for community use? (such as this, or this, or this)

Technorati Tags: , , , , , , , ,

006 – Community Podcast – DDD5 – Mike Scott – Gary Short

In this, the sixth Community podcast, I spend a few minutes chatting to DDD5 attendee Mike Scott and DDD5 speaker Gary Short. We discuss the worth of DDD as an event and we think about getting AutoCAD out to redesign the Memphis room to make it bigger.

Download the podcast here. Transcript to follow.

I have a new podcast feed available too, you can subscribe to it here – and it works with Apple’s iTunes!

Related posts:
Podcasting – great advice
001 – Community Podcast – Dave McMahon, NxtGenUG
002 – Community Podcast – Ravi Nar – VistaSquad
003 – Community Podcast – Guy Smith-Ferrier – DotNetDevNet
004 – Community Podcast – Barry Carr, Gary Short, Hamish Hughson – North East of Scotland User Group
005 – Community Podcast – GeekDinner/DDD5 – Adrian Sutcliffe

Technorati Tags: , , , , , , , ,

The Power of Regular Expressions

I have been a fan of regular expressions for a long time now.

Regular expressions provide a concise and flexible notation for matching and replacing patterns of text within a body of text. Some might say that regular expressions are concise and cryptic, perhaps because most regular expressions are built from a combination of metacharacters such as ^$*+?. The actual regular expression itself is known as a pattern.

They are, in my opinion, very much underused. Perhaps they are a visual turn off? After all, looking at this regular expression…


…and it’s no wonder people don’t use them as much as they should.

However, there is a plethora of good web-sites that list common regular expressions thus relieving us of the need to type them in manually. Equally there are many good tools that will help us build regular expressions using a pleasing visual interface…after which it’s typically a matter of cut’n’paste.

A few months ago I had to write a little application that scraped the HTML that makes up a web-page. I needed to extract all the e-mail addresses that were in the HTML – it was all legit, the e-mail addresses were made available to registered organisations (of which we are one) – it was just a shame that the sheer number of e-mail addresses didn’t lend itself to a mailshot. That was, until I wrote a few lines of code that used a pre-defined regular expression to extract all the e-mail addresses, formatting them nicely on the way.

The application worked by asking the user to paste the HTML source code from the web-page that contained the e-mail addresses, albeit they were embedded withing anchor tags. The user could then run the regular expression over the HTML source code – a treeview of the matches appears on the right-hand side and a neatly textbox appears at the bottom. Here’s a screenshot of the application:

Here’s the source code:

[code lang=”C#”]

using System.Text.RegularExpressions;

namespace HTML_Scraper
public partial class Extractor : Form
public Extractor()

private void btnProcess_Click(object sender, EventArgs e)
Boolean found = false;
lblMessage.Visible = false;

Match m;

Regex r = new Regex(tbRegEx.Text,
| RegexOptions.CultureInvariant
| RegexOptions.IgnorePatternWhitespace
| RegexOptions.Compiled


this.Cursor = Cursors.WaitCursor;

for (m = r.Match(tbSource.Text); m.Success; m = m.NextMatch())
if (m.Value.Length > 0)
found = true;
tvTree.Nodes.Add(“[” + m.Value + “]”);

if (tbOutput.Text.Length > 0) { tbOutput.Text = tbOutput.Text + “, “; }

tbOutput.Text = tbOutput.Text + m.Value;

int ThisNode = tvTree.Nodes.Count – 1;
tvTree.Nodes[ThisNode].Tag = m;
if (m.Groups.Count > 1)
for (int i = 1; i < m.Groups.Count; i++) { tvTree.Nodes[ThisNode].Nodes.Add(r.GroupNameFromNumber(i) + ": [" + m.Groups[i].Value + "]"); tvTree.Nodes[ThisNode].Nodes[i - 1].Tag = m.Groups[i]; int Number = m.Groups[i].Captures.Count; if (Number > 1)
for (int j = 0; j < Number; j++) { tvTree.Nodes[ThisNode].Nodes[i - 1].Nodes.Add(m.Groups[i].Captures[j].Value); tvTree.Nodes[ThisNode].Nodes[i - 1].Nodes[j].Tag = m.Groups[i].Captures[j]; } } } } } } if (found) { tbOutput.SelectAll(); Clipboard.SetText(tbOutput.Text); lblMessage.Visible = true; } this.Cursor = Cursors.Default; } private void btnGetText_Click(object sender, EventArgs e) { tbSource.Text = ""; tbSource.Text = Clipboard.GetText(); } private void textBox1_TextChanged(object sender, EventArgs e) { btnProcess.Enabled = (tbSource.Text.Length > 0);

private void btnEmail_Click(object sender, EventArgs e)
tbRegEx.Text = @”([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})”;

As long as you don’t get too boiled down in the actual regular expression itself, the code is fairly self-explanatory.

A simple example
Consider the following strings: A123, 234, C456. I’ve deliberately missed the ‘B’ from the second string.

It would be useful to be able to scan these strings to pick out strings similar to A123, i.e. an alphabetic character, followed by some numeric content. Alphabetic characters are represented using character sets enclosed in square brackets. Assuming the alphabetic character was allowed a range of A through to Z, we could represent this set like this: [A-Z]. Numeric sets work in the same way; the range 0 to 9 is the pattern [0-9]. Thus given the pattern [A-Z][0-9]+, we can match the two strings A123 and C456.

If we augmented the strings to be A123, B234, C345, we could use the pattern [A,C][0-9]+ to match A123 and C345, to give us the same result.



Via Search Engines:


Technorati Tags: , , , , ,

UK credit card marketing

If you live in the UK you’re probably quite used to receiving junk mail. For me, and I know that I’m not alone here, a lot of the junk mail I get emanates from credit card providers. It seems that everybody else’s credit card is better than the one I have currently. There’s the usual carrot and stick, offers of 0% interest for 12 months (longer with some of the more desperate providers), cashback or famous-name High Street store vouchers, etc.

I don’t like naming names, but Capital One would appear to be the worst culprits. I think it was one of their envelopes that has a return address on the back of it – it has a disclaimer stating that a fee will be charged if the item is returned. I find that astounding, albeit I won’t be paying the fee, whoever attempts to deliver it will probably have to, and even then it’ll be very much subject to a response of “two fingers“, “up yours” or “not on your nelly” from the person attempting the return delivery. This weekend, I spent many hours in my study clearing out old magazines, old mail, etc. I lost count of the number of Capital One envelopes that I had to process. I say “process” because I had to open each one – there’s a plastic replica of the “credit card you could have” inside most of the envelopes. My shredder doesn’t like plastic, nor does my paper recycling facility.

Now this presents another problem: a large proportion of the general public will probably just throw the whole envelope in to the general trash. This then opens them up to possible identity theft. This has negative effects for both the individual concerned and the credit card company. Granted, in order to successfully apply for a credit card you do need more information than is present on those forms the credit card company pre-print for you, but it’s a start. The prospective credit card company have essentially established a relationship with you by pre-printing some information on the forms. By making it as easy as possible for you complete the form, they are of course hoping to get you to sign on the dotted line and join their debt mountain.

What’s the solution? Well, I believe that the credit card companies should pull together and rationalise their junk mailings. They should offer their own Mailing Preference Service – and we should be able to register with our current credit card provider. This would mean a huge reduction in the amount of pure junk mail that is sent around the UK and as a side-effect, will see a very small reduction in indentity theft and case of credit card fraud. This approach does have a downside: our current credit card providers will have to wise up and offer existing customers better deals. Existing customers get it in the neck: rarely do they get preferential APRs or 0% offers. But at least they would get to keep their customers, and that has to be a good thing, surely?

Technorati Tags: , , , , , , , , ,

Advert overload?

I came across a .net related site today, content was pretty good…after I got through all the adverts:

Without checking, I think that there are too many Google AdSense blocks on the page, I’m sure it’s limited to three per page.

Hint: the yellow bits were part of the site content.

Just to stay in keeping, here’s my gratuitous ad block:

Technorati Tags:

Opening the .net Command Prompt Programatically

In a recent forum posting, I found myself writing some code that would open the Visual Studio 2005 Command Prompt (C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat). Once opened, the command prompt had to accept command-lines, just as if they were typed in by the user…except in this case it had to be under program control!

I’m sure that there are many ways of doing this, but here’s what I ended up with:

[code lang=”C#”]
using System.Diagnostics;
using System.IO;

namespace Cmd
public partial class Form1 : Form
public Form1()

private void button1_Click(object sender, EventArgs e)
string sProcess = @”C:\windows\system32\cmd.exe”;
string sParam = @”C:\Program Files\Microsoft Visual Studio 8\VC\vcvarsall.bat”;
string cmd = String.Format(” /k {0}{1}{2} x86″, “\””, sParam, “\””);

Process p = new Process();
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;

p.StartInfo.FileName = sProcess;
p.StartInfo.Arguments = cmd;

System.IO.StreamReader sOut = p.StandardOutput;
StreamWriter myStreamWriter = p.StandardInput;

myStreamWriter.WriteLine(“dir”); // Your command line, MSBuild, etc.



I’ve left the call to MessageBox.Show() to make you aware of the output.

Technorati Tags: , , , , , , , , ,

8 things about me…that you don’t know already…

Former MVP, now Microsoft DPE, and good buddy, Dan Moth has essentially blog-tagged me – I need to think up eight random things about me (that you don’t already know). Another good buddy, Gary, got me too. So here are 8 things about me. I hope these are new to you.

1. Like Dan, I too am a Metallica fan. But, you already knew this. But it’s unlikely that you’ll know I’m also a long-standing Magnum fan.

2. Like Dan, I too was tempted to kill off this almost viral-like meme/tagging thing. It’s difficult thinking up random things that folks don’t know about me. Like this one: I believe in a world where money isn’t required. It’s unlikely to happen in my lifetime, or even my son’s lifetime, but I’m sure it will happen. Let’s face it, a lot of things in Star Trek become reality sooner or later.

3. I crave tidiness, but I am, at the moment, one of the most untidy people I know. I believe this is due to the fact that I tidy in small pockets of time – I really should “take a week” and do it all in one go.

4. Related to 3 above, I hoard things. “That’ll come in useful one day”. The situation has improved recently: I cull my computer-related magazines very frequently now, perhaps because we have the facilities to recycle more and more – for example, we have a regular trash container, two paper/cardboard recycle containers and as of yesterday, we have containers for plastics and cans/glass.

5. Despite 1 above, I do like late-80s, early-90s dance, electronica, old-skool and trance music. I don’t know why. It’s good to work and drive to. Many years ago, I was driving to work, the tunes were “up there”, the speakers were replicating the bass to perfection (thanks to a proper acoustic MDF parcel shelf, a Kenwood amp and a pair of 6×9 JBL speakers), the sun was shining, it was a clear day…I nearly didn’t go to work, wanting only to continue enjoying the drive! There was a Sony headunit and an autochanger cunningly installed in the glovebox.

6. Despite 5 above, I have a cassette unit in my current car! On days when I don’t take the train, I spend up to 2 hours per [working] day in my car and find myself listening to the likes of Chris Moyles and Scott Mills on BBC Radio 1. Whatever you may think of those shows (and BBC Radio 1 in general), I like them and will continue to listen to BBC Radio 1 until I feel that I’m old enough to progress to BBC Radio 2 or 4 (I believe this is the natural progression from folks who are 15 years my senior). Radio’s a funny beast. I find myself listening to it whilst travelling, either in the car or whenever I’m on a train that doesn’t have an overly protective cocoon that blocks basic forms of radio transmission (Virgin please note). By virtue of this listening habit, I have a listening pattern: I tend to listen to Chris Moyles, Scott Mills, Jo Whiley, Vernon Kay and Sara Cox. Rarely do I find myself the other shows, because of the time I travel. I rarely find the peace and quiet required to turn the radio on at home, which is a shame because there are plenty of other great shows on BBC Radio 1. If you don’t believe me, go listen for yourself.

7. Despite 1 and 5 above, I have a reasonable collection of classical music and do listen to Classic FM – it’s tuned in to speed button number 2 on the car stereo. As you might imagine, BBC Radio 1 is tuned in to speed button number 1!

8. I would like to emigrate and work [from] abroad. Most of what I [really want to] do can be done from anywhere thanks to the power of the Internet. This would negate commuting and the downtime of having to fit in with a 9 to 5 working day. I’m a creative type, I can’t turn creativity on such that it’s there between certain hours. It takes many hours to for people like me to reach a state where creativity is found…for me, that happens between 0000 and 0400 – at which point I’m tired because I have to get up at 0630 for the 9 to 5 shuffle. But, unless I really push myself, it’s unlikely to happen.

Who’s next? Must I really propagate this thing? I guess so, otherwise some nasty stuff will happen to me…at least that’s what Dan told me when he dropped me an e-mail reminding me my obligation to write something. So here goes:


Technorati Tags: , , , , , , , , , , , , , , , , , , , , ,

UK Pensions – State of the Nation

I received a letter from the company that I am hoping will be able to provide me with a pension later in my life. I was a little bit stunned by its contents. Here’s a snippet:

I’m a little worried that the procedures required to prevent such an error were not already in place. It begs the questions: what other procedures are not in place and what other mistakes could happen? And given that this is an illustration of what I might get from my fund, how do they know that it’s precisely 15% higher than it should be? And why should I really care? After all, they could have corrected this supposed error over the course of the next 20 years and I would have been none the wiser.

Frankly, the UK’s pension industry seem to go out of their way to confuse and baffle the general public (of which you and I are members). They [the pension providers] make transfers between policies and providers either impossible or very costly, frequently citing government regulations for their inflexibility and inability to honour the customer’s requests. Since we are no longer in a job-for-life culture, this means most of us have at least one pension fund for each job that we’ve had. I’ve given up trying to consolidate some of the small pension funds, every time I’ve tried: no can do.

The UK pension providers and those who are responsible for writing the government legislation behind the crazy rules that make the pension industry so rigid, so inflexibile and so incapable, really need a rocket up their backsides to make them realise how daft they’re being. They’ve created a real mess with today’s pension industry. Either they realise this and go about sorting it out, or they should hand over their operations to some folks who do know what they’re doing (although, I can’t say that I know who those folks might be, sorry!)

Perhaps I’ll just have to hope that I win the lottery or the premium bonds?

Technorati Tags: , , , ,

Scottish Developers – User Group Event – voting required

Author of .NET Internationalisation, Guy-Smith Ferrier will be coming to Scotland in October!

If you are interested in seeing any of the sessions below, please let us know by voting here. Session abstracts are available at the aforementioned link.

Microsoft Codename “Astoria”
10 Things To Know Before Internationalizing An Application
Internationalizing ASP.NET
Internationalizing ASP.NET AJAX
How To Give Great Presentations
Internationalizing WPF Applications
Automating Testing With Virtual Server 2005
Visual Studio 2005 IDE Tips and Tricks
Replacing Reflection With Introspection
Introduction To Windows Workflow Foundation
Exception Handling Strategies In Windows Vista (Using Windows Error Reporting)
Planning Your Internationalization Strategy
Using ClickOnce and XBAPs To Deploy Windows Forms and WPF Applications
Deploying Internationalized Applications Using ClickOnce
Creating Custom Cultures
Writing Custom FxCop Rules

Technorati Tags: , , , , , , , , , , , , , , , , , , , , ,

July 23 – Jeff Barr, Amazon Web Services Talk – Glasgow


Monday, July 23, 2007 5:00 PM to 7:00 PM BST

Strathclyde University, Graham Hills Building, Room 5.14
Richmond Street
Glasgow, Glasgow City G1 1XQ
United Kingdom

Jeff Barr, Senior Manager at Amazon Web Service Evangelism will talk about Amazon Web Services.

More details can be found at

There are a MAXIMUM of 100 places available, so please book at by clicking the “I’m Going” button !

Cost: Free!

Google group:

Technorati Tags: , ,

Vista – Automatic updating

This morning I was greeted with Vista’s “restart” prompt:

I was busy, so I dropped the menu down, clicked on 4 hours and went back to work. I had all sorts of things going on: A dual-monitor setup with Vista on the laptop’s monitor, XP on the external monitor (in a virtual machine), Microsoft Word, Microsoft Outlook and Microsoft Access were running and busy in the virtual machine, WIndows Mail was working away in Vista, and so on. You get the picture.

Then, at 1215, my boss and I decided we’d take our usual lunchtime walk. I returned from the walk one 50 minutes later to see a login prompt. I realise that the security folks amongst my readership wouldn’t see anything wrong with this picture, however for me, as somebody who rarely needs to lock his laptop, seeing this prompt meant one thing: a reboot had occured. Doh! What sort of state was my virtual machine going to be in? Heck, I was in the middle of a document in the virtual machine, would Microsoft Word recover from that? Thankfully everything came back to life as I expected it to, Virtual PC recognised that I had undo changes left and offered me the chance to save them. However things might not have been so good had there been any long-running processes running on either Vista or in the XP virtual machine.

Phew! But there’s a lesson to be had from this incident: good as automatic updates can be, be careful if you need to avoid the automatic update, postponing it might not be the answer. Now, please note the use of “can” in the previous sentence. There are times when automatic updates can be a real pain and can cause you problems (refer to this, this (old) and this).

So, if you do need to postpone the automatic reboot until you choose to restart the machine, here’s what you can do:

1. Open up a Command Prompt (as Administrator)

2. Enter: net stop “Windows Update” – then press Enter.

The Windows Update service that you just stopped will come back to life when you next reboot, so you’re not breaking anything by doing this.

Technorati Tags: ,