Skip to content

Instantly share code, notes, and snippets.

@stesh
stesh / gist:8928821
Created February 11, 2014 03:28
Instead of defaultdict(lambda: defaultdict(lambda: defaultdict(lambda: defaultdict(float))))
#!/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:1130885
Created August 7, 2011 22:37
Disable Dashboard on OS X
#!/bin/sh
defaults write com.apple.dashboard mcx-disabled -boolean YES
killall Dock

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:

@stesh
stesh / gist:3012428
Created June 28, 2012 16:44
hacky decorator for class-level properties in python using @classmethods
class classproperty(property):
def __get__(self, cls, inst):
return self.fget.__get__(None, inst)()
class MyClass(object):
numbers = [1,2,3,4,5]
<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",
@stesh
stesh / gist:7833975
Created December 6, 2013 23:33
News
#!/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',
@stesh
stesh / gist:7784529
Created December 4, 2013 09:06
Haderp
#!/bin/bash
export PATH=$PATH:/opt/hadoop/hadoop-0.20.2/bin/
HDFS_PATH="/user/s1317371"
if [ -e $1 ]; then
rm $1
fi
>>> detect_language(u'Buenas días')
'spanish'
>>> detect_language(u'Hello there')
'english'
>>> detect_language(u'Guten Tag')
'german'
@stesh
stesh / gist:6874191
Created October 7, 2013 20:15
Make a new tex document
#!/bin/bash
if [ $# -ne 1 ]; then
echo "Usage: $0 <title>" > /dev/stderr
exit 1
fi
title="$1"
cat > "$title.tex" <<EOF
@stesh
stesh / gist:5864060
Last active December 18, 2015 23:49
'90s roulette
<?$choons = Array(
'-1jPUB7gRyg',
'-EqsbGpUrGk',
'-UajuBAUkBs',
'-mPraO_sJ7A',
'07kpF1MZHOQ',
'19HT0w1uW4A',
'19WUwZYM7bM',
'1Hjnf-vPcL4',
'1tuQ6AkOdGY',