Skip to content

Instantly share code, notes, and snippets.

View mthri's full-sized avatar
🦄

Amir Motahari mthri

🦄
View GitHub Profile
@mthri
mthri / 00_README.md
Last active September 19, 2026 10:29
FastMCP + Django (ADRF): Single-Process ASGI Architecture

FastMCP + Django (ADRF) Integration via Starlette ASGI

A production-ready reference implementation demonstrating how to mount a FastMCP server alongside a Django (ADRF) backend on a single ASGI process using Starlette.

This setup allows AI agents (e.g., Cursor IDE, Claude Desktop) to interact directly with Django business logic, database models, and authentication layers without requiring separate backend services or complex reverse-proxy routing.


📺 Video Tutorial

@mthri
mthri / torob.py
Created July 27, 2026 10:35
Torob Product Tracker
"""
Scrape Torob API using curl_cffi to monitor product prices with Telegram and Bale alerts.
Installation:
pip install curl_cffi
Configuration:
Create a 'config.json' file in the same directory:
{
"bale_bot_token": "YOUR_BALE_TOKEN",
@mthri
mthri / smart_dns.py
Last active August 26, 2026 09:02
A smart DNS proxy script in Python using SOCKS5
"""
SOCKS5 DNS Proxy
================
**GUI VERSION IS HERE: https://github.com/mthri/smart-dns**
Description:
This script runs a local DNS server that acts as a proxy, selectively
routing DNS queries through any SOCKS5 proxy. It's a powerful tool for
enhancing DNS privacy and bypassing internet censorship or sanctions.
@mthri
mthri / divar_notifier.py
Created May 9, 2025 11:45
Divar to Telegram Notifier Bot
"""
Divar to Telegram Notifier Bot
This script monitors a filtered Divar page and sends newly posted items to a specified Telegram channel every 60 seconds.
Setup Instructions:
1. Create a Telegram bot using BotFather.
2. Add the bot to your Telegram group or channel.
3. Promote the bot as an admin in your channel so it can post messages.
4. Use @username_to_id_bot to get the numeric ID of your channel (e.g., -1001234567890).
@mthri
mthri / exception.py
Created November 9, 2024 11:15
Python Decorator for Exception Logging and Telegram Notifications
from functools import wraps
import logging
import time
import requests
logger = logging.getLogger(__name__)
TELEGRAM_NOTIFICATION_BOT = 'YOUR_TELEGRAM_NOTIFICATION_BOT'
TELEGRAM_NOTIFICATION_CHANNEL_ID = 'YOUR_TELEGRAM_NOTIFICATION_CHANNEL_ID'
@mthri
mthri / settings.py
Created September 24, 2024 11:48
print sql query in django
import os
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
},
'file': {
@mthri
mthri / prompt.MD
Created August 10, 2024 13:51
ChatGPT4o initial prompt

You are ChatGPT, a large language model trained by OpenAI, based on the GPT-4 architecture. Knowledge cutoff: 2023-10 Current date: 2024-07-29

Image input capabilities: Enabled Personality: v2

Tools

bio

@mthri
mthri / main.py
Created June 4, 2024 12:51
URL Extractor: Sniffing HTTP and HTTPS Traffic with Scapy
from scapy.all import sniff, IP, TCP, Raw
def extract_http_url(packet):
"""Extracts and prints HTTP URL from the packet"""
if packet.haslayer(Raw):
try:
http_payload = packet[Raw].load.decode('utf-8')
if "Host:" in http_payload:
headers = http_payload.split("\r\n")
@mthri
mthri / verify.py
Created May 12, 2024 11:39
Extracting and Verifying Telegram Web App Data in Python
import hashlib
import hmac
TELEGRAM_BOT_TOKEN = 'BOT_TOKEN
def extract_telegram_web_app_data(telegram_init_data: str) -> dict:
return dict(qc.split('=') for qc in telegram_init_data.split('&'))
def verify_telegram_web_app_data(telegram_init_data: str) -> bool:
@mthri
mthri / import_export.MD
Last active February 1, 2024 23:20
export and import from PostgreSQL with pg_dump

Export

pg_dump -h HOST -p PORT -U DBUSER -W -d DBNAME > bak.sql

Import

pg_dump -h HOST -p PORT -U DBUSER -W -d NEWDBNAME < bak.sql
or