Skip to content

Instantly share code, notes, and snippets.

View Ashkar-m's full-sized avatar

Muhammed Ashkar m Ashkar-m

View GitHub Profile
"""
Post Lookup — JSONPlaceholder API
====================================
API : https://jsonplaceholder.typicode.com (free, no key, never goes down)
Endpoint: GET /posts/{id} — fetch a single post by ID (1 to 100)
Clean JSON output (4 fields):
{ "status": 200, "post_id": int, "title": str,
"body": str, "user_id": int }
def find_unique_pairs(arr, target):
if not isinstance(target, (int, float)):
raise TypeError(f"Target must be a numeric value, got {type(target).__name__!r}")
if not isinstance(arr, (list, tuple, set)):
raise TypeError(f"Input must be a valid list or array, got {type(arr).__name__!r}")
clean_arr = [x for x in arr if isinstance(x, (int, float)) and not isinstance(x, bool)]
if len(clean_arr) < 2:
return []
seen = set()
result_pairs = set()
@Ashkar-m
Ashkar-m / rate_limiter.py
Last active April 22, 2026 11:54
Assesment
"""
Rate Limiter — Event Log Deduplicator
======================================
For each userId, an event is ALLOWED only if the same user
has not had an allowed event within the last `window` seconds.
Comparison is always against the last ALLOWED event, not blocked ones.
"""
import warnings