Shop around before you open your wallet

Posted on Thursday, July 30, 2009 by Nicki

This is common sense, of course, but I was amazed at the profiteering some computer stores are up to.

I was looking for some CAT5E network cable to connect my media centre to my network, and enquired at a few stores. I was quoted R7.50 and R8.00/meter, and finally bought at another store for R3.00/meter. Granted, the first two prices were for stores inside a popular shopping mall, and the last is not. But charging 166% more than someone else for the same thing? I was even contemplating getting a wireless network adapter because it would have been cheaper than the cable at R8.00/meter!

Since then I found the name of a cable supplier which might even be cheaper than R3.00/meter. In case you are in Cape Town, look at Cape Cables.

Generic classes and Component services

Posted on by Nicki

I recently wrote a lightweight generic data access layer with generic list functionality. Everything worked fine until I had to implement a derived class as a Serviced Component. Turns out classes with generic methods cannot be added to component services, regsvcs.exe gives the following error


An unknown exception occurred during installation:
1: System.Reflection.ReflectionTypeLoadException - Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.


Searched Google, and found 2 hits. If that happens you know trouble is looming on the horizon...

It appears to be a known bug, see the details here.

So for now I had to implement a workaround by not having my class derive from the generic base class but instead to have a private instance of it.

Getting Hauppauge WinTV-PVR-150 IR Blaster to work

Posted on Wednesday, July 29, 2009 by Nicki

I'm ready to move to the next level, to be able to change the channels on my decoder using the IR blaster that comes with the PVR-150. This link will help you a lot: LIRC PVR-150 IR blaster support

I only had to download the firmware and put it into the /lib/firmware directory on mythbuntu, and configure the IR blaster in Mythbuntu Control Center. I still have to figure out which codeset to use, but at least the irsend makes the little led on the blaster flash now.

MythTV on Windows

Posted on by Nicki

I found a nice mythtv front-end for Windows, MythTV Player. Version 0.50 even supports Live TV. It can skip commercials as well.

I found the download here

My first foray into PowerShell

Posted on Friday, July 17, 2009 by Nicki

I needed to change the date/timestamp on a file, and found that the touch utility does not exist. I also could not find the XP resource kit download, which apparently contains it. Then I remembered that PowerShell was installed when I recently installed SQL Server Express 2008.


Here is how to change the timestamp of test.txt in the current directory to 31/08/2012 with PowerShell:
$(get-item test.txt).lastwritetime=$(get-date "08/31/2012")


You can find more info here.

How many rows in all the tables in a database?

Posted on Thursday, July 16, 2009 by Nicki

Often one needs to know the number of rows in all tables in a database, like when you are writing or executing tests, and need to know if you have test data for a table.


I found a nice query, and adapted it slightly for my use.
SELECT sysobjects.[name], max(sysindexes.[rows]) AS TableRows
FROM sysindexes INNER JOIN sysobjects ON sysindexes.[id] = sysobjects.[id]
WHERE sysobjects.xtype = 'U'
GROUP BY sysobjects.[name]
ORDER BY name
You can find the original here.

C# generics and testing

Posted on Tuesday, July 14, 2009 by Nicki

The power of C# generics, you just gotta love it.


I'm writing NUnit unit tests for the business objects of the application. All the factory objects happen to have a LoadById method that takes an int as parameter, and return a typed list.

This is beautiful, as I can write a generic test method that for the factory type and list type, and then just write a one-liner test for every factory I want to test.

The generic method:

public void TestGeneric(int logicalRecord) where L : new()
{
L list = new L();
Type x = typeof(L);
MethodInfo LoadMethod = x.GetMethod("LoadById");
List records = (List)LoadMethod.Invoke(list, new object[] { logicalRecord });
Assert.IsTrue(records.Count > 0);
}



Invoking the generic method with the Factory type and the List type
            TestGeneric(logicalRecord);


You just gotta love generics. More info here