avatar
Rei
用 Ruby 实现基于大模型的命令行角色扮演脚本
最近想研究一下大模型的使用,为了练手写了一个命令行角色扮演脚本,在此分享。 先看效果: 录屏2025-05-22 16.30.50.mov 代码放在文末,这是一个单文件脚本,运行需要安装 Ruby 环境。 使用的时候把代码保存在本地,例如 main.rb。 申请一个 OpenAI 兼容的 API(我用的是 DeepSeek),设置环境变量到同目录的 .env 文件,内容为: OPENAI_BASE_URL=https://api.deepseek.com OPENAI_API_KEY=sk-xxx 然后执行 ruby main.rb 即可。 脚本代码: require "bundler/inline" gemfile do…
avatar
wulu
Docker容器中的定时任务:使用Supercronic运行Python脚本
在上一篇文章中,我介绍了 eudic-maimemo-sync 项目——利用 Python 脚本调用欧路词典和墨墨背单词的开放API将生词本自动同步到墨墨背单词,并演示了如何用 Docker 将其部署到树莓派上,每天自动执行同步。 这篇文章,我想分享我在配置 Docker 容器实现定时任务时遇到的一个问题,以及我是如何解决它的:我最初在容器内使用标准的 Cron 服务来调度 Python 脚本。但我发现,即使把环境变量传入了容器…
avatar
busylog
Example Windows Sandbox conf (wsb)
<Configuration> <AudioInput>false</AudioInput> <VideoInput>false</VideoInput> <MemoryInMB>8192</MemoryInMB> <MappedFolders> <MappedFolder> <HostFolder>C:\Users\USER\Downloads</HostFolder> <SandboxFolder>C:\Users\WDAGUtilityAccount\Downloads</SandboxFolder> <ReadOnly>false</ReadOnly> </MappedFolder> </MappedFolders> <LogonCommand> <Command>netsh advfirewall firewall add rule name="SearchHost.exe" dir=out action=block program="C:\Windows\SystemApps\MicrosoftWindows.Client.CBS_cw5n1h2txyewy\SearchHost.exe" enable=yes</Command> <Command>netsh advfirewall firewall add…
avatar
busylog
One liner powershell for ipv6-literal.net
Read-Host "Enter IPv6 address" | %{ ($_ -replace ':','-' -replace '%','s') + '.ipv6-literal.net' }
avatar
Rei
daisyUI - 我找到了理想中的 UI 库
我已经有几年时间没有使用 UI 库,近几年的项目我都是从头开始写 UI,小到按钮、对话框,大到响应式布局。原因是以前的 UI 库样式千篇一律,又难以定制,我宁愿从头开发。 重复了几次后,我感觉累了。UI 优化是没有尽头的,工作量已经影响到功能开发。有时我会觉得,如果自己没有 CSS 经验,就不会花那么多时间在 UI 上了。 最近开始一个新项目的时候,我决定放弃什么都自己做的想法,选一个过得去的…
avatar
busylog
iPhone Shortcuts tips
Generate QR Code (from Clipboard, Show in Quick Look) Great way to transfer short text/url between devices. Extract Text from Images (OCR, from Clipboard, Show in Quick Look) Automation: When NFC card is detected (set some Speak? action) Note that it is the most quick way to confirm NFC functionality is working, without 3rd party apps. check SEID in Settings. if it is available then the secure element is working. the antenna may not be connected correctly (NFC antenna is a loop, one connect to small antenna, and one connect to rare case). iPhone does NOT support reading / connecting…
avatar
Muspi Merol
为什么不用静态分析来实现 HMR
几个月前,我看到 How to build Hot Module Replacement in Python 这篇文章,讲的是用他们的 Tach 这个 Python 静态分析工具,可以获得一个依赖图,类似这样的键值格式: { "a.py": ["b.py", "c.py"], "b.py": ["d.py"], "d.py": ["e.py"], "c.py": ["f.py"] } 说起来,这个项目上个月开始 unmaintained 了 😅 一问才发现原来是开发者跑去 AI 创业了。我觉得网友说的挺好: I guess that's the issue with open source tools being backed by VCs. These tools will never…
avatar
Rei
LLMRPG - 用于角色扮演的大语言聊天应用
最近做了一个用于角色扮演的大语言聊天应用,想跟大家分享。 这个应用可以给 AI 设定各种角色,然后跟这些角色进行聊天。支持私聊和群聊,并且自己可以扮演其中的角色参与聊天。 示例: 为了方便体验,我部署了一个在线版本:(已下线) https://app.llmrpg.com/ 注意在线版本的数据不加密,我可能会观察使用情况来改进应用。 如果你注重隐私,这个项目已经开源,可以尝试自己部署: https://github.com/chloerei/llmrpg 使用方法 注册账号。 到“角色”创建角色定义…
avatar
Rei
Turbo Stream Broadcast - 被低估的 Rails 功能
我一直认为,把 Rails 作为前后端分离项目的后端是一种浪费。类似于在 Mac 上安装 Windows 系统,没有什么可以阻止你这样做,而且看起来很美好:Windows 系统更大众化,Mac 硬件做工好,似乎是强强联合。但是深度 Mac 用户会知道,这丢失了很多软硬件一体化设计的优势。 Rails 优势在于前后端紧密集成,有的功能只有在全栈环境下才能使用,Turbo Stream Broadcast 就是其中一个。Broadcast 在官方文档中只有一个小节的介绍,并且没有完整示例,可能…
avatar
电子芥末
极简 Markdown 阅读器
Safe and Simple Markdown Reader in the Browser 浏览器里的 Markdown 阅读器,极简,安全。 使用浏览器阅读 Markdown 的好处 不需要安装软件 如果你和我一样同时使用 Firefox/Chrome 等多个浏览器, 那么,使用本阅读器就能确保 markdown 文档里的链接在当前浏览器里打开。 极简 只有一个 HTML 文件,包含 HTML CSS JavaScript 一共不到 100 行代码。 安全 不安装软件,不安装浏览器插件,减少危险因素。 自由 真正脱离任何生态。 回归本质, Markdown 文档就是纯文本文档,可以自由地使用任何文本编辑器…
avatar
电子芥末
加密币钱包助记词保护器
为了安全,本项目采用完全本地运行的 HTML 和 JS, 完全不使用第三方库。 比金属板打点更好 我的灵感来源是这个 onekey 金属板打点 但我认为金属板有两个问题:1. 贵; 2. 不够安全。 于是我想出了这个替代方法,用汉字来代替打点,比金属板更安全、更不怕丢失,而且还免费 使用方法 项目地址 https://github.com/ahui2016/wallet-passphrases-protector 下载本项目的全部 html 和 js 到本地,双击打开 index.html 即可开始使用。 基本原理 随机生成一个英语单词与汉字…
avatar
busylog
Some simple ideas that can be done in minutes with any chat AI
simple progress and deliverables are important for programming/ai beginners. 1 expand script curl supports [1-99] like number enumeration, and bash supports {a,b,c,d} list expand. write a python script that expand argv[1]. (seq -f "%g" number also works though) 2 pastebin note that in python 3.14, there is no more multipart parser to accept file upload easily. save the file/text under upload-timestamp-randomnumber.txt and use Content-Type application/octet-stream for any file/text display. 3 line joiner or slot joiner(if all keyword appeared, display in order) script filename a…
avatar
Rei
在 Rails 应用实现用户行为统计
本文介绍如何用 ahoy/groupdate/chartkick 实现用户行为统计。 B 站视频 https://www.bilibili.com/video/BV1ysxCzLEnH/ 代码摘要 ahoy https://github.com/ankane/ahoy 安装 Ruby 库: gem "ahoy_matey" bundle install rails generate ahoy:install rails db:migrate 配置 API: # config/initializers/ahoy.rb Ahoy.api = true 安装 JavaScript 库: npm add ahoy.js 修改 app/javascript/applicatoin.js: import ahoy from "ahoy.js" window.ahoy = ahoy Ruby 收集: ahoy.track "event_name", language: "Ruby" JavaScript 收集: ahoy.track("event_name", {language: "JavaScript"}); groupdate https://github.com/ankane/groupdate 安装库: gem "groupdate…
avatar
Rei
【Rei on Rails】#12 RubyGems 分裂?
梳理 RubyGems 分裂出 gem.coop 事件的始末。 视频 https://www.bilibili.com/video/BV1YLWvzYEn8/ 引用 Ruby Central’s Attack on RubyGems https://pup-e.com/goodbye-rubygems.pdf Strengthening the Stewardship of RubyGems and Bundler https://rubycentral.org/news/strengthening-the-stewardship-of-rubygems-and-bundler/ A board member's perspective of the RubyGems controversy https://apiguy.substack.com/p/a-board-members-perspective-of-the Why I'm not rushing to take sides in the RubyGems fiasco https://justin.searls.co/posts/why-im-not-rushing-to-take-sides-in-the-rubygems-fiasco/ Ruby Central’s “security…
avatar
Rei
【Rei on Rails】#13 TailwindCSS + DaisyUI 简介
介绍 TailwindCSS + DaisyUI 在 Ruby on Rails 中的使用。 视频 https://www.bilibili.com/video/BV1yDyaBCEpX/ 引用 Tailwind CSS https://tailwindcss.com/ daisyUI https://daisyui.com/ CSS Utility Classes and "Separation of Concerns" https://adamwathan.me/css-utility-classes-and-separation-of-concerns/ Adam Wathan - Tailwind CSS: It looks awful, and it works - Rails World 2023 https://www.youtube.com/watch?v=TNXM4bqGqek
avatar
busylog
Notes for migrating to new iPhone
keep the old phone until finance/banking apps are successfully tested, and record related info first. but delete the app wont actually hurt as long as you dont wipe the phone to reset device id. remove most cards from Apple Pay, it will be saved to the cloud but some needs cvv / sms / phone verification later. you cant receive SMS until the entire transfer ends so you wont be successful re-enable those cards, so do it later. delete those Chinese apps that could simply re-login with mobile number and SMS (unless chats/files are valuable), it saves time…
avatar
busylog
Celebrate HLS support on Chrome 142+
You can use more browsers than players? Requirements: the Header Editor extension from https://he.firefoxcn.net/ if something can play on ffmpeg/mpv but not browser? "headers": { "user-agent": "Lavf/58.29.100", "referer": "_header_editor_remove_" } if something triggered direct downloads (application/octet-stream)? "condition": { "regex": "\\.m3u8" }, "headers": { "content-type": "application/vnd.apple.mpegurl" }, this might be useful as well. %{start msedge -argumentlist ("-inprivate", $_)}
没有更多内容。