Skip to content

Instantly share code, notes, and snippets.

Ian Bicking ianb

Block or report user

Report or block ianb

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View jupyter-weave.js
// An extension to evaluate `${Python}` in Markdown cells
define(["base/js/namespace"], function(Jupyter) {
function load_ipython_extension() {
Jupyter.notebook.events.on("rendered.MarkdownCell", (event, data) => {
let cell = data.cell;
renderCell(cell);
});
Jupyter.notebook.events.on("kernel_ready.Kernel", () => {
View test-16.diff
diff --git a/browser/extensions/screenshots/bootstrap.js b/browser/extensions/screenshots/bootstrap.js
index d252588..800ad66 100644
--- a/browser/extensions/screenshots/bootstrap.js
+++ b/browser/extensions/screenshots/bootstrap.js
@@ -11,12 +11,18 @@ const { interfaces: Ci, utils: Cu } = Components;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "AppConstants",
+ "resource://gre/modules/AppConstants.jsm");
View make-static-html.js
/** This file is used to turn the document into static HTML with no scripts
As a framescript this can access the document and its iframes without
cross-domain permission issues.
documentStaticData() is the main function that collects all the information
and returns a JSONable object.
This script also contains the infrastructure for communicating as a framescript
with lib/framescripter
View example.js
function onButtonClicked() {
console.log("yay, click!");
}
document.getElementById("button").addEventListener("click", function () {
TogetherJS.send({type: "myButtonClick"});
onButtonClicked();
}, false);
TogetherJS.hub.on("myButtonClick", function () {
View package-count
$ cat packages.txt
minimock
formencode
sqlobject
tempita
initools
zptkit
pastewebkit
deliverance
httpencode
@ianb
ianb / tjs-bookmarklet
Created Oct 25, 2013
TogetherJS bookmarklet
View tjs-bookmarklet
javascript:(function%20()%20%7Bwindow._TogetherJSBookmarklet%20%3D%20true%3Bs%3Ddocument.createElement('script')%3Bs.src%3D%22https%3A%2F%2Ftogetherjs.com%2Ftogetherjs.js%22%3Bdocument.head.appendChild(s)%3B%7D)()%3Bvoid(0)
View detector.py
class Detector:
def __init__(self):
self.detectors = []
self._pending = []
self.matches = []
def feed_input(self, obj, index):
"""After instantiating Detector and adding individual detector coroutines, call
feed_input(obj, index) over and over until you are done. You should end with a
sentinal obj. Look in .matches to get the results.
@ianb
ianb / assert.js
Last active Dec 16, 2015
assert() for Javascript
View assert.js
function AssertionError(msg) {
this.message = msg || "";
this.name = "AssertionError";
}
AssertionError.prototype = Error.prototype;
/* Call assert(cond, description1, ...)
An AssertionError will be thrown if the cond is false. All parameters will be logged to the console,
and be part of the error.
*/
View promisizer.js
function promisize(func) {
return function () {
try {
var promise = func.apply(this, arguments);
if (! promise.isThenable) {
var result = new Resolver();
result.resolve(promise);
return result.promise;
} else {
return promise;
@ianb
ianb / new.js
Created Jan 28, 2013
Thinking about what the new operator really looks like, if you treat Object.create() as the more fundamental operation
View new.js
function new_(constructor /* arguments to constructor */) {
var args = Array.prototype.slice.call(arguments, 1);
var obj = Object.create(constructor.prototype);
var result = constructor.apply(obj, args);
if (result === undefined) {
result = obj;
}
return result;
}
You can’t perform that action at this time.