Monday, 13 September 2010

Dell XPS M1330, nVidia GeForce 8400 GS overheats and the laptop cuts out

I have had this laptop this January 2009 and it’s been fine, but recently it’s been cutting out if I use Google Earth or Bing Maps!  I have measured the temperature at which it cuts out is about 110 degrees.  When it turns on again, it reports either error #M1001 or #M1004.  This is apparently and overheating problem with the nVidia GPU.

I am contacting Dell about this, however my motherboard was only replaced last month when my graphics card failed with what I can only describe as “on screen display corruption issues”.  Weird symbols and colours appeared.  Oh well, looks like I’ll need another repair, or just have to buy a new laptop as I’m a freelancer, so the loss of earnings will eventually become greater than the cost of a laptop, so I may as well get a new one… hopefully from a more reliable brand.

UPDATE: 15th September 2010: A Dell engineer changed the heat sink and now it runs perfectly!

ASP.NET MVC 2, “Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted” and the ValidateInput does not work

If you have problems getting the [ValidateInput(false)] attribute to work in a Visual Studio 2010 ASP.NET MVC 2 solution; please remember to put requestValidationMode="2.0" on the httpRuntime element of the web.config.

Then everything will be fine. Enjoy.

Monday, 23 August 2010

Umbraco 4.x – Warning on upgrading document types

Please be aware, though Umbraco is a great Content Management System, once you have deployed an application based on it – it’s very difficult to upgrade items in the meta-database afterwards.  Umbraco Courier does a good job of transferring content, but it doesn’t take into account changes to Document, Media and Member types, nor does it take into account new macros or changes to settings on those entities.  Courier will report the problems as you try to migrate content which is dependent on a latest meta database changes.

This is akin to developing your database in the development environment, then, once you’ve deployed the software, having to use the SQL Table Designer GUI make all the necessary schema changes manually.

Thursday, 5 August 2010

Dynamic subdomains on Apache and PHP

To rewrite subdomain urls internally to subdirectories under the root, ensure mod_rewrite is installed in Apache. Configure .htaccess inside the root directory as follows:-

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\
RewriteCond %{HTTP_HOST} ([^.]+)\
RewriteRule ^(.*)$ /home/sites/

Obviously replace “mydomain” and change the path on the last line to where your website physically resides on the server. Use the variable %1 to use the name of the subdomain as the name of the destination subdirectory.

Wednesday, 21 July 2010

My iPad Review

I got an iPad a few weeks ago and thought I’d share with you the pros and cons I have discovered:-


  • Great for reading e-books and PDFs
  • Makes surfing a web really easy as you can pinch, zoom and scroll really easily using just one or two fingers
  • Watching YouTube and videos is a really tactile experience, and so is viewing Photos.
  • If you get an iPad you can run both iPhone and iPad apps on it.  This is great if you’re a developer and want to target both platforms and not have to purchase an iPhone. For me the cost of getting into iPad and iPhone development has been about £1000 (£500 for the iPad and about £500 for the Mac Mini). Although they have just put up their Mac Mini price.  If I’d had to purchase an iPhone as well, the cost would be today at about £1700.  I have saved £700!


  • The Apps in the App Store don’t have a trial period, so if you don’t like it, then you can’t get a refund.  Also, sometimes the description of an App can exaggerate how good it really is
  • Apps can be a bit too expensive
  • Re iTunes;  I can get the IT Crowd from channel 4 for £10.  However, on a Windows PC or a Mac I can go to 4OD on and watch loads of stuff for free.
  • No support for Flash, so stuff like 4oD doesn’t work :-(  Also, the BBC News website experience is degraded as they rely on flash
  • When I download Spotify I find I cannot play music in the background (although this is an iPhone app, maybe an iPad version will be different)
  • When I plug in headphones the sound doesn’t seem to come through – not sure whether this is a fault or a configuration problem
  • The soft-keyboard is a bit annoying (although, a keyboard or anything other than a proper physical one is generally annoying!)

All in all, if I had £500 to spend and I needed a computer, I’d probably get a netbook and pocket £100-£200. Just because a netbook supports everything and there’s an abundance of free software out there and it’s compatible with most things (e.g. Flash), and it has a regular keyboard so you can work and play on it.  Sure, it won’t have integrated 3G, but get a bluetooth link to a 3G-enabled mobile phone and you’re sorted.

Steve Jobs said in his keynote speech, introducing the iPad that it occupies the same market space as netbooks.  Although for me, it’s just a different type of device really – and very niche.

In summary then… an iPad is

  • Less functional than a netbook (you can literally do anything a PC can do, albeit slower)
  • More controlled and regulated by Apple HQ
  • However a much more tactile, novel and fun experience

My gut feeling is that, one day, a manufacturer will invent a powerful netbook with a detachable screen and all the fun of an iPad. At least I hope this will happen, alongside a de-facto open e-book format.

Wednesday, 30 June 2010

Get this? Windows Azure MMC, Could not load file or assembly 'Microsoft.Samples.AzureManagementTools.PowerShell, Version=1.1.3779.27370, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

You probably have a previous version of the Windows Azure SDK. Delete all but the latest folder from ‘C:\Program Files\Windows Azure SDK’.  For me, I had to delete the folder ‘C:\Program Files\Windows Azure SDK\v1.0’

Thursday, 10 June 2010

Google copies Bing!

One day I woke up to find this atrocity!


And then realised they were trying to do this…


I think maybe Google use – which is nice. Well done bing.

Tuesday, 27 April 2010

Escaping javascript strings in Umbraco XSLT macros

How to escape string literals in XSLT which appear inside JavaScript function calls:-

<xsl:variable name="apos">'</xsl:variable>
<xsl:if test="data[@alias='popupMessage'] != ''">
      <xsl:attribute name="onclick">
        <xsl:text>return window.confirm('</xsl:text>
        <xsl:value-of select="umbraco.library:Replace(data[@alias='popupMessage'], $apos, concat('\',$apos))" disable-output-escaping="yes" />

Sunday, 25 April 2010

ASP.NET, hMailServer, error “The SMTP server requires a secure connection or the client was not authenticated” or “SMTP authentication is required”

If you receive the above error message when sending email via hMailServer’s SMTP Service, just go into the Admin console –> Settings/Advanced/IP Ranges/My Computer and uncheck the boxes below.


Windows Server 2008, IIS 7, Shared Configuration, System Corrupted Irrecoverably

The story is, I tried to copy IIS7 configuration from one Windows Server 2008 server to another. 

  • This overwrote the applicationHost.config
  • IIS/App Pools failed because global modules that were on the previous server were not installed on the current
    • Attempted to install those modules
    • that failed.
  • Thought I’d try to rollback, but it doesn’t backup the original IIS7 config
  • Uninstalled IIS7
    • Tried to reinstall IIS7
    • That failed
  • Tried to set up Windows Installer tracing with special registry entries
    • Tracing doesn’t work, no file is output into the %Temp% directory
  • Now wanting to do a system restore
    • There’s no system restore on Windows Server 2008

Quite a disproportional dilemma given the cause.

I like Microsoft – sometimes.  But really, I have had problems with Windows Server set up before… they haven’t put the effort into making this work.  And given that it’s usually professionals who are working setting up boxes, it would be a good idea to give some error messages that mean something.

Tuesday, 13 April 2010

Message: Type 'umbraco.DataLayer.SqlHelperException' in Assembly 'umbraco.DataLayer, Version=, Culture=neutral, PublicKeyToken=null' is not marked as serializable.

This is most likely because the database is inaccessible to Umbraco.  Check the connection strings are correct and also try connecting using the same connection string credentials with SQL Management Studio. 

Friday, 26 March 2010

MSMQ "The destination queue does not exist” or “BadDestinationQueue” when sending MSMQ messages or WCF net.msmq bound service calls

If you’re sending MSMQ messages using the DNS name of the server, you may get one of the above errors… this is easily fixed by adding a new registry key which tells MSMQ to ignore the hostname validation.

  1. Click Start, click Run, type regedit, and then click OK.
  2. Locate and then click the following key in the registry:


  3. On the Edit menu, point to New, and then click DWORD Value.
  4. Type IgnoreOSNameValidation, and then press ENTER.
  5. On the Edit menu, click Modify.
  6. Type 1, and then click OK.

See the Microsoft Support Article.

Wednesday, 24 March 2010 product feeds gzip trailer invalid / corrupt.

Please note that product feeds in gzip format are corrupt.  There is no CRC32 or ISIZE value in the trailer of the file which is required. Please see the gzip spec. You can see this by opening a valid gzip file and their invalid gzip file in WinRAR or 7-Zip… there’s no input file size or CRC in the file.
Also see

On a separate note; if you're looking for free online event registration and booking management, check out this website.

GZipInputStream, GZipStream, GZipUtil, C#.NET UNIX .gz files - decompression ends prematurely - Workaround

I have been trying for days now to decompress a 10MB gzip file using
  • ICSharpCode.SharpZipLib.GZip.GZipInputStream,
  • Ionic.Zlib.GZipStream,
  • and System.IO.Compression.GZipStream
Using both my own code and other people’s code from all over the Internet.  I have tried analyzing the file to make sure it’s valid – and it is. The only thing I know about this file is that it’s been compressed by a UNIX based system with the “DEFLATE” method, downloaded over http and can be successfully decompressed by 7Zip, WinZip and WinRAR.  But when it comes to decompressing the file within C# with various libraries, it’s just not happening.  It always prematurely ends the decompression, so I get a truncated file.
In the end, I decided to wrap a call to gzip.exe which can be downloaded from  or the direct Windows Download is here.
Put gzip.exe inside your project folder, in Solution Explorer and ensure “Copy to output directory” is set to “Copy always”.  The code for calling the exe is below.
/// <summary>
/// Uncompresses a gzip file 
/// </summary>
/// <param name="gzipFilename"></param>
/// <returns></returns>
public static string UngzipFile(string gzipFilename)
    const string GZIP_EXE_NAME = "gzip.exe";
    string gzipExePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, GZIP_EXE_NAME);
    string args = string.Format("-d \"{0}\"", gzipFilename);
    var p = System.Diagnostics.Process.Start(gzipExePath, args);
    return gzipFilename.Remove(gzipFilename.Length - 3, 3);

UPDATE: ok, the files I’m trying to decompress are corrupt – they have no ISIZE or CRC32 GZip File Trailer (well, they are zero, which can’t be good).  I wish there was a way to force it to decompress as the bandwidth usage for uncompressed it massive.

UPDATE MAY 2012: Turns out the GZip file is a multi-part BGZF "Blocked GNU Zip Format" file.  Basically, it's a file with multiple GZip files concatenated.  In order to support BGZF with GZipStream you must first pre-process the GZip file and strip out all the additional GZip file headers and footers... then concatenate all the compressed payloads. See:

Tuesday, 16 March 2010

How to horizontally centre align an inner div of unknown width within an outer div of known width :: CSS, JQuery, HTML.

Situation:  You have a an outer div with the id “outer” and an inner div called “inner”.  The menuCont div is of fixed width; let’s say 960 for this example.

The inner div contains variable width elements and you cannot know at design time how many elements and of what width they will be.  You cannot do this with CSS alone (but if you know how, please do share!)

Here’s the solution – it relies on jQuery BTW.

Set the CSS as follows:


And HTML as follows:

<div id="outer">
  <div id="inner" style=”display:none”>
    <!-- Insert variable width elements here -->

And then JavaScript:

$(document).ready(function() { = function() {
        return this.each(function() {
            var el = $(this);
            var w = el.width();
            var w_box = 960; // TODO: ADD THE CONTAINER WIDTH HERE!
            var w_total = (w_box - w) / 2;
            var css = { "position": 'absolute', "left": w_total + "px" };
$("#inner").fadeIn(); // optional! could use show()

This solution can definitely be improved – but it’s a start.

Monday, 15 March 2010

HttpModule and Application_Start

Unfortunately there is no “Start” event to hook onto for HttpModules.  Instead you should use Init() – be aware though that there may be multiple instances of your http module, serving many threads in the appdomain.  So you need a bit of thread sync’ing in order to ensure that your start-up code only executes once.

    public class MyHttpModule : IHttpModule
        /// <summary>
        /// Mutex object which gives the lock statement something to get an exclusive lock on
        /// </summary>
        private readonly static object _mutex = new object();
        /// <summary>
        /// Flags whether the application has started
        /// </summary>
        private static bool _isInitialised = false;
        #region IHttpModule Members
        public void Dispose()
        public void Init(HttpApplication context)
            if (!_isInitialised) 
                lock (_mutex)  
                    if (!_isInitialised) 
        /// <summary>
        /// Application start-up code will be executed once here
        /// </summary>
        private void Application_Start()
            _isInitialised = true;
            // add code

ASP.NET, JQuery, Colorbox, Postback Problem

As Colorbox appends inline divs to the body tag, this is outside the form.


Change this: $('body').prepend($overlay,  $cbox.append($wrap, $loadingBay))

To this: $('form').prepend($overlay, $cbox.append($wrap, $loadingBay))

or search in the minified file for “body”, and replace it with “form”.

I also recommend prepending the project name to the min file and putting a comment the top stating it’s been customised.

Friday, 12 March 2010

Umbraco, XSLT :: Reading RSS Feeds, Aggregating and Sorting

Here's a quick summary of how to read multiple RSS feeds, merge them, sort them and then output the first 30 items.  You can easily combine and concatenate nodes from external sources into an xsl:variable with xsl:copy-of and GetXmlDocumentByUrl.


  1. Set up a doc type named 'RssFeed' with a property called 'url' (textstring)
  2. Create RSS Feed nodes in the Content section with your chosen feed urls
  3. Create an XSLT macro with the code that follows.


Just put this into an <xsl:template> and it will output the first 30 items.

<!-- Find all RSS Feed nodes, create new XML tree with all rss nodes merged into the 'container' node -->
<xsl:variable name="rssFeeds">
    <xsl:for-each select="$currentPage/ancestor-or-self::root//node [@nodeTypeAlias='Feed Item']">
      <xsl:variable name="url" select="string(data[@alias='url'])" />
      <!-- Is the url populated? -->
      <xsl:if test="string-length($url) &gt; 0">
        <!-- Import the feed-->
        <xsl:copy-of select="umbraco.library:GetXmlDocumentByUrl( $url )"/>
<!-- Iterate through the container doc -->
<xsl:for-each select="msxsl:node-set($rssFeeds)/container/rss/channel/item">
  <!-- Sort the items -->
  <xsl:sort select="pubDate" order="descending"/>
  <!-- Only output the first 30 items -->
  <xsl:if test="position() &lt;= 30">
        <xsl:attribute name="href">
          <xsl:value-of select="link/text()"/>
        <xsl:value-of select="title/text()"/>
      <xsl:value-of select="description/text()" />

Wednesday, 17 February 2010

Javascript in data binding syntax

onclick='<%# string.Format("return OpenWindow1(\"Edit/Supplier.aspx\", \"{0}\",\"WindowName\");", Eval("id")) %>'