This document has now been incorporated into the uWSGI documentation:
http://uwsgi-docs.readthedocs.org/en/latest/tutorials/Django_and_nginx.html
Steps with explanations to set up a server using:
| -- show running queries (pre 9.2) | |
| SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
| FROM pg_stat_activity | |
| WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
| ORDER BY query_start desc; | |
| -- show running queries (9.2) | |
| SELECT pid, age(clock_timestamp(), query_start), usename, query | |
| FROM pg_stat_activity | |
| WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |
| # This is an example .wsgi file for serving up localwiki inside of a | |
| # custom virtualenv. | |
| # | |
| ############################################################# | |
| # CHANGE THIS LINE to the absolute path of the virtualenv: | |
| ############################################################# | |
| VIRTUAL_ENV_PATH = '/home/philip/projects/py_envs/localwiki' | |
| import os | |
| import sys |
| #!/usr/bin/env bash | |
| curl https://s3.amazonaws.com/heroku-jvm-buildpack-vi/vim-7.3.tar.gz --output vim.tar.gz | |
| mkdir vim && tar xzvf vim.tar.gz -C vim | |
| export PATH=$PATH:/app/vim/bin |
| #!/usr/bin/python | |
| import inspect | |
| from functools import wraps | |
| from collections import defaultdict | |
| # This time, we'll avoid using a class to hold the namespace. We'll just use | |
| # the class that the functions are being defined in. | |
| # AS A BONUS | |
| # This means that it works for module-level functions, not just methods! |
| import os | |
| import sys | |
| import subprocess | |
| import re | |
| import optparse | |
| import boto | |
| dynamodb_conn = boto.connect_dynamodb(aws_access_key_id='MY_ACCESS_KEY_ID', aws_secret_access_key='MY_SECRET_ACCESS_KEY') | |
| table_name = 'mytable' | |
| dynamodb_table = dynamodb_conn.get_table(table_name) |
| import requests | |
| from requests.auth import OAuth1 | |
| url = u'https://api.twitter.com/1/account/settings.json' | |
| client_key = u'...' | |
| client_secret = u'...' | |
| resource_owner_key = u'...' | |
| resource_owner_secret = u'...' |
| # This module intentionally minimizes dependencies to mitigate breakage risk. | |
| # Subset of Syslog's numerical severity codes (RFC 3164, Table 2) | |
| SEVERITY = | |
| ERROR: 3 | |
| WARN: 4 | |
| INFO: 6 | |
| DEBUG: 7 | |
| # Configuration |
Pushing a certain quantity/mixture of data through a VB guest's NAT interface causes all TCP/UDP connections to fail for a period of time thereafter.
The only way I've been able to reliably reproduce this is to use pip(1) to download a large list of Python packages. After a number of packages have been downloaded (14~20) pip will exit with an HTTP or DNS timeout. Inbound port-forwarded SSH connections will drop with:
Connection to 127.0.0.1 closed by remote host.
This appears most likely to occur with the Intel PRO/1000 MT Desktop (82540EM) NIC. It is harder to reproduce with PCnet-FAST III (Am79C973) NICs. It is not reproducible with host-only or bridged adapters.
| from django import template | |
| register = template.Library() | |
| class UpdateQuerystringNode(template.Node): | |
| def __init__(self, **kwargs): | |
| self.kwargs = kwargs | |
| def render(self, context): | |
| query_dict = context['request'].GET.copy() |