Skip to content

Instantly share code, notes, and snippets.

View brycebaril's full-sized avatar

Bryce Baril brycebaril

View GitHub Profile
brycebaril / binding.gyp
Created April 13, 2017 00:01 — forked from trevnorris/binding.gyp
Example of returning all values from uv_rusage() as tuples w/ no overhead. Values are only valid until getrusage() is called again.
"targets": [{
"target_name": "addon",
"sources": [ "" ]
"type": "Program",
"body": [
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "Identifier",
"name": "require"
function abc() {
return def();
function def() {
return abc.arguments[0] * 2;
abc(50); // >> 100
// so that's weird enough but:

The 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/ > out.perf-folded
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 /
Created September 7, 2013 04:38 — forked from rvagg/

Work in progress, I'll write this up properly when I'm done.

Almost all credit goes to @maxogden for putting me on to this and pointing me in the right direction for each of these items.


  • Raspberry Pi
  • Kindle Paperwhite freed from its locked down state (jailbroken)
    • You have to downgrade your Kindle to 5.3.1 to install the current jailbreak; that's just a matter of getting the old version image, putting it on your Kindle via USB and telling it to install "upgrade". Then you put in the Jailbreak files, load the ebook and break.
  • Your kindle will be quick to detect an upgrade is available so it'll want to upgrade soon afterwards but the jailbreak will last but you have to reinstall the developer certificates so it's a bit of a pain but doable. Find all the instructions on the forums and wiki.
fs.readFile('/proc/meminfo', 'utf8', function (err, str) {
var fields = {};
str.split('\n').forEach(function (line) {
var parts = line.split(':');
if (parts.length === 2) {
fields[parts[0]] = parts[1].trim().split(' ', 1)[0];
cb(fields['MemTotal'] + fields['Buffers'] + fields['Cached']);
var cluster = require('cluster');
var PORT = +process.env.PORT || 1337;
if (cluster.isMaster) {
// In real life, you'd probably use more than just 2 workers,
// and perhaps not put the master and worker in the same file.
cluster.on('disconnect', function(worker) {
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
module.exports = the_exported_function // Modules are a function. Always.
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
if [[ $1 != "-f" ]]; then
echo "### Dry-run mode, specify -f to actually perform deletes.";
for branch in $(git branch -r --merged origin/master | grep '\<origin/' | grep -v '\<origin/master\>');
if [[ -z $(git rev-list $branch --since '1 month') ]]; then
name=$(echo $branch | sed 's/^origin\///');
if [[ $1 = "-f" ]]; then