Skip to content

Instantly share code, notes, and snippets.

View brycebaril's full-sized avatar

Bryce Baril brycebaril

View GitHub Profile

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 March 16, 2014 23:20
requirebin sketch
/*
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 */
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))
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 March 15, 2014 20:45
requirebin sketch
/*
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 March 14, 2014 22:19 — forked from max-mapper/index.js
requirebin sketch
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 March 14, 2014 22:19
requirebin sketch
// 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 March 14, 2014 22:19
requirebin sketch
// 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 December 18, 2013 05:33
poor-man's multibuffer-stream
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()
}))
@brycebaril
brycebaril / baleet.js
Created November 7, 2013 23:50
BALEET
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])
}