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
/* @flow */ | |
const createPerson = ({}: { name: string, birth: Date, pets: number }): [] => [] | |
const a = {}; | |
//createPerson(a); | |
const b = { ...a, name: 'fred' }; | |
//createPerson(b); |
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
<html> | |
<head> | |
<style> | |
.type-chars { | |
font-family: monospace; | |
font-size: 30px; | |
} | |
</style> | |
</head> | |
<body> |
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
Cache-Control: no-cache, no-store, must-revalidate | |
Pragma: no-cache | |
Expires: 0 |
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
#!/usr/bin/env bash | |
set -e | |
set -x | |
COMMIT=$(git rev-parse master) | |
TAG=$(git describe $(git rev-list --tags --max-count=1)) | |
DATE=`date +%Y-%m-%d` | |
mkdir -p doc-building |
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
const map = f => r => (m, i) => r(m, f(i)); | |
const filter = p => r => (m, i) => (p(i) ? r(m, i) : m); | |
function conc(m, i) { return m.concat(i); } | |
[1, 2, 3].reduce( | |
map(x => (console.log('map ' + x), x + x))( | |
filter(x => (console.log('filter ' + x), x !== 4))(conc)), | |
[]); | |
class S { |
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
const gistUser = process.argv[2]; if (!gistUser) { | |
console.error('no gist user specified'); process.exit(1); } | |
const destDir = process.argv[3] || './'; | |
const exec = require('child_process').exec; | |
const path = require('path'); | |
exec(`curl -s https://api.github.com/users/${gistUser}/gists`, (e, so, se) => { | |
gists = JSON.parse(so).map(gist => ({ | |
folder: gist.description || gist.id, | |
pull: gist.git_pull_url })); |
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/sh | |
mkdir -p /etc/systemd/system/docker.service.d | |
echo "[Service] | |
Environment=\"HTTP_PROXY=http://10.215.2.2:8080/\" | |
Environment=\"HTTPS_PROXY=https://10.215.2.2:8080/\""\ | |
> /etc/systemd/system/docker.service.d/http-proxy.conf | |
echo sudo systemctl daemon-reload |
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 throng from 'throng'; | |
import {MongoClient} from 'mongodb'; | |
let dups = 0; | |
async function insertOptimisticLoop(doc, collection, retry=100){ | |
const cursor = await collection // find greatest __t progrssive number | |
.find( { __t: { $exists: true } }, { __t: 1, __id: -1} ) | |
.sort( { __t: -1 } ).limit(1); | |
const next = await cursor.hasNext() ? (await cursor.next()).__t + 1 : 1; // calculate next __t |
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
var pg = require ('pg'); | |
var pgConString = "postgres://postgres:mysecretpassword@localhost/postgres" | |
pg.connect(pgConString, function(err, client) { | |
if(err) { | |
console.log(err); | |
} | |
client.on('notification', function(msg) { | |
console.log(msg); |
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
const mongodb = require('mongodb') | |
const Bluebird = require('bluebird') | |
class EventStore { | |
constructor(dbUrl, collectionName){ | |
this.db = mongodb.MongoClient.connect(dbUrl); | |
this.cappedCollection = this.db.then(db=> | |
db.createCollection(collectionName, { capped: true, size: 1024*1024 }) | |
.then(()=> db.collection(collectionName).createIndex({__t: 1}, {unique: true})) | |
.then(()=> db.collection(collectionName)) |