Image of Lucian Ghinda writing for notes.ghinda.com
Short posts mostly about Ruby and Ruby on Rails. You can find me at : Linkedin, Mastodon, Twitter, Bluesky or for longer posts at allaboutcoding.ghinda.com. Check goodenoughtesting.com if you want to learn to write fewer tests and cover more features. 
Subscribe via RSS here

Twitter transitioned to Scala to continue writing beautiful code

I found this quote in this article about Twitter moving to Scala:

> But he also prefers Scala because it's, well, beautiful. "It's a fuzzy thing. But we like writing beautiful code, code that you're proud of, code that you can show to non-programmers and they get it."

Screenshot of quote from Payne from Twitter saying we like to write beautiful code
About Scala and writing beautiful code

They chose Scala because they wanted to write "beautiful code." 
I think I can say that Ruby influenced this decision in more ways than one.

Short Ruby Newsletter - Highlights from edition 117

🚀 Launches

  • Stanislav Katkov launched the website for poshtui.com
  • Lindsey Christensen launched the Hotwire Essentials
  • Sandi Metz announced a 40% discount for their books until 13 December
  • Martin Sojka launched codesnips.io
  • Andrey Eremin launched a new course Ruby on Types: Static Typing with Ruby and Ruby on Rails
  • Josef Strzibny announced that testdrivingrails.com - 1st edition is out

📅 Events:

  • RoRvsWild shared a map from Ruby meetups in Europe
  • Check RubyConferences.org/meetups as there 26 meetups this week only around the world
  • Ruby Central invites Ruby meetup organizers to apply for a grant
  • Balticruby announced CFP is open at papercall.io/balticruby25

👉 All about Code and Ruby

Ruby On Rails announced that The Rails Foundation welcomes 1Password as Core member.

There are a lot of code samples included; here are just some of them:

  • Drew Bragg shared a code sample about DATA constant in a Ruby file
  • Xavier Noria shared that Ruby already has “pipe operator" and that is the dot
  • Akash Manohar shared a tip about enabling debugging for Stimulus:
  • Prabin Poudel shared a code sample about accessing a helper method
  • Joel Drapper shared a code sample about defining a / method to lookup a record by using a Base64 id
  • Jamie Schembri shared a code sample about using StringInquirer from ActiveSupport
  • Joël Quenneville shared a code sample showing how converting to UTC changes a time value
  • Nate Berkopec shared a code sample about how IO/CPU interact with the GVL
    And there are so many more code samples. This edition is packed with interesting code samples, discussions about code design, and inspiration around code.

🧰 Gems, Libraries, Tools and Updates

  • Vladimir Dementyev published a new gem called wasmify-rails - Tools and extensions to pack and run Rails apps on Wasm
  • Sam Ruby announced a new gem called fly-atc - A SaaS toolkit for mutli-tenant production deployments with zero-config streaming backups
  • Alex Denisov shared their work on lightstorm: Minimalistic ahead-of-time Ruby compiler

You will also find updates on their projects or libraries from Rosa, who announced the 1.0 version of Mission Control Jobs, Avo, who announced version 3.15.0 with huge improvements, Bozhidar Batsov, who announced an update about Rubocop v1.69.1, Nate Hopkins, who announced an update about LocalBus v.0.3.0, and many more gem updates.

As always, we have more links to newsletters, videos, podcasts, and articles.

Read the full newsletter for free at https://newsletter.shortruby.com/p/edition-117

Using shoutouts.page to embed a link to my workshops

Maybe this would be a great time to share more buildinpublic or experiment with how this works.

This morning, I added a footer to the booklet about testing for developers Writebook from 37 Signals, and I used the that are using https://shoutouts.page for this.

Here is how it looks like on the main website https://booklet.goodenoughtesting.com

Displaying the embeded shoutout
Displaying the embeded shoutout

I created a small snippet on shoutouts.page by Vincent Ritter 

I chose this because, once included, any changes to the text or image will automatically update everywhere it's embedded

Here is how it looks like to create the shoutout:

The form for creating the shoutout
The form for creating the shoutout

I then embedded this to two places: 

  1. booklet.goodenoughtesting.com
  2. notes.ghinda.com - this blog where you read this content

I could not make it work for the Hashnode where I have the longer form articles: allaboutcoding.ghinda.com. Not sure why and I did not had time to debug. 

The entire process took me about 30 minutes at most, considering I already had the Open Graph image from a post I published about the #GoodEnoughTesting workshop some time ago.

Before using Shoutout, I manually added information about where to find me online at the end of each blog post. This process was time-consuming, and if I wanted to make changes, I had to edit multiple posts in various places.

Two recommendations if you want to start a blog

If you're planning to start a blog or just publish some notes, may I suggest two projects launched by two very lovely Ruby developers?

Both are easy to start with, simple to set up, and offer just enough options to get you going without the need to configure many things.

1️⃣ scribbles.page by Vincent Ritter 

I am using this one for the current notes blog, where I post shorter form article and quicker notes.

scribbles.page
scribbles.page

2️⃣ pagecord.com by Olly Headey

See an example of how it looks https://pagecord.com/pagecord

I am looking for a reason to use it :) even if I already have 2-3 blogs already

Pagecord is also open source at https://github.com/lylo/pagecord

pagecord.com
pagecord.com


Here is a short audio where I share why I think you should start a blog or share more your knowledge: 

https://podcast.shortruby.com/2417631/episodes/16192809-sharing-your-knowledge-as-a-path-to-mastery


 

Short Ruby Newsletter - edition 116

🚀 Launches


📅 Events:


👉 All about Code and Ruby

There a lot of code samples included; here are just some of them:

  • Jorge Manrubia shared they will announce a surprise for Hotwire before Christmas, Tobi Lutke shared the stats from Shopify during Black Friday
  • Postmodern asked about array.fetch(index,0) versus array[index] || 0 and there was an interesting discussion about it
  • RoRvsWild shared a code sample about avoiding returning from model’s method
  • Nate Berkopec shared the latency numbers every Ruby on Rails dev should know
  • Matt Swanson shared a code sample about using code design to guide developers to make the correct decisions
  • JP Camara shared a thread about calculating the largest known prime number by using the latest PR about "Do not round a**b to infinity by mame · Pull Request \#12033" that will be part of Ruby 3.4
  • Bozhidar Batsov shared a code sample about touching a file in Ruby by using File.open(path, ‘a’) {}
  • Jeremy Smith shared about Stimulus pain points and proposed a solution
  • Gregory Brown shared a a code sample about an inline template experiment
  • Ruby Cademy shared a code sample about using ActiveSupport::BacktraceCleaner
    And there are many more code samples you can browse and have inspiration while coding this week.

Remember to read ️ 📐Thinking about Code where Remi Mercier asked about how to trigger a bunch of turbo streams right after the initial request and got a couple of replies, Noel Rappin started a discussion about treating application.rb and environments files immutable, Benjamín Silva H. asked about if the loops benchmark can be optimised and read the replies.

Inside 💡Around code section, Tropical.Rb asked absout recommendations for people just getting started with Rails and there are some nice replies there about it.

🧰 Gems, Libraries, Tools and Updates

  • Yaroslav Shmarov announced a new gem hotwire_native_rails - Hotwire Native generator for Rails applications
  • Harry Lascelles announced a new gem dememoize - A rubygem to remove memoized values (instance variables) for easier testing
  • Marcus Almeida announced a new gem curlify - The gem convert ruby requests(net/http) into curl command
  • Samuel Williams announced a new project async-discord - combining async-ollama and async-discord
  • Svyatoslav Kryukov announced a new demo repo skryukov/inertia_rails_svelte5_ssr
  • Nemo published a new gem jekyll-sqlite - A Jekyll plugin to use SQLite databases as a data source
  • Adrien Siami announced a new gem hyperactiveform: Simple form objects for Rails
  • Onyx announced a new gem for Pinata library pinata-ruby
    There are also interesting updates from various gems and libraries.

As always, we have more links to newsletters, videos, podcasts, and articles.

Read the full newsletter for free at https://newsletter.shortruby.com/p/edition-116

Reminder to write articles about Ruby to have better LLM suggestions

Reminder to publish article about Ruby
Reminder to publish article about Ruby

This is a weekly reminder that if you want better suggestions for Ruby and Rails projects using LLMs (Large Language Models), you should consider writing more articles (not generated by LLMs) about how you believe idiomatic Ruby and Rails code should be written or showing modern Ruby and Rails code. 

Aim to produce content for beginners, intermediates, seniors, and experts. The more you publish online, the better!

Remember that current AIs are LLMs, so to receive improved suggestions for Ruby, you need to train them with more knowledge.

Additionally, there is a lot of outdated Ruby content that requires refreshing. One way to identify this content is to browse Stack Overflow for older questions and write articles on how you would solve those questions using Ruby 3.3+ and Rails 8.

Here are two queries you can use for reference:

  • https://stackoverflow.com/questions/tagged/ruby?sort=MostFrequent&edited=true
    - https://stackoverflow.com/questions/tagged/rails?sort=MostFrequent&edited=true

Take a look at those questions from 2011. Please write an article providing a fresh answer for them.

When Neovim does not know the Ruby version

If you are using:
- MacOS
- Neovim configured with Lua
- a Ruby version manager (for example chruby)
- zsh 

Then in case you cannot install for example RubyLSP because after installing a new version of Ruby it seems like Neovim does not recognize anymore the global Ruby version set and defaults to the system Ruby (which is ruby 2.6.x) you can fix this by adding the following to your Lua Neovim config:

vim.opt.shell = "zsh"
How to fix when Neovim loads system's Ruby version
How to fix when Neovim loads system's Ruby version

Short Ruby Newsletter - edition 115 highlights


🚀 Launches

  • Kuba Suder launched sdk.blue - a collection of all SDKs about Bluesky
  • Brian Casel launched Instrumental.dev - Rails UI Components to Build Better Products, Faster
  • Zack Gilbert launched susanssudoku.com - a simple in browser Sudoku
  • Check the Short Ruby Newsletter Deals for Ruby Developers page

📅 Events:

  • Visuality announced the Ruby Community Conference - Winter 2025, with Rosa Gutierrez being the first speaker
  • Paul Campbell shared they are thinking to organise a Ruby conference in Ireland
  • Balkan Ruby announced tickets are on sale for balkanruby.com
  • Check rubyconferences.org to see upcoming conferences announced and rubyconferences.org/meetups to see all meetups that will happen this week

👉 All about Code and Ruby
There are a lot of code samples included; here are just some of them:

  • Xavier Noria shared that alias_method does not give a polymorphic alias
  • Henrik Nyh shared a code sample about combining uniq and sole to check object classes
  • Ross Kaffenberger shared a code sample about using Rails excluding and with
  • Kerrick Long shared an interesting code sample about using the under-the-covers technique shared last week by Victor Shepelev in their article
  • Ruby Cademy shared about using pick and ids instead of pluck for getting the attribute of the first element or the ids
  • Saeloun shared about generating controllers in Rails with --parent option
    And there are a lot more code sample to inspire you while coding.

Remember to read ️ 📐Thinking about Code where Russ Olsen asked about what's new in Ruby in the last 5 years and got a lot of replies, where Brandon Weaver shared about modularity failing because it is seen as a technical issue and other interesting discussions.

🧰 Gems, Libraries, Tools and Updates

  • Chris Oliver announced a new gem black_friday: Black Friday sales in your Rails apps
  • Samuel Williams announced a new gem socketry/async-cable
  • Vladimir Dementyev published a new branch about Demo: pglite & electric-sql
  • Lucas Mendelowski announced a new repository hotwire-htmx-unpoly:Simple TODO application built with Rails to compare Hotwire, HTMX, and Unpoly
  • Rails Designer published a new gem stealth_dom_id - Extends Rails dom_id helper to support custom attribute-based identifiers
  • Evgeniy Demin published a new gem called database_schema_ownership - Provide an easy way to manage code ownership over a database schema

You will also find updates on their projects or libraries from a new Puma version 6.5.0, Bridgetown 2.0 Beta 3, Rodauth 2.37, a discussion on Ruby parser about how Rubocop will be affected by deprecating the current parser, the introduction of Fiber::Scheduler#blocking_operation_wait to Ruby and a lot more.

As always, we have more links to newsletters, videos, podcasts, and articles.

Read the full newsletter for free at newsletter.shortruby.com/p/edition-115

Comparison of image quality Twitter vs Bluesky

What kind of image (compressions, AR, ...)  do I need to upload to Bluesky to have them show high quality?

Here is a comparison (left: Twitter, right: Bluesky) of screenshots taken from MacOS / Safari, which I think has the best quality.

Comparison of images shared on Twitter vs Bluesky
Comparison of images shared on Twitter vs Bluesky

RBS inline code sample from Anycable example

I was reading this article Hey, AnyCable speaking! Needing help with a Twilio-OpenAI connection? by Vladimir Dementyev over last weekend and noticed an example of RBS inline usage:

Code sample showing usage of RBS Inline
Code sample showing usage of RBS Inline

That made me curious about how the tool configuration is created to be used by the other pieces of sofware.

Thus I browsed the source code and found inside https://github.com/anycable/twilio-ai-demo/blob/demo/rbs-tools an exciting combination of parsing RBS Inline with Prism to read method definitions and generate functions for LLM:

Code sample from RBSTools module that parses method signatures
Code sample from RBSTools module that parses method signatures

Source: module RBSTools::MethodDecl - I like what Vladimir did here and the idea to parse the method signature to create LLM functions. 

Using Pattern Matching in Ruby to act based on array contents

The following piece of code is inspired by something I wrote the other day. I cannot share the exact piece of code or the content, but I liked the syntax so I played a bit with it here. 

Matching against array being empty or not 

You can use in [] to match if the array is empty. And you can use in [*] to match when an array has elements. 

You can combine in with if and have something like: in [*] if <condition>

Example of using pattern matching to check empty/non-empty arrays
Example of using pattern matching to check empty/non-empty arrays

Please note the results of using in [] and in [*] with empty

Remember that [] in [] will return true and use case in with checking about empty first:

Checking about being empty first
Checking about being empty first

Using pattern matching with values of elements inside the array

Pattern matching can also be used in this way: to check if there are any elements with 0 or nil values inside the array:

Checking if any elements are of a specific type and values
Checking if any elements are of a specific type and values

Short Ruby Newsletter - edition 114 highlights

🚀 Launches

  • Josh Branchaud launched Ruby Operator* Lookup
  • Andrea Rocca launched blackfridaycapitalist.com - a pay to play directory of Black Friday deals
  • Mikkel Malmberg launched Nitro Kit - is a set of generic UI components to help you build your Ruby on Rails application
  • Tonton Cyber launched ShipOnRails AI - a specialized and up-to-date AI for Ruby on Rails developers with Rails 8, Kamal, Turbo, Stimulus, and more than 100 gems

📅 Events:

  • Jason Swett announced that tickets for SinCityRuby are now on sale:
  • Ruby Conf asked about the interest in the final RailsConf in 2025
  • Greg Molnar announced they are thinking of organizing a Ruby conference in Furnas, on Sao Miguel island of the Azores.
  • There are 15 meetups happening this week. Check RubyConferences.org for when and where they are happening.

👉 All about Code and Ruby
There a lot of code samples included, here are just some of them:

  • Use DRB to interact with Nick Schwaderer blog, and read about neste module calls reopening from Xavier Noria
  • Victor Shepelev shared how they implemented a not-a-pipe operator in Ruby
  • James shared a code sample about downloading file using multiple range requests, Jorge Manrubia shared a code to replicate a bug on M4 when working in YJIT
  • Jeremy Smith shared the code for a bin script that opens the locally sent emails, RoRvsWild shared a script to stop waiting for Redis responses when pipelining
  • Emmanuel Hayford shared a code sample showing how the rate limiter works in Rails 8, Kuba Suder shared how to use Skyfall gem to listen to Bluesky firehouse

Remember to read ️ 📐Thinking about Code where you will find discussions about service objects, about TDD, about migrating from Next.js to Ruby on Rails and Inertia, about how to process webhooks and much more.
Inside 💡Around code section you will find a list of Starter Packs about Ruby and Ruby on Rails that you can find on Bluesky and there is a nice collection of why people are choosing Ruby and Ruby on Rails inside the ❤️ Why Choose Ruby and Rails` section

🧰 Gems, Libraries, Tools and Updates

  • Marc Köhlbrugge announced a new WIP Rails repository showing how to work with omniauth and atproto
  • Peter Bhat Harkins published a new gem called quickquestion - cli utility for asking Claude a quick question
  • Igor Alexandrov announced Kamal Deploy · Actions · GitHub Marketplace
  • Eth3rnit3 published a new gem chromate - Chromate is a Ruby library to control Google Chrome with the Chrome DevTools Protocol

And you will find updates of their projects or libraries from Roda, 37Signals Writebook, Redmine, skyfall, raix and more gems.

As always, we have more links to newsletters, videos, podcasts, and articles.

Read the full newsletter for free at https://newsletter.shortruby.com/p/edition-114

Script to display VCR body using jq

When I work with VCR in Ruby on Rails, I like to see the structure of the body printed as formatted JSON

The current setup: 

  • have VCR save responses as JSON (it is not always a good idea 😀 )
  • install `jq`
  • setup `~/.local/bin` to be loaded in .zshrc
    How to setup
    How to setup
    Here is the script: 
\#!/usr/bin/env bash

if [ $\# -ne 1 ]; then
    echo "Usage: $0 <json_file>"
    exit 1
fi

input_file="$1"

\# Does the file exists?
if [ ! -f "$input_file" ]; then
    echo "Error: File '$input_file' not found"
    exit 1
fi

\# is jq installed ?
if ! command -v jq &> /dev/null; then
    echo "Error: jq is not installed. Please install it first."
    exit 1
fi

\# Process the JSON file
jq -r '.http_interactions[0].response.body.string' "$input_file" | jq '.'

Here is an example of how to use it: 

Example of output when using the script
Example of output when using the script

My first contribution to ruby-lang.org website

I am so grateful for the ongoing effort to improve the Ruby documentation done by Stan Lo.

I think we should try to contribute too in any way we can and make the documentation welcoming for new people who might join our community and start learning.

For example, a while back, while reading some materials for the ShortRuby Newsletter, I encountered people who were confused about which one was the official Ruby documentation.

So I just tried to do a small PR about it:

Source: https://github.com/ruby/www.ruby-lang.org/pull/3352
Source: https://github.com/ruby/www.ruby-lang.org/pull/3352

I think there are a lot of opportunities to contribute. It does not matter if you are a beginner or expert. You can make the Ruby documentation better.

If you don't know how to contribute, I think you should read Stan Lo's  article about his vision on Ruby documentation, where he also shares how other people can contribute: A RDoc Maintainer's View on Ruby's Documentation

On the same direction of improving documentation, there is also this project by Masafumi Okura that won one of the three 2024 Ruby Association Grants  that has as objective to create a plugin system for RDoc:

2024 Ruby Association Grant selection result - A plugin system for RDoc
2024 Ruby Association Grant selection result - A plugin system for RDoc

Choosing between if and a modifier

A little bit of bikeshedding: In Ruby, even outside of guard clauses, I sometimes use modifiers to make the code easier to read out loud.

A mental rule that I use to choose when to use a full if versus a modifier is taking into consideration if the condition has a side effect:

An image with three code samples showing an Active Record model and two options to check if post is saved
Example of two ways to write a condition

In this case I would choose the explicit if because the post.save has some important information when reading this code, while return Success(post) if post.save focuses on what is returned when skimming the code.

An image with a block of code and an explanaation about why I would choose that version
Using the normal if to communicate the important of the post.save operation
Written by Lucian Ghinda - Senior Ruby Developer by day, Curator of Short Ruby Newsletter during weekends