Skip to content

Instantly share code, notes, and snippets.

@DerWeh
DerWeh / typed_callbacks.py
Last active September 13, 2025 10:35
Creating dash callbacks from type hints
"""Provide `typed_callback` to create `dash.callback`s from type hints."""
import sys
from typing import get_origin, get_args, Any, Union, Tuple
from dash import callback, Output, Input, State # type: ignore[import]
if sys.version_info >= (3, 10):
from collections.abc import Callable
from inspect import get_annotations
from typing import Annotated, _AnnotatedAlias
@DerWeh
DerWeh / boundingbox.tikz.tex
Created November 30, 2017 21:22
Bounding box for a document -- draw a red rectangle in the size of your text area to indicate that maximum size for your graphic
\documentclass[
tikz,
class=scrartcl,% underlying class which is loaded by standalone
headinclude,fontsize=12pt,DVI=12% options used by typearea
]{standalone}
\storeareas\standalonelayout% save the standalone layout
\recalctypearea% recalculate the typearea layout
\edef\savedtextheight{\the\textheight}% save the text height of the typearea layout
\standalonelayout% restore the standalone layout