Skip to content

Instantly share code, notes, and snippets.

@fasionchan
fasionchan / libco.py
Created August 31, 2020 07:39
一个精简的Python协程库,才100来行代码!
import select
from collections import deque
from socket import socket, AF_INET, SOCK_STREAM, SOL_SOCKET, SO_REUSEADDR
def create_listen_socket(bind_addr='0.0.0.0', bind_port=55555, backlogs=102400):
sock = socket(AF_INET, SOCK_STREAM)
sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
sock.bind((bind_addr, bind_port))
sock.listen(backlogs)
@fasionchan
fasionchan / pyconsole.py
Last active May 17, 2023 03:40
Python 远程交互式终端
import code
import threading
import sys
from io import StringIO
from xmlrpc.client import ServerProxy
from xmlrpc.server import SimpleXMLRPCServer
class OutputHookContext:
@fasionchan
fasionchan / GFW-Rules-Surge.txt
Last active August 14, 2023 02:38
Surge configuration files
# AntiGFW
DOMAIN-SUFFIX,amysecure.com
DOMAIN-SUFFIX,justmysocks.net
# Chrome
DOMAIN-SUFFIX,chrome.
# Docker
# Facebook
@fasionchan
fasionchan / Makefile
Created February 12, 2022 09:43
Call C function in Go | Go语言调用C函数
.DEFAULT_GOAL := run
callee.o: callee.c
gcc -fPIC -c callee.c
libcallee.so: callee.o
gcc -shared -o $@ $^
caller: caller.go libcallee.so
go build caller.go