Skip to content

Instantly share code, notes, and snippets.

View lonnen's full-sized avatar
:shipit:

Lonnen lonnen

:shipit:
View GitHub Profile
#!/usr/bin/env python
'''
Fetch /toolkit/components/telemetry/Histograms.json for various firefox
branches and store them in the local FS in `validation/[branch]/Histograms.json
'''
import os
import requests
build_map = {
@lonnen
lonnen / matching.py
Last active December 18, 2015 10:39
Produces a stable matching of Mozillians to summit locations based on each Mozillian's preferences over the different summit locations. see: http://xor.lonnen.com/2013/05/04/gale-shapley.html
# !/usr/bin/env python
# coding=utf-8
"""
Produces a stable matching of Mozillians to summit locations based on each
Mozillian's preferences over the different summit locations.
see: http://xor.lonnen.com/2013/05/04/gale-shapley.html
"""
import csv
@lonnen
lonnen / crimsontwins.coffee
Last active December 17, 2015 18:09
working draft of a crimsontwins hubot script powering crimsonguardcommanders in `#bots` drop it in your `/scripts` folder to play along at home
# Description
# push content to your crimsontwins
#
# Dependencies:
# None
#
# Configuration:
# CRIMSONTWINS_HOST
#
# Commands:

I'm playing with Boxen for setting up my new work machine. I really like the idea of setting up open source boxens for working on Mozilla stuff -- this could be very useful for onboarding new contributors, interns, employees, etc. Hack days get significantly easier to manage when people can just pull down a box.

Beyond that I end up managing several machines for my first degree relatives... and there's something appealing about being able to push updates to them magically with boxen + cron. This gets even more attractive if boxen could interface to the app store.

I want to remove editing puppet as a requirement to get what you want. I really like the basic homebrew interface for this and think part of it could be coopted for boxen to remove the need to edit puppet for basic things:

 brew install FORMULA...
 brew uninstall FORMULA...
 brew search [foo]
@lonnen
lonnen / random_string.py
Created April 9, 2013 21:56
generate a random alphanumeric string
import string
from random import sample
length = 16
print ''.join(sample(string.letters + string.digits, length))
@lonnen
lonnen / custom_response.py
Created April 8, 2013 17:49
Returning a custom response code in Flask without subclassing `werkzeug.exceptions.HTTPException`.
from flask import Flask
app = Flask(__name__)
@app.route("/")
def hello():
return ("Failed Dependency", 424, {})
if __name__ == "__main__":
@lonnen
lonnen / idl.js
Created March 19, 2013 18:17
Execute in a console to run the modal version of the Internet Defense League script on the page.
(function(){
window._idl = {};
_idl.variant = "modal";
(function() {
var idl = document.createElement('script');
idl.type = 'text/javascript';
idl.async = true;
idl.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'members.internetdefenseleague.org/include/?url=' + (_idl.url || '') + '&campaign=' + (_idl.campaign || '') + '&variant=' + (_idl.variant || 'banner');
document.getElementsByTagName('body')[0].appendChild(idl);
})()
@lonnen
lonnen / job_ordering.py
Last active December 14, 2015 23:28
Given a hash representing a dependency DAG, with job names and jobs they are dependent on, create a list of job names ordered such that when you iterate over them you are guaranteed to have already visited all the dependencies by the time you inspect a given item. Not particularly efficient, but it shouldn't be a problem for our use case of a fe…
jobs = {
"F": ["E"],
"A": [],
"B": ["A"],
"C": ["A"],
"D": ["B", "C"],
"G": ["A", "D"],
"E": []
}
@lonnen
lonnen / gist:4423380
Created December 31, 2012 22:28
How to implement a custom error code for use with Flask
from werkzeug.exceptions import HTTPException
class FailedDependency(HTTPException):
code = 424
description = "The request failed due to failure of a previous request."
name = "Failed Dependency"
def get_response(self, environment):
resp = super(FailedDependency, self).get_response(environment)
@lonnen
lonnen / init.pp
Last active December 10, 2015 03:58
Exec {
logoutput => "on_failure",
}