XHTML in Mantis 1.3 development trunk

I just wanted to upgrade my current installation of Mantis to the current 1.3.0 trunk. But this wasn’t as easy as in previous development releases of mantis. Obviously the content-encoding switched to more strict xhtml+xml. In previous versions the HTTP content-type was still text/html, which worked just fine. Using Firefox is no problem, but Internet Explorer doesn’t like the content-type application/xhtml+xml and always tries to download the page instead of displaying the page.

To resolve this problem I added a test prior to sending the content type, to which content type is actually supported by the client. The content-type is set in thehttp_api.php, so the modified function http_content_headers() looks like this:

 * Set content-type headers.
function http_content_headers() {
    if ( !headers_sent() ) {
        if (stristr($_SERVER[HTTP_ACCEPT], "application/xhtml+xml")) {
            header( 'Content-Type: application/xhtml+xml; charset=UTF-8' );
        } else {
            header( 'Content-Type: text/html; charset=UTF-8' );
        // Disallow Internet Explorer from attempting to second guess the Content-Type
        // header as per http://blogs.msdn.com/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-pro
        header( 'X-Content-Type-Options: nosniff' );

On another quick side-note: I had some custom HTML to include my own header to mantis, which caused an XML parse error – this was because I didn’t close the img tag for an embedded image.

Printer mapping in script

On a side note, a quick way to add printer mappings in a logon script. Even though logon-scripts seem a little out-dated with the power of group policies … non the less.

OK, to map a printer to a local machine you can leverage the rundll32.

rundll32 printui.dll,PrintUIEntry /in /n \\[server]\[printer_share]

Manually restore timer settings

I just updated the image of my dreambox to the latest offical DMM release.

To get a clean start I did a manual backup of my settings located in /etc/enigma2. Actually the most valueable settings are the bouquets and the timer settings. So I just copied all files from /etc/enigma2 via FTP to my computer.

Restoring the bouquets is actually quite easy, just copy the bouquet files back to /etc/enigma2 and restart enigma. Voila!

But the timers.xml is totally different story. The timers.xml is being loaded into memory when enigma starts and is written back to disk when the box shutdowns. So just copying the timers.xml from the backup back to disk doesn’t do anything, since the file is being overwritten when enigma stops.

The solution is actually quite easy as well. Turn off enigma will flush the timers.xml to disk. To shutdown only enigma without turning off the dreambox you have to switch the runlevel. switching to init 4 will cause just this. Now you can copy the timers.xml from the backup to disk and then restart enigma with either init 3 or by starting enigma2.

Trimming SQL databases

Update 2012-06-15: I just realized, that although I shrink the logfile after changing the recover-model, I actually should truncate the logfile. This way all stored transactions are getting pruged from the logfile. I updated the last script accordingly.

The other day I already cleaned out some cache files to free up some space on my dev-machine. Since I’m on a roll I thought I just take a look at my SQL databases.

Recently I picked up a classic-thread around DBA’s. At a client the database stopped working, because the server ran out of disk-space. Obviously the databases are set to full recovery-model, but apparently the logfiles where never backed up. Consequently the logfiles consumed all available disk-space.

OK, we’re talking a dev-machine here, so I don’t really care about data-security. So I don’t care about full recovery-models for my databases.

So let’s take a look at the current databases.

SELECT [name] AS [DatabaseName],
CONVERT(SYSNAME, DATABASEPROPERTYEX(N''+ [name] + '', 'Recovery')) AS [RecoveryModel]
FROM master.dbo.sysdatabases
where CONVERT(SYSNAME, DATABASEPROPERTYEX(N''+ [name] + '', 'Recovery'))='full'

This will give us a list of all databases with full recovery-model. Changing the recovery model for a particular database is actually quite easy.


But that’s not all, you actually need to shrink the logfile as well.

DBCC SHRINKFILE (N'test_log' , 1)

When you have more than just a couple of databases, you might want to speed thinks up a little.

FROM master.dbo.sysdatabases
WHERE CONVERT(SYSNAME, DATABASEPROPERTYEX(N''+ [name] + '', 'Recovery'))='full'
SELECT 'USE [' + sysdatabases.[name] +']; DBCC SHRINKFILE (N''' + master_files.[name] + ''',0, TRUNCATEONLY);'
FROM sys.master_files
  INNER JOIN master.dbo.sysdatabases ON
    master_files.database_id = sysdatabases.dbid
WHERE CONVERT(SYSNAME, DATABASEPROPERTYEX(N''+ sysdatabases.[name] + '', 'Recovery'))='full'
AND [type]=1

This will give you all the sql statements needed to modify all your databases.

Freeing space in Windows

I’ve now been working with my virtual dev-machine for about one year, and it starts to show. I have installed quite a rig of software like SharePoint, Visual Stduio 2008 and 2010, SQL Server 2008, Office 2007 yada-yada-yada.

I just realized that also keeping always up-to-date with all updates and service packs does has some impact on the available disk-space. I know that Windows 2008 itself is not suited for a small drive, but I still wondered how much space the windows-folder could consume.

So I looked into the windows-folder to get a broad overview of what’s actually happening there. And I noticed that the installer-folder is actually eating up quite some space.

Luckily I found a couple of great posts by Heath Steward about the PatchCache folder. To control the size of the PatchCache folder you also might want to take a look at the MaxPatchCacheSize in the windows registry.

For me, that re-gained me about 2.6 GB of disk-space. For a virtual machine running on a laptop this is quite something.

BTW: this is also applicable to other OS, like Windows 7, Vista, XP …

I just hope, that this will not haunt me some time in the future – but then again, it’s just a dev-machine.

AutoHotKey & Notepad++

OK, so I want to get a little more automated, so I figured to go with AHK. So downloading AHK is easy, and getting started using Notepad is also good for the getting started.

But before I get serious I do want some kind of comfort-environment to edit scripts. So I pick my currently favorite editor: Notepad++.

While there is actually a description on how to setup various versions of Notepad++ to work with AHK, I found some pieces were not working – at least not with my current version 5.8.1 of Notepad++. So here are my few steps to get up and running with AHK & Notepad++:

  1. Have Notepad++ and AHK installed (duh!)
  2. Instead of the bundled userDefineLang.xml of AHK I used some modified version. Just download that file to any location.
  3. Start Notepad++ and go to Display\Userdefined Language.
  4. Import the userDefineLang.xml downloaded in step 2.
  5. To get Command-Completion download API-definition and place the XML file into your Notepad++-Programfiles\Plugins\APIs.
  6. Restart Notepad++

Apply Workflows to folders

In my last blog-post I described how to enable meta-data for folders. Even though you can configure workflows for your custom content-type (of type “folder”), there seems to be no way to actually start those workflows. There is no context-menu entry to start such workflows as for any other content-type.

But there is a way! If you happen to know the right URL to start workflows … just call /_layouts/Workflow.aspx?ID=[ItemID of the folder]&List=[GUID of the list]. Just insert the appropriate values and off you go.