#547 — April 8, 2021

Read on the Web

Ruby Weekly

Ruby 3.0.1 Released — A quick point release to fix two vulnerabilities: a XML round-trip vulnerability in REXML and a file creation vulnerability in tempfile on Windows. Ruby 2.7.3, 2.6.7 and 2.5.9 have also been released to fix these and other issues.

Yui Naruse and the Ruby Core Team

An Interview with Jeremy Evans — Jeremy is best known as the creator of Sequel, the Ruby database library, as well as Roda, and for maintaining the Ruby ports for OpenBSD. Here he shares his thoughts on where Roda trumps Rails and what features he’d remove from Ruby if he could.

Evrone

Redis 6.2 on RedisGreen — SSL encryption, key size tracking, memory mapping, online upgrades, and more.

RedisGreen sponsor

▶  YJIT: Building a New JIT Compiler Inside CRuby — A technical talk on the optimization challenges Ruby presents, how a JIT can help, and specific details about the YJIT (Yet Another Ruby JIT), a JIT project being worked on at Shopify by Maxime, Alan Wu, and Aaron ‘tenderlove’ Patterson.

Maxime Chevalier-Boisvert

RubyMine 2021.1 Released — The popular (though commercial) IDE gets a key update with added Ruby 3 and RBS support, improved code completion (from the RBS type signatures), and integration with a new collaborative development system JetBrains has released.

Nataliia Kudanova

Quick Bits

  • Two weeks ago we mentioned the release of Crystal 1.0, a compiled Ruby-inspired language, but just how fast is it? Very fast indeed but, and it's worth stressing this, it isn't Ruby even if it looks similar.
  • Somehow we missed this April Fool's joke, but it was proposed that rather than having rightward assignments like in Ruby 3.0, maybe we could try downwards assignments instead? :-) I'm not going to lie.. I like this in a warped kinda way.

💻 Jobs

Sr. Ruby Engineer at Propelor (Est Time Zone +/- 3 Hrs, Remote) — Interested in Fintech? Join our core team building the AI that will level the playing field for self-directed investors.

Propelor

Staff Rails Engineer-Denver or Remote — Ibotta is looking for a Staff Rails Engineer to work on the platform that powers our app that is used by millions of consumers.

Ibotta

Find Ruby Jobs with Hired — Take 5 minutes to build your free profile & start getting interviews for your next job. Companies on Hired are actively hiring right now.

Hired

📘 Articles & Tutorials

Four Non-Standard Ways to Fix N+1 Queries in Rails — Love this bit: “To make up for the cliché topic, I’ll describe less common solutions to this problem.” Pawel looks at some approaches to reduce the number of cascading queries without using includes or additional table join operations.

Paweł Urbanek

Building Real-Time Command Line Applications with Action Cable and Thor — Action Cable is great for adding real-time functionality to Rails apps, but did you know you can leverage it from the command line? A neat bit of experimentation at play here.

Hans-Jörg Schnedlitz

Why and How to Host your Rails 6 App with AWS ElasticBeanstalk and RDS — From the Honeybadger Developer Blog. When errors strike, Honeybadger’s monitoring service has your back to defeat them ⚔️

Honeybadger sponsor

Ruby 3.1 Adds Enumerable#compact and Enumerator::Lazy#compact — You’re probably familiar with Array’s compact method for removing nil elements, but now the same idea is being extended to enumerables and lazy enumerators.

Ashik Salman

▶  How to Use Stripe Checkout in Rails — Learn how to accept payments in your Rails app with Stripe Checkout using the Pay gem.

Go Rails

How to Set Up Tailwind CSS JIT in a Rails Project to Compile Styles 20x Faster — Leans on the JIT compiler that rolled out with this week’s Tailwind CSS 2.1 release.

Vladimir Dementyev

Building a DSL with Ruby — A look at a handful of Ruby based DSLs you might use on a frequent basis and then the basics of how such things are implemented.

Paweł Dąbrowski

Kubernetes Single Sign On: A Detailed Guide — How to set up a group based SSO system for Kubernetes including the kubectl CLI, any web app with ingress, a Docker registry and gitea.

Ben Dixon

HTTP Caching in Rails Apps“The fastest web page is one you’ve already loaded.”

Jonathan Miles

The Six Characters That Could Bring Down Your Rails App — Spoiler alert: It’s .count – I’m surprised it was so slow in their case, though, but a story is a story and they found a worthwhile fix.

Moncef Belyamani

🛠 Code and Tools

Mechanize 2.8: A Library for Automated Web Interaction — Automatically stores and sends cookies, follows redirects, and can follow links and submit forms, etc. Now needs Ruby 2.5 or newer.

Sparkle Motion

Clayoven: A Site Generator Aimed at Math-Heavy Sites — A curiously specific static site generator. Only 500 lines and, if you can understand it, certainly puts out good looking pages packed with math and diagrams.

Ramkumar Ramachandra

Application Dependencies Outdated? We Can Help

Hint sponsor

Avo 1.0: A Ruby on Rails Admin System — More about how it works in the documentation. Note that it’s only free for personal use and commercial otherwise, but the end results do look nice.

AvoHQ

InvoicePrinter 2.1: A Pure Ruby Invoice PDF Library — It now supports Ruby 3.

Josef Strzibny

Passenger 6.0.8: The Ruby (and More) App Server

Phusion Blog

ValidatesTimeliness 5.0: Date and Time Validation for ActiveModel and Rails

Adam Meehan

💡 Tip of the Week

Eval History in IRB

Often, when working in an IRB console, I'll realize only after running a command that I didn't store the result in a variable but I'd like to access it. Thankfully, IRB has _ to allow us to access our previous result:

irb> some.expensive_method
=> :some_result

# We can access the result without having
# to re-run the expensive method using _
irb> variable_to_store_result = _
=> :some_result

But did you know IRB also gives us the ability to access evaluations prior to the most recent one?

We have to configure this ability explicitly by setting IRB.conf[:EVAL_HISTORY] to the number of results we'd like to store. We can add this snippet to our ~/.irbrc file and it will apply to every IRB console we open:

# This will allow us to access our previous
# 3 evaluations in an IRB console
IRB.conf[:EVAL_HISTORY] = 3

Or, you can run this code within an already running IRB context:

IRB::CurrentContext().eval_history = 3

And then, once we've configured our eval history, we can access previous evaluations like this:

irb> this = "is just to demonstrate"
irb> how = :useful
irb> this_command = :can_be

# We'll see IRB.conf[:EVAL_HISTORY] number
# of the most recent results we've gotten
# if we use __
irb> __
=>
1 "is just to demonstrate"
2 :useful
3 :can_be

# And we can access them by index
> __[2]
=> :useful

# And even store them as variables
> some_var = __[3]
=> :can_be

Note: In case it's not clear, this feature uses a double underscore rather than a single one.

Hopefully this saves a little re-running of commands in IRB to store evaluations.

This week’s tip was written by Jemma Issroff.