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
/** | |
* Strongly typed event emitter | |
* | |
* @usage | |
* | |
* const emitter = createEmitter<{ | |
* signature: [{ publicKey: number[]; signature: number[] }]; | |
* }>(); | |
* | |
* emitter.on("signature", ({ publicKey, signature }) => { |
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
/** | |
* sort array (of objects) by multiple values | |
*/ | |
function sort (order) { | |
return function by (head, ...tail) { | |
return function comparator (a, b) { | |
if (!head) return 0; | |
if (a[head] > b[head]) return order; | |
if (a[head] < b[head]) return -order; |
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 fs = require('fs'); | |
const hyperquest = require('hyperquest'); | |
const pump = require('pump'); | |
const xray = require('x-ray'); | |
const parse = require('json-parse-stream'); | |
const through = require('through2').obj; | |
const x = xray().throttle(1, 300); // be considerate | |
const schema = [{ |
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
/** | |
* Print SVG that will render a rectangular tooltip with a tip at the bottom | |
*/ | |
setTimeout(function() { | |
console.log( | |
'<svg version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="' + | |
getTooltipPath(10, 10, 200, 80, 4, 10, 2, 'top').toString() + | |
'" fill="#777777"/></svg>' | |
); |
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
for line in `docker ps | awk '{print $1}' | grep -v CONTAINER`; do docker ps | grep $line | awk '{printf $NF" "}' && echo $(( `cat /sys/fs/cgroup/memory/docker/$line*/memory.usage_in_bytes` / 1024 / 1024 ))MB ; done |
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
# USAGE: | |
# production node -e 'console.log(process.env.HELLO)' | |
# staging node -e 'console.log(process.env.HELLO)' | |
# | |
production() { | |
NODE_ENV=production \ | |
HELLO=world \ | |
FOO=bar \ | |
$* |
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
title | content | cover | createdAt | |
---|---|---|---|---|
Hello | World | -123- | 10-10-2012 |
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
var vm = require('vm'), | |
code = 'var square = n * n;', | |
fn = new Function('n', code), | |
script = vm.createScript(code), | |
sandbox; | |
n = 5; | |
sandbox = { n: n }; | |
benchmark = function(title, funk) { |
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
# http://forums.shopify.com/categories/6/posts/42926 | |
# This is a fairly simple mechanize script to create a few hundred or so shopify discounts from a CSV of groupon codes. | |
# You'll want to change all of the "changeme" values to your own. | |
# The script expects there to be a groupon_codes.csv in the same directory. | |
# | |
# The groupons_code.csv should look like this: | |
# 8m7677 | |
# 8m6749 | |
# 8m5398 | |
# 8m7699 |