Blog

  • 清理 VS Code「最近打开」列表中的无效记录

    清理 VS Code「最近打开」列表中的无效记录

    用 VS Code 时间久了,「文件 > 最近打开」列表会积累大量已删除或移动过的项目路径,点进去全是报错。网上流传的清理方法大多已过时——本文记录了在 VS Code 1.122+ 上找到正确存储位置的完整过程,以及最终可用的清理脚本。


    传统方法失效

    常见教程的做法是直接修改 SQLite 数据库:

    %APPDATA%\Code\User\globalStorage\state.vscdb

    查询 key:

    SELECT value FROM ItemTable WHERE key = 'history.recentlyOpenedPathsList'

    但在 VS Code 1.122 上执行后返回 None——这个 key 在这个路径下根本不存在。


    逐步排查过程

    1. 确认 User globalStorage 中没有该 key

    列出 state.vscdb 中所有 key,没有任何 recent 相关条目。

    2. 搜索所有 .vscdb 和 LevelDB 文件

    workspaceStorage 目录下有数百个工作区数据库,Local Storage LevelDB 也无相关 key。

    3. 在 storage.json 中找到文件夹历史

    %APPDATA%\Code\User\globalStorage\storage.json 中的 profileAssociations.workspaces 存储了所有打开过的文件夹路径与 profile 的对应关系,可以从这里删除不存在的文件夹记录。

    4. 在 workspaceStorage 中找到文件历史

    每个工作区的 state.vscdbhistory.entries 记录了该工作区内曾打开过的文件路径,可以从这里批量清理。

    5. 最终发现:真正的「最近打开」列表

    上面两步清理后,独立文件(直接用 File > Open File 打开、不属于任何工作区的文件)仍然出现在列表里。通过分析 VS Code 1.122 的主进程日志,找到了最终答案:

    [shared storage] Creating shared storage database at
    '~/.vscode-shared/sharedStorage/state.vscdb'

    真正的存储位置是 ~/.vscode-shared/sharedStorage/state.vscdb,这是 VS Code 的跨 profile 共享存储,包含完整的「文件夹 + 独立文件」全局最近打开列表,key 仍然是 history.recentlyOpenedPathsList,只是搬到了这个新路径。


    VS Code 存储结构(1.122+)

    内容 文件 Key
    全局最近打开列表(文件夹 + 文件) ~/.vscode-shared/sharedStorage/state.vscdb history.recentlyOpenedPathsList
    文件夹与 profile 关联 %APPDATA%/Code/User/globalStorage/storage.json profileAssociations.workspaces
    工作区内文件编辑历史 %APPDATA%/Code/User/workspaceStorage/*/state.vscdb history.entries

    版本变迁

    VS Code 版本 存储位置 Key
    ~1.74 及以前 %APPDATA%/Code/User/globalStorage/storage.json(JSON) history.recentlyOpenedPathsList
    ~1.75 ~ 1.121 %APPDATA%/Code/User/globalStorage/state.vscdb(SQLite) history.recentlyOpenedPathsList
    1.122+ ~/.vscode-shared/sharedStorage/state.vscdb(SQLite) history.recentlyOpenedPathsList

    版本节点为推测值,以实际行为为准。


    清理脚本

    完整脚本已开源,一键清理上述三个位置:

    GitHub:sudoghut/vscode-clean-recent

    运行方法

    git clone https://github.com/sudoghut/vscode-clean-recent.git
    cd vscode-clean-recent
    python clean_vscode_recent.py

    或在 Windows 下避免编码问题:

    cmd.exe /c "chcp 65001 >nul && set PYTHONIOENCODING=utf-8 && python clean_vscode_recent.py"

    注意事项

    • 先关闭 VS Code,否则 VS Code 退出时会覆盖修改
    • 脚本会自动备份所有修改的文件
    • Remote SSH / WSL 路径不会被删除

    结果

    脚本在测试机上:

    • 全局最近打开列表:806 条 → 删除 427 条无效,保留 379 条
    • 文件夹 profile 关联:338 条 → 删除 190 条无效,保留 148 条
    • 工作区文件历史:扫描 477 个数据库 → 删除 1325 条无效记录,保留 2002 条

    重启 VS Code 后「最近打开」列表彻底干净。

  • Dropbox 的 Smart Sync 触发自动故障导致磁盘空间被迅速消耗完的问题

    Dropbox 的 Smart Sync 触发自动故障导致磁盘空间被迅速消耗完的问题

    Dropbox 的 Smart Sync 功能允许用户将文件设为”仅在线”以节省本地磁盘空间。然而,Dropbox 客户端在重新启动时(例如系统从睡眠唤醒、客户端更新或手动重启),有时会将大量文件夹的 Smart Sync
    策略从”仅在线”批量重置为”下载到本地”,触发数万个文件的大量下载,迅速耗尽磁盘空间。这一行为并非用户误操作,而是 Dropbox 客户端的已知问题。

    当这种情况发生时,在 Dropbox 正在执行批量下载的过程中,直接通过右键菜单将文件夹设为”Make available online only”往往无效,因为父级文件夹的策略优先级更高,且 Dropbox 的下载队列在重启后仍会持续执行。

    有效的解决方法是:完全退出 Dropbox 客户端,然后用 SQLite 工具打开本地数据库文件 smarter_smart_sync.dbx(位于 AppData\Local\Dropbox\instance1\),执行 UPDATE scan_history SET folder_policy=NULL WHERE folder_policy=1
    将所有被重置的下载策略清除。操作前建议先备份该文件。清除后重新启动 Dropbox,立刻暂停同步,再对 Dropbox 根目录执行一次”Make available online only”,然后恢复同步,Dropbox 便会开始删除本地副本、释放磁盘空间,而不再重新下载。

    为避免此问题,建议对于不需要本地存储的超大文件夹改用 Selective Sync(选择性同步)而非 Smart Sync,因为 Selective Sync 将文件夹完全排除在本地之外,不受策略重置的影响,稳定性更好。此外,也建议在磁盘上保留足够的余量,以便在策略意外重置时有足够时间发现并处理。

  • 圣诞假补完链锯人蕾塞篇

    圣诞假补完链锯人蕾塞篇

    前段,男频 yy 恋爱剧嘛,有什么好看的。中段,哇,分镜!音乐!节奏!适合圣诞的打斗爆米花番! 过度到结尾之前:有些事既正确又恶心,那么就愉快地不要恶心自己!结尾:价值观冲突时,「子弹的批判」总是适合悲剧。权力/暴力决定结局,也算是当下文化的写实。豆瓣 9.1, 真不错。
    原作藤本树:「原作中让帕瓦最后登场是为了过渡到下一章,但拍成电影我也想过,结束时是否有必要让她出场。不过多亏她最后阳光的声音,能让自己心情愉悦地走出电影院。」你也知道吖!

  • VSCode 中文折行不完全

    在 VSCode 中安裝了主題和字體之後,開啟折行時,有時會出現折行後仍然有一部分內容需要透過水平滾動條顯示的狀況。

    這時候可以進入 VSCode 的設置,檢索”Wrapping Strategy”, 把它設置為 advanced 即可。

  • Trending stories 轉型方案

    Trending stories 轉型方案

    Trending stories 網站在設計的時候,有兩個技術點,首先是用打開 internet access 的 gemini api 根據 Google trends 生成新聞。這本身也是我自己想要的產品,經常看到 Google trends 一頭霧水,希望能快速知道這些搜索熱詞背後到底是什麼,而不是被新聞站或者 twitter 這種基於推送的算法引導。第二個是用 flux .1 模型為每一條新聞配圖。如:

    https://trending.oopus.info/date/20251101

    在推廣失利以及和 LLM 深度探討之後,對 Trending news 有進一步的思考:新聞站有大量競品,甚至是惡意新聞農場。而關於新聞報道,Google 本身也在做 news 和其他產品來解釋新聞。基於 Google trends 做新聞解釋網站等於與自己的完整產業鏈供貨者競爭下游利益,更難成功。

    考慮到當前網站的維護由於圖片生成質量不穩定,需要我自己檢查和重新生成部分圖片,所以沒辦法全自動運行。那麼當前的轉變是:

    1. 把基於 AI 的圖片生成轉為簡單的詞雲。如 https://trending.oopus.info/date/20251104 頁面的後二十張圖。這樣雖然更加不好看,但更容易讓人一眼就能看到今天的新聞熱點,以及當前所瀏覽新聞的大致熱度。比如 20251104 的熱點是選舉。
    2. 生成 trending news 的文本需要一個模板(還沒做,這幾天調試 prompt)。比如每一篇新聞都由總結,為什麼會變成今日熱點,以及何時、何地、何人、何事。
    3. 把新聞生成程序部署到雲端,全自動生圖生文,卡住早、晚報的時間(還沒做,這幾天做)。讓偶爾能看到這個網站的人,確實可以看到今日新聞。網站不會因為我某天沒來得及手動做圖片質檢而導致新聞推遲發佈。
    4. 【真正的轉變】基於當前的每日新聞撰寫深度報道和分析文章。這些文章可以用 AI 生圖, AI 組織,AI 分析,但都要經過自己來最終成文。這些深度報道和分析也許可以發佈在另一個新的網站上。它們是作為對 trending news 相關新聞的「透視」。建立 trending news 的目標本來就是希望研究「新聞」和「歷史」的關係。之前想看看 trending news 作為日報,本身是否能成為獨立產品。現在看來不太行,那麼就回到最初設計。並且這也是「須有我在」。之前單純是基於 U.S. Google trends 面向北美的產品,並沒有「我在」。而現在把自己對新聞的興趣,自己設計的相似性算法,自己的新聞分析,以及可視化加進來。

  • Troubleshooting Localhost Access Issues: When Your Terminal Can’t Reach Local Services

    Have you ever encountered a frustrating situation where your browser can access a local service, but your terminal and IDE cannot? Recently, I faced this exact issue while trying to access a ComfyUI API running on 127.0.0.1:8188.

    The Problem

    • What worked: Browser with proxy settings could access the local service
    • What didn’t work: VSCode, terminal, and curl commands couldn’t reach 127.0.0.1:8188
    • What I tried: Cleared system and IDE proxy settings, removed HTTP_PROXY and HTTPS_PROXY environment variables

    Despite confirming that echo %HTTP_PROXY% and echo %HTTPS_PROXY% returned empty values, the issue persisted.

    The Solution: Let Your Tools Tell You What They See

    Sometimes the best approach is to let your applications reveal their own proxy configuration. Here’s a Python script that helped me diagnose the issue:

    import os
    import urllib.request
    
    print("--- Checking Environment Variables from Python's perspective ---")
    # os.environ is how Python sees all environment variables
    print(f"HTTP_PROXY: {os.environ.get('HTTP_PROXY')}")
    print(f"HTTPS_PROXY: {os.environ.get('HTTPS_PROXY')}")
    
    print("\n--- Checking what proxies urllib automatically detects ---")
    # getproxies() shows what urllib will use by default
    print(urllib.request.getproxies())

    What This Reveals

    The urllib.request.getproxies() function shows you exactly what proxy settings your Python environment detects, even when environment variables appear clean. This often reveals:

    • Registry-based proxy settings (Windows)
    • System-wide proxy configurations
    • Application-specific proxy settings that override environment variables

    The Fix: Explicitly Disable Proxies

    If you find unwanted proxy settings, you can force urllib (and applications that use it) to bypass proxies entirely:

    # Create a proxy handler with no proxies
    proxy_handler = urllib.request.ProxyHandler({})
    opener = urllib.request.build_opener(proxy_handler)
    urllib.request.install_opener(opener)

    Key Takeaway

    When troubleshooting network connectivity issues, don’t just rely on environment variables and system settings. Use your application’s own introspection capabilities to understand what it actually sees. This approach often reveals hidden proxy configurations that standard troubleshooting methods miss.

    Pro tip: Always check what your specific tools and libraries detect, not just what the system claims to be configured.

  • VSCode Python Run Button Not Working? Check Your Extension Version

    If you’re experiencing issues with VSCode where clicking the “Run” button in the top-right corner of a Python file doesn’t work properly, you might encounter these problems:

    1. No new terminal window is activated (the new windows are created in the background)
    2. The command “python xxx.py” doesn’t execute automatically

    Here’s a quick fix that often resolves this issue:

    Solution:

    Go to your VSCode Extensions panel and locate the Python extension. Check if you’re currently using the pre-release version of the Python extension. If you see “Pre-Release” indicated next to the Python extension, that’s likely the culprit.

    Simply switch from the pre-release version back to the stable release version. You can do this by clicking on the extension and selecting the option to install the release version instead.

    After switching to the release version, restart VSCode and try running your Python file again. The run button should now properly activate a new terminal and execute your Python script as expected.

  • 十個月兩個項目的低谷

    epr (番劇推薦)半年籌備獲得慘淡的點擊率之後,奮起兩個月,把 trending 做出來。這個禮拜 trending(熱門關鍵詞解說) 在 hackernews 和 reddit 收穫雙份失敗,這個禮拜就特別的 down 無比的 down. 加上老爸和老媽的矛盾導致老爸被 120 送到醫院,就更覺得世界的荒謬。到週日,實在就動不了。和 gemini 好好聊了一次,收穫許多 pua. 也是令人溫馨治愈, 感覺被 pua 到了(不要代入啊,喂!)!也獲得了實質性可以試驗的建議

  • 世界当今的困境思考

    上一個時代,世界的困境是東西方陣營的對抗。而面對這一困境的普世性訴求是平等和自由。

    上上一個時代,世界的困境是不平等和舊制度。面對這一困境的方式是解放。同樣在東西方,都在對抗和消解前現代的不平等。

    当下時代,各種政治、經濟、社會相關的學說在學術市場,為掙得教職和學術身份,散亂堆疊。在實踐家與獨立的社會擾動性實驗越來越少的當下,我們到底在解決自己的職業問題,還是世界的問題?

    從自己的經歷反思中,想到當下世界的的三件極壓迫個人的問題:

    首先是資本至上的資本主義,它通過資本、慾望、習俗、文化控制者各行各業,控制每一個人的行動和自由。

    第二是政治問題:威權主義。從東方到西方,對社會以及每一個人自由的控制力在當下每一個國家都在瘋漲。

    第三個是社會問題:小集團的信息繭房和層層自利。從每一個國家,每一個地區,到每一種性別,每一種宗教,到每一個階級,每一種職業,到每一個學校,每一個中心,到每一個家族,每一個家庭,到每一個人。理念和利益的衝突帶來的社會各層面的對抗和撕裂。

    競爭和個人利益(家庭、社會、國家利益)在這些的問題中成為每一方自我掙扎的唯一方式,並且催生糟糕的競爭或者是在中國互聯網語境裡的「內捲」。當下的我們似乎還沒有理論,沒有實踐,沒有力量嘗試全面解決這些問題。

  • clash verge + proxifier only proxies part of your traffic issue

    If you find that your Clash Verge + Proxifier setup only proxies part of your traffic, double-check whether the port opened from Clash Verge to Proxifier is set to Mixed Port or another type. If it is not set to Mixed Port, change it to Mixed Port, and it should work.

    This issue can occur with VS Code and GitHub VS Code.

    On the other hand, for VS Code and Docker, if you are using Proxifier, please change your “localhost” proxy rule to Direct instead of Proxy.