Skip to content

Instantly share code, notes, and snippets.

View polmuz's full-sized avatar

Pablo Mouzo polmuz

  • Valencia, Spain
View GitHub Profile
@polmuz
polmuz / build_relative_paths.py
Created February 11, 2016 18:25
Simple python function to build paths relative to the current file
# source http://code.tutsplus.com/articles/diving-into-django--net-2969
import os
def rel(*l):
"""
Create paths relative to this file
e.g.
rel('tmp', 'bla.txt') -> '<this file dir>/tmp/bla.txt'
git branch --merged origin/master | grep -v '\* master' | xargs -l1 git branch -d
@polmuz
polmuz / gist:98d37d12eb4b9b9f3243
Created July 28, 2014 16:14
Speed is a feature - Django Meetup Buenos Aires June 2014 - Reference links
@polmuz
polmuz / test_settings.py
Created February 11, 2014 21:00
Monkey patch django-assets to force using staticfiles during test runs
# WARNING!!
# This is a hack until there's a setting in django-assets
# to force using staticfiles finders and avoid the need
# to run collectstatics before each test run.
# Just put this in your test settings.
from django_assets.env import DjangoResolver
use_staticfiles = property(lambda self: True)
DjangoResolver.use_staticfiles = use_staticfiles
@polmuz
polmuz / README
Last active December 14, 2015 04:49
Update submodules automatically after checkout when HEAD changes
Update submodules automatically after checkout
----------------------------------------------
Put the file post-checkout in .git/hooks/
Make it executable
(chmod u+x .git/hooks/post-checkout)
Never update your submodules manually again (unless something goes horribly wrong)!
@polmuz
polmuz / gist:4568964
Created January 18, 2013 21:51
Useful git aliases
[alias]
st = status
ci = commit
br = branch
co = checkout
df = diff
lg = log -p
lol = log --graph --decorate --pretty=oneline --abbrev-commit
lola = log --graph --decorate --pretty=oneline --abbrev-commit --all
@polmuz
polmuz / gist:1685139
Created January 26, 2012 21:13
LiveServerTestCase backported to Django 1.3
""" LiveServerTestCase extracted from Django 1.4 alpha source """
import os
import threading
import select
from django.conf import settings
from django.db import connections, DEFAULT_DB_ALIAS
from django.core.management import call_command
from django.contrib.staticfiles.handlers import StaticFilesHandler