看了一下 Egg 的语法,目前整体风格似乎更接近 Zig。
想请教一下,在设计 Egg 时,有没有考虑过采用 Ruby 风格的关键字和语法结构(例如 def...end、case...when),让它具有更强的 Ruby-like syntax?
选择目前这种语法风格,主要是出于解析器实现、静态类型系统和所有权语义方面的考虑,还是有其他设计上的权衡(design trade-offs)?
升级了,谢谢,最近光看别的语言的热闹了,想不到 Ruby 也有!有了 AI 是不是闭源安全一点 :)
能力越大责任越大,大佬再做一个 spinel 的 windows port 吧,Windows 搞定后就可以做一个 Sails 了,用来打败 Electron, Tauri, Wails.
感觉是自嗨爽文或脱敏的钓鱼文章,如果没入职才有可能泄漏面试题。
Rails Service 只是一个单纯处理单一动作的 Ruby 类,通常会包装在一个 call 方法中,如果场景合适,我觉得也是 rails 味的,以下是上古时期的学习资料:
https://www.toptal.com/developers/ruby-on-rails/rails-service-objects-tutorial
https://www.honeybadger.io/blog/refactor-ruby-rails-service-object/
https://dev.to/joker666/ruby-on-rails-pattern-service-objects-b19
https://codeclimate.com/legacy/7-ways-to-decompose-fat-activerecord-models
https://blog.appsignal.com/2020/09/16/rails-concers-to-concern-or-not-to-concern.html
Fat model 其实也是问题,拆成 concerns, service 是常规操作。
俱往矣,现在都是闭着眼睛 PUA Opus 了。
总会有小白鼠的,但不能是我 :)
matz 也用上了 claud,一个月搞定 rewritten
现在都不手写代码了,提交前用一下 bin/rubocop -f github -a
很好,是不是要加个 ping 服务,因为上次我的服务器没挂,nginx 挂了。然后再配个 resend 邮件服务,如果网站掉线直接发邮件
对生态很好的补充。
你们职业生涯以来因为数据类型导致的 bugs 遇到过几例,我几乎没有这方面的记忆。 现在几乎也是 AI 写代码,估计现在 AI 也不习惯用 T-Ruby。
无法想象,这公司的人脑子进水了吗?为什么为难老百姓。再说让别人限期搬走也可以啊,这域名过期还没法续费。
生产环境不急着升吧。
我还没转正,不能留言,如果你有空可以介绍一下多租户的思路吗?谢谢!
粗看了一下,好像实现得不太灵活,下面这篇感觉更灵活,但会复杂很多:
https://jumpstartrails.com/docs/accounts
我的意思是基于别人的改造,还不如自己搭,Rails 加上 AI, 应该很快。改别人的说不定不适合自己,还有很多潜在的坑你也不知道,这种涉及交费的系统,稍不注意可能要破财。
gem "devise"
gem "rolify"
gem "pundit"
每个商户一个 tenant_id, 然后就是 CRUD, 这不分分钟就搭好了吗?
class Tenant < ApplicationRecord
has_many :users
has_many :shops # 加钱后, 每个商户还能开多个商店
class User < ApplicationRecord
belongs_to :tenant, optional: true
has_and_belongs_to_many :shops
class Role < ApplicationRecord
validates :name, presence: true, uniqueness: true
has_and_belongs_to_many :users, :join_table => :users_roles
很棒!
下面是我的分屏脚本
hs.window.animationDuration = 0
units = {
left50 = { x = 0.00, y = 0.00, w = 0.50, h = 1.00 },
right50 = { x = 0.50, y = 0.00, w = 0.50, h = 1.00 },
up50 = { x = 0.00, y = 0.00, w = 1.00, h = 0.50 },
down50 = { x = 0.00, y = 0.50, w = 1.00, h = 0.50 },
left30 = { x = 0.00, y = 0.00, w = 0.30, h = 1.00 },
mid55 = { x = 0.30, y = 0.00, w = 0.55, h = 1.00 },
right15 = { x = 0.85, y = 0.00, w = 0.15, h = 1.00 },
maximum = { x = 0.00, y = 0.00, w = 1.00, h = 1.00 }
}
coc = { 'ctrl', 'option', 'cmd' }
hs.hotkey.bind(coc, 'left', function() hs.window.focusedWindow():move(units.left50, nil, true) end)
hs.hotkey.bind(coc, 'right', function() hs.window.focusedWindow():move(units.right50, nil, true) end)
hs.hotkey.bind(coc, 'up', function() hs.window.focusedWindow():move(units.up50, nil, true) end)
hs.hotkey.bind(coc, 'down', function() hs.window.focusedWindow():move(units.down50, nil, true) end)
hs.hotkey.bind(coc, 'j', function() hs.window.focusedWindow():move(units.left30, nil, true) end)
hs.hotkey.bind(coc, 'k', function() hs.window.focusedWindow():move(units.mid55, nil, true) end)
hs.hotkey.bind(coc, 'l', function() hs.window.focusedWindow():move(units.right15, nil, true) end)
hs.hotkey.bind(coc, 'm', function() hs.window.focusedWindow():move(units.maximum, nil, true) end)
-- bind hotkey
hs.hotkey.bind(coc, 'n', function()
-- get the focused window
local win = hs.window.focusedWindow()
-- get the screen where the focused window is displayed, a.k.a. current screen
local screen = win:screen()
-- compute the unitRect of the focused window relative to the current screen
-- and move the window to the next screen setting the same unitRect
win:move(win:frame():toUnitRect(screen:frame()), screen:next(), true, 0)
end)
看上去不错,还没试过,如果在 ~/.config/hola/provision.rb 添加了新的项目,那些已经执行过的老项目还会重复执行一次吗?
我以前一直用 Mac, 直到现在公司配了 Window 电脑,发现 WSL 也很好用,再加上 docker, 完全没问题。
很棒!不过 2025 年的 Feature list 里 Ctrl + F 怎么没找到 AI
我的经验是找工作就像找对象,你在找公司,公司也在找你,如果刚好对上了,那真的很容易。如果你身怀 Ruby 绝技,公司却要找个 C++, 那就难了。
https://github.com/socketry/falcon
建议在生产环境中不要这样做,作者说的是 I saw an opportunity
Once I had something working, I saw an opportunity to simplify my development, testing and production environments, replacing production (Nginx+Passenger) and development (Puma) with Falcon.
非常感谢你的第一手经验分享,不知道除了自动整理文件、定时发邮件之外,还有没有可能分享其它不涉密的案例,这样可以帮助大家打开思路。
这个要留言点赞,Ruby on Rails 界的一件年度大事。
问了 ChatGPT, 它说:
在 PostgreSQL 里,默认情况下唯一索引会允许多个 NULL, 但如果你指定了 NULLS NOT DISTINCT,就会把 NULL 当作相等值处理,从而不允许多个 NULL 出现。
所以你可以试试去掉 nulls_not_distinct: true. 这 nulls_not_distinct 其实说得也很直白,就是把多个 nulls 认定为非 distinct, 插入第二个 null 就破坏了 distinct.
我没花时间尝试,这种情况我一般像 @Rei 那样找个大众一点的方式,这样才不会出小众的错。
jetbrains 现在有点被动了,我现在都用 cursor + claude-4-sonnet
以前买过商业许可,他们搞的是复杂的 perpetual fallback license, 就算是一年内的后续版本修复了 Bug 也要让我退回一年前有 Bug 的版本。 至少要把 Bugfix 和 Features 分开吧,这种 license 只能每年交年费。
可以试一下,基本还是可用的。个人感觉 Sonoma 比 Sequoia 要流畅一些。
有机会的时候多布道,这样社区会壮大,这样才能有更多公司用 Ruby, 如果能加入用 Ruby 的公司,自己就可以不写让自己难受的 js, java 等代码了。
使用 Ruby 的公司在减少,这是事实,但市场还是挺大的,如果自己水平不错,工资比 php, js , java 还是要高不少,错开了与那一大堆人的竞争。
一个人同时只能做一两份工作,有机会就用自己喜欢的语言,框架,同时保持学习其它语言,了解优缺点,最好拿小项目多练练手,这样在没工作的时候,也是可以接受其它语言的工作的,如果可能接了别的工作后,可以先画饼,在局部加入 Ruby, 比如 micro service 的某部分,一旦效果不错,再画更大的饼就可以继续友好扩张。
12 年的 mbp 跑 Omarchy 绝对没问题,用 oclp 还能跑 Sequoia 15.7, windows 11 驱动也是全的。
换个 2TB SSD, 再换一下硅脂,清一下风扇,还可以再战 10 年。
真的不想试一下 oclp 吗?