Install pip and virtualenv:
sudo apt-get install python_setuptools sudo easy_install pip sudo pip install virtualenv virtualenvwrapper
Set the following in ~/.bashrc:
WORKON_HOME=/home/yuri/virtualenvs source /usr/local/bin/virtualenvwrapper.sh
| # nano /etc/fail2ban/filter.d/nginx-4xx.conf | |
| # | |
| [Definition] | |
| failregex = ^<HOST>.*"(GET|POST).*" (404|444|403|400) .*$ | |
| ignoreregex = | |
| from django.db import connection | |
| from django.db import models | |
| class EstimateCountManager(models.Manager): | |
| def estimate_count(self): | |
| """ | |
| Postgres really sucks at full table counts, this is a faster version | |
| see: http://wiki.postgresql.org/wiki/Slow_Counting | |
| """ | 
| import base64 | |
| from django.core.files.base import ContentFile | |
| from rest_framework import serializers | |
| class Base64ImageField(serializers.ImageField): | |
| def from_native(self, data): | |
| if isinstance(data, basestring) and data.startswith('data:image'): | |
| # base64 encoded image - decode | 
| from django.core.exceptions import ValidationError | |
| from django.utils.translation import ugettext_lazy as _ | |
| from rest_framework import serializers | |
| class EmailListField(serializers.EmailField): | |
| default_error_messages = { | |
| 'invalid': _('Invalid E-mail address.'), | |
| } | 
| [mysqld] | |
| default-character-set=utf8 | |
| default-collation=utf8_general_ci | |
| character-set-server=utf8 | |
| collation-server=utf8_general_ci | |
| init-connect='SET NAMES utf8' | |
| [client] | |
| default-character-set=utf8 | 
Install pip and virtualenv:
sudo apt-get install python_setuptools sudo easy_install pip sudo pip install virtualenv virtualenvwrapper
Set the following in ~/.bashrc:
WORKON_HOME=/home/yuri/virtualenvs source /usr/local/bin/virtualenvwrapper.sh
| import logging | |
| logging.basicConfig() | |
| logger = logging.getLogger('') | |
| logger.setLevel(logging.DEBUG) |