[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"$fmCl2vPYxDxTFbdpvsAUtW5D6DncEcjTSdgpIE2_JnrY":3,"$fJU-4tot_gC5fDkujNeoE-cGsdMy5V_KcdUXLuAnTFgw":16,"$fHkT95bBSrf8pIOH2EfarqjzF7HxzeKJmw0cM1paEi4s":423},{"slug":4,"title":5,"description":6,"content":7,"content_html":8,"pub_date":9,"tags":10,"draft":15},"python-type-hints-guide","Python 类型注解完全指南：从入门到实践","Python 3.5+ 引入类型注解，配合 mypy\u002Fpyright 让 Python 也能享受静态类型检查的好处。","# Python 类型注解完全指南：从入门到实践\n\nPython 是动态类型语言，但从 3.5 开始引入了类型注解（Type Hints），配合 mypy 或 pyright，可以在不牺牲动态特性的前提下获得静态类型检查的好处。\n\n## 为什么要用类型注解\n\n1. **IDE 补全更智能**：VS Code \u002F PyCharm 能精准推断方法和属性\n2. **重构更安全**：改函数签名时工具帮你找到所有调用点\n3. **文档即代码**：类型注解就是最好的参数说明\n4. **提前发现 Bug**：mypy strict 模式能在运行前抓住大量错误\n\n```bash\n# 安装 mypy\npip install mypy\n\n# 检查文件\nmypy main.py\n\n# strict 模式（推荐）\nmypy --strict main.py\n```\n\n## 基础类型\n\n```python\n# 变量注解\nname: str = \"Alice\"\nage: int = 30\npi: float = 3.14\nactive: bool = True\nnothing: None = None\n\n# 函数注解\ndef greet(name: str) -> str:\n    return f\"Hello, {name}\"\n\ndef add(a: int, b: int) -> int:\n    return a + b\n\n# 无返回值\ndef log(msg: str) -> None:\n    print(msg)\n```\n\n## 容器类型\n\nPython 3.9+ 可以直接用内置类型，旧版本需要从 `typing` 导入。\n\n```python\nfrom typing import List, Dict, Tuple, Set  # Python 3.8 及以下\n\n# Python 3.9+ 写法（推荐）\ndef process(items: list[int]) -> dict[str, int]:\n    return {\"count\": len(items), \"sum\": sum(items)}\n\n# Tuple：固定长度\ndef get_point() -> tuple[int, int]:\n    return (1, 2)\n\n# Tuple：可变长度（同类型）\ndef get_scores() -> tuple[int, ...]:\n    return (90, 85, 92)\n\n# Set\ndef unique_tags(tags: list[str]) -> set[str]:\n    return set(tags)\n```\n\n## Python 3.10+ 新写法\n\n```python\n# Union 用 | 代替\ndef parse(value: str | int) -> str:\n    return str(value)\n\n# Optional[T] 等价于 T | None\ndef find_user(uid: int) -> str | None:\n    if uid == 1:\n        return \"Alice\"\n    return None\n\n# 旧写法（仍然有效）\nfrom typing import Optional, Union\ndef old_style(x: Optional[int]) -> Union[str, int]:\n    return x or 0\n```\n\n## TypedDict：给字典加类型\n\n```python\nfrom typing import TypedDict\n\nclass UserInfo(TypedDict):\n    name: str\n    age: int\n    email: str\n\nclass PartialUser(TypedDict, total=False):\n    name: str\n    age: int  # 可选字段\n\ndef create_user(info: UserInfo) -> str:\n    return f\"{info['name']} ({info['age']})\"\n\n# 使用\nuser: UserInfo = {\"name\": \"Bob\", \"age\": 25, \"email\": \"bob@example.com\"}\nprint(create_user(user))\n```\n\n## Protocol：结构化子类型\n\nProtocol 比 ABC 更灵活，不需要显式继承，只要\"鸭子类型\"匹配就行。\n\n```python\nfrom typing import Protocol\n\nclass Drawable(Protocol):\n    def draw(self) -> None: ...\n    def get_area(self) -> float: ...\n\nclass Circle:\n    def __init__(self, r: float):\n        self.r = r\n\n    def draw(self) -> None:\n        print(f\"Circle r={self.r}\")\n\n    def get_area(self) -> float:\n        return 3.14 * self.r ** 2\n\nclass Square:\n    def __init__(self, side: float):\n        self.side = side\n\n    def draw(self) -> None:\n        print(f\"Square side={self.side}\")\n\n    def get_area(self) -> float:\n        return self.side ** 2\n\n# Circle 和 Square 都没有继承 Drawable，但都满足 Protocol\ndef render(shape: Drawable) -> None:\n    shape.draw()\n    print(f\"Area: {shape.get_area():.2f}\")\n\nrender(Circle(5))   # OK\nrender(Square(4))   # OK\n```\n\n## TypeVar：泛型函数\n\n```python\nfrom typing import TypeVar\n\nT = TypeVar(\"T\")\n\ndef first(items: list[T]) -> T | None:\n    return items[0] if items else None\n\n# 带约束的 TypeVar\nNumber = TypeVar(\"Number\", int, float)\n\ndef double(x: Number) -> Number:\n    return x * 2\n\nprint(first([1, 2, 3]))       # 1，类型推断为 int\nprint(first([\"a\", \"b\"]))      # \"a\"，类型推断为 str\nprint(double(3))               # 6\nprint(double(2.5))             # 5.0\n```\n\n## dataclass + 类型注解\n\n```python\nfrom dataclasses import dataclass, field\nfrom typing import ClassVar\n\n@dataclass\nclass Product:\n    name: str\n    price: float\n    tags: list[str] = field(default_factory=list)\n    _id: int = field(default=0, repr=False)\n\n    # 类变量（不是实例字段）\n    category: ClassVar[str] = \"general\"\n\n    def discounted_price(self, pct: float) -> float:\n        return self.price * (1 - pct)\n\np = Product(\"Laptop\", 999.99, [\"tech\", \"computer\"])\nprint(p)\nprint(p.discounted_price(0.1))  # 899.991\n\n# frozen=True 让 dataclass 不可变\n@dataclass(frozen=True)\nclass Point:\n    x: float\n    y: float\n\npt = Point(1.0, 2.0)\n# pt.x = 3.0  # FrozenInstanceError\n```\n\n## mypy 配置\n\n在项目根目录创建 `mypy.ini` 或 `pyproject.toml`：\n\n```ini\n# mypy.ini\n[mypy]\npython_version = 3.12\nstrict = true\nwarn_return_any = true\nwarn_unused_configs = true\n```\n\n```toml\n# pyproject.toml\n[tool.mypy]\npython_version = \"3.12\"\nstrict = true\n```\n\n```bash\n# 运行 strict 检查\nmypy --strict src\u002F\n\n# 常见输出\n# error: Function is missing a return type annotation\n# error: Argument 1 to \"foo\" has incompatible type \"str\"; expected \"int\"\n```\n\n## 实际项目中的细节\n\n### py.typed 标记\n\n如果你发布了一个库，需要在包根目录放一个空的 `py.typed` 文件，告诉类型检查器这个包支持类型注解：\n\n```bash\ntouch mypackage\u002Fpy.typed\n```\n\n```toml\n# pyproject.toml\n[tool.setuptools.package-data]\nmypackage = [\"py.typed\"]\n```\n\n### type: ignore 注释\n\n遇到无法修复的类型错误（比如第三方库没有 stub），可以用 `# type: ignore` 抑制：\n\n```python\nimport untyped_lib  # type: ignore[import]\n\nresult = untyped_lib.do_something()  # type: ignore[no-any-return]\n```\n\n### cast：强制类型转换\n\n```python\nfrom typing import cast\n\nvalue: object = get_some_value()\n# 你确定它是 str，但类型推断不知道\ns = cast(str, value)\nprint(s.upper())\n```\n\n## 总结\n\n| 特性 | 场景 |\n|------|------|\n| 基础注解 | 所有函数参数\u002F返回值 |\n| TypedDict | 字典结构固定时 |\n| Protocol | 需要鸭子类型约束 |\n| TypeVar | 泛型函数\u002F类 |\n| dataclass | 数据容器类 |\n| mypy strict | 项目级别质量把控 |\n\n类型注解不是强制的，渐进式引入即可。从最重要的公共 API 开始加注解，逐步扩展到整个项目。\n","\u003Ch1>Python 类型注解完全指南：从入门到实践\u003C\u002Fh1>\n\u003Cp>Python 是动态类型语言，但从 3.5 开始引入了类型注解（Type Hints），配合 mypy 或 pyright，可以在不牺牲动态特性的前提下获得静态类型检查的好处。\u003C\u002Fp>\n\u003Ch2 id=\"为什么要用类型注解\">为什么要用类型注解\u003C\u002Fh2>\n\u003Col>\n\u003Cli>\u003Cstrong>IDE 补全更智能\u003C\u002Fstrong>：VS Code \u002F PyCharm 能精准推断方法和属性\u003C\u002Fli>\n\u003Cli>\u003Cstrong>重构更安全\u003C\u002Fstrong>：改函数签名时工具帮你找到所有调用点\u003C\u002Fli>\n\u003Cli>\u003Cstrong>文档即代码\u003C\u002Fstrong>：类型注解就是最好的参数说明\u003C\u002Fli>\n\u003Cli>\u003Cstrong>提前发现 Bug\u003C\u002Fstrong>：mypy strict 模式能在运行前抓住大量错误\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cpre>\u003Ccode class=\"language-bash\"># 安装 mypy\npip install mypy\n\n# 检查文件\nmypy main.py\n\n# strict 模式（推荐）\nmypy --strict main.py\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"基础类型\">基础类型\u003C\u002Fh2>\n\u003Cpre>\u003Ccode class=\"language-python\"># 变量注解\nname: str = &quot;Alice&quot;\nage: int = 30\npi: float = 3.14\nactive: bool = True\nnothing: None = None\n\n# 函数注解\ndef greet(name: str) -&gt; str:\n    return f&quot;Hello, {name}&quot;\n\ndef add(a: int, b: int) -&gt; int:\n    return a + b\n\n# 无返回值\ndef log(msg: str) -&gt; None:\n    print(msg)\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"容器类型\">容器类型\u003C\u002Fh2>\n\u003Cp>Python 3.9+ 可以直接用内置类型，旧版本需要从 \u003Ccode>typing\u003C\u002Fcode> 导入。\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-python\">from typing import List, Dict, Tuple, Set  # Python 3.8 及以下\n\n# Python 3.9+ 写法（推荐）\ndef process(items: list[int]) -&gt; dict[str, int]:\n    return {&quot;count&quot;: len(items), &quot;sum&quot;: sum(items)}\n\n# Tuple：固定长度\ndef get_point() -&gt; tuple[int, int]:\n    return (1, 2)\n\n# Tuple：可变长度（同类型）\ndef get_scores() -&gt; tuple[int, ...]:\n    return (90, 85, 92)\n\n# Set\ndef unique_tags(tags: list[str]) -&gt; set[str]:\n    return set(tags)\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"python-3-10-新写法\">Python 3.10+ 新写法\u003C\u002Fh2>\n\u003Cpre>\u003Ccode class=\"language-python\"># Union 用 | 代替\ndef parse(value: str | int) -&gt; str:\n    return str(value)\n\n# Optional[T] 等价于 T | None\ndef find_user(uid: int) -&gt; str | None:\n    if uid == 1:\n        return &quot;Alice&quot;\n    return None\n\n# 旧写法（仍然有效）\nfrom typing import Optional, Union\ndef old_style(x: Optional[int]) -&gt; Union[str, int]:\n    return x or 0\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"typeddict-给字典加类型\">TypedDict：给字典加类型\u003C\u002Fh2>\n\u003Cpre>\u003Ccode class=\"language-python\">from typing import TypedDict\n\nclass UserInfo(TypedDict):\n    name: str\n    age: int\n    email: str\n\nclass PartialUser(TypedDict, total=False):\n    name: str\n    age: int  # 可选字段\n\ndef create_user(info: UserInfo) -&gt; str:\n    return f&quot;{info['name']} ({info['age']})&quot;\n\n# 使用\nuser: UserInfo = {&quot;name&quot;: &quot;Bob&quot;, &quot;age&quot;: 25, &quot;email&quot;: &quot;bob@example.com&quot;}\nprint(create_user(user))\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"protocol-结构化子类型\">Protocol：结构化子类型\u003C\u002Fh2>\n\u003Cp>Protocol 比 ABC 更灵活，不需要显式继承，只要&quot;鸭子类型&quot;匹配就行。\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-python\">from typing import Protocol\n\nclass Drawable(Protocol):\n    def draw(self) -&gt; None: ...\n    def get_area(self) -&gt; float: ...\n\nclass Circle:\n    def __init__(self, r: float):\n        self.r = r\n\n    def draw(self) -&gt; None:\n        print(f&quot;Circle r={self.r}&quot;)\n\n    def get_area(self) -&gt; float:\n        return 3.14 * self.r ** 2\n\nclass Square:\n    def __init__(self, side: float):\n        self.side = side\n\n    def draw(self) -&gt; None:\n        print(f&quot;Square side={self.side}&quot;)\n\n    def get_area(self) -&gt; float:\n        return self.side ** 2\n\n# Circle 和 Square 都没有继承 Drawable，但都满足 Protocol\ndef render(shape: Drawable) -&gt; None:\n    shape.draw()\n    print(f&quot;Area: {shape.get_area():.2f}&quot;)\n\nrender(Circle(5))   # OK\nrender(Square(4))   # OK\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"typevar-泛型函数\">TypeVar：泛型函数\u003C\u002Fh2>\n\u003Cpre>\u003Ccode class=\"language-python\">from typing import TypeVar\n\nT = TypeVar(&quot;T&quot;)\n\ndef first(items: list[T]) -&gt; T | None:\n    return items[0] if items else None\n\n# 带约束的 TypeVar\nNumber = TypeVar(&quot;Number&quot;, int, float)\n\ndef double(x: Number) -&gt; Number:\n    return x * 2\n\nprint(first([1, 2, 3]))       # 1，类型推断为 int\nprint(first([&quot;a&quot;, &quot;b&quot;]))      # &quot;a&quot;，类型推断为 str\nprint(double(3))               # 6\nprint(double(2.5))             # 5.0\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"dataclass-类型注解\">dataclass + 类型注解\u003C\u002Fh2>\n\u003Cpre>\u003Ccode class=\"language-python\">from dataclasses import dataclass, field\nfrom typing import ClassVar\n\n@dataclass\nclass Product:\n    name: str\n    price: float\n    tags: list[str] = field(default_factory=list)\n    _id: int = field(default=0, repr=False)\n\n    # 类变量（不是实例字段）\n    category: ClassVar[str] = &quot;general&quot;\n\n    def discounted_price(self, pct: float) -&gt; float:\n        return self.price * (1 - pct)\n\np = Product(&quot;Laptop&quot;, 999.99, [&quot;tech&quot;, &quot;computer&quot;])\nprint(p)\nprint(p.discounted_price(0.1))  # 899.991\n\n# frozen=True 让 dataclass 不可变\n@dataclass(frozen=True)\nclass Point:\n    x: float\n    y: float\n\npt = Point(1.0, 2.0)\n# pt.x = 3.0  # FrozenInstanceError\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"mypy-配置\">mypy 配置\u003C\u002Fh2>\n\u003Cp>在项目根目录创建 \u003Ccode>mypy.ini\u003C\u002Fcode> 或 \u003Ccode>pyproject.toml\u003C\u002Fcode>：\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-ini\"># mypy.ini\n[mypy]\npython_version = 3.12\nstrict = true\nwarn_return_any = true\nwarn_unused_configs = true\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cpre>\u003Ccode class=\"language-toml\"># pyproject.toml\n[tool.mypy]\npython_version = &quot;3.12&quot;\nstrict = true\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cpre>\u003Ccode class=\"language-bash\"># 运行 strict 检查\nmypy --strict src\u002F\n\n# 常见输出\n# error: Function is missing a return type annotation\n# error: Argument 1 to &quot;foo&quot; has incompatible type &quot;str&quot;; expected &quot;int&quot;\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"实际项目中的细节\">实际项目中的细节\u003C\u002Fh2>\n\u003Ch3 id=\"py-typed-标记\">py.typed 标记\u003C\u002Fh3>\n\u003Cp>如果你发布了一个库，需要在包根目录放一个空的 \u003Ccode>py.typed\u003C\u002Fcode> 文件，告诉类型检查器这个包支持类型注解：\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-bash\">touch mypackage\u002Fpy.typed\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Cpre>\u003Ccode class=\"language-toml\"># pyproject.toml\n[tool.setuptools.package-data]\nmypackage = [&quot;py.typed&quot;]\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3 id=\"type-ignore-注释\">type: ignore 注释\u003C\u002Fh3>\n\u003Cp>遇到无法修复的类型错误（比如第三方库没有 stub），可以用 \u003Ccode># type: ignore\u003C\u002Fcode> 抑制：\u003C\u002Fp>\n\u003Cpre>\u003Ccode class=\"language-python\">import untyped_lib  # type: ignore[import]\n\nresult = untyped_lib.do_something()  # type: ignore[no-any-return]\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch3 id=\"cast-强制类型转换\">cast：强制类型转换\u003C\u002Fh3>\n\u003Cpre>\u003Ccode class=\"language-python\">from typing import cast\n\nvalue: object = get_some_value()\n# 你确定它是 str，但类型推断不知道\ns = cast(str, value)\nprint(s.upper())\n\u003C\u002Fcode>\u003C\u002Fpre>\n\u003Ch2 id=\"总结\">总结\u003C\u002Fh2>\n\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>特性\u003C\u002Fth>\n\u003Cth>场景\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>基础注解\u003C\u002Ftd>\n\u003Ctd>所有函数参数\u002F返回值\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>TypedDict\u003C\u002Ftd>\n\u003Ctd>字典结构固定时\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>Protocol\u003C\u002Ftd>\n\u003Ctd>需要鸭子类型约束\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>TypeVar\u003C\u002Ftd>\n\u003Ctd>泛型函数\u002F类\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>dataclass\u003C\u002Ftd>\n\u003Ctd>数据容器类\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>mypy strict\u003C\u002Ftd>\n\u003Ctd>项目级别质量把控\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\n\u003Cp>类型注解不是强制的，渐进式引入即可。从最重要的公共 API 开始加注解，逐步扩展到整个项目。\u003C\u002Fp>\n","2026-05-03",[11,12,13,14],"python","typescript-style","type-hints","工具链",false,[17,30,41,53,62,69,76,83,90,97,107,116,125,134,142,150,159,168,171,181,188,198,204,211,217,226,233,240,248,258,267,276,286,296,306,314,324,335,345,354,362,368,376,384,392,400,408,415],{"slug":18,"title":19,"description":20,"pub_date":21,"tags":22,"draft":15,"word_count":29},"ide-skills-guide","Agent Skills 完全指南：21 款第三方 Skill 深度评测与使用心得","全面评测 21 款第三方 Agent Skills，涵盖 Vue 生态、前端设计、构建工具、实用工具四大分类。从安装配置到实际使用场景，带你了解每个 Skill 的功能特点、最佳实践与使用心得。","2026-06-15",[23,24,25,26,27,28],"agent","skills","AI","效率工具","前端","Vue",4169,{"slug":31,"title":32,"description":33,"pub_date":34,"tags":35,"draft":15,"word_count":40},"linux-kernel-skeleton-struct-funcptr-container_of","Linux 内核骨架：struct、函数指针与 container_of","读懂 Linux 内核源码的三件套：巨大的 struct 组合代替继承、函数指针表实现虚派发、container_of 宏从嵌入成员找回完整对象。","2026-05-09",[36,37,38,39],"linux","kernel","C","container_of",1369,{"slug":42,"title":43,"description":44,"pub_date":45,"tags":46,"draft":15,"word_count":52},"astro-complete-guide-2025","Astro 5 深度剖析：Islands 架构原理、构建优化与 Cloudflare Workers 边缘部署","从编译器视角解析 Astro 5 的 Islands 架构实现原理，Content Layer API 的 Vite 插件机制，Server Islands 的流式渲染，以及如何在 Cloudflare Workers + D1 边缘环境下榨干性能。","2026-05-08",[47,48,49,50,51],"astro","frontend","cloudflare","performance","architecture",3663,{"slug":54,"title":55,"description":56,"pub_date":9,"tags":57,"draft":15,"word_count":61},"llm-prompt-engineering","Prompt Engineering 实战：让 LLM 真正听话的技巧","System prompt 怎么写、Few-shot 怎么设计、Chain-of-Thought 原理，以及常见失败模式和调试方法。",[58,59,60],"ai","llm","工程实践",1723,{"slug":63,"title":64,"description":65,"pub_date":9,"tags":66,"draft":15,"word_count":68},"rag-system-design","RAG 系统设计：从 naive 到 production-ready","Retrieval-Augmented Generation 不只是「向量数据库 + LLM」，分块策略、召回质量、重排序、缓存才是工程核心。",[58,67,59,60],"rag",1613,{"slug":70,"title":71,"description":72,"pub_date":9,"tags":73,"draft":15,"word_count":75},"git-advanced-workflow","Git 进阶工作流：rebase、cherry-pick、bisect 的正确使用","merge 会了，但 rebase 总搞错？bisect 找 bug 提交？interactive rebase 整理历史？这篇一次说清楚。",[74,60],"git",1396,{"slug":77,"title":78,"description":79,"pub_date":9,"tags":80,"draft":15,"word_count":82},"docker-practical-guide","Docker 实战：从会用到用好","会 docker run 不够，Dockerfile 最佳实践、多阶段构建、Compose 编排、镜像瘦身才是日常真正需要的。",[81,36,60],"docker",1268,{"slug":84,"title":85,"description":86,"pub_date":9,"tags":87,"draft":15,"word_count":89},"anthropics-skills-guide","anthropics\u002Fskills：Anthropic 官方 Agent Skills 仓库解析","Anthropic 官方开源的 Agent Skills 标准仓库，127k stars，解析 SKILL.md 规范、17 个示例 skill 的设计模式，以及如何在 Claude Code \u002F Claude.ai \u002F API 中使用",[58,88,23,24],"Claude",2090,{"slug":91,"title":92,"description":93,"pub_date":9,"tags":94,"draft":15,"word_count":96},"karpathy-claude-code-guidelines","Karpathy 的 LLM 编码批评与 CLAUDE.md 最佳实践","基于 Andrej Karpathy 对 LLM 编程助手的观察，forrestchang 提炼出一个 CLAUDE.md 文件，4 条原则解决 AI 编码的典型失控问题：乱猜假设、过度设计、乱改代码、目标不清",[58,88,95,60],"Claude Code",2699,{"slug":98,"title":99,"description":100,"pub_date":9,"tags":101,"draft":15,"word_count":106},"typescript-advanced-patterns","TypeScript 高级模式：让类型系统为你工作","基础 TS 会了但类型总是 any？条件类型、映射类型、模板字面量类型、infer 关键字才是 TS 的真正威力。",[102,103,104,105],"typescript","类型系统","前端工程","高级模式",1419,{"slug":108,"title":109,"description":110,"pub_date":9,"tags":111,"draft":15,"word_count":115},"linux-performance-tuning","Linux 性能调优实战：从 top 到 perf 的完整工具链","遇到性能问题不知道从哪下手？这篇建立系统化的排查思路，从 CPU\u002F内存\u002FIO\u002F网络逐层分析。",[36,112,113,114],"性能","运维","系统编程",1524,{"slug":117,"title":118,"description":119,"pub_date":9,"tags":120,"draft":15,"word_count":124},"python-functional-programming","Python 函数式编程：map\u002Ffilter\u002Freduce 之外","Python 不是纯函数式语言，但 functools、itertools、偏函数、闭包这些工具用好了能让代码简洁一个量级。",[11,121,122,123],"函数式","闭包","装饰器",1867,{"slug":126,"title":127,"description":128,"pub_date":9,"tags":129,"draft":15,"word_count":133},"python-oop-guide","Python 面向对象：__init__ 之外你需要知道的","Python OOP 不只是 class + __init__，魔术方法、描述符、元类才是真正的武器。",[11,130,131,132],"OOP","面向对象","魔术方法",1792,{"slug":135,"title":136,"description":137,"pub_date":9,"tags":138,"draft":15,"word_count":141},"python-data-structures","Python 内置数据结构深度解析","list、dict、set、tuple 不只是数据容器，搞懂它们的底层实现和时间复杂度，才能写出高性能 Python。",[11,139,112,140],"数据结构","算法",1517,{"slug":143,"title":144,"description":145,"pub_date":9,"tags":146,"draft":15,"word_count":149},"python-basics-quick-start","Python 快速上手：写给有编程基础的人","已经会其他语言，想快速掌握 Python 的语法特性和思维方式，这篇是捷径。",[11,147,148],"入门","基础",1607,{"slug":151,"title":152,"description":153,"pub_date":9,"tags":154,"draft":15,"word_count":158},"python-dataclass-pydantic","Python dataclass vs Pydantic：数据类选型指南","dataclass 是标准库的轻量选择，Pydantic v2 是带验证的重武器，什么时候用哪个，这篇说清楚。",[11,155,156,157],"dataclass","pydantic","数据验证",1323,{"slug":160,"title":161,"description":162,"pub_date":9,"tags":163,"draft":15,"word_count":167},"python-asyncio-practical","Python asyncio 实战：从回调地狱到协程优雅","asyncio 是 Python 异步编程的核心，搞懂 event loop、Task、gather 这些概念才能写出真正高效的异步代码。",[11,164,165,166],"asyncio","并发","网络编程",1258,{"slug":4,"title":5,"description":6,"pub_date":9,"tags":169,"draft":15,"word_count":170},[11,12,13,14],1102,{"slug":172,"title":173,"description":174,"pub_date":175,"tags":176,"draft":15,"word_count":180},"pwa-install-update-button","PWA 踩坑：为什么安装按钮从来不出现","从 beforeinstallprompt 到 Service Worker waiting，把 PWA 的安装与更新提示真正做对","2026-05-02",[177,178,179],"pwa","javascript","web",1683,{"slug":182,"title":183,"description":184,"pub_date":185,"tags":186,"draft":15,"word_count":187},"openclaw-vs-hermes-agent","OpenClaw vs Hermes Agent：两个本地优先 Agent 的设计差异","OpenClaw（Novita AI）和 Hermes Agent（Nous Research）都是本地运行的个人 AI Agent，但在记忆系统、技能学习、运行环境和模型生态上走了不同的路。深入对比两种架构的核心差异。","2026-05-01",[58,23,59],1679,{"slug":189,"title":190,"description":191,"pub_date":185,"tags":192,"draft":15,"word_count":197},"cpp-random-design-patterns","C++ 设计模式实战：RAII、观察者、工厂","用现代 C++（C++17\u002F20）实现三种高频设计模式：RAII 资源管理、观察者模式事件系统、工厂模式插件架构。每种模式给出问题场景、实现代码和真实工程案例。",[193,194,195,196],"cpp","设计模式","c++17","工程",2613,{"slug":199,"title":200,"description":201,"pub_date":185,"tags":202,"draft":15,"word_count":203},"data-structures-fundamentals","数据结构基础：从数组到红黑树","系统梳理常用数据结构的核心原理、时间复杂度和适用场景。数组、链表、栈、队列、哈希表、二叉树、堆、图，每种结构附实现要点和 C++ 代码片段。",[139,140,193,148],3004,{"slug":205,"title":206,"description":207,"pub_date":208,"tags":209,"draft":15,"word_count":210},"ai-agent-what-is","什么是 AI Agent？从 LLM 到自主执行","LLM 本身是无状态问答机，Agent 是什么让它’动’起来的？本文深入解析 Agent 的四个核心能力、ReAct 框架、工具调用原理，以及主流框架横向对比。","2026-04-30",[58,23,59],2116,{"slug":212,"title":213,"description":214,"pub_date":208,"tags":215,"draft":15,"word_count":216},"ai-agent-memory","AI Agent 的记忆系统：从上下文窗口到长期记忆","深入拆解 AI Agent 的四种记忆类型、上下文窗口压缩策略、RAG 向量检索原理，以及三种典型失败模式和工程选型建议。",[58,23,67],2052,{"slug":218,"title":219,"description":220,"pub_date":208,"tags":221,"draft":15,"word_count":225},"network-proxy-vpn-guide","代理与翻墙技术原理：从 HTTP 代理到现代协议","深入解析代理与 VPN 的本质区别，梳理从 SOCKS5 到 Shadowsocks、V2Ray\u002FXray、Hysteria2 的协议演进，以及机场订阅的技术本质。",[222,223,224],"网络","代理","协议",2148,{"slug":227,"title":228,"description":229,"pub_date":208,"tags":230,"draft":15,"word_count":149},"algorithm-binary-search","二分查找：永远写不对？记住这个模板","彻底搞清楚二分查找的边界问题：闭区间和左闭右开两套模板、三道经典 LeetCode 题目完整 C++ 实现，以及二分答案的进阶思路。",[140,231,232,193],"二分查找","leetcode",{"slug":234,"title":235,"description":236,"pub_date":208,"tags":237,"draft":15,"word_count":239},"algorithm-sliding-window","滑动窗口算法：从暴力到 O(n) 的思维跃迁","系统讲解滑动窗口算法的核心模板、适用题型，配合三道经典 LeetCode 题目的完整 C++ 实现，彻底理解双指针收缩思路。",[140,238,232,193],"滑动窗口",1943,{"slug":241,"title":242,"description":243,"pub_date":208,"tags":244,"draft":15,"word_count":247},"network-clash-config","Clash \u002F Mihomo 配置详解：规则、策略组与分流","深入解析 Clash\u002FMihomo 的核心配置结构，包括代理节点、策略组类型、规则优先级、DNS fake-ip 模式，以及一份实用的完整配置模板。",[222,245,223,246],"clash","配置",1292,{"slug":249,"title":250,"description":251,"pub_date":252,"tags":253,"draft":15,"word_count":257},"hid-hotplug","HID 设备热插拔检测：从 udev 到 node-hid","在 Linux 上用 node-hid + usb 库实现可靠的 USB HID 设备热插拔检测，踩坑记录","2026-04-28",[193,254,36,255,256],"hid","nodejs","electron",2039,{"slug":259,"title":260,"description":261,"pub_date":262,"tags":263,"draft":15,"word_count":266},"electron-ipc-types","Electron IPC 类型安全：从 any 到完全类型化","用 TypeScript 泛型封装 Electron IPC，彻底消灭 any，preload 契约集中管理","2026-04-25",[256,102,264,265],"ipc","vue",1446,{"slug":268,"title":269,"description":270,"pub_date":271,"tags":272,"draft":15,"word_count":275},"element-plus-popover-hide","手动关闭多个 el-popover（不用 v-model:visible）","通过 ref + Reflect.get 调用 hide() 方法手动关闭 Element Plus Popover，解释 Vue3 Proxy 导致无法直接调用实例方法的原因。","2024-10-25",[265,273,274],"element-plus","vue3",1321,{"slug":277,"title":278,"description":279,"pub_date":280,"tags":281,"draft":15,"word_count":285},"vite-vue3-ts-elementplus-pinia","用 Vite+（vp）从零搭建 Vue3 + TypeScript + Element Plus + Pinia + Vue Router","使用 Vite+ 统一工具链（vp）一条命令搭建 Vue3 全家桶，涵盖按需导入、Pinia store、路由配置，以及常见坑的解决方案。","2024-08-27",[265,282,102,273,283,284],"vite","pinia","vite-plus",1960,{"slug":287,"title":288,"description":289,"pub_date":290,"tags":291,"draft":15,"word_count":295},"cef-lnk2038-iterator-debug-level","CEF LNK2038：解决 _ITERATOR_DEBUG_LEVEL 不匹配错误","分析 CEF（Chromium Embedded Framework）集成时出现的 LNK2038 _ITERATOR_DEBUG_LEVEL 链接错误，从根本原因到解决方案的完整指南。","2024-05-07",[193,292,293,294],"CEF","Visual Studio","链接错误",1509,{"slug":297,"title":298,"description":299,"pub_date":300,"tags":301,"draft":15,"word_count":305},"npm-electron-install-fix","彻底解决 npm 安装 Electron 失败的问题","分析 npm install electron 失败的根本原因（下载二进制超时\u002F被墙），通过国内镜像（npmmirror）彻底解决，并介绍多种备选方案和常见错误排查。","2024-03-01",[256,302,303,304],"npm","前端工具链","国内镜像",1494,{"slug":307,"title":308,"description":309,"pub_date":310,"tags":311,"draft":15,"word_count":313},"git-out-of-memory","解决 git 报错：Fatal: Out of memory, malloc failed","分析 git 大仓库操作时出现 Out of memory malloc failed 的根本原因，通过调整 pack.windowMemory、http.postBuffer 和 git repack 彻底解决。","2024-01-31",[74,36,312],"工具",2244,{"slug":315,"title":316,"description":317,"pub_date":318,"tags":319,"draft":15,"word_count":323},"vmware-tools-install","在 VMware 虚拟机中安装 open-vm-tools 完整指南","详解 VMware Tools 的作用、open-vm-tools 与官方 VMware Tools 的区别，以及在 Ubuntu 虚拟机中安装并生效的完整步骤和常见问题排查。","2023-11-21",[320,36,321,322],"VMware","Ubuntu","虚拟机",2523,{"slug":325,"title":326,"description":327,"pub_date":328,"tags":329,"draft":15,"word_count":334},"load-balancing-algorithms","负载均衡算法完全指南：从轮询到一致性哈希","系统梳理静态与动态负载均衡算法，涵盖轮询、随机、权重、IP Hash、一致性 Hash、最少连接、最快响应等，并对比 Nginx、Dubbo、Spring Cloud LoadBalancer 的实现差异。","2023-11-15",[330,331,332,333],"分布式","负载均衡","Nginx","微服务",1764,{"slug":336,"title":337,"description":338,"pub_date":339,"tags":340,"draft":15,"word_count":344},"win-cw2a-ca2w","ATL 字符串转换：CW2A 与 CA2W 完全指南","详解 ATL 宏 CW2A\u002FCA2W 在 Unicode 与 ANSI 之间的字符串转换用法、头文件依赖、USES_CONVERSION 宏的作用与常见陷阱。","2023-06-09",[193,341,342,343],"windows","ATL","字符串",1665,{"slug":346,"title":347,"description":348,"pub_date":339,"tags":349,"draft":15,"word_count":353},"csharp-sendmessage-cpp","C# 通过 SendMessage 向 C++ 窗口发送消息与字符串","使用 P\u002FInvoke 调用 user32.dll 的 SendMessage，从 C# 发送自定义 WM_USER 消息及字符串指针给 C++ 原生窗口，并在 C++ 侧正确接收和转换。",[350,193,341,351,352],"C#","互操作","PInvoke",1554,{"slug":355,"title":356,"description":357,"pub_date":358,"tags":359,"draft":15,"word_count":361},"win-postmessage-vector","Windows PostMessage 跨线程传递 std::vector 指针","通过 PostMessage 在 Windows 消息队列中传递 std::vector 指针，使用 reinterpret_cast 将指针装入 LPARAM，并在接收方正确释放内存。","2023-05-26",[193,341,360],"WinAPI",1823,{"slug":363,"title":364,"description":365,"pub_date":358,"tags":366,"draft":15,"word_count":367},"exe-dll-single-package","将 EXE 和 DLL 打包成单一可执行文件","介绍两种将 exe 和依赖 dll 打包成单文件的方案：Enigma Virtual Box 和 WinRAR 自解压，适合发布 Windows 桌面程序时简化分发流程。",[341,193,312],1619,{"slug":369,"title":370,"description":371,"pub_date":358,"tags":372,"draft":15,"word_count":375},"cpp-random-mt19937","C++ 现代随机数生成：用 mt19937 彻底告别 rand()","深入讲解为什么 rand() 不够用，以及如何用 C++11 的 \u003Crandom> 库正确生成高质量随机数，涵盖 mt19937、各种分布和线程安全。",[193,373,374],"c++11","random",1549,{"slug":377,"title":378,"description":379,"pub_date":380,"tags":381,"draft":15,"word_count":383},"win-startup-registry","C++ 实现程序开机自启动：注册表方式详解","通过操作 Windows 注册表 Run 键实现程序开机自启动，包括 HKCU 与 HKLM 区别、完整封装代码、工作目录问题和 UAC 权限处理。","2022-12-26",[341,193,382],"registry",1201,{"slug":385,"title":386,"description":387,"pub_date":388,"tags":389,"draft":15,"word_count":391},"mfc-cstring-wparam","MFC 中 CString 与 WPARAM 之间的转换","详解 MFC 消息传递中 CString 无法直接强转为 WPARAM 的原因，以及两种正确的转换方案，并介绍结构体指针传递的正确姿势。","2022-11-25",[390,193,341],"mfc",1546,{"slug":393,"title":394,"description":395,"pub_date":396,"tags":397,"draft":15,"word_count":399},"duilib-static-build","正确编译 Duilib 静态库：避免 ATL 依赖和链接错误","详解如何用 DuiLib_Static.vcxproj 编译 Duilib 静态库，解决 VARIANT 未定义、Unicode 配置不匹配和 ATL 依赖等常见问题。","2022-08-24",[193,398,341,390],"duilib",2639,{"slug":401,"title":402,"description":403,"pub_date":404,"tags":405,"draft":15,"word_count":407},"mfc-dpi-adaptive","MFC 界面自适应不同分辨率","MFC 对话框程序实现控件和字体随分辨率自动缩放的完整方案，附 DPI Awareness 配置说明","2022-08-17",[390,193,341,406],"dpi",1414,{"slug":409,"title":410,"description":411,"pub_date":412,"tags":413,"draft":15,"word_count":414},"mfc-drag-window","MFC 无标题栏窗口客户区拖动：三种方法对比","MFC 对话框去掉标题栏后如何实现拖动移动窗口，三种方案完整实现与适用场景分析","2022-08-16",[390,193,341],1633,{"slug":416,"title":417,"description":418,"pub_date":419,"tags":420,"draft":15,"word_count":422},"algorithm-number-complement","整数的补数：位运算掩码解法","LeetCode 476 题，用掩码 XOR 实现整数补数，附 C++\u002FPython\u002FJava 三种实现及补数与补码的区别","2021-03-08",[140,421,232],"位运算",1374,[]]