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
| # Want to run your Flask tests with CSRF protections turned on, to make sure | |
| # that CSRF works properly in production as well? Here's an excellent way | |
| # to do it! | |
| # First some imports. I'm assuming you're using Flask-WTF for CSRF protection. | |
| import flask | |
| from flask.testing import FlaskClient as BaseFlaskClient | |
| from flask_wtf.csrf import generate_csrf | |
| # Flask's assumptions about an incoming request don't quite match up with |
git add HISTORY.md
git commit -m "Changelog for upcoming release 0.1.1."
bumpversion patch
| #!/bin/bash | |
| NAME="hello_app" # Name of the application | |
| DJANGODIR=/webapps/hello_django/hello # Django project directory | |
| SOCKFILE=/webapps/hello_django/run/gunicorn.sock # we will communicte using this unix socket | |
| USER=hello # the user to run as | |
| GROUP=webapps # the group to run as | |
| NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | |
| DJANGO_SETTINGS_MODULE=hello.settings # which settings file should Django use | |
| DJANGO_WSGI_MODULE=hello.wsgi # WSGI module name |
| #get rid of anything from a mis-installed version | |
| sudo apt-get --purge remove postgres* | |
| sudo rm -rf /var/lib/postgresql | |
| sudo deluser -remove-all-files postgres | |
| #install the packages | |
| sudo apt-get install postgresql-9.1 | |
| sudo apt-get install pgadmin3 phppgadmin | |
| #shutdown postgres database server |
| Latency Comparison Numbers (~2012) | |
| ---------------------------------- | |
| L1 cache reference 0.5 ns | |
| Branch mispredict 5 ns | |
| L2 cache reference 7 ns 14x L1 cache | |
| Mutex lock/unlock 25 ns | |
| Main memory reference 100 ns 20x L2 cache, 200x L1 cache | |
| Compress 1K bytes with Zippy 3,000 ns 3 us | |
| Send 1K bytes over 1 Gbps network 10,000 ns 10 us | |
| Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD |