Skip to content

Instantly share code, notes, and snippets.

View zthxxx's full-sized avatar
🐾
Nyaa~

zthxxx zthxxx

🐾
Nyaa~
View GitHub Profile
import {
AsyncLocalStorage,
} from 'node:async_hooks'
import {
IterableWeakSet,
} from './IterableWeakSet'
/**
* Basic implementation of tc39 Stage 2 [Async Context](https://github.com/tc39/proposal-async-context)
*
/**
* Allows arbitrary level property access and callable,
* support mock with usage likes:
* ```
* faker = new FakeClass()
* faker.xxxx()
*
* faker()
*

Rewrite "import then re-export" to a direct "re-export" approach via ast-grep.

Rule file see in file-import-to-export.yml

Preview Effect

- import Form, {
+ export {
@zthxxx
zthxxx / hammerspoon.init.lua
Last active July 12, 2023 15:35
My Hammerspoon config
function shell(command)
ok, result = hs.osascript.applescript(string.format('do shell script "%s"', command))
return result
end
function sleep(n)
os.execute('sleep ' .. tonumber(n))
end
-- https://github.com/smudge/nightlight
@zthxxx
zthxxx / tmux.conf
Last active June 17, 2024 03:33
My tmux config, migrate from gnu screen config via ChatGPT
# ~/.config/tmux/tmux.conf
# https://quickref.me/tmux
# https://man7.org/linux/man-pages/man1/tmux.1.html
# Install
#
# ```bash
# mkdir -p ~/.config/tmux
# curl -sL https://gist.github.com/zthxxx/bbbb37c100254d688236c21e8b977b85/raw/tmux.conf -o ~/.config/tmux/tmux.conf
# ```
# https://code.visualstudio.com/docs/editor/command-line#_working-with-extensions
# code --list-extensions
code --uninstall-extension cduruk.thrift
code --uninstall-extension byted-sec.bytesec-vscode
code --uninstall-extension byted-ide.ppe-debug
code --uninstall-extension byted-ide.ftt
code --uninstall-extension byted-ide.cloud-dev-task
code --uninstall-extension byted-ide.cloud-dev-debug
code --install-extension shalldie.background
@zthxxx
zthxxx / .lunar-vim-install.sh
Last active November 26, 2023 06:38
installation for LunarVim
# https://www.lunarvim.org/
# https://www.lunarvim.org/docs/installation
brew install neovim rust
brew install --cask homebrew/cask-fonts/font-hack-nerd-font
# on linux without homebrew, install with AppImage
# apt install -y libfuse2
curl -fsSL https://github.com/neovim/neovim/releases/download/stable/nvim.appimage -o /usr/local/bin/nvim
chmod +x /usr/local/bin/nvim
import path from 'path'
import { spawn } from 'child_process'
import { promises as fs } from 'fs'
import readline from 'readline'
import { chunk } from 'lodash-es'
/**
* usage:
* tsx <path>/.sources.mts <target dir>
*/
@zthxxx
zthxxx / .deps.mts
Last active August 29, 2022 07:27
some scripts for analysis dependency graph from entry, with result of dependency-cruiser
import path from 'path'
import { argv, fs } from 'zx'
import type { IModule } from 'dependency-cruiser'
import {
keyBy,
} from 'lodash-es'
/**
* depcruise -p -c dependency-cruiser.config.js --output-type json src > .logs/depcruise/src.json
*/
@zthxxx
zthxxx / comb-import.mts
Last active July 27, 2022 15:00
梳理代码依赖项
/**
* download command:
* curl -O https://gist.githubusercontent.com/zthxxx/6306cab0615df6c0545bbc4fb07179dc/raw/comb-import.mts
*/
import path from 'path'
import os from 'os'
import { $, argv, fs } from 'zx'