Tuesday 30 December 2014

"Clone in Desktop" doesn't launch GitHub for Windows

"Clone in Desktop" wasn't launching GitHub for Windows.
Fortunately Joe Freeman solved it.

You either
a. Log in to GitHub in the Web Browser before clicking the "Clone in Desktop" link
b. Drag the URL of the repository to GitHub for Windows

Sunday 28 December 2014

Galaxy Tab S doesn't connect to ADB (Android Device Bridge)

After receiving a new Galaxy Tab S, I noticed it would not connect to Eclipse or ADB for debugging.

(I had enabled Developer options by clicking on Settings > General > About Device > Android Version 7 times).

The solution is that you have to download the USB driver from Samsung's site. This then enables the following drivers:

Tuesday 23 December 2014

Sitecore 6.6, Web API 1.2 and the message "An attempted to execute remote call was declided, because current mode is 'off'"

We are running Sitecore with MVC and installed the Web API 1.2.

When accessing the URL

from within Chrome and Postman it was running an error page.
After some extensive reading, experimenting, writing a custom pipeline processor and using Reflector, I finally solved it.

Firstly I turned on logging to ALL in App_Config\Sitecore.log4net.config.


This showed the following error message in the event log:

"An attempted to execute remote call was declided, because current mode is 'off'"

er... this should mean "declined", but never mind. Carrying on:

Reflector indicated that the CheckMode processor found the itemwebapi.mode setting was turned to "Off".

But hold on, my settings were on:

<site name="website">
        <patch:attribute name="itemwebapi.mode">StandardSecurity</patch:attribute>
        <patch:attribute name="itemwebapi.access">ReadOnly</patch:attribute>
        <patch:attribute name="itemwebapi.allowanonymousaccess">true</patch:attribute>

So then I wrote a processor to fit within the pipeline to evaluate the problem.
The following class was written and added to a class library:

using System;
using System.Diagnostics;
using Sitecore.Diagnostics;
using Sitecore.Pipelines.HttpRequest;

namespace TestPipeline
    public class TestProcessor : HttpRequestProcessor
        public override void Process(HttpRequestArgs args)
            var context = args.Context.Items["Sitecore.ItemWebApi.Context"];
            Console.WriteLine("Hello World");

the class library requires references to Sitecore.Kernel and System.Web.

Using reflector, it can be seen that the Web API settings are loaded in SetRuntimeSettings, which runs after SiteResolver:

<processor type="Sitecore.ItemWebApi.Pipelines.HttpRequest.SetRuntimeSettings, Sitecore.ItemWebApi" patch:after="processor[@type='Sitecore.Pipelines.HttpRequest.SiteResolver, Sitecore.Kernel']" />

Therefore the pipeline was inserted after SiteResolver:

<processor type="Sitecore.Pipelines.HttpRequest.SiteResolver, Sitecore.Kernel" />
<processor type="TestPipeline.TestProcessor, TestPipeline" />
<processor type="Sitecore.Pipelines.HttpRequest.UserResolver, Sitecore.Kernel" />

A debugger was then attached to the wp3 process and a breakpoint put within the processor.
Looking at args.Context.Items["Sitecore.ItemWebApi.Context"].Settings.Mode it was indeed turned to off and not StandardSecurity.

It was then determined that in the Web API config the site had the default sitename:

<site name="website">

whereas in Include\Sitecore.SiteDefinition.config the sitename was patched to something else:

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
      <site br="" name="checkout" patch:instead="site[@name='website']">

Removing Include\Sitecore.SiteDefinition.config fixed the problem.
To keep the file, the following attributes were added:

Solved: The WebAPI config was assuming the default site name "website" whereas this had been configured to something else.

Friday 28 November 2014

Firebug remembers old / deleted breakpoints

  • In Firefox, go to URL about:support
  • Check the Profile Directory
  • Open containing folder
  • Go into folder firebug
  • Delete breakpoints.json

  • Tuesday 25 November 2014

    MSMQ code sends message, doesn't error, but doesn't show


    For queue's that you have created as transanctional, you must use the version of Send() that includes the MessageQueueTransactionType parameter. The biggest frustration with this is that it doesn't throw any exceptions or errors as you have seen, but the message just doesn't ever show up.
    So, in your code, change:
    helpRequestQueue.Send(theMessage, MessageQueueTransactionType.Single); 

    Tuesday 4 November 2014

    FXCop and built-in rules: CA1723 and "Use preferred terms" for Canceling

    FXCop has some built-in rules for complaining about a UK spelling of "Canceled", e.g. "Cancelled".

    If you override the section

    <Term PreferredAlternate="Cancelled">canceled</Term>

    it doesn't work and it still complains about the word "Cancelled".

    However if you set it to

    <Term PreferredAlternate="Andy">canceled</Term>

    it then raises CA1723 and suggest you change it to "Andy".
    If you remove the line completely it still complains about the word "Cancelled" and suggests "Canceled".

    So the behavior is relying upon a default rule and error cannot be configured out using the PreferredAlternate section of the CustomDictionary; it looks like it can only changed to an alternative spelling.

    However there is a way! Looking at the FX Cop IL, it can be seen that if you set the US spelling as an unrecognized term


    then it overrides the built-in rule and the error disappears!

    Saturday 25 October 2014

    Command to help remove a printer driver

    printui /s /t2

    Running Theme Park on Windows 8 and Windows 10

    My copy of Theme Park World wouldn't work on Windows 8: it loaded and then displayed the error message "tp.icd has stopped working".

    Thanks to articles here and the great work and hours spent by Adam Hearn I got it working again.

    To ensure they are kept for prosperity I repeat the instructions here, but all credit is due to the authors above.

    Installing Theme Park World on Windows 8

    (Installing Sim Theme Park on Windows 8)

    (1) Installation
    (2) Patching
    (3) No-cd TP.exe(4) Microsoft SafeDisc Patch
    (5) Compatibility Mode(6) Mouse Pointer Issue


    (1) Installation

    Theme Park World should install without any issues on a modern PC. Simply insert the CD / mount the ISO and follow the on-screen prompts. If the CD / mounted ISO does not auto-run, explore the contents of the CD in Windows Explorer and run the “Autorun.exe” file. You should then see a menu allowing you to install the game.

    (2) Patching (to version 2.0)

    Before playing Theme Park World on a modern PC, you must install the version 2.0 patch. You can download the patch here. Simply run the patch once it has downloaded and the game will start.

    (3) No-Cd TP.exe

    In the event you have installed Theme Park World from a .iso file, you will need to switch the TP.exe executable file (located in your TPW folder) with a version that allows the game to be run sans disc (search on Google for Theme Park World Nocd Patch). Note that the original TP.exe file is approximately 260KB whereas the No-Cd version is approximately 3647KB.

    (4) Microsoft SafeDisc Patch

    Download and install this file: http://www.adamhearn.co.uk/games/themeparkworld/files/updatesecdrv.exe

    (4a) Install Fonts (may be optional)
    Run the Fix Fonts installer.
    (5) Compatibility Mode
    Right click on TP.EXE, select properties and then the 'Compatibility' tab. In the compatibility mode section, tick the checkbox (Run this program in compatibility mode for:) and select 'Windows 7'.

    (6) Mouse Pointer Issue

    If you have followed the instructions above at this point you should be able to launch into Theme Park World / Sim Theme Park. Unfortunately, due to an issue with 32bit colour (color) the mouse pointer in the game will not be visible. This is just a minor glitch and easily resolvable so with a little patience you'll be playing TPW in under 5 minutes :)

    So, first step is to navigate to the TPW / Sim Theme Park folder on your pc - once there locate the Data folder and you will see a list of files. We are interested in just 3 of these, namely:


    What you need to do is open every one of them using Notepad (double click on the icon and select to open using notepad), then set "GraphicalOptions.TEXTURE32" and "GraphicalOptions.RENDER32" to 1 (in place of the 0 that had been listed previously).

    Take care to save .sam file as a .sam file (windows may attempt to convert it to a .sam.txt file). For example if you want to save the low.sam file, just do a normal save and type the file name as "low.sam". 
    [In the event that while trying to save the .sam file you receive an error message, this is as a result of Windows' user privilege settings - What you will have to do is save the .sam files elsewhere, say the desktop for example, and then copy and paste them into the folder with the original .sam files. NB - Make sure to click yes if Windows requests your administrator access to move the files] 

    [In the event it the .sam files get saved as .txt files... you will need to open up an explorer page (e.g. double click on 'My Computer', click 'View' in the top left hand menu, click options in the drop down ribbon menu which appears just below and then 'Change folder and search options'. You will now see a folder options popup box and here there are 3 headings - General / View / Search. Click on View. Navigate to 'Hide extensions for known file types' and unclick it. Next click apply. Now go back you your .sam.txt file and rename it to just .sam]
    (7) Processor Affinity
    For added security, once the game is running, go to Task Manager, select tp.exe in the Details tab and click "Set Affinity". Only check a single CPU (e.g. CPU 0) and this will ensure the game will run with one CPU only (the game may not be expecting the modern day multi-core processors).
    (8) Set the Preferred Resolution
    1) Exit the game if you haven’t done so already.
    2) Browse to the games installation folder using Windows Explorer. By default this is C:\Program Files\Bullfrog\Theme Park World on 32 bit systems and C:\Program Files (x86)\Bullfrog\Theme Park World on 64 bit systems.
    3) Find a file called _Resolution.sam and rename it to Resolution.sam (remove the underscore character at the start of the file name).
    4) Click on the Resolution.sam file and choose to open it in Notepad. Inside this file you will see a note explaining how to activate extra resolutions. Amazingly for such an old game, Theme Park World actually supported high definition screen resolutions. However, the monitors at the time were not widescreen, so you probably want to avoid modes like 1600×1200 or 2048×1536.
    5) To change to one of the extra resolutions, locate the line beginning “Res.RESOLUTION” at the very bottom of the file, then simply change the number on this line according to the instructions in the text file. For instance, to use 1280×1024 screen mode (works best on a 1080p monitor) use “Res.RESOLUTION 5″. Don’t forget to save your changes when you are done.
    6) If you did everything correctly, next time you start the game it should start in your chosen screen resolution.

    Sunday 19 October 2014

    Rooting a phone does not invalidate a warranty

    From http://matija.suklje.name/rooting-and-flashing-your-device-does-not-void-the-warranty-in-eu

    This is a joint blog post written together with Carlo Piana with the goal to disband some popular FUD that you lose your warranty if you flash or root your device.
    Does rooting your device (e.g. an Android phone) and replacing its operating system with something else void your statutory warranty, if you are a consumer?

    In short:

    Just the fact that you modified or changed the software of your device, is not a sufficient reason to void your statutory warranty. As long as you have bought the device as a consumer in the European Union.

    A bit longer:

    Directive 1999/44/CE dictates 1 that any object meeting certain criteria (incl. telephones, computers, routers etc.) that is sold to a consumer 2 inside the European Union, has to carry a warranty from the seller that the device will meet the quality that you would expect for such a device for a period of 2 years.
    A telephone is an example of such a device and is an object that comprises many parts, from the case to the screen to the radio, to a mini-computer, to the battery, to the software that runs it. If any of these parts 3 stop working in those 2 years, the seller has to fix or replace them. What is more these repairs should not cost the consumer a single cent – the seller has to cover the expenses (Directive 1999/44/CE, §3). If the seller has any expenses for returning it to the manufacturer, this is not your problem as a consumer.
    If your device becomes defective in the first 6 months, it is presumed that the defect was there all along, so you should not need to prove anything.
    If your device becomes defective after the first 6 months, but before 2 years run out, you are still covered. The difference is only that if the defect arises now, the seller can claim that the defect was caused by some action that was triggered by non-normal use of the device. 4 But in order to avoid needing to repair or replace your device, the seller has to prove that your action caused 5 the defect. It is generally recognised by courts that unless there is a sign of abuse of the device, the defect is there because the device was faulty from the beginning. That is just common sense, after all.
    So, we finally come to the question of rooting, flashing and changing the software. Unless the seller can prove that modifying the software, rooting your device or flashing it with some other OS or firmware was the cause for the defect, you are still covered for defects during those 2 years. A good test to see if it is the software’s fault is to flash it back with stock firmware/OS and see if the problem persists. If it does, it is not a software-caused problem. If it is not possible to revert it stock software any more, it is also not a software-caused defect. There are very few hardware defects that are caused by software – e.g. overriding the speaker volume above the safe level could blow the speaker.
    Many manufacturers of consumer devices write into their warranties a paragraph that by changing the software or “rooting” your device, you void the warranty. You have to understand that in EU we have a “statutory warranty”, which is compulsory that the seller must offer by law (Directive 1999/44/CE, §7.1) and a “voluntary warranty” which the seller or manufacturer can, but does not need to, offer as an additional service to the consumer. Usually the “voluntary warranty” covers a longer period of time or additional accidents not covered by law 6. If though the seller, the manufacturer or anyone else offers a “voluntary warranty”, he is bound to it as well!
    So, even if, by any chance your “voluntary warranty” got voided, by European law, you should still have the 2 year “compulsory warranty” as it is described in the Directive and which is the topic of this article.
    In case the seller refuses your right to repair or replace the device, you can sue him in a civil litigation and can report the incident to the national authority. In many European countries such action does not even require hiring a lawyer and is most of the time ensured by consumers associations.
    The warranty under this Directive is only applicable inside the European Union and only if you bought the device as a consumer.
    hook out → I hope this encourages many of you to go and flash your devices with something Free! ☺

    1. EU member states must have by now imported the Directive 1999/44/CE into their national laws. So you should quote also your local law on that topic. 
    2. A consumer is a natural person who acts for their own private purposes and not as a professional. 
    3. Batteries can be exempt of this and usually hold only 6 months warranty. 
    4. E.g. a defect power button could be caused by spreading marmalade in it or hooking it onto a robot that would continuously press the button every second 24/7 – of course that is not normal or intended use. 
    5. Note that correlation is not causation – the defect has to be proven to be caused by your action, not just correlate with it. 
    6. E.g. if a device manufacturer guarantees the phone is water- and shock-proof or a car manufacturer offers 7 years of warranty against rust. 

    Related Posts

    Monday 13 October 2014

    Can't install Project 2013 - Group Policy software restrictions

    Local software restrictions were preventing me from installing Project 2013.

    Errors were logged in %AppData%\Local\Temp.

    "Error checking already running ose version. Error code 0x00000000"
    "Unable to select Source Engine process to start"

    Firstly System Restore was disabled by policy:
    HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows NT\SystemRestore

    Then the Office 64 Source Engine was not started and local attempts to start it (OSE.EXE failed).

    Access to C:\Users\ANDREW~1\AppData\Local\Temp\ose00004.exe has been restricted by your Administrator by location with policy rule {34ae1087-c2cc-409f-a442-e48e70e62efb} placed on path C:\Users\AndrewPotts\AppData\Local\*\*.exe.

    Saturday 27 September 2014

    HMRC RTI database - deleting an unwanted submission

    If like me you have got an outstanding submission in the HMRC Basic PAYE tools and it shouldn't be there and there is no way to delete it; then you may have to edit the SQLLite database that it uses. Here are the steps I undertook:

    1. Backup the data from within the Basic PAYE tools application.

    2. Download the SQLLite tool from here: http://sqlitebrowser.org (the source code can be downloaded here). This will allow you to view and edit the underlying database.

    3. Open the sqllite.db in %appdata%\Roaming\HMRC\payetools-rti

    4. Look in the bptrti_submissiondirtydata table. You'll see one row that looks like the outstanding submission. Find the "id" column and note down the number for the row.

    5. Execute
    delete from bptrti_submissiondirtydata where id = <id>
    and substitute <id> with the appropriate ID that you took note of in step 4.

    Tuesday 16 September 2014

    Code Analysis not working properly through MSBuild

    One project would not build locally on my machine through an MSBuild script, despite it working in Visual Studio.

    The error was various permutations of the FxCop error:

    InfoMessageExtensions.cs(19): error : CA1006 :
    Consider a design where 'InfoMessageExtensions.InfoMessageFor<TModel, TProperty>(this HtmlHelper<TMo
    n<Func<TModel, TProperty>>, object)' doesn't nest generic type 'Expression<Func<TModel, TProperty>>'.

    An inspection of what was going on was that:
    1.      MSBuild (v4) was picking up old versions of FxCop
    2.      The Code Analysis suppression was not being taken into account

    Issue 1 was fixed by installing VS2012. There are better ways to sort this by defining the Microsoft.CodeAnalysis.Targets in the project or as command-line parameters to MSBuild.

    Issue 2 was the killer. This is a BUG in Visual Studio. For the code analysis and suppressions to work with MSBuild, the Conditional Compilation symbol CODE_ANALYSIS must be added to the project file (VS.NET doesn’t need it but MSBUILD does).

    However the bug is this: If ONE symbol is present, the symbol is not written to the Csproj. After adding a dummy symbol it then appeared. See below for the before and after.

    Then MSBuild works.

    Monday 15 September 2014

    MSMQ explorer

    MSMQ QExplorer is a good tool for viewing MSQM messages.


    Changing the OneNote screen clipping / capture shortcut

    For OneNote 2007, see Changing the OneNote Screen Clipping and New Side Note keyboard shortcuts. I believe this article will answer your question.
    In short, look at this registry key:
    There are two DWORD values ScreenClippingShortcutKey & NewNoteShortcutKey. The default values are:
    • ScreenClippingShortcutKey: 0x53
    • NewNoteShortcutKey: 0x4e
    If we look in this ASCII table:
    In row 5, column 3 (0x53), we see the S. So, this is where the S of the hotkey is set.
    Change it to another value according to the ASCII table to adjust the hotkey.

    Wednesday 10 September 2014

    ZoomIt - Error launching 64-bit version: This program is blocked by your group policy.

    Zoomit doesn't work on a 64-bit machine with certain group policy settings.
    In my situation, when you run the downloaded zoomit.exe, it tries to create a 64-bit version in the folder specified by the TEMP variable. Writing to the specific temp folder is blocked by group policy.

    So the solution was to create a new folder C:\Temp1 and change the TEMP variable to C:\Temp1  - this fixed the problem.

    Tuesday 5 August 2014

    Changing a forgotten SA password using the command line

    If you forget the sa password many articles give you advice of how to login to Management Studio and change the sa password. But what if you've inherited someone else's developer PC and you don't have access to Management Studio using your Windows credentials?

    There is a way to do it using the command line.

    Stop the SQL Server instance
    net stop MSSQLSERVER

    Start the instance
    net start MSSQLSERVER /mSQLCMD

    Go in single user mode
    sqlcmd -S. -E

    1> sp_password @new='<pwd>', @loginame='sa'
    2> go

    You can also add the user
    sp_addsrvrolemember '<domain>\<user>', 'sysadmin'

    Wednesday 30 July 2014

    Device Unauthorized when debugging android on a new PC

    When you connect a new PC to a device for debugging android apps, it doesn't initially work.

    In Android Device Chooser, the window displays the device serial number and Target shows 'unknown'.

    This is because the PC needs to be registered with the device. Disconnect the USB cable and reconnect it. On the device the window should appear.

    Click OK to register and authorize the PC.

    Wednesday 23 July 2014

    Deploying to Production IIS 8 on Windows 2012

    I had problems deploying a new Web application to IIS 8 on Windows 2012.

    Firstly the Web site just returned a 404 error. So to increase the verbosity (by following this post) the Web application was reconfigured through web.config:

            <httperrors errormode="Detailed">
            <customerrors mode="Off">
            <compilation debug="true">
    Then an error showed itself:

    Detailed Error Information:
    Module   IIS Web Core
    Notification   BeginRequest
    Handler   Not yet determined
    Error Code   0x80070021
    Config Error   This configuration section cannot be used at this path. This happens when the section is locked at a parent level. Locking is either by default (overrideModeDefault="Deny"), or set explicitly by a location tag with overrideMode="Deny" or the legacy allowOverride="false".
    Config File   \\?\C:\inetpub\wwwroot\Monitor Web Site\web.config

    This was fixed by running:

    %windir%\system32\inetsrv\appcmd.exe unlock config -section:system.webServer/handlers

    Then another error showed itself:
    HTTP Error 500.21 - Internal Server Error
    Handler "ExtensionlessUrlHandler-Integrated-4.0" has a bad module "ManagedPipelineHandler" in its module list

    Most likely causes:
    Managed handler is used; however, ASP.NET is not installed or is not installed completely.
    There is a typographical error in the configuration for the handler module list.
    During application initialization, either the application initialization feature has set skipManagedModules to true, or a rewrite rule is setting a URL that maps to a managed handler and is also setting SKIP_MANAGED_MODULES=1.

    This was fixed with this post:
    The Web Server (IIS) and Application Server should be installed, and you should also have the optional Web Server (IIS) Support under Application Server.

    Solution: I had to install "application server" to server roles and add the Web Server IIS support subsection.

    Thursday 17 July 2014

    Code for calculating pension projections

    void Main()
     // This projection works for personal pensions
     // var performance = 1.0489m;
     var performance = 1.05m;
     // performance = 1.0196m;
     // performance = 1.0782m;
     var inflation = 1.025m;
     var initialFund = 35370;
     var fund = initialFund;
     // See the Fisher equation
     var nominalRate = performance / inflation;
     var nominalDisplayRate = ((nominalRate) - 1) * 100;
     string.Format("Projection: {0:0.##}%", nominalDisplayRate).Dump();
     var year1 = (nominalRate * initialFund);
     year1 = (int)(year1/100) * 100;
     string.Format("Year 1: {0:0.##}", year1).Dump();
     var year3 = (nominalRate * nominalRate * nominalRate * initialFund);
     year3 = (int)(year3/100) * 100;
     string.Format("Year 3: {0:0.##}", year3).Dump();
     var year5 = (nominalRate * nominalRate * nominalRate * nominalRate * nominalRate * initialFund);
     year5 = (int)(year5/100) * 100;
     string.Format("Year 5: {0:0.##}", year5).Dump();
     var yearX = Math.Pow((double)nominalRate, 10) * initialFund;
     yearX = (int)(yearX/100) * 100;
     string.Format("Year 10: {0:0.##}", yearX).Dump();
    // for (var i = 1; i<=365; i++)
    // {
    //  49500m
    // }

    Wednesday 11 June 2014

    Multiple requests in the browser and VS.NET's browser link

    I was debugging an Web Application, looking at the client port:

    model.Port = Request.ServerVariables["REMOTE_PORT"];

    and on the browser I could see that this was changing everytime the page was loaded. This is a soft reload (F5), not a hard refresh (CTRL + F5). This obviously has a penalty cost, and is not in keeping with the concept of server keep alives.

    So why was the port changing all the time? Firefox gives a clue:

    For every page, a load of subsequent requests are being made which are incrementing the client port.
    Why is this?

    It's Visual Studio's browser link. It allows a communication between VS.NET and the browser and one use allows you to refresh all of the connected browsers from VS.NET with one button click. For example, you may have a tablet and a desktop connected, you make a change to the content and want to see the browsers update immediately with one click, rather than going round all the browsers individually.

    It can be turned off by selecting the icon below.

    Friday 30 May 2014

    Debugging an EXE in Visual Studio

    Select File > Open > Project / Solution and select the EXE.
    This will create a blank solution with the EXE in it.
    Then Start Debugging to run the EXE.
    Create a breakpoint and inspect the stack as normal. Note that the addresses shown will be the memory addresses, not the file addresses.

    Playing Star Wars - Battlefront without the CD

    To play Star Wars Battlefront without having to keep the CD in the drive all the time.

    1. Hex Edit (using something like HxD) the file at C:\Program Files (x86)\LucasArts\Star Wars Battlefront\GameData\battlefront.exe

    2. Search for the hex data E8 79 FE FF FF - you should find it at address 001ECED2 or similar.

    3. Edit the preceding two bytes from Jump If Not Equal (JNE) - to Jump.
    In other words: change the two bytes at address 001ECED2 from 75 0F to EB 0F.

    4. Save the modified file.

    5. Change the shortcut to C:\Program Files (x86)\LucasArts\Star Wars Battlefront\GameData\battlefront.exe.

    Monday 26 May 2014

    OpenBVE - An attempt was made to load a program with an incorrect format, SDL failed to create window

    If you get the error message

    "An attempt was made to load a program with an incorrect format" when starting OpenBVE, make sure you have installed OpenAL via the installer.

    "SDL failed to create window" - this can be because you've copied the installation from one machine to another and the resolution is set wrong. Go into the options and set the correct resolution.

    Wednesday 14 May 2014

    Rooting a Samsung Galaxy Tab 3 10.1 - What they don't tell you

    I've spent a few hours trying to root a Samsung Galaxy Tab 3.0 10.1 following instructions on the Internet. There are a few little gotchas that aren't made clear.

    - You only get one chance to boot to the CWM recovery after you've flashed the device
    - You don't need to press the HOME button when starting the boot

    So, here is my version of the instructions:


    1. Turn on Developer Mode.
    If not done already, click on Settings->About Device->Build number->Build number->Build number 
    and press Build number" seven times. 
    2. Turn on USB debugging.

    3. Download Odin (3.07 or higher) and save it to your desktop. 
    4. Download CWM Recovery and save it to your Desktop.
    5. Download Root ZIP and save it to your Desktop.


    1. Extract files from Odin and CWM Recovery archives by right-clicking on each of them and selecting Extract here.
    2. Open Odin ensuring you "Run as administrator".
    3. Click on PDA and choose the CWM Recovery file you just extracted from the archive.
    4. Make sure only the F. Reset Time boxes are checked in the Odin. De-select Auto-Reboot - otherwise you will have to be quick at engaging recovery mode. If you aren't you will end up in Android recovery, not CWM.
    5. Turn OFF your device.
    6. Turn it back on by holding down Volume DOWN+Power buttons together.
    7. Your device should reboot into Download mode.
    8. Plug in your device to your PC via USB cable.
    9. Hit Start in the Odin and it’ll start flashing the recovery on your device.
    10. Connect your device to your PC using the USB cable.
    11. Copy the Root ZIP file from your Desktop over to the root of your SD card. Note: the SD card. Not internal memory. You will need an SD card.
    12. Open a command prompt in administrator mode. Go to the android platform-tools folder and type adb reboot recovery. Alternatively turn OFF the device and turn it back on by holding down Volume UP + Power buttons together.
    13. Your device should reboot into recovery mode.
    14. Select install zip from sdcard followed by choose zip from sdcard.
    15. Choose Root ZIP to be flashed on your device.
    16. It should start flashing the file on your device.
    17. Once the flashing’s done, reboot your device.
    18. Go back to the menu and select reboot. If it asks you "ROM may flash stock recovery on boot. Fix?" then it will be asking you whether to reapply the stock recovery. Select Yes to keep CWM or No to return to android recovery.


    Odin stuck at initializing connection? - You didn't boot the device into download mode (POWER + VOL DOWN).
    You keep booting to android recovery rather than cwm recovery? - When you've flashed using Odin it starts to automatically reboot by default. You only have the one chance to press POWER + VOL UP to enter recovery mode. If you don't do it and it goes to the normal power up sequence then install-recovery.sh will replace cwm with the stock recovery. Turn off the Auto-Reboot option in Odin and perform the reboot yourself.

    Stock firmware
    Stock firmware is available from the this site.

    Monday 5 May 2014

    Minecraft and Multiple versions of Forge and mods

    Minecraft enables you to play multiple versions of the program and multiple versions of mods.

    Installing Forge

    Forge is a useful utility which enables the easy addition of mods. You no longer need to copy Java class files into the .minecraft folder and delete the META-INF folder. Instead you install Forge and then copy files to a mods folder.

    You can download Forge from here.

    The following instructions are courtesy of mod-buildcraft.com:

    Go to http://files.minecraftforge.net/ and download the installer recommended for Minecraft 1.6.4. The download link is going to bring you to an adfly link that might look weird at first. This is a sponsored link used to remunerate the developers of the Forge for the work they're doing. You should see a page like this (probably with a different advertisement in the body):
    Note that on the top right corner, the count-down for the download. Just wait the 5 seconds, until the top looks like:
    Then click on the “Skip Ad” link. This should download a file with the .jar extension. Click on it. You should get the following installer:
    Click on OK on the bottom left corner, up until the success message. Then open the Minecraft lobby again, and switch profile to the Forge profile:
    Hit play. The Minecraft lobby will then offer to log on the Forge profile with the same user as the one currently registered. Hit Play again to validate it:
    And then back to the lobby, hit Play one last time. You should now see a Minecraft menu with Forge details displayed:
    That's it! You successfully installed Minecraft Forge. Close Minecraft for now.

    Multiple verions of Forge and Mods

    When using Forge and the Minecraft launcher, by default all mods are stored in


    This is the global mod folder. However it will cause problems if you put a 1.6.4 and a 1.7.2 mod in here.
    To get around this, use the GameDir setting in Minecraft.

    Create a folder, such as %appdata%\.minecraft\mods\GameDir\Forge 1.6.4. Set the folder to this.
    Run Minecraft again and it will create a set of subfolders within this, including the mods folder.
    Put your version-specific mods in here.

    Monday 28 April 2014

    Group Policy prevents Chrome Sync of bookmarks

    My Chrome browser was disabled from Syncing bookmarks. It transpires Group Policy was preventing it.


    Some of the appropriate keys are here:


    Tuesday 22 April 2014

    JSONP and CORS

    JSONP allows GET verbs to be passed across domains. But it is restricted only to GET verbs. Custom or standard headers cannot be added, so you cannot include ETag when calling a REST service to use the cache where possible.

    The more modern technique is to use CORS. This works for more modern browsers.

    To get CORS to work with AngularJS, first add the code:

    var dashboard = angular.module('dashboardApp', []);
    dashboard.config(['$httpProvider', function ($httpProvider) {
        $httpProvider.defaults.useXDomain = true;

    The useXDomain means the browser will send the Origin: http://serverhost header in the request.
    The request can now be changed from

                'method': 'JSONP',
                'url': endurTradeServiceUrl + '?callback=JSON_CALLBACK',


                'method': 'GET',
                'url': endurTradeServiceUrl,

    However if you look in Firebug, the server still shows no response:

    Note that the Content-Length is 715 bytes but firebug shows no data:

    This is because the browser's Same Origin policy is working. Now we need to go server-side and add the following header to the response:

    public HttpResponseMessage Get()
                var cache = ObjectFactory.GetInstance();
                var response = Request.CreateResponse(HttpStatusCode.OK, cache.Strategies);
                response.Headers.Add("Access-Control-Allow-Origin", "*");
                return response;

    And now it will work. Note that the wildcard for the response header is not best practice.

    Now for the headers. If we have the code to add custom headers:

                'method': 'GET',
                'url': endurTradeServiceUrl,
                headers: {
                    'if-none-match' : 'Today',
                    'mycustom' : 'Bob'

    Then go back to Firefox we can see that the client is now calling the OPTIONS method and requesting permission to use the headers with the Access-Control-Request-Headers header. This is the CORS "preflight" request:


    The browser can skip the preflight request if the following conditions are true:
    The request method is GET, HEAD, or POST, **and**
    The application does not set any request headers other than Accept, Accept-Language, Content-Language, Content-Type, or Last-Event-ID, **and**
    The Content-Type header (if set) is one of the following:
     - application/x-www-form-urlencoded
     - multipart/form-data
     - text/plain

    As we are sending JSON and custom headers, these conditions are not met and so the preflight request is raised.

    Now to handle the preflight:
    Install the NuGet Package Microsoft.AspNet.WebApi.Cors.

    Add the following code to WebApiConfig.cs

    public static void Register(HttpConfiguration config)
                var enableCorsAttribute = new EnableCorsAttribute("*", "*", "GET, PUT, POST, DELETE, OPTIONS"); 
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }

    and you can then remove the lines
    response.Headers.Add("Access-Control-Allow-Origin", "*");

    from the controller actions.
    The server
    is now handling the Options message:

    You may wish to read a header from the server. This may be useful for example if you want to store the ETag and reuse it for subsequent requests, thus using the full caching capability. If you want to be able to read a header from the server, the server needs to add the line

    response.Headers.Add("Access-Control-Expose-Headers", "ETag");

    NOTE: You CANNOT use the wildcard ("*") for Access-Control-Expose-Headers - it is rejected by Firefox and Chrome. It has to be a comma-separated list of headers.

    MSDN Blogs
    CORS support in ASP.NET