- cd to the directory the file is saved in
- python3 -m http.server
- navigation to ???:8000/formerror.html
- Press
next
orprev
- Check the params sent with the Intercooler intercepted request.
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 UnevaluableQuerySet(QuerySet): | |
def __init__(self, *a, **kw): | |
super(UnevaluableQuerySet, self).__init__(*a, **kw) | |
self._frozen = False | |
def freeze(self): | |
clone = self._clone() | |
clone._frozen = True | |
return clone |
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 django_filters import FilterSet | |
class MyModelFilterSet(FilterSet): | |
class Meta: | |
model = MyModel | |
fields = ['my_relation'] # internally this is a reverse relation, so MyModelInstance.my_relation_set.all() | |
# How do I get it so that the ModelChoiceFilter (actually a ModelMultipleChoiceFilter!) is only | |
# those items which exist given the FilterSet's original queryset (self.queryset.all()) |
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
# https://simpleisbetterthancomplex.com/tips/2016/08/19/django-tip-12-disabling-migrations-to-speed-up-unit-tests.html | |
class DisableMigrations(object): | |
def __contains__(self, item): | |
return True | |
def __getitem__(self, item): | |
return 'notmigrations' | |
MIGRATION_MODULES = DisableMigrations() |
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
<VirtualHost *:80> | |
ServerName whatever | |
ServerAlias www.whatever | |
<Directory /PATH/TO/PROJECT/CONFIGDIR> | |
<Files wsgi.py> | |
Require all granted | |
Satisfy Any | |
</Files> | |
</Directory> |
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
""" | |
python mm2px.py 290 210 150 | |
""" | |
import sys | |
w = float(sys.argv[1]) # 1830 | |
h = float(sys.argv[2]) # 1547 | |
dpi = int(sys.argv[3]) # 150 | |
w_mm = (w * dpi) / 25.4 | |
h_mm = (h * dpi) / 25.4 | |
print((w_mm, h_mm)) |
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 random import randint | |
from operator import attrgetter, itemgetter | |
from contexttimer import Timer | |
class Lol(object): | |
@property | |
def test(self): | |
return randint(1, 100) | |
def __getitem__(self, x): |
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
line ([1-9]\d+|[1-9]), in ([^\d\W]\w+) |
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
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals, absolute_import | |
from pprint import pprint | |
from operator import itemgetter | |
from copy import deepcopy | |
import sys | |
""" | |
Wheeee: | |
python sorto.py "age" "gender" |