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({
@thomasballinger
thomasballinger / subprocess.py
Created December 15, 2013 23:26
Using a pseudo-terminal to interact with interactive Python in a subprocess
from subprocess import Popen, PIPE
import pty
import os
from select import select
import sys
import tty
master, slave = pty.openpty()
p = Popen(['python'], stdin=slave, stdout=PIPE, stderr=PIPE)
pin = os.fdopen(master, 'w')
@thomasballinger
thomasballinger / gist:5879705
Created June 27, 2013 19:44
Iterative and recursive minimax
class Board(object):
"""
>>> Board().rows
((' ', ' ', ' '), (' ', ' ', ' '), (' ', ' ', ' '))
>>> print Board()
| |
-----
| |
-----
@thomasballinger
thomasballinger / gist:1336916
Created November 3, 2011 16:13
nifti2nrrd dwi conversion
#!/usr/bin/env python
#TODO
#1) Add measurement frame
#2) Save data part of nifti to its own file, and point to it in 'data file' field
import nibabel as nib
import sys
@thomasballinger
thomasballinger / vtk2vtp.py
Created October 12, 2011 15:10
vtk2vtp.py
#!/usr/bin/env python
"""File format conversion
category: vtk, file conversion, tomb"""
import os, sys
import vtk
def vtk2vtp(invtkfile, outvtpfile, binary=False):
"""What it says on the label"""
reader = vtk.vtkPolyDataReader()
#!/usr/bin/env python
"""An externally-accessible toy server whith several response strategies"""
import socket
import sys
from multiprocessing import Pool
def web_scrape(site):
s = socket.socket()
s.connect((site, 1333))
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