This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class WebSocketImage extends React.Component { | |
state = { | |
blob: null, | |
}; | |
componentDidMount() { | |
let ws = this.ws = new WebSocket(...); | |
ws.binaryType = 'blob'; | |
ws.onmessage = (event) => { | |
if (this.state.blob) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="application/javascript;version=1.7"> | |
/** | |
* Proxy handler to automatically bind methods. | |
*/ | |
function prebound(obj) { | |
return { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/env python | |
import base64 | |
import hashlib | |
import sys | |
if len(sys.argv) < 2: | |
print >>sys.stderr, "Usage: %s <email address>" % sys.argv[0] | |
sys.exit(1) | |
email = sys.argv[1].lower() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*** Monkey patch vs. evil() ***/ | |
// Consider an object with a method: | |
var Obj = { | |
aMethod: function (arg) { | |
print("Hello " + arg); | |
} | |
}; | |
Obj.aMethod("World!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
NewerOlder