This file contains 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 os | |
from django.http import HttpResponse | |
from django.shortcuts import render | |
from django.utils.functional import wraps | |
from django.utils import simplejson | |
def render_to(view=None, template_name=None): | |
""" |
This file contains 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
Warning: /usr/local/share/python is not needed in PATH. | |
Formerly homebrew put Python scripts you installed via `pip` or `pip3` | |
(or `easy_install`) into that directory above but now it can be removed | |
from your PATH variable. | |
Python scripts will now install into /usr/local/bin. | |
You can delete anything, except 'Extras', from the /usr/local/share/python | |
(and /usr/local/share/python3) dir and install affected Python packages | |
anew with `pip install --upgrade`. |
This file contains 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 unittest | |
from collections import defaultdict | |
class Anagrams(object): | |
def __init__(self): | |
self.words = open('words.txt').readlines() | |
self._load_anagrams() |
This file contains 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 json | |
import unittest | |
from functools import partial | |
from operator import itemgetter | |
from math import sin, cos, sqrt, asin, radians | |
from cStringIO import StringIO | |
def get_records(fl): | |
for line in fl: |
This file contains 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 Config(dict): | |
def __init__(self, root_path, defaults=None): | |
dict.__init__(self, defaults or {}) | |
self.root_path = root_path | |
def from_envvar(self, variable_name, silent=False): | |
"""Loads a configuration from an environment variable pointing to | |
a configuration file. This is basically just a shortcut with nicer | |
error messages for this line of code:: |