Skip to content

Instantly share code, notes, and snippets.

View abersheeran's full-sized avatar
👋
玉楼金阙慵归去,且插梅花醉洛阳

Aber abersheeran

👋
玉楼金阙慵归去,且插梅花醉洛阳
View GitHub Profile
@abersheeran
abersheeran / init.wsl
Created June 27, 2020 20:09
Auto run wsl script on Windows10 startup
/etc/init.d/supervisor $1
@abersheeran
abersheeran / get-cn-ipv4.sh
Last active March 22, 2024 06:38
Chinese IPv4
wget -c http://ftp.apnic.net/stats/apnic/delegated-apnic-latest
cat delegated-apnic-latest | awk -F '|' '/CN/&&/ipv4/ {print $4 "/" 32-log($5)/log(2)}' | cat > ip.txt
@abersheeran
abersheeran / headers.py
Last active June 14, 2020 15:26
get fake User-Agent in desktop or moblie
import random
DESKTOP_USER_AGENT = [
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
"Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)",
"Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.35; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
"Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)",
"Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)",
"Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
"Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)",
@abersheeran
abersheeran / echo.py
Last active March 24, 2020 08:20
get UDP address by asyncio
import sys
import asyncio
import typing
import logging
import signal
from socket import AF_INET, AF_INET6, inet_pton
try:
import uvloop
@abersheeran
abersheeran / getdocker.sh
Created February 8, 2020 08:04
阿里云服务器中一键安装 docker
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
import asyncio
from asyncio import AbstractEventLoop, Task, Future
from typing import Set, Optional, Coroutine
def onlyfirst(*coros: Coroutine, loop: Optional[AbstractEventLoop] = None) -> Future:
"""
Execute multiple coroutines concurrently, returning only the results of the first execution.
When one is completed, the execution of other coroutines will be canceled.
"""
@abersheeran
abersheeran / websocks.conf
Created December 12, 2019 10:15
Nginx 反向代理 websocket
server {
listen 443 ssl;
server_name websocks;
root html;
ssl_certificate /path/to/websocks.pem;
ssl_certificate_key /path/to/websocks.key;
ssl_session_timeout 5m;
location / {
@abersheeran
abersheeran / settings
Last active July 9, 2021 06:25
Windows Terminal settings
{
"$schema": "https://aka.ms/terminal-profiles-schema",
// Add custom actions and keybindings to this array.
// To unbind a key combination from your defaults.json, set the command to "unbound".
// To learn more about actions and keybindings, visit https://aka.ms/terminal-keybindings
"actions":
[
// Copy and paste are bound to Ctrl+Shift+C and Ctrl+Shift+V in your defaults.json.
// These two lines additionally bind them to Ctrl+C and Ctrl+V.
// To learn more about selection, visit https://aka.ms/terminal-selection
@abersheeran
abersheeran / currying.py
Created October 20, 2019 10:01
currying in Python
import typing
import inspect
import functools
def currying(func: typing.Callable) -> typing.Callable:
f = func
if inspect.ismethod(func):
partial = functools.partialmethod
@abersheeran
abersheeran / httpserver.py
Last active January 21, 2020 07:39
httpserver.py base on asyncio
import sys
import socket
import asyncio
import typing
import signal
import logging
import logging.config
from http import HTTPStatus
logger: logging.Logger = logging.getLogger("httpserver")