Skip to content

Instantly share code, notes, and snippets.

View jamespreed's full-sized avatar

James jamespreed

  • Earth
View GitHub Profile
@toonetown
toonetown / webserver
Last active September 7, 2022 21:11
A quick-and-dirty python web server
#!/usr/bin/python3
import http.server, ssl, argparse, re
from tempfile import mkdtemp
from shutil import rmtree
from contextlib import contextmanager
from os.path import exists, join, abspath
@contextmanager
def TemporaryDirectory():
name = mkdtemp()
@bricef
bricef / monkey.py
Last active May 16, 2024 03:31
Monkey patching of builtins in Python3
# found this from Armin R. on Twitter, what a beautiful gem ;)
import ctypes
from types import MappingProxyType, MethodType
# figure out side of _Py_ssize_t
if hasattr(ctypes.pythonapi, 'Py_InitModule4_64'):
_Py_ssize_t = ctypes.c_int64
else:
_Py_ssize_t = ctypes.c_int