Skip to content

Instantly share code, notes, and snippets.

@shivamMg
shivamMg / airline_api_swagger.json
Last active September 19, 2025 07:26
Airline and Retail API OpenAPI (Swagger) Specifications
{
"openapi": "3.0.3",
"info": {
"title": "Airline Tools API",
"version": "1.0.0"
},
"paths": {
"/reservations": {
"post": {
"operationId": "book_reservation",
@shivamMg
shivamMg / log_without_buffering.py
Created September 17, 2025 11:45
Python: Log everything, without buffering
import os, sys, logging
# 1) Disable Python’s stdout buffering
os.environ["PYTHONUNBUFFERED"] = "1"
try:
# Python 3.7+ lets you force line-buffering on stdout
sys.stdout.reconfigure(line_buffering=True)
except Exception:
pass
@shivamMg
shivamMg / author.py
Created August 28, 2025 03:26
python author variables
class _mail:
def __matmul__(self, other):
return "mail@" + other
def __str__(self):
return "mail"
mail = _mail()
@shivamMg
shivamMg / lru_catch_ttl.py
Created January 14, 2025 18:47
LRU Cache with TTL
import time
from datetime import datetime, timedelta
class Node:
def __init__(self, key, value, expiry):
self.key = key
self.value = value
self.expiry = expiry
self.next = None
print("Hello World")
Downloading https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz to ../data/cifar-10-python.tar.gz
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
0.0%
The future depends on what we do in the present
It’s easy to stand in the crowd but it takes courage to stand alone
Our greatest ability as humans is not to change the world, but to change ourselves
Service without humility is selfishness and egotism
It does not require money to live neat, clean, and dignified
My life is my message
Speak only if it improves upon the silence
Satisfaction lies in the effort, not in the attainment
Relationships are based on four principles: respect, understanding, acceptance and appreciation
Hate the sin, love the sinner
@shivamMg
shivamMg / poweroff.py
Created April 24, 2022 18:04
poweroff.py
#!/bin/env python3
from http.server import BaseHTTPRequestHandler, HTTPServer
import subprocess
HOST = '0.0.0.0'
PORT = 9000
HTML = '''
<html>
@shivamMg
shivamMg / dashboard.json
Created January 13, 2022 12:13
Rapyuta IO Spidermon
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
@shivamMg
shivamMg / dashboard.json
Last active January 13, 2022 12:20
Rapyuta IO Device Metrics
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",