Skip to content

Instantly share code, notes, and snippets.

View RainMark's full-sized avatar

RainMark

View GitHub Profile
@dmfigol
dmfigol / asyncio_loop_in_thread.py
Last active April 24, 2025 03:57
Python asyncio event loop in a separate thread
"""
This gist shows how to run asyncio loop in a separate thread.
It could be useful if you want to mix sync and async code together.
Python 3.7+
"""
import asyncio
from datetime import datetime
from threading import Thread
from typing import Tuple, List, Iterable
@darkr4y
darkr4y / httpsrv.py
Last active November 13, 2024 15:18
python simple http server with upload & download
#!/usr/bin/env python
"""Extend Python's built in HTTP server to save files
curl or wget can be used to send files with options similar to the following
curl -X PUT --upload-file somefile.txt http://localhost:8000
wget -O- --method=PUT --body-file=somefile.txt http://localhost:8000/somefile.txt
__Note__: curl automatically appends the filename onto the end of the URL so
@toke
toke / anybind_aio.py
Created January 28, 2020 13:06
Using TPROXY to bind to any port on many IPs (asyncio variant)
import asyncio
import socket
BIND_IP = "127.0.0.1"
TCP_PORT = 1234
SOCK_BACKLOG = 32
IP_TRANSPARENT = 19
desc = f"""
Anybind; "bind" on many IPs and many Ports.
@antonfirsov
antonfirsov / install-liburing.sh
Last active January 26, 2022 00:49
Patch Ubuntu 18.04 LTS for io_uring
mkdir liburing
pushd liburing
git clone https://github.com/axboe/liburing.git
pushd liburing
./configure
make
sudo make install
popd
@algal
algal / colorize-emacs.bashsource
Last active March 28, 2025 16:15
Setting up truecolor (24 bit color) in emacs in the terminal, under iTerm2, blink.sh, and others.
# sourcing this file will define a bash functions that
# tries to run subsequent calls to emacs with 24 bit color.
#
# It sets TERM=xterm-emacs-leg if
# - we've created a user-local terminfo record for xterm-emacs-leg, and
# - we're using iTerm2 or something has set COLORTERM=truecolor
#
# This will cause emacs to use 24 bit color only when it will work,
# inside or outside of tmux. I haven't found a way to auto-detect Blink.sh yet.
#