Skip to content

Instantly share code, notes, and snippets.

View novemberborn's full-sized avatar

Mark Wubben novemberborn

View GitHub Profile
@novemberborn
novemberborn / gist.md
Created August 6, 2015 15:22
Removing all unused docker containers and images
@novemberborn
novemberborn / gist:6938771
Created October 11, 2013 17:30
Guide to setting up a local NPM registry

CouchDB

Install CouchDB. This guide assumes 1.3.1. Set up an admin account.

Create the database required by NPM:

curl -X PUT http://admin:password@127.0.0.1:5984/registry
var legendary = require("legendary");
test1();
test2();
test3();
test4();
test5();
test6();
test7();
@novemberborn
novemberborn / gist:4407774
Last active December 10, 2015 08:28
Cancelation/A+ Draft B

Cancelation/A+

This proposal specifies how cancelation is triggered, handled and propagated in a Promises/A+ promise library.

Terminology

In addition to the terminology from Promises/A+ we use the following:

  1. OperationCanceled is an error used to reject canceled promises.
  2. "direct cancelation" is when a promise or resolver is canceled by the consumer of the promise calling cancel.

Progress/A+

This proposal specifies how progress is triggered and propagated in a Promises/A+ promise library.

Requirements

The then Method

The then method is the same as that specified in the promises-spec except that it also takes a third argument. We'll call that third argument the onProgress:

@novemberborn
novemberborn / gist:4399269
Last active December 10, 2015 07:08
Cancelation/A+ Draft A

Cancelation/A+

This proposal specifies how cancelation is triggered, handled and propagated in a Promises/A+ promise library.

Terminology

In addition to the terminology from Promises/A+ we use the following:

  1. OperationCanceled is an error used to reject canceled promises.
  2. "direct cancelation" is when a promise is canceled by the consumer of the promise calling 'cancel'.
@novemberborn
novemberborn / Deferred.js
Created June 7, 2012 18:44 — forked from mikewilcox/Deferred.js
Deferred Error Testing
require([
"dojo/Deferred"
], function(Deferred){
var useError = 0;
var getError = function(name, useThisError){
var msg = name + ' error';
if(useError || useThisError){
return function(e){ console.error(msg); d.reject(e); };
}
};
@novemberborn
novemberborn / zed.js
Created July 20, 2011 17:28
widgets/zed
// Supported modes:
// * non-modal (like dijit/popup, default)
// * modal (like dijit/Dialog)
// * underlay (like dijit/Dialog, off by default, specify underlay widget)
// * allowTab (TAB goes through the widget, off by default)
// * lockFocus (prevent TAB from going out of widget, by default on for modal, off for non-modal)
// * cancelOnEsc (close when ESC is hit, on by default)
// * cancelOnBlur (close when widget is blurred, on by default)
// Also supports `around`, `orient`, `x` and `y` and `padding` args from dijit/popup
@novemberborn
novemberborn / Activate Terminal.scpt
Created June 26, 2011 18:00
Focus the terminal window open in the current space, or open a new one.
tell application "Terminal"
activate
set hasWindow to false
try
repeat with theWindow in windows
if (frontmost of theWindow) then
set hasWindow to true
end if
end repeat
end try
@novemberborn
novemberborn / gist:899634
Created April 2, 2011 16:46
Convert pasteboard string into JSON
#!/usr/bin/env node
require("child_process").exec("pbpaste", function(_, stdout){
process.stdout.write(JSON.stringify(stdout.trim()));
});