Skip to content

Instantly share code, notes, and snippets.

@rwarren
rwarren / hacky_thread_pool.py
Created October 18, 2016 16:21
Basic thread pool example whipped up quickly for #python discussion. Don't judge me.
import threading
import Queue
import time
QUEUE_TIMEOUT_s = 0.1
WORKER_COUNT = 200 # play with this! If switching to multiprocessing, use ncores+1 (or 2)
NUM_TASKS = 1000
SLOW_ADD_TIME_s = 0.1
done_event = threading.Event()
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rwarren
rwarren / gist:e8005fe380e529ce297d
Created February 18, 2016 20:38
Mercurial .bashrc mod for prompt showing bookmark/rev and incoming state
# add hg info to the prompt if it exists...
in_hg() {
# returns 0 if in a hg repo, 1 if not
d=$PWD
# Check up the path (using bash string operators) looking for .hg
while [ "${d}" != "" ]; do
if [ -d "${d}/.hg" ]; then
HG_DIR=$d/.hg
return 0
fi
@rwarren
rwarren / tc_remaster.sh
Last active December 18, 2015 19:49
handy tinycore remastering script from coreplayer2 (see http://goo.gl/c6uQh). Takes the tedium out of it.
#!/bin/sh
. /etc/init.d/tc-functions
# Use this script to extract and re-package core.gz, core64.gz or corepure64.gz
#
# Note
# When repackaging a x86_64 core, use this script on same type system (core64 or corepure64)
#
# How to..
@rwarren
rwarren / sys_displayhook
Created March 7, 2014 20:54
python displayhook for pprint by default
#lifted from http://stackoverflow.com/questions/17248383/pretty-print-by-default-in-python-repl
import pprint
import sys
orig_displayhook = sys.displayhook
def myhook(value):
if value != None:
__builtins__._ = value