Friday, 27 December 2013

How to solve the Rubik's cube

My kids got rubik's cubes for christmas this year, and the first thing I wanted to do was solve it for myself. I remember when I was a child, only being able to solve one face of the cube, and in the age of youtube I thought there may be a training video out there to show my how to solve all three levels of the cube. Sure enough a quick type into youtube search engine for Rubik's cube brought up these two great training videos.

Full solution

3rd level codes

For my reference I wrote down the codes for the 3rd level as follows


Wednesday, 18 December 2013

SQL Server Report Server Investigations

The following SQL will let you find the worst performing reports, and also the ones that error on your reporting services database instance.


          , E.Requesttype
           --WHEN 1 THEN 'Subscription'
           --WHEN 0 THEN 'Report Launch'
           --ELSE ''
          ,[TimeTotal (ms)] = DATEDIFF ( millisecond , E.TimeStart , E.TimeEnd )
     FROM Reportserver.dbo.ExecutionLog E (NOLOCK)
     INNER JOIN Reportserver.dbo.Catalog C (NOLOCK)
       ON E.ReportID = C.ItemID
--    WHERE C.Name = 'Project Full Control Comments'
and E.Requesttype = 0
and E.Status <> 'rsSuccess'

ORDER BY [TimeTotal (ms)] DESC

Wednesday, 11 December 2013

Altering the HTTP response using Fiddler

Should you ever have the need to change the http response to a web server, then please note in the latest version of Fiddler it's actually possible to do this without having to hack the CustomRules.js file that the Fiddler training videos and documentation tell you about.

You can simply set up an AutoResponder tab rule as follows

1. Stick a file in %userprofile%\Documents\Fiddler2\Captures\Responses folder

2. Highlight the request you want to set up a rule for

3. Got to the AutoResponder tab and check Enable automatic responses and unmagtched requests passthrough

4. Click Add rule

5. In the dropdown list control at the bottom, select the file that you dropped in the folder in step 1 above.

6. Hit the save button

7. Clear the Cache


Now next time you request that resource, the version you have saved on disk will be downloaded instead. You can check this by looking in the IE cache folder %userprofile

%userprofile%\AppData\Local\Microsoft\Windows\Temporary Internet Files

More detail about request and response breakpoints in fiddler here… (this is very useful should you wish to change the request going to the server in the first place as well)…

P.S. For more powerful / permanent debugging solution you can just alter the fiddler customrules.js as follows

static function OnBeforeResponse(oSession: Session) {

        if (m_Hide304s && oSession.responseCode == 304) {

            oSession["ui-hide"] = "true";


if (oSession.uriContains("Name=ViewerScript")) {




Monday, 9 December 2013

Using the DataContractSerializer to serialize and deserialize


To serialize a Business object marked with [DataContract] and properties marked with [DataMember] attributes…

public static string DataContractSerializeObject<T>(T objectToSerialize)


using (var output = new StringWriter())


using (var writer = new XmlTextWriter(output) { Formatting = Formatting.Indented })


var dataContractSerializer = new DataContractSerializer(typeof(T), EntityUtilities.GetAllKnownTypes(), int.MaxValue, true, true, null);

                    dataContractSerializer.WriteObject(writer, objectToSerialize);

return output.GetStringBuilder().ToString();




Then to deserialize back to your DataContract type, use this logic…

public static T Deserialize<T>(string xml)


using (Stream stream = new MemoryStream())


byte[] data = System.Text.Encoding.UTF8.GetBytes(xml);

                stream.Write(data, 0, data.Length);

                stream.Position = 0;

var dataContractSerializer = new DataContractSerializer(typeof(T), EntityUtilities.GetAllKnownTypes(), int.MaxValue, true, true, null);

return (T)dataContractSerializer.ReadObject(stream);



Thursday, 5 December 2013

Cross platform mobile development in C#

Microsoft Virtual Academy - ASP.NET MVC

I’ve just got into the Microsoft Virtual Academy, and I have to say it has a wealth of up to date, excellent training videos.

Razor syntax escape characters…


Html anti forgery token..

ASP.NET MVC 4 Content Map

Script including - always use the longhand version for the <script></script> tag, otherwise your script file will not be downloading to the client browser - a fantastic javscript, jquery, html and css online playground like and The nice thing about this one though is that you can download the entire finished article file as a single html page.

What's coming in ASP.NET -

Signed nightly builds of vnext -

Getting started with web api -

Web API 2 (video) -

How to Fix a Humax HDR FOX T2 PVR that will not stay powered on

Issue When you attempt to power on your Humax the standby orange light goes blue for a moment, and then powers off automatically again. ...