Skip to content

Instantly share code, notes, and snippets.

View alexisbellido's full-sized avatar

Alexis Bellido alexisbellido

View GitHub Profile
@alexisbellido
alexisbellido / gist:4945061
Created February 13, 2013 14:45
Run $ workon x_YourTango_SecretWeapon_development and then edit your ~/run-x_YourTango_SecretWeapon_development file with to look like this, notice the export lines.
#!/bin/bash -e
# this script may need to run with source to switch the virtualenv correctly, like this: $ source thisscript.sh
# gunicorn application has to be enabled in Django project
LOGFILE=/home/alexis/logs/yourtango_secret_weapon_development/gunicorn.log
LOGDIR=$(dirname $LOGFILE)
LOGLEVEL=debug
NUM_WORKERS=3
BIND_ADDRESS=127.0.0.1:8002
@alexisbellido
alexisbellido / utils.py
Created August 21, 2012 18:21
Django conditional cache for per-site cache based on user.is_authenticated()
"""
A decorator to bypass per-site cache if the user is authenticated. Based on django.views.decorators.cache.never_cache.
See: http://stackoverflow.com/questions/12060036/why-django-1-4-per-site-cache-does-not-work-correctly-with-cache-middleware-anon
"""
from django.utils.decorators import available_attrs
from django.utils.cache import add_never_cache_headers
from functools import wraps
def conditional_cache(view_func):
@alexisbellido
alexisbellido / django.vcl
Created August 16, 2012 18:21 — forked from ghughes/django.vcl
Django VCL for Varnish
sub vcl_recv {
# unless sessionid/csrftoken is in the request, don't pass ANY cookies (referral_source, utm, etc)
if (req.request == "GET" && (req.url ~ "^/static" || (req.http.cookie !~ "sessionid" && req.http.cookie !~ "csrftoken"))) {
remove req.http.Cookie;
}
# normalize accept-encoding to account for different browsers
# see: https://www.varnish-cache.org/trac/wiki/VCLExampleNormalizeAcceptEncoding
if (req.http.Accept-Encoding) {
if (req.http.Accept-Encoding ~ "gzip") {
@alexisbellido
alexisbellido / gist:2852245
Created June 1, 2012 13:42
vmbuilder.partition
root@jericho:~/scripts# cat /var/lib/libvirt/images/vm1/vmbuilder.partition
root 20000
swap 500
root@jericho:~/scripts# cat createvm.sh
#!/bin/bash
echo "./createvm.sh HOSTNAME SUITE ARCH IP GW USER USERNAME PASS MEM"
echo "example: ./createvm.sh vm6 oneiric i386 192.168.0.186 192.168.0.1 username UserName password 1024"
BASEVM=vm1
HOSTNAME=$1