Don’t like npm!!

Every time I have to use npm I find myself hating it.  I hate the general direction software development seems to be headed, with loads and loads of bloat.

An example of this taken to an extreme is the new Microsoft Cordova Multiplatform Template project.  When the project is created, before being built, it contains 10,000 files.  10,000!!!

Worse still, after building, that count goes up to 30,000 files!!!  I am sorry, but that is just ridiculous.  An empty built application template is 30,000 files and 167 MB in size.

Worse still, if you try and delete the project it fails, because windows explorer can’t handle the path length.  Sigh.

What is this shit?  It’s a joke is what it is.

Posted in Cordova, JavaScript, windows, Windows 10 | Leave a comment

Idea: Low Emission Zones & Engine Control Units

The idea is that a car’s ECU would know (triggered by GPS or NFC communication) when it is in a low emission zone and to automatically alter its driving parameters to reduce emissions while within the low emission zone.

Posted in Driving, Emissions, Uncategorized | Leave a comment

Find what is setting a global variable in javascript

Having identified an unknown global variable in your JavaScript application, how should you go about finding what is setting it?

Well one way is to watch for the variable being set as follows.  In this example, I look for something setting the ‘value’ global variable:

  var value;
  Object.defineProperty(window, 'value', {
    get: function(){ return value; },
    set: function(val) {
      value = val;
      debugger; // BOOM!

Just paste that into your debugger console, and run your code.  To find other global variables, just change ‘value’ to the name of the variable you are interested in.

Credit to :

Posted in Uncategorized | Leave a comment

iOS Safari correct viewport size

In our html5 application on iOS, in particular when running as a home screen icon, there was an annoying extra 20px of space at the bottom of the window that allowed the content to be scrolled up underneath the status bar. For a long time I could not figure out what was causing this and simply ignored it.

On re-visiting this issue today, I tracked it down the the viewport meta tag setting height = device-height. I tried removing this and letting it work it out for itself but that made matters worse (even more space).

In the end, I came up with the following code to specify a specific height based on the device height less 20 pixels for the status bar:

<meta id="viewport" name="viewport" content="width=device-width, height=device-height">
(function() {
    var iOS = !!navigator.platform.match(/(iPad|iPhone|iPod)/g);
    if (iOS) {
        var viewport = document.getElementById("viewport"),
            content = viewport.getAttribute("content").split(/[ ]*,[ ]*/);
        for (var i = 0; i < content.length; i++) {
            var nv = content[i].split(/[ ]*=[ ]*/);
            if (nv[0] === "height" && nv[1] === "device-height") {
                nv[1] = window.innerHeight - 20;
                content[i] = nv.join("=");
        viewport.setAttribute("content", content.join(","));
Posted in Uncategorized | Leave a comment

Game crash at startup? d3d9.dll faulting module? Windows 8.1 / KB3000850 installed?

Some games/applications of mine started crashing at startup at some point after a windows update (as I run these games/apps infrequently its had to tell which particular update caused the issue).

I first experienced this with a program called Sourcetree after an update to Sourcetree it stopped loading. I tracked this down to an exception being thrown by d3d9.dll. I tried re-installing direct-x but all I got was a message saying it is already installed.

I searched for d3d9.dll on my disk to check what versions there were, comparing checksums, and the faulting one, was exactly the same checksum as the same version found under WinSxS which suggested to me that it was not a corruption issue.

I happened to try (cant remember why -probably was thinking along the lines of a permission issue) copying d3d9.dll into the application folder and lo and behold, the application now launches.

Fast forward several months, GTAV comes to PC finally. Install it, the launcher crashes at startup – bugger. After checking around for similar issues and not finding any solutions, I decide to try the d3d9.dll fix (can’t remember if I had already spotted the faulting module error or not) and lo and behold, GTAV launcher no longer crashes.

After a long and unfruitful support ticket with Rockstar who offered no help other than reinstall, reinstall again, reinstall with administrator, turn off your virus scanner blah blah despite being give very specific details about the problem (don’t you just hate stock responses) I did some more searching for the d3d9.dll problem.

I came across a post that referenced this problem, and a November update (timing is about right) that caused it. KB3000850

The advice seems to be to uninstall this update, but I have also seen comments from people saying they can’t uninstall it, and not sure I want to risk uninstalling it so many months later.

So I am left with my workaround, it works and now I know about it, it is quick to fix. No doubt at some point down the line I will come across a situation where this doesn’t solve the problem, but I will cross that bridge when I get to it. I don’t fancy re-installing the O/S just yet (it takes many weeks, even months to get all the software I use back on and configured).

So if you are experiencing this issue and d3d9.dll is the faulting module, try my workaround. The workaround is completely safe, just copy d3d9.dll from c:\windows\system32 to the folder where program that is crashing is installed. You can easily remove it again (or rename it) if it doesn’t solve the problem or causes other issues.

For reference (and google search) here are the faulting module details from event viewer for GTAVLauncher.exe

Faulting application name: GTAVLauncher.exe, version: 1.0.323.1, time stamp: 0x5527ed90
Faulting module name: d3d9.dll, version: 6.3.9600.17415, time stamp: 0x54505402
Exception code: 0xc0000005
Fault offset: 0x00000000000275aa
Faulting process ID: 0x616c
Faulting application start time: 0x01d077079e400e6c
Faulting application path: C:\GAMES\SteamLibrary\steamapps\common\Grand Theft Auto V\GTAVLauncher.exe
Faulting module path: C:\Windows\SYSTEM32\d3d9.dll
Report ID: de2a7d70-e2fa-11e4-826e-d8cb8a18af95

Posted in d3d9.dll, Direct X, Windows 8.1 | Leave a comment

HOWTO: Generate a javascript stack trace

(new Error(‘oops’)).stack

Posted in Uncategorized | Leave a comment

showModalDialog replacement

Ok, so this is not a drop-in replacement for showModalDialog, because it does not block javascript, and does require some code changes.  I wrote it to demonstrate that we don’t really need showModalDialog, we can achieve the use case (prevent interaction with the page while prompting for something else) without needing to block.

Update: Code now available on GitHub:

Here is the code:-

NOTE, due to WordPress crapyness, I can no longer show html source code, use this Github link to see the full source code

function showModalDialog(url, args, options) {
    options = options || {};
    return new Promise(function(fullfil, fail) {
        var cover = $('<'+'div>')
        var content = $('<'+'div>')
            .css({ width : options.width||'50%',
                  height: options.height||'50%',
                  left: options.left||'25%',
                  display: 'none'
        var iframe = $('<'+'iframe>').appendTo(content).attr("src", url)
            .on("load", function() {
                content.css({ display: 'block' });
        var close = function () {
        showModalDialog.dialogArguments = args;
        showModalDialog.returnValue = function(v) {
        showModalDialog.cancel = function() {

And here is an example usage: (actual source code)

showModalDialog('dialog1.html', { arr: [ 'my', 'args' ] }, { width: '50%', height: '50%' }).then(function(returnValue) {
    alert('dialog returned ' + JSON.stringify(returnValue));
    // rest of your code

And the dialog HTML:- (actual source code)

<h1>A sample dialog</h1>
<p>Hello World</p>
<p>This dialog returns 'hello'</p>
<h2>Dialog Arguments</h2>
<+div id="args"></div>
<button onclick="complete('hello')">Close</button>
function complete(v) {
args.textContent = JSON.stringify(parent.showModalDialog.dialogArguments);
Posted in Uncategorized | 4 Comments