Skip to content

Instantly share code, notes, and snippets.

@marcusadair
marcusadair / !javadoc.md
Last active June 20, 2025 18:24
Javadoc quick ref

Javadoc Markdown Examples

# uv https://docs.astral.sh/uv/concepts/projects/dependencies/
# poetry https://python-poetry.org/docs/pyproject/
# packaging https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
[project]
name = ""
version = "0.0.1"
description = ""
requires-python = "3.12.*"
authors = [{ name = "", email = "" }]
@marcusadair
marcusadair / !pytest.md
Last active June 20, 2025 18:20
pytest config

pytest snippets

  • starter pytest.ini
  • starter conftest.py with some pytest hook functions
    • add custom cli options.
    • assign markers in a hook.
    • skip tests in a hook.
    • add globals to the doctest namespace.

References

@marcusadair
marcusadair / mypy.ini
Last active January 24, 2025 16:13
mypy config
[mypy]
# Config: https://mypy.readthedocs.io/en/stable/config_file.html
# Cheat sheet: https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html
python_version = 3.12
files = .
check_untyped_defs = True
no_implicit_reexport = True
@marcusadair
marcusadair / ruff.toml
Last active June 20, 2025 18:18
Ruff config for high value and low nag
#r4
target-version = "py311"
line-length = 88
indent-width = 4
respect-gitignore = true
show-fixes = true
output-format = "concise"
preview = true
[lint]
#!/usr/bin/env zsh
## Snippets for data munging, DuckDB, JSON imports and exports
## Requires AWS CLI and jq
## Playground data is CSV with 200k Jeopardy questions found on Kaggle:
## https://www.kaggle.com/datasets/tunguz/200000-jeopardy-questions
## Snippet highlights:
## * zsh to set a var from a heredoc without any escaping
## * zsh for var substitution in template strings
## * DuckDB DDL for tables
#!/usr/bin/env zsh
## Snippets for data munging and import to DynamoDB
## Requires AWS CLI and jq
## Playground data is CSV with 200k Jeopardy questions found on Kaggle:
## https://www.kaggle.com/datasets/tunguz/200000-jeopardy-questions
## DynamoDB local:
## https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html
## Snippet highlights:
## * JQ to convert some JSON format to DynamoDB PutRequest

Clap 4 enum options interacting with boolean flags

  • Demo two-way effects between options and flags
  • Avoid breaking changes when a CLI args gets more complex

Short help

Clap 4 enum options interacting with boolean flags
import json
import os
import sys
import boto3
def receive(queue_url, delete_messages=False):
print(f"Reading queue {queue_url}", file=sys.stderr)
sqs_client = boto3.client('sqs')
@marcusadair
marcusadair / dynamodb-export.py
Created March 12, 2024 21:25
Export DynamoDB table to json stream
from __future__ import annotations
import json
import sys
from decimal import Decimal
from time import perf_counter
import boto3