- Short Ruby Newsletter
- Posts
- Issue #8 - 29 August - 4 September 2022
Issue #8 - 29 August - 4 September 2022
The one with pattern matching
Hello,
Iβm Lucian (@lucianghinda on Twitter), and I am the curator of this newsletter.
π Code Summaries: Last week, I launched a new section on the newsletter website called Code Summaries. The purpose is to summarise technical articles with Ruby code. I started with the idea that most of the time, I first want to see the code and then read an explanation. That section is not sent via email as I plan to publish it several times weekly. But you can subscribe to it if you want; here is how.
This edition was created with support from @adrianthedev from Avo for Ruby on Rails (a friendly full-featured Rails admin panel) and from @jcsrb, who sent me recommendations to include in the newsletter.
If you have any feedback or ideas about this newsletter, please reach out on Twitter or via email at [email protected]
π Emmanuel Hayford shared a tip about how to use Kernel method:
π Petrik De Heus shared a performance benchmark for running simultaneous connections in Ruby 3.2 thanks to work done by @_k01
See the benchmarks here on Github
π Nicolas Alpi πͺ shared their experience with deploying a Ruby on Rails app on various PaaS providers:
Here are some main things to consider, but please read the entire thread on Twitter (or via TheReaderApp):
Heroku: βWill not be able to achieve multi-regionβ
Render:
Configuring render.yaml can require some time. More focus on deploying infrastructure and not an app
Price is more flexible than Heroku
Works great, documentation is very good once you understand the concept of infrastructure as code
Multi-region: similar with Heroku, the way to do this is to deploy region based apps
Fly:
Region works great
Encountered various errors from jmalloc to Ruby version
They seem a bit behind answering community questions
Railway
Pricing based on usage
Simple to deploy
Hatchbokio:
"For medium size apps (2 web, 1 worker, 1 db, 1 redis) it can quickly lead to similar(ish) cost than Heroku but with bigger servers"
Simple deployment and works out of the box
You manage the actual servers, "These are not managed servers, you will be in charge of them"
π Nejdet Kadir shared an example about how to dry-rb to validate params:
π Joel Drapper shared new benchmarks for Phlex:
π Emmanuel Hayford shared a piece of code about how to restrict a method to accept keyword args:
π Facundo Espinosa shared a code example about using |= operator:
π A question asked by Facundo Espinosa about what do you use for Admins today in Rails, triggered an excellent answer by Adrian Marin from www.avo.cool about what DSLs are:
And he then goes to balance between writing Rails code and making abstractions:
π Nate Berkopec shared advice about how to use Puma and triggered and discussion about how to design the app to call external services:
It is worth reading the thread as is has some interesting takes:
In case you still want Puma with threads, Nate shared in 2021 a good thread about a basic configuration. You should read that Twitter thread as it has more recommendations for various configurations. Here are the main points:
π Andrew Mason shared how to use Pry to show source location for methods:
If you are not using Pry, the source location is included in Ruby.
π A frustration shared by Benoit Daloze about the defaults of Rubocop, triggered a long discussion with some examples of defaults for cops not working well for some people.
As a result of this Joel Drapper shared they are starting a new project to set up sane Rubocop defaults. The work has not yet started, but he already created a repo for it here at joeldrapper/good_cop
π Facundo Espinosa shared a short TIL about reorder in active record:
π Ruby Conf Mini shared an announcement about an opportunity scholarship for RubyConfMini. You can directly apply here if you want. Deadline 17 September.
π Nate Berkopec shared a proposal about how to name queues: by using their SLAs:
For more insights, you can read this article about how they do this at Gusto.
π Julian Rubisch shared a sample code to feature flag a route in Rails when using Devise:
π Steve Polito shared advice with a code sample for testing error messages:
Code sample:
π Jason Swett shared an experiment to organise tests by feature and not by test type:
The main benefit is:
I can run ALL the tests for a feature or area in one command because they're all grouped in one folder - great for when I want to check for regressions without having to run the entire test suite
Here is how he explains the structure of the test folder:
π Drew Bragg shared an old code example about reading __END__ data in multi-file view component:
But there are more ideas about how to do this in this thread started by Konnor Rogers
π Thiago Massa shared that merging hash with splat operator is faster (source) than using merge:
He also shared a code sample about how to use pattern matching:
And here is another example shared by Thiago Massa :
And here is an example shared by me where I mix pattern matching with static typing checking and omitting values in keyword arguments:
If you read so far and you like the content, maybe you take into consideration sharing this and subscribe:
Related (but not Ruby specific)
Josef Strzibny shared a concise image explaining positioning for CSS grid layout:
Koichi Ito shared shared 3 frames in time when a developer is doing a review of their work:
Vim Tricks shared tip about how to change case in VIM:
Jared White shared a new project about converting Tailwind CSS to Semantic CSS: vanillabreeze.dev:
He wrote a good article explaining how to use utility classes in a maintainable way: The Three Laws of Utility Classes. It is worth reading!
Tobias Petry.Sql shared shared a new SQL tip about how to fill in data gaps automatically in SQL:
Mike Perham shared a good and short insight into marketing:
Thiago Massa shared nice trick to transpile JS in browser:
Gee Paw Hill shared an excellent thread about how we think, and this tweet is an excellent summary of what makes change hard:
Articles and Videos
Courses or Books
Justin shared launched a new Ruby On Rails course: Modern Application Development with Rails
Something to read
Newsletters
π VimTricks released a new edition of their newsletter about Vim here: Vim Search Visual Selection
π Greg Molnar shared they published the latest issue of This week in rails
π David shared a new newsletter with interesting things found on Twitter: Weekly bookmarks - Issue #17
π Ruby LibHunt released their 328 issue of Awesome Ruby Newsletter.
π Ruby Weekly released their 618 issue
π Ruby Radar shared they released their 65 issues: #65 - Fly Away From Heroku
Articles
Tom Doe shared an article about Ruby loops overview.
The Ruby Dev shared how to set up Git to run static analysis on Ruby/Rails: Read the article here
Tute Costa shared an article about value objects in Ruby, written by JoΓ«l Quenneville: Value Object Semantics in Ruby
Chris Oliver shared how they built GoRails into a sustainable business: How This Midwestern Coder Overcame Self-Doubt to Earn Over $1.8 Million Continuing a Community Legacy
Justin Searls shared a new article they wrote about using custom attributes types in Rails and how to use them with forms: Stateless Forms with the Rails Attributes API
Ruby Lib Hunt shared an article about how to write code and think about the principle of least surprise: Keep it boring, donβt surprise me
Something to watch or listen
Videos
π₯ Drifting Ruby shared a new episode they published about learning Hotwire: this one they build a Full Calendar for an appointment scheduling program. See it here β Episode 364 - Booking System
π₯ Hanami Mastery shared a new article about using Sidekiq with Hanami: See it here β Integrate Sidekiq with Hanami Applications
π₯ Timnan shared a new tutorial about implementing TimetableJS in Ruby on Rails: See it here β Implementing TimetableJs in Ruby On Rails
π₯ Facundo Espinosa shared an older tutorial done by Mario Visic about building asteroids game with ruby2d: See it here β Building a player select screen - Asteroids Ruby 2D Part 1
π₯ Rubyland shared a collection of RailsConf talks by Shopify engineers. See them here β RailsConf 2022: 10 Shopify Tech Talks You Might Have Missed
π₯ Cj Avilla shared a video released by GoRails about how to deploy to Fly. See it here β How to Deploy Rails to Fly.io
π₯ Drifting Ruby shared the video format of the This week in Rails newsletter: See it here β This Week in Rails Sept 2nd, 2022
π₯ The Rubber Duck Dev Show shared a new episode this time with Drew Bragg. See it here β Episode 57 | Going Off The Rails With Drew Bragg
Audio & Podcasts
π§ Stephan Hagemann shared a great discussion about modularization and internationalization with Irina Nazarova - CEO @evilmartians. Listen to the recording here β Ruby@Scale
π§ Jason Swett shared their latest episode from Code with Jason where he talks with Andrew Atkinson about PostgreSQL. Listen to it here β 160 - PostgreSQL with Andrew Atkinson
π§ JoΓ«l Quenneville shared a new episode of The Bike Shed about submitting talks to conferences, case expressions, and good enough. Listen here β The Bike Shed: 352: Case Expressions
π§ Therubyonrailspodcast shared a new episode where they talk about layoffs. Listen here β Episode 433: The One About Layoffs (Brittany + Brian)
π§ Ruby For All shared a new episode about pairing with Josh Goldberg. Listen here β Pairing with Josh Goldberg
Gems, Libraries, and Updates
π§° Avo shared a new release of their Admin for Rails library. This has a lot of improvements: select all matching records, override destructive actions, automatic required option, and more. Check the changelog here
π§° Aaron Patterson shared a new database adapter for Ruby on Rails called Trilogy:
Compared to the mysql2 gem, Trilogy avoids a dependency on the libmariadb / libmysqlclient library, which can simplify gem installation and eliminate version mismatch issues, and minimizes the number of times data must be copied in memory when building and parsing network packets. It should simplify gem installation and be more efficient under heavy query loads.
Check the gem here, it is compatible with the main branch of rails
π§° Marco Roth shared shared they are working on a new gem providing more power to interact with DOM from Ruby. See the gem here: marcoroth/turbo_power-rails. It adds some very cool actions from DOM actions, Attribute Actions, Event Actions, Storage Actions, Browser Actions, Browser History Actions and more.
Here are just some examples, but there are many more on the Github homepage:
π§° Pascal LalibertΓ© shared shared a bit of work done for creating a charts library for Rails. Check the website here.
π§° Sam Aaron πͺπΊ πΊπ¦ shared a new release of Sonic Pi that supports nudging time forward or back to sync the phase with an external rhythm. Read here more about this release.
π§° Mike Dalessio shared new version of sqlite3 gem. This is v1.5.0.rc2. See the initial release notes of v1.5.0 here
π§° Sam Ruby shared announced a change to flyctl to allow deployment of Rails via fly.rake. See the RFC: have fly launch produce a lib/tasks/fly.rake. Here is what it might look like:
π§° Bozhidar Batsov (Bug) π§π¬πͺπΊπΊπ¦ shared a new release of Rubocop containing small improvements. RuboCop 1.36
π§° Jeremy Evans shared a new release of Sequel 5.6.0. See change log here
π§° Eric Berry π πΊπ¦ shared a gem created by Igor Kasyanchuk about printing debugging information called Wrapped print.
π§° Konnor Rogers shared a gist for having a single file view component. Check it out here
This was a long issue as there was a lot of great content that I discovered in Ruby community. I started to follow what is happening on Reddit communities so I will probably start bringing content from there.
Please consider sharing this on social media or with your colleagues:
Reply