Skip to content

Instantly share code, notes, and snippets.

View jbweston's full-sized avatar

Joseph Weston jbweston

View GitHub Profile
@jbweston
jbweston / graphene.svg
Created August 18, 2015 23:36
graphene
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jbweston
jbweston / rng.py
Last active April 25, 2016 21:10
import random
from itertools import accumulate
# random number generator that will not generate the same sequence
# of pseudorandom numbers if the `random` module is used elsewhere.
# the advantage is a 60x speedup
class Rng:
def __init__(self, outputs, probabilities, seed=0):
# test inputs for consistency
if len(outputs) != len(probabilities):
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jbweston
jbweston / jupyterhub-google-sheets.py
Last active January 25, 2018 15:08
A mixin class for Jupyterhub deployments that uses a Google docs spreadsheet for whitelisting
import csv
import subprocess
from tornado import gen, AsyncHTTPClient
@gen.coroutine
def get_whitelist(sheets_url, usernames_field):
# Get CSV from sheet
client = AsyncHTTPClient()
@jbweston
jbweston / interface.py
Last active March 15, 2018 09:31
Abstract Interfaces in Python
import abc
class Interface(abc.ABC):
__slots__ = ()
@classmethod
def __subclasshook__(cls, obj):
if cls is not Interface:
return NotImplemented
@jbweston
jbweston / libdmtx-test.sh
Created November 15, 2018 14:46
Test for compatibility between pylibdmtx and libdmtx
#!/bin/bash
export LD_LIBRARY_PATH=$(pwd)/.libs
make -j8 2>/dev/null >/dev/null
if [ $? != 0 ]; then
exit 125
fi
python 2>/dev/null << EOF

Keybase proof

I hereby claim:

  • I am jbweston on github.
  • I am jbweston (https://keybase.io/jbweston) on keybase.
  • I have a public key whose fingerprint is E836 17D2 3FAF 6B96 DCA3 81B4 0982 D739 D2C4 E1B6

To claim this, I am signing this object:

@jbweston
jbweston / raise-on-unknown.patch
Created March 29, 2021 15:30
Get miniver to raise UnknownVersion when it encounters an unknown veresion
@@ -10,6 +10,11 @@ from setuptools.command.sdist import sdist as sdist_orig
Version = namedtuple("Version", ("release", "dev", "labels"))
+
+class UnknownVersion(RuntimeError):
+ pass
+
+
# No public API