Skip to content

Instantly share code, notes, and snippets.

View MisaghM's full-sized avatar

Misagh Mohaghegh MisaghM

View GitHub Profile
@MisaghM
MisaghM / HttpServer.py
Created September 22, 2023 00:48
Sample HTTP server with Python standard library. With decoupled backend and rate limitter.
import sys
import time
from http import HTTPStatus
from http.server import HTTPServer, BaseHTTPRequestHandler
from urllib.parse import urlparse, parse_qs
from functools import cached_property, partial
IP = "127.0.0.1"
PORT = 18018
@MisaghM
MisaghM / BitcoinKey.py
Created September 13, 2023 17:59
Simple Bitcoin main and test network key generator.
import secrets
import hashlib
from enum import Enum
import ecdsa
import base58
class Key:
class Prefix(Enum):
@MisaghM
MisaghM / proxy.bat
Created October 1, 2022 14:12
A simple script to easily enable and disable your system proxy.
@ECHO OFF
SETLOCAL EnableExtensions DisableDelayedExpansion
REM This script sets and toggles your system proxy.
REM (Internet Explorer LAN proxy server)
REM Call the script with enable/disable/custom as the first command-line argument:
REM proxy.bat enable (use a proxy server for your LAN)
REM proxy.bat disable (uncheck use a proxy server for you LAN)
REM proxy.bat custom (set proxy server to the 'proxy' variable below)
REM Or just run the script to get a choice.
@MisaghM
MisaghM / array2d.hpp
Created August 23, 2022 20:57
Simple single allocation multidimensional arrays in C++
#ifndef ARRAY2D_HPP_INCLUDE
#define ARRAY2D_HPP_INCLUDE
#include <algorithm>
#include <cstddef>
template <class T>
class Array2D {
public:
// clang-format off
@MisaghM
MisaghM / dns.bat
Last active September 30, 2022 18:53
A simple script to easily enable and disable DNS.
@ECHO OFF
SETLOCAL EnableExtensions DisableDelayedExpansion
REM This script will (de)activate a statically configured DNS server for a network interface.
REM Call the script with enable/disable as the first command-line argument:
REM dns.bat enable (set static DNS server)
REM dns.bat disable (obtain DNS server automatically [DHCP])
REM Or just run the script to get a choice.
REM Additionally, you can use the second argument to set which interface to change.
REM Use `netsh interface show interface` to check your interface names.
@MisaghM
MisaghM / DelNetworkProfiles.py
Created August 8, 2022 17:11
Reset USB tethering network number.
"""
Reset USB tethering network number.
Removes the network profiles made by tethering each time.
Requires administrative privileges.
"""
import winreg
import re
@MisaghM
MisaghM / Upgrade-All-Pip-Packages.md
Created March 7, 2022 15:45
One-liners to upgrade all pip packages.

Upgrade All Pip Packages

pip install -U pip
pip install -U setuptools

Batch

@MisaghM
MisaghM / VSCode-Quote-Swap-Snippet.md
Created March 7, 2022 15:41
Snippet to swap single and double quotes.

Add to global snippets. (command palette > configure user snippets)
Select the text you want, write QuoteSwap and enter/tab to apply.

"QuoteSwap": {
    "prefix": "QuoteSwap",
    "body": "${TM_SELECTED_TEXT/(')|(\")/${1:+\"}${2:+'}/g}",
    "description": "Swap single and double quotes."
}