Skip to content

Instantly share code, notes, and snippets.

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

Aber abersheeran

👋
玉楼金阙慵归去,且插梅花醉洛阳
View GitHub Profile
@abersheeran
abersheeran / bbig_vip.js
Created May 24, 2024 08:02
领取 bilibili 大会员权益
function getCSRFToken() {
let bilijct = "";
document.cookie
.split(";")
.filter((cookie) => cookie.includes("bili_jct"))
.forEach((cookie) => {
const [name, value] = cookie.split("=");
bilijct = value;
});
return bilijct;
from __future__ import annotations
import html
import inspect
import os
import traceback
import typing
from baize.typing import WSGIApp, Environ, StartResponse, ExcInfo
from baize.wsgi import Request, Response, HTMLResponse, PlainTextResponse
@abersheeran
abersheeran / interpreters.py
Created March 12, 2024 02:59
Use interpreters module in python3.12
import _xxsubinterpreters
from typing import List
from inspect import cleandoc
SharedValue = int | float | bool | bytes | str | None | tuple["SharedValue", ...]
class Interpreter:
def __init__(self, id: int):
@abersheeran
abersheeran / merge_ip_range.py
Created February 29, 2024 08:40
Merge ip range to ip network list
import ipaddress
def ip_range(
start_ip: ipaddress.IPv4Address, end_ip: ipaddress.IPv4Address
) -> list[ipaddress.IPv4Network]:
if start_ip > end_ip:
raise ValueError("Start IP must be less than end IP")
res = []
@abersheeran
abersheeran / writecache.py
Created October 31, 2023 05:57
Write after timing or accumulation.
import abc
import threading
from typing import Any
class WriteCache(metaclass=abc.ABCMeta):
def __init__(self, max_size: int = 100, min_time: float = 1) -> None:
self.max_size = max_size
self.min_time = min_time
@abersheeran
abersheeran / multiworker.py
Last active May 11, 2024 06:36
Python:在多个进程中分别使用线程池处理任务
from concurrent.futures import ThreadPoolExecutor
import gc
import multiprocessing
import queue
import signal
import threading
import time
from typing import Callable, ParamSpec
from loguru import logger
@abersheeran
abersheeran / llama2-2-7b-chat-int8-worker.js
Last active December 5, 2023 06:02
llama2-2-7b-chat-int8 in Cloudflare workers
import { Ai } from './vendor/@cloudflare/ai.js';
export default {
async fetch(request, env) {
const ai = new Ai(env.AI);
// prompt - simple completion style input
// let simple = {
// prompt: 'Tell me a joke about Cloudflare'
// };
from __future__ import annotations
import html
import inspect
import os
import traceback
from baize.typing import ASGIApp, Message, Receive, Scope, Send
from baize.asgi import Request, Response, HTMLResponse, PlainTextResponse
@abersheeran
abersheeran / youtube.yaml
Created August 25, 2022 07:09
给 Clash Pro 用的 youtube 列表
payload:
- '+.youtube.be'
- '+.youtube.ch'
- '+.youtube.co'
- '+.youtube.co.id'
- '+.youtube.com'
- '+.youtube.com.bd'
- '+.youtube.com.co'
- '+.youtube.com.do'
- '+.youtube.com.ee'
[Unit]
Description=Visual Studio Code Server
After=network.target
[Service]
Type=exec
Restart=always
User=%i
ExecStart=dbus-run-session -- sh -c "(echo 'somecredstorepass' | gnome-keyring-daemon --unlock) && /usr/local/bin/code-server serve-local --accept-server-license-terms --connection-token=somecredstorepass"