Skip to content

Instantly share code, notes, and snippets.

Hobson Lane hobson

Block or report user

Report or block hobson

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
hobson /
Last active Apr 13, 2018 — forked from DavidYKay/
Simple color balance algorithm using Python 2.7.8 and OpenCV 2.4.10. Ported from:
""" White balance (color balance)
Adjust colors to flatten color histogram peaks and broaden color spectrum for better color contrast.
This is also sometimes called white balancing or probability distribution whitening.
- Color balance algorithm in [OpenCV](
- Ported to python by [DavidYKay](
- Optimized (`O(N^2)` -> `O(N)`) by @alxrsngartn funded in part by NSF grant number 1722399 to [Aira]( (@jmeyers-aira)
- Incorporated into [nlpia]( by @hobson
r"""Faulty positive semidefinite matrix generator
Using a normally distributed random matrix it's pretty
rare that you'll get a semidefinite matrix from the product,
even for low dimensions. For 3 dimensions you have about a 0.001%% yield
>>> pos_semi_matrices = generate_positive_semidefinite_matrices(num_samples=1000)
6.7% were positive semidefinite and not positive definite
45.5% were positive definite
52.2% were positive semidefinite
hobson / BYOB-Learn-to-be-Logical.ipynb
Created Aug 18, 2015
Tech Fest Northwest Workshop -- BYOB: Build Your Own Brain
View BYOB-Learn-to-be-Logical.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"""Attempt to confirm results in paper by Miller and Sanjurjo
["Confused by the Gambler's and Hot Hand Falacy?..."](
Calculate the probability of a streak of length 2 in a coin flip
for a small sequence of attempts ("finite sequence of iid Bernoulli trials").
The fencepost counting issue means you have to ignore one of the flips.
Perhaps this is what causes Miller and Sanjurjo to get 0.4 instead of 0.5.
"the conditional relative frequency... is 0.4 not 0.5"
from random import randint
def walk_level(path, level=1):
"""Like os.walk, but takes `level` kwarg that indicates how deep the recursion will go.
TODO: refactor `level`->`depth`
hobson /
Last active Aug 29, 2015
install 64-bit version of sublime text 2 editor in linux
SHORTCUT="[Desktop Entry]
Name=Sublime Text 2
Comment=Edit text files
hobson /
Last active Aug 29, 2015
Shellshock bash patch and vulnerability tests, manually compiled and installed -- no package manager required
# Manually patch and compile bash for systems like FC16 that don't have shellshock protection
# availalbe through their package managers.
# sudo yum install patch byacc texinfo bison autoconf gettext ncurses-devel
hobson / gist:6802139
Created Oct 2, 2013
`cygcheck -d -c` Cygwin Package Information. Kind of like requirements.txt for Cygwin. This was sufficient for installing pip and `pip install numpy` (compiled/linked with gcc).
View gist:6802139
_autorebase 000013-1
_update-info-dir 00236-1
alternatives 1.3.30c-10
autobuild 5.3-1
autoconf 13-1
autoconf2.1 2.13-12
autoconf2.5 2.69-2
automake 9-1
automake1.13 1.13.4-1
automake1.14 1.14-1
# install pip & virtualenv
# create a virtual environment for your webapp
# install django in the new virtualenv
cd ~/tmp
# go directly to the source to get the latest and greatest
# Install python and some binary-dependencies from source in the user directory
# useful for Django webapps on shared hosts like Dreamhost
# BerkelyDB v 4.8 is supported by python 2.7 but not 5.3
# In addition, the bsddb module was deprecated in Python 2.6 and will be removed in 3.0
# So all this BDB stuff isn't useful, but does no harm
# has patch that can make python 2.7 work with BerkelyDB, if you need it
export LDFLAGS="-L$HOME/local/lib -L$HOME/local/BerkeleyDB.$BDBVE/lib"
You can’t perform that action at this time.