Skip to content

Instantly share code, notes, and snippets.

View jdrake's full-sized avatar

Jonathan Drake jdrake

  • Narrative Science
  • Seattle, WA
View GitHub Profile
[Unit]
Description=uWSGI
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi /opt/ns/app/uwsgi.yml
RuntimeDirectory=/opt/ns/app
Restart=always
KillSignal=SIGQUIT
Type=notify
uwsgi:
master: 1
processes: 16
need-app: 1
buffer-size: 32768
post-buffering: 8192
chmod-socket: 660
harakiri: 60
reload-on-rss: 1024
umask: 002
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello, World!'
@app.route('/health')
def health():
@jdrake
jdrake / example_of_table.py
Created January 17, 2012 23:09
Example of table()
>> print table(
sorted(team.special_events.values(), key=lambda e:(e.period, e.time)),
["period","time","type","player_in","player_out"],
{
'period':{'align':'rjust'},
'time':{'format':toTime, 'align':'rjust'}
}
)
PERIOD TIME TYPE PLAYER_IN PLAYER_OUT
@jdrake
jdrake / print_table_to_stdout.py
Created January 17, 2012 22:51
Print list of objects to stdout
from collections import Counter
def table(data, fields, user_config={}, debug=False):
"""Nicely formatted table, for printing to stdout
Required:
@param data: list, objects instances
@param fields: list, object properties/fields to display
Optional:
@jdrake
jdrake / py-list-comprehension
Created December 15, 2011 17:58
Python list comprehension
run_list = [run
for run in run_list
if playermatch_id in [player.id for player in run.players]]