Skip to main content

Snippets

Explore, use and share reusable code from verified tech professionals.

Join NXG to share yours
More

Catch Celery beat jobs that point at unregistered tasks

If a beat job names a task the worker never registered, the worker silently drops it and the job never runs. These two pytest checks fail in CI instead of in production.

Python CeleryDjangopytest +1
McMichael-Codes

Positional Array Transformation Alogrithm

Generating new arrays by interleaving values from previously generated arrays according to directional rules.

Python Python
Chisom Eze Sample

Kubernetes: Restart a Deployment Safely

Rolling restart and watch until it's healthy.

Bash
Fatima Al-Rashid Sample

Go: Context With Timeout Helper

Wrap a parent context with a deadline.

Go
Olumide Bakare Sample

Postgres: Find Slow Queries

Top queries by total time (needs pg_stat_statements).

SQL
Mariam Toure Sample

Rust: Checked Token Transfer

Never let a balance underflow.

Rust
Chidi Okoro Sample

TypeScript: Exhaustive Switch Helper

Make the compiler tell you when a union gains a case.

TypeScript
Adaeze Okafor Sample

React Custom Hook: useDebounce

Debounce a fast-changing value, e.g. a search box.

JavaScript
Emeka Nwosu Sample

Python Retry Decorator

Retry a flaky call a fixed number of times.

Python
Lindiwe Dube Sample

Idempotent Kafka Consumer (Go)

Skip events that were already processed, inside one transaction.

Go
Zainab Bello Sample

Exponential Backoff with Jitter

Spread retries out so a recovering service isn't stampeded.

Python
Kenechukwu Igwe Sample

Playwright: Wait for Network Idle After Action

Click and wait for the matching API response instead of sleeping.

TypeScript