Skip to content

Instantly share code, notes, and snippets.

View jerrylususu's full-sized avatar

Neko Null jerrylususu

View GitHub Profile
@jerrylususu
jerrylususu / select_mermaid.js
Created September 26, 2024 14:36
Render Mermaid diagrams from selected text
// ==UserScript==
// @name Mermaid Diagram Renderer
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Render Mermaid diagrams from selected text
// @author Claude
// @match *://*/*
// @require https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.14.0/mermaid.min.js
// @grant GM_addStyle
// ==/UserScript==
document.addEventListener('DOMContentLoaded', function() {
const c = document.getElementById("c");
if (!c) {
console.error("Canvas element with id 'c' not found");
return;
}
const ctx = c.getContext("2d");
if (!ctx) {
console.error("Unable to get 2D context for canvas");
@jerrylususu
jerrylususu / epoll_with_conn_pool.cpp
Last active August 28, 2024 15:57
custom tcp protocol client with conn pool by claude
// MyProtocol.h
#pragma once
#include <array>
#include <vector>
#include <string>
#include <memory>
#include <chrono>
#include <mutex>
@jerrylususu
jerrylususu / hack.js
Created August 19, 2024 15:35
hack element-ui DateTimePicker
javascript:(function() {
// 获取当前时间
var now = new Date();
var formattedTime = now.toISOString().slice(0, 16); // 格式化为 YYYY-MM-DDTHH:MM
// 找到 DateTimePicker 的 input 元素
var inputElement = document.querySelector('.el-date-editor input');
if (inputElement) {
// 模拟用户点击 input 元素
inputElement.click();
import os
import logging
import requests
import subprocess
from pathlib import Path
from datetime import datetime
import time
import json
import time
@jerrylususu
jerrylususu / base.cpp
Last active June 12, 2024 16:02
有namespace的宏替换
// 对于没有命名空间的变量
#define BUILD_MY_FUNC_SINGLE(name) Build##name##Processor()
// 对于有命名空间的变量
#define BUILD_MY_FUNC_NS(ns, name) Build##ns##name##Processor()
// 定义一个辅助宏,根据参数数量调用正确的宏
#define GET_MACRO(_1,_2,NAME,...) NAME
#define BUILD_MY_FUNC(...) GET_MACRO(__VA_ARGS__, BUILD_MY_FUNC_NS, BUILD_MY_FUNC_SINGLE)(__VA_ARGS__)
@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 / 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;