Skip to content

Instantly share code, notes, and snippets.

working on


working on
  • Switzerland
Block or report user

Report or block miraculixx

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
miraculixx /
Created Feb 4, 2014
Get latest django-south migrations per app
def get_latest_migrations():
using South' MigrationHistory, get the latest migration id per app
using this, we can apply a --fake later on to get back the previous
from south.models import MigrationHistory
from django.db.models.aggregates import Max
latest = MigrationHistory.objects.values('app_name').annotate(latest=Max('applied'))
migrations = {}
miraculixx / filters.js
Created Apr 17, 2014
Add a Django-like filter to Backbone Models and Collections
View filters.js
* Backbone filter. This adds a filtering mechanism
* similar to Django ORM filters:
* var MyModel = Backbone.Model.extend(...);
* var model = new MyModel(...);
* model.filter("somekey", "somevalue");
* model.filter("anotherkey", "anothervalue");
* Doing so will result in the query() method to
* return a query string of all filters:
miraculixx / README
Created Apr 23, 2014
shrink size of git repository
I adopted Steve's script so that you can now do:
# list top 10
# delete for sure
./ --delete file ...
miraculixx / cleanzipextract
Last active Aug 29, 2015
remove files extracted from a zip file
View cleanzipextract
# Purpose:
# you have unzipped a zip file and realise the files are in the wrong place?
# simply remove the files again using this command
# Usage: cleanzipextract <zipfile>
# WARNING: this will list all files and then unconditionally remove all files it finds
miraculixx /
Last active Aug 29, 2015
Django Queryset CSV Exporter
class CSVExport(object):
A generic CSV exporter for any queryset. Use with a
file object or the default storage class.
Use with a file object:
queryset = SomeModel.objects.all()
exporter = CSVExport(queryset)
miraculixx / git-graph
Created Oct 6, 2014
git branch history in extended or dense format using git log, similar to git-cola's branch visualizatoin
View git-graph
# print a pretty branch graph
# (c) miraculixx 2014
# Installation:
# 1. Put this file in /usr/local/bin
# 2. chmod +x /usr/local/bin/git-graph
# Usage:
# $ git graph -h
View shrcoach.json
[{"pk": 1, "model": "shrcoach.operatoraddress", "fields": {"city": 1, "display_name": "Z\u00fcrich, Schweiz, Suisse, Svizzera, Svizra", "country": 1, "street": null, "normalized": "Zurich, Schweiz, Suisse, Svizzera, Svizra", "position": "47.3719943,8.5415277"}}, {"pk": 2, "model": "shrcoach.operatoraddress", "fields": {"city": 2, "display_name": "Z\u00fcrich, Schweiz, Suisse, Svizzera, Svizra", "country": 1, "street": null, "normalized": "Zurich, Schweiz, Suisse, Svizzera, Svizra", "position": "47.3719943,8.5415277"}}, {"pk": 1, "model": "shrcoach.itenaryaddress", "fields": {"itenary_code": "ZUR", "city": 4, "display_name": "Z\u00fcrich, Schweiz, Suisse, Svizzera, Svizra", "country": 1, "street": null, "normalized": "Zurich, Schweiz, Suisse, Svizzera, Svizra", "position": "47.3719943,8.5415277"}}, {"pk": 2, "model": "shrcoach.itenaryaddress", "fields": {"itenary_code": "HAM", "city": 5, "display_name": "Hamburg, Deutschland", "country": 2, "street": null, "normalized": "Hamburg, Deutschland", "position": "53.
This is a temporary fix for django-cms 3.0 failing to logout
a user correctly (I don't currently have the time to setup a
PR). The fix goes into cms.middleware.user
The problem is manifest in unit tests where there are multiple
tests that repeatedly login/logout using Django's test Client()
and which use fixtures referencing auth_user.
The first test that runs will install the fixtures fine. Any
miraculixx / alphabet.js
Created Oct 28, 2014
transform a list of names into an alphabet-keyed dictionary.
View alphabet.js
// transform a list of names into an alphabet-keyed dictionary.
// e.g. input is
// var list = ["Elsie Chambers", "Gene Keller", "Glen Hall", "Lawrence Burke", "Lenora Robbins", "Lillian Stone", "Lucy Roberson", "Mario Curry",
// "Shawn Matthews", "Terry Joseph"]
// asAlphabetDictionary(list) =>
// {"A":["Adrian Stanley"],"F":["Fred Houston"],"H":["Hilda Hart"],
// "I":["Irene Coleman"],"J":["Jeffery Castillo","Jon Floyd","Jonathan
// Conner"],"L":["Leon Higgins"],"N":["Nettie Jensen"],"S":["Sally
miraculixx /
Last active Aug 29, 2015
MoneyField for tastypie
from decimal import Decimal
from moneyed.classes import Money
from tastypie.fields import CharField, DecimalField
from tastypie.resources import ModelResource
from djmoney.models.fields import MoneyField as ModelMoneyField
class MoneyFieldMixin(object):
You can’t perform that action at this time.