Skip to content

Instantly share code, notes, and snippets.

Bruno Alla browniebroke

Block or report user

Report or block browniebroke

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
Custom Celery task for providing useful extensions
from import Task
from django.db import transaction
class BetterCeleryTask(Task):
"""Extend the default Task class to add helpers with Django's on_commit()."""
browniebroke /
Last active Jun 29, 2016 — forked from rfj001/
MultiLocationField for django-haystack
import six
from django.contrib.gis.geos import Point
from haystack import indexes
from haystack.exceptions import SpatialError
from haystack.utils.geo import ensure_geometry, ensure_point
def ensure_multipoint(geom):
Makes sure the parameter passed in looks like a GEOS ``MultiPoint``.
browniebroke /
Last active Aug 29, 2015
Basic test of the Django admin views yours installed apps: simple GET on the list view, add view and list seacrh
from django.contrib import admin
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.db.models import get_models
from django.test import TestCase
class TestAdminViews(TestCase):
def setUp(self):
username = "test"
browniebroke /
Last active Aug 29, 2015
Django: Group model & count by date
Generic method (disclaimer: I did not consider any security concerns) to get stats
on a model in Django.
Created from
from django.db import connection
from django.db.models import Sum, Count
def truncate_date_model(model, period_length, date_field, criteria=None, pk='pk'):
browniebroke / circle.yml
Last active Aug 29, 2015
YAML Install postgres 9.1 with postgis on CircleCI
View circle.yml
# Use postgres 9.1
- sudo service postgresql stop && sudo apt-get remove -y postgresql-9.3 && sudo apt-get update && sudo apt-get install -y postgresql-9.1 postgresql-contrib-9.1 postgresql-9.1-postgis-2.1
- sudo sed -i "s/\port = 5433/port = 5432/" /etc/postgresql/9.1/main/postgresql.conf
- sudo cp /etc/postgresql/9.3/main/pg_hba.conf /etc/postgresql/9.1/main/pg_hba.conf
- sudo service postgresql restart
- sudo -u postgres createuser ubuntu -d --superuser
- createdb circle_test
You can’t perform that action at this time.