Python Project
Practical Python, Real Results
Compact, production-minded snippets I use in real client work.
Python Projects (Real-world)
A few compact, practical tools I build in Python across telecom, design, and automation.
Ringtone Generator (WAV)
Programmatically generates clean dual-tone ringtones for IVR/VOIP & apps.
Image → Color Palette
Extracts top 5 colors from any image and renders a branded palette preview.
<!-- ==== Python Showcase (Carrd Embed • HTML+CSS only) ==== -->
 <style>
 .py-wrap{font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;color:#111;background:#fff;padding:28px 16px}
 .py-title{margin:0 0 6px;font-size:26px}
 .py-lead{margin:0 0 18px;color:#666}
 .py-grid{display:flex;flex-wrap:wrap;gap:16px;justify-content:center}
 .py-card{width:360px;max-width:100%;background:#f7f9fc;border:1px solid #e6ecf5;border-radius:14px;padding:14px}
 .py-card h3{margin:0 0 6px;font-size:18px}
 .py-desc{font-size:14px;color:#3a3a3a;min-height:40px;margin-bottom:10px}
 .py-code{background:#0b1020;color:#e8e8e8;padding:12px;border-radius:10px;overflow:auto;font-size:12px;line-height:1.4;white-space:pre}
 .py-badges{display:flex;gap:6px;flex-wrap:wrap;margin:6px 0 10px}
 .py-badge{font-size:12px;padding:4px 8px;border-radius:999px;background:#eaf3ff;color:#0a66ff}
 </style><div class="py-wrap">
 <h2 class="py-title">Python That Ships</h2>
 <p class="py-lead">Compact, production-minded snippets I use in real client work.</p><div class="py-grid"><!-- 1) Micro API (Flask) -->
 <div class="py-card">
 <h3>Micro API, Zero Bloat</h3>
 <div class="py-badges"><span class="py-badge">Web</span><span class="py-badge">API</span><span class="py-badge">Flask</span></div>
 <div class="py-desc">Tiny Flask service for forms/webhooks with health check and JSON echo.</div>
 <div class="py-code">from flask import Flask, jsonify, requestapp = Flask(name)@app.get("/health")
 def health():
 return {"status": "ok"}@app.post("/echo")
 def echo():
 data = request.getjson(silent=True) or {}
 return jsonify({"yousent": data}), 200if name == "main":
 app.run(port=8000, debug=True)</div>
 </div><!-- 2) CSV Cleaner (pandas) -->
 <div class="py-card">
 <h3>CSV Cleaner, On Tap</h3>
 <div class="py-badges"><span class="py-badge">Data</span><span class="py-badge">ETL</span><span class="py-badge">pandas</span></div>
 <div class="py-desc">Fix headers, types, and dupes; export a clean dataset in seconds.</div>
 <div class="py-code">import pandas as pddf = pd.readcsv("input.csv")
 df.columns = [c.strip().lower().replace(" ", "") for c in df.columns]
 df = df.dropduplicates().dropna(how="all")if "email" in df.columns:
 df["email"] = df["email"].astype(str).str.strip().str.lower()df.tocsv("clean.csv", index=False)
 print("Saved clean.csv")</div>
 </div><!-- 3) Uptime Monitor (requests) -->
 <div class="py-card">
 <h3>Ping • Alert • Relax</h3>
 <div class="py-badges"><span class="py-badge">Automation</span><span class="py-badge">Ops</span><span class="py-badge">requests</span></div>
 <div class="py-desc">Checks your URL on a schedule and flags issues before users do.</div>
 <div class="py-code">import time, requestsURL = "https://www.sumandas.in"
 INTERVAL = 300 # 5 minuteswhile True:
 try:
 r = requests.get(URL, timeout=8)
 print(time.strftime("%Y-%m-%d %H:%M:%S"), "->", r.statuscode)
 except Exception as e:
 print(time.strftime("%Y-%m-%d %H:%M:%S"), "ERROR:", e)
 time.sleep(INTERVAL)</div>
 </div><!-- 4) Image → Brand Palette (Pillow) -->
 <div class="py-card">
 <h3>Image → Brand Palette</h3>
 <div class="py-badges"><span class="py-badge">Design</span><span class="py-badge">Pillow</span><span class="py-badge">Visualization</span></div>
 <div class="py-desc">Extract top five colors and render a neat, shareable swatch.</div>
 <div class="py-code">from PIL import Image, ImageDraw
 from collections import Counterdef topcolors(path, n=5):
 img = Image.open(path).convert("RGBA").resize((400, 400))
 px = [p for p in img.getdata() if p[3] > 0]
 counts = Counter((r,g,b) for r,g,b,a in px)
 return [rgb for rgb,_ in counts.mostcommon(n)]def swatch(colors, out="palette.png"):
 w, h = 100len(colors), 120
 im = Image.new("RGB", (w,h), "white")
 d = ImageDraw.Draw(im)
 for i,c in enumerate(colors):
 x = i100
 d.rectangle([x,0,x+100,100], fill=c)
 im.save(out)if name == "main":
 cols = topcolors("input.jpg", n=5)
 swatch(cols, "palette.png")</div>
 </div><!-- 5) Dual-Tone Ringtone (stdlib) -->
 <div class="py-card">
 <h3>Dual-Tone Ringtone (440/480)</h3>
 <div class="py-badges"><span class="py-badge">Audio</span><span class="py-badge">Telecom</span><span class="py-badge">Stdlib</span></div>
 <div class="py-desc">Generate IVR-ready WAV tones with precise on/off cadence.</div>
 <div class="py-code">import math, wave, structdef sine(f, t, sr=8000):
 return [math.sin(2math.pif(i/sr)) for i in range(int(tsr))]def normalize(samples):
 m = max(abs(x) for x in samples) or 1
 return [int(32767 * (x/m)) for x in samples]def writewav(samples, path, sr=8000):
 with wave.open(path, "w") as w:
 w.setnchannels(1); w.setsampwidth(2); w.setframerate(sr)
 for s in samples: w.writeframes(struct.pack('<h', s))def makedualtone(f1=440, f2=480, on=2.0, off=4.0, cycles=2, sr=8000):
 out = []
 for _ in range(cycles):
 onp = [(a+b)/2 for a,b in zip(sine(f1,on,sr), sine(f2,on,sr))]
 offp = [0.0]int(offsr)
 out.extend(onp + offp)
 return normalize(out)if name == "main":
 data = makedualtone()
 writewav(data, "ringtone.wav")</div>
 </div><!-- 6) Async Fetch (httpx + asyncio) -->
 <div class="py-card">
 <h3>Async Fetch at Scale</h3>
 <div class="py-badges"><span class="py-badge">Async</span><span class="py-badge">I/O</span><span class="py-badge">httpx</span></div>
 <div class="py-desc">Concurrent HTTP requests with timeouts—starter for scrapers and status.</div>
 <div class="py-code">import asyncio, httpxURLS = ["https://example.com", "https://httpbin.org/get"]async def fetch(url, client):
 r = await client.get(url, timeout=10)
 return url, r.status_codeasync def main():
 async with httpx.AsyncClient() as client:
 results = await asyncio.gather(*(fetch(u, client) for u in URLS))
 for url, status in results:
 print(url, status)if name == "main":
 asyncio.run(main())</div>
 </div></div>
 </div>
Nulla commodo
Suman Das
Contact me.