Skip to content

Instantly share code, notes, and snippets.

View mdboom's full-sized avatar

Michael Droettboom mdboom

View GitHub Profile
<html>
<head>
<meta charset="UTF-8">
<title>new notebook - iodide</title>
<link rel="stylesheet" type="text/css" href="iodide.dev.css">
</head>
<body>
<script id="jsmd" type="text/jsmd">
%% meta
{
@mdboom
mdboom / syncdom.html
Created May 2, 2018 16:04
Demo Iodide notebook with a probably terrible idea for "synchronous" DOM updating
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>untitled - iodide</title>
<link rel="stylesheet" type="text/css" href="iodide.dev.css">
</head>
<body>
<script id="jsmd" type="text/jsmd">
%% meta
@mdboom
mdboom / bootstrap.js
Last active July 27, 2018 15:36
Demonstrate interaction between TextDecoder and WebAssembly.instantiate in Chrome
function go() {
function test() {
// This is a distillation of what emscripten's UTF8String does in the case of long strings.
// Commenting out these four lines causes the test to pass.
// It is important that the input string buffer is on the Wasm heap. If it's just a
// Javascript-allocated buffer, everything works fine.
var ptr = example._get_string();
var bytes = new Uint8Array(example.HEAPU8.buffer, ptr, 5);
var jsval = new TextDecoder('utf-8').decode(bytes);
console.log("Got string " + jsval);
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://code.jquery.com/jquery-latest.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet"/>
<script src="https://iodide.io/pyodide-demo/pyodide.js"></script>
</head>
<body>
@mdboom
mdboom / gist:3d5d86e217f8f650f33a85a39cd835cc
Created November 8, 2018 21:27
Import profile of matplotlib within Pyodide
import time: 1000 | 1000 | _hashlib
import time: 0 | 0 | _md5
import time: 0 | 0 | _sha1
import time: 1000 | 1000 | _sha256
import time: 0 | 0 | _sha512
import time: 0 | 0 | _blake2
import time: 1000 | 1000 | _sha3
import time: 5000 | 8000 | hashlib
import time: 0 | 0 | _bisect
import time: 4000 | 4000 | bisect
@mdboom
mdboom / evaluate-php.js
Last active March 18, 2019 12:36 — forked from filips123/evaluate-php.js
Iodide with PHP
const PHP_MODULE = 'https://oraoto.github.io/pib/php.js'
const loadResource = url => new Promise((resolve) => {
const head = document.getElementsByTagName('head')[0]
const theScript = document.createElement('script')
console.log("window.PHP " + window.PHP)
theScript.src = url;
theScript.onload = () => {
@mdboom
mdboom / mermaid-plugin.json
Created June 7, 2019 17:15
Mermaid plugin for Iodide example
{
"languageId": "mermaid",
"displayName": "Mermaid diagram",
"url": "https://gist.githubusercontent.com/wlach/2fbe93ee57b0acb87bf69cdb1488ccd0/raw/044d75169be301aa0116e1e64c6921ce9f3ec855/mermaidplugin.js",
"module": "mermaidPlugin",
"evaluator": "evaluateMermaid",
"pluginType": "language"
}
# Look for problematic ordering of events in Glean events pings
import codecs
import gzip
import json
import sys
results = json.load(open(sys.argv[-1], "r"))
total = 0
@mdboom
mdboom / kotlin_to_java.py
Created November 8, 2019 18:47
Convert Glean Kotlin code examples to Java code examples
#!/bin/env python
import sys
import inflection
content = sys.stdin.read()
content = content.replace("Kotlin", "Java")
kotlin_lines = content.split("\n")
@mdboom
mdboom / size_of_import.py
Created November 12, 2019 19:05
Measures the amount of code loaded by "import X"
import os
import sys
original_modules = dict(sys.modules)
import pandas
sizes = {}
total = 0
files = set()