Skip to content

Instantly share code, notes, and snippets.

@jedp
jedp / gist:4062623
Last active October 12, 2015 17:37
try server and mercurial queues
# push to try
hg qref --message "try: -b do -p all -u all -t none"
hg push -f try
# refresh with name and bug info
hg phase -f --draft qbase:tip # if it complains about immutable revisions
hg qrefresh -m "Bug 876543 - blah blah blah. r=pqdbach"
@jedp
jedp / gist:3922102
Created October 20, 2012 05:12
Blog Draft - Tracking Down Memory Leaks in Node.JS

#Tracking Down Memory Leaks in Node.JS

Last month, the Identity team at Mozilla delivered the first beta release of Persona. Getting to this point, we built a lot of tools to help us achieve the scalability and performance that Persona demands, and to help us with problems ranging from debugging to localization to dependency management and more. As a team, we hope our solutions will be useful to other developers, and of course we hope that other developers will help us make our tools even better. So we're kicking off a series of blog posts in which we're going to talk about

@jedp
jedp / go-mode-load.el
Created October 19, 2012 05:17
Emacs go mode
;;; go-mode-load.el --- Major mode for the Go programming language
;;; Original source: http://golang.org/misc/emacs/go-mode-load.el
;;; Commentary:
;; To install go-mode, add the following lines to your .emacs file:
;; (add-to-list 'load-path "PATH CONTAINING go-mode-load.el" t)
;; (require 'go-mode-load)
;; After this, go-mode will be used for files ending in '.go'.
@jedp
jedp / gist:3778932
Created September 24, 2012 22:50
B2G repo setup and build quickstart

B2G Quickstart for Payments and Identity

Before you begin: You want to do this on a Mac. I have been using Linux for months, and unresolved redraw issues (white screen of death) are killing me. Mac works great. Use OSX.

This sets you up to make two separate targets:

  • One for a desktop [simulator] [1]
  • One for the Unagi [device] [2]

These are the moving parts:

  • [mozilla-inbound repo] [3] clone (hg)
@jedp
jedp / example.js
Created August 1, 2012 20:45
Node.JS CouchDB paginator
var cradle = require('cradle');
// change as necessary
var host = '127.0.0.1';
var port = 5984;
var dbname = 'foo';
// setup cradle db and paginator
var conn = new (cradle.Connection)(host, port);
var db = conn.database(dbname);
@jedp
jedp / gist:3166329
Created July 23, 2012 21:25
Hash to small integer
// Hash 'string' to a small number (digits default: 6)
function hash(string, digits) {
digits = digits || 6;
var m = Math.pow(10, digits+1) - 1;
var phi = Math.pow(10, digits) / 2 - 1;
var n = 0;
for (var i = 0; i < string.length; i++) {
n = (n + phi * string.charCodeAt(i)) % m;
}
return n.toString();
@jedp
jedp / gist:3166317
Created July 23, 2012 21:22
Logging module, file, and line number of caller
var util = require('util');
const STACK_FRAME_RE = new RegExp(/at ((\S+)\s)?\(?([^:]+):(\d+):(\d+)/);
const THIS_FILE = __filename.split('/')[__filename.split('/').length - 1];
var Logger = module.exports = function Logger() {
// I like pie
};
Logger.prototype = {
@jedp
jedp / reducers.js
Created July 2, 2012 03:42 — forked from Gozala/reducers.js
Experimenting with clojure reducers
Array.prototype.reduce = this.ArrayReduce || Array.prototype.reduce
var console = window.console
var global = this
function assert(actual, expected) {
if (arguments.length < 2 && actual)
return actual
if (actual === expected)
return actual
if (JSON.stringify(actual) == JSON.stringify(expected))
return JSON.stringify(actual)
@jedp
jedp / gist:3005816
Created June 27, 2012 18:18
postMessage() security review checklist

Security-Reviewing Uses of postMessage()

The postMessage() API is an HTML5 extension that permits string message-passing between frames that don't share the same origin. It is available in all modern browsers. It is not supported in IE6 and IE7.

postMessage is generally considered very secure as long as the programmer is careful to check the origin and source of an arriving

@jedp
jedp / gist:2956223
Created June 19, 2012 20:03
libuv simple async
#include <v8.h>
#include <v8-profiler.h>
#include <node.h>
#include <uv.h>
#include <sys/time.h>
#include <iostream>
using namespace node;
using namespace v8;
using namespace std;