Skip to content

Instantly share code, notes, and snippets.

View myrepl.mjs
import tty from 'tty'
import { emitKeypressEvents } from 'readline';
let drain;
process.stdout.on('drain', () => { drain() });
const waitForDrain = () => new Promise(r => {drain = r});
function waitForDrainify(func) {
return async (...args) => {
if (!func(...args)) {
await waitForDrain();
View endless-sky emscripten progress
# Starting with Ubuntu 18.04.3 (LTS) x64
# I'm using a local VMwareFusion vm instead of Docker or something because I want to be able to test with a video device.
# New install
# (not shown) make account, enable ssh, add vm to /etc/hosts
ssh vm
apt-get update
sudo apt install git
git clone https://github.com/endless-sky/endless-sky.git
@thomasballinger
thomasballinger / invalidation.js
Created February 5, 2020 03:40
invalidation of Jupyter notebook cells
View invalidation.js
// Find deepest DOM ancestor that does not change on reexecute
const findParentOutputDiv = (el) => {
let candidate = el;
while (candidate) {
candidate = candidate.parentElement
if (candidate.className === 'output') {
return candidate;
}
}
throw Error("parent output div not found");
@thomasballinger
thomasballinger / cell_invalidation.ipynb
Created February 1, 2020 08:15
sketch of noticing that a cell has been removed or reexecuted. Useful for stopping timers, removing event listeners, etc.
View cell_invalidation.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View browserCanvasCtxFill.html
<html>
<body>
<canvas id="canvas1" width="200" height="200"></canvas>
<canvas id="canvas2" width="200" height="200"></canvas>
<canvas id="canvas3" width="200" height="200"></canvas>
<script>
var canvases = [canvas1, canvas2, canvas3]
var fillArgs = [undefined, 'evenodd', 'nonzero']
@thomasballinger
thomasballinger / Main.elm
Last active August 18, 2016 23:54
This type error goes away if I switch the order of lines 54 and 55
View Main.elm
module Main exposing (..)
type alias HasXAndY a =
{ a | x : Float, y : Int }
type alias HasX a =
{ a | x : Float }
View composition.py
from typing import Callable
class A: pass
class B: pass
class C: pass
def composition(aToB: Callable[[A], B],
bToC: Callable[[B], C]) -> Callable[[A], C]:
"""Returns a callable that takes an A and returns a C"""
View gist:f72c2a4ca5dba8d1b38db33458962ef1
a simple remix file format
Files are always UTF-8
a syntax like
episode <episode query> of <podcast url>
play from <time> to <time> [at 2x speed] [at +12 dB]
example:
View justnumbers.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@thomasballinger
thomasballinger / openedByPython.log
Created February 14, 2016 01:45
.py files opened by Python just to start up
View openedByPython.log
tomb@localhost:~$ strace python myPythonScript.py 2>&1 >/dev/null | grep open | grep -v ENOENT | grep -o '".*"' | grep -v '\.pyc'
"/etc/ld.so.cache"
"/lib/x86_64-linux-gnu/libpthread.so.0"
"/lib/x86_64-linux-gnu/libc.so.6"
"/lib/x86_64-linux-gnu/libdl.so.2"
"/lib/x86_64-linux-gnu/libutil.so.1"
"/lib/x86_64-linux-gnu/libz.so.1"
"/lib/x86_64-linux-gnu/libm.so.6"
"/usr/lib/python2.7/site.py"
"/usr/lib/python2.7/os.py"