Skip to content

Instantly share code, notes, and snippets.

@kevadsett
kevadsett / ValueMapper
Last active December 23, 2015 08:39
ValueMapper - normalise and transform - great for converting a number from one range to a different range
var ValueMapper = {
normalise: function(value, low, high) {
var range = high - low;
return (value - low) / range;
},
transform: function(value, inputLow, inputHigh, outputLow, outputHigh) {
var normal = this.normalise(value, inputLow, inputHigh);
return normal * (outputHigh - outputLow) + outputLow;
}
@jfromaniello
jfromaniello / continous-qunit.ps1
Created August 4, 2011 14:22
The powershell continuously watch for file changes in a directory, then it executes PhantomJs with the Run-Qunit.js attached to your htm qunit test harness.
# watch a file changes in the current directory,
# execute all tests when a file is changed or renamed
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = get-location
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $false
$watcher.NotifyFilter = [System.IO.NotifyFilters]::LastWrite -bor [System.IO.NotifyFilters]::FileName
while($TRUE){