Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am stesh on github.
  • I am stesh (https://keybase.io/stesh) on keybase.
  • I have a public key ASDB0VqQYaP4igLHS3te3PuHl8rM26fyeyTxo0gq1VjG-Qo

To claim this, I am signing this object:

View gist:9238176
>>> from Queue import PriorityQueue
>>> l = [PriorityQueue()] * 10
>>> [hash(x) for x in l]
[-9223372036579180054, -9223372036579180054, -9223372036579180054, -9223372036579180054, -9223372036579180054, -9223372036579180054, -9223372036579180054, -9223372036579180054, -9223372036579180054, -9223372036579180054]
>>> l = [PriorityQueue() for _ in range(10)]
>>> [hash(x) for x in l]
[275597326, 275597335, 275597371, -9223372036579178388, 275597470, -9223372036579178289, 275597829, -9223372036579177930, 275597928, -9223372036579177831]
@stesh
stesh / gist:8928821
Created Feb 11, 2014
Instead of defaultdict(lambda: defaultdict(lambda: defaultdict(lambda: defaultdict(float))))
View gist:8928821
#!/usr/bin/python
from collections import defaultdict
def nested_defaultdict(f, n):
if n == 1:
return defaultdict(f)
else:
return defaultdict(lambda: nested_defaultdict(f, n-1))
@stesh
stesh / gist:8796219
Created Feb 4, 2014
Overcoming library path silliness in SWI Prolog on OS X
View gist:8796219
#!/bin/sh
app="/Applications/SWI-Prolog.app"
export SWI_HOME_DIR="$app/Contents/swipl"
exec "$app/Contents/MacOS/$(basename $0)" $@
View gist:8698674
#!/bin/bash
[ -z "$1" -o -z "$2" ] && (
cat <<EOF >&2
Usage: $0 <YouTube URL> <filename>
EOF
exit 1
)
URL="$1"
View gist:8221756
<Perl>
use Apache2::ServerUtil;
my @sites = (
"netsoc.tcd.ie",
"issue.netsoc.tcd.ie",
"meta.netsoc.tcd.ie",
"cubewww.cube-external.netsoc.tcd.ie",
"meecro.netsoc.tcd.ie",
"phpmyadmin.netsoc.tcd.ie",
View gist:7833975
#!/usr/bin/python
from subprocess import call
open = lambda s: call(['open', 'http://%s' % s])
news = [
'bbc.co.uk',
'theguardian.co.uk',
'telegraph.co.uk',
View gist:7784529
#!/bin/bash
export PATH=$PATH:/opt/hadoop/hadoop-0.20.2/bin/
HDFS_PATH="/user/s1317371"
if [ -e $1 ]; then
rm $1
fi
View gist:6926742
>>> detect_language(u'Buenas días')
'spanish'
>>> detect_language(u'Hello there')
'english'
>>> detect_language(u'Guten Tag')
'german'
@stesh
stesh / gist:6874191
Created Oct 7, 2013
Make a new tex document
View gist:6874191
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <title>" > /dev/stderr
exit 1
fi
title="$1"
cat > "$title.tex" <<EOF