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
# Usage: show <local-port> <subdomain> | |
function show() { | |
DOMAIN=".tekacs.com" | |
REMOTE="$2$DOMAIN" | |
ssh -tR 1080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:1080 localhost" | |
} |
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 QuerySetDoubleIteration(Exception): | |
"A QuerySet was iterated over twice, you probably want to list() it." | |
pass | |
# "Skinny" here means we use iterator by default, rather than | |
# ballooning in memory. | |
class SkinnyManager(Manager): | |
def get_query_set(self): | |
return SkinnyQuerySet(self.model, using=self._db) |
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
diff --git a/django_root/django/db/models/base.py b/django_root/django/db/models/base.py | |
index 37331b3..4da2802 100644 | |
--- a/django_root/django/db/models/base.py | |
+++ b/django_root/django/db/models/base.py | |
@@ -5,6 +5,7 @@ from itertools import izip | |
import django.db.models.manager # Imported to register signal handler. | |
from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS | |
from django.core import validators | |
+from django.db.models.expressions import ExpressionNode | |
from django.db.models.fields import AutoField, FieldDoesNotExist |
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 queryset_to_dict(qs, key='pk'): | |
""" | |
Given a queryset will transform it into a dictionary based on ``key``. | |
""" | |
return dict((getattr(u, key), u) for u in qs) | |
def distinct(l): | |
""" | |
Given an iterable will return a list of all distinct values. | |
""" |