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 python3.4 | |
# A response to http://nbviewer.ipython.org/url/norvig.com/ipython/Fred%20Buns.ipynb | |
# Read more about it at https://blog.glyphobet.net/essay/2770 | |
import itertools | |
from collections import Counter | |
lock_size = 10 | |
WORDS = set(w.lower() for w in open('words4.txt').read().split()) | |
norvig_improved_wordlock = ['spcmthdlfb', 'leyhwruoai', 'enmlrtacso', 'dsnpaylkte'] |
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
(* | |
Copyright (c) 2013, Richard Emile Sarkis <rich@sarkis.info> | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions are met: | |
1. Redistributions of source code must retain the above copyright notice, this | |
list of conditions and the following disclaimer. | |
2. Redistributions in binary form must reproduce the above copyright notice, |
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 | |
''' | |
The only dependencies for this script are SQLAlchemy 0.9.2, psycopg2 | |
2.5.2, and Postgres 9.3.2, so you should be able to use it for debugging | |
yourselves. Also, those are the exact same versions that are being used | |
in all our other environments, so this problem isn't caused by a slight | |
version mismatch anywhere. | |
This test script connects to the Postgres DB, creates a table with a | |
text column, and then tries to write a Python dictionary object to the |
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 bash | |
# Recommended sort: -k2,2 -k1,1 | |
REMOTE='origin' | |
BRANCHES=$(git branch -r | grep $REMOTE | grep -v 'HEAD -> ') | |
for BRANCH in $BRANCHES ; do | |
git log -n 1 --pretty="%C(yellow)%ci%Creset %x00 %C(cyan)%an%Creset %x00 %C(blue)<%ae>%Creset %x00 %Cred${BRANCH:7}%Creset" $BRANCH | |
done | sort -t '\0' $@ | |
echo `echo $BRANCHES | wc -w` "remote ($REMOTE) branches found." |
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
First shalt thou take out the Holy Space Bar, then shalt thou count | |
to four, no more, no less. Four shall be the number thou shalt count, | |
and the number of the counting shall be four. Five shalt thou not count, | |
neither count thou three, excepting that thou then proceed to four. | |
Tabs are right out. Once the number four, being the fourth number, be | |
reached, then typest thou thy Holy Source Line of Code towards thy | |
editor, which being syntactical in My sight, shall execute. |
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
# Like this: | |
def function( | |
arg, kurz="klein", | |
really_long_argument_name="really long default value", | |
): | |
my_result = do_something( | |
# multiple short arguments on the same line are ok | |
arg, kurz=kurz, | |
really_long_argument_name=do_something_else( | |
one, |
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
First shalt thou take out the Holy Virtualenv. Then, shalt thou | |
install using pip, no more, no less. pip shall be the installer | |
that thou shalt run. easy_install shalt thou not, nor either shalt | |
thou setup.py install, excepting that thou run setup.py via pip. | |
Sudo is right out. Once pip, being the installer you used, be used, | |
then installest thou thy Holy Package of Python Module towards | |
thine Virtualenv, which, being an .egg in my sight, shall install. |
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
Punctual MUNI, which art in transit, | |
Punctual be thy name. | |
Thy arrival come. | |
Thy will be done, in Noe, | |
As it is in Dogpatch. | |
Give us this day our daily transfer. | |
And forgive us our fare evasions, | |
As we forgive them that do not know to step down. | |
And lead us not into Hunter's Point, | |
But deliver us from our stop. |
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
def size_cmp(sizea, sizeb): | |
return cmp(size_value(sizea), size_value(sizeb)) | |
def size_value(size): | |
size = size.upper() | |
return (size.count('L') - size.count('S')) * (size.count('X') + 1) |
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
#!/bin/bash | |
mybasename=`basename $0` | |
if [ ! -e .git/hooks/${mybasename} ] ; then | |
ln -s ../../git-hooks/${mybasename} .git/hooks/${mybasename} | |
fi | |
if [ $3 ] && [ $3 -eq '1' ] ; then | |
# Start from the repository root. | |
pushd ./$(git rev-parse --show-cdup) > /dev/null |
NewerOlder