Log et al – Peter Curd

An irreverent peek into the inner rumblings of Peter Curd



Review: The Rowan

By pcurd

The Rowan
The Rowan by Anne McCaffrey
My rating: 3 of 5 stars

This isn’t the best of the series, or even an especially good story, but it does set up the universe for the remainder of the series. On a reread I’ve realised how bad McCaffrey was at describing relationships and how almost all of her male characters are either father figures or horrible people.

Still, worth reading if you are diving into the whole series or later points aren’t clear.

View all my reviews



2015 in review

By pcurd

A big year! 2014 was one of the biggest of my life (but I didn’t write a blog post about it!) so 2015 felt like it would be simpler, well let’s talk about it.
Read more »



Twitter updates on this blog

By pcurd

Back in 2009 I started including my public twitter feed on this blog, a practice I continued for 2 years or so until early 2012.

Today I have archived all of those posts as although they were a considerable percentage of my total posts they were not truly in keeping with my intentions for this blog and led me towards laziness.

If anyone needs to see my old tweets there are various services around including snapbird.org.



How to perform an SQL “IN” query in Linq

By pcurd

Using Linq to achieve a query that in SQL that uses the “IN” keyword – i.e. to check a value against a range of values – requires use of the .Contains method on a new array of the range of values.

For example, if I need to exclude from reports the following customers:

  1. Internal
  2. Demo
  3. Sample
I would in SQL use something like:
CustomerName NOT IN ('Internal', 'Demo', 'Sample')
In Linq I need something like:
!(new[] {"Internal", "Demo", "Sample"}).Contains(CustomerName))

Appropriately wired into EF or your ORM of choice.

I think this is confusing since it is written backwards to a SQL programmer, so it reads “does this list of things contain the value?” instead of “is the value in this list of things?” as we are used to in SQL.



How to get SQL Server Table Row Counts fast and efficiently

By pcurd

SQL Server Central ran an article this morning about using a system DMV to get table row counts without doing a table scan (so it’s VERY fast and has no performance hit).

I decided to test this on my test server, a virtual machine running on a Dell R900. I ran the queries four times, discounting the first time to be sure all were in memory, and averaging the last three for the following values.

Read more »



The FizzBuzz problem

By pcurd

Amy Kimber posted an article today referring to a post from Nick Telford on twitter:

Will The Real Programmers Please Stand Up? http://retwt.me/1NEBw // another example of how diluted our industry really is (link)

This interests me as I often find job interviews to be very generic and after about four in a row you get to know all the answers and appear much cleverer than you perhaps are.  I like a problem that makes you think and although FizzBuzz is a trivial problem, I wanted to answer it with a little bit of real world thinking.

To quote Amy, the FizzBuzz problem is “The idea is simple, all you have to do is write a program that prints out the numbers 1 to 100, but for multiples of 3, print Fizz instead of the number and for multiples of 5 print Buzz. If the number is a multiple of both, FizzBuzz should be printed.”

In the real world, specs change. Today it’s 3 and 5 and tomorrow it’s 4 and 9 and we need to add an extra one “Bibble” for 11.  I decided to solve the problem with a list of number and word pairs so that changing it would be easy.  .Net provides a nice KeyValuePair generic which I used as Int,String.

Originally I had this implemented using a Dictionary but as FizzBuzz must be implemented the correct way around (not BuzzFizz) I needed to change this to a SortedDictionary to ensure order of execution.

Code is as below:

using System;
using System.Collections.Generic;

namespace FizzBuzz
    class Program
        static ICollection<KeyValuePair<int, string>> wordlist;
        static void Main(string[] args)
            wordlist = new SortedDictionary<int, string>();
            wordlist.Add(new KeyValuePair<int, string>(3, "Fizz"));
            wordlist.Add(new KeyValuePair<int, string>(5, "Buzz"));
            PrintFizzBuzz(1, 100);

        static void PrintFizzBuzz(int start, int finish)
            for (int i = start; i <= finish; i++)

        static object CalculateFizzBuzz(int i)
            string CalculateFizzBuzz = "";
            foreach (KeyValuePair<int, string> word in wordlist)
                if (i % word.Key == 0)
                    CalculateFizzBuzz += word.Value;
            if (CalculateFizzBuzz.Length == 0)
                CalculateFizzBuzz = i.ToString();

            return CalculateFizzBuzz;

Update 27th February 2012:

Many great answers in the comments below, great to see how different languages can solve this problem. My solution is designed around flexibility and the ability to change the list of “Fizz”es and “Buzz”es which takes away from the brevity possible!

I found this article today from Calvin Bottoms regarding implementing FizzBuzz in Haskell – at 78 characters it’s impressive and his explanation of how it develops is a great read.



SWDevelopments Website launched

By pcurd

For the last few months I have been rebranding my personal projects and side work to “SW Developments” and today I have launched a website for this venture – http://swdevelopments.co.uk.

I will be developing this website and the venture with more details in the coming months.

SW Developments will consider any project and can produce cost effective, modern Content Management System driven websites, and more powerful custom development driven websites or any IT consultancy services for local companies.



Unable to add certain Active Directory users as Windows Logons to SQL Server 2008 on Windows Server 2008 R2

By pcurd

Last week I faced an issue where I was unable to create Windows Logons for SQL Server 2008 from Active Directory users on a Windows Server 2008 R2 server when a Windows Server 2008 server was able to.

The error was a 15401 error which are quite common and usually mean your Server Principal names are wrong, however I had checked this and knew it was not an authentication issue. See my post on Server Principal Names for more details on this. Plus I was able to add other users. The error was “Error 15401 – Windows NT user or group ‘domain\username’ not found”.

There is a Knowledge Base article which describes the problem (with a hotfix) but the symptoms are not the same as the knowledge base so I hope this makes it easier to find. The knowledge base article is KB976494 (Error 1789 when you use the LookupAccountName function on a computer that is running Windows 7 or Windows Server 2008 R2) http://support.microsoft.com/kb/976494.

Reblog this post [with Zemanta]



Access 97: The database engine can’t find Error

By pcurd

When linking to a SQL Server table in Access 97 today I came across this weird error:
“The database engine can’t find TableName. Make sure it is a valid parameter or alias name, that it doesn’t include invalid characters or punctuation, and that the name isn’t too long.”

As the table name was reasonably small, and I had longer table names already linked, I became suspicious.

The problem was indexes, if the total length of the table name plus the length of the name of the longest index is longer than 64 characters, you get that error. Making the index name smaller solved the problem.



DRM and me – The problem with The Settlers 7

By pcurd

This morning I happened to notice on Steam that there is an update for the Settlers 7 out and I thought to myself, wow did I miss the release?

I’m a big fan of the Settlers series and I own all of them from Settlers 1 (which I have on floppy disk somewhere) through to Rise of an Empire, the sixth game in the series, which I own on Steam.

Although there have been shakey moments in the francise, the fifth game The Settlers: Heritage of Kings tried to be too much like Spellforce without capturing the essence of RTSRPG for example, Settlers games have always been fun to play.

So with much excitement I did a quick search.. nope, Settlers 7 (Paths to a Kingdom) is not available on Steam.. must be one of those regional locks which annoys me, considering The Settlers is made by Blue Byte Software, a German developer. Why does the US get it first? It’s published by Ubisoft – a French publisher!

So I decide to check out Ubisoft’s download page to see what the price is and there I find it. Well, I find the US page anyway. After some more searching I find the UK page – except it’s from GamesPlanet. But whatever, it’s got a Ubisoft logo on it.

£34.99 is a reasonable price for a new game, don’t even get me started on the “electronic copies should be cheaper” debate, so I start to check out what’s in this edition, after all the US copy is the Gold Edition and only £5 more. The feature difference isn’t important but I do notice one thing I’ve been secretly dreading all this time. Ubisoft’s DRM package (Digital Rights Management).

Read more »