View subprocess.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') |
View gist:5879705
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Board(object): | |
""" | |
>>> Board().rows | |
((' ', ' ', ' '), (' ', ' ', ' '), (' ', ' ', ' ')) | |
>>> print Board() | |
| | | |
----- | |
| | | |
----- |
View gist:1336916
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
View vtk2vtp.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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() |
View gist:2991211
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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)) |
View myrepl.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
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 invalidation.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
View server.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
import select | |
import sys | |
clients = [] | |
server = socket.socket() | |
server.bind(('', 8001)) | |
server.listen(1) |
NewerOlder