#​574 — October 14, 2021

Read on the Web

Ruby Weekly

Embracing Infinite Loops with Ruby and Polyphony — See how infinite loops can be used as the basis for long running concurrent tasks here with Polyphony, a io_uring/libev oriented concurrency library, doing the heavy lifting.

Sharon Rosner

▶  39 Talks from RubyKaigi Takeout 2021 — The popular RubyKaigi conference usually takes place in Japan each year but was held online again due to the ongoing world health problems. A wide array of both English and Japanese talks happened, including these:

RubyKaigi

Complete Peace of Mind Rails Hosting — OpsCare is 100% peace of mind Rails hosting and support. Built on our 12-factor compliant custom stack, we provide comprehensive deployment, scaling and monitoring tools. OpsCare keeps your application performing, 24 hours a day - 7 days a week.

OpsCare by reinteractive sponsor

Ruby2JS 4.2.0: A Ruby to JavaScript Transpiler — A transpiler aimed at keeping your code looking ‘hand crafted’ rather than merely transpiled. There’s a live demo if you want to see it in action.

Sam Ruby and Jared White

QUICK BITS:

A Ruby One-Liners Cookbook — Ruby is a fantastic language for one-liners, whether in IRB or even from the command line. This cookbook is an extension of a epic list of them we’ve shared before, and it relates to our Tip of the Week further down this issue too :-)

Sundeep Agarwal

Jobs

Principal Ruby Platform Engineer (Remote - EST Timezone +/- 3 hours) — Interested in Fintech? Join our core team building the AI that will level the playing field for self-directed investors.
Propelor

Senior Backend Software Engineer (Remote) — Design, develop, and extend our data integration framework and APIs to continue to onboard new AMI Customers and social sellers.
Sell With Ami

Find Ruby Jobs Through Hired — Create a profile on Hired to connect with hiring managers at growing startups and Fortune 500 companies. It's free for job-seekers.
Hired

📕 Articles & Tutorials

Upgrading to Zeitwerk — A walkthrough of what’s involved in upgrading a Rails 6 app from classic to Zeitwork mode, if you haven’t taken on Zeitwerk yet.

Simon Chiu

Ruby Safe Navigation — Using the lonely (or safe) operator (&.) says some things about your code that you may not realize and, once you do, there may be a better way to say them.

Joël Quenneville

Using DynamoDB in Your Rails App — Julie introduces DynamoDB and its concepts then closes by showing how using it can feel very much like Active Record.

Julie Kent

A Way to Detect Early Returns from a Block — An interesting little technique the author discovered via this Rails PR.

Ben Sheldon

▶  Discussing Polished Ruby Programming with Jeremy Evans — Jeremy joins the Rogues to discuss his new book, Polished Ruby Programming, and his opinions on and best practices for Ruby development.

Ruby Rogues Podcast podcast

▶  A Team Looks at Reducing Memory Bloat in a Rails App — A team has shared an 11-minute, originally internal-use-only, video of a post mortem of a Rails memory bloat issue they experienced.

bigbinary

Seamlessly Integrate Video into Your Ruby App

Mux sponsor

Organizing Business Logic in Rails with Contexts — Josef takes on the age-old conundrum of models vs service objects, adding a new take he gleaned from working with the Phoenix framework.

Josef Strzibny

▶  Discussing the Organization of Large Rails Apps with Jared White

Code with Jason Podcast podcast

▶  How to Use Bootstrap with CSS Bundling in Rails
Go Rails

🛠 Code & Tools

redis-rb 4.5: The Ruby Client Library for Redis — The official Ruby client for the Redis data structure server. 4.5 adds support for a variety of command introduced in Redis 6.2 like ZRANDMEMBER, ZMSCORE and SMISMEMBER.

Redis

JRuby 9.3.1.0 Released — The latest release of the Ruby 2.6.x compatible line of the JVM-based Ruby implementation.

JRuby Core Team

A Better Way to Index Your Postgres Database: pganalyze Index Advisor — Paste your query and schema data and the free pganalyze Index Advisor recommends the ideal index for your query.

pganalyze sponsor

Informers: State-of-the-Art Natural Language Processing for Ruby — You can do sentiment analysis, question answering, name-entity recognition, and the latest feature is text generation.

Andrew Kane

benchmark-ips: 'Iterations Per Second' Benchmarking for Ruby — Improves the standard Benchmark functionality.

Evan Phoenix

DeadEnd: Searches for Unexpected end Syntax Errors — This is a very specific tool, but if unmatched ends are a particular bugbear of yours..

ZomboCom

Xcodeproj: Create and Modify Xcode Projects from Ruby
CocoaPods

💡 Tip of the Week



Ruby's -e and -c command line options

You will be familiar with running Ruby code saved in a file from the command line using ruby filename.rb. You'll also be familiar, especially if you follow along with the Tip of the Week!, with running snippets of code within different Ruby REPLs, such as irb, pry, rails c or something else.

We can also run small snippets by passing the -e flag to ruby from the command line. For instance:

$ ruby -e "puts 1 + 3"
4

The -e flag can come in handy if we're looking for a specific method, or just need a quick calculation, and don't necessarily need to open up a full REPL.

This guide to Ruby 'one liners' provides a vast array of ways to use the -e flag along with others to achieve quite complex outcomes from the command line or shell script.

Another useful flag is -c which will do a Ruby syntax check on a file without actually executing the file. I find this useful when resolving git merge conflicts, as a way to double check that I haven't left any stray lines in my Ruby files. For instance:

$ ruby -c some_file.rb
some_file.rb:1: syntax error, unexpected end-of-input

The -e and -c flags are two of many which we can use when running ruby from the command line. To see more options, run man ruby from the command line, and we will cover some more interesting ones in coming weeks too.

This week’s tip was written by Jemma Issroff.

🕰 ICYMI (Some older stuff that may catch your eye...)