Skip to content

Instantly share code, notes, and snippets.

Zach Kanzler theY4Kman

Block or report user

Report or block theY4Kman

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
import cmd
import sys
from fancycompleter import interact, DefaultConfig
class ConfigForTest(DefaultConfig):
use_colors = False
prefer_pyrepl = False
theY4Kman /
Created May 26, 2019
pytest utility method for creating wrapper or factory fixtures, allowing methods defined elsewhere to request fixtures, while augmenting their return value
import functools
from typing import Callable, Iterable
from _pytest.compat import get_real_func, getfuncargnames
from _pytest.fixtures import call_fixture_func
def wrap_fixture(fixturefunc: Callable, wrapped_param: str = 'wrapped') -> Callable[[Callable], Callable]:
"""Wrap a fixture function, extending its argspec w/ the decorated method
theY4Kman / hulu-chrome-omnibox-search-fix.tamper.js
Last active Mar 31, 2019
There seems no way to search Hulu from the Chrome omnibox, because it no longer fills the search bar using the `?q=query` param. This script resolves that issue.
View hulu-chrome-omnibox-search-fix.tamper.js
// ==UserScript==
// @name Hulu fill search input from query params
// @namespace
// @updateUrl
// @version 0.1
// @description There seems no way to search Hulu from the Chrome omnibox, because it no longer fills the search bar using the `?q=query` param. This script resolves that issue.
// @author You
// @match*
// @grant none
// ==/UserScript==
theY4Kman /
Last active Mar 11, 2019 — forked from mikelane/
Conway's Game of Life implemented using a 2d convolution.
theY4Kman / beanstalk-instance-linker.tamper.js
Created Jan 11, 2019
Link instance IDs on Beanstalk's Health page to the EC2 Console
View beanstalk-instance-linker.tamper.js
// ==UserScript==
// @name Linkify beanstalk instances
// @namespace
// @updateURL
// @version 0.1
// @description Link instance IDs to EC2 console in Beanstalk
// @author theY4Kman
// @match*
// @grant none
// ==/UserScript==

Below are a list of the available Slack commands for Jukebot.

Command Description
/add track name Add a song to your Jukebot playlist
/album album name Search for an album
/artist artist name Search for an artist
/current playlist track
/delete Delete the currently playing track from your Jukebot playlist
/find track name Search for a track to add to your Jukebot playlist
theY4Kman /
Created Oct 12, 2018
pytest plugin to allow matching class names on word boundaries
In pytest.ini, we configure python_classes with wildcard patterns that are
checked with fnmatch. This can produce some unintentional effects; for instance,
the pattern For* also matches ForbidsAnonymousUsers, which we don't wish.
This plugin extends the semantics of fnmatch for python_classes, so a dash '-'
in the pattern matches a CamelWords boundary.
- For* will match "ForbidsAnonymousUsers" as well as "ForCurrentUser"
- For-* will match "ForCurrentUser", but not "ForbidsAnonymousUsers"
theY4Kman /
Created Oct 4, 2018
A Django middleware which rolls back any DB changes at the end of the request. I found it useful when profiling SQL queries from POST/PUT requests, because I didn't have to find or generate so much test data
import logging
from contextlib import contextmanager
from django.db import transaction
from django.http import HttpRequest
from django.utils.deprecation import MiddlewareMixin
logger = logging.getLogger(__name__)
theY4Kman /
Created Oct 4, 2018
A Django ORM Subquery Expression which only returns the specified fields
from django.db.models import Subquery
class SubquerySelect(Subquery):
"""Return only a subset of fields from a Subquery"""
template = '(SELECT %(fields)s FROM (%(subquery)s) AS %(subquery_alias)s)'
def __init__(self, queryset, output_field=None, fields=('*',), **extra):
self.fields = tuple(fields)
theY4Kman /
Created Oct 4, 2018
A Django ORM Expression for Postgres ARRAY literals
from django.contrib.postgres.fields import ArrayField
from django.db.models import Expression, Value
from netfields import InetAddressField
class Array(Expression):
"""A Postgres ARRAY[] expression"""
def __init__(self, *items, output_field=None):
if output_field is None:
You can’t perform that action at this time.