Skip to content

Instantly share code, notes, and snippets.

View esdmr's full-sized avatar

Saeed M Rad esdmr

View GitHub Profile
@esdmr
esdmr / merge.fish
Last active July 26, 2025 21:14
(Fish Script) Merge wine prefixes by symlinking similar files into a base directory
#!/usr/bin/env fish
set -g BASE_DIR (path resolve -- (status dirname))
set -g BASE_PROTON $BASE_DIR/shared
set -g BASE_WINE $BASE_DIR/shared_ge
set -g HELP_MESSAGE "\
Usage: merge.fish [-h|--help] [-d|--dry-run] [-v|--verbose]
[-u|--unmerge|-b <base>|--base=<base>] [-r|--recursive]
<prefix> [<prefixes...>]
@esdmr
esdmr / iran.pac
Created June 19, 2025 14:17
Iran PAC file
/**
* Iran PAC file.
* @copyright 2025 esdmr
* @license MIT
*/
function _nonIranURL(_url, _host) {
return 'SOCKS 127.0.0.1:9050';
}
@esdmr
esdmr / somebody.mjs
Last active June 16, 2025 11:22
tor 2-layer wrapper scripts
// … once told me the world is gonna roll me.
// @ts-check
import {createInterface} from 'node:readline';
import {spawn} from 'node:child_process';
import process from 'node:process';
import {setTimeout} from 'node:timers/promises';
import {writeFile, watch, readFile} from 'node:fs/promises';
const killSwitchPath = '/tmp/Tor.KillSwitch';
/** @type {Awaited<ReturnType<typeof spawnTor>> | undefined} */
@esdmr
esdmr / README.md
Last active June 15, 2025 22:56
Cloudflare PAC file

Cloudflare PAC file (Proxy Auto-Configuration)

Since Cloudflare is IP banned in most ISPs of Iran, this can be used to bypass it via a proxy. You likely have to modify the proxy URL in the _cloudflareURL function. You can also modify the _nonCloudflareURL function to run other PAC files.

@esdmr
esdmr / Dockerfile
Last active May 4, 2025 08:59
Containerized SOCKS5 Proxy for Invidious
FROM ubuntu@sha256:8e5c4f0285ecbb4ead070431d29b576a530d3166df73ec44affc1cd27555141b
RUN apt-get update && apt-get install -y iproute2
COPY tun2socks starttun /bin/
ENTRYPOINT [ "/bin/starttun" ]
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=1 CMD [ "/bin/starttun", "--health" ]
ENV SOCKS_PROXY=proxy:1080
@esdmr
esdmr / aria2vis.py
Created April 2, 2025 20:47
Aria2 Control File Visualizer
from dataclasses import dataclass
import sys
from typing import List
@dataclass
class InFlightPiece:
index: int
length: int
piece_bitfield: bytes
@esdmr
esdmr / inv-block.user.js
Last active May 23, 2025 18:38
Violentmonkey Userscript for Invidious Block Channels
// ==UserScript==
// @name Invidious Block Channels
// @namespace https://esdmr.ir
// @downloadURL https://gist.github.com/esdmr/035a6df74f9e1aebfcb0a43f48f696c1/raw
// @homepageURL https://gist.github.com/esdmr/035a6df74f9e1aebfcb0a43f48f696c1
// @match http*://localhost:3000/*
// @match http*://inv.nadeko.net/*
// @match http*://inv1.nadeko.net/*
// @match http*://inv2.nadeko.net/*
// @match http*://inv3.nadeko.net/*
@esdmr
esdmr / await-chain.ts
Last active February 1, 2025 19:01
JS/TS Await Chain Implementation
"use strict";
type ChainPromise<T> = Promise<T> & {
promise: Promise<T>;
[Symbol.asyncIterator](): AsyncGenerator<T>;
} & {
readonly [K in keyof T as K extends keyof Promise<T>
? never
: K]: ChainPromise<Awaited<T[K]>>;
} & (T extends (...args: infer P) => infer R
@esdmr
esdmr / exec.html
Created December 20, 2024 14:37
Stack Machine in HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
x-block,
x-jump-if,
x-jump,
@esdmr
esdmr / paginator.py
Created December 12, 2024 17:49
Split Inkscape SVG into printable A4 pages
from sys import argv, stderr
from typing import NamedTuple, SupportsIndex
from re import compile
from math import ceil
def n[T](v: T | None) -> T:
assert v is not None
return v