Skip to content

Instantly share code, notes, and snippets.

@5j9
5j9 / one_month_returns_of_iranian_silver_etfs.py
Last active September 10, 2026 07:53
Calculate one-month returns of Iranian silver ETFs
# /// script
# requires-python = ">=3.14"
# dependencies = [
# "aiohttp",
# "jdatetime",
# "polars",
# "pydantic",
# "tsetmc",
# ]
# ///
@5j9
5j9 / project-zomboid-b42-copy-sandbox-settings.py
Last active September 12, 2026 15:32
Project Zomboid Copy map_sand.bin To Another Save
import shutil
from pathlib import Path
# ============================================================
# CONFIGURATION
# ============================================================
SAVES_DIR = Path(r'C:\Users\a\Zomboid\Saves\Sandbox')
@5j9
5j9 / Sync-TimeHttpAdaptive.ps1
Created January 25, 2026 20:18
PowerShell high-accuracy time synchronization script using HTTP headers (Google) to bypass restricted or blocked NTP/UDP 123 ports. Developed for system clock recovery during the Iran internet shutdowns of January 2026. Features dynamic outlier trimming and latency compensation.
# ==============================================================================
# SCRIPT NOTE:
# This script was developed to synchronize the system clock during the
# internet shutdowns in Iran in January 2026. During this period, NTP servers
# were restricted, and only a limited number of sites (like Google) were
# accessible. This script uses HTTP headers to bypass those restrictions.
#
# ACCURACY NOTE:
# Standard HTTP 'Date' headers only provide precision to the nearest second.
# While this script compensates for network latency (RTT/2), the base data
@5j9
5j9 / Fusion_StickyInput_Buffer.ahk
Created January 25, 2026 19:50
AutoHotkey v2 script for Fusion.exe: Emulates "Sticky Keys" for navigation (ASDQWE/Arrows) to maintain input states during paused frame-advance workflows. Includes a CapsLock toggle and status indicator.
/*
================================================================================
FUSION 3D FRAME-ADVANCE INPUT BUFFER
================================================================================
USAGE:
1. Press [Pause] to halt the simulation/emulation in Fusion.
2. Toggle [A,S,D,Q,W,E,Arrows] to set the desired movement/action state.
3. Use the [Insert] key to advance frame-by-frame.
(The keys will remain "digitally held" thanks to this script).
4. Toggle [CapsLock] to instantly release all keys and disable sticky mode.
@5j9
5j9 / Fix-Windows-DisplayPort-Resizing.ps1
Last active January 7, 2026 04:36
Automates the fix for Windows windows resizing/shrinking to the top-left corner after the monitor sleeps. Dynamically detects current resolution and applies it to the "Simulated" and "NOEDID" registry profiles under GraphicsDrivers.
# Run this script as Administrator to fix the "DisplayPort/Sleep Resizing" bug.
# It syncs your active resolution with the Windows 'Simulated' fallback profiles.
# Check for Administrator privileges
if (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "Please run this script as an Administrator!"
break
}
# 1. Get current screen resolution automatically
@5j9
5j9 / show_all_icons.py
Created August 15, 2025 17:28
PyQt6 List of Standard Icons
# A fork of https://joekuan.wordpress.com/2015/09/23/list-of-qt-icons/
# Modified to work with PyQt6 and also avoids using a hardcoded list.
# of icons.
from PyQt6.QtWidgets import (
QApplication,
QGridLayout,
QPushButton,
QStyle,
QWidget,
)
@5j9
5j9 / tg-link-handler-install.cmd
Last active November 3, 2025 12:12
telegram link default app handler installer/uninstaller .cmd
@5j9
5j9 / is_unique_time_complexity.py
Created November 27, 2024 02:53
time complexity of `pandas.DataFrame.index.is_unique` looks to be constant for unique index and linear for non-unique index
from timeit import timeit
import matplotlib.pyplot as plt
import pandas as pd
df = pd.DataFrame(range(10), columns=['A'])
times = []
lengths = []
for i in range(26):
# بیشترین بازده درصدی فصلی برای زمستان سال 1401 مربوط به کدام سبد دارایی زیر بوده است؟
# https://bashgah.com/Question/140201029/
from asyncio import run
from tsetmc.instruments import Instrument
from iranetf.sites import RayanHamafza
from iranetf import Session as IranETFSession
from tsetmc import Session
from jdatetime import date
import pandas as pd
# بیشترین بازده درصدی فصلی برای تابستان سال 1401 مربوط به کدام سبد دارایی زیر بوده است؟
# https://bashgah.com/Question/140201027/
from asyncio import run
from tsetmc.instruments import Instrument
from iranetf.sites import RayanHamafza
from iranetf import Session as IranETFSession
from tsetmc import Session
from jdatetime import date
import pandas as pd