Skip to content

Instantly share code, notes, and snippets.

Avatar

Bryce Baril brycebaril

View GitHub Profile
View perf-flame-graph-notes.md

The prep-script.sh will setup the latest Node and install the latest perf version on your Linux box.

When you want to generate the flame graph, run the following (folder locations taken from install script):

sudo sysctl kernel/kptr_restrict=0

perf record -i -g -e cycles:u -- ~/sources/node/node --perf-basic-prof script.js

perf script | egrep -v "( __libc_start| LazyCompile | v8::internal::| Builtin:| Stub:| LoadIC:|\[unknown\]| LoadPolymorphicIC:)" | sed 's/ LazyCompile:[*~]\?/ /' | ~/sources/FlameGraph/stackcollapse-perf.pl > out.perf-folded
@brycebaril
brycebaril / index.js
Created Mar 16, 2014
requirebin sketch
View index.js
/*
Browserify Live Demos!
How to make your own:
1. Clone this RequireBin
2. Adjust the REQUIRES section
3. Create a gist with demo snippets that can be run
4. Put the id for that gist into the demoGist variable
*/
/* REQUIRES: Put modules you need in your demo in this Array */
View All Methods
var stats = require("stats-lite")
var dice = require("droll")
var rolls = []
for (var i = 0; i < 3000; i++) {
rolls.push(dice.roll("2d6").total)
}
console.log("sum: %s", stats.sum(rolls))
console.log("mean: %s", stats.mean(rolls))
View Put Get
var levelup = require("levelup")
var leveljs = require("level-js")
var db = levelup("./demo", {db: leveljs})
db.put("wow", "mom", function (err, reply) {
if (err) return console.log(err)
db.get("wow", function (err, reply) {
if (err) return console.log(err)
console.log("Got: '%s'", reply)
})
@brycebaril
brycebaril / index.js
Created Mar 15, 2014
requirebin sketch
View index.js
/*
Browserify Live Demos!
How to make your own:
1. Clone this RequireBin
2. Adjust the REQUIRES section
3. Create a gist with demo snippets that can be run
4. Put the id for that gist into the demoGist variable
*/
/* REQUIRES: Put modules you need in your demo in this Array */
@brycebaril
brycebaril / index.js
Created Mar 14, 2014 — forked from maxogden/index.js
requirebin sketch
View index.js
var observer = require('continuous-observer')
var cave = require('cave-automata-2d')
var fill = require('ndarray-fill')
var zero = require('zeros')
var raf = require('raf')
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d')
// Set up the controls, so that we can control
@brycebaril
brycebaril / index.js
Created Mar 14, 2014
requirebin sketch
View index.js
// try requiring some modules from NPM and then hit Run
var s = require('stats-lite')
console.log(s.mean([0, 9, 100, 3, 51, 33, Math.random() * 20]))
@brycebaril
brycebaril / index.js
Created Mar 14, 2014
requirebin sketch
View index.js
// try requiring some modules from NPM and then hit Run
var s = require('stats-lite')
console.log(s.mean([0, 9, 100, 3, 51, 33, Math.random() * 20]))
@brycebaril
brycebaril / s.js
Created Dec 18, 2013
poor-man's multibuffer-stream
View s.js
var spigot = require("stream-spigot")
var through2 = require("through2")
var terminus = require("terminus")
var mb = require("multibuffer")
spigot(["aaaaaaaaaaa", "bbbbbbbbbbbb", "cccccccccccccccc"])
.pipe(through2(function (chunk, encoding, callback) {
this.push(mb.pack([chunk]))
callback()
}))
View baleet.js
var client = require("redis").createClient()
var pattern = process.argv[2]
if (!pattern) throw new Error("Read codez for usage")
client.keys(pattern, function (err, keys) {
for (var i = 0; i < keys.length; i++) {
client.del(keys[i])
}