Skip to content

Instantly share code, notes, and snippets.

View medmunds's full-sized avatar

Mike Edmunds medmunds

  • Planapple
  • San Francisco, CA, USA
  • 09:21 (UTC -08:00)
View GitHub Profile
@medmunds
medmunds / pycharm_adapter.py
Last active October 2, 2026 00:39
PyCharm unittest adapter for running Django's own test suite
# Allows running Django's test suite in PyCharm's Unittest runner.
# Author: JetBrains AI Assistant/GPT-5.5 (with some help from Mike Edmunds).
#
# Usage:
# - Place this file in Django's tests dir.
# - Create a PyCharm run configuration for Python tests > Unittests with:
# Target: Script path: "pycharm_adapter.py" (this file)
# Working directory: "$ProjectFilesDir$/tests"
# - Don't set "Pattern" or "Additional arguments". Use the environment
# variables below instead.
@medmunds
medmunds / example.html
Last active September 25, 2026 02:48
Simple html file for testing
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example html</title>
</head>
<body>
<!-- Some content to scroll past -->
<p>Doggo ipsum you are doing me the shock ur givin me a spook pats many pats, tungg.</p>
<p>Stop it fren ur givin me a spook long doggo tungg long water shoob, such treat what a nice floof.</p>
@medmunds
medmunds / rename-email-providers.py
Created May 9, 2026 00:30
rename-email-providers
#!/usr/bin/env python
#
# Rename EMAIL_PROVIDERS to MAILERS (and related renaming) in all commits on
# the current branch.
#
# (With some assistance -- and more than a few false starts -- from GPT-5.5,
# plus many helpful "next edit suggestions" from PyCharm AI Assistant.)
#
# Strategy: apply the renaming within patch files, which limits the
# substitutions to the specific lines related to these changes.
@medmunds
medmunds / deprecation.py
Last active February 8, 2025 22:30
@deprecate_posargs decorator
import functools
import inspect
import warnings
def deprecate_posargs(category):
"""
Function/method decorator to deprecate some or all positional arguments.
The decorated function will map any positional arguments after the `*`
to the corresponding keyword arguments, but issue a deprecation warning.
@medmunds
medmunds / zen34.yaml
Last active August 7, 2023 21:13 — forked from flyingsubs/zen34.yaml
blueprint tutorial for Zen34
blueprint:
name: Zooz ZEN34
description: Automations helper for the Zooz ZEN34 S2 Switch using the Zwave
JS integration.
domain: automation
input:
zooz_zen34:
name: Zooz ZEN34
description: The ZEN34 Switch to interact with.
selector:
@medmunds
medmunds / README.md
Last active August 6, 2020 22:13
Dexie TrackedTransaction addon

This is an addon for [Dexie][] v3+ that adds a new db.trackedTransaction() method, using DBCore middleware.

trackedTransaction() is called just like transaction(), but takes an additional report function that is called with a list of TrackedChange records once the transaction is ready to commit (but before it actually commits).

See additional docs in the module declaration, and examples in the test file.

@medmunds
medmunds / patch_boto.py
Created September 21, 2018 00:48
Monkey-patch botocore to improve performance on large API requests
# Monkeypatch botocore.awsrequest.AWSRequest.body to improve performance by caching result.
# Usage: import this file once, at some point before making boto3 requests
# See https://github.com/boto/botocore/issues/1561
import six
from botocore.awsrequest import AWSRequest
# Monkeypatch AWSRequest.body to improve performance by caching result.
# - AWSRequest.body is accessed multiple times during request signing.
@medmunds
medmunds / lambda_function.py
Created September 20, 2018 23:36
Test botocore performance preparing large API requests in AWS Lambda
# This is an AWS Lambda function to help isolate apparent botocore performance issues
# when posting API requests with large parameters (e.g., SES.SendRawEmail with an 8MB
# RawMessage). See https://github.com/boto/botocore/issues/1561.
#
# Recommended Lambda config:
# Runtime: Python 3.6
# Handler: lambda_function.run_test
# Environment variables: SES_FROM = "your-validated-ses-sender@example.com"
# (if not set, SES will complain, but the timings should still be valid)
# Memory: 256 MB
@medmunds
medmunds / first_working_email_backend.py
Last active September 6, 2016 20:52
Django FirstWorkingEmailBackend uses ESP status APIs to find an "up" ESP for sending
# *Untested* implementation of a Django email backend that checks
# several ESP status APIs to see which are working, and uses the first
# available one to send.
#
# This caches the ESP API status check results for one hour (by default).
# You can subscribe to webhook notifications on the ESP status pages
# to force status re-checks after ESPs update their status pages.
#
# See https://github.com/anymail/django-anymail/issues/31 for discussion.
#