This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
state | |
""" | |
from south.models import MigrationHistory | |
from django.db.models.aggregates import Max | |
latest = MigrationHistory.objects.values('app_name').annotate(latest=Max('applied')) | |
migrations = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Source: http://stevelorek.com/how-to-shrink-a-git-repository.html | |
I adopted Steve's script so that you can now do: | |
# list top 10 | |
./gitsize.sh | |
# delete for sure | |
./gitsize.sh --delete file ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin | |
# 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 | |
# USE WITH CAUTION |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
export.export(file) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[{"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 file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): | |
""" |
OlderNewer