This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATABASES = { | |
'default': { | |
'ENGINE':'django.db.backends.mysql', | |
... | |
'OPTIONS': {'charset': 'utf8mb4'}, | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from itertools import chain | |
from operator import attrgetter | |
# ascending oreder | |
result_list = sorted( | |
chain(queryset1, queryset2), | |
key=attrgetter('date_created')) | |
# descending order |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install via MacPorts | |
sudo port install openssl | |
sudo env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/opt/local/lib" CFLAGS="-I/opt/local/include" pip install cryptography | |
# install via Homebrew | |
brew install openssl | |
env ARCHFLAGS="-arch x86_64" LDFLAGS="-L/usr/local/opt/openssl/lib" CFLAGS="-I/usr/local/opt/openssl/include" pip install cryptography |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
find . \( -name '*.py' -o -name '*.coffee' -o -name '*.scss' \) | xargs wc -l |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream php { | |
server unix:/var/run/php5-fpm.sock; | |
} | |
server { | |
# enforce NO www | |
server_name www.example.com; | |
return 301 $scheme://example.com$request_uri; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.forms import ModelForm | |
from django.forms import ValidationError | |
from django.forms import FileField | |
# Django 1.6 Version | |
class BaseModelForm(ModelForm): | |
# strip leading or trailing whitespace | |
def _clean_fields(self): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# round robin load balance pool | |
# servers can be local or remote | |
upstream lbpool { | |
ip_hash; | |
server 10.10.10.1:8000 max_fails=3 fail_timeout=120; | |
server 10.10.10.2:8000 max_fails=3 fail_timeout=120; | |
# additional servers | |
} | |
# http server |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the following assumes a typical MacPorts install to /opt/local | |
# create a directory to hold local ports | |
sudo mkdir /opt/custom | |
# edit /opt/local/etc/macports/sources.conf and add the following line before rsync://rsync.macports.org/release/tarballs/ports.tar | |
# file:///opt/custom | |
# create the directories to hold the port file | |
sudo mkdir -p /opt/custom/databases/mysql56/files/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream php-sendy-example-com { | |
server unix:/var/run/php5-fpm.sock; | |
} | |
server { | |
listen 80; | |
server_name sendy.example.com; | |
root /home/webapps/sendy.example.com/; | |
access_log /var/log/nginx/sendy.example.com.access.log main; | |
error_log /var/log/nginx/sendy.example.com.error.log; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name jira.example.com; | |
access_log /var/log/nginx/jira.example.com.access.log main; | |
error_log /var/log/nginx/jira.example.com.error.log; | |
location / { | |
proxy_pass http://localhost:8080; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; |