Python

Scripting (shebang + uv)

Install uv:

#!/usr/bin/env uv run --no-project --with toml

You may add as many --with as you'd like and specify the version as with requirements.txt.
Update uv using uv self update.

Absolute directory path

import os

def r(relative_path: str):
    return os.path.join(os.path.dirname(__file__), relative_path)

Reverse string

rev = 'abcdef'[::-1]

Jinja

Minimal Jinja setup

import jinja2

template = jinja2.Template(open('template.jinja').read())
obj = {
    'name': 'My Template',
    'property': [0, 1, 2],
}
payload = tempalte.render(obj)