Skip to content

Instantly share code, notes, and snippets.

View fitzgen's full-sized avatar
🙃

Nick Fitzgerald fitzgen

🙃
View GitHub Profile
function wu(thing) {
return new wu.Iterable(thing);
}
// This is known as @@iterator in the ES6 spec. Until it is bound to some
// well-known name or importable, find the @@iterator object by expecting it
// as the first property accessed on a for-of iterable.
//
// This shim is thanks to @andywingo via @gozala.
const iteratorSymbol = (function() {
@fitzgen
fitzgen / go.js
Created August 30, 2013 20:07
http://swannodette.github.io/2013/08/24/es6-generators-and-csp/ ported to SpiderMonkey (at least until ES6 generators are fully supported, which should be within the next month or so)
function go_(machine, step) {
while(!step.done) {
try {
var arr = step(),
state = arr[0],
value = arr[1];
switch (state) {
case "park":
setImmediate(function() { go_(machine, step); });
Components.utils.evalInSandbox("" + function one(fn) { two(fn); },
gDebuggee,
"1.8",
"http://example.com/one.js");
@fitzgen
fitzgen / .mozconfig
Created June 24, 2013 20:12
Basic .mozconfig for hacking on devtools stuff
. $topsrcdir/browser/config/mozconfig
mk_add_options MOZ_MAKE_FLAGS="-s -j8"
ac_add_options --enable-tests
mk_add_options AUTOCLOBBER=1
# Using ccache will speed up incremental builds a ton.
# See https://developer.mozilla.org/en-US/docs/ccache
# ac_add_options --with-ccache=/usr/local/bin/ccache
# Enable if you ever need to use the gecko profiler
Object.defineProperty(window, "sourceMaps", {
get: function () {
delete window.sourceMap;
window.sourceMap = require("source-map");
return window.sourceMap;
}
});
#!/usr/bin/env bash
set -e
function errorAndExit {
echo "Error building, see '.build-error.log' file"
say "Error! Error! Error!"
exit 1
}
_discoverScriptsAndSources: function TA__discoverScriptsAndSources() {
let scriptsAdded = [];
for (let s of this.dbg.findScripts()) {
if (!this._allowSource(s.url)) {
continue;
}
scriptsAdded.push(this._addScript(s));
}
// Load the actor definition.
DebuggerServer.addActors("chrome://global/content/devtools/dbg-profiler-actors.js");
// Define a global-scoped actor
function ProfilerActor(aConnection, aRootActor)
{
this._conn = aConnection;
this._profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
this._started = false;
}
ProfilerActor.prototype = {
@fitzgen
fitzgen / gist:1346669
Created November 8, 2011 00:41 — forked from zpao/gist:1346649
diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp
index afa2125..2afdbb8 100644
--- a/js/src/jsobj.cpp
+++ b/js/src/jsobj.cpp
@@ -7230,7 +7230,6 @@ dumpValue(const Value &v)
fprintf(stderr, "false");
} else if (v.isMagic()) {
fprintf(stderr, "<invalid");
-#ifdef DEBUG
switch (v.whyMagic()) {
# DSL in grammar.coffee
o = (patternString, action, options) ->
patternString = patternString.replace /\s{2,}/g, ' '
return [patternString, '$$ = $1;', options] unless action
action = if match = unwrap.exec action then match[1] else "(#{action}())"
action = action.replace /\bnew /g, '$&yy.'
action = action.replace /\b(?:Block\.wrap|extend)\b/g, 'yy.$&'
action = action.replace /(this\.\$)/g, '@'
console.log action
[patternString, "$$ = #{action};", options]