Skip to content

Instantly share code, notes, and snippets.

View Wxh16144's full-sized avatar
✡️

𝑾𝒖𝒙𝒉 Wxh16144

✡️
View GitHub Profile
@Wxh16144
Wxh16144 / server.js
Created August 20, 2026 06:34
one URL, two content types — a live HTML page for humans, plain JSON for machines (curl / uptime monitors / CI probes).
// ============================================================================
// Health endpoint: one URL, two content types — a live HTML page for humans,
// plain JSON for machines (curl / uptime monitors / CI probes).
//
// Why this pattern is neat:
// - ONE route, no separate /health and /health/ui. Content negotiation
// decides what the client gets based on the Accept header.
// - The browser gets a page that ticks in real time WITHOUT polling:
// the server injects the initial uptime once, then the client
// accumulates locally on requestAnimationFrame (smooth 60fps).
@Wxh16144
Wxh16144 / wechat_verify.py
Last active August 13, 2026 03:27
微信公众号 API 最小验证脚本
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
微信公众号 API 最小验证脚本 (单文件 / 零第三方依赖 / 直接运行)
功能:
GET /health 健康检查: 返回 ok, 用于确认服务是否启动成功
GET /wechat 服务器配置验证: 校验 signature 后原样返回 echostr
POST /wechat 消息回调(安全模式): 验签 -> AES-256-CBC 解密 -> 解析消息
-> 组织被动回复 -> 加密返回; 无需回复时返回 success
@Wxh16144
Wxh16144 / fill_icloud.sh
Created May 5, 2026 11:06
iCloud 占用脚本 (iCloud Storage Filler)
#!/bin/bash
# Colors
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
RED='\033[0;31m'
NC='\033[0m' # No Color
# Log helpers
@Wxh16144
Wxh16144 / no-use-effect.md
Created March 19, 2026 07:36 — forked from alvinsng/no-use-effect.md
Skill generated by Factory Droid
name no-use-effect
description Enforce the no-useEffect rule when writing or reviewing React code. ACTIVATE when writing React components, refactoring existing useEffect calls, reviewing PRs with useEffect, or when an agent adds useEffect "just in case." Provides the five replacement patterns and the useMountEffect escape hatch.

No useEffect

@Wxh16144
Wxh16144 / auto-update-repos.sh
Last active March 3, 2026 09:46
Auto Update Repos Script
#!/bin/bash
# 配置:定义仓库路径,格式为 "路径|分支|命令"
# - 分支:可选。指定要拉取的分支,如 "main" 或 "develop"。留空则使用当前检出的分支。
# - 命令:可选。pull 成功后执行的命令。
#
# 示例:
# "path/to/repo|main|npm install" -> 强制 main 分支,执行 npm install
# "path/to/repo||npm install" -> 跟随当前分支,执行 npm install
# "path/to/repo|develop" -> 强制 develop 分支,无后续命令
@Wxh16144
Wxh16144 / gitlab.contribution.js
Last active February 12, 2026 10:09
GitLab 贡献热力图生成器 (Contribution Graph)
/**
* GitLab 贡献热力图生成器 (Contribution Graph)
*
* 1. 必填配置:修改下方 `GITLAB_CONFIG` (GitLab地址, Token, 目标用户)。
* 2. 运行脚本:node gitlab-contribution.js
* // or envx run -f .env -- node gitlab-contribution.js
*/
const http = require('http');
@Wxh16144
Wxh16144 / app.js
Created January 7, 2026 07:04
SSE Demo Server
const http = require('http');
let lastPostData = '';
const clients = new Set();
const server = http.createServer((req, res) => {
if (req.method === 'POST' && req.url.startsWith('/')) {
// 解析 query 参数 interval
const url = require('url');
const parsedUrl = url.parse(req.url, true);
@Wxh16144
Wxh16144 / App.tsx
Created December 19, 2025 10:35
Ant Design Modal Animation
import { Button, ConfigProvider, Modal } from "antd";
import React, { useEffect, useState } from "react";
import 'animate.css';
import clsx from "clsx";
// 动画持续时间
const ENTRY_DURATION = 800;
const EXIT_DURATION = 600;
const App = () => {
@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() {