Skip to content

Instantly share code, notes, and snippets.


Bruno Renié brutasse

View GitHub Profile
import os
import subprocess
base = [f.rsplit('-', 3)[0] for f in os.listdir('..') if f.endswith('.xz')]
downloaded = {'sh'}
def clean(p):
return p.split('>=')[0].split('=')[0]
brutasse /
Last active Dec 25, 2015
Setting application environment variables on production servers

A great tool is envdir

apt-get install envdir
mkdir /etc/mysite.d/env
echo "postgres://postgres:@localhost:5432/mysite" > /etc/mysite.d/env/DATABASE_URL
echo "s3ce3t K3Y" > /etc/mysite.d/env/SECRET_KEY
echo "/srv/www/mysite/static" > /etc/mysite.d/env/STATIC_ROOT
echo "mysite.settings" > /etc/mysite.d/env/DJANGO_SETTINGS_MODULE
brutasse /
Created Jul 14, 2013
Clean stale RQ jobs
import datetime
import redis
import pytz
from dateutil import parser
from itertools import product
r = redis.Redis()
last_month = (
datetime.datetime.utcnow().replace(tzinfo=pytz.utc) -
import os
import re
import requests
import feedgenerator
from dateutil.parser import parse
from raven import Client
REPO = 'django/django'
brutasse /
Created Dec 10, 2012
Markdown filter with proper content filtering
from django.template import Library
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
import bleach
import markdown as markdownlib
register = Library()
from django.contrib.auth.hashers import BasePasswordHasher
class NotHashingHasher(BasePasswordHasher):
A hasher that does not hash.
algorithm = 'plain'
def encode(self, password, salt):
brutasse /
Created May 14, 2011
Github Djangoproject commits -> highlighted Atom feed with links to changesets, tickets and files.
import os
import re
import feedgenerator
from github2.client import Github
REPO = 'django/django'
BRANCH = 'master'
HERE = os.path.abspath(os.path.dirname(__file__))
TICKET_RE = re.compile(r'#(?P<id>\d+)')
brutasse /
Created Jul 13, 2010
Colorized shell output, some useful constants…
# Font colors #
BLACK = '\x1b[30m'
RED = '\x1b[31m'
GREEN = '\x1b[32m'
YELLOW = '\x1b[33m'
BLUE = '\x1b[34m'
PURPLE = '\x1b[35m'
PALE_BLUE = '\x1b[36m'
WHITE = '\x1b[37m'
sudo apt-get -y install python-virtualenv libxslt1-dev libxml2-dev python-virtualenv-tools
export VERSION=`date +"%Y.%m.%d"`.$BUILD_NUMBER
mkdir -p build/usr/share/python
virtualenv build/usr/share/python/sentry
build/usr/share/python/sentry/bin/pip install -U pip wheel distribute
build/usr/share/python/sentry/bin/pip uninstall -y distribute
build/usr/share/python/sentry/bin/pip install sentry[mysql] dj-database-url hiredis dj-redis-url django-redis-cache
View replication.rst


Sync process is:

  • make a base backup
  • catch up with changes that happened during the base backup using master's WAL files
  • stream

Make sure master's wal_keep_segments is set to a high enough value to allow tracking all changes happening during the base backup. Restart needed when changing this.

You can’t perform that action at this time.