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
| class DisableMigrations(object): | |
| def __contains__(self, item): | |
| return True | |
| def __getitem__(self, item): | |
| return "notmigrations" | |
| MIGRATION_MODULES = DisableMigrations() |
| upstream myapp { | |
| server 127.0.0.1:8081; | |
| } | |
| limit_req_zone $binary_remote_addr zone=login:10m rate=1r/s; | |
| server { | |
| listen 443 ssl spdy; | |
| server_name _; | |
| error_page 400 404 405 =200 @40*_json; | |
| location @40*_json { | |
| default_type application/json; | |
| return 200 '{"code":"1", "message": "Not Found"}'; | |
| } | |
| error_page 500 502 503 504 =200 @50*_json; | |
| location @50*_json { |
| package main | |
| import ( | |
| "bytes" | |
| "code.google.com/p/go.crypto/openpgp" | |
| "encoding/base64" | |
| "io/ioutil" | |
| "log" | |
| "os" | |
| ) |
| sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common | |
| sudo apt-get build-dep vim-gnome | |
| sudo apt-get install liblua5.1-dev luajit libluajit-5.1 python-dev ruby-dev libperl-dev libncurses5-dev libgnome2-dev libgnomeui-dev libgtk2.0-dev libatk1.0-dev libbonoboui2-dev libcairo2-dev libx11-dev libxpm-dev libxt-dev | |
| sudo rm -rf /usr/local/share/vim | |
| sudo rm /usr/bin/vim | |
| from uuid import UUID | |
| def validate_uuid4(uuid_string): | |
| """ | |
| Validate that a UUID string is in | |
| fact a valid uuid4. | |
| Happily, the uuid module does the actual | |
| checking for us. |
| server { | |
| listen 80; | |
| server_name subdomain.example.com; | |
| access_log /var/log/nginx/example.access.log; | |
| location / { | |
| if ($http_origin ~* (https?://.*\.example\.com(:[0-9]+)?)) { | |
| set $cors "true"; |
| # | |
| # Acts as a nginx HTTPS proxy server | |
| # enabling CORS only to domains matched by regex | |
| # /https?://.*\.mckinsey\.com(:[0-9]+)?)/ | |
| # | |
| # Based on: | |
| # * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html | |
| # * http://enable-cors.org/server_nginx.html | |
| # | |
| server { |