Skip to content

Instantly share code, notes, and snippets.

View shakeebshaan's full-sized avatar

SHAAN SHAIK shakeebshaan

View GitHub Profile
@shakeebshaan
shakeebshaan / async_retry.py
Created April 17, 2026 08:05
Async retry decorator — exponential backoff + jitter · for unreliable APIs
"""Async retry decorator with exponential backoff + jitter.
@retry(tries=5, base=0.5)
async def fetch_price(symbol: str) -> float:
async with aiohttp.ClientSession() as s:
async with s.get(url) as r:
r.raise_for_status()
return (await r.json())["price"]
"""
import asyncio
@shakeebshaan
shakeebshaan / useDebounce.ts
Created April 17, 2026 08:05
useDebounce — typed React hook for search boxes + expensive effects
/**
* useDebounce — delays a value update until input settles.
* Perfect for search boxes, API calls, expensive re-renders.
*
* const [q, setQ] = useState("");
* const debounced = useDebounce(q, 300);
* useEffect(() => { search(debounced); }, [debounced]);
*/
import { useEffect, useState } from "react";
@shakeebshaan
shakeebshaan / fastapi_jwt_auth.py
Created April 17, 2026 08:05
FastAPI — minimal JWT auth in 35 lines · login + protected route
"""Minimal FastAPI JWT auth — login + protected route + dependency."""
from datetime import datetime, timedelta, timezone
import jwt
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from passlib.hash import bcrypt
SECRET = "change-me-in-prod"
ALGO = "HS256"
@shakeebshaan
shakeebshaan / rsi_indicator.py
Created April 17, 2026 08:05
RSI — vectorized pandas, no loops, production-ready
"""RSI (Relative Strength Index) — pure pandas, vectorized, no loops.
Usage:
import pandas as pd
df = pd.read_csv("btc.csv")
df["rsi"] = rsi(df["close"], period=14)
"""
import pandas as pd