# Tuesday, June 19, 2007

The results of the previous three tests are interesting. In both IE7 and Firefox all three render correctly (although the PRE tag in the first one causes the text to spill into the right hand bar). When viewing the RSS feed it becomes a whole new story:

  • IE7 doesn't honor PRE tags, single spaces or stylesheets
  • Firefox doesn't honor PRE tags, single spaces or stylesheets as well but at least it cuts out the embedded stylesheet in the last post
  • Google Reader also doesn't honor PRE tags, single spaces or stylesheets and to cap it all anything in a PRE tag just renders to the end of line and stops so it makes things impossible to read

I wonder, is there a standard that feed readers need to adhere to? What is the best way of embedding syntax colored code in blog posts?

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, June 19, 2007 5:14:50 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback

Same post but with embedded styles.

I'm trying to get a decent solution to inserting code in blog articles so the next few posts are all about the code. The sample below is a simple line counter tool I use to work out some metrics for code reviews.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace LineCount
{
  class Program
  {
    private static int folders;
    private static int files;
    private static int lines;
    private static int code;
    private static int comments;

    static void Main(string[] args)
    {
      if (args.Length == 0)
      {
        Console.WriteLine(@"
Usage: linecount <root folder>

e.g. linecount t:\dev\projects\main

NB: Only .cs files are considered
  Review time is hard coded to 200 lines per hour
"
);
        return;
      }

      CountLines(new DirectoryInfo(args[0]));

      Console.WriteLine("FOLDERS:{0} FILES:{1} LOC:{2} SLOC:{3} COMMENTS:{4}",
        folders, files, lines, code, comments);
      Console.WriteLine("Code density: {0:p}",
        (double)code / (double)lines);
      Console.WriteLine("Comment density: {0:p}",
        (double)comments / (double)lines);
      Console.WriteLine("Comment ratio: {0:p}",
        (double)comments / (double)code);
      Console.WriteLine("Estimated review time: {0}h", 1+ (code / 200));
    }

    private static void CountLines(DirectoryInfo parent)
    {
      ++folders;

      foreach (DirectoryInfo folder in parent.GetDirectories())
      {
        CountLines(folder);
      }

      foreach (FileInfo file in parent.GetFiles())
      {
        CountLines(file);
      }
    }

    private static void CountLines(FileInfo file)
    {
      switch (file.Extension)
      {
        case ".cs":
          break;
        default:
          return;
      }

      ++files;

      using (StreamReader reader = file.OpenText())
      {
        string line = null;
        bool inComment = false;

        while ((line = reader.ReadLine()) != null)
        {
          ++lines;
          line = line.Trim();

          if (line.Length == 0)
            continue;

          if (line.StartsWith("//"))
          {
            if (line.Replace("//", "").Trim().Length > 0)
              ++comments;

            continue;
          }

          if (line.StartsWith("/*"))
            ++comments;
          else if (!inComment)
            ++code;

          if (line.Contains("/*"))
          {
            inComment = true;
          }

          if (inComment && line.Contains("*/"))
          {
            inComment = false;
          }
        }
      }
    }
  }
}
by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, June 19, 2007 4:34:25 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback

Same post but without the PRE tags:

I'm trying to get a decent solution to inserting code in blog articles so the next few posts are all about the code. The sample below is a simple line counter tool I use to work out some metrics for code reviews.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace LineCount
{
  class Program
  {
    private static int folders;
    private static int files;
    private static int lines;
    private static int code;
    private static int comments;

    static void Main(string[] args)
    {
      if (args.Length == 0)
      {
        Console.WriteLine(@"
Usage: linecount <root folder>

e.g. linecount t:\dev\projects\main

NB: Only .cs files are considered
  Review time is hard coded to 200 lines per hour
"
);
        return;
      }

      CountLines(new DirectoryInfo(args[0]));

      Console.WriteLine("FOLDERS:{0} FILES:{1} LOC:{2} SLOC:{3} COMMENTS:{4}",
        folders, files, lines, code, comments);
      Console.WriteLine("Code density: {0:p}",
        (double)code / (double)lines);
      Console.WriteLine("Comment density: {0:p}",
        (double)comments / (double)lines);
      Console.WriteLine("Comment ratio: {0:p}",
        (double)comments / (double)code);
      Console.WriteLine("Estimated review time: {0}h", 1+ (code / 200));
    }

    private static void CountLines(DirectoryInfo parent)
    {
      ++folders;

      foreach (DirectoryInfo folder in parent.GetDirectories())
      {
        CountLines(folder);
      }

      foreach (FileInfo file in parent.GetFiles())
      {
        CountLines(file);
      }
    }

    private static void CountLines(FileInfo file)
    {
      switch (file.Extension)
      {
        case ".cs":
          break;
        default:
          return;
      }

      ++files;

      using (StreamReader reader = file.OpenText())
      {
        string line = null;
        bool inComment = false;

        while ((line = reader.ReadLine()) != null)
        {
          ++lines;
          line = line.Trim();

          if (line.Length == 0)
            continue;

          if (line.StartsWith("//"))
          {
            if (line.Replace("//", "").Trim().Length > 0)
              ++comments;

            continue;
          }

          if (line.StartsWith("/*"))
            ++comments;
          else if (!inComment)
            ++code;

          if (line.Contains("/*"))
          {
            inComment = true;
          }

          if (inComment && line.Contains("*/"))
          {
            inComment = false;
          }
        }
      }
    }
  }
}
by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, June 19, 2007 4:27:52 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback

I'm trying to get a decent solution to inserting code in blog articles so the next few posts are all about the code. The sample below is a simple line counter tool I use to work out some metrics for code reviews.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;

namespace LineCount
{
    class Program
    {
        private static int folders;
        private static int files;
        private static int lines;
        private static int code;
        private static int comments;

        static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                Console.WriteLine(@"
Usage: linecount <root folder>

e.g. linecount t:\dev\projects\main

NB: Only .cs files are considered
    Review time is hard coded to 200 lines per hour
");
                return;
            }

            CountLines(new DirectoryInfo(args[0]));

            Console.WriteLine("FOLDERS:{0} FILES:{1} LOC:{2} SLOC:{3} COMMENTS:{4}", 
                folders, files, lines, code, comments);
            Console.WriteLine("Code density: {0:p}", 
                (double)code / (double)lines);
            Console.WriteLine("Comment density: {0:p}", 
                (double)comments / (double)lines);
            Console.WriteLine("Comment ratio: {0:p}", 
                (double)comments / (double)code);
            Console.WriteLine("Estimated review time: {0}h", 1+ (code / 200));
        }

        private static void CountLines(DirectoryInfo parent)
        {
            ++folders;

            foreach (DirectoryInfo folder in parent.GetDirectories())
            {
                CountLines(folder);
            }

            foreach (FileInfo file in parent.GetFiles())
            {
                CountLines(file);
            }
        }

        private static void CountLines(FileInfo file)
        {
            switch (file.Extension)
            {
                case ".cs":
                    break;
                default:
                    return;
            }

            ++files;

            using (StreamReader reader = file.OpenText())
            {
                string line = null;
                bool inComment = false;

                while ((line = reader.ReadLine()) != null)
                {
                    ++lines;
                    line = line.Trim();

                    if (line.Length == 0)
                        continue;

                    if (line.StartsWith("//"))
                    {
                        if (line.Replace("//", "").Trim().Length > 0)
                            ++comments;

                        continue;
                    }

                    if (line.StartsWith("/*"))
                        ++comments;
                    else if (!inComment)
                        ++code;

                    if (line.Contains("/*"))
                    {
                        inComment = true;
                    }

                    if (inComment && line.Contains("*/"))
                    {
                        inComment = false;
                    }
                }
            }
        }
    }
}
by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, June 19, 2007 3:54:31 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Wednesday, June 13, 2007
Digg This!
Digg This!, uploaded to Flickr by James Snape.

Canon 400D, Canon 24-105 f/4L IS lens - 1/500 second, f/4, ISO 100

It should be noted that I'm not very good at naming things so if you can come up with a better title for this picture I'd appreciate it.

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Wednesday, June 13, 2007 8:14:54 PM (GMT Daylight Time, UTC+01:00)  #    Comments [5] Trackback
# Wednesday, June 06, 2007

My programmer personality type is: DHTC

You're a Doer.
You are very quick at getting tasks done. You believe the outcome is the most important part of a task and the faster you can reach that outcome the better. After all, time is money.
You like coding at a High level.
The world is made up of objects and components, you should create your programs in the same way.
You work best in a Team.
A good group is better than the sum of it's parts. The only thing better than a genius programmer is a cohesive group of genius programmers.
You are a Conservative programmer.
The less code you write, the less chance there is of it containing a bug. You write short and to the point code that gets the job done efficiently.

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Wednesday, June 06, 2007 6:58:18 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Tuesday, June 05, 2007

I'm spending today and tomorrow working with DPE on a lab for ISV's working with the Microsoft BI stack (SQL, SSIS, SSAS, Excel, BSM, PPS etc). Basically each customer brings along an application they are working on and we help on everything from architecture to solving any problems they might be having. It's a lot of fun and I even learned a few things. Because customers turn up with their own applications and problems you never really know what to expect. In the mix today we had:

  • A stock trading system
  • A very cool spreadsheet based query designer
  • A tool to automatically create cubes based on Dynamics customizations
  • Someone working with SharePoint, Business Scorecard Manager and Reporting Services

I'm not sure when the next lab will be but keep an eye on Eric Nelson as he runs most ISV events in the UK.

On a similar note, I'm taking on a new customer. It seems you never escape your past - the customer has a number of call centers they develop applications for... 

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, June 05, 2007 9:26:09 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Monday, June 04, 2007
Calm Water
Calm Water, uploaded to Flickr by James Snape.

Taken at a friend's house... I liked the contrast of yellow and blue.

Canon 400D, Canon 24-105 f/4L IS lens - 1/25 second, f/4, ISO 100

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Monday, June 04, 2007 10:33:19 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Tuesday, May 29, 2007
Bournemouth Pier
Bournemouth Pier, originally uploaded to Flickr by James Snape.

Canon 400D, Canon 18-55 f/3.5-5.6 lens - 49mm, 1/200 second, f/11, ISO 100

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, May 29, 2007 8:33:07 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
Branksome Beach
Branksome Beach, originally uploaded to Flickr by James Snape.

Canon 400D, Canon 24-105 f/4L IS lens - 24mm, 1/125 second, f/4, ISO 100

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, May 29, 2007 8:29:41 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback
# Tuesday, May 01, 2007

OK, I took a few pictures whilst we were away; approximately 19GB of pictures... Hence it's taken a little while to process and upload them all. Anyways, for those that are interested I've narrowed the selection down to 500 or so of the best ones and put them on Flickr. You can see them here.

The whole trip was fantastic, managing to fit a little bit of everything into the two and a half weeks away. We drove from Cape Town to East London and back then spent a couple of nights in Clarens, Free State. A total distance of about 2200 miles.

In detail, the trip looked like:

6th April 2007 - 06:35 Flight to Amsterdam, arrive 08:55

10:30 Flight to Johannesburg, arrive 21:00

Airport Grand, Johannesburg Airport (The room was very small)

7th April 2007 - 10:00 Flight to Cape Town, arrive 12:10

Nelson’s Guesthouse (Lovely place, great views, well located)

209 High Level Road, Sea Point, Cape Town, 8005 Tel: 021 4332602 Cell: 0728 752077

10th April 2007 - De Oude Ryneveld (Right in the center)

71 Ryneveld Street Stellenbosch 7600 Tel: 083 2984 856 Cell: 083 2984 856

11th April 2007 - Tranquillity Lodge (Great getaway)

130 St' Michael's Avenue, Nature's Valley, 6602 Tel: 044-531 6663 Cell: 0832 645221

12th April 2007 - Stumble Inn (Fantastic theme rooms)

31 Princess Alice Drive, Nahoon, East London, 5201 Tel: +27 43 735 3532

13th April 2007 - Inkwenkwezi Game Reserve (Really good private reserve)

15th April 2007 - Stumble Inn (again)

31 Princess Alice Drive, Nahoon, East London, 5201 Tel: +27 43 735 3532

16th April 2007 - Yellowwood Lodge (A little old fashioned but very nice)

18 Handel Street, PO Box 2020, Knysna 6570 Tel: 044 3825906 yellwood@global.co.za

17th April 2007 - The Highstead Manor (Serviced apartment for 4)

Crn Highlevel Road & St.Johns Road, Sea Point'fresnaye' 8060

Tel: +27 21 4396040 Cell: +27 837 629121

20th April 2007- 09:40 Flight to Johannesburg, arrive 11:40

Mt Rouge Guest House (Corrie du Preez) (Very peaceful)

152 Bester Street , Clarens, Free State Tel: +27-58-2561207 Cell: 0725129707, 0827827208

23th April 2007 - 23:30 Flight to Amsterdam arrive 24th April 10:20

24th April 2007 - 12:05 Flight to London Heathrow, arrive 12:30

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, May 01, 2007 6:56:47 PM (GMT Daylight Time, UTC+01:00)  #    Comments [2] Trackback
# Tuesday, April 10, 2007
Cape Point
Cape Point, originally uploaded to Flickr by James Snape.

After three flights and a car ride we finally made it. Here I am at the most south westerly point in Africa. Its been really hot; I hate to imagine what its like in summer. More pictures when I get back.

by This posting is provided "AS IS" with no warranties, and confers no rights.
posted on Tuesday, April 10, 2007 6:03:55 PM (GMT Daylight Time, UTC+01:00)  #    Comments [0] Trackback