Skip to content

Instantly share code, notes, and snippets.

Avatar

Bruno Renié brutasse

View GitHub Profile
View find-deps.py
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
brutasse / env.md
Last active Dec 25, 2015
Setting application environment variables on production servers
View env.md

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
brutasse / clean-redis.py
Created Jul 14, 2013
Clean stale RQ jobs
View clean-redis.py
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) -
View commits.py
import os
import re
import requests
import feedgenerator
from dateutil.parser import parse
from raven import Client
REPO = 'django/django'
@brutasse
brutasse / markup.py
Created Dec 10, 2012
Markdown filter with proper content filtering
View markup.py
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()
View hashers.py
from django.contrib.auth.hashers import BasePasswordHasher
class NotHashingHasher(BasePasswordHasher):
"""
A hasher that does not hash.
"""
algorithm = 'plain'
def encode(self, password, salt):
@brutasse
brutasse / commits.py
Created May 14, 2011
Github Djangoproject commits -> highlighted Atom feed with links to changesets, tickets and files.
View commits.py
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
brutasse / shell_colors.py
Created Jul 13, 2010
Colorized shell output, some useful constants…
View shell_colors.py
# 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'
View package-sentry.sh
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

Replication

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.