Skip to content

Instantly share code, notes, and snippets.

View fitzgen's full-sized avatar
🌴
On vacation

Nick Fitzgerald fitzgen

🌴
On vacation
View GitHub Profile
@fitzgen
fitzgen / gist:95f8b2ea672d773f3537
Created August 2, 2014 22:12
Generators + prototypes
function* G() { yield this.x; }
G.prototype = { x: 5 };
console.log([...G()]);
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const ALLOCATIONS_TREE_INDENTATION = 16; // px
const AUTO_EXPAND_DEPTH = 3; // depth
Cu.import("resource://gre/modules/Task.jsm")
let runTaskWhileValid = (isValid, generator) => {
Task.spawn(function* () {
const g = generator();
let value, resolved;
let done = false;
while (!done) {
try {
({ value, done }) = g.next(resolved);
#!/usr/sbin/dtrace -Fs
pid$target::main*heap*Rooted*:entry{ printf("{"); }
pid$target::main*heap*Rooted*:return{ printf("}"); }
pid$target::main*eval*:entry{ printf("{"); }
pid$target::main*eval*:return{ printf("}"); }
use std::{mem,ptr};
fn box_map_in_place<T, F>(boxed: Box<T>, f: F) -> Box<T> where F: FnOnce(T) -> T {
unsafe {
let p : *mut T = mem::transmute(boxed);
ptr::write(p, f(ptr::read(p)));
return mem::transmute(p);
}
}
@fitzgen
fitzgen / census.js
Created July 27, 2015 22:14
record allocations for 5s -> take a census
dbg = null;
Components.utils.forceGC();
Components.utils.import("resource://gre/modules/devtools/Loader.jsm");
Debugger = devtools.require("Debugger");
dbg = devtools.require("devtools/server/actors/utils/make-debugger")({
findDebuggees: dbg => dbg.findAllGlobals(),
shouldAddNewGlobalAsDebuggee: () => true
});

Keybase proof

I hereby claim:

  • I am fitzgen on github.
  • I am fitzgen (https://keybase.io/fitzgen) on keybase.
  • I have a public key ASBSc69NuFfQncKT0KhfIXas2FWlq3cAMKHkYHiHr9MkCQo

To claim this, I am signing this object:

@fitzgen
fitzgen / who-calls.py
Last active January 10, 2018 20:40
List the callers of some function in the given `.wasm` file.
#!/usr/bin/env python3
import argparse
import re
import subprocess
DESC = """
List the callers of some function in the given `.wasm` file.
use nannou::noise::{NoiseModule, Seedable};
use nannou::prelude::*;
const WIDTH: u32 = 400;
const NOISE_FACTOR: f32 = 0.75;
const SEGMENT_LENGTH: u32 = 20;
const LINE_MARGIN: u32 = 8;
const LINE_NOISE_RANGE: f32 = LINE_MARGIN as f32 / 3.0;
fn main() {
@fitzgen
fitzgen / cargo-build-hooks-for-wasm.md
Last active November 3, 2019 10:47
Rust and WebAssembly Working Group meeting notes from the 2019 Rust All Hands
Audience WG-wasm + cargo team (+ maybe WG-embedded?)
When TBD (45 minutes)
Where Snow
Meeting Style Discussion and brainstorming

Deliverables

  • Sketch of an eventual ideal we’d like to end up at
  • Sketch of a minimal RFC that is a first step towards that eventual ideal