| 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. |
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
| // ============================================================================ | |
| // 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). |
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
| #!/usr/bin/env python3 | |
| # -*- coding: utf-8 -*- | |
| """ | |
| 微信公众号 API 最小验证脚本 (单文件 / 零第三方依赖 / 直接运行) | |
| 功能: | |
| GET /health 健康检查: 返回 ok, 用于确认服务是否启动成功 | |
| GET /wechat 服务器配置验证: 校验 signature 后原样返回 echostr | |
| POST /wechat 消息回调(安全模式): 验签 -> AES-256-CBC 解密 -> 解析消息 | |
| -> 组织被动回复 -> 加密返回; 无需回复时返回 success |
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
| #!/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 |
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
| #!/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 分支,无后续命令 |
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
| /** | |
| * 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'); |
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 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); |
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 { 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 = () => { |
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 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>({ |
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
| #!/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() { |
NewerOlder