Skip to content

Instantly share code, notes, and snippets.

View Wxh16144's full-sized avatar
✡️

𝑾𝒖𝒙𝒉 Wxh16144

✡️
View GitHub Profile
@Wxh16144
Wxh16144 / scroll-spy-demo.tsx
Created November 12, 2025 05:31
基于 React 和 react-intersection-observer 实现的滚动监听(Scroll Spy)组件示例,支持菜单与内容区块的联动高亮
import React, { useRef, useState, useContext, createContext, useCallback, useMemo } from "react";
import { useInView } from "react-intersection-observer";
// 1. Create a single context to hold everything
type SpyContextValue = {
root: HTMLElement | null;
onRatioChange: (key: string, ratio: number) => void;
};
const SpyContext = createContext<SpyContextValue>({
@Wxh16144
Wxh16144 / nvm-clean-major.sh
Created August 27, 2025 04:36
清理 nvm 已安装 Node.js 版本,只保留每个 major 版本的最新版本(macOS bash)
#!/bin/bash
# nvm-clean-major: 清理 nvm 已安装 Node.js 版本,只保留每个 major 版本的最新版本
# 仅在 macOS + bash 环境下测试通过
RED="\033[31;1m"
GREEN="\033[32;1m"
YELLOW="\033[33;1m"
RESET="\033[0m"
function clean_nvm_versions() {
@Wxh16144
Wxh16144 / index.html
Created August 13, 2025 03:19
全球时区对照工具
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>全球时区对照工具</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<style>
* {
margin: 0;
@Wxh16144
Wxh16144 / main.js
Created August 8, 2025 10:35
Node.js tmp Module Learning - Temporary File Auto-cleanup Demo
const tmp = require('tmp');
const fse = require('fs-extra');
const path = require('path');
const dir = tmp.dirSync({
prefix: path.basename(path.dirname(__filename))
});
console.log(`Temporary directory created: ${dir.name}`);
@Wxh16144
Wxh16144 / CombinatoricsKit.ts
Created July 23, 2025 08:35
CombinatoricsKit 排列、组合、全排列与笛卡尔积工具类 (TypeScript)
/**
* 集合操作工具类
* 支持排列、组合、笛卡尔积和全排列操作
*/
class CombinatoricsKit<T> {
private elements: T[];
// #region 构造函数
/**
* 构造函数
@Wxh16144
Wxh16144 / view-antd-token.tsx
Created July 16, 2025 07:44
可视化 Ant Design Token
import { Typography, List, theme } from "antd";
import { FastColor } from "@ant-design/fast-color";
import { createGlobalStyle, ThemeProvider, type ThemeMode } from "antd-style";
import { NuqsAdapter } from "nuqs/adapters/react";
import type { PropsWithChildren } from "react";
import { parseAsStringEnum, useQueryState } from "nuqs";
export const setupInstructions = `
# Create a new directory for your project
mkdir hi-antd-token && cd hi-antd-token
@Wxh16144
Wxh16144 / chrome-ext-bisect.js
Created July 10, 2025 03:32
Chrome 扩展二分诊断工具
const fs = require('fs');
const path = require('path');
const os = require('os');
const BACKUP_DIR = path.join(os.homedir(), 'chrome-extensions-backup');
// 获取Chrome扩展目录路径
function getChromeExtensionsPath() {
const platform = os.platform();
const homedir = os.homedir();
@Wxh16144
Wxh16144 / App.tsx
Created March 26, 2025 09:49
贝塞尔曲线可视化
import React, { useEffect, useRef, useState } from 'react';
import { Flexbox } from 'react-layout-kit';
interface BezierVisualizerProps {
controls: [number, number, number, number]; // [x1, y1, x2, y2]
width?: number;
height?: number;
}
const BezierVisualizer: React.FC<BezierVisualizerProps> = ({
@Wxh16144
Wxh16144 / re.tsx
Created December 13, 2024 10:13
try-reselect [REDUX]
import React from "react";
import { createSelector, createSelectorCreator, lruMemoize, weakMapMemoize } from 'reselect'
import { shallowEqual } from 'react-redux'
import fastDeepEqual from 'fast-deep-equal'
const createSelector2 = createSelectorCreator(
lruMemoize,
// fastDeepEqual
{
@Wxh16144
Wxh16144 / local-visual-setup.sh
Last active November 1, 2024 04:14
Ant Design 视觉回归--本地对比脚本
#!/bin/bash
#
# 一键本地运行视觉回归测试
#
# 前置条件:
# 1. 安装 GitHub CLI // brew install gh
# 使用方法:
# 1. 进入 ant-design 仓库目录
# 2. 执行 npm run test:image 生成本地视觉回归快照