This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // preview.js | |
| // @from https://www.thenodebook.com/blog/fast-nodejs-doing-less#where-it-ended-up | |
| import * as cheerio from 'cheerio'; | |
| const OK_TTL = 60 * 60 * 1000; // 1 hour | |
| const FAILURE_TTL = 60 * 1000; // 1 minute | |
| const TIMEOUT = 4000; | |
| const MAX_HEAD_BYTES = 512 * 1024; | |
| class LRU { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Next = () => Promise<void> | void; | |
| type Middleware = (ctx: any, next: Next) => Promise<void> | void; | |
| class Koa { | |
| #middlewares: Middleware[] = []; | |
| use(middleware: Middleware) { | |
| this.#middlewares.push(middleware); | |
| return this; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| type Middleware = (next: (err?: unknown) => void) => void | Promise<void> | |
| function express() { | |
| const middlewares: Middleware[] = [] | |
| return { | |
| use(fn: Middleware) { | |
| middlewares.push(fn) | |
| return this | |
| }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 公开仓库的 PAT 即可,无任何敏感权限,仅用于提高 GitHub API 速率限制 | |
| # 将本文件内容放到 ~/.bashrc 或者 ~/.zshrc 即可通过 `repo vikiboss/60s` 快速查询仓库大小等信息 | |
| # Public-repo-only PAT for higher API rate limits. | |
| export GITHUB_RATE_LIMIT_PAT="github_pat_xxx" | |
| # size(KB)转可读字符串 | |
| _repo_size() { | |
| local kb=$1 | |
| if (( kb < 1024 )); then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 设置 Dock 自动隐藏动画时间为 0.3 秒 | |
| defaults write com.apple.dock autohide-time-modifier -float 0.3 | |
| # 设置 Dock 自动隐藏延迟为 0 秒(立即隐藏) | |
| defaults write com.apple.dock autohide-delay -float 0 | |
| # 重启 Dock 使设置生效 | |
| killall Dock |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function When<T>(props: { | |
| condition: T | |
| children?: React.ReactNode | ((data: NonNullable<T>) => React.ReactNode) | |
| fallback?: React.ReactNode | |
| }) { | |
| const { condition, children, fallback } = props | |
| if (condition) { | |
| if (typeof children === 'function') { | |
| return children?.(condition) ?? null |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function isObject(obj: unknown): obj is Record<string, unknown> { | |
| return typeof obj === 'object' && obj !== null | |
| } | |
| export function deepClone<T>(obj: T, cache: Map<unknown, unknown> = new Map()): T { | |
| if (obj === null || typeof obj !== 'object') { | |
| return obj | |
| } | |
| if (cache.has(obj)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // const prompt = '请扮演 QQ 群内拥有海量知识储备的全能问答机器人。' | |
| const prompt = '哎呀,好无聊' | |
| ;(async () => { | |
| async function putAiChat(message: string = '') { | |
| const res = await fetch(`https://shu6.y.qq.com/cgi-bin/musicu.fcg`, { | |
| method: 'POST', | |
| body: JSON.stringify({ | |
| comm: { qq: 10000 }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface ProxyState { | |
| initialState: object | |
| getNotifyVersion: (nextVersion?: number) => number | |
| createSnapshot: <State extends object>(proxyState: State, version: number) => State | |
| addListener: (listener: (change: Change, nextVersion: number) => void) => () => void | |
| } | |
| const state2proxyCache = new WeakMap<object, object>() | |
| const proxy2proxyStateCache = new WeakMap<object, ProxyState>() | |
| const proxy2snapshotCache = new WeakMap<object, [version: number, snapshot: object]>() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { definePlugin, http } from 'kivibot' | |
| export default definePlugin({ | |
| name: 'sd', | |
| version: '1.0.0', | |
| setup(ctx) { | |
| ctx.handle('message', async (e) => { | |
| if (e.raw_message.startsWith('#sd ')) { | |
| const hasRight = ctx.isOwner(e) || ctx.isAdmin(e) |
NewerOlder