BlogEngine Maintenance

One thing I have found frustrating about the BlogEngine, when you are developing is I have to go on the the server to recycle the application pool if I need to refresh the object loaded in memory.

In addition I wanted a way to find out how may posts, pages and files the BlogEngine held in the application.  Also find out the amout of hard disc space they used would be useful.

So I went ahead and wrote a Maintenance section 

Installation is quite simple copy the admin/Maintenance folder in to the admin/maintenance folder.

Ammend the web.sitemap to include the maintenance

<siteMapNode url="~/admin/Pages/Maintenance/" title="Maintenance"  description=""  roles="administrators"/>

When you login as an administrator you will find the maintenance section appear. (3.83 kb)


Web 3.0

What is next after Web 2.0?  It's got to be Web 3.0 but what is it?  Officially it is Semantic Web.  The semantic web is relatively unknown to most people and some of the technologies are very complex to understand.
Technologies or formats such as FOAFAPMLSIOCXFN tags and microformats are some of the building blocks of the social aspects of the semantic web. They are used to create cross-site profiles of people and also represent relationships between them. XFN and microformats are somewhat easy to start using, but FOAF, APML and SIOC are a different story.
As time goes on I will try to explain each format and how it can be implemented. 

Speed up the Copy process on Windows Vista

Maybe you have already encountered the strange behavior that it takes much longer to copy large files in Windows Vista than in Windows XP. You thought that the change from XP to Vista would at least be not a disadvantage speed wise but Vista somehow seems to have a problem copying large files. This happens especially with mapped drives but it could also be that you witness network disconnects.
The problem is caused by a new feature called Auto Tuning which is by default enabled in Microsoft Windows Vista. What Auto Tuning does is that it reacts on changes in the network by tuning the receive windows size. The solution would be of course to disable Auto Tuning in Vista. Some users reported that disabling Auto Tuning had a positive effect on their ability to connect to services such as Windows Live Messenger which did not work before.
To disable Auto Tuning and speed up the copy process and avoid timeouts and disconnects do the following:
Open a command prompt and type the following: 
netsh int tcp set global autotuninglevel=disabled
To turn it on again: 
netsh int tcp set global autotuninglevel=normal

Cancel some of Windows Vista Effects

Disabling some of Windows Vista’s Visual effect will make your Video Card and CPU very grateful. Do the following:

1. Open Control Panel.
2. Click on ‘System and Maintenance’.
3. Click “Performance Information and Tools”.
4. Click “Adjust Visual Effects”.


uncheck everything but :
Show shadows under menus Show shadows under mouse pointer
Show translucent selection rectangle
Show windows content while dragging
Smooth edges of screen fonts
Use drop shadows for icons labels on the desktop
Use visual styles on windows and buttons 

Remove Tablet Feature

If your computer is not a Tablet Computer (most odds) go to Control Panel –> add/Remove and select remove system components uncheck Tablet PC since you don’t have one… For more advanced users you can change the Tablet option in the Services. 
If you have time to spare then you can watch the Windows Vista Performance Round Table
If you are serious about performance, you can also type out Microsoft Xperf, just make sure you read the manual first.

How do you convert a string into an enum?

I've come across the situation on a number of occasions when coding where I've wanted to convert from a string to an enum.

Here is one of those methods that you can never find when you're looking for it, but once discovered it seems blindingly obvious:

   object Enum.Parse(System.Type enumType, string value, bool ignoreCase);

So you can write the following kind of code:

enum Colour

   // …
   Colour c = (Colour) Enum.Parse(typeof(Colour), "Red", true);
   Console.WriteLine("Colour Value: {0}", c.ToString());

   // Picking an invalid colour throws an ArgumentException. To
   // avoid this, call Enum.IsDefined() first, as follows:
   string nonColour = "Polkadot";

   if (Enum.IsDefined(typeof(Colour), nonColour))
      c = (Colour) Enum.Parse(typeof(Colour), nonColour, true);
      MessageBox.Show("Uh oh!");

Footnote: interestingly, whilst writing this up I noticed that Enum.IsDefined() doesn’t offer the ignoreCase parameter. If you don’t know whether the casing is right, it seems the only way to do the conversion is using the Parse method and catching the ArgumentException. That's not ideal, since it runs a lot slower. I wonder if this is a loophole in the design?

DateTime Format

I’m always searching the internet for DateTime formats, so I’ve placed them in my Blog so I’ll also know where I can find them

DateTime Format Specifiers

Below lists the valid format specifiers supported by the Format method on theDateTime type (see System.IFormattable).

DateTime Format Specifiers

Specifier String Result
d MM/dd/yyyy
D dddd, MMMM dd, yyyy
f dddd, MMMM dd, yyyy HH:mm
F dddd, MMMM dd, yyyy HH:mm:ss
g MM/dd/yyyy HH:mm
G MM/dd/yyyy HH:mm:ss
m, M MMMM dd
r, R Ddd, dd MMM yyyy HH’:’mm’:’ss ‘GMT’
s yyyy-MM-dd HH:mm:ss
S yyyy-MM-dd HH:mm:ss GMT
t HH:mm
T HH:mm:ss
u yyyy-MM-dd HH:mm:ss
U dddd, MMMM dd, yyyy HH:mm:ss
y, Y MMMM, yyyy

Here’s an example that uses these custom format specifiers on a DateTime value:

using System;class TestDateTimeFormats {static void Main( ) {DateTime dt = new DateTime(2000, 10, 11, 15, 32, 14);// Prints "2000-10-11T15:32:14"Console.WriteLine(dt.ToString( ));// Prints "Wednesday, October 11, 2000"Console.WriteLine("{0}", dt);// Prints "10/11/2000"Console.WriteLine("{0:d}", dt);// Prints "Wednesday, October 11, 2000"Console.WriteLine("{0:D}", dt);// Prints "Wednesday, October 11, 2000 3:32 PM"Console.WriteLine("{0:f}", dt);// Prints "Wednesday, October 11, 2000 3:32:14 PM"Console.WriteLine("{0:F}", dt);// Prints "10/11/2000 3:32 PM"Console.WriteLine("{0:g}", dt);// Prints "10/11/2000 3:32:14 PM"Console.WriteLine("{0:G}", dt);// Prints "October 11"Console.WriteLine("{0:m}", dt);// Prints "October 11"Console.WriteLine("{0:M}", dt);// Prints "Wed, 11 Oct 2000 22:32:14 GMT"Console.WriteLine("{0:r}", dt);// Prints "Wed, 11 Oct 2000 22:32:14 GMT"Console.WriteLine("{0:R}", dt);// Prints "3:32 PM"Console.WriteLine("{0:t}", dt);// Prints "3:32:14 PM"Console.WriteLine("{0:T}", dt);// Prints "2000-10-11 22:32:14Z"Console.WriteLine("{0:u}", dt);// Prints "Wednesday, October 11, 2000 10:32:14 PM"Console.WriteLine("{0:U}", dt);// Prints "October, 2000"Console.WriteLine("{0:y}", dt);// Prints "October, 2000"Console.WriteLine("{0:Y}", dt);// Prints "Wednesday the 11 day of October in the year 2000"Console.WriteLine("{0:dddd 'the' d 'day of' MMMM 'in the year' yyyy}", dt);}}

Windows and .NET incompatability

There are some things to consider when using these default formatters in an international environment.

Console.WriteLine("{0:t}", dt);   // Prints "3:32:14 PM"Console.WriteLine("{0:T}", dt);   // Prints "2000-10-11 22:32:14Z" 

The difference between {0:t} and {0:T} has to be taken into account. This difference is due to the fact that .NET has two date time representations—Long ( T ) and Short ( t )—while Windows uses only the Long notation.

So, if a user changes the Regional Settings in Windows only the Long notation will follow this change in .NET. This means that the programmer has to perform his own formatting—and not use the default formatters—if he wants to follow the users settings—not something a programmer should expect.

It’s worth check out SteveX Blog on String Formats

Embed Picasa slideshows into

I was having a problem embedding a slide show from Picasa into my editor. Basically, the editor kept stripping the embed html.  The trick is to edit \admin\tinyMCE.ascx file.  You need to modify the extended_valid_elements entry. Apparently this is used to define valid html tags for the tinyMCE editor. Here are my additions in red:

extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style],



Have fun!

Visual Studio, which version?

What version of Visual Studio is the most current?

Depending on what you are using and which application you are modifing the following are the latest releases of Visual Studio:

  • Visual Studio 6 (Used for the Legacy VB/C++ apps).
    • Latest build is 9782 and this corresponds to Visual Studio 6.0 SP6.
  • Visual Studio 2003
    • Version 7.1.6030. This corresponds to VS2003 SP1 and is a MANDATORY install. If you don't have it install it now.
  • Visual Studio 2005
    • Version 8.0.50727,762 (SP). This corresponds to VS2005 SP1 and is a MANDATORY install. If you don't have it install it now. It can also take over an hour to install.
  • Visual Studio 2008
    • Version 9.0.21022.8 RTM. This corresponds to the RTM release so if you have VS2008 you have this build.