Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
Ruby Together News 

August 2021 Monthly Update

Hello! Welcome to the monthly update. During August, our work was supported by Zendesk, DigitalOcean, Stitch Fix, and many others.

ruby together news

In August, Ruby Together was supported by 38 different companies, including Ruby member Zendesk. 2 companies joined as new members.

On top of those companies, 2 new developers signed up as members, including Jay Ang. In total, we were supported by 108 developer members. Thanks to all of our members for making everything that we do possible. <3

rubygems & bundler news

This month in RubyGems, we released a new version of RubyGems: 3.2.26. This release features experimental support for the RUBYGEMS_GEMDEPS environment variable, which allows…

Awesome Ruby Newsletter 

💎 Issue 278 - The Future Shape of Ruby Objects

Julia Evans 

Debugging by starting a REPL at a breakpoint is fun

Hello! I was talking to a Python programmer friend yesterday about debugging, and I mentioned that I really like debugging using a REPL. He said he’d never tried it and that it sounded fun, so I thought I’d write a quick post about it.

This debugging method doesn’t work in a lot of languages, but it does work in Python and Ruby and kiiiiiind of in C (via gdb).

what’s a REPL?

REPL stands for “read eval print loop”. A REPL is a program that:

  1. reads some input from you like print(f"2 + 2 = {2+2}") (read)
  2. evaluates the input (eval)
  3. print out the result (print)
  4. and then goes back to step 1 (loop)

Here’s an example of me using the IPython REPL to run a print statement. (also it…

Ruby Weekly 

The first alpha of Rails 7.0

#​570 — September 16, 2021

Read on the Web

Ruby Weekly

The Future 'Shape' of Ruby Objects — Chris looks at history to propose a change to MRI around shapes which are a form of polymorphic inline cache used in Self (a shoot-off of Smalltalk) and if you’re still reading then you’ll enjoy this article. At the very least, you’ll learn something about how Ruby internally handles objects, as it’s very well presented.

Chris Seaton

Rails 7.0 Alpha 1 Released — DHH has teased us with looks at what Rails 7 will offer, particularly in regard to its management of JavaScript code, for the past few weeks, but now…

Saeloun Blog 

ECMAScript 2021(ES12) introduces Promise.any() and AggregateError

ECMAScript 2021(ES12) is the latest JavaScript version that introduced multiple new features to the JavaScript language.

In this blog, we will cover Promise.any() method and AggregateError that was a part of ECMAScript 2021 addition.

Promise.any() method accepts a list of Promise objects as an iterable object and, as soon as one of the promises from the list fulfills, it returns a single promise that resolves with the value from that promise.

If no promise in the iterable is fulfilled, then the returned promise is rejected with an AggregateError, which is a new subclass of the Error.

Let’s take an example to understand it better.

const promise1 = fetch("https://jsonplaceholder.typicode…
Riding Rails 

Rails 7.0 Alpha 1: New JavaScript Answers, At-Work Encryption, Query Origin Logging, Zeitwerk Exclusively

Welcome to the first alpha release of Rails 7. It brings some very exciting new answers to how we do JavaScript, an awesome approach to at-work encryption with Active Record, SQL query origin logging, asynchronous query loading, exclusive autoloading through Zeitwerk, and much more.

We usually don’t do alpha releases for Rails, but given the fact that the new front-end approach is such a substantial change, we thought it best to validate that a little further before jumping straight on the beta -> release candidate -> final train.

Please help us test all this new stuff so we can ensure a solid final release of Rails 7 this year!

All New Answers On The Front-End

After almost five years…

The Rails Tech Debt Blog 

Friendlier UUID URLs in Ruby

In this article we will discuss and demonstrate how we can use Ruby to encode UUIDs into URL friendly representations. This article does not assume any previous knowledge about UUIDs. Instead we will first discuss what exactly a UUID is. We look at all the reasons we would prefer using UUIDs over conventional incremental integers.

You can look forward to some binary math and adding a simple but effective encoding algorithm to your tool belt.

BigBinary Blog 

Rails 7 adds ActiveRecord::Relation#structurally_compatible?

ActiveRecord isone of the most powerful features in Rails. With ActiveRecord we can easilyquery and handle database objects without writing any SQL.

By using ActiveRecord Query Interface, we can perform various query operationslike Joins, Group, Find, Order. We can also chain relations withwhere, and, or, not but for and or or the two chaining relationsmust be structurally compatible.

For any two relations to beStructurally Compatiblethey must be scoping the same model, and they must differ only by the whereclause when no group clause has been defined. If a group clause is presentthen the relations must differ by the having clause. Also, Neither relationmay use a limit, offset, or distinct

Previously for and or or query methods, we needed to make…

Hongli Lai 

Ruby gem: distributed locking on Google Cloud

I previously designed a robust distributed locking algorithm based on Google Cloud. Now I'm releasing a Ruby implementation of this algorithm: distributed-lock-google-cloud-storage-ruby.

To use this, add to your Gemfile:

gem 'distributed-lock-google-cloud-storage'

Its typical usage is as follows. Initialize a Lock instance. It must be backed by a Google Cloud Storage bucket and object. Then do your work within a #synchronize block.

Important: If your work is a long-running operation, then also be sure to call #check_health! periodically to check whether the lock is still healthy. This call throws an exception if it's not healthy. Learn more in Long-running operations, lock refreshing…

require '…
All Ruby Podcasts by Devchat.tv 

Building Mobile Apps and Ruby ft. Maxwell Anselm - RUBY 514

Maxwell Anselm discusses the options that he's found to build multi-platform mobile applications. The panel chimes in on different options.

Maxwell also goes into how he uses Ruby in non-Ruby codebases.

Panel

  • Darren Broemmer
  • Dave Kimura
  • John Epperson
  • Luke Stutters

Guest

  • Maxwell Anselm

Sponsors

Links

Picks

Greater Than Code 

250: Employee Resource Groups with Adrian Gillem

01:19 - Adrian’s Superpower: Humor

  • Making People Feel Comfortable Through Humor
  • Self-Deprecating Humor & Authenticity

04:57 - Employee Resource Groups (ERGs): What are they?

  • Employees Share Effective, Measurable, Impactful Insights
  • Connecting New Hires with People Who Look Like Them
  • Making Employee Experiences Better

09:20 - How ERGs Operate

  • “Build with not for”
  • Making Fellow Colleagues Heard

18:03 - Successfully Policy Implementations: Examples

  • Transgender Healthcare

23:18 - ERGs and Management / Executive Sponsor Partnerships

30:41 - ERGs vs Unions

  • Equity

34:19 - Inclusivity Training

Reflections:

Casey: “ERGs are only as strong as the management…

Saeloun Blog 

Rails 7 adds Marginalia to Query Logs

Rails provides great Query Logs detailing exact database queries made. It looks something like this,

User Load (0.3ms)  SELECT `users`.* FROM `users`
WHERE `users`.`id` = 1234567890
LIMIT 1

However, when debugging for slow or troublesome queries, we might need extra information. Instead of polluting the codebase with multiple print statements, it’s a great idea to add the Marginalia gem by Basecamp. Now, this is how the query logs would look,

User Load (0.3ms)  SELECT `users`.* FROM `users`
WHERE `users`.`id` = 1234567890
LIMIT 1

/*application:saeloun,controller:users,action:show*/

In Rails 7

A recent PR to Rails brings Marginalia SQL comments to Rails as a native feature! It’s a much…

Island94.org 

Home buyer letter

Having now successfully purchased a home in San Francisco, I have had friends asked me for resources. This was the letter we sent to the seller, which is very SF, but also the energy to bring. I also learned that these letters are waning because they are biased af.

Dear [seller],

Your home at [street address] is the right fit for us, our two cats, and (hopefully) our future family. We love the long layout, high ceilings (we’re both tall) and sunny patio, and look forward to hosting friends for Sunday brunch someday.

We’re rooted in the city through the South End Rowing Club, St. Francis Lutheran Church, supporting the YMCA, kickstarting local businesses like Andytown coffee, and…

Jekyll • Simple, blog-aware, static sites 

Goodbye, Dear Frank.

Over the weekend, the Jekyll core team learned of the passing of one of our own: Frank Taillandier, popularly known by his GitHub username @DirtyF.

Ruby not being his forte, he chose to avoid code-level changes and instead focus on what he did best — engage with the community.

He helped resolve complaints reported on the GitHub issue tracker, ensured that Jekyll documentation remained simple for novice users yet detailed enough for advanced users seeking additional information.

He also served as the administrator for Jekyll’s public discourse forum where he not only addressed queries from users and provided tips to improve Jekyll workflow, he also shared feedback on Jekyll sites created…

OmbuLabs Blog 

How to pick an open source project to contribute to

Open source powers many of the tools that we rely on daily for our work. As developers, we have the privilege of being able to read, learn, and build from thousands of codebases at our fingertips. What better way to give back to the community that creates the software that powers our world than to contribute to those very same tools?

Contributing to the open source community can be daunting for a seasoned developer, let alone a novice. One problem I’ve had as an early-career developer has been figuring out how to find a project that aligns with my interests as well as the skills that I want to practice. One great resource I've found very helpful with finding answers to my questions is the…

BigBinary Blog 

Playing videos in React Native

These days a large number of mobile apps allow users to upload videos and playthose videos efficiently. While building these features in a React Native app weran into some challenges. In this blog we will discuss those challenges and thesolutions.

Where to host the videos

Since we are dealing with videos we need a service that will store, host, encodeand be a CDN. After looking at various service providers we decided to go withCloudinary. Cloudinary is a service provider with anend-to-end image/video-management solution for web and mobile applications,covering everything from uploads, storage, manipulations, optimizations todelivery with a fast content delivery network (CDN).

Setting up…

Martian Chronicles, Evil Martians’ team blog 

The tale of Sprockets and Webpacker duality

Authors: Vladimir Dementyev, Principal Backend Engineer at Evil Martians and Artem Shibakov, ex-Frontend Engineer at Evil Martians

I push my fingers onto my… keyboard; it’s the only… way to run rails assets:precompile and get two independent bundles: one generated with Sprockets and the other using Webpacker! There’s nothing unusual about this idea so far. Well, except that both bundles are compiled from the same source files and provide equal functionality. “What the heck are you doing?” I’m migrating a large Rails application from Sprockets to Webpacker using a dual build strategy. Does this all sound new to you? Then keep reading!

One requirement for keeping an application in a…

Sandip Mane 

OpenSSL connection error with Redis6 on heroku

OpenSSL::SSL::SSLError (SSL_connect returned=1 errno=0 state=error: certificate verify failed (self signed certificate in certificate chain))

This error is occurring because Redis6 requires SSL to connect while Heroku does not use SSL, instead, they use HTTP routing.

This error will not occur for the hobby-dev verion of the Redis6 on Heroku as it supports both HTTP and HTTPS connections.

Fix

The fix suggested by Heroku involves changing the verification mode.

$redis = Redis.new(url: ENV["REDIS_URL"], ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE })

Fixes for Rails

1. If you are using Sidekiq

Sidekiq.configure_server do |config|
  config.redis = {
    url: ENV["REDIS_URL"
Saeloun Blog 

Rails 7 adds support for ActiveStorage expiring URLs

The introduction of ActiveStorage in Rails 5.2 changed the way we upload or serve the attachments in a Rails application.

ActiveStorage has made it easier to integrate and use various cloud storage services.

While working with attachments, we often come across situations where we need to expire the URLs after a specific amount of time.

Before, this specific change, we had to use the service url (referred as service_url before) to set the expiration time.

But, with the introduction of this change in ActiveStorage, it can be set with the redirection URL itself without using or exposing the actual service URL.

Before

Let’s say, we have a User model which has one registration attached to…

class User <
The Bike Shed 

308: That’s Picante

You know what really grinds Chris' gears? (Spoiler Alert: It's Single-Page Applications.)

Steph needs some consulting help. So much to do, so little time.

Transcript:

CHRIS: I have restarted my recording, and we are now recording. And we are off on the golden roads. Isn't software fun?

STEPH: Podcast battle. Here we go!

Hello and welcome to another episode of The Bike Shed, a weekly podcast from your friends at thoughtbot about developing great software. I'm Steph Viccari.

CHRIS: And…

Test Double Blog 

Double Agent Profile: Daniel Flynn

Name: Daniel Flynn Designation: Agent 0056 Double Agent Role: Senior Software Consultant Special Skills: Quantity and quality distributed across a bell curve derived by the amount of coffee consumed. Aliases: Github
Benito Serna 

Preload object on the guide for preloading associations

I want to tell you that I have added a new section to the guide for preloading associations in rails, to introduce you to something I call “Preload objects” that will help you build complex preloads for those cases when you can’t find a way to do what you need to do, with the standard rails mechanisms.

Visit the new section

You can visit the new section on Guide for preloading associations in rails - Preload Object. And a standalone article about it on Preload objects.

If you don’t know what this guide is about…

Is a guide I wrote to try to help you get better on this specific skill of preloading associations, for when you need a more than just a preload(:comments).

To help you…

RubySec 

CVE-2021-39197 (better_errors): Older releases of better_errors open to Cross-Site Request Forgery attack

### Impact better_errors prior to 2.8.0 did not implement CSRF protection for its internal requests. It also did not enforce the correct "Content-Type" header for these requests, which allowed a cross-origin "simple request" to be made without CORS protection. These together left an application with better_errors enabled open to cross-origin attacks. _As a developer tool, better_errors documentation strongly recommends addition only to the `development` bundle group, so this vulnerability should only affect development environments. Please ensure that your project limits better_errors to the `development` group (or the non-Rails equivalent)._ ### Patches Starting with release 2.8.x, CSRF…
RubySec 

CVE-2021-23435 (clearance): Open Redirect in clearance

This affects the package clearance before 2.5.0. The vulnerability can be possible when users are able to set the value of session[:return_to]. If the value used for return_to contains multiple leading slashes (/////example.com) the user ends up being redirected to the external domain that comes after the slashes (http://example.com).
Rebased Blog 

Rebased 💚 Shopify

We’re excited to announce that the Rebased team has joined Shopify! We founded Rebased to bring our Ruby and JavaScript programming experience to support companies all over the world. And, today, we are proud to be able to bring our expertise to one of the leading technology companies in the...
Engine Yard Blog 

Tutorial on how to use Active Storage on Rails 6.2

Understanding Active Storage in Rails 6.2

Honeybadger Developer Blog 

Currency Calculations in JavaScript

One of the most curious things about modern programming languages is that when someone decides to create a new one, lots of thinking about the accepted data types and internal auxiliary libraries takes place.

Think about all the programming languages you've worked with before. How many ways to deal with dates and times do they have? Most of them will probably release at least one way to deal with such data types because it is a very present type in a developer's programming life.

What happened to the money, then? Banks, brokers, online shopping, etc. need to handle money programmatically. And it's been like that for a long time.

Because of the lack of representativity, money types are…

Brandon Weaver 

Ruby 3.1 – Shorthand Hash Syntax – First Impressions

It's the time of year again, and with it comes a bundle of new Ruby 3.1 features getting approved and merged ahead of the December release.

This series will be covering a few of the interesting ones I see going across the bug tracker. Have one you think is interesting? Send it my way on Twitter @keystonelemur or comment here.

Shorthand Hash Syntax - First Impressions

Now this, this is something I've wanted for a very long time. Shorthand Hash Syntax, also known as Punning in Javascript, is an incredibly useful feature that allows you to omit values where the variable name is the same as the key:

a = 1
b = 2

{ a:, b: }
# => { a: 1, b: 2 }

In Javascript this would like…

Riding Rails 

Bye-bye Byebug, Hello jsbundling and cssbundling!

Hi! zzak here! We’re back after a 2 week break with some of the latest changes that will land in Rails 7.

DHH previews JavaScript options in Rails 7 [YouTube]

If you haven’t been following along, Rails 7 will get a major facelift on the front-end. We recommend reading this blog post to learn more.

Replace Byebug with ruby/debug

Ruby 3.1 will launch with a new first-class debugger that works great with Rails.

Let’s all appreciate the many years Byebug has helped us ship software.

Add SSL support for postgresql in “bin/rails dbconsole”

This PR fixes the dbconsole command when used with PostgreSQL to support encrypted connections.

Instrument ActiveStorage analyzers

Help identify…

Josh Software 

PERFORMANCE OPTIMIZATIONS IN NODEJS💁

Ok so let’s start with introducing Node.js. Node.js enables us to run javascript outside the browser. It is based on the chrome V8 engine and under the hood it uses JS, C++ and C. Oh God! Are you guys still using C? 🙈 and although you may have heard that Node.js is single threaded and … Continue reading PERFORMANCE OPTIMIZATIONS IN NODEJS💁
Peter Zhu 

To Free or Not to Free: A Story About a Memory Leak in Strings

Finding and fixing a memory leak in Ruby strings.
Julia Evans 

Quadratic algorithms are slow (and hashmaps are fast)

Hello! I was talking to a friend yesterday who was studying for a programming interview and trying to learn some algorithms basics.

The topic of quadratic-time vs linear-time algorithms came up, I thought this would be fun to write about here because avoiding quadratic-time algorithms isn’t just important in interviews – it’s sometimes good to know about in real life too! I’ll explain what a “quadratic-time algorithm is” in a minute :)

here are the 3 things we’ll talk about:

  1. quadratic time functions are WAY WAY WAY slower than linear time functions
  2. sometimes you can make a quadratic algorithm into a linear algorithm by using a hashmap
  3. this is because hashmaps lookups are very fast…

I’m going to try to keep the math jargon to a minimum and focus on real code examples and how fast/slow they are.

our problem: intersect two lists

Le…

Code with Jason 

What to do about bloated Rails Active Record models

Overview

It’s a common problem in Rails apps for Active Record models to get bloated as an application grows. This was a problem that I personally struggled with for a number of years. As I’ve gained experience, I’ve figured out a couple tactics for addressing this problem, tactics that I feel have worked well. I’ll share my these in this post.

First let’s talk about how and why this problem arises.

How bloated Active Record models arise

Some background on the Active Record pattern

Many Rails developers might not know that the Active Record pattern existed before Rails. The pattern was named by Martin Fowler in Patterns of Enterprise Application Architecture. The idea behind Active Record…

RubyGems Blog 

August 2021 RubyGems Updates

Welcome to the RubyGems monthly update! As part of our efforts at Ruby Together, we publish a recap of the work that we’ve done the previous month. Read on to find out what updates were made to RubyGems and RubyGems.org in August.

RubyGems News

This month in RubyGems, We released a new version of RubyGems - 3.2.36. This release features experimental support for the RUBYGEMS_GEMDEPS environment variable, which allows using locked versions of executables without the need of prepending bundle exec to them. It also fixes an issue with the loading of RubyGems plugin and improves reporting of errors inside operating system customizations of RubyGems.

On Bundler, we released Bundler 2.2.26,…

Remote Ruby 

Moving From Consulting To Products With Andrew Sabetta

[00:03:15] Andrew introduces himself, what he does, and more about the businesses that he started.


[00:09:48] Chris asks Andrew what took him from PHP to Ruby.


[00:12:22] Find out about the project Andrew did with Rails.


[00:14:28] The conversation turns to talking about going from consulting, into wanting to build a product, and the transition being a hard decision.  


[00:16:48] Jason tells us about his issue with being idea driven. He’s excited about building, the marketing stuff he’s not good at, and he’s okay with talking to people but he doesn’t want to. He also mentions a great book to read called, The Mom Test. 


[00:20:48] Andrew tells us his first experience of chasing an idea…

Hanami Mastery newest episodes! 

#8 Learn new things easily - mapping Rails to Hanami

When I've started with learning Hanami, I've struggled a lot because of the different concepts Hanami has over Rails. In this episode of Hanami Mastery I'm mapping Rails to Hanami for easier learning.
Awesome Ruby Newsletter 

💎 Issue 277 - How I keep my Rails controllers organized

Test Double Blog 

How to build a search engine with Ruby on Rails

You don’t hear this one every day: I just made a critical database query 10x faster by moving the bulk of the complexity out of SQL and back into Ruby. This post will explain how I did it, plus how you can apply a similar approach to rethinking search in your own application.
Ruby Weekly 

More on JavaScript and autoloading in Rails 7

#​569 — September 9, 2021

Read on the Web

✍️ I know not all readers are into Rails, but when a glut of interesting Rails news comes along, we've got to cover it :-) Scroll down a bit for the normal Ruby goodness if this is you, especially as Jemma is back with a new Tip of the Week
__
Peter Cooper, your editor

Ruby Weekly

▶  DHH's Rails 7 Alpha Preview with esbuild and Tailwind CSS — If you’re a fan of David Heinemeier Hansson’s (DHH) screencasts, here’s his latest where he shows off more of what’s coming in Rails 7 with regards to JavaScript integration. It’s too early to call how this will pan out, but everyone…

DHH on…

Saeloun Blog 

Keep the React app responsive even during large screen updates with startTransition API introduced in React 18

The most significant update of React 18 comes with concurrent rendering. Concurrency is the ability to execute multiple tasks simultaneously by prioritizing the tasks. This concept is explained nicely by Dan Abramov with a simple analogy of phone calls.

React 18 exposed a few APIs to allow users to have some control over concurrency. One of them is the startTransition API, which indicates that the actions wrapped in startTransition may take time.

Let’s explore in detail the startTransition API.

Sometimes we come across applications that become unresponsive due to heavy or complex operations.

Consider an example of searching a photo from a large list. When we type the photo name in the…

The Ruby on Rails Podcast 

Episode 383: Aim for Good (GoodJob) with Ben Sheldon

Ben Sheldon is the Director of Engineering Operations at Code for America and the author of the GoodJob gem. He fields all of Brittany's questions about why GoodJob was created, how it leverages Active Job, why a dev team would select it and what the life of an open source maintainer currently looks like.

Show Notes & Links:

Sponsored By:

Honeybadger

Honeybadger makes you a DevOps hero by combining error monitoring, uptime monitoring and check-in monitoring into a single, easy to use platform.…

Greater Than Code 

249: #TechIsHiring + eSports and Software Engineering with Chad Stewart

01:19 - Chad’s Superpower: Making People Laugh

  • Using Comedy to Deal with Problems

03:46 - #TechIsHiring

31:03 - eSports and Software Engineering

Reflections:

John: The simple act of connecting others with a hashtag.

Mandy: Follow

The RubyMine Blog : The Ruby on Rails IDE | JetBrains Blog 

Working With RBS in RubyMine

Starting with v2021.2, RubyMine provides code assistance for working with RBS files, along with all of the essential features that make RBS code easier to read. Here’s a brief overview.

Creating RBS code

  • Generate RBS type signatures using the Generate Code popup (⌘N or Alt+Insert).
    Generate type signatures
  • Run RBS commands with Run Anything (double ^ or double Ctrl).
    Run RBS commands with Run Anything
  • Use file templates to create new RBS files, classes, modules, or interfaces.
    RBS file templates
  • Create your own RBS live templates to insert frequently-used constructions into your code.

Code completion

  • Code completion now works for RBS code and includes suggestions…
Giant Robots Smashing Into Other Giant Robots 

Testing Your Edge Cases

We have just added some new permissions logic to a project.

def can_read?
  article.access_policy&.public? || user.admin?
end

We might include some tests that read like:

describe "#can_read?" do
  it "allows admin to access public article"
  it "allows admin to access private article"
  it "allows non-admin to access public article"
  it "disallows non-admin from accessing private article"
end

During code review, one of our colleagues asks

Do we have any tests that cover the nil case?

Hmmm, it looks like we forgot! How can we do a better job of making sure we cover all our edge cases?

Using math

We can use math to calculate how many combinations of inputs we have. In…

Ruby Together News 

Ruby In Google Summer of Code 2021

Ruby in Google Summer of Code 2021

We were delighted to act as fiscal sponsor for the Ruby organization as part of Google’s Summer of Code (GSOC) program. This year, the org was administrated by Ruby core team member Koichi Sasada. Read on to hear from two students who participated in this year.

王新宇 Wang Xinyu, a third year university student in software engineering at Tongji University, Shanghai, contributed to an event-based profiling tool inspired by Google Chromium. The profiler is designed to help analyze Ruby’s boot process and locate the bottleneck. The aim is to deliver faster gem loading for Ruby users, and provide a way to analyze Ruby VM performance intuitively for MRI…

Code with Jason 

111 - Dockerizing Development and Production with Nick Janetakis

In this episode, Nick Janetakis and I discuss freelancing, Dockerizing for development versus Dockerizing for production, and Kubernetes.

Martian Chronicles, Evil Martians’ team blog 

Real-time stress: AnyCable, k6, WebSockets, and Yabeda

Authors: Vladimir Dementyev, Principal Backend Engineer at Evil Martians, Svyatoslav Kryukov, Backend Engineer at Evil Martians, and Andrey Novikov, Backend Developer at Evil Martians

So everything is set. Our new and shiny chat feature is up and running. There are unit and integration tests, maybe even 100% coverage. Everything seems working fine. At least for now. On this machine. Under these very stars. But what if one day you hit the orange website and suddenly find yourself handling 10-100x more users? Read on to learn how to reliably test real-time web scenarios with modern tools and minimum effort.

Performance testing is crucial for the healthy uptime. By simulating an increased…

Saeloun Blog 

Rails 7 adds ActiveRecord::Relation#structurally_compatible?

One of the best things about Rails is the ease of handling database objects and queries without writing any SQL code. It is possible because of ActiveRecord library that is arguably one of the best core libraries of Rails.

With the use of ActiveRecord Query Interface, we can perform various query operations such as Find, Group, Joins, and various other operations.

We could also chain relations with the help of where, not, or operations. But for or and and operations, we need to ensure that the two chaining relations are structurally compatible.

For two relations to be structurally compatible, they must be scoping the same model, and they must differ only by #where (if no #group has been…

Brandon Weaver 

Let's Read – Eloquent Ruby – Ch 3

Perhaps my personal favorite recommendation for learning to program Ruby like a Rubyist, Eloquent Ruby is a book I recommend frequently to this day. That said, it was released in 2011 and things have changed a bit since then.

This series will focus on reading over Eloquent Ruby, noting things that may have changed or been updated since 2011 (around Ruby 1.9.2) to today (2021 — Ruby 3.0.x).

Note: This is an updated version of a previous unfinished Medium series of mine you can find here.

Chapter 3. Take Advantage of Ruby's Smart Collections

This chapter covers some of Ruby's collection classes and how to work with them. In Ruby this is probably going to be one of your most…

The Bike Shed 

307: Walking Contradictions

On this episode, Chris talks about testing external services and dissects a tweet on refinements for Result. Steph talks about thoughbot's recent improvement to their feature flag system.

Links:

Transcript:

CHRIS: Hello and welcome to another episode of The Bike Shed, a weekly podcast from your friends at thoughtbot about developing great software. I'm Chris Toomey.

STEPH: And I'm Steph Viccari.

CHRIS: And together, we're here to share a bit of what we've learned along the way. So, Steph, what's new with you?

STEPH: Hey, Chris. Well, today is…

Test Double Blog 

Blank Mac Syndrome

New Mac, Who Dis? As someone who loves to write, both personally and as a programmer, there’s one thing I dread more than anything else: an empty screen. Nothing is more intimidating than a fresh page with a blinking cursor.
Drifting Ruby Screencasts 

esbuild for Rails

Use esbuild to bundle your JavaScript, then deliver it via the asset pipeline in Rails. This gem provides an installer to get you going with esbuild in a new Rails application.
Honeybadger Developer Blog 

Build an Uptime Monitoring System in Ruby with GCE, Cloud Storage, and PubSub

Uptime monitoring involves checking the availability of websites, APIs, and servers. The monitor probes a given endpoint within a specified interval to determine whether it is available. The goal is to achieve the contracted level of availability, as specified in the system's SLA, and determine the difference when the contract isn't met.

In this article, we'll build an uptime monitoring system based on Prometheus blackbox_exporter. While it might be trivial to build a custom HTTP monitoring system, building a wrapper around the exporter enables us to access many other probe techniques and quickly monitor other elements of our system.

This article covers the use of several technologies,…

Drifting Ruby Screencasts 

Importmaps in Rails 7

Import maps let you import JavaScript modules using logical names that map to versioned/digested files – directly from the browser. This will be a default in the upcoming Rails 7.
All Ruby Podcasts by Devchat.tv 

Going from Development to Production - RUBY 513

Dave Kimura, John Epperson, Luke Stutters, Darren Broemmer, and Valentino Stoll talk about their experiences in setting up a maintainable development environment and discuss considerations when deploying to production.

Panel

  • Darren Broemmer
  • Dave Kimura
  • John Epperson
  • Luke Stutters
  • Valentino Stoll

Sponsors

Links

Picks

All Ruby Podcasts by Devchat.tv 

How to Launch the Next Stage of Your Career - BONUS

Charles Max Wood explains how podcasting has repeatedly opened up opportunities for him to move his career forward. He dives into how it helped early in his career, how he was able to use it as a tool to find freelance clients, and how it can take you beyond a full time senior developer job into coaching or courses.

If you'd like to learn how to start your own podcast, go to podcastbootcamp.io

Panel

  • Charles Max Wood

code.dblock.org | tech blog 

How I Learned Rust by Accident

I had to quickly ramp up my Python over the past few weeks. Mind, because Ruby is obviously better, I’ve never really written any Python in 20 years of programming. At least not production-grade Python with unit tests. Working on a real active codebase was the easiest and fastest way for me to learn, but I’m not telling you anything you didn’t already know.

Then yesterday, I accidentally “learned” Rust. I’m, obviously, still a total Rust noob, but at least now I know what Cargo and TOML are, and I think I’m getting just sufficiently dangerous with it. Here’s the full story.

The OpenSearch project uses a link checker called lychee to ensure that links in the OpenSearch markdown docs work.…

code.dblock.org | tech blog 

Generating a Task Matrix by Looping over Repo Files with GitHub Actions

I’ve been having more fun with GitHub actions after Automating Code Changes via GitHub Actions Making Pull Requests. Let’s generate a job matrix from a list of files.

Why would I need that? In opensearch-project/opensearch-build we create manifest files that are used to produce an OpenSearch distribution. These files are created manually, one for every version. Each needs to be sanity-checked when created or changed.

These checks can be executed in parallel, so we can create a GitHub Actions matrix like so.

name: manifests
on: [push, pull_request]
jobs:
  check:
    runs-on: ubuntu-latest
    strategy:
        matrix:
            manifest:
                - manifests/opensearch-1.1.0.yml
Remote Ruby 

Kasper Timm Hansen from the Rails Core Team

[00:00:43] Jason and Chris chat about stripe-ruby-mock and Paddle. 


[00:03:23] Kasper tells about himself, what he’s doing now, and how he got into the Rails and Ruby stuff. 


[00:13:51] Chris asks Kasper if he has any thoughts on the depth that he has to put into thinking about every one of the PR’s which has to be quite a lot.


[00:15:06] Chris brings up Active Storage as an interesting example that was a basecamp use case that was extracted, and Kasper shares some thoughts on this too. 


[00:17:12] Something Chris brings up is Kasper’s been doing some pull request reviews and stuff publicly on Twitter, and he brings up a thread he noticed there is very close attention to detail in…

Riding Rails 

Autoloading in Rails 7, get ready!

The forthcoming Rails 7 represents a milestone for autoloading.

There are two important changes coming:

  1. Zeitwerk has been the default autoloader for more than two years. Rails 6.0 and Rails 6.1 supported both zeitwerk and classic modes to help projects transition. This period ends with Rails 7: classic mode won’t be available anymore.

  2. Initializers can autoload reloadable constants if wrapped in to_prepare blocks, but they no longer can otherwise.

Maybe your 6.x application is already ready for these changes. Otherwise, you can prepare in advance to ease the upgrade. Let’s briefly explore their implications.

Applications need to run in zeitwerk mode

Applications…

RubyGems Blog 

3.2.27 Released

RubyGems 3.2.27 includes enhancements.

To update to the latest RubyGems you can run:

gem update --system

To install RubyGems by hand see the Download RubyGems page.

## Enhancements:

  • Redact credentails when printing URI. Pull request #4868 by intuxicated
  • Prefer require_relative to require for internal requires. Pull request #4858 by deivid-rodriguez
  • Prioritise gems with higher version for fetching metadata, and stop fetching once we find a valid candidate. Pull request #4843 by intuxicated

SHA256 Checksums:

  • rubygems-3.2.27.tgz
    5bbc6ee95d570dadbf7972cb6dbe1dd612cfa57ec8ecab77055e5dcf27296f39
  • rubygems-3.2.27.zip
    b03641d930e76828b11339c8521ef073d3041e284399569d008bf16fdcba3…
Awesome Ruby Newsletter 

💎 Issue 276 - Ruby is Still a Diamond - in-house retrospective on Ruby 3.0

Noteflakes 

How I Write Code: Pen & Paper

I am a self taught programmer. I first started programming as a kid, and have never bothered to formally study this discipline. To me, programming is first of all a pleasant creative pursuit. It’s a bit like putting together and taking apart all kinds of machines, except these machines happen to be virtual constructions, and you get to keep your hands clean (well, mostly…) Incidentally, this pleasant activity is also how I support my family.

But even though I love programming, I try not to sit in front of a computer screen too much. I do not find staring at a screen all day beneficial, not for my physical health, nor for my mental health. In the last few years, I’ve started a habit of…

Ruby Weekly 

Ruby is still a diamond

#​568 — September 2, 2021

Read on the Web

Ruby Weekly

Ruby is Still a Diamond: Some Reflections“So let’s talk contemporary Ruby”. The author focuses on the ongoing development of Ruby, particularly in terms of concurrency and performance, and why Ruby still matters despite never being ‘the fastest language.’

Emma Hyde

OpenSourceRails: A Curated List of Open-Source Rails Apps — The reinvention of a former project of the same name (but on .com, vs .org) where you can check out some projects built in Rails and, most importantly, quickly see what gems and tools they use in their stacks. Check the most…

Code with Jason 

How I keep my Rails controllers organized

The problem to be solved

As a Rails application grows, its controllers tend to accumulate actions beyond the seven RESTful actions (index, show, new, edit, create, update and destroy). The more “custom” actions there are, the harder it can be to understand and work with the controller.

Here are three tactics I use to keep my Rails controllers organized.

First, a note about “skinny controllers, fat models”

The concept of “skinny controllers, fat models” is well-known in the Rails community at this point. For the sake of people who are new to Rails, I want to mention that one good way to keep controllers small is to put complex business logic in models rather than controllers. For more on…

All Ruby Podcasts by Devchat.tv 

Going from Development to Production - RUBY 513

Dave Kimura, John Epperson, Luke Stutters, Darren Broemmer, and Valentino Stoll talk about their experiences in setting up a maintainable development environment and discuss considerations when deploying to production.

Panel

  • Darren Broemmer
  • Dave Kimura
  • John Epperson
  • Luke Stutters
  • Valentino Stoll

Sponsors

Links

Picks

All Ruby Podcasts by Devchat.tv 

Going from Development to Production - RUBY 513

Dave Kimura, John Epperson, Luke Stutters, Darren Broemmer, and Valentino Stoll talk about their experiences in setting up a maintainable development environment and discuss considerations when deploying to production.

Panel

  • Darren Broemmer
  • Dave Kimura
  • John Epperson
  • Luke Stutters
  • Valentino Stoll

Sponsors

Links

Picks

Notes to self 

Deployment from Scratch, 1st edition is released!

Today, I am releasing Deployment from Scratch, 1st edition. It was a long journey of more than three years, and it’s time to make it a reality. Of course, I could always do a one more read and rewrite a paragraph or two, but it’s just as important to stop at some point and let the world benefit from all that work.

cover

It all started as a small resource of deploying a Rails application on a virtual server, but it outgrew itself by a large margin. Python, containers, NFS, or emails were included, among other things. It’s the single resource you need to get started with deployment. Although from scratch, it goes wide and deep.

It covers a lot:

  • networking and typical system administration
The Rails Tech Debt Blog 

Introducing Dotenv Validator: A Lean Library to Validate your Environment Variables

We are excited to share a new gem for the Ruby community: dotenv_validator! A library that will help you validate that the values in your environment are valid according to the comments in your .env.sample file.

  1. Problem
  2. Solution
  3. Caveats
  4. Final Thoughts (TL;DR)

1. Problem

At OmbuLabs (the company behind FastRuby.io) we embrace the Twelve-Factor Methodology for all of our internal, open source, and client applications. One of the principles of this methodology is to store configuration in the environment.

The twelve-factor app stores config in environment variables (often shortened to env vars or env). Env vars are easy to change between deploys without changing any code;…

The RubyMine Blog : The Ruby on Rails IDE | JetBrains Blog 

RBS: How to Get the Most Out of RubyMine’s Code Assistance

The following article shows the benefits of investing some of your time into adding RBS declarations to your project.

Catch type errors

RubyMine performs real-time type checking based on the information stored in .rbs files. It will show a type error if there’s a mismatch between the RBS and Ruby code, like in method parameters or return values.

Inspection: type mismatch between Ruby and RBS

There’s also a new inspection for optional types specified in RBS. In such cases, RubyMine will show an error if you try to invoke a method without first checking for nil:

Nil dereference error

Navigate large code bases

Go to declaration and Find usages can help a lot with navigating large code bases, especially those that are new to you.

RubyMine can find potential…

The Ruby on Rails Podcast 

Episode 382: Code::Anth with Gui Heurich

After participating in his study, Brittany interviewed Gui Heurich. Gui is a Brazilian anthropologist and programmer, currently researching the Ruby language and its community in an ambitious projected named Code::Anth. He lives in England, where he works as a Ruby backend developer at Farmdrop and also as an Associate Researcher at University College London.

Show Notes & Links:

Sponsored By:

Honeybadger

Honeybadger makes you a DevOps hero by combining error monitoring, uptime monitoring and check-in monitoring into a single, easy to use platform. Go to Honeybadger.io and discover how…

Saeloun Blog 

Rails 7 adds attributes_for_database to return attributes as they would be in the database

Rails provides various methods to store objects in a standardized way. One popular method is to use marshal – the marshaling library converts collections of Ruby objects into a byte stream, allowing them to be stored outside the currently active script. This is the general accepted method in the Ruby world.

However it is far less than efficient when storing ActiveRecord objects. It is unable to properly store binary attributes and is sometimes incompatible across Rails versions.

Before

Prior to this update, Rails developers had to use a hacked up solution to accurately serialize ActiveRecord objects. Let’s compare two popular methods used to do this.

First, let’s look at #attributes,

Greater Than Code 

248: Developing Team Culture with Andrew Dunkman

01:27 - Andrew’s Superpower: Stern Empathy

03:30 - Setting Work Boundaries

18:54 - Providing Support During a Pandemic

  • Stretching/Growth Work
  • Comfortable/Safety Work
  • Social Connection

23:37 - Keeping People Happy / Avoiding Team Burnout

36:26 - Developing Team Culture

  • “Gravity People”
  • Honing Communication…
Code with Jason 

110 - Code Organization, Project Management, and Freelancing with Riaz Virani

Riaz Virani joins me for a discussion that covers strategies for project management, the realities of freelancing, declarative versus imperative programming, and productive disagreements.

Rails Performance Audit and Tuning Consultant for Hire 

My Recipe for Optimizing Performance of Rails Applications

Rails performance audits have been my main occupation and source of income for over a year now. In this blog post, I’ll share a few secrets of my trade. Read on if you want to learn how I approach optimizing an unknown codebase, what tools I use, and which fixes are usually most impactful. You can treat this post as a generalized roadmap for your DIY performance audit with multiple links to more in-depth resources.

Layers of performance optimization

My audits usually span a few weeks. That’s not a lot of time time to get familiar with an unknown and often legacy codebase. I’ve established a framework for analyzing different layers of a Rails application. It allows me to propose and…

Saeloun Blog 

Rails 7 allows anything that responds to `#to_str` into redirect_to

Rails 7 adds support for passing all string-like arguments (that respond_to? #to_str) to redirect_to.

Any class that defines #to_str like the Addressable::URI class can now be passed to redirect_to.

We can also write a custom class that defines #to_str as shown below.

Example

  class GoogleSearcher
    attr_reader :query

    def initialize(query)
      @query = query
    end

    def to_str
      "https://www.google.com/search?q=#{query}"
    end
  end

Before

  def saeloun_home
    redirect_to "https://saeloun.com"
  end
  #=> No error, will work properly and redirect us to https://saeloun.com

  def google_home
    redirect_to Addressable::URI.parse("https://google.com")
  end
  #=>…

In the above example, the google_home action will raise a NoMethodError as r…

The Bike Shed 

306: If You Want To Go Far, Go Together

In this episode, Steph and Chris talk about things they've changed their minds about over the course of their careers as software developers. Steph talks about as it turns out, arm chair rests are good, feature flags and comments are also good, she's changed her mind about how teams structure the work that each person is doing at once, and believes strongly in representation in the field.

Chris is not a fan up upgrading his operating system and when he first started out, he gravitated towards learning dynamic languages, and since then, much prefers functional languages, static typing or more broadly, static analysis. He also no longer believes in the 10x engineer, and also very…

Riding Rails 

Remove default reliance on Sass and more!

Hi, this is Greg, bringing you the latest changes in Rails.

Remove default reliance on Sass and CSS generators

Due to Saas has chosen to focus exclusively on dart-saas, Rails is decreasing its reliance on it. Besides that, this PR also removes the per model css file generation.

Avoid use of exceptions to detect invalid floats

This PR Improves the performance of ActiveSupport::NumberHelper and ActionView::Helpers::NumberHelper formatters by avoiding the use of exceptions as flow control.

Make preload_link_tag work with images

Prior to this change, preload_link_tag with an image would generate a tag without an as attribute. If the as attribute doesn’t get set, browsers tend to ignore…

Brandon Weaver 

Let's Read – Polished Ruby Programming – Ch 3.1 – Local Variables

Polished Ruby Programming is a recent release by Jeremy Evans, a well known Rubyist working on the Ruby core team, Roda, Sequel, and several other projects. Knowing Jeremy and his experience this was an instant buy for me, and I look forward to what we learn in this book.

You can find the book here:

https://www.packtpub.com/product/polished-ruby-programming/9781801072724

This review, like other "Let's Read" series in the past, will go through each of the chapters individually and will add commentary, additional notes, and general thoughts on the content. Do remember books are limited in how much information they can cram on a page, and they can't cover everything.

With that said let's…

Josh Software 

Recoil — is this the new ‘Redux’ for React?

Recoil is a new state management library for React that lets you manage global/sharable state in a Reactish way. What’s great is that Recoil is being developed by the Facebook team. In this blog we’ll take a look at the useRecoilState hook and how they have made it is so ‘React’-ish? Let’s take a very simple … Continue reading Recoil — is this the new ‘Redux’ for React?
Honeybadger Developer Blog 

Using Hotwire with Rails

If you are looking for a way to speed up page changes and form submissions and divide complex pages into components without writing any JavaScript code, this post will help you take Rails to the next level with Hotwire. This article will teach you how to use a tool for server-side rendering.

What is Hotwire?

Hotwire provides a way to build modern web applications without writing JavaScript by sending HTML instead of JSON over the wire, which makes pages load faster. It maintains rendering on the server-side and allows for a simpler and more productive development experience, as Rails has always incorporated into its technologies, without sacrificing the speed or responsiveness associated…

Test Double Blog 

First days, first client as a software consultant

Nerves I would not call myself a professional consultant. Certainly, prior to working at Test Double, I did very little “consulting” and much more “building” and “owning” product decisions.
Andy Croll 

Compress Your HTML Responses

There are multiple aspects to the performance of typical Rails applications: database queries, view render time, fragment caching, and more. There are also considerations for the front-end: image compression, Javascript, and CSS size.

We often use CDNs, compression, and minification for the assets (images, CSS, and JS) our applications use. However, many hosts (including Heroku) do not compress the HTML that is generated by our applications by default.

Ensure…

you compress the HTML output being sent from your app with gzip using Rack::Deflater.

config/application.rb

# ...
module DreamCoverage
  class Application < Rails::Application
    # ...
    config.middleware.use Rack::Deflater

Why?

Compressing ‘text-based’ resources (i.e. the HTML or JSON your views…

Ruby Yagi 🐐 

How to truncate long text and show read more / less button

If you are working on an app that has user generated content (like blog posts, comments etc), there might be scenario where it is too long to display and it would make sense to truncate them and put a “read more” button below it.

This post will solely focus on the front end, which the web browser will detect if the text needs to be truncated, and only show read more / read less as needed. (dont show “read more” if the text is short enough)

TL;DR? Check out the Demo at CodePen.

Truncate text using CSS

Referenced from TailwindCSS/line-clamp plugin.

Using the combination of these CSS properties, we can truncate the text (eg: <p>...</p>) to the number of lines we want :

.line-clamp-4 {
  ov…
Doctolib Engineering 

GitHub actions: how to push a GitHub status in addition of GitHub checks

GitHub actions are incredibly efficient to quickly deploy a CI on a project, especially because of the native parallelism system.

But we found some downsides along the way. One downside is the result of a GitHub actions is a Check, not a Status.
There are identical in the UI, but are not in the API. In the image below, the last line is a status in the API, but all the lines above are checks at API Level.

image

What is wrong with that? At Doctolib, we have a lot of automation relying on statuses, not on checks. To onboard some of our projects on Github action, we were looking for an elegant solution.

The first idea is to add a step at the end of the workflows, which push a status from here.

Remote Ruby 

Code Metrics with Kevin Murphy

[00:03:15] We start with Andrew telling us he’s not a fan of code coverage metric and talks about a gem everyone uses called SimpleCov and what it does. Kevin dives into code coverage and why he doesn’t believe it’s a holistic measure and how code coverage can lie to you.  

 

[00:05:40] Find out why Kevin love tests, and he explains some other downsides of focusing on code coverage and brings up Coveralls and when is it too much.


[00:08:55] Andrew asks Kevin if there are some metrics that are good to track to provide value for your team. 


[00:15:59] Chris and Kevin chat about tools and Andrew mentions Attractor, from Julian Rubisch and possibly RubyCritic.


[00:17:33] Andrew wonders how…

Awesome Ruby Newsletter 

💎 Issue 275 - Rails report: Good-bye [autoloader] classic mode, –skip-puma, –skip-gemfile.. hello weekday_options_for_select!

Ruby Weekly 

Basecamp's privacy-aware Rails console

#​567 — August 26, 2021

Read on the Web

Ruby Weekly

Privacy-Aware Rails Consoles with console1984 and audits1984 — Basecamp created console1984 to protect sensitive/encrypted data in a console connected to production. The audits1984 gem provides a UI (Rails engine) to examine the logs created by console1984.

Jorge Manrubia (Basecamp)

A Tour of Twist — Twist is a Hanami-inspired Ruby application that Ryan uses to expose his nascent books to reviewers for notes and suggestions. It uses dry-rb components, ROM, and many off-the-Rails-path items.

Ryan Bigg

Free eBook: Effective Indexing in Postgres

John Nunemaker 

Founders Talk: The acquisition of a lifetime

Adam summarized our conversation well:

On today’s show Adam is joined by John Nunemaker (an old friend). For some of you listening you might remember John’s appearance on The Changelog #11, which was basically forever ago.

Or his company Ordered List — they made Gauges, Harmony, and Speaker Deck which was quite popular in its time — so much so that they attracted the attention of Chris Wanstrath, one of the co-founders of GitHub to acquire Ordered List. The rest as they say is history.

Today, John and I go back through that history to see what it was like to be acquired by GitHub and how that single choice has forever changed his life.

You can follow this link or use this fancy embed below…

Truemark Technology 

Run RuboCop on git commit with Overcommit Gem

How do you make sure that RuboCop rules configured in your project are followed by all your team members and code with issues are not pushed to Git repository?

Answer is using Overcommit gem with git hooks. Git hooks are one of the most popular way to trigger and enforce different side effects like RuboCop rules. Overcommit gem depends on git hooks to trigger RuboCop rules and make sure that all issues are resolved before you or anyone on your team can commit and push new changes to Git.

Assumptions

  • You have basic knowledge of Rails
  • You have worked with RuboCop previously and have required configuration files for RuboCop in your project

Shameless Plug:

If you are new to…

The RubyMine Blog : The Ruby on Rails IDE | JetBrains Blog 

RubyMine 2021.2.1 Is Available

RubyMine 2021.2.1 is now available!

You can update using the Toolbox App or right from inside the IDE. You can also download RubyMine 2021.2.1 from our website.

You’ll find the following important fixes in this update:

  • Fixed the issue with extra whitespaces appearing after reformatting multiline statements with /: RUBY-21927
  • Added the ability to mark directories under vendor/as a library root or part of the project: RUBY-18315
  • Fixed the behavior of the shortcuts used to extend the text selection: IDEA-267294
  • Fixed the issues causing the file type setting to be reset when the IDE is restarted: IDEA-274889
  • Fixed the Run/Debug Configuration issue: when you click the Run button, the IDE runs…

Check out…

Saeloun Blog 

ECMAScript 2021(ES12) introduces replaceAll method and numeric separators

ECMAScript 2021(ES12) is the latest JavaScript version that introduced multiple new features to the JavaScript language.

In this blog, we will cover replaceAll() method and numeric separators that was a part of ECMAScript 2021 additions.

String.prototype.replaceAll()

String.prototype.replaceAll() method replaces all instances of a substring in a string with a new string value.

Syntax

String.prototype.replaceAll(subString, newSubstring)

Parameters

subString: Input string that is to be replaced by a new value. It can be a string or a regular expression.

newSubstring: The string that replaces the substring argument

Return value

The original string is left unchanged and a new string…

All Ruby Podcasts by Devchat.tv 

Using Typing Systems in Ruby with Sorbet ft. Alex Dunae - RUBY 512

Alex Dunae joins the Rogues to discuss his experience introducing types into an existing codebase using the Sorbet gem and how it saved him and his company time, money, and effort.

The conversation covers libraries and tools for working with types in Ruby.

Panel

  • Charles Max Wood
  • Luke Stutters
  • Valentino Stoll

Guest

  • Alex Dunae 

Sponsors

Links

Picks

Noteflakes 

What's new in Polyphony and Tipi - August 2021 edition

The summer is drawing to an end, and with it I bring another edition of Polyphony (and Tipi) news, this time on my own website, where I’ll be publishing periodically from now on.

Polyphony is a library for writing highly concurrent Ruby apps. Polyphony harnesses Ruby fibers and a powerful io_uring-based I/O runtime to provide a solid foundation for building high-performance concurrent Ruby apps.

Tipi is a new Polyphony-based web server for Ruby. Tipi provides out of the box support for HTTP/1, HTTP/2, and WebSocket. Tipi also provides SSL termination (support for HTTPS) with automatic certificate provisioning and automatic ALPN protocol selection.

From counterpoint to composition

Engine Yard Blog 

Rails encrypted credentials on 6.2

Any rails program would have secrets to be stored, for at least the secret key base with tokens for third-party APIs.  Post  version updates, handling secrets has become easier.

Notes to self 

Writing Absinthe authorization middleware

Plug is not the only interface with the middleware layer. Absinthe also comes with a middleware layer of its own and we can use it similarly to implement authorization for queries, mutations, and subscriptions.

If we want to authorize our GraphQL API and don’t want to do that within business logic (for various reasons), we can write a middleware that will handle it. I wrote about using Plug for authorization, but using a plain Plug wouldn’t work in this case.

Since GraphQL is essentially a graph, we need to cover authorization for all nested queries. Absinthe middleware can do that for us, and might also be used for specific query fields, which is quite handy.

In the following example,…

Saeloun Blog 

Rails 7 optimizes remove_columns to use a single SQL statement when supported

ActiveRecord Migrations provides neat ways to handle migrations in databases. This includes adding, updating, and removing columns in databases. Some of these operations can take a lot of time, depending on the translated SQL queries.

One of these slow operations is the remove_columns operations with multiple columns. It is because individual SQL queries are triggered to delete each column. Since, both MySQL and PostgreSQL support dropping multiple columns in a single SQL statement, Rails 7 will now generate a single SQL statement to remove all the columns together if the database supports it.

Since SQLite3 doesn’t support dropping multiple columns, it will still generate multiple SQL…

The Ruby on Rails Podcast 

Episode 381: Life Stories and Some Of Our Favorite Things (Brittany & Jemma)

Jemma is going to be joining Shopify as a member of the Core Foundations team! She and Brittany discuss the interview process from Jemma's perspective. They then talk through their favorite developer tools, what they would improve and what sponsorship means for this show and WNB.rb.

Show Notes & Links:

Sponsored By:

Honeybadger

Honeybadger makes you a DevOps hero by combining error monitoring, uptime monitoring and check-in…

Greater Than Code 

247: Approaching Learning and Content Creation with Sy Brand

02:01 - Sy’s Superpower: Making Complex Topics Digestible

06:28 - Approaching Learning to Code: Do Something That Motivates You

11:25 - Computers Can Hurt Our Bodies!

13:57 - Motivation (Cont’d)

22:15 - Sy’s Content (Cont’d)

33:58 - Code As Art

41:34 - #include…

Benito Serna 

Using an objet to represent a complex preload

Sometimes just using preload or includes is not possible… or maybe it is, but you just can’t figure it out how to do it.

Maybe you want to preload some records matching two keys, or preload a grouped relation.

Maybe you know how to represent the association with a has_many :through, but you need something faster, or to use less memory.

In that kind of situations, one thing that you can do is to write a custom object to represent that preload.

Here I will try to explain how and when you can do it with an example.

Index

Example

For example, given the…

Ruby Together News 

July 2021 Monthly Update

Hello! Welcome to the monthly update. During July, our work was supported by Zendesk, DigitalOcean, Stitch Fix, and many others.

ruby together news

In July, Ruby Together was supported by 39 different companies, and 3 companies joined as new members.

On top of those companies, 3 new developers signed up as members: Wayne Vucenic, Joe Winter, and Stephan Kämper. In total, we were supported by 108 developer members. Thanks to all of our members for making everything that we do possible. <3

rubygems & bundler news

This month in RubyGems, We released new versions of RubyGems (3.2.22, 3.2.23, 3.2.24, and 3.2.25) and Bundler (2.2.22, 2.2.23, 2.2.24, and 2.2.25).

We also simplified Bundler…

Test Double Blog 

Double Agent Profile: Daniel Flynn

Name: Daniel Flynn Designation: Agent 0056 Double Agent Role: Senior Software Consultant Special Skills: Quantity and quality distributed across a bell curve derived by the amount of coffee consumed. Aliases: Github Location: Dayton, OH Favorite Emoji: ✨
Ruby Magic by AppSignal 

Responsible Monkeypatching in Ruby

When I first started writing Ruby code professionally back in 2011, one of the things that impressed me the most about the language was its flexibility. It felt as though with Ruby, everything was possible. Compared to the rigidity of languages like C# and Java, Ruby programs almost seemed like they were alive.

Consider how many incredible things you can do in a Ruby program. You can define and delete methods at will. You can call methods that don’t exist. You can conjure entire nameless classes out of thin air. It’s absolutely wild.

But that’s not where the story ends. While you can apply these techniques inside your own code, Ruby also lets you apply them to anything loaded into the…

Rails Performance Audit and Tuning Consultant for Hire 

5 Productivity Tips for Lazy Ethereum Blockchain Developers

Working with Ethereum blockchain is vastly different from any tech stack that I’ve encountered before. In this blog post, I’ll describe a set of tools and techniques that I wish I knew when I started building my first Solidity project. We’ll discuss how to use the Mainnet without paying gas fees, apply advanced debugging to local transactions and steal all the Vitalik’s Ether.

1. Don’t use testnets for testing

Developing for Ethereum is an expensive hobby. With the current gas fees deploying a simple smart contract costs over $100.

A common practice is to deploy contracts to one of the testnets before the final release is ready. This approach works good-enough for simpler contracts that…

Frank’s blog 

The most underused browser feature

The web has been plagued by cookie consent popups and banners since the General Data Protection Regulation (GDPR) has come into effect. See for yourself when you visit articles like this and this. Now what if I told you there is a one-click solution to hide those banners and make your reading experience on websites such as these examples a lot simpler?

I’m talking about the “reader mode”. When available for a website, it is displayed as an icon at the end of the url bar in Firefox. The same is true for Chrome, but you first need to enable it at chrome://flags/#enable-reader-mode. Safari on iOS includes it in the menu at the left of the url bar.

Now open the first example again and click…

Saeloun Blog 

Rails 7 now consistently renders button_to

Rails provides many methods that render out HTML tags, allowing for easy customization. However, some of the Rails methods do not offer consistent results. One such example, until recently, was the button_to helper method.

This is how it works,

  <%= button_to "New", new_article_path %>

  # => "<form method="post" action="/articles/new" class="button_to">
  #      <input value="New" type="submit" />
  #    </form>"

Unfortunately, the helper method render <input type="submit"> when passed String contents but renders <button type="submit"> when passed a block.

Before

Though this difference is subtle, it will lead to surprises later. One such quirky behavior is when button_to renders out…

Test Double Blog 

How OWASP helped me quit Facebook

Over the last couple years I have been getting fed up with social media. For me, that mostly means Facebook and various Google services and software. Google was once thought of as an ethical company and beloved by nerds.
Code with Jason 

109 - Peter Cooper, Publisher of Ruby Weekly

In this episode, Peter Cooper and I discuss the publishing of Ruby Weekly and the benefits of podcasting and blogging. We also talk about cars and the Smashing Pumpkins.

Blog of WJWH 

Submitting many ActionMail jobs at once with Sidekiq

The default integration of ActiveJob with Sidekiq can be slow when submitting many jobs in a loop, because a new network roundtrip is made for every job. While Sidekiq does allow for multiple jobs to be submitted in the same call, this functionality is not natively available from Rails. This post describes the root cause of the problem and shows how to work around it with the `push_bulk` method provided by Sidekiq.
Martian Chronicles, Evil Martians’ team blog 

SPA hexagon: Robust app architecture for mobile and web

Author: Alexander Madyankin, Senior mobile software engineer at Evil Martians

See how we stepped away from the Apollo-driven design for a GraphQL-backed multi-platform frontend application and went for a robust and scalable approach inspired by Alistair Cockburn’s Hexagonal Architecture that we applied to the modern React, React Native, and TypeScript stack. If you get inspired by diagrams and love solving high-level design puzzles—this post is for you!

This article summarizes our learnings from helping an American real estate startup simplify housing and create a better co-living experience. During this collaboration, we have built two React Native applications and arrived at a…