Skip to content

Instantly share code, notes, and snippets.

View jwineinger's full-sized avatar

Jay Wineinger jwineinger

  • SPS Commerce
  • Minneapolis, MN
View GitHub Profile
@Stono
Stono / x-workload-name-envoyfilter.yaml
Created October 15, 2021 15:15
Adds a workload name header to outbound requests in istio
apiVersion: networking.istio.io/v1alpha3
kind: EnvoyFilter
metadata:
name: add-x-workload-header
namespace: istio-system
annotations:
name: Add Workload Header
description: Adds an x-workload-header
spec:
configPatches:
groups:
# These sum(irate()) functions are in separate groups, so they run in parallel
- name: istio.workload.istio_request_duration_milliseconds_bucket
interval: 10s
rules:
- record: workload:istio_request_duration_milliseconds_bucket:rate1m
expr: |
sum(irate(istio_request_duration_milliseconds_bucket{reporter="source", source_workload!=""}[1m]))
by (
@specialunderwear
specialunderwear / meta.py
Last active July 22, 2019 12:12
Override model fields of an abstract model baseclass in django, by removing them from the abstract model.
def AbstractClassWithoutFieldsNamed(cls, *excl):
"""
Removes unwanted fields from abstract base classes.
Usage::
>>> from oscar.apps.address.abstract_models import AbstractBillingAddress
>>> from koe.meta import AbstractClassWithoutFieldsNamed as without
>>> class BillingAddress(without(AbstractBillingAddress, 'phone_number')):
... pass
@jwineinger
jwineinger / django_multivalue_datetime_timezone.py
Created August 1, 2013 17:55
A Django MultiValue form field that handles a text datetime input and a pytz timezone input from a select list. Also, widget classes and data-format attribute are intended for use with bootstrap-datetimepicker from https://github.com/tarruda/bootstrap-datetimepicker
from django import forms
from django.forms.fields import MultiValueField
import pytz
# provided by django-timezone-field==0.4
from timezone_field import TimeZoneFormField
class DatetimeTZWidget(forms.MultiWidget):
@jwineinger
jwineinger / storage.py
Created December 16, 2011 16:46
Django staticfiles JS-minifying storage backend
from django.core.files.storage import FileSystemStorage
from slimit import minify
class StaticFileStorageAndJSMinifier(FileSystemStorage):
"""
A storage backend to be used by the staticfiles app -- STATICFILES_STORAGE
setting. This backend operates just as a normal filesystem storage backend
except when it detects a javascript file.
After a javascript file is saved, we reopen the file, minify the contents