This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
/** | |
* Socket.io => Client => Listener | |
*/ | |
function onSocketMessage: (channel_id, array_buffer) => | |
// ArrayBuffer => String | |
// http://updates.html5rocks.com/2012/06/How-to-convert-ArrayBuffer-to-and-from-String | |
json = String.fromCharCode.apply(null, new Uint8Array(array_buffer)); | |
try { |
This file contains hidden or 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
/** | |
* Redis => Server => Socket.io | |
*/ | |
function onRedisMessage(channel, message) { | |
var json; | |
try { | |
json = JSON.parse(message); | |
} | |
catch (err) { |
This file contains hidden or 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 hidden or 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://gist.github.com/trevnorris/9616784 | |
sudo sysctl kernel.kptr_restrict=0 | |
sudo sysctl kernel.perf_event_paranoid=0 | |
sudo sysctl kernel.perf_event_mlock_kb=65536 |
This file contains hidden or 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 hidden or 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://perf.wiki.kernel.org/index.php/Main_Page | |
# https://perf.wiki.kernel.org/index.php/Tutorial#Sampling_with_perf_record | |
# https://perf.wiki.kernel.org/index.php/Tutorial#Sample_analysis_with_perf_report | |
sudo apt-get install -y linux-tools-`uname -r` | |
sudo apt-get install -y linux-tools-common | |
sudo apt-get install -y linux-cloud-tools-`uname -r` | |
sudo apt-get install -y linux-cloud-tools-common |
This file contains hidden or 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
daemonize yes | |
logfile "/var/log/redis/redis-server.log" | |
save "" | |
dir /tmp | |
# lots of connections | |
maxclients 10000 | |
# low tolerance for under-run | |
# otherwise, redis-server gets a memory leak |
NewerOlder