Skip to content

Instantly share code, notes, and snippets.

View thomasballinger's full-sized avatar

Tom Ballinger thomasballinger

View GitHub Profile
@thomasballinger
thomasballinger / dom.diff
Created November 5, 2024 02:34
React commits just this at some point, that's when we lose the CSS
--- stuff.html 2024-11-04 18:33:00
+++ right.html 2024-11-04 17:09:24
@@ -1,15 +1,21 @@
-<head></head>
+<head>
+ <meta name="tsr-meta" />
+ <title>TanStack Start Starter</title>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <link rel="stylesheet" href="/_build/app/styles/app.css" />
--- left.html 2024-11-04 16:36:50
+++ right.html 2024-11-04 16:36:50
@@ -1,79 +1,22 @@
<head>
<meta name="tsr-meta" />
<title>TanStack Start Starter</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="/_build/app/styles/app.css" />
- <script class="tsr-once">
@thomasballinger
thomasballinger / html.diff
Last active November 4, 2024 20:17
pre/post SSR diff
9,43d8
< <script class="tsr-once">
< __TSR__ = {
< matches: [],
< streamedValues: {},
< initMatch: (index) => {
< Object.entries(__TSR__.matches[index].extracted).forEach(([id, ex]) => {
< if (ex.type === "stream") {
< let controller;
< ex.value = new ReadableStream({
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();
# 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
// 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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<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
module Main exposing (..)
type alias HasXAndY a =
{ a | x : Float, y : Int }
type alias HasX a =
{ a | x : Float }
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"""