Skip to content

Instantly share code, notes, and snippets.

View jerrylususu's full-sized avatar

Neko Null jerrylususu

View GitHub Profile
@jerrylususu
jerrylususu / copliot.ts
Created February 17, 2024 12:17
promise concurrency
type PromiseFunction<T> = () => Promise<T>;
type PromiseResult<T> = { status: 'fulfilled', value: T } | { status: 'rejected', reason: any };
async function allSettledWithConcurrency<T>(promises: PromiseFunction<T>[], concurrency: number): Promise<PromiseResult<T>[]> {
const results: PromiseResult<T>[] = new Array(promises.length);
let running = 0;
let index = 0;
return new Promise((resolve) => {
const enqueue = () => {
@jerrylususu
jerrylususu / utils.ahk
Last active December 3, 2023 04:19
Utils.ahk
; ====== IMPORTANT ======
; If you're using Windows with locale zh-CN, use **GBK** encoding, not UTF8
; Otherwise the notepad save script will not work!
; ====== IMPORTANT ======
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
@jerrylususu
jerrylususu / glm.py
Created October 29, 2023 11:24
glm to openai adapter
import json
from mitmproxy import http, ctx
from collections.abc import Iterable
import time
import jwt # pip install PyJWT / pipx inject mitmproxy PyJWT
import re
GLM_TOKEN = "[INSERT_YOUR_TOKEN]"
GLM_HOST = "open.bigmodel.cn"
@jerrylususu
jerrylususu / gym_wait_sim.py
Created October 22, 2023 13:05
gym_wait_sim.py
import numpy as np
import csv
from tqdm import tqdm
import seaborn as sns
import matplotlib.pyplot as plt
import pandas as pd
def simulate_wait_times(num_machines, num_simulations, mean, std_dev):
wait_times = []
@jerrylususu
jerrylususu / check_if_member_exist.cpp
Last active August 16, 2023 16:05
cpp check member exist
// should read
// https://hedzr.com/c++/algorithm/cxx-is_detected-and-detection-idioms
#include <iostream>
#include <type_traits>
#include <experimental/type_traits>
// AClass definition
class AClass {
public:
std::string dueDate;
mpv --no-video "https://www.youtube.com/watch?v=jfKfPfyJRdk" --script-opts=ytdl_hook-ytdl_path=yt-dlp.exe
@jerrylususu
jerrylususu / fib.js
Created July 29, 2023 13:22
es module worker
export function fibonacci(num) {
if (num <= 1) return num;
return fibonacci(num - 1) + fibonacci(num - 2);
}
@jerrylususu
jerrylususu / demo.html
Created December 18, 2021 16:53
Simple Dark Mode with CSS Filter `invert`
<!DOCTYPE html>
<html lang="cmn-Hans">
<head>
<meta charset="utf-8">
<title>Hello!</title>
<style id="dark-mode-theme" disabled>
html {
background-color: #ebebeb !important;
}
@jerrylususu
jerrylususu / gpt-stream.py
Created June 14, 2023 15:40
simple gpt streaming implementation (works as 2023/6/14)
import requests
import json
import sseclient
# API_KEY = 'sk-xxx'
def performRequestWithStreaming():
reqUrl = 'https://api.openai.com/v1/chat/completions'
reqHeaders = {
@jerrylususu
jerrylususu / demo.html
Created April 27, 2023 15:00
protobuf string to base64
<!DOCTYPE html>
<html>
<head>
<title>Base64 Encoder</title>
</head>
<body>
<textarea id="myTextArea" rows="10" cols="50"></textarea>
<br>
<button onclick="encodeText()">Encode to Base64</button>
<br>