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:
| from django.db.models import Func, Value | |
| class DateTrunc(Func): | |
| """ | |
| To support using DATE_TRUNC('text', "field") in SQL | |
| Example:: | |
| order_totals = (orders |
| #!/usr/bin/env python | |
| # | |
| # (c) 2015, Edoburu, GPLv3+ licensed | |
| # | |
| # Based on https://github.com/ansible/ansible-modules-core/blob/devel/web_infrastructure/htpasswd.py | |
| # | |
| DOCUMENTATION = """ | |
| module: htpasswd | |
| short_description: manage PgBouncer userlist.txt entries | |
| description: |
| 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: |
| 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. |
| """ | |
| 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 |
| // Debugging for media queries | |
| #media-debug { | |
| position: fixed; | |
| left: 0; | |
| bottom: 20px; | |
| color: #000; | |
| font-weight: bold; | |
| padding: 2px 5px; | |
| z-index: 1001; | |
| } |
| 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. |
| #!/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 |
I hereby claim:
To claim this, I am signing this object:
| #!/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 |