A long hard slog

With my first ultra fast approaching, my training has been far from ideal. Whilst a week skiing worked wonders for my leg strength, it did nothing to help condition my legs for the repetetive slog of 33 cold, hard miles.

Added to this the last week I have had rather debilitating digestive issues and have been horribly dehydrated, despite trying to over hydrate, and been unable to run as a result. So far from ideal – the key stage when I just need to be getting out on my feet and getting miles in so far has been spent doing neither.

I’m always in two minds as to whether or not I can compete at an event like this: logic tells me no, at least not the first time. Hopefully common sense will prevail; make sure I finish one first, and maybe next time I can try and be a bit more competetive; ideally with better preparations.

On a brighter note I did manage to [poorly] capture a rather pretty sun rise.
IMG 20120207 075151cleaned A long hard slog

Creating IIS 6 Directories by C#

I’ve been writing this for a while today and couldn’t figure out why I couldn’t get the application to create within IIS. The virtual directory created without problems, but after that nothing happened. It turns out that the msdn library was incorrect!

Here is a working IIS 6 virtual directory creator. The only paramaters that need to be changed are in the // Set comment.

// IIS 6 Virtual Directory Builder and Configuration
// http://r-dunn.co.uk/ieatpenguin/computing/software/962/
// Please feel free to use and distribute

// Set variables: Site_Name,Path_to_wwwroot,Virtual_Directory_Name,Path_to_virtual_dir
// Change the port number after "ServerBindings" if you wish to use a different port.

using System;
using System.IO;
using System.DirectoryServices;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Collections;

namespace System_DirectoryServices_DirectoryEntry_ConfigIIS
{
  class Program
  {
    static void Main(string[] args)
    {
        CreateSite("IIS://Localhost/W3SVC", "555", "Site_Name", "Path_to_wwwroot");
        SetSingleProperty("IIS://Localhost/W3SVC/555", "ServerBindings", ":8080:");
        CreateVDir("IIS://Localhost/W3SVC/1/Root", "Virtual_Directory_Name", "Path_to_virtual_dir");
    }

    static void CreateSite(string metabasePath, string siteID, string siteName, string physicalPath)
    {
      //  metabasePath is of the form "IIS://<servername>/<service>"
      //    for example "IIS://localhost/W3SVC" 
      //  siteID is of the form "<number>", for example "555"
      Console.WriteLine("\nCreating site {0}/{1}, mapping the Root application to {2}:", 
          metabasePath, siteID, physicalPath);

      try
      {
        DirectoryEntry service = new DirectoryEntry(metabasePath);
        string className = service.SchemaClassName.ToString();
        if (className.EndsWith("Service"))
        {
          DirectoryEntries sites = service.Children;
          DirectoryEntry newSite = sites.Add(siteID, (className.Replace("Service", "Server")));
          newSite.Properties["ServerComment"][0] = siteName;
          newSite.CommitChanges();

          DirectoryEntry newRoot;
          newRoot = newSite.Children.Add("Root", "IIsWebVirtualDir");
          newRoot.Properties["Path"][0] = physicalPath;
          newRoot.Properties["AccessScript"][0] = true;
          newRoot.CommitChanges();

          Console.WriteLine(" Done. Your site will not start until you set the ServerBindings or SecureBindings property.");
        }
        else
          Console.WriteLine(" Failed. A site can only be created in a service node.");
      }
      catch (Exception ex)
      {
        Console.WriteLine("Failed in CreateSite with the following exception: \n{0}", ex.Message);
      }
    }

    static void SetSingleProperty(string metabasePath, string propertyName, object newValue)
    {
      //  metabasePath is of the form "IIS://<servername>/<path>"
      //    for example "IIS://localhost/W3SVC/1" 
      Console.WriteLine("\nSetting single property at {0}/{1} to {2} ({3}):",
          metabasePath, propertyName, newValue, newValue.GetType().ToString());

      try
      {
          DirectoryEntry path = new DirectoryEntry(metabasePath);
          PropertyValueCollection propValues = path.Properties[propertyName];
          string oldType = propValues.Value.GetType().ToString();
          string newType = newValue.GetType().ToString();
          Console.WriteLine(" Old value of {0} is {1} ({2})", propertyName, propValues.Value, oldType);
          if (newType == oldType)
          {
              path.Properties[propertyName][0] = newValue;
              path.CommitChanges();
              Console.WriteLine("Done");
          }
          else
              Console.WriteLine(" Failed in SetSingleProperty; type of new value does not match property");
      }
      catch (Exception ex)
      {
          if ("HRESULT 0x80005006" == ex.Message)
              Console.WriteLine(" Property {0} does not exist at {1}", propertyName, metabasePath);
          else
              Console.WriteLine("Failed in SetSingleProperty with the following exception: \n{0}", ex.Message);
      }
    }

    static void CreateVDir(string metabasePath, string vDirName, string physicalPath)
    {
      //  metabasePath is of the form "IIS://<servername>/<service>/<siteID>/Root[/<vdir>]"
      //    for example "IIS://localhost/W3SVC/1/Root" 
      Console.WriteLine("\nCreating virtual directory {0}/{1}, mapping the Root application to {2}:",
          metabasePath, vDirName, physicalPath);

      try
      {
        DirectoryEntry site = new DirectoryEntry(metabasePath);
        string className = site.SchemaClassName.ToString();
        if ((className.EndsWith("Server")) || (className.EndsWith("VirtualDir")))
        {
          DirectoryEntries vdirs = site.Children;
          DirectoryEntry newVDir = vdirs.Add(vDirName, (className.Replace("Service", "VirtualDir")));
          newVDir.Properties["Path"][0] = physicalPath;
          newVDir.Properties["AccessScript"][0] = true;

          // Create Application, set appropriate documents and permissions
          newVDir.Invoke("AppCreate", new object[1] { 1 });
          newVDir.Properties["AppFriendlyName"].Value = vDirName;
          newVDir.Properties["EnableDirBrowsing"][0] = false;
          newVDir.Properties["AccessRead"][0] = true;
          newVDir.Properties["AccessExecute"][0] = true;
          newVDir.Properties["AccessWrite"][0] = false;
          newVDir.Properties["EnableDefaultDoc"][0] = true;
          newVDir.Properties["DefaultDoc"][0] = "ReportsIsapi.dll?Login,ReportsIsapi.dll";
          newVDir.Properties["AspEnableParentPaths"][0] = true;
          newVDir.CommitChanges();

          Console.WriteLine(" Done.");
        }
        else
          Console.WriteLine(" Failed. A virtual directory can only be created in a site or virtual directory node.");
      }
      catch (Exception ex)
      {
        Console.WriteLine("Failed in CreateVDir with the following exception: \n{0}", ex.Message);
      }
    }
  }
}

Don’t forget to use a double ‘\\’ in your pathnames to avoid the compiler interpreting them as an escape sequence. I certainly did.

Note to self: Seal Yoghurt

The main advantage of running in the mornings through winter is that you get to mark the advance of the seasons, and almost will Spring in as you move each foot forward.

The beauty of dawn still never ceases to amaze me, and I consider myself fortunate in that I actually can get up at an uncivilised hour to trot off the 15 miles to work; because despite niggles here and there, it really isn’t a chore. It is the most peaceful time of the day, I didn’t see a soul out on the pavement until around half way through my run this morning, and whilst that is unusual for a city centre – and the route I take – it was a liberating experience.

The first person I did pass had a gorgeous spaniel who looked most perplexed as to why someone was chugging along with a backpack wearing some ludicrously bright and reflective clothing, a head torch set to dazzle, and had yoghurt all over his legs.

Of course, it wasn’t until 7 or 8 miles in when I stopped for a hot cross bun and a drink that I actually noticed the yoghurt: a spattering down the front of my legs. I have an unfortunate but small hole in the bottom of my rucksack, and sure enough one of my yoghurt pots had burst in my bag, and dripped out down onto my legs. Oh well – no harm done, other than a bag full of yoghurt.

Dawn had broken around 7:50 this morning, and I sauntered into the village where I work at 8:10am, running smoothly. I felt like I had had a good run; my average speed was ticking along nicely, and I was enjoying myself thoroughly. Being a regular commuter by bike, you get to recognise the other regulars and say good morning as you pass. It’s nice passing them as they recognise you with a look of surprise because you’re not on your bike, but still take the time to say good morning. It’s little things like this that help take the mind out of the work, and just enjoy the run.

A great enjoyable run this morning, encompassing just under 15 miles in 1 hour 48 minutes was only slightly marred by getting to work and realising that the small spattering of yoghurt on the front of my legs was only marred by the huge deluge, that dwarfed it, on the back. The only way I can really describe it is that it probably looked – to the dozens of people I passed and who passed me on the commute to work – like I’d shat myself and let it just run down my legs, after eating something altogether unpleasant the night before.

Oh well. It will wash out!

Backing up The Latest File – Name Unknown

It’s a common enough issue for me that I want to be able to backup the latest backup of a database, and using variables to set date and time I never quite know what the filename of the backup will be.

::copy latest file to network server
set LF=
for /F %%i in ('dir /Od /b *.sql') DO set LF=%%i
:
echo%TIME% on %DATE%: Latest Backup is %LF% >> Backup.file
:
xcopy /Y %LF% \\networkserver\bugzilla

My solution is to sort the backup directory by date, and create a variable based on the filename of the most recent file.

I then echo the time and date to a file (Backup.file) so that I have a log of the backup process that I can check should I need to in the future.

Finally, the script copies the latest backup to a network location.

This was used in conjunction with my bugzilla backup script, hence the directory names, but it can of course be used for anything.

Automated Backup of Bugzilla Database on Windows

Bugzilla isn’t really designed to be used on Windows, but once set up its fairly easy to administer.

One obviously important thing is backing up the database. Using the niftily built in mysqldump I used the following solution. Note this assumes default settings were used in the installation of Bugzilla.

First, add mysql to the windows path if it hasn’t been done so already, by running up a command prompt:

PATH=%PATH%;C:\Program Files\Bugzilla\mysql\bin\

I then use a command file to create the backup dump, and then append the date and time to the file name. Note I have also created a user (backup) on the bugzilla database with a limited set of privileges (Select, Lock Table, Show Databases, Event).

rem commmand to dump the database to file
mysqldump -ubackup -pbackup Bugs > c:\bugsbackup\bz.sql

rem set date and time into useable file format
set _my_datetime=%date%_%time%
set _my_datetime=%_my_datetime: =_%
set _my_datetime=%_my_datetime::=%
set _my_datetime=%_my_datetime:/=_%
set _my_datetime=%_my_datetime:.=_%

rem rename file
ren "c:\bugsbackup\bz.sql" bz_%_my_datetime%.sql

This command file can of course be added to scheduled tasks and run as frequently as you want.

A Better Christmas Than Expected

I did approach the Christmas period with a sense of foreboding – it’s a usual time to eat and drink too much, put on some weight, and lose all the fitness I’d worked so hard to build after injuring my ankle.

However, I did not eat to excess, and I managed a fell race on Boxing day. My legs in truth still haven’t recovered fully; my running is dreadful at present. The daily cycle commute of 30 miles is a wonderful cross train however, and whilst my legs feel like two blocks of lead, I am encouraged by my fitness. I don’t appear to have lost much, (not that I had a huge amount before Christmas mind!), and I have lost half a kilo. Ideally I would like to lose 5-8 KGs for racing, but given that I’m so far off being able to race yet, I can’t be too unhappy.

So today I will be entering the Haworth Hobble. And a-hobbling I shall be. I plan to walk/jog the distance this year, my real aim is to do a good years work on the hills, and then run it next year. I can’t see me ever getting near the winning times which are usually and incredibly down near the 4 hour mark, but I’d like to be able to compete, and that will require a long set up time. Plans after that vary, but they certainly include moving house in order to be able to train in hills!

The 8am Dawn-Endorphin Rush

Ever since my serious ankle injury earlier in the year, it has been a rough and at times painful recovery for me, mentally more than physically. The physical pain is something I’m used too and have had to cope with a lot, but mentally I get frustrated and upset if I can’t run.

I was a bit anxious setting off this morning, it’s a long way to work, and although I’ve been running pretty well recently, I’ve not done the half marathon distance (save one run that went somewhat close after going wrong on a Monday night,) in an awful long time.

Getting up when its dark has never really been difficult for me, I’m an early morning person. And given how warm it is for the time of year, it was actually nice getting outside so early. My part of the world is peaceful at 6:30am, and it is quite a fulfilling experience treading the streets without meeting anyone for at least half an hour.

I ran through town to Histon, where I picked up the path on the Guided Busway that runs from Cambridge through to St Ives. This is long and very straight. My total run was 14.21 miles, and most of it was done on this path, pretty slowly. It was at times demoralising, because way down the long route one can see traffic lights. It’s easy to run along setting markers, and to set these sets of lights as markers made things feel good for a while, and the euphoric feeling would slowly tail off as I’d realise that they were still a long way ahead.

Still, when dawn broke at roughly 8am, I stopped to have a drink, turn off my light and watch the sun crest over the horizon. I’m so disappointed that I had no camera with me as it was one of the most beautiful sights I’ve seen in a long time. The suns rise in turn gave rise to sheer enthusiam within myself as well – I finished the last few miles considerably faster than I’d run all morning, and I got to work and into the shower feeling good. Far from fresh, but feeling good. And feeling so pleased with myself. I’m far off what one would call a reasonable half marathon time, but the simple fact that I ran the distance so soon after my injury made me feel amazing.

And I haven’t stopped grinning.

The Perfect Christmas Cake

This receipe hasn’t changed much in the years I’ve been making it, except I’ve added more brandy and a twist – the pepper. It uses a basic dense rich fruit cake, and then the decoration comes later. The best time to make a fruit cake is roughly 6-8 weeks before its needed, as the fruit matures nicely. You can of course make it with less time to spare, it just won’t taste quite as good.

The christmas cake variation is made in three stages. First the fruit is soaked in the brandy, then the cake is made, and then, a week before being needed, the cake is decorated.

Ingredients

imag0082le The Perfect Christmas Cake

  • 225g plain flour
  • 225g unsalted butter
  • 225g soft brown sugar
  • 1/2 teaspoon salt
  • 1/4 teaspoon grated nutmeg
  • 1/2 teaspoon ground mixed spice
  • 1/4 teaspoon ground black pepper
  • 35cl brandy
  • 450g currants
  • 175g raisins
  • 175g sultanas
  • 50g glace cherries
  • 50g candied peel
  • 4 large eggs
  • 50g chopped almonds
  • Rind of one lemon and orange

Props

  • This recipe is for an 8 inch round cake tin, or an 7 inch square tin
  • An airtight container
  • Various mixing bowls

Method

Stage one is done 24 hours before baking the cake. Add the dried fruit ingredients to a large bowl, add most of the brandy (leaving enough to spoon over the cake in the coming weeks), and leave to soak overnight, covered with a tea towel.

imag0083q The Perfect Christmas Cake

Now for the actual cake. Preheat the oven to gask mark 1, or 140°C. Sift the flour, nutmeg, mixed spice, salt and pepper together. I prefer to do this twice.

imag0086t The Perfect Christmas Cake

Next, place the butter in a bowl on a radiator so that it warms up, don’t let it melt though. Beat the eggs quite a lot, making sure a lot of air gets into them.

Fold the butter and sugar together, a little bit at a time:
imag0087o The Perfect Christmas Cake

This is the most important stage (and the most tiring!) because you need to get as much air in to the mix as possible. This is an extremely dense cake, and every little helps essentially.

Next, beat in the eggs vigorously, a tablespoon at a time, until you have a thick almost porridge style mix:
imag0088gx The Perfect Christmas Cake

Then slowly fold in the flour mix taking care when doing so, so that as much air stays in the mix.

imag0089wg The Perfect Christmas Cake

Once you have a nice conistency, stir in the fruit, the rind and the chopped almonds.

imag0090bj The Perfect Christmas Cake

Finally, grease your cake tin with butter, and line it with greaseproof paper, making sure you leave a decent amount above the cake tin, to help stop the top of the cake burning.

imag0091p The Perfect Christmas Cake

Place in the oven, and bake for around 4 and a half hours. Try to resist taking a peek until at least 4 hours have passed. Once done, place in the airtight container where it will live until a week before it is needed. Using a thin needle, or a cooking thermometer is perfect for this, create little holes in the surface of the cake, and, once a week, spoon a little of the remaining brandy over the top to help the cake mature.

imag0095uk The Perfect Christmas Cake

Decoration to follow.

Coq au Vin

Ingredients
imag0071z Coq au Vin

  • 1 large Chicken, or 4 legs and 4 boneless thighs
  • 250g Cooking Bacon (or pancetta)
  • 2 large onions, roughly chopped
  • 2 cloves garlic, crushed
  • Cracked black pepper
  • Cracked Salt
  • 750ml Red Wine
  • 8 button mushrooms (optional)
  • 1 tablespoon oil
  • 1 tablespoon plain flour
  • 2 teaspoons thyme and rosemary

About the ingredients.

I have used legs/thighs this time round, rather than my usual receipe which would call for a large chicken (5-6 person roast) to be jointed. To emulate the same amount of chicken, I have used four chicken legs, and four chicken thighs.

The wine used isn’t that important. We important wine from France on a regular basis, so I threw in a bottle of that, but any wine with a strong tannin base will do, when making this at university I’d use a carton of generic french table top wine.

Many receipes call for Pancetta. I use cooking bacon for a few reasons: it’s dirt cheap, and very fatty. The fats in it make the sauce incredibly rich, and prevent a lot of the flavours in the broth boiling off during the simmer/cooking phase. Use whatever you want here, but thats the reasons for my choice.

You will need a large flat frying plan, a spoon with holes in it, and a cast iron casserole dish, although in desparation in the past I’ve cooked this in a large oven dish, covered with a baking tray icon smile Coq au Vin .

imag0072b Coq au Vin

There are two methods for this, my preferred method which is overnight, or a quicker method. Both are the same until the cooking phase, so I’ll explain that later.

Method

Coat the chicken in the cracked black pepper and a small amount of salt. Melt the butter with the oil in the large frying pan on a low light. Once the butter is properly melted, add the chicken thighs. Starting the butter on a low light prevents it burning. You might need to fry it in stages unless you have a huge pan, I did the legs first, then the thighs. Fry them until they are golden brown on both sides, then place in the cast iron dish.

imag0074jd Coq au Vin

Put the wine, garlic and thyme into the casserole dish, combined with the chicken to start the flavour mixing.

Next, add the bacon, mushrooms (if using) and the onion to the frying pan (I didn’t say turn it off!), and fry until the onions are golden brown. Add to the casserole dish.

Now here is where things can differ.

My preferred choice is to put the lid on the casserole dish, simmer for 30 minutes, allow to cool, and then refrigerate overnight.

imag0078md Coq au Vin

Take the chicken and vegetables out of the mixture using the holed spoon, so that the sauce and fat stay in the casserole dish. Put in the flour, and whisk for a few minutes to thicken it, then return the chicken and vegetables. You simply then bring back to the boil the next day, and simmer for a further 30 minutes.

If you want to eat this the same day however, simmer for 30 minutes, thicken the sauce as above, simmer for another 30 minutes, and then serve with boiled potatoes. Sautéed potatoes is a great idea, and it goes fantastically well with a baked potato as well.