Skip to content

Instantly share code, notes, and snippets.

View gregglind's full-sized avatar

Gregg Lind gregglind

View GitHub Profile
@gregglind
gregglind / shield-format.parquet.txt
Last active January 24, 2017 23:20
Parquet Schemas For Shield Studies
message shield-study-addon {
required int64 version;
required binary study_name (UTF8);
required binary branch (UTF8);
required binary addon_version (UTF8);
required binary shield_version (UTF8);
optional boolean testing;
required group data {
required binary type (UTF8);
required group attributes (MAP) {
@gregglind
gregglind / talk, log.
Created January 17, 2017 20:36
jetpack (addon-sdk frames) don't share constructors, busting instanceOf
20:20 < gregglind> Sorry to ask Jetpack questions :(
20:20 < gregglind> is `instanceof Object` ... reliable or funky across modules in jetpacks?
20:21 < gregglind> i have observed that Error is funky as well.
20:21 < gregglind> I am not even sure how to phrase it.
20:25 < The_8472> each module has its own global, including separate instances of the primordial types such as Object, Error, etc.
20:26 < The_8472> (foo !== null && typeof foo === "object") to check for objectness
20:27 < The_8472> or you can export the constructor function from that module
20:28 < The_8472> then foo instanceof MyClass should work. i think.
20:29 < gregglind> The_8472: different frames :)
20:29 < The_8472> yes, same thing
@gregglind
gregglind / ateam_prefs_general.json
Last active December 30, 2016 17:19
Simple script and output for converting user prefs to json
{
"browser.console.showInPanel": true,
"browser.dom.window.dump.enabled": true,
"browser.firstrun.show.localepicker": false,
"browser.firstrun.show.uidiscovery": false,
"browser.startup.page": 0,
"browser.search.suggest.timeout": 10000,
"browser.ui.layout.tablet": 0,
"dom.allow_scripts_to_close_windows": true,
"dom.disable_open_during_load": false,
// studyInfo.js
"use strict";
const prefSvc = require("sdk/preferences/service");
const OURPREF = 'some.newfeature.design';
const name = require("sdk/self").id;
const duration = 7;
const surveyUrl = "https://qsurvey.mozilla.com/s3/Shield-Study-Example-Survey";
const variations = {
'strong': () => {prefSvc.set(OURPREF, 'strong')},
@gregglind
gregglind / index.js
Last active August 24, 2016 13:51
Shield Study Example: Simple Pref Flipping Study
"use strict";
const self = require("sdk/self");
const { when: unload } = require("sdk/system/unload");
const shield = require("shield-studies-addon-utils");
const prefSvc = require("sdk/preferences/service");
/* shield info */
const OURPREF = 'some.newfeature.design';
const variations = {
'strong': () => {prefSvc.set(OURPREF, 'strong')},
@gregglind
gregglind / sessionRestoreNotes.md
Last active August 23, 2016 15:49
Notes on Session Restore, and what feels off

Better UI Feel for session restore

Strategic landscape :

Firefox has been trying to avoid restarting for a long time. With e10s, not-quite-silent updates that may longer be possible. Given that phone apps restart without warning, people may be more used to restarting. Having a better (easier, cleaner, quieter) restart and restore flow might simplify other technical choices.

Thus, is may be in our strategic interest to:

  1. Make restart less painful
  2. Assume restarts / restores happen
@gregglind
gregglind / addon-lint-consumer.js
Created July 27, 2016 19:34
Takes output from `addon-lint`, and errors or not based on a user-specified set of ignore rules.
#!/usr/bin/env node
/*
usage:
```
jpm xpi # makes myaddon.xpi
npm install addon-linter
./node_modules/.bin/addon-linter myaddon.xpi | node addon-lint-consumer.js
```
@gregglind
gregglind / git-in-bash.md
Created July 27, 2016 14:56
Git'ing Better All The Time

Making Git Awesome In Your CLI

Ye Olde School - Improve it with Bash

  1. Git info in your prompt

    brew install vcprompt

    vcprompt original link

@gregglind
gregglind / loops.js
Last active July 27, 2016 02:20
Loop Party, You are invited.
/* some wild-ass loop parties */
var x = 6;
var numberArray = [
1, /* 0th item, b/c arrays *index* from 0 */
2, /* 1st item */
3 /* 2nd item */
];
@gregglind
gregglind / cors.js
Last active March 9, 2016 17:48
failed cors
log = console.log.bind(console);
error = console.error.bind(console);
function cors1 (url, method, data) {
return new Promise(function (resolve, reject) {
var createCORSRequest = function(method, url) {
var xhr = new XMLHttpRequest();
if ("withCredentials" in xhr) {
// Most browsers.
xhr.open(method, url, true);
} else if (typeof XDomainRequest != "undefined") {