Skip to content

Instantly share code, notes, and snippets.

View alexisbellido's full-sized avatar

Alexis Bellido alexisbellido

View GitHub Profile
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
@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
@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 / 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 / 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 / gist:4945125
Created February 13, 2013 14:55
Create this in ~/dev_run-x_YourTango_SecretWeapon_development and chmod u+x. Replace
#!/bin/bash -e
PROJECTDIR=/home/alexis/yourtango_secret_weapon_development
PROJECTENV=/home/alexis/.virtualenvs/x_YourTango_SecretWeapon_development
source $PROJECTENV/bin/activate
cd $PROJECTDIR
export LC_ALL="en_US.UTF-8"
export YTSW_DATABASES_DEFAULT_NAME_DEVELOPMENT="db_name"
googletag.cmd.push(function() {
googletag.defineSlot('/7181/blogs/blog_celeblove', [[728, 90], [320, 50]], 'ad-leaderboard').addService(googletag.pubads()).setTargeting("nid", "174371").setTargeting("type", "blog").setTargeting("name-url", "2013174371/five-things-you-must-know-sundays-downton-abbey-finale");
;
googletag.defineSlot('/7181/blogs/blog_celeblove', [[300, 250], [300, 600]], 'ad-atf').addService(googletag.pubads()).setTargeting("nid", "174371").setTargeting("type", "blog").setTargeting("name-url", "2013174371/five-things-you-must-know-sundays-downton-abbey-finale");
googletag.defineSlot('/7181/blogs/blog_celeblove', [160, 600], 'ad-skyscraper').addService(googletag.pubads()).setTargeting("nid", "174371").setTargeting("type", "blog").setTargeting("name-url", "2013174371/five-things-you-must-know-sundays-downton-abbey-finale");
googletag.defineSlot('/7181/blogs/blog_celeblove', [300, 100], 'ad-incontent').addService(googletag.pubads()).setTargeting("nid", "174371").setTargeting("type", "blog").setTa
<script type="text/javascript">
<!--//--><![CDATA[//><!--
GlamCreateSlot("281100876", "728x90", "ad-leaderboard");
GlamCreateSlot("281100876", "300x250", "ad-atf");
GlamCreateSlot("281100876", "970x66", "ad-pushdown");
GlamGetAds("281100876");
//--><!]]>
</script>
<section class="ad-atf"><div id="ad-atf">
<script type="text/javascript">
if (GlamIsAvailable('ad-atf')) {
GlamShow('ad-atf');
} else {
googletag.cmd.push(function() { googletag.display('ad-atf'); });
}
</script>
</div></section>
if (drupal_is_front_page()) {
$canonical_url = $base_url . '/';