Skip to content

Instantly share code, notes, and snippets.

View vvanglro's full-sized avatar
💤

vvanglro vvanglro

💤
View GitHub Profile
@vvanglro
vvanglro / clash_example.yaml
Last active December 12, 2025 08:40
clashx meta config
proxy-providers:
provider1:
url: "xxx"
type: http
interval: 86400
# health-check: {enable: true,url: "https://www.gstatic.com/generate_204",interval: 300}
override:
additional-prefix: "[p1]"
provider2:
url: "xxx"
@rednafi
rednafi / __init__.py
Last active February 8, 2025 03:39
Log context propagation in Python ASGI apps. Details here: https://rednafi.com/python/log_context_propagation/
from svc import log # noqa
@lloesche
lloesche / multicoreserver.py
Created August 15, 2023 19:24
Python async server that uses multiple CPU cores while sharing a single socket.
#!/bin/env python3
import signal
import socket
import multiprocessing
import asyncio
import logging
import argparse
from threading import Event
from asyncio import StreamReader, StreamWriter
@jcrist
jcrist / bench.py
Last active November 28, 2025 12:30
A quick benchmark comparing msgspec (https://github.com/jcrist/msgspec), pydantic v1, and pydantic v2
"""A quick benchmark comparing the performance of:
- msgspec: https://github.com/jcrist/msgspec
- pydantic V1: https://docs.pydantic.dev/1.10/
- pydantic V2: https://docs.pydantic.dev/dev-v2/
The benchmark is modified from the one in the msgspec repo here:
https://github.com/jcrist/msgspec/blob/main/benchmarks/bench_validation.py
I make no claims that it's illustrative of all use cases. I wrote this up
@dmfigol
dmfigol / asyncio_loop_in_thread.py
Last active November 24, 2025 13:16
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
const findIP = (onNewIP) => { // onNewIp - your listener function for new IPs
// compatibility for firefox and chrome
const myPeerConnection = window.RTCPeerConnection ||
window.mozRTCPeerConnection ||
window.webkitRTCPeerConnection
const pc = new myPeerConnection({ iceServers: [] })
const noop = () => {}
const localIPs = {}
const ipRegex = /([0-9]{1,3}(\.[0-9]{1,3}){3}|[a-f0-9]{1,4}(:[a-f0-9]{1,4}){7})/g
@zziuni
zziuni / stuns
Created September 18, 2012 08:05
STUN server list
# source : http://code.google.com/p/natvpn/source/browse/trunk/stun_server_list
# A list of available STUN server.
stun.l.google.com:19302
stun1.l.google.com:19302
stun2.l.google.com:19302
stun3.l.google.com:19302
stun4.l.google.com:19302
stun01.sipphone.com
stun.ekiga.net