Writing & video
Ruby craft, one idea at a time.
Latest
ActionController::Live gives you SSE in six lines, and one open stream blocked every other request in that Puma process for as long as it stayed open. Measured on Rails 8.1.4: 3.0 seconds of blocking from a 4 second stream, while a plain sleeping action blocked nothing at all.
Read more
JSON.create_id, a json_create hook and create_additions turn JSON.parse into an object factory. One iteration instead of two, and it has been in the standard library all along.
One model, one controller, one route. Slugs that generate themselves with SecureRandom, a click counter that does not restamp the row, and why allow_other_host exists at all.
One method_missing hook generates every HTML tag. The Ruby object model, the ancestor chain, the method lookup path, and the two tag names Kernel already owns.
Seven lines of Ruby add a palindrome? method to String. What the POSIX regex, Module#include and Unicode accents actually do to it.
A Ruby interview question: evaluate 2+3*4 as 14 without eval. Precedence as an array of operator levels, leftmost-first reduction, and where it breaks.