Skip to content

Instantly share code, notes, and snippets.

View theY4Kman's full-sized avatar

Zach Kanzler theY4Kman

View GitHub Profile
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
from generate_functions import *
from .fixtures import *
@theY4Kman
theY4Kman / gist:7760149
Last active August 11, 2016 18:45
Decorator to automatically create a keyword-discriminating autouse fixture, so you can use either @pytest.mark.xxxx or shove in xxxx as an argument in order to use it. This way you don't have to make things arguments that aren't really arguments, and you need not rely on boilerplate usefixtures calls. You know what the mark means.
def _keyword_fixture(fn):
fixture_name = fn.__name__
fixture_module = import_module(fn.__module__)
@pytest.fixture(autouse=True)
def _autouse_fixture(request):
if fixture_name in request.keywords:
request.getfuncargvalue(fixture_name)
_autouse_fixture.__name__ = '_{}_autouse'.format(fixture_name)
@theY4Kman
theY4Kman / gist:6416702
Last active December 22, 2015 04:19
Log, taken from my TiddlyWiki, of a blog post I'm writing about making laws computer-testable: http://y4kstudios.com/post/computer-testable-laws/
Placeholder
// ==UserScript==
// @name Hive passwords utilities
// @description Copies to clipboard upon Reveal
// @match https://hive.hivelocity.net/admin/passwords/password/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @grant GM_setClipboard
// @copyright 2013, Zach "theY4Kman" Kanzler
// ==/UserScript==
$('input[type=password]').siblings('a').click(function() {
@theY4Kman
theY4Kman / yakbot.yaml
Created August 14, 2013 18:07
The default yakbot configuration file.
channels:
- '#sourcemod'
- '#yakbot'
network:
host: irc.gamesurge.net
port: 6667
nickname: yakbot
plugins:
- smapi
- smbugs
@theY4Kman
theY4Kman / one-liner.sh
Last active May 4, 2017 15:00
Downloads and sets up my environment. Copy the one-liner.sh to the terminal and you're all set!
wget https://gist.github.com/theY4Kman/6197365/raw/setup-yak.sh -O /tmp/setup-yak.sh && source /tmp/setup-yak.sh
@theY4Kman
theY4Kman / local.py
Created July 31, 2013 15:26
Default address/port for runserver
# runserver
from django.core.management.commands import runserver
runserver.BaseRunserverCommand.handle.im_func.func_defaults = ('0.0.0.0:5050',)
# And runserver_plus
from django_extensions.management.commands import runserver_plus
runserver_plus.Command.handle.im_func.func_defaults = ('0.0.0.0:5050',)
@theY4Kman
theY4Kman / sql_enum_if.py
Last active December 19, 2015 11:58
Generates a MySQL (maybe generic SQL) expression which converts the stored index of an enum to its constant name. Useful if some jackasses put their constants in the PHP code—not in the database—and you want to see more descriptive values than numbers.
def sql_enum_if(enum_dict, field):
"""
Example:
>>> enum_dict = {'CONST_NAME': 1, 'CONST_TWO': 2}
{'CONST_TWO': 2, 'CONST_NAME': 1}
>>> sql_enum_if(enum_dict, 'myfield')
'IF(myfield = 2, "CONST_TWO", IF(myfield = 1, "CONST_NAME", "<unknown>")) AS myfield'
"""
def _sql_enum_if(items):