I hereby claim:
- I am vdboor on github.
- I am vdboor (https://keybase.io/vdboor) on keybase.
- I have a public key ASDsqChLIrg8x7oYbtOBGh51bkDAnKWs69Izsyc4onhroQo
To claim this, I am signing this object:
import functools | |
import logging | |
from django.core.cache import DEFAULT_CACHE_ALIAS, caches | |
logger = logging.getLogger(__name__) | |
class CachedFunction: | |
""" | |
The CachedFunction is a proxy object that implements cache-wrapper logic around |
from django.core.management import BaseCommand | |
from django.db import connection, models | |
from django.db.migrations import Migration | |
from django.db.migrations.autodetector import MigrationAutodetector | |
from django.db.migrations.graph import MigrationGraph | |
from django.db.migrations.questioner import InteractiveMigrationQuestioner | |
from django.db.migrations.state import ModelState, ProjectState | |
class PatchedModelState(ModelState): |
#!/usr/bin/env python3 | |
# | |
# This runs dmesg to show iptable logs, and replaces the IP addresses with | |
# actual DNS names. Resolved names are cached for speedup. | |
# | |
# Uses dnspython for proper resolver timeout handling: | |
# pip3 install dnspython (or apt install python3-dnspython) | |
from collections import defaultdict | |
import dns.exception |
I hereby claim:
To claim this, I am signing this object:
#!/bin/bash | |
# Add user to k8s 1.6 using service account, no RBAC (must create RBAC after this script) | |
if [[ -z “$1” ]] || [[ -z “$2” ]];then | |
echo “usage: $0 <username> <environment (stg|prod)>” | |
exit 1 | |
fi | |
USER=$1 | |
environment=$2 |
from django.contrib import admin | |
from django.contrib.admin.utils import get_model_from_relation | |
from django.utils.encoding import smart_text | |
class LimitedRelatedFieldListFilter(admin.RelatedFieldListFilter): | |
""" | |
Limit the filter choices in the admin sidebar to objects | |
which are actually used by the objects shown in the list. |
// Debugging for media queries | |
#media-debug { | |
position: fixed; | |
left: 0; | |
bottom: 20px; | |
color: #000; | |
font-weight: bold; | |
padding: 2px 5px; | |
z-index: 1001; | |
} |
""" | |
Patch the creation of database migrations in Django | |
Import this early from `__init__.py``. | |
- Don't want verbose_name changes in the migrations file. | |
- Don't want help_text in the migrations file. | |
""" | |
from functools import wraps | |
from django.db.models import Field |
from django.utils.functional import cached_property | |
from django.views.generic import UpdateView | |
class CreateOrUpdateMixin(object): | |
""" | |
A mixin to make an ``UpdateView`` behave like an ``CreateView`` when the ID argument is missing. | |
The ``is_add`` attribute allows views to make small changes depending on the way the view is called. | |
Note this mixin is designed to save code. When the create and update logic differs a lot, | |
write them as separate views. |
from django import forms | |
from django.db.models import QuerySet, Q | |
class ListFilterForm(forms.Form): | |
""" | |
Base form for lists to add a search feature. | |
Tips: |