This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map $http_upgrade $connection_upgrade { | |
default upgrade; | |
'' close; | |
} | |
upstream server_cluster { | |
# sticky connections are critical for non-WebSocket Socket.io | |
# http://socket.io/docs/using-multiple-nodes/ | |
ip_hash; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# https://askubuntu.com/questions/197016/how-to-install-a-package-that-contains-ubuntu-kernel-debug-symbols | |
# https://wiki.ubuntu.com/DebuggingProgramCrash#Debug_Symbol_Packages | |
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs) main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list | |
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs)-updates main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list | |
echo "deb http://ddebs.ubuntu.com $(lsb_release -cs)-proposed main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list.d/ddebs.list | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ECDCAD72428D7C01 | |
sudo apt-get update |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def catchAndThrow(flow) | |
i = 0 | |
if (flow == :return) then | |
return i | |
end | |
catch do |label| | |
# TODO: something useful | |
i += 1 | |
throw label if (flow == :throw) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { URL } from 'url'; | |
const DOMAINS = new Set([ 'example.com', 'alternate.net' ]); | |
const SEGMENTS = new Set([ 'query', 'search' ]); | |
export function matchURI(uri) { | |
let id = undefined; | |
let url; | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import assert from 'assert'; | |
import { matchURI } from './matchURI.mjs'; | |
assert.deepStrictEqual(matchURI('UNPARSEABLE'), { | |
uri: 'UNPARSEABLE', | |
id: undefined, | |
reason: 'error', | |
}); | |
assert.deepStrictEqual(matchURI('https://stealth.mil/resource/SECRET'), { | |
uri: 'https://stealth.mil/resource/SECRET', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
method() { | |
return 'foo'; | |
} | |
} | |
class Wrapper { | |
constructor(wrapped) { | |
this.latch = 2; // arbitrary condition; "proxy it this many times" | |
return new Proxy(wrapped, this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* fewer lines, sure ... | |
*/ | |
function _sameLineStyle() { | |
return example.firstMethod().then(function() { | |
return example.secondMethod(); | |
}).then(function() { | |
return example.thirdMethod(); | |
}); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// const ... | |
var EARLY_RETURN; | |
function _getSomething(key, data) { | |
var scopedResult; | |
return cache.fetchSomething(key) | |
.then(function(_resolved) { | |
scopedResult = _resolved; | |
if (scopedResult) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* be careful to return a Promise from every exiting branch | |
*/ | |
function mayReject(may) { | |
if (may || (may === undefined)) { | |
return Promise.reject(new Error('I REJECT')); | |
} | |
return Promise.resolve(true); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fooAndBarInParallel() { | |
// boiler-plate. meh | |
var constructed = new Promise(function(resolve, reject) { | |
emitter.once('foo', function(food) { | |
resolve(food); | |
}); | |
}); | |
// such clean. so code | |
var deferred = Promise.deferred(); |
NewerOlder