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

Spurl.net - grabb'em while you can

Posted on by Nicki

If you have online bookmarks at spurl.net, grab them while you can. I downloaded mine today, both the bookmark.htm and the bookmarks_xbel.xml. I don't know what the future holds for spurl, it has not been in a good state for weeks.


Do it, NOW!

Want to get rid of Word as default .htm(l) editor

Posted on by Nicki

Seems like MS thought Word was a good html editor. NOT!


I finally had enough of right-click Edit on html file, and then Word pops up. Good grief, what were they thinking? Here's how to get rid of that.

Open a new explorer, click on Tools / Folder Options / File Types. Scroll to HTM, select it, click Advanced, make sure Edit is selected, and click Edit. To make Visual Studio 2008 the editor, paste this in the 2nd entry field (Application used to perform action)

"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" "%1"

Click all the right buttons to confirm and get out, and test it.

What's in Google Chrome cache?

Posted on by Nicki

I'm trying to get my bookmarks from spurl.net while it seems to be up (albeit VERY slow), and the bookmarks.htm download broke with the html downloaded, but not the images. I wanted to see if I can grab it from the cache.


I found a nifty little tool, ChromeCacheView, that you can use to view what is in the cache, if you ever needed to.

Spurl.net is dead, or is it?

Posted on Thursday, July 9, 2009 by Nicki

Spurl.net is (or should I say was?) an online bookmark service, like del.icio.us. I've added quite a lot of bookmarks there, and it seems they might all be gone, as I've been unable to access the service for the past week or so. I've sent them emails, even that does not seem to get delivered.


If anyone from spurl.net reads this, I would like my bookmarks back!

I think I'm going to go with Google Bookmarks for now, they have the best chance of surviving IMO.

mythbuntu + Hauppauge PVR150 = win-win

Posted on Tuesday, July 7, 2009 by Nicki

I got a Hauppauge PVR 150 card today, installed it in place of the Genie Wonder Pro, configured it and the remote in the Muthbuntu Control Center, and it works out of the box! No editing of config files, no manual tricks, nada, niks!


It is brilliant when software and hardware gets this this level, especially on Linux.

Big thumbs up to the mythbuntu and mythtv guys, you rock!

mythbuntu 9.04 - 1, KnoppMyth 5.5 - 0

Posted on Sunday, July 5, 2009 by Nicki

I dug an old Athlon 700 out of retirement, and fitted my Genie Wonder Pro TV card in it to see if I can get it working as a media centre.


First I tried KnoppMyth 5.5. Setup worked fine (after I replaced the faulty pc133 memory), but I could not get it to Watch TV, no matter what I tried. After a day or so of struggling, I gave up.

Next was mythbuntu 9.04. Setup went without a hitch, and I could Watch TV!!!! Then the struggle to get the Genie Wonder Pro audio working started. In case you have the same problem - just connect the audio line from the card to your motherboard's aux input and forget about getting btaudio working... I've set up some xmltv schedules, and have some recordings scheduled for the next few days. The machine only has 384mb RAM, so it swaps a bit between certain ops like MythTV setup and MythTV frontend. I'm looking to upgrade to an Intel Atom or such and a proper capture card like a Hauppage 150 soon.

All in all, I have hope for a Linux Media Centre after mythbuntu, they've done a good job in my opinion.

What SQL is currently executing?

Posted on Friday, July 3, 2009 by Nicki

Have you wondered what SQL is currently executing on SQL Server, or which statement in a stored procedure is currently executing? Below is a script to create the sp_currentsql stored procedure.


I got this contribution from a colleague, thanks J.


CREATE PROCEDURE [dbo].[sp_currentsql]
AS

SET NOCOUNT ON

CREATE TABLE #SP_WHO2 (
SPID SMALLINT,
Status NCHAR(30),
Login NCHAR(128),
HostName NCHAR(128),
BlkBy CHAR(5),
DBName NCHAR(128),
Command NCHAR(16),
CPUTime INTEGER,
DiskIO INTEGER,
LastBatch VARCHAR(20),
ProgramName NCHAR(128),
SPID_2 SMALLINT,
RequestID int
)

INSERT INTO #SP_WHO2
exec sp_who2 active

DECLARE @SPID int
DECLARE @sql_handle binary(20), @handle_found bit
DECLARE @stmt_start int, @stmt_end int
DECLARE @line varchar(8000), @wait_str varchar(8)

DECLARE curSPID CURSOR FOR
SELECT DISTINCT SPID
FROM #SP_WHO2
WHERE Status != 'BACKGROUND' AND HostName != ' .' AND SPID != @@spid
OPEN curSPID


FETCH NEXT FROM curSPID INTO @SPID

WHILE @@FETCH_STATUS = 0 BEGIN
SELECT @sql_handle = sql_handle,
@stmt_start = stmt_start/2,
@stmt_end = CASE WHEN stmt_end = -1 THEN -1 ELSE stmt_end/2 END
FROM master.dbo.sysprocesses
WHERE spid = @SPID
AND ecid = 0

SELECT @line=SUBSTRING( text,
COALESCE(NULLIF(@stmt_start, 0), 1),
CASE @stmt_end
WHEN -1
THEN DATALENGTH(text)
ELSE
(@stmt_end - @stmt_start)
END
)
FROM ::fn_get_sql(@sql_handle)
SELECT @SPID SPID, @line SQL

FETCH NEXT FROM curSPID INTO @SPID
END

CLOSE curSPID
DEALLOCATE curSPID

DROP TABLE #SP_WHO2

GO

Windows XP refuses to hibernate

Posted on Thursday, July 2, 2009 by Nicki

For a while now my laptop has refused to hibernate. One out of every 20 times it would hibernate, otherwise it would black the screen briefly and continue running, without any error messages. My machine takes quite a few minutes to boot up, due to all the stuff installed, so this was becoming quite annoying, as hibernate/resume is so fast compared to shutdown and boot.


I digged around the net, and found that MS has a patch for this very problem. I installed it, and now my machine hibernates for days on end without any problems.

To download the patch, go to http://support.microsoft.com/kb/909095