Filtering Out of Office notifications from rt (Request Tracker)

Posted on Thursday, December 17, 2009 by Nicki

It's that time of the year again, where everyone has Out of Office replies set. One of our systems send out daily reports of files processed, and the Reply To address is set to the rt Queue address. This causes unnecessary requests being opened in rt for the Out of Office replies. What can one do?

Well, that's what I love about open source, procmail is your friend.

I found some references where people had exactly the same problem, so here is the solution I used based on those references.

Create/modify the procmailrc file (in my case it sits in /usr/local/etc/procmailrc).


# Trash Outlook autoreplies
:0 w
* ^subject:.*Out of Office AutoReply

# Pass to rt
:0 w
|/usr/local/bin/rt-mailgate --queue $QUEUE --action $ACTION --url http://xx.yyy.zz/rt

The $1 and $2 variables are arguments passed to procmail, see the arguments after the -a command line switch below. These are stored in $QUEUE and $ACTION and passed to rt-mailgate in turn to make the solution more generic and reuseable.

Then I modified the postfix aliases file to pass all mail for the queue to procmail:

raxas-request: "|/usr/local/bin/procmail -a Raxas -a correspond"

Then remember to execute newaliases and postfix reload, and send some test mails.

Source links:

Ubuntu and 1.44mb floppy drive

Posted on Wednesday, November 18, 2009 by Nicki

A neighbour recently had a computer crash, and needed to get some files off floppy disks for her school. Luckily my old Athlon700 serving as a mythbuntu PVR still had a floppy drive.

I inserted the disk, and tried to mount it. It said the device did not exist. Huh? Then it dawned on me that the driver was possibly not loaded. I did some googling, and found out that you have to do a sudo modprobe floppy to load the driver before trying to mount it.

After I did that I was able to get all the files off the 3 disks and burned them onto CD. It was quite a trip down memory lane, I can't remember how many years it has been since I last used a floppy drive. Just the sound of the thing copying the files was almost foreign. And the speed, wow. We have become so used to USB flash drives. This was portable data back in the days.

Sidestepping those AutoRun USB viruses

Posted on Sunday, November 15, 2009 by Nicki

I've had far too many people recently that got one of the AutoRun variants such as Conficker on their computers. Here is a tip on how to disable AutoRun (normally that window that pops up when you plug in a USB drive, but abused by Conficker and others to launch the viral code).

Click on Start / Run, type gpedit.msc and press Enter,

Then double-click Administrative Templates under Computer Configuration. Click on the System folder. In the right-hand side pane you should see Turn off AutoPlay. Double-click it, click on Enabled and make sure that All Drives is selected. Click Ok and close the Group Policy application.

Now whenever you plug in an infected USB drive it won't try to infect your PC right away.


CLR Procedure, next iteration

Posted on Monday, November 9, 2009 by Nicki

We have code that uses an old Extended Stored Procedure written in Delphi that is giving some problems, so I decided to rewrite the procedure in C# as a CLR procedure.

The code has to download emails from a POP mailbox and process the attachments. For the POP code I found a nice POP library:

I had to exclude the MessageBuilder class from being compiled, as it was referencing System.Drawing, with which SQL Server has some issues, and I did not want to delve into them forever.

The first challenge was to register the CLR procedures. The database needs TRUSTWORTHY property set to ON, because the CLR procedure needs to be created with UNSAFE permissions as it accesses the network for the POP mail download.

This is the error it gives:

CREATE ASSEMBLY for assembly 'IntRegPopUtil' failed because assembly 'IntRegPopUtil' is not authorized for PERMISSION_SET = UNSAFE.  
The assembly is authorized when either of the following is true: the database owner (DBO) has UNSAFE ASSEMBLY permission and the database has the
TRUSTWORTHY database property on; or the assembly is signed with a certificate or an asymmetric key that has a corresponding login with UNSAFE ASSEMBLY permission.
If you have restored or attached this database, make sure the database owner is mapped to the correct login on this server.
If not, use sp_changedbowner to fix the problem.

This is the change necessary:

Next is creating the assembly:

create assembly IntRegPopUtil from 'C:\work\sandbox\IntRegPopUtil\bin\Debug\IntRegPopUtil.dll' with permission_set = UNSAFE

And the CLR Procedure:

create procedure IntRegPopProcessMail as external name IntRegPopUtil.[IntRegPopUtil.IntRegBulkMail].ProcessMail

Now we are ready to execute the procedure.

If you get an error like the following when executing your procedure, you need to create the assembly with UNSAFE permissions, as above.

A .NET Framework error occurred during execution of user-defined routine or aggregate "IntRegPopProcessMail":
System.Security.SecurityException: Request for the permission of type 'System.Net.DnsPermission, System, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
at SmtPop.POP3Client.Open(String pop3host, Int32 port, String user, String pwd)
at IntRegPopUtil.IntRegBulkMail.ProcessMail()

The next challenge was to get my code to be able to read its appSettings from sqlservr.exe.config in the SQL Server Binn folder.

You have to restart SQL after creating the sqlservr.exe.config in the same folder as sqlservr.exe. Then the fun starts.

It kept on giving error like the following:

"The value of the property 'key' cannot be parsed.
* The error is: Request failed. (sqlservr.exe.Config line X)".

This seems to be a bug from SQL2005 beta days, the solution is to add a dummy call to the ConnectionStrings property, this causes it to initialize properly. I found the solution here.

int i = ConfigurationManager.ConnectionStrings.Count;

That's it, now the procedure can connect to the POP server to download the mail, and it can use settings from the <appSettings> section in the sqlservr.exe.config.

To update the assembly when you've made changes to the dll, use the following syntax:

alter assembly IntRegPopUtil from 'C:\work\sandbox\IntRegPopUtil\bin\Debug\IntRegPopUtil.dll'

Web application testing with Selenium

Posted on Tuesday, October 27, 2009 by Nicki

Someone told me about this wonderfull FireFox plugin called Selenium that one can use to record and automate web application testing. You can record, change and playback tests, and also use recorded tests to do load balancing.

For more details, see SeleniumHQ

ASP.Net 1.1 form not submitting on IE

Posted on Monday, October 5, 2009 by Nicki

We had this stubborn form that did not ant to submit when entering a value in the 1 textbox and pressing Enter. This is supposed to work!

After Googling a bit, I found the solution: just add another hidden HTML textbox to the page. This issue only occurs in IE when there is only 1 textbox control in the form.

You can confirm this behaviour by using Fiddler.

Credit to 4guysfromrolla.

Repeated conversion of Web project file

Posted on Wednesday, September 30, 2009 by Nicki

I had the dubious honour of converting a VB Web app from Visual Studio 1.1 to VS 2008.

Every time I opened the converted (or so I thought) project, it gave the following message:

The following Web projects must be converted to the new Web Site format. The conversion process will remove all source control bindings and the project will not be under source control after migration.

After the 3rd attempt it was not funny, so I googled it and found this fix:

1. For the project that's causing you the issue, backup your solution file, your project file, and the "hint" file associated with your project file (the .vspscc file sitting in the same directory as your project) to some other location.
2. Check out your solution file and the project file and close VS
3. Open the project hint file (.vspscc) in notepad, change the ENLISTMENT_CHOICE from COMPULSORY to "ENLISTMENT_CHOICE" = "NEVER"
4. Open your solution file in notepad, remove that line SccProjectEnlistmentChoiceX = 2 (X is the number that corresponds to your project that is causing you the problem). Also, if you see the line "SccWebProjectX=true" (x is again the number of the project in your solution), remove that as well.
5. Open everything in VS again, and assuming everything works now, check in your files.

Link to original article here.

IIS App pools and process ids

Posted on Tuesday, September 29, 2009 by Nicki

Have you ever needed to know which application pool is which process id? It turns out there is a script installed with Windows Server 2003 that can give you that information.

Just execute iisapp.vbs to list the app pools and the process id of the worker process.

More information here

OpenDNS for web filtering

Posted on Wednesday, September 23, 2009 by Nicki

If you have kids, or you manage the company firewall/proxy server, this service can be of great assistance to block unwanted sites. It is DNS based, and managed from a browser, so you have little (possibly in the case of dynamic ip) or no software to install to start using the service. All you have to do is change the DNS servers on your firewall/proxy.

For more info, go to to their site.

mythtv and cifs (samba)

Posted on Tuesday, September 22, 2009 by Nicki

Due to some error in the linux NFS client, I had to use CIFS to mount the storage from FreeNAS on my mythbuntu box. This seems to have created a new issue, whereby recordings do not get deleted by the backend due to "Text file busy" errors.

Because my storage was eventually going to fill up, I wrote a script to delete the recordings from the database and filesystem, and scheduled it in cron. It only deletes recordings that have been watched and with autoexpire on older than 14 days, plus LiveTV recordings with autoexpire on older than 7 days.

The script was in a .gz in the referenced directory, so I had to uncompress and chmod it.

mysql -u mythtv -ppassword mythconverg -e "delete from recorded where autoexpire=1 and watched=1 and endtime < curdate() - 14;"
mysql -u mythtv -ppassword mythconverg -e "delete from recorded where storagegroup='LiveTV' and autoexpire > 0 and endtime < curdate() - 7;"
/usr/share/doc/mythtv-backend/contrib/ --dodelete

Add CAPTCHA to your site, free

Posted on Wednesday, September 16, 2009 by Nicki

Google announced today that it has acquired reCAPTCHA, so I had a look at what reCAPTCHA offers. Turns out they have an API that lets you add CAPTCHA to your site. They have plugins for ASP.Net, PHP, Java, etc.

Have a look here.

ASP.Net AJAX Toolkit and 'AjaxControlToolkit' is undefined

Posted on Thursday, September 3, 2009 by Nicki

If your site uses AJAX, and you receive the dreaded 'AjaxControlToolkit' is undefined error, this might help you.

After some troubleshooting with Fiddler, I found out that I installed the FlatCompress ISAPI filter a while ago to test HTTP compression. It turns out this causes some problems with the ASP.Net AJAX toolkit. After I disabled it and restarted IIS, the error went away. Great. Now I can continue testing BugNET...

MyTechEd #Closing and final impressions

Posted on Wednesday, September 2, 2009 by Nicki

The closing presentation was informational as to what is coming down the line in terms of next generation user interfaces, etc. The insert by Arthur Goldstuck on broadband was very interesting.

Unfortunately I did not win the MVix PVR, or any other goodies for that matter.

MyTechEd #17 - Practical Web Testing

Posted on by Nicki

This was a very valuable presentation with lots of practical examples. Great to know some things are already available in Visual Studio 2008.

Link to presentation: download here

MyTechEd #16 - Inside T-SQL: Enhancements, Techniques, Tips & Tricks

Posted on by Nicki

This was a very informative session.

Keyword from the session: Insert statement multiple values, Common Table Expression, Using Hierarchy functionality for sorting, Inline functions, OUTPUT clause for INSERT, UPDATE, DELETE.

Link to presentation: download here

MyTechEd #15 - Understanding Microsoft ASP.NET Under the Covers

Posted on by Nicki

This was a VERY interesting session by a very knowledgeable presenter, Nic Goossens.

Link to presentation: download here

MyTechEd #14 - Team System 2010 Development Essentials

Posted on by Nicki

Some keywords from the session: Code Analysis,Extensions, Check-In policy, Work Items

Link to presentation: download here

MyTechEd #12 - Microsoft Visual Studio 2010 Overview for the Business Application Developer

Posted on by Nicki

An overview session with some demos.

Link to presentation: download here

MyTechEd #13 - How Microsoft and Others Use Team Foundation Server

Posted on by Nicki

This was a whiteboard session with some good panelists.

Some keywords from the session: Code Coverage, TFS Branching Guide


MyTechEd #11 - Using Virtualization to Improve Application Quality with Team System - Lab Management

Posted on by Nicki

This was a very interesting session to see some of the features that will be available in VS 2010 with regards to testing. Large software projects can definitely benefit from this. It just seems complex to set up and get going.

Link to presentation: download here

MyTechEd #10 - A Lap around Microsoft ASP.NET 4.0 and Microsoft Visual Studio 2010

Posted on by Nicki

Another most useful session by Mike Palermo.

Link to presentation: Download here

MyTechEd #9 - Team Build Tips and Tricks

Posted on by Nicki

This session showed amongst other things how you can customize the build process to automate versioning, etc. Quite useful. And I had information overload, I don't think there is a human that can consume all the words the presenter spoke in 1 hour.

Link to presentation: download here

MyTechEd #8 - A Strategic Comparison of Data Access Technologies from Microsoft

Posted on by Nicki

This was a whiteboard session, so there are no slides available. My personal opinion is that I will leave the Entity Framework, etc. to still mature a bit. Seems like Linq to SQL is just about dead, glad I did not jump on that bandwagon.

MyTechEd #7 - Guiding Your Query Plans in Microsoft SQL Server for Improved Query Performance

Posted on by Nicki

This was a VERY informative session. The presenter knows her stuff. This is also where I picked up on the NOLOCK issue I posted about previously.

With SQL2008 you can now give hints via SQL Management Studio, instead of having to code them into your SQL. This allows for easier application tuning, as no build-test-deploy of the application is needed.

Link to presentation: download here

MyTechEd #6 - What's new in SQL Azure

Posted on by Nicki

The starting pitch was "Everything you can do with SQL Server you can do with SQL Azure". The longer the session carried on, the more limitations came to light. Granted, they are not necessarily show stoppers, but could be depending on the application you might want to deploy.

Link to presentation: not available

MyTechEd #5 - SQL 2008: Best Practices and lessons learned

Posted on by Nicki

The presentation/presenter was a bit boring. There might be some value in the slides though.

Link to presentation: download here

MyTechEd #4 - Entity Framework Tips and Tricks

Posted on by Nicki

This session shared some tips and tricks on Entity Framework

Link to presentation: download here

MyTechEd #3 - Architectures: The good, the bad & the Ugly

Posted on by Nicki

A presentation about good and bad architectures.

Link to presentation: download here

nVidia TV Out on mythbuntu

Posted on Tuesday, September 1, 2009 by Nicki

I finally put in the LAN cable from my study/lab/network centre to the lounge so the mediacentre was moved to its final location close to the tv. Next up was getting the TV out to work to my tv. I used this site to get it working. Initally I thought I only had only black and white output, and struggled for 2 hours to try to get it working. I even went to far as to buy an S-Video - RCA cable, because a lot of references I found pointed to the fact that the RCA output on nVidia cards sometimes does not work correctly.

Well, after putting the new cable in, it still gave the same black & white results, but I now it works, because I just tested it on the DVD player. I used xclock to test, and it turns out I tried an incorrect/ignored command line option. After using the correct option, I have color! As they say: if it takes longer than 5 minutes it is probably a stupid mistake.

Next up is configuring the TV output to be the default/only display, and getting the remote blaster and my MNet decoder talking.

Here are the portions I had to add to /etc/X11/xorg.conf to get TV output working.

Section "Device"
Identifier "Device_tv"
Driver "nvidia"
VendorName "NVIDIA Corporation"
BoardName "GeForce2 MX 100/200"
Option "TVStandard" "PAL-I"
Option "TVOutFormat" "SVIDEO"
Option "ConnectedMonitor" "TV"

Section "Monitor"
Identifier "TV"
HorizSync 30-50
VertRefresh 50.0

Section "Screen"
Identifier "Screen_tv"
Device "Device_tv"
Monitor "TV"
DefaultDepth 16
Subsection "Display"
Modes "720x576" "720x480"

Section "ServerLayout"
Identifier "Layout_tv"
Screen 0 "Screen_tv" 0 0
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"

Debugging web application requests

Posted on Wednesday, August 26, 2009 by Nicki

Have you ever needed to debug a web application request for an application for which you do not have the source? There is a neat little application that can do it transparently, without needing you to reconfigure anything. It's called Fiddler, and you can download it here.

Some screenshots:

How to make video recordings of screen activity on your computer

Posted on Monday, August 24, 2009 by Nicki

A colleague found a nice tool for creating videos from activity on your computer, like when you show someone how to navigate your website, etc. It's called CamStudio, and is free. Get it here.


Common Table Expression (CTE)

Posted on Tuesday, August 18, 2009 by Nicki

Do you know what a Common Table Expression is? It is a temporary named result set that can make your SQL easier to read and maintain.

Where can I use it? Often one encounters a summary screen that has some basic information, along with a sum or count. One example is for instance details about an employee, plus a count of the number of people reporting to him. This can lead to some nasty SQL if you write it all in one statement. This is where CTE steps in. You can create a CTE for the number of people reporting to an employee, and join that with the employees table like it was a normal table.

In the example below the CTE is a result set with a ManagerID and the number of people reporting to that manager. It is then joined to the Employee table. Do you think it makes the SQL cleaner and easier to read?
USE AdventureWorks;
WITH DirReps(ManagerID, DirectReports) AS
FROM HumanResources.Employee AS e
SELECT e.EmployeeID, e.BirthDate, ISNULL(DirectReports, 0) as DirectReports
FROM DirReps as d right outer join HumanResources.Employee as e on d.ManagerID = e.EmployeeID
ORDER BY e.EmployeeID;

You can find some additional info here.

Adding more storage for mythbuntu (and other uses)

Posted on Sunday, August 16, 2009 by Nicki

Since my mythbuntu box is old and does not have onboard SATA support, I deciced to build a storage server with new hardware and record from the mythbuntu box to an NFS share on the storage server.

The hardware of choice was an Intel Atom motherboard, D945GCLF2D, due to the low processing power required. It has a 1.6GHz dual core processor, but is very quiet due to no fan on the processor (although the chipset has one!). Since I don't want to have problems later on, and RAM is so cheap nowadays I decided to get the max 2GB that the board supports, even though it is a huge overkill.

For storage I got 2 500GB SATA drives, which is going to be used in a RAID mirroring configuration to provide some form of protection from failure. Since I don't have hardware RAID capability, I needed another disk to install the base OS on, because the RAID volume would not be available until after boot. I also wanted a cost effective (read cheap!) solution, so I opted to get a USB drive to install the base OS on, since the motherboard supports USB booting. This meant I did not have to get an optical drive, which was only going to be used once for installation.

The software of choice for the storage server is FreeNAS, a free Network Attached Storage server based on FreeBSD. It has software RAID capability, and can exposes the storage in lots of different ways. It can also notify you via email in case something goes wrong with your server, so you can really hide the box in a corner and almost forget about it. Administration is via a web interface once you have it up and running and connected to a network.

I installed the embedded image from the downloaded ISO onto a USB drive using physdiskwrite, booted the new box with it, configured the disks, and shared the RAID volume via NFS. The next step was mounting the NFS share from my mythbuntu box, which was trivial as well, I only had to install the nfs-common package.

Initially I had a stability issue on mythbuntu with the NFS share, it kept hanging up after a period of inactivity, but installing all available updates seems to have cured that problem, I'm happily watching a recording as I'm typing this.

MyTechEd #2 - Visual Studio Tips and Tricks

Posted on Friday, August 14, 2009 by Nicki

Presenter: Mike Palermo

The session started off a bit rocky due to the fact that Mike's laptop and the projector did not want to go to a higher resolution than 640x480 or800x600, can't remember, all I know it was big and not a lot fitted on the screen. It was really unfortunate, as it was a great session.

One of the nice things we were shown was how to create your own code snippets.
Snippets are XML documents, so they can be created/edited easily. The standard code snippets are stored in Program Files\Microsoft Visual Studio 9.0\VC#\Snippets\1033\Visual C# for C#, so you can copy one from there to My Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets and edit it to your liking, obviously changing the Title and Shortcut values.

Look here for a snippet editor.

Other usefull tips were Prevent Copy on Blank Line and Toggle Clipboard. I'm not going to post every tip here, so please see Mike's speaker notes here.

Link to presentation: download here

My TechEd #1 - Dashboards & Scorecards

Posted on by Nicki

Presenter: Gavin Russell-Rockliff

This was an overview session to introduce the dashboarding and scorecarding capabilities available in the Microsoft platform.

The central component is PerformancePoint Server 2007, which now comes with MOSS Enterprise. A variety of datasources can be integrated into dashboard/scorecard, including SQL Services Analysis Services, Excel 2007, Excel Services and Relational Tables.

Link to the presentation: download here

WITH NOLOCK = dirty rotten scoundrels

Posted on Wednesday, August 12, 2009 by Nicki

A comment by a presenter at a SQL Server tuning session at TechEd Africa 2009 sparked my interest, so I decided to investigate.

Do you use WITH (NOLOCK) with each SELECT statement? Do you know what it does?

Let me fill you in. It allows your query to read uncommitted data, i.e. deleted or inserted rows that might still be rolled back. Even worse is that it can double read rows, or even misread rows. Imagine the impact it might have on financial systems...

This might be ok in a data warehouse environment (when the data is not being updated), but certainly is not ok in a transactional database.

If you still need convincing not to to it, look here.

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]
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

You just gotta love generics. More info here - grabb'em while you can

Posted on by Nicki

If you have online bookmarks at, 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 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. is dead, or is it?

Posted on Thursday, July 9, 2009 by Nicki is (or should I say was?) an online bookmark service, like 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 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]


Status NCHAR(30),
Login NCHAR(128),
HostName NCHAR(128),
BlkBy CHAR(5),
DBName NCHAR(128),
Command NCHAR(16),
LastBatch VARCHAR(20),
ProgramName NCHAR(128),
RequestID int

exec sp_who2 active

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

WHERE Status != 'BACKGROUND' AND HostName != ' .' AND SPID != @@spid


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

COALESCE(NULLIF(@stmt_start, 0), 1),
CASE @stmt_end
(@stmt_end - @stmt_start)
FROM ::fn_get_sql(@sql_handle)





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

Sony TSL300C Illegal Cassette Config

Posted on Monday, June 29, 2009 by Nicki

One of the tapes in our tapeset failed, and a new one was labelled. This is where the trouble started.

As soon as the magazine is inserted into the drive, it scans all the tapes. Every time it gets to the position where the new tape is located, it ejects the magazine with a "Illegal Cassette Config" error together with flashing indicator for the position where the tape was located. I searched on Google, and could not find anything. That usually spells trouble. I grabbed an old tape, as well as a new one and a cleaning tape.

After inserting the new (unlabelled as in sticker on the tape) tape into the drive, it loaded. Then we had a look at the other new tape we tried to load, and realised that we had used the bigger sticker label instead of the narrow one, and it covered some indentations obviously necessary for the tape to be detected. After replacing the label with the correct one, all was well.

A huge relief when I was prepared for a good couple of hours...

Creating a SQL Server CLR Procedure

Posted on Thursday, June 25, 2009 by Nicki

I ventured into unchartered territory (for myself) and created a SQL Server CLR Procedure today. It is actually very easy.

First, create a class library project in VS 2005/2008. Create a class with a static method that will be the CLR Procedure

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using System.Data.SqlClient;
using Microsoft.SqlServer.Server;

namespace SQLCLRTest
public class SQLCLRDemo
public static void HelloWorld()
using (SqlConnection conn =
new SqlConnection("context connection = true"))
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "SELECT 'Hello World!' AS Greeting";
Then you have to register the assembly in SQL Server

CREATE ASSEMBLY SQLCLRTest FROM 'C:\work\sandbox\SQLCLRTest\SQLCLRTest\bin\Debug\SQLCLRTest.dll'

Then you create the procedure


You might have to enable CLR execution in SQL2005

EXEC sp_configure 'clr enabled', 1;

Then you can appreciate the fruits of your labour

exec HelloWorld

Hello World!

(1 row(s) affected)

Now that was easy!

MSDN reference here
Error when creating CLR procedure here
Enabling CLR in SQL Server here

How to connect to SQL Server, VS TFS, etc using Windows Authentication when computer is not on Active Directory Domain

Posted on by Nicki

I often move around between different clients, and never join their domains, simply because my machine would get cluttered with policies and logon scripts, so I've encountered this problem before.

To access a fileshare, you just map using
net use \\machinename\ipc$ /user:domain\user
This does not work for connecting to SQL Server with Windows Authentication though. I found this neat little trick to accomplish this:
runas.exe /netonly /user: "C:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\ide\SqlWb.exe"
This runs Management Studio as the domain user, which can then authenticate to SQL Server using Windows Authentication.

The original article can be found here

ASP .Net Windows Authentication

Posted on by Nicki

If you use Windows Authentication, and the user is not allowed to access the specific page, a nasty 401.2 Access Denied error message will be displayed to the user. What if you want to display a friendly error message?

You would think that an entry in the <customErrors> section would work? No, it does not.

To get to the solution: You have to define Application_EndRequest in Global.asax.cs that looks something like

protected void Application_EndRequest(object sender, EventArgs e)
HttpContext context = HttpContext.Current;
if (context.Response.Status.Substring(0,3).Equals("401"))
context.Response.Write("<script language="javascript">" +

Then you create the NotAllowed.aspx page to display a nice friendly message to the user.

You can find more information here.

ASP.Net configure page-level security

Posted on by Nicki

Did you know that you can configure security on a page level instead of on a folder level, like the custom tool in Visual Studio does?

Here's how:

Outside the section in the Web.config, add a location tag and configure the required security for the location.

<location path="Default.aspx">
<allow roles="Users"/>
<deny users="*"/>

This is all in the main Web.config file, so it does not require a folder per role with its own Web.config for which you want to secure pages, reducing the deployment complexity.

You can specify a directory in the path attribute, which will then apply all settings to that directory. It seems that you can also have nested <location> tags, so you can define a <location> tag for a directory, and then define a <location> tag for each page in the folder, each with its own settings. I think it is brilliant!

I found some details on the subject here. You can find the reference in the MSDN library here.

Building a Linux MediaCentre

Posted on Tuesday, June 23, 2009 by Nicki

I'm currently toying with the idea of building a Linux MediaCentre to record and watch TV, as well as store and display photos, as my VCR is getting old.

KnoppMyth (soon to be called LinHES) has drawn my attention, as it is already in version 6. The card I'll be using initially will be a Genie Wonder Pro that I have lying around. Are there any DVB-T (DTTV - soon to be launched in SA) cards available in SA already?

Hopefully I'll install everything in the next couple of weeks.

Perl upgrade on FreeBSD

Posted on by Nicki

Have you ever done a perl upgrade on FreeBSD, only to find that none of your installed ports that use perl work anymore? I recently had that shock, and found the following hint:

Execute perl-after-upgrade after upgrading perl on FreeBSD, it will display all modules that needs to be updated. Then execute it again with the -f switch to actually make the required changes.

Voila, everyone settle down again please!

Flushmaster not flushing

Posted on by Nicki

We have two Cobra Flushmaster flushvalves in our toilets at home, and recently the one refused to flush. I enquired as to pricing, and was shocked. A new one is about R2k. I spoke to the guys in the plumbing department at my local hardware store, and they suggested a seal kit at R200. I was quite scared of tackling this, as I could end up having to fork out R2k if I get it wrong...

It took about 1.5-2h to take it apart and replace the seals, taking care not to break anything in the process. I also cleaned gave it a thourough cleaning and lubed the moving parts with some wheel bearing grease. Imagine the relief when I put it all back together and it flushes like a new one. Now if I could get some goodies with the money saved...

SQL Server 2008 Spatial, Google MAPS API

Posted on by Nicki

At a recent TechDays event I was introduced to the spatial features in the latest version of SQL Server, 2008. Spatial apps has interested me for a while, but I never really got a chance to do anything, I suppose in a way due to the preceived complexity.

I wondered what I could to with the new sptial features. A farmer on one of the forums I frequent recently suggested that the fellow forumites acquire rainmeteres and report daily rainfall figures, as rainfall often differs sunstantially between areas just a few km apart. Well I thought, why not write an application allowing users to register their geographical locations and record their rainfall, and display the data on a map?

This is where Google Maps API comes in. It allows you to populate a map on your own website with your own objects. I was amazed at the amount of free custom controls available for the Google Maps API, and quickly put together the site.

You can see the end result here.

Javascript, Timezones and Google Mail

Posted on by Nicki

Google hosts the email for my domain, and I've always had an issue with the times of messages in the message list displaying incorrectly. I just ignored it for a while, but then it became too irritating to ignore anymore.

The correct time was displayed in IE, but not in FireFox and Google Chrome. Creating a test.html page containing a script tag with the instruction alert(new Date()) showed the differences.

I browsed the Google Help forums for assistance, and the suggestions I found did not help. I found a thread that could be relevant ( and followed on the postings. After trying a couple of things, bkenelly suggested that I have a look for the TZ environment variable, as the Timezone setting (via double-clicking on the clock) was correct.

There was no TZ environment variable set under My Computer / Properties / Advanced / Environment variables, but executing the SET command in a Command Prompt showed that TZ was defined as CAT2. This caused the mysterious 4h difference. After defining TZ to GMT-2 and restarting Chrome, the time was correct. Hooray!!!

What is this all about?

Posted on by Nicki

When I was a little boy, I had a red knitted jacket that I used to live in, especially in winter. I was so fond of it, the workers on the farm called me Jasman, the Afrikaans for "Jacket Man", directly translated.

On this blog I intend to post about things I encounter in my daily life, from computer programming to toilet flushvalves to linux media center to motorcycle maintenance.