Skip to content

Instantly share code, notes, and snippets.

View samgiles's full-sized avatar
🗺️

Sam Giles samgiles

🗺️
  • Citymapper
  • London
View GitHub Profile
@samgiles
samgiles / buster.js
Created December 11, 2012 14:19
Buster JS TestCase
var config = module.exports;
config["The Tests"] = {
env: "browser",
rootPath: ".",
tests:[
"*-test.js"
]
};
@samgiles
samgiles / gist:2e32e0d86a15fd3f0790
Last active October 8, 2015 00:53
gdb wrong breakpoint?
Breakpoint 1, mozilla::dom::BlobParent::IDTableEntry::GetOrCreateInternal (aID=..., aProcessID=aProcessID@entry=0, aBlobImpl=aBlobImpl@entry=0x8c50ccf0,
aMayCreate=aMayCreate@entry=true, aMayGet=aMayGet@entry=true, aIgnoreProcessID=false) at /Users/sam/code/mozilla/mozilla-central/dom/ipc/Blob.cpp:*4549*
4549 entry = new IDTableEntry(aID, aProcessID, aBlobImpl);
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x82ab12d4 in mozilla::dom::BlobParent::IDTableEntry::GetOrCreateInternal(nsID const&, int, mozilla::dom::BlobImpl*, bool, bool, bool)
at /Users/sam/code/mozilla/mozilla-central/dom/ipc/Blob.cpp:*4544*
@samgiles
samgiles / .travis.yml
Last active September 22, 2015 14:55 — forked from triblondon/.travis.yml
sudo: false
language: node_js
node_js:
- "0.10"
before_install:
- npm install -g Financial-Times/origami-build-tools#node-0.10
- obt install
script:
- obt test
- obt verify
@samgiles
samgiles / addfxmob.js
Created September 17, 2015 20:27
Polyfill Service config automaticificationifier!
// vim: set ts=4 sw=4 tw=78 noet :
const latest = require('./lib/sources').latest;
const path = require('path');
const fs = require('fs');
latest.listPolyfills().then(function(polyfills) {
return Promise.all(polyfills.map(function(polyfill) {
return latest.getPolyfill(polyfill).then(function(polyfill) {
const config = path.join(polyfill.baseDir, 'config.json');
@samgiles
samgiles / gist:54f11668dc7cdb697500
Created September 17, 2015 09:48
b2gdroid jimdb start error.
Launching org.mozilla.b2gdroid...
Starting: Intent { cmp=org.mozilla.b2gdroid/.App }
Error type 3
Error: Activity class {org.mozilla.b2gdroid/org.mozilla.b2gdroid.App} does not exist.
/Users/sam/code/c/jimdb-arm/bin/../utils/gdbinit:136: Error in sourced command file:
Error while launching org.mozilla.b2gdroid.
@samgiles
samgiles / zonefile.js
Created August 6, 2015 14:25
Parse Zone File to generate a list of all domains defined within it.
// Polyfill
// String.prototype.includes
String.prototype.includes = function (string, index) {
if (typeof string === 'object' && string instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression");
return this.indexOf(string, index) !== -1;
};
// Array.prototype.includes
Array.prototype.includes = function includes(searchElement /*, fromIndex*/ ) {'use strict';
var O = Object(this);
@samgiles
samgiles / timer.js
Created March 30, 2015 15:54
hrtimer.js
// Usage:
//
// ```JS
// var timer = new Timer();
//
// timer.start("javascript");
//
// compile(function(e, callback) {
// var timeInSecs = timer.end("javascript");
// console.log("It took: ", timeInSecs, "s");
@samgiles
samgiles / api-style.js
Last active August 29, 2015 14:17
API style?
// THIS?
// #wrap(func) - Wrap the function in error handling code
// #wrap(context, func) - Wrap the function in error handling code with additional context
function wrap(context, func) {
if (func === undefined) {
func = context;
context = {};
}
return doThing(context, func)
@samgiles
samgiles / gist:b3fa9da8f6b8d71ca6b2
Created March 13, 2015 14:12
php56w configure flags
--build=x86_64-redhat-linux-gnu --host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64 --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/var/lib --mandir=/usr/share/man --infodir=/usr/share/info --cache-file=../config.cache --with-libdir=lib64 --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --disable-debug --with-pic --disable-rpath --without-pear --with-exec-dir=/usr/bin --with-freetype-dir=/usr --with-png-dir=/usr --with-xpm-dir=/usr --enable-gd-native-ttf --with-t1lib=/usr --without-gdbm --with-jpeg-dir=/usr --with-openssl --with-pcre-regex --with-zlib --with-layout=GNU --with-kerberos --with-libxml-dir=/usr --with-system-tzdata --with-mhash --enable-dtrace --enable-force-cgi-redirect --disable-phpdbg --libdir=/usr/lib64/php --enable-pcntl --enable-fastcgi --without-readline --with-libedit --
@samgiles
samgiles / promisetimeout.js
Last active August 29, 2015 14:16
Tiny Promise timeout implementation
// License MIT;
// Simple Promise timeout implementation, always assume IO is being done by carrier pigeon. Timeout.
function promiseTimeout(promise, timeInMs) {
function promiseTimer(resolve, reject) {
setTimeout(function() { reject(new Error("Promise timed out")); }, timeInMs);
}
return Promise.race([promise, new Promise(promiseTimer)]);
}
// Usage: