Skip to content

Instantly share code, notes, and snippets.

@medecau
medecau / bootstrap_changelog.py
Created January 6, 2023 21:47
A CHANGELOG bootstrap script
import argparse
import re
import subprocess
import shlex
import itertools
# this will be used for SUBJECT_CATEGORIES
def insensitive(pattern):
"""Return a case-insensitive regex pattern."""
@medecau
medecau / witchhazelhypercolor.zsh-theme
Last active July 23, 2021 15:19 — forked from zoeisnowooze/witchhazelhypercolor.zsh-theme
Witch Hazel Hypercolor ZSH Theme
# Witch Hazel Hypercolor ZSH Theme
#
# https://witchhazel.thea.codes/
# https://twitter.com/ZoeIsNowOoze/status/1418271734327820289
#
# 1. Create a file ~/.oh-my-zsh/custom/themes/witchhazelhypercolor.zsh-theme
#
# 2. Set the name of the theme to load in the ~/.zshrc configuration, for example:
#
# ZSH_THEME="witchhazelhypercolor"
@medecau
medecau / shadow_it.md
Last active March 6, 2021 04:31
Dark IT, Rogue IT, and Stealth IT

Shadow IT

What you are looking for is Shadow I.T..

Dark IT, Rogue IT, and Stealth IT all mean Shadow IT.

@medecau
medecau / interpret.py
Last active November 12, 2020 16:47
Interpret python code and update the caller's locals
import inspect
def interpret(src):
"""Compile and execute provided code as if it was local to the caller"""
# get a decent name
try:
name = __file__
except NameError:
name = __name__
@medecau
medecau / insist.py
Created October 22, 2020 02:54
enforce type hinting at runtime with a decorator
from functools import wraps
from typing import get_type_hints
class InputError(Exception):
pass
def make_error_message(arg_name, arg_type, expected_type):
return f"{arg_name} value has type {arg_type} - must be {expected_type}"
@medecau
medecau / mod.py
Created May 18, 2020 05:35
mutation testing with redbaron and pytest
def inc(n):
"""increments n by one"""
return n + 1
def square(n):
"""squares n"""
return n ** 2
@medecau
medecau / exc_info_to_db.py
Created July 16, 2018 05:49
Exception > Dict > SQLite
import datetime as dt
import logging
import sys
from playhouse.dataset import DataSet # this can be any DB ;)
params = 'timestamp name level pathname lineno msg args exc_info func sinfo'.split(' ')
db = DataSet('sqlite:///db.sqlite')