Skip to content

Instantly share code, notes, and snippets.

@cdaringe
cdaringe / promise-queue-with-chained-settle-detection.js
Created June 3, 2016 00:14
promise-queue-with-chained-settle-detection
var bluebird = require('bluebird');
var queue;
var queueLen = 0;
function queueUp(fn) {
if (!queue) {
console.log('start');
queue = bluebird.resolve();
}
++queueLen;
@cdaringe
cdaringe / 8.0.5-joi-profile-fast.txt
Last active June 5, 2016 03:16
8.0.5-joi-profile-fast.txt
Statistical profiling result from isolate-0x102004a00-v8.log, (885 ticks, 90 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
70 7.9% /usr/local/bin/node
6 0.7% /usr/lib/system/libsystem_platform.dylib
2 0.2% /usr/lib/system/libsystem_c.dylib
[JavaScript]:
ticks total nonlib name
@cdaringe
cdaringe / 8.4.0-joi-profile-slow.txt
Created June 5, 2016 03:18
8.4.0-joi-profile-slow.txt
Statistical profiling result from isolate-0x102800000-v8.log, (4205 ticks, 405 unaccounted, 0 excluded).
[Shared libraries]:
ticks total nonlib name
448 10.7% /usr/local/bin/node
23 0.5% /usr/lib/system/libsystem_platform.dylib
16 0.4% /usr/lib/system/libsystem_malloc.dylib
8 0.2% /usr/lib/system/libsystem_pthread.dylib
2 0.0% /usr/lib/system/libsystem_c.dylib
@cdaringe
cdaringe / gist:99c4a02d92cb71a666508a64cdc2b634
Created November 19, 2016 18:17
mdp-reward-discount-exp
T 1 1 1 1 1 1 1 1 1
9 0 0 0 0 0 0 0 0 1
9 0 0 0 0 0 0 0 0 1
9 0 0 0 0 0 0 0 0 1
9 0 0 0 0 0 0 0 0 1
9 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0 0 1
S 1 1 1 1 1 1 1 1 1
@cdaringe
cdaringe / pouchy-web-bundled.js
Created November 30, 2016 21:28
pouchy-web-bunlded.js
// index.js
const Pouchy = require('./src/index')
const db = new Pouchy({ name: 'kittens' })
db.save({ name: 'meow' })
.then(() => db.all())
.then(docs => console.log(docs))
// browserify index.js -o bundle.js
// load bundle.js into a <script src="...></script>, and you get
@cdaringe
cdaringe / kuberenetes-no-nodes
Created December 29, 2016 17:16
kuberenetes-no-nodes
$ kubectl describe pod kubernetes-dashboard-3543765157-94gj9 --namespace="kube-system"
Name: kubernetes-dashboard-3543765157-94gj9
Namespace: kube-system
Node: /
Labels: k8s-app=kubernetes-dashboard
pod-template-hash=3543765157
Status: Pending
IP:
Controllers: ReplicaSet/kubernetes-dashboard-3543765157
Containers:
@cdaringe
cdaringe / get-vagrant-box-ip.sh
Created December 30, 2016 17:08
get vagrant box ip
vagrant ssh w1 -c "ip address show eth0 | grep 'inet ' | sed -e 's/^.*inet //' -e 's/\/.*$//'"
@cdaringe
cdaringe / nested-vs-inline-fns
Created January 23, 2017 17:16
nested-vs-inline-fns
var ITCOUNT = 1e6
function a () {
return function b (z) { return z + 1 }
}
var sum1 = 0
for (var i = 0; i < ITCOUNT; ++i) {
var toAdd1 = Math.random()
var start1 = process.hrtime()[1]
@cdaringe
cdaringe / index.html
Created January 26, 2017 00:58 — forked from anonymous/index.html
JS Bin // source http://jsbin.com/wugayu
<!DOCTYPE html>
<html>
<head>
<script src="https://unpkg.com/[email protected]/dist/react.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-dom.min.js"></script>
<script src="https://unpkg.com/redux@^3.5.2/dist/redux.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-redux.min.js"></script>
<script src="https://unpkg.com/@reactivex/rxjs/dist/global/Rx.js"></script>
<script src="https://unpkg.com/redux-observable/dist/redux-observable.min.js"></script>
<meta charset="utf-8">
@cdaringe
cdaringe / index.js
Created February 3, 2017 23:00
vscode-hover-wrong-variable-data.js
// install rxjs
// configure vscode to run this file
const Rx = require('rxjs')
const { Observable } = Rx
const EventEmitter = require('events')
const myEmitter = new EventEmitter()
const START_REGISTRATIONS_POLL = 'START_REGISTRATIONS_POLL'
const STOP_REGISTRATIONS_POLL = 'STOP_REGISTRATIONS_POLL'