展示HN:用Gemini代码解决一个问题
我对“氛围编码”这一趋势稍显迟钝。虽然我曾经尝试过使用大型语言模型(LLMs)进行简单的脚本编写,但我并没有真正将它们融入我的工作流程中。不过,最近我有了一个需求,决定全力以赴。
我使用 Supernote A5X2 来做笔记,但找不到完美的点阵网格。我想要一个简单的——轻便、6mm 间距的点阵网格。我在网上找到的每一个生成器都有一个问题:要么在页面上加水印,要么在角落里强行放上他们的logo,或者根本就无法使用。
通常,构建一个自定义 PDF 生成器意味着要花一个小时查阅文档,找到合适的库并弄清楚坐标系统。但我没有时间奢侈,所以我给 Gemini 提供了一个提示,详细描述了我想要的内容:命令、参数,以及我期望得到的结果。
根据这些指示,它生成了一个使用 BeautifulSoup 的功能性 Python 脚本,我想是这样的(我没有原始的 Python 代码,Gemini 决定删除它)。效果非常好。经过几次后续提示来调整间距和点密度,我得到了一个几乎完美的 PDF。
这个脚本对我来说很好用,但我想与 Supernote 社区分享。大多数用户不会安装 Python 并运行终端命令来获取一个笔记本模板。我需要一个网络应用程序。但我不想运行一个服务器来生成 PDF。我想要一个静态文件,可以在 GitHub 上托管。
我再次向 Gemini 提出了一个新挑战:“给我构建一个纯 JavaScript 应用程序,完全在浏览器中生成这个 PDF。”
Gemini 使用客户端库生成了 HTML、CSS 和 JavaScript 文件。在经过几轮“打磨氛围”——调整用户界面和优化 PDF 输出后,我得到了我想要的效果。
你可以在这里查看最终产品 <a href="https://satran.github.io/grid-generator" rel="nofollow">https://satran.github.io/grid-generator</a>,源代码可以在 GitHub 仓库中找到 <a href="https://github.com/satran/grid-generator" rel="nofollow">https://github.com/satran/grid-generator</a>。
回顾过去,我最享受的并不是速度,而是框架的搭建。我不需要研究哪个 JS 库最适合 PDF 生成;LLM 选择了一个标准库并正确地实现了它。它创建了应用程序的结构“骨架”,让我可以专注于补充和完善细节,而不是编写样板代码。我从一个小烦恼变成了一个面向公众的工具,所花的时间远比传统方式少得多。我想我正式成为了信徒。这就是我想要的:我可以专注于代码的意图,让 LLM 处理语法。
查看原文
I am a little late to the "vibe coding" trend. While I’d played around with LLMs for simple scripting, I hadn't truly integrated them into my workflow. But for a recent itch, I thought I'd give it all.<p>I use a Supernote A5X2 for taking notes. I couldn't find the perfect dot grid for it. I wanted something simple—a light, 6mm spaced dot grid. Every generator I found online came with a catch: they either slapped a watermark on the page, forced their logo into the corner, or simply didn't work.<p>Usually, building a custom PDF generator means spending an hour documentation-diving to find the right library and figuring out coordinate systems. I didn't have the luxury of time, so I gave Gemini a prompt describing exactly what I wanted: the command, arguments, and what I expected to get out of it.<p>With these instructions it popped out a functional Python script using beautifulsoup, I think (I don’t have the original Python code, Gemini decided to delete it). It worked remarkably well. With a few follow-up prompts to tweak the spacing and dot density, I had a near perfect PDF.<p>The script worked for me, but I wanted to share it with the Supernote community. Most users aren't going to install Python and run terminal commands just to get a notebook template. I needed a web application. But I didn’t want to run a server and have it generate the PDF. I wanted a static file that I could host it in GitHub.<p>I went back to Gemini with a new challenge: “Build me a pure JavaScript application that generates this PDF entirely in the browser.”<p>Gemini generated the HTML, CSS, and JavaScript files using a client-side library. After a few rounds of "polishing the vibes"—tweaking the UI and refining the PDF output—I had exactly what I envisioned.<p>You can see the final product here <a href="https://satran.github.io/grid-generator" rel="nofollow">https://satran.github.io/grid-generator</a> and the source code is available in the GitHub repository <a href="https://github.com/satran/grid-generator" rel="nofollow">https://github.com/satran/grid-generator</a>.<p>Looking back, what I enjoyed most wasn't the speed, but the scaffolding. I didn’t have to research which JS library was best for PDF generation; the LLM picked a standard one and implemented it correctly. It created the structural "bones" of the app, allowing me to focus on supplementing and finalising the details rather than writing boilerplate code. I went from a minor annoyance to a public-facing tool in a fraction of the time it would have taken traditionally. I think I’m officially a convert. This is it: I can focus on the intent of the code and let the LLM handle the syntax.