Skip to content

Instantly share code, notes, and snippets.

View thomcc's full-sized avatar
🦀

Thom Chiovoloni thomcc

🦀
View GitHub Profile
#![feature(test)]
#![recursion_limit = "1024"]
#![allow(dead_code)]
#![feature(stdsimd)]
extern crate test;
extern crate rand;
// Defines a little benchmarking DSL macro. If you've been linked here, it's safe to ignore.
#[macro_use]
// Coord is a way of storing a 2d integer vector (e.g. vec2i or similar) as a
// value type by packing it into a number. It will do what you want in a Map or
// Set, you can compare them for equality, and it should be free of alloctions
// (at least in Spidermonkey and V8, but probably anywhere else too).
//
// The downside is that it's a pain to debug, use, and it has ugly syntax. It's
// type safe (in typescript) tho.
//
// Each component is stored as a 15 bit (signed, 2's complement) integer. These
ChromeUtils.import("resource://gre/modules/SyncedBookmarksMirror.jsm");
async function addBookmarks() {
let buf = await SyncedBookmarksMirror.open({
path: ":memory:",
recordTelemetryEvent() {},
});
let menu = {
id: "menu",
@thomcc
thomcc / gist:a47f472bbd8a88b1e7763b59a8b71ece
Created March 6, 2018 23:03
git-sizer on mozilla-central via git-cinnabar
Processing blobs: 2528058
Processing trees: 7712410
Processing commits: 920603
Matching commits to trees: 920603
Processing annotated tags: 0
Processing references: 165
| Name | Value | Level of concern |
| ---------------------------- | --------- | ------------------------------ |
| Overall repository size | | |
| * Commits | | |
#include <string>
#include <vector>
#include <cstddef>
#include <memory>
#include <iostream>
#include <cassert>
#include <stdexcept>
struct XmlNode {
struct Attribute {
// Run me from a scratchpad.
(function() {
ChromeUtils.import("resource://gre/modules/SyncedBookmarksMirror.jsm");
ChromeUtils.import("resource://services-sync/util.js");
const RECORDS_TO_INSERT = 10000;
function randUpTo(n) {
return Math.floor(Math.random() * n);
}

Steps to faster git on mac.

  1. Update to git 2.16

  2. Setup file monitoring with hgwatchman

    1. Run
    $ brew install watchman
    $ cd /path/to/mozilla-central
    

$ watchman watch-project .

(function() {
Cu.import("resource://gre/modules/PlacesUtils.jsm");
Cu.import("resource://gre/modules/PlacesSyncUtils.jsm");
Cu.import("resource://services-common/async.js");
Cu.import("resource://gre/modules/Log.jsm");
Cu.import("resource://services-sync/engines.js");
Cu.import("resource://services-sync/engines/bookmarks.js");
Cu.import("resource://services-sync/service.js");
Cu.import("resource://services-sync/util.js");
@thomcc
thomcc / profcall.js
Created March 3, 2016 10:48
autoprofiling function.prototype.call. works in node, not in browser (in node you need to use process.hrtime though)
var oldCall = Function.prototype.call;
var profileTable = Object.create(null);
Function.prototype.call = function call() {
if (this === oldCall || this === call || this === Function.prototype.apply || this === performance.now) {
return oldCall.apply(this, arguments);
}
var profEntry = profileTable[this.name];
if (!profEntry) {
profEntry = { calls: 0, time: 0 };
profileTable[this.name] = profEntry;
@thomcc
thomcc / resumable_random.dart
Last active August 29, 2015 14:06
Serializable RNG
// This is free and unencumbered software released into the public domain.
// For more information, please refer to <http://unlicense.org/>
import 'dart:math' as math;
/// A class used to store the state of a [ResumableRandom].
class RngState {
final int originalSeed, a, b, c, d;
RngState(this.originalSeed, this.a, this.b, this.c, this.d);
}