Skip to content

Instantly share code, notes, and snippets.

@polotek
polotek / device.js
Created May 11, 2012 05:27 — forked from rwaldron/device.js
Fat Arrows and Classes-as-Prototype-sugar make a beautiful future for JavaScript
var stream = require("fake-stream-lib"),
Emitter = require("events").EventEmitter,
util = require("util");
// Today...
function Device( opts ) {
this.value = null;
var request = require('request')
, gunzip = require('zlib').createGunzip()
, json = new (require('jstream'))();
request('http://data.githubarchive.org/2012-03-11-12.json.gz')
.pipe(gunzip)
.pipe(json)
.on('data', function(obj) {
console.log(obj);
});
@polotek
polotek / db-launch.sh
Last active April 20, 2016 05:47 — forked from fancyremarker/db-launch.sh
Example: db-launch script to launch the Aptible postgresql database image
# A script for creating aptible postgres databases in containers
container=$(head -c 32 /dev/urandom | md5);
username=${USERNAME:-aptible};
passphrase=${PASSPHRASE:-password};
dbname=${DATABASE:-db}
cname=${CNAME}
extport=${EXTPORT:-5432}
image="${@: -1}";
# Create a data volume
JSON._dateReviver = function (k,v) {
if (v.length !== 24 || typeof v !== 'string') return v
try {return new Date(v)}
catch(e) {return v}
}
JSON.parseWithDates = function (obj) {
return JSON.parse(obj, JSON._dateReviver);
}
@polotek
polotek / design_docke_template.md
Created April 3, 2019 03:06
Design Doc Template

Design Doc Title

Stakeholders

List stakeholders for project/feature.

Role Person
Dev Owner
Other Dev 1 (Engine)

JavaScript Fundamentals

Part 1: Variables

Var & Scope

var greeting = 'Hello';
console.log(greeting); // prints: Hello

if (true) {
  var greeting = 'Hi';