This file contains hidden or 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
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. |
This file contains hidden or 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
~ » 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 |
This file contains hidden or 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
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{") |
This file contains hidden or 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
NAMES = ['John', 'Mat', 'Sam'] | |
TEAMS = """Croatia | |
Czech Republic | |
Denmark | |
England | |
France | |
Germany | |
Greece |
This file contains hidden or 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
~/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 |
This file contains hidden or 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 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) |
This file contains hidden or 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
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 |
This file contains hidden or 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
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;.,:;;;``;;;;;;;;; ;;`;: :;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;: `;;: .' ;;;;. ,: ;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;:;;; `` `';` ';;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;.. .` `;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;, .. `;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;'. :;;;;;;;;;;;;;; |
This file contains hidden or 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
######################################################################## | |
### 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 |
This file contains hidden or 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
[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 |