[Cookie] SameSite Attribute

SameSite 為一項在寫入 cookie 時可加註的屬性 SameSite Attribute: Strict 最嚴格,完全禁止第三方 Cookies,same-site request 才能夠帶有此 cookie Lax 全部的 same-site request 以及部分 cross-site request 能夠寫入 cookie,Get 請求除外 None same-site 及 cross-site 的 request 上, 都可以帶有該 cookie。但需設置 Secure »

[Rails] Pluralize i18n

rails i18n 如遇到單複數的情況可以這樣寫 en: notification: one: You have 1 notification other: You have %{count} notifications 在指定的 key 下增加 one、other 兩個 key,並將數量帶入 other <%= t("notification", count: current_user.notifications.count) %> i18n 就會自動判斷單複數做對 »

[Rails] clean-rails-codebase

一些整理 rails repo codebase 的技巧 包含了 rails 的 bundle, js 的 yarn, 還有 git branch, … Ref: Spring Cleaning: Tidying up your codebase »

[Ruby] Announcing RubyGems stats

RubyGems 的團隊將一些使用資訊整理在 stats.rubygems.org 可以看到各時間區間,每個版本、平台的使用率,蠻有趣的 XD RubyGems.org 每天產生的 log 大約 500GB,非常驚人的量 他們使用 rust 做 parse log 的處理,相關文章的連結都附在文末 Ref: Announcing RubyGems.org Stats Parsing logs 230x faster with Rust ecosystem source kirby »

[CSS] 在網頁上實作 dark mode 自動切換

使用 css prefers-color-scheme 可以偵測使用者裝置的 appearance 是使用 light mode 還是 dark mode 因此可以這樣寫,區分 light mode 與 dark mode 的 style 並自動切換 @media (prefers-color-scheme: dark) { # dark mode 所需 style } Ref: How To Add CSS Dark Mode To A Website »