A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
#!flask/bin/python | |
from flask import Flask, jsonify, abort, request, make_response, url_for | |
from flask_httpauth import HTTPBasicAuth | |
app = Flask(__name__, static_url_path = "") | |
auth = HTTPBasicAuth() | |
@auth.get_password | |
def get_password(username): | |
if username == 'miguel': |
from urllib import quote | |
from string import ascii_lowercase | |
from operator import itemgetter | |
import os | |
import random | |
import requests | |
from datetime import datetime | |
from lib.languages import LANGUAGES, get_language_by_name | |
from lib.utils import format_timedelta |
Created by Christopher Manning
import networkx as nx | |
from collections import defaultdict | |
def get_percolated_cliques(G, k): | |
perc_graph = nx.Graph() | |
cliques = [frozenset(c) for c in nx.find_cliques(G) if len(c) >= k] | |
perc_graph.add_nodes_from(cliques) | |
# First index which nodes are in which cliques | |
membership_dict = defaultdict(list) |
from fabric.api import env, run, sudo, local, put | |
def production(): | |
"""Defines production environment""" | |
env.user = "deploy" | |
env.hosts = ['example.com',] | |
env.base_dir = "/var/www" | |
env.app_name = "app" | |
env.domain_name = "app.example.com" | |
env.domain_path = "%(base_dir)s/%(domain_name)s" % { 'base_dir':env.base_dir, 'domain_name':env.domain_name } |