Skip to content

Instantly share code, notes, and snippets.

View rsp4jack's full-sized avatar
🕒
Awaiting

rsp4jack rsp4jack

🕒
Awaiting
  • 06:38 (UTC +08:00)
View GitHub Profile
@mentha
mentha / ppua.py
Last active November 27, 2022 11:12
proxy protocol v2 universal adapter
#!/usr/bin/env python3
from argparse import ArgumentParser
from collections import namedtuple
from contextlib import AsyncExitStack
from ipaddress import IPv4Address, IPv6Address, IPv4Network, IPv6Network
from signal import signal, SIGHUP, SIGINT, SIGTERM
from socket import socket, AF_INET, AF_INET6, SOCK_STREAM, IPPROTO_IP, IP_TRANSPARENT, SHUT_WR
import asyncio as aio
import logging
@Qix-
Qix- / coro.cpp
Created September 29, 2020 04:16
C++20 coroutines + LibUV sample, v2
// Thank you to the folks at the C++ slack channel,
// along with @lewissbaker for the excellent literature
// (even though it took me a few days to be convinced
// it really was so).
#include <uv.h>
#include <iostream>
#include <experimental/coroutine>
@Integralist
Integralist / Python Asyncio Timing Decorator.py
Last active June 30, 2024 09:27
Python Asyncio Timing Decorator
import asyncio
import time
def timeit(func):
async def process(func, *args, **params):
if asyncio.iscoroutinefunction(func):
print('this function is a coroutine: {}'.format(func.__name__))
return await func(*args, **params)
else: