Skip to content

Instantly share code, notes, and snippets.

View hackergrrl's full-sized avatar
🌱

Kira hackergrrl

🌱
View GitHub Profile
#!/usr/bin/env bash
perf record -e cycles:u -g -- node --perf-basic-prof $1
perf script > perf-script.txt
cat perf-script.txt | flamegraph -t perf > perf-graph.svg
chromium perf-graph.svg
#!/usr/bin/env bash
perf record -e cycles:u -g -- node --perf-basic-prof $1
perf script > perf-script.txt
cat perf-script.txt | flamegraph -t perf > perf-graph.svg
chromium perf-graph.svg
#!/usr/bin/env bash
perf record -e cycles:u -g -- node --perf-basic-prof $1
perf script > perf-script.txt
cat perf-script.txt | flamegraph -t perf > perf-graph.svg
chromium perf-graph.svg
foobar
@hackergrrl
hackergrrl / noffle.md
Last active August 19, 2017 03:35
noffle's linux setup
  • OS: NixOS (tough learning curve; recommend using Arch Linux)
  • Window Manager: i3
  • Menu Bar: i3bar
  • Wifi: my wifi- commands (depends on wpa_supplicant and dhcpcd)
  • Custom keyboard shortcuts: xbindkeys
  • Email: neomutt + getmail + msmtp
  • Terminal/Editor Font: Ubuntu Mono
  • Terminal Emulator: termite

dotfiles repo

@hackergrrl
hackergrrl / get_osm_doc.js
Last active June 26, 2017 22:15
Convert a version ID to an OSM document (osm-p2p-db)
function getOsmDocFromVersionId (osmdb, version, done) {
osmdb.get(version, function (err, node) {
if (err) done(err)
else done(null, getOsmDocFromHyperlogNode(node))
})
}
function getOsmDocFromHyperlogNode (node) {
if (node.value && node.v) return node.value.v // Returns the OSM document (has 'type', 'lat', 'lon', etc)
if (node.value && node.d) return null // This document is a deletion marker for an older document

understanding callbacks & async code flow

Consider setTimeout: a very simple asynchronous function. It takes two parameters: a callback and a delay:

setTimeout(fn, delay)

In use, it might look something like this:

var hyperlog = require('./')
var level = require('level')
var through = require('through2')
var memdb = require('memdb')
var TopoSort = require('topo-sort');
var dedupe = require('dedupe')
if (process.argv.length !== 4) {
console.error('USAGE: rebuild <LEVEL-DIR> <NEW-LEVEL-DIR>')
process.exit(1)

1. register particle account

https://build.particle.io/signup

2. setup board

unpackage the board and plug it into your laptop

particle's "getting started" guide: