No Free Time

Because my therapist says I need to let things out

Archive for April, 2008

This is too scary

Posted by andrewmyhre on April 18, 2008

Man trapped in elevator for 41 hours:
http://disembedded.wordpress.com/2008/04/14/madness-trapped-in-elevator-car-30/

And if you can’t be bothered reading the story, here’s a time-lapse film of the whole ordeal:

http://www.snotr.com/video/1078

Posted in Uncategorized | Leave a Comment »

Developer day Scotland

Posted by andrewmyhre on April 17, 2008

Looking forward to Developer Day Scotland! Going to catch up with a few people I used to work with up there, before I fled to London with my tail between my legs.

Posted in .net, community events | Tagged: , | Leave a Comment »

Weird

Posted by andrewmyhre on April 11, 2008

I mis-typed and browsed to http://www.silverlight.com/showcase today. That domain is hosted by Apple?

Posted in Uncategorized | Leave a Comment »

But

Posted by andrewmyhre on April 9, 2008

But I he replies because he’s super-cool, and Twitter is cool, and not because I’m special. Just so that’s clear.

Posted in Uncategorized | Leave a Comment »

What’s cool

Posted by andrewmyhre on April 9, 2008

What’s cool is that I can send Scott Hanselman a message on Twitter, apropros nothing, and he’ll reply. That’s cool.

Posted in Uncategorized | Leave a Comment »

The right way to install SQL Server 2005

Posted by andrewmyhre on April 8, 2008

When you install SQL 2005 DO NOT choose to start the SQL Server and SQL Agent services. If these are running when you install the service pack you will have to reboot (or manually shut them down yourself – save yourself the bother).

SQL Server 2005 Service Pack 2 is cumulative – meaning you do not have to install SP1.

Posted in Uncategorized | Leave a Comment »

Strip special characters (including spaces) from a string using Regex

Posted by andrewmyhre on April 6, 2008

This is the regex I use to convert a free text value to a filename style value (used in my CMS to create a filename based on a page title):

string cleanName = new Regex(“\W”).Replace(uncleanName, “”)

e.g: new Regex(“\W”).Replace(“page & title $ with %bad characters!!”, “”) = “pagetitlewithbadcharacters”

Posted in Uncategorized | Tagged: , | Leave a Comment »

System.Web.Uri(string) encodes using System.Web.HttpUtility.UrlPathEncode(), not System.Web.HttpUtility.UrlEncode()

Posted by andrewmyhre on April 5, 2008

I discovered the difference between System.Web.HttpUtility.UrlEncode() and System.Web.HttpUtility.UrlPathEncode:

System.Web.HttpUtility.UrlEncode(“http://something.com/some page.html”) == “http://something.com/some+page.html”

Whereas

System.Web.HttpUtility.UrlPathEncode(“http://something.com/some page.html” == “http://something.com/some%20page.html”);

the System.Web.Uri class automatically uses UrlPathEncode() when constructed from a string value, so when comparing a string Url to a Uri instance, make sure to run the string through UrlPathEncode before the comparison, and NOT UrlEncode().

Posted in Uncategorized | Leave a Comment »

MSTest still doesn’t assert array equality properly

Posted by andrewmyhre on April 5, 2008

I ran into this issue today where asserting equality on two arrays always fails, even if the arrays really are equal:

Assert.Equals(new string[] {“value”}, new string[] {“value”}); // always fails

Evidently for arrays the Assert.Equals() method tests object identity, rather object equality, which is what you would expect. There is an Assert.AreSame() method which should test object identity, shouldn’t it?

I found this post from 2005 which notes the problem – I can’t believe they haven’t fixed it by now!

Posted in testing | Tagged: , | 1 Comment »

Constrain a generic Class/Method to a particular type

Posted by andrewmyhre on April 2, 2008

In C# you can constrain a generic type using the where T:Type syntax. For instance, my method to get a Url for a particular CMSObjectType (my base CMS domain object class) I declare the method like this:

public string GetUrl<T>() where T:CMSDataObject

This instructs the compiler that it will only accept types passed into the generic method which derive from CMSDataObject. The syntax is also valid for generic classes.

More information at MSDN: http://msdn2.microsoft.com/en-us/library/bb384067.aspx

Posted in .net, c++ | Tagged: , | Leave a Comment »