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
# add pip install/uninstall to requirements.txt automatically | |
pipr() { | |
if [ "$1" == "install" ]; then | |
pip $1 $2 | |
pip freeze | grep -i $2 >> requirements.txt | |
echo ok, added $2 as: | |
tail -n1 requirements.txt | |
fi | |
if [ "$1" == "uninstall" ]; then | |
echo y | pip $1 $2 >> .pipremoved |
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 | |
# create .keep files for empty directories currently ignored by git | |
# run git clean -nd to see which directories are empty and therefore ignored by git currently | |
# run git keep to add these directories by adding a .keep file | |
# see this discussion http://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository/21422128#21422128 | |
git clean -nd | awk '{ print $3 }' | xargs -L1 -I{} touch {}.keep |
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
""" | |
(c) 2014 miraculixx at gmx.ch | |
""" | |
from shrutil.dictobj import DictObject | |
class RuleContext(DictObject): | |
""" | |
rule context to store values and attributes (or any object) | |
""" | |
def __init__(self): |
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
class FieldSelectionMixin(object): | |
""" | |
add ability to Resource to query specific fields. This works by | |
removing any fields not in the fields list provided by the fields | |
query parameter. | |
Programming Use: | |
class MyResource(FieldSelectionMixin, ModelResource): | |
... | |
(as with any normal resource) |
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 |