Skip to content

Instantly share code, notes, and snippets.

View Khushsheth's full-sized avatar

Khush Sheth Khushsheth

View GitHub Profile
@Khushsheth
Khushsheth / retry_decorator.py
Created April 14, 2026 12:45
Auto Retry Decorator (Production gold)
import time
from functools import wraps
def retry(retries=3, delay=0.5):
def decorator(func):
@wraps(func)
def wrapper(*args, **kwargs):
for attempt in range(retries):
try:
return func(*args, **kwargs)
@Khushsheth
Khushsheth / loading_spinner.py
Created April 14, 2026 12:44
Simple CLI Spinner
import itertools
import sys
import time
import threading
def spinner(stop_event):
for c in itertools.cycle('|/-\\'):
if stop_event.is_set():
break
sys.stdout.write(f'\rLoading {c}')