Skip to content

Instantly share code, notes, and snippets.

View sneeu's full-sized avatar
🦀
Hi

John Sutherland sneeu

🦀
Hi
View GitHub Profile
12:21 < samc_> whoever it was that mentioned python's json.tool is amazing
12:24 < mmcnickle> think it was sneeu
12:29 < d0ugal> samc_: sneeu is indeed amazing.
~ » ls -alh `which python`
lrwxr-xr-x 1 john admin 33B 20 Jun 16:36 /usr/local/bin/python -> ../Cellar/python/2.7.3/bin/python
~ » ls -alh `which pip`
-rwxr-xr-x 1 root admin 275B 20 Jun 16:37 /usr/local/bin/pip
~ » ls -alh `which easy_install`
-rwxr-xr-x 1 root admin 323B 17 Mar 00:06 /usr/local/bin/easy_install
from gzip import open as gzip_open
from json import loads
with gzip_open('data/2012-06-20-4.json.gz', 'rb') as f:
content = f.read()
print content.replace("}{", "}\n{")
NAMES = ['John', 'Mat', 'Sam']
TEAMS = """Croatia
Czech Republic
Denmark
England
France
Germany
Greece
~/Desktop » python sweapstakes.py
John: Croatia
Mat: Ukraine
Sam: Russia
John: Germany
Mat: Republic of Ireland
Sam: England
John: Spain
Mat: France
Sam: Czech Republic
def beta_access(request):
if request.method == 'POST':
form = BetaCodeForm(request.POST)
# form validation handles checking for the beta code
if form.is_valid():
request.session['has_beta_access'] = True
return redirect('register')
else:
form = BetaCodeForm(request.POST)
@sneeu
sneeu / circles.py
Created May 2, 2012 11:58 — forked from anonymous/gist:2576078
Generate Hirst–like circles
import datetime
import hashlib
from PIL import Image, ImageDraw
def circles(across, down, radius):
# Scale the image up by 4, to anti-alias.
scale = 4
render_radius = scale * radius
@sneeu
sneeu / TEAMMAT.js
Created April 27, 2012 15:10
TEAMMAT
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;.,:;;;``;;;;;;;;; ;;`;: :;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;: `;;: .' ;;;;. ,: ;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;:;;; `` `';` ';;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;.. .` `;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;, .. `;;;;;;;;;;;;;;
;;;;;;;;;;;;;;'. :;;;;;;;;;;;;;;
@sneeu
sneeu / collections.py
Created March 28, 2012 15:34
The Counter class from Python 2.7.2's collections module.
########################################################################
### Counter
########################################################################
class Counter(dict):
'''Dict subclass for counting hashable items. Sometimes called a bag
or multiset. Elements are stored as dictionary keys and their counts
are stored as dictionary values.
>>> c = Counter('abcdeabcdabcaba') # count elements from a string
@sneeu
sneeu / .gitconfig
Created March 16, 2012 16:12
My git aliases
[alias]
st = status -s
ci = commit
co = checkout
di = diff
br = branch
lg = log --graph --decorate --pretty=oneline --abbrev-commit
lga = log --graph --decorate --pretty=oneline --abbrev-commit --all