Skip to content

Instantly share code, notes, and snippets.

View philikon's full-sized avatar

Philipp Weitershausen philikon

View GitHub Profile
[buildout]
parts = raindrop
find-links = .
[raindrop]
recipe = zc.recipe.egg
eggs =
Twisted
pyOpenSSL
paisley
div.HprMsc div.ii,
table.cf textarea.Ak {
font-family: Monaco,monospace !important;
font-size: 10px !important;
}
"""
Takes CSV locale statistics from addons.mozilla.org and sums numbers
for same languages (e.g. es = es + es_ES + es_MX + ...). Output is
similarly formatted CSV.
"""
import sys
languages = {}
for line in open(sys.argv[-1]):
// Consider a function:
function multiply(a, b) {
return a*b;
}
print(multiply(Math.PI, Math.exp(1)))
// We want to replace it with an "enhanced" version that does some
// stuff before invoking the original, e.g. generate debugging output
/*** Monkey patch vs. evil() ***/
// Consider an object with a method:
var Obj = {
aMethod: function (arg) {
print("Hello " + arg);
}
};
Obj.aMethod("World!");
// Install jQuery in each XUL window namespace
var wu = require("window-utils");
var module = require("securable-module");
var windowtracker = new wu.WindowTracker({
onTrack: function (window) {
var namespace = {
window: window,
document: window.document,
location: window.location,
// https://developer.mozilla.org/en/Setting_up_extension_development_environment
user_pref("javascript.options.showInConsole", true);
user_pref("nglayout.debug.disable_xul_cache", true);
user_pref("browser.dom.window.dump.enabled", true);
user_pref("javascript.options.strict", true);
user_pref("extensions.logging.enabled", true);
user_pref("dom.report_all_js_exceptions", true);
# Start a new chapter by branching the current branch off:
(branch chapter5)$ git checkout -b chapter6
# Make some commits:
(branch chapter6)$ git commit
(branch chapter6)$ git commit
# Oh noez, chapter 3 needs a bugfix
(branch chapter6)$ git checkout chapter3
(branch chapter3)$ git commit -m "Bugfix"
@philikon
philikon / wtf8.py
Created February 8, 2011 08:22
WTF-8 codec for Python
# wtf8.py
import codecs
def encode(input, errors='strict'):
return input.encode('utf-8', errors).decode('latin-1', errors).encode('utf-8', errors), len(input)
def decode(input, errors='strict'):
return input.decode('utf-8', errors).encode('latin-1', errors).decode('utf-8', errors), len(input)
class StreamWriter(codecs.StreamWriter):
@philikon
philikon / dev-prefs.js
Created May 2, 2011 20:29
Developer prefs
// https://developer.mozilla.org/en/Setting_up_extension_development_environment
user_pref("javascript.options.showInConsole", true);
user_pref("nglayout.debug.disable_xul_cache", true);
user_pref("browser.dom.window.dump.enabled", true);
user_pref("javascript.options.strict", true);
user_pref("extensions.logging.enabled", true);
user_pref("dom.report_all_js_exceptions", true);
user_pref("devtools.errorconsole.enabled", true);
user_pref("services.sync.log.appender.file.logOnSuccess", true);