Examples

Page 6 of 14

javascriptSnippet

Throttle a Function

Throttle limits how often a function runs by allowing at most one call per interval, useful for scroll and resize handlers that fire continuously.

pythonSnippet

Celery Beat Crontab Schedules

Schedule recurring Celery tasks with beat crontabs, mixing timezones, staggered offsets, and task-specific routing to dedicated queues.

pythonSnippet

Token Bucket Rate Limiter

Implement a token bucket that refills at a steady rate and allows short bursts, a standard algorithm for shaping request traffic.

pythonSnippet

Redis Sentinel Failover Client

Connect through Redis Sentinel for automatic failover, detecting role changes, retrying reads on replicas, and fencing split-brain writes.

pythonSnippet

Retry Decorator With Backoff

Decorate a function so transient exceptions are retried a fixed number of times with growing delay, keeping call sites free of retry plumbing.

pythonSnippet

Rich Table Live Display CLI

Render dynamic CLI tables with Rich Live mode, updating rows in place as background tasks progress and finishing with a clean summary.

pythonSnippet

Typer Async Command Options

Build async CLI commands with Typer, combining type-annotated options, enum choices, environment fallbacks, and per-command validation.

rustSnippet

Anyhow Context Error Chains

Enrich errors with anyhow context layers, converting foreign error types into chains that print root causes and section context.