- Passport (+I-797B)
- Hoodie
- Bluetooth headphones
- Surface
- 3DS/Vita (+games for 3DS)
- Nexus 9
- Kindle
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
class MyClass(object): | |
def a(self): | |
pass | |
b = [a] | |
# Get the reference to a from the list | |
a = MyClass.b[0] | |
# How do I get the class a was defined on? Is it even possible? | |
# On Python 3, I can use __qualname__. This isn't around on Python 2. |
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 __future__ import unicode_literals | |
from django.core import validators | |
from django.db import models, migrations | |
from django.utils import timezone | |
class Migration(migrations.Migration): | |
dependencies = [ |
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
class X: | |
@staticmethod | |
def y(self): | |
return 3 | |
z = [y] | |
>>> X.y | |
<function X.y at 0x7fc5e5ca90d0> |
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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
class Migration(migrations.Migration): | |
dependencies = [ | |
] |
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 collections import deque | |
def dependency_sort(initial, dependency_func): | |
""" | |
Generic dependency sorting algorithm; supply an initial list of IDs as | |
"initial", and a callable that takes an ID and returns a list of IDs as | |
"dependencies". | |
The resultant list is in order from leaf nodes (no dependencies) to stems. | |
""" |
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 cProfile, pstats, StringIO | |
pr = cProfile.Profile() | |
pr.enable() | |
# ... do something ... | |
pr.disable() | |
s = StringIO.StringIO() | |
sortby = 'cumulative' | |
ps = pstats.Stats(pr, stream=s).sort_stats(sortby) |
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 presents an example of rendering templates in the database. | |
-- DO NOT DO THIS! It's a terrible idea, and just example for my talk | |
-- which you can see at https://speakerdeck.com/andrewgodwin/dubious-database-design | |
CREATE EXTENSION plpythonu; | |
-- Table to store template HTML by name | |
CREATE TABLE templates ( | |
"name" text PRIMARY KEY, | |
"template" text |
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
# Main Nginx router | |
www-router: | |
image: andrewgodwin/www-router | |
environment: | |
www.aeracode.org: aeracode-varnish | |
aeracode.org: redirect:www.aeracode.org | |
www.codingponies.com: codingponies | |
codingponies.com: redirect:www.codingponies.com |
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
#!/usr/bin/python | |
import sys | |
import subprocess | |
import random | |
terms = [t.lower() for t in sys.argv[1:]] | |
if not terms: | |
print "No search terms supplied" | |
sys.exit(1) |
OlderNewer