A basic requirejs for WScript

So I like the module pattern when programming javascript.  So when I came to writing a script to process some inbound emails in an MSSQL database, I had already chosen JavaScript as my language of choice, and wanted to use the module pattern, so I wrote a crude but effective require function:-

function require(FN) {
    var cache = require.__cache = require.__cache || {};
    if (cache[FN]) return cache[FN];
    var FSO = WScript.CreateObject("Scripting.FileSystemObject");
    var T = null;
    try {
        var TS = FSO.OpenTextFile(FN,1);
        if (TS.AtEndOfStream) return "";
        T = TS.ReadAll();
        TS.Close();
        TS = null;
    } catch(e) {
        WScript.echo("ERROR! " + e.number + ", " + e.description + ", FN=" + FN);
        WScript.quit();
        return;
    }
    FSO = null;
    T = "(function(global){\n" + '"use strict";' + "\n" + T + "})(this);\n\n////@ sourceURL=" + FN;
    cache[FN] = eval(T);
    if ("VERSIONINFO" in cache[FN]) WScript.echo(cache[FN].VERSIONINFO);
    return cache[FN];
}

Use as follows:-

var interface = require("module.js");
interface.run();

Where module.js contains:-

return {
  run: function() {
  }
};

What module returns, is up to the module. It may be an object, a function, a resource. I use this in a script called app.js that takes the first argument on the command line as the name of the app to run, loads it as a module, then calls main() passing the rest of the arguments to the main function.

var arguments = WScript.arguments;
if (arguments.length > 0) {
    var args = [];
    for (var i = 0; i < arguments.length; i++) {
        args.push(WScript.arguments(i));
    }
    var name = args.shift();
    var app = require(name+".js");
    if (app) {
        var exitstatus = app.main.call(app, args);
        if (typeof exitstatus != undefined) {
            WScript.quit(exitstatus);
        }
    } else {
        WScript.echo("Error, cannot find " + name + ".js");
        WScript.quit(1);
    }
}

I can then run my application (procemail.js) as follows:-

cscript.exe app.js procemail
Posted in JavaScript, module pattern, require, WScript | Tagged , , , | Leave a comment

How to convert SQL Blob to Text in JavaScript

The problem I was facing was that I had some text in a database stored in an image field (blob data), and I wanted to get at that text in javascript.  After a lot of searching and some experimentation, I came up with the following code:-

var blob2Text = function(blobField, charset) {
        var stream = new ActiveXObject("ADODB.Stream");
        stream.Charset = charset;
        stream.Type = 1;  // binary
        stream.Open();
        stream.Write(blobField);
        stream.Position = 0;
        stream.Type = 2;  // text
        var text = stream.ReadText(-1);
        stream.Close();
        return text;
};

Use as follows:-

var rs = new ActiveXObject("ADODB.Recordset");
... code to query data ...
var text = blob2Text(rs("myBlobData"), "us-ascii");
Posted in JavaScript, WScript | Tagged , , , , | Leave a comment

TESO

Huge Fuck Up
Nuff Said

Posted in Uncategorized | Leave a comment

Leap Motion – Most useless tech 2013 (now 2014) award

At least, that’s what I award it. Has to be my worst purchase this year, the thing just does not work as promised. Controlling your PC with it is impossible to do with any amount of proficiency, its so inaccurate and unreliable, and the software is badly designed.

Some specifics:-

– The difference between moving the mouse pointer over something and clicking it, is signalled by moving your finger towards the screen across the ‘touch’ threshold. However that threshold keeps moving towards and away from your monitor it is NEVER in the same place, and so completely fails as a user interface.

– It sees your thumb/hand as a finger quite often so thinks your using two (or three) fingers when your only using one or two, which prevents the gesture recognition from working properly.

– It’s almost impossible to calibrate – I spent the best part of 5 minutes trying to get it to calibrate before I managed it (and no real confidence its properly calibrated)

– Scrolling requires this awful circular motion so your hand is moving in an out of (the ever changing) touch zone

– Gestures have to be done SSSSLLLLOOOOWWWWWLLLLLYYYY or else it just can’t recognise them (it even tells you this in the instructions).

– Lastly, its tiring to use. Your arms are aching after 10 to 15 minutes using it.

There are some other issues with it too, for instance, PC won’t boot with it plugged in it hangs at post. There was loads of trouble getting the device to be recognised by windows, in the end it would only work in one USB port, and only then after messing about updating drivers in device manager / disabling reenabling – so much messing about that I don’t remember exactly what I had to do now to get it going.

Lastly, support is non existent – I logged 3 calls, 3 separate issues on release day (weeks ago) and to date not a single one has been replied to.

Take my advice, don’t waste your money in this tech. At best its a rubbish game controller backed by an app store full of rubbish games.

https://www.leapmotion.com/

Update:

The other day I decided to give this kit another go, this time on my Win 8 media centre PC, and I have to say … ITS AS BAD AS EVER, in fact it was possibly even worse. I did manage to get calibration to work this time, but it didn’t matter much. I was trying the tutorial for controlling windows with it, and it kept telling me I was touching too fast, and I was moving so incredibly slowly it was ridiculous. Also attempting to scroll by waving in and out of the touch zone hardly worked at all, probably 1 in 10 swipes resulted in the desired action. Plus, as before the touch zone keeps moving, the finger detection is inaccurate – its just totally not fit for purpose.

So, I award this tech. Most useless tech award 2014 as well.

http://www.maplin.co.uk/p/leap-motion-controller-a28lr

Maplin’s description of it makes me laugh, how can they claim these things about this kit:-

* It accurately senses your hands and fingers up to 1/100th of a millimeter, with no latency.

Firstly it is far from accurate. Pointing with one finger is often interpreted as two fingers, and two fingers as three fingers. Rendering it USELESS as an input mechanism for controlling windows.

Secondly, no latency is clearly a lie, as that is physically not possible.

Posted in PC | Tagged , , , | 4 Comments

Chrome Issue 335248

Bit if a major booboo from google chrome dev team, they very broke chrome 32, and there seems to be no contingency for rolling back a bad commit once it hits stable.

http://code.google.com/p/chromium/issues/detail?id=335248

If you are having problems scrolling and / or seeing page not responding dialog when using a popup or app window, then you have just run into this issue.

Posted in Chrome | Tagged , , , , , , | Leave a comment

Apple Dishonest Tricksters?

In the App Store for MAC, in the Top Free category, positions 4. 5. and 6. are Keynotes, Pages and Numbers apps, all at £13.99 each!! — FUNNY DEFINITION OF THE WORD FREE

Also note, they are the ONLY paid-for apps in the Top Free section. Now if it was just a random selection of apps, I would have put it down to a bug or oversight, but specifically 3 paid-for apple apps from the same suite of apps — something fishy going on.

TopFree

Posted in Apple | Leave a comment

How long to empty recycle bin?

Well, on my OSX Mavericks macbook pro, its been running over 5 minutes already and only 10% complete, WHAT IS IT DOING – Is it uploading everything in it to cloud storage or something? It’s taking enough time to do that.

While on the subject of performance, OSX boot time is dymsal, also takes about 5 minutes. I was literally able to go into the kitchen and make a brew, whilst it rebooted. I was hoping that OSX Mavericks was going to address some of OSXs performance issues, it would seem not.

In the time it has taken me to come to this website and write this post, my Items to delete: progress has gone from 19 to 18. Going to be waiting a while!

Posted in Uncategorized | Tagged , | Leave a comment

Post OSX Mavericks upgrade issues

After upgrading to OSX Mavericks, here is a list of things that were broken:-

Issue Solution
Dashlane no longer works in chrome Complete uninstall and re-install using DMG form their website fixed the issue.
ant disappeared brew update ; brew install https://raw.github.com/Homebrew/homebrew-dupes/master/ant.rb
php disabled sudo vi /etc/apache2/httpd.conf and uncomment LoadModule php5_module libexec/apache2/libphp5.so then restart apache using sudo apachectl restart
mkdir -p app/. broken remove the trailing /. or an even simpler fix, prefix the path with ./ so mkdir ./app/. works. The issue is restricted to mkdir -p with one level of relative path with a trailing ./
Chrome Helper (Not Responding) https://code.google.com/p/chromium/issues/detail?id=304860
Parallels VM (Not Responding) These not responding problems are cosmetic in that the process are not stuck, they are functioning normally, but activity viewer is showing them as not responding
Posted in Uncategorized | Leave a comment

Dashlane broken in OSX Mavericks + Chrome 30 – FIXED

So I updated to OSX Mavericks only to find that now Dashlane is completely useless as the browser extension for chrome as it no longer works at all, and never offers to auto-fill any login or other forms, plus when clicking the extension icon, all I see is the extension popup framework with a spinner icon in the middle.

Trying my hardest to like this product but it seems to be trying its best to make me not want to like it!

Hoping for a fix soon, else I will be left with little option but to switch back to LastPass.

*update* After speaking to support, and obtaining an uninstaller, uninstalled and initially tried installing the App Store version (based on supports suggestion to do so) and that version didn’t work in chrome at all. Then re-installed using the latest dmg from their website and it is working again.

Posted in Uncategorized | 3 Comments

Serious Dashlane memory leaks in chrome extension

The screenshot(s) below shows a very bad memory leak that has existed in Dashlane for some time, that I have previously reported to their support/development teams (though not this particular evidence, which I have only just sent to them).

It shows using chrome developer tools timeline & profiler that a module in their extension is repeatedly and rapidly firing a timer, and each time it fires it is consuming a number of bytes of memory (in this instance, on the new tab page, its consuming 200-256 bytes per tick.  In my application that I was profiling this was just short of 1k per tick.

The culprit seems to be kw_injected and something to do with frameReport (whatever that is).

Posted in Chrome, Extensions, Memory Leaks, Security | 3 Comments