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
View 00_fcomplete.py
import cmd
import sys
from fancycompleter import interact, DefaultConfig
class ConfigForTest(DefaultConfig):
use_colors = False
prefer_pyrepl = False
@theY4Kman
theY4Kman / wrap_fixture.py
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
View wrap_fixture.py
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
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 https://y4kstudios.com
// @updateUrl https://gist.github.com/theY4Kman/6e3680fdd5383992aeee5f3f4312dd8d/raw/e6d247c5e60d3411408f59faa82cdd833b84dac4/hulu-chrome-omnibox-search-fix.tamper.js
// @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 https://www.hulu.com/search?*
// @grant none
// ==/UserScript==
@theY4Kman
theY4Kman / README.md
Last active Mar 11, 2019 — forked from mikelane/game_of_life.py
Conway's Game of Life implemented using a 2d convolution.
@theY4Kman
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 https://perchsecurity.com
// @updateURL https://gist.github.com/theY4Kman/9938a82b2176aa4ef3fb38fec564500c/raw/bc532f738dbb87064d3a96d665da5458457277de/beanstalk-instance-linker.tamper.js
// @version 0.1
// @description Link instance IDs to EC2 console in Beanstalk
// @author theY4Kman
// @match https://console.aws.amazon.com/elasticbeanstalk/*
// @grant none
// ==/UserScript==
View jukebot-commands.md

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
theY4Kman / camel_words_collector.py
Created Oct 12, 2018
pytest plugin to allow matching class names on word boundaries
View camel_words_collector.py
"""
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
theY4Kman / django_rollback_transactions_middleware.py
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
View django_rollback_transactions_middleware.py
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
theY4Kman / django_subquery_only.py
Created Oct 4, 2018
A Django ORM Subquery Expression which only returns the specified fields
View django_subquery_only.py
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
theY4Kman / django_postgres_arrays.py
Created Oct 4, 2018
A Django ORM Expression for Postgres ARRAY literals
View django_postgres_arrays.py
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.