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 / gist:826adc30d5209d56a692
Last active February 26, 2016 15:22
This makes no sense...
type mismatch: the type `[closure@src/service_router.rs:28:37: 32:6 c2:T]` implements the trait
`for<'r, 'r, 'r> core::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>`,
but the trait
`for<'r, 'r, 'r> core::ops::Fn<(&'r mut iron::request::Request<'r, 'r>,)>`
is required
(expected struct
`iron::request::Request`,
found a different struct
`iron::request::Request`
)
E/Gecko ( 9982): ShmemAndroid::Create():open: Bad address (14)
I/Gecko ( 9982): [GFX1]: [Tiling:Client] Failed to allocate a TextureClient
I/Gecko ( 9982): [GFX1]: ValidateTile failed
.
├── JSONStream
│   ├── LICENSE.APACHE2
│   ├── LICENSE.MIT
│   ├── examples
│   │   └── all_docs.js
│   ├── index.js
│   ├── package.json
│   ├── readme.markdown
│   └── test
@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 / 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 / async-streams-and-promises.js
Last active October 6, 2017 00:04
Returning a Stream in a Promise is an anti-pattern.
/** Method 1. Use a PassThrough stream */
var PassThrough = require('stream').PassThrough;
function myAsyncContent() {
var myContentStream = new PassThrough();
var streamPromise = getAsyncInfo().then(function(info) {
return createStreamFromInfo(info);
});
@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)