Skip to content

Instantly share code, notes, and snippets.

View wcooley's full-sized avatar

Wil Cooley wcooley

View GitHub Profile
@wcooley
wcooley / xml.vim
Created June 6, 2019 16:53
Vim support for BeanShell-in-XML rules for SailPoint IIQ; also, example setting syntax for region of language embedded within CDATA structures in XML
"
" Place in ~/.vim/after/syntax/xml.vim
"
" This enables Java syntax highlighting for the BeanShell embedded within CDATA
" regions of rule XML for Sailpoint IIQ.
"
" There might be better ways to limit loading this syntax than looking in the
" first 5 lines for 'language="beanshell"', but I cannot figure out how and this
" works for now.
"
@wcooley
wcooley / README.md
Last active April 3, 2023 14:35
Pytest: Ab(using) parametrize to alias long fixture names

Problem

I am testing an object with varied datasets, which I am creating as separate fixtures, so my fixture names become rather long due to encoding enough distinguishing characteristics so I can keep their purposes straight. I have to refer to my object a number of times throughout the test and futhermore there is a local convention for the name of the object in production code, so it makes sense to use the same short name in my tests. As a result, one of the very first things I do in the test is alias the long fixture name to the short conventional name, as can be seen in the assignment to foo in test_01_before.py. Whenever I do this, I wish to myself "it's too bad there isn't a way to express the fixture declaration/import with an alias

@wcooley
wcooley / setup.py
Created August 22, 2017 19:52
Inline setuptools command to list requirements
from setuptools import setup, Command
class ListRequirements(Command):
"""In-line command to display declared requirements."""
# TODO:
# * Add option to write out in a format
# comaptible with requirements.txt.
# * Add options to restrict to particular
# kinds & extras.
user_options = []
@wcooley
wcooley / README.md
Last active August 2, 2017 21:57
WIP: Interactive apply from stash to working copy

I'd like to be able to interactively apply the contents of a stash to the working copy, much as one can do with git checkout -p, git add -p and git stash save -p. The following is a bit of fiddling that I've done to figure out how to do this. It might one day grow into an actual PR but right now it's all just manual.

  1. Get the hash of the stash commit:
$ git rev-parse stash@{0}
feeebb56d0299c7dd130d643b21a73c2482a37c1
@wcooley
wcooley / Makefile.dash
Last active August 6, 2021 07:38
Building 3rd Party Sphinx Docs for Dash
# docs/Makefile.dash
include Makefile
PROJECT_NAME = $(shell python ../setup.py --name)
.PHONY: dashdoc
dashdoc:
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) -D 'html_theme=epub' $(BUILDDIR)/dashdoc
doc2dash -A -v -n $(PROJECT_NAME) -d $(BUILDDIR)/ -f -I index.html -j $(BUILDDIR)/dashdoc
@echo
@echo "Build finished. The Docset is in $(BUILDDIR)/$(PROJECT_NAME).docset."
@wcooley
wcooley / snippet_auto_sudo.sh
Created May 8, 2017 16:20
Snippet: Ensure script is run with correct user by re-running with sudo
# Ensure this script is run with the correct user by checking
RUNAS_USER="svcuser"
# Can use "$USER" instead of "$(id -un)" if the environment
# variable can be trusted; saves the exec(2) of the `id` which
# could be important -- because exec's are a bit more expensive
# and `id` can incur the overhead of a slow nameservice lookup.
# These would be important in a script used to shutdown or otherwise
# recover a system that is in distress due to resource starvation,
# for example.
@wcooley
wcooley / gist:84f3028a1ecf04e36e1c
Created March 25, 2015 07:18
Puppet => alignment
# Starts like this...
class strictly_following_style_guide {
yumrepo { 'puppetlabs-products':
descr => 'Puppet Labs Products El $releasever - $basearch',
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
}
}
@wcooley
wcooley / init.pp
Created November 15, 2012 20:12 — forked from big-samantha/init.pp
# Install, configure, and make persistent, iptables.
class iptables (
$publicports = [],
)
{
include
'iptables::config',
'iptables::service',
'iptables::install'
@wcooley
wcooley / gist:4080734
Created November 15, 2012 19:38
puppet specialization
module/foo/manifests/init.pp:
class foo {
file { 'foo':
source => 'puppet:///modules/foo/usual-case.conf'
}
}
module/foo/manifests/special.pp:
class foo::special inherits foo {
File['foo'] {