Skip to content

Bestdoom20/snippets

Repository files navigation

snippets

Small, reusable Python & shell utilities I reach for often. Each lives in one file, no dependencies, copy-paste friendly.

Contents

  • slugify.py — turn any string into a URL-safe slug
  • retry.py — retry a flaky call with exponential backoff
  • humanize_bytes.py — human-readable byte sizes (1536 -> '1.5 KiB')
  • chunk.py — split an iterable into fixed-size chunks
  • timer.py — context manager that prints elapsed wall time
  • load_env.py — tiny .env parser into a dict
  • parallel_map.py — thread-pooled map for I/O-bound work
  • deep_get.py — safe nested lookup by dotted path
  • dedupe.py — order-preserving dedupe with optional key
  • sh.py — run a command, return stripped stdout
  • truncate.py — truncate to n chars on a word boundary
  • flatten.py — flatten a nested iterable one level
  • memoize.py — cache a function's return values
  • debounce.py — delay a call until calls stop firing
  • atomic_write.py — crash-safe file write via tmp + rename
  • flatten_dict.py — nested dict to dotted keys
  • human_duration.py — seconds to '1h 2m 5s'
  • clamp.py — clamp a value to [lo, hi]

About

Small, reusable Python & shell utilities I reach for often.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages