Skip to content

Instantly share code, notes, and snippets.

Avatar

Mark Wubben novemberborn

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

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
View cancellation-c.js
var legendary = require("legendary");
test1();
test2();
test3();
test4();
test5();
test6();
test7();
@novemberborn
novemberborn / gist:4407774
Last active Dec 10, 2015
Cancelation/A+ Draft B
View gist:4407774

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.
View gist:4400252

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 Dec 10, 2015
Cancelation/A+ Draft A
View gist:4399269

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 Jun 7, 2012 — forked from mikewilcox/Deferred.js
Deferred Error Testing
View Deferred.js
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); };
}
};
View zed.js
// 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 Jun 26, 2011
Focus the terminal window open in the current space, or open a new one.
View Activate Terminal.scpt
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 Apr 2, 2011
Convert pasteboard string into JSON
View gist:899634
#!/usr/bin/env node
require("child_process").exec("pbpaste", function(_, stdout){
process.stdout.write(JSON.stringify(stdout.trim()));
});