Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
Andy Croll 

All Your Mailer Views in One Place

One of the greatest things that Rails provides to developers is a sensible set of defaults for where stuff goes in the file hierarchy. The standard approach to app/models, app/mailers, app/views, config, etc., allows us to arrive at a Rails project and quickly understand where existing code is and where to place our new code.

I’m therefore loathe to deviate from the defaults, but I do make one exception: email view templates. They live in the same part of the folder hierarchy as the web views tied to Controllers, e.g. the views for whatever_mailer are found in app/views/whatever_mailer, even though your application’s Mailers are in a different location to your Controllers.

I don’t know…

Emmanuel Hayford 

Linking a Webcam Directly to Rails’ ActiveStorage

Linking a Webcam Directly to Rails' ActiveStoragePhoto by Laura Boccola

Quick Note: I’m actively looking for a new remote Ruby/Rails opportunity. Please get in touch if you or someone you know needs some hands and I’ll be happy to jump aboard! Here’s a CV.

OK, down to business!

ActiveStorage is awesome! For all the times I’ve seen it being used, it was for direct file uploads where the user clicks a file field, a window pops up and a file is selected, usual stuff, nothing new.

Not long ago, I was tasked with developing a feature to allow users to upload pictures, not from the traditional sense that we already know but from the webcam. This was novel!

Note: I have built a working version of this here and also posted the code on GitHub…

Getting the Frontend Sorted…

Appfolio Engineering 

How Much Do You Save With Ruby 2.7 Memory Compaction?

If you read this blog recently, you may have seen that Ruby Memory Compaction in 2.7 doesn’t affect the speed of Rails Ruby Bench much. That’s fair - RRB isn’t a great way to see that because of how it works. Indeed, Nate Berkopec and others have criticised RRB for that very thing.

I think RRB is still a pretty useful benchmark, but I see their point. It is not an example of a typical Rails deployment, and you could write a great benchmark centred around the idea of “how many requests can you process at most without compromising latency at all?” RRB is not that benchmark.

But that benchmark wouldn’t be perfect for showing off memory compaction either - and this is why we need a variety of…

Remote Ruby 

Joined by Jonathan Reinink, Creator of Inertia.js

Saeloun Blog 

Rails adds ActiveRecord API for switching multiple database connections

Rails has introduced support for multiple databases in application.

Rails now provides a method connects_to which we need to specify at the model level and mention the databases as shown below:

class User < ApplicationRecord
  connects_to database: { writing: :primary, reading: :replica }
end

As specified in the connects_to block above, all the update and insert queries will be executed on the primary database and select queries on replica.

connects_to method must be specified in the common base class, let’s say ApplicationRecord and this can be inherited by other models as needed. Database clients have a limit on the number of open connections and hence we need to specify connects_to

Awesome Ruby Newsletter 

💎 Issue 195 - A Developer's Notebook - Repurposing an old Android phone as a Ruby web server

Ruby on Rails Podcast 

307: Choosing the Right Tech Stack with Dave Paola

Dave Paola was cofounder and CTO at Bloc. He is now the cofounder of Jellyswitch, unleashing the power of the distributed workforce. Dave and Brittany converse about choosing frameworks, bootcamps and frontend frameworks.

Links for this episode:

Ruby Weekly 

A Look Inside the Ruby Concurrency Toolbox

#488 — February 13, 2020

Read on the Web

Ruby Weekly

A Look Inside the Ruby Concurrency Toolbox — This post covers threads, fibers, and guilds (hypothetically) and while you’ve likely seen all of this before, this is a solid explainer with practical comparisons.

Alex Braha Stoll

rubyapi.org: Another Way to Search and Explore Core Ruby Docs — There have been a few projects like this over the years, but the presentation on this one is pretty nice, it’s open source, and it looks good on mobile.

Colby Swandale

Get Deeper Insights into Your DB with Automated EXPLAIN Plan Analysis — Other tools…

Code with Jason 

Understanding Rails secrets/credentials

What this feature is for

The credentials feature is a way of storing secrets that you don’t want to keep in plaintext, like AWS credentials for example. (In fact, the one and only thing I keep in my main Rails project’s credentials are my Active Storage AWS credentials.)

Why the credentials feature is difficult to learn about

I personally have found Rails credentials really hard to understand. I think there are three reasons why this is.

  1. The official Rails docs about the credentials feature are a little terse and not easily discoverable.
  2. The feature changed somewhat drastically from Rails 4 to Rails 5, even changing names from “secrets” to “credentials”.
  3. I only need to use the feature once…

How to work with credentials without frustration

There are perhaps five important…

Saeloun Blog 

Rails introduces disallowed deprecations in ActiveSupport

As we upgrade our application’s Rails version, we often come across deprecation warnings.

For example:

> user.update_attributes(name: 'New name')
DEPRECATION WARNING: update_attributes is deprecated and will be removed from
Rails 6.1 (please, use update instead)
(0.1ms)  begin transaction
User Update (2.7ms)  UPDATE "users" SET "name" = ?, "updated_at" = ? WHERE
"users"."id" = ? [["title", "New name"], ["updated_at", "2019-05-11 11:32:48.075786"],
 ["id", 1]]
(1.1ms)  commit transaction
=> true

In the above case, we remove these deprecation warnings by replacing update_attributes to update.

But, when developing new features after it, we might use end up using deprecated update_attributes

The Miners 

My Experience Migrating a Rails API to Crystal and AWS Lambda – Part II Optimizing our solution with Crystal

Hey, this is the second part of my post, giving an overview of how I migrated a Rails API to Crystal with hosting on AWS Lambda.

In the first part, I have given an introduction about how our Rails API was designed and the technologies that we used. Now, I will explain why we chose to use Crystal, the different solutions we stumbled across, and some technologies we used to finish our microservice.

Some of you should be asking yourselves now: What is Crystal, and why use it?

This is what I am going to explain now!

The Crystal Lang

Crystal is a programing language with syntax similar to Ruby, statically type-checked, and most importantly: it is a compiled language!

class Code
  def…
Scott Bartell 

Building a Sumo Logic Dashboard for a Rails App on Heroku

Note: The dashboard and graphs outlined in this article are simplified examples of what I have used successfully in a production environment in the past. You should modify the dashboard and queries to fit your application’s specific needs.

Example Sumo Logic Dashboard for Heroku Rails App You can download the JSON config to import this dashboard for your own application.

Overview

Our goal is to create a Sumo Logic dashboard that we can use to help us identify trends and problems with the performance of our Heroku Ruby on Rails application.

To do this we are going to focus on a few key areas:

  1. Rails Application (Web Dynos)
    • Web dyno load1
    • Web dyno memory utilization
  2. Heroku Postgres
    • Postgres load2
  3. Wo…
Fast Ruby Blog 

How to Calculate Tech Debt Using Skunk on GitHub Actions

In preparation for my talk at RubyConf Australia this month, I've been working on a way to make it easy for anyone to run skunk on their Ruby projects. In order to do that I decided to use GitHub Actions. It's a powerful service by GitHub and it's quite easy to set up.

This is an article about the process that I followed and how you can use it in your own application.

GitHub Actions have been around for more than a year and I had been meaning to play around with them to incorporate some automation to our workflows at FastRuby.io. The good news is that GoRails already published an article about setting up CI in your Rails app: Continuous Integration with GitHub Actions

After following…

Ruby Magic by AppSignal 

Getting Started With System Tests in Rails With Minitest

In today’s post, we’ll look at system tests in Rails 6. System tests are meant to auto-test the way users interact with your application, including the Javascript in your user interface. Minitest, being the default testing framework in Rails, is a great match for system testing. With all the configuration that Rails handles for us, there are just a few steps needed before we have our first tests up and running.

System tests were added to the Rails stack in Rails 5.1. When I sat down to start using them, I found it hard to gather relevant, up to date information that is not about RSpec. Here’s all the latest and greatest that I collected on working with the system tests with Minitest.

Intro…

Greater Than Code 

169: Career Elbows

01:49 - Rein Talks About His Recent Career Transition From Being a Consultant to a Full-Time Employee

03:52 - Jamey Talks About the Decision to Leave Their Job

  • Making The Decision To Leave Your Comfort Zone

05:34 - Pros and Cons of Staying for Job Stability and Comfort

13:20 - Resilience and Regulatory Mechanisms

15:59 - Interviews

20:20 - Job Success and…

Honeybadger Developer Blog 

Opening The Ruby Concurrency Toolbox

Concurrency and parallelism are more important than ever for Ruby developers. They can make our applications faster, utilizing the hardware that powers them to its fullest potential. In this article, we are going to explore the tools currently available to every Rubyist and also what Ruby promises to soon deliver in this department.

Not everyone uses concurrency directly, but we all use it indirectly via tools like Sidekiq. Understanding Ruby concurrency won't just help you build your own solutions; it will help you understand and troubleshoot existing ones.

But first let's take a step back and look at the big picture.

Concurrency vs. Parallelism

These terms are used loosely, but they…

The Miners 

My Experience Migrating a Rails API to Crystal and AWS Lambda – Part I The First Iteration on Rails

Hey folks!

Today I am going to tell you how was my first project as a Codeminer42 employee. Two colleagues and I were charged of building a microservice for a logistics company. It was a great experience to learn about new services, features, and even a new programming language.

You can read the part 2 of this post here.

Without further ado, let’s start!

Contextualizing

Before telling the whole thing, I would like to bring in some context. As I said, this was my first official project as a Codeminer42 employee. Our job was to build an API that receives a list of locations and returns the best route, going through all locations. This is widely known as the Travelling Salesman Problem

The TSP describes a…

Saeloun Blog 

Rails has added a benchmark generator

Rails added a new benchmark generator. This is used to create benchmark file that uses benchmark-ips.

To use the benchmark generator, run

rails generate benchmark my_benchmark

This creates a benchmark file script/benchmarks/my_benchmark.rb. It also adds benchmark-ips gem to Gemfile. Be default, it adds 2 blocks for reporting before and after that can be used for benchmarking.

The file content looks like following:

# frozen_string_literal: true

require_relative "../../config/environment"

# Any benchmarking setup goes here...



Benchmark.ips do |x|
  x.report("before") { }
  x.report("after") { }

  x.compare!
end

This benchmark can be run using following command:

ruby…
Rails with Jason 

031 - Noah Gibbs on His New Book, Mastering Software Technique

Noah is working on a new book called Mastering Software Technique. In this episode Noah and I talk about his book, parallels between visual art and programming, French loanwords, and European history.

Alfredo Motta 

Not So Random Software #13 – Observability

Welcome back to Not So Random Software. This week’s links are dedicated to Observability; the capability to observe the system’s current state and how the system reached such a state. I have been researching this topic for a lightning talk at the London Ruby User Group and here are some of the links I found. […]
The Bike Shed 

232: I'm Not Allowed to Play With Other Shells

On this week's episode, Chris and Steph celebrate the new Bike Shed website and logo!

Steph finds a new way to optimize her keyboard happiness and Chris dabbles with Zsh auto-suggestions. They also explore the team and technical trade-offs in the pursuit of clean code and respond to a listener question about building products that meet strict security policies.

This episode is brought to you by Clubhouse. Click through to get 2 free months on any paid plan.

Sponsored By:

Test Double | Our Blog 

The Slippery Slope of Docker Dev Environments

Recently, I built up a local development environment that uses Docker for some critical integration test paths. As I put the finishing touches on this work, I realized there were some far-reaching implications that I had not taken into consideration before I started down this road, namely:
Honeybadger Developer Blog 

F*ck-That Money

I've met some hugely successful people. Some of them are happy. Some of them... aren't. I've noticed some things about the ones who aren't:

  • They're obsessed with their careers
  • They spend a lot of time at work
  • They aren't fulfilled by the work they do
  • They aren't content with what they have

In many circles, these people are way more successful than most of us. They probably have better networks. They might have fancier job titles. They certainly make more money.

The Silicon Valley meme goes, "start a company and sell it for so much money that you can say 'f*ck you' to anyone in the world." Or maybe an alternate career path is to climb the corporate ladder at Google until you've banked…

Saeloun Blog 

Rails adds support for if_exists/if_not_exists on remove_column/add_column in migrations

In Rails, when we have a table and we want to add or remove columns from that table, then we write migrations using methods like add_column for adding column and remove_column for removing a column.

Typical add_column and remove_column migrations look like these:

class AddDescriptionToProduct < ActiveRecord::Migration[5.1]
  def change
    add_column :products, :description, :text
  end
end
class RemoveDescriptionFromProduct < ActiveRecord::Migration[5.1]
  def change
    remove_column :products, :description
  end
end

If the column is already present and we try to run add_column migration then we get an error like this:

DuplicateColumn: ERROR:  column "description" of relation…
Remote Ruby 

StimulusReflex at CodeFund, Testing ChurchChat, Encryption Gems, Inspecting Hey.com

Rebased Blog 

SSH Key Internals

SSH is a great tool but it can also be pretty complex. Therefore it is often misunderstood, misused or underutilized. In this short series of two articles we’ll go into what SSH is, how exactly it works and how we can use it most effectively and securely, avoiding common pitfalls....
Riding Rails 

This week in Rails - PostgreSQL 11 partitioned indexes support and more!

Hello, this is Greg, bringing you the latest news about Ruby on Rails!

20 contributors to Rails in past week

There have been 20 contributors to Rails past week! 

Default HSTS max-age directive to 2 years

The new recommendation for the HSTS max-age directive is 2 years, and that’s what Rails defaults to from now on.

Add support for partitioned indexes in PostgreSQL 11+

This pull request adds support to retrieve partitioned indexes when asking for indexes in a table. 

Add a fallback database config when loading schema cache

The schema cache defaults to loading the ‘primary’ database config, however, if an app doesn’t have a db config with a spec name of ‘primary’ the filename lookup…

Prathamesh Sonpatki 

How to get feedback on your Ruby blog posts

You have written a blog post about Ruby or Rails or Hanami or Roda? Great, Congratulations! Now is the time to share it with other Rubyists and get some feedback.

Rubyflow

You can share it on rubyflow.com. Rubyflow is aggregator where people post links about articles or gems that they find interesting.

Reddit

Reddit is great place to share the blog article and get some feedback. You can post your article to r/ruby or /r/rubyonrails/ (for Rails specific articles)

dev.to

dev.to is my favourite place these days to find interesting articles about various languages and libraries. You can write an article itself on dev.to platform or connect your blog to it so that you can cross post your existing…

Saeloun Blog 

Rails adds support for if_exists/if_not_exists on remove_column/add_column in migrations

In Rails, when we have a table and we want to add or remove columns from that table, then we write migrations using methods like add_column for adding column and remove_column for removing a column.

Typical add_column and remove_column migrations look like these:

class AddDescriptionToProduct < ActiveRecord::Migration[5.1]
  def change
    add_column :products, :description, :text
  end
end
class RemoveDescriptionFromProduct < ActiveRecord::Migration[5.1]
  def change
    remove_column :products, :description
  end
end

If the column is already present and we try to run add_column migration then we get an error like this:

DuplicateColumn: ERROR:  column "description" of relation…
Scott Watermasysk 

Via Configurator

I previously mentioned my best experience with QMK was via ErgoDox EZ's online tool, Oryx. Oryx may be the best online tool, but it is no longer my favorite.

Hello Via Configurator.

Via Configurator Logo

Via is a desktop tool for configuring your keyboards' firmware (QMK). I had never used it until a couple of days ago, but I have now tried it with three different keyboards (NK65, Rama M10-B, and Rama M60-A). In all three cases, it has been nothing short of amazing. I am blown away by how well it works.

Via's most impressive feature: no compiling and flashing. You make a change, and it is working on your keyboard. No need to run a make command and then flash your board. No need to compile and watch the baking…

OmbuLabs Blog 

Tips For Creating Contributor Friendly Open Source Projects

At Ombu Labs we are firm believers of open source. We use open source but also like to contribute back to the community and we have open sourced a few projects.

We know that contributing to open source can be a difficult task so we have been looking for easier ways help to onboard new and past contributors. Here is a list of tips and tools that we believe that can help you make your open source project a more friendly space.

Documentation

Having proper documentation for your project is key to make your project more friendly. Document the steps to setup the project, known issues and a guide on how to properly contribute to the project with a CONTRIBUTING.md or adding steps in your…

Awesome Ruby Newsletter 

💎 Issue 194 - Error handling with Monads in Ruby

Honeybadger Developer Blog 

Breadcrumbs for JavaScript

One of the things that makes fixing JavaScript errors so difficult is that everything happens on the client-side. When an obscure error happens in a callback, you often lack the context to reproduce it. If the error is critical, you may even resort to deploying debug code to get more information about the events leading up to it.

We added a feature to help, and it's called Breadcrumbs.

Breadcrumbs for javascript

A Breadcrumb is a client-side event that happened before an error. Breadcrumbs are collected in realtime as users interact with your client-side application. When an error happens, the breadcrumbs leading up to it are included, filling in the missing context.

Since launching breadcrumbs for Ruby and…

Ruby Weekly 

Exploring Big-O Notation with Ruby

#487 — February 6, 2020

Read on the Web

Ruby Weekly

▶  An Interview with David Heinemeier Hansson, the Software Contrarian — The creator of Rails talks about his relationship with Ruby, and why single page apps, microservices, and standups are not for him. 63 minutes.

CoRecursive Podcast podcast

Exploring Big-O Notation with Ruby — ‘Big O’ notation is used to express algorithmic complexity and it’s a handy concept to know as a developer (and not only for job interviews).

Honeybadger Developer Blog

Because Reading Error Logs Is Not a Hobby — What would you do with more time in your day?…

Scott Watermasysk 

Taking Control of Twitter

For better or worse, Twitter has become the de facto information exchange hub for some of my favorite communities (developers and bootstrappers). While I long for the day when blogs and personal sites make their triumphant return, I am taking a more pragmatic approach to how I interact with Twitter.

Twitter makes sharing small pieces of content highly efficient. Unfortunately, it lacks tools to make consuming content anywhere near as efficiently. Since it relies on your eyeballs to get paid, it does its best to keep you within it as much as possible.

Over the last couple of months, I have been using the following tools to help keep me informed, without the time suck that Twitter can often…

With a Twist 

Backward-compatible database migrations

My team has a policy of not applying destructive changes to our database. We don’t, for example, remove a column or table when deprecated, and we don’t rename either, as renaming is akin to removing a name the code uses.

Our deployment process performs database changes about a minute before the related code changes go live. During this time, Rails might run database queries using an out-of-date schema, erroring out. As the usage of our app continues to increase, even sub-second rename migrations bring down several in-flight requests.

For some time, we dealt with this by deploying after hours, with the consequence of having to work after hours. Also, this doesn’t guarantee that no users…

Valentino Gagliardi - RSS Feed 

Formatting dates in JavaScript with Intl.DateTimeFormat

Formatting dates in JavaScript with Intl.DateTimeFormat

What is Intl?

The Intl object in JavaScript is the home for methods and constructors of the ECMAScript Internationalization API. This API has a number of convenient features for converting strings, numbers, and dates.

Intl.DateTimeFormat is part of Intl and in this post we'll see how it can help with date formatting.

A quick introduction to ISO strings

Consider an ISO string like this:

const date = new Date().toISOString();

// "2020-02-05T16:30:41.392Z"

The ISO string format is convenient and can be used in the time HTML tag for example:

<time datetime="2020-02-05T16:30:41.392Z">Published on ...</time>

Or in the head:

<meta property="article:published_time" content="

Search engines may…

Fast Ruby Blog 

Gemifying your style guide to DRY your CSS

At Ombu Labs we like to follow a style guide to drive our own products. A style guide is a document that provides guidelines for the way your brand should be presented from both a graphic and language perspective. You can see Fast Ruby's style guide at this link.

Since we have a few applications in place and it's important to make sure that they all use the same style, we need to ensure that they will all inherit the same CSS files. One way to do this is to copy the above style guide and paste it inside all of our apps, but this would end up causing a lot of duplicated code. If we decided to change the font-style, for example, we would need to change it in all apps individually.

Something…

Scott Watermasysk 

QMK Any (or How to Setup a Custom Quantum Keycode)

I mentioned previously that I am huge fan of the QMK Firmware.

For most customizations, you can use the online configurator to make your changes right in the browser.

I have been using a keyboard with a HHKB layout the last couple of weeks. After a bit of trial and error I settled on the following basic layout:

Bottom Row

  • Bottom Row: Control - Command - Spacebar - Alt - Control
  • Caplock - MO(2) (essentially Function2)
  • Function - MO(1)

This has been working really well for me, with one notable issue - Command + Alt is awkward. This is evident when trying to debug something in a browser. For years, I have been trained to Command+Alt+I to open up the developer console and related tools in every browser.

Ruby on Rails Podcast 

306: Ask For The Job with Brian Mariani (Part II)

Back by popular demand, Brian is back! Brian Mariani, founder of Mirror Placement, a Ruby on Rails focused recruiting firm, came back to share his wisdom on financial negotiations, what it is like to recruit from both the client and developer side and that one overlooked tip to get the job.

Links for this episode:

Kir Shatrov 

Databases and company growth

You start a company, make the MVP in Ruby on Rails or whatever another technology is hyped at the moment, raise a round of investments, and start hiring people. All of your production fits in the Hobby plan on Heroku and a single database (also managed by Heroku).

A few years after, your headcount is a couple hundred people, and the business is growing as well as demands for the app. You start noticing occasional load on that Heroku-managed database. This load could be analytical workloads like reports or a particularly noisy customer that hits a path that’s no so well optimized for the DB access.

You move analytical workloads on a read-only replica of the primary DB and optimize that…

Greater Than Code 

168: Appolition with Dr. Kortney Ziegler

01:06 - Kortney’s Superpower: Being a visionary. Seeing things that aren’t necessarily there.

01:50 - How Appolition Came to Be

  • Grassroots Company Crowdfunding Money for Incarcerated Black Mothers
  • Tweeted About Using the Change Round Up Model
  • Educating Those in Tech About What Bail Is
  • Gaining Trust

07:20 - Kortney’s Professional Background

  • Building Things in Technological Space
  • PhD in 2011 - difficulty finding substantial employment
  • Filmmaker, Scholar
  • Encountered a lot of discrimination in professional career
  • Became Entrepreneur in 2012/2013
  • Attended Filmmakers Hackathon
  • Launched Trans*H4CK
  • Appolition

13:10 - Appolition Specifics

  • Bail is Predatory
  • Educate Yourself About…
Valentino Gagliardi - RSS Feed 

Cos'è JavaScript e perché studiarlo?

Cos'è JavaScript e perché studiarlo?

Cos'è JavaScript?

JavaScript è un linguaggio di programmazione (detto anche di scripting). Tutti gli sviluppatori conoscono JavaScript in qualche misura. Da semplici animazioni sulle pagine web ad interazioni complesse, tutti ci siamo trovati almeno una volta ad utilizzarlo.

JavaScript è un linguaggio di programmazione nato in origine per il web. Brendan Eich, il creatore di JavaScript, si ritrovò nel 1995 a lavorare per Netscape. Il project manager assegnò a Brendan un compito in apparenza impossibile da portare a termine: creare un linguaggio di programmazione che funzionasse nel browser Netscape Navigator.

Brendan Eich concepì JavaScript (originariamente…

Honeybadger Developer Blog 

Honeybadger is hiring a software developer

For only the second time in the 7+ years we've been running Honeybadger, we have an opening for a software developer position. This individual will have ownership of our open source libraries, and will participate in significant projects in our main Rails app and in other apps we are bringing to market this year.

We hope that candidates of all backgrounds will apply... though we are a pretty homogenous team at the moment, we'd like that to change. :) Our goal as a company is to always be learning and growing, and we feel we can best do that when we have a variety of experiences and viewpoints from which to draw.

This is a full-time position available to remote candidates in time zones…

Honeybadger Developer Blog 

Exploring Big-O Notation With Ruby

There once was a time when nothing scared me more than hearing the question, "What's the Big-O notation for that?" I remembered the topic from school, but because it had to do with math (which was never my strongest subject), I had blacked it out.

However, as my career progressed, I found myself:

  • Looking at performance charts
  • Trying to debug slow queries
  • Being asked if I had considered how my code would hold up given increased load

When I decided it was time to circle back (get it?) to learn Big-O, I was surprised at its high-level simplicity. I'm sharing what I learned in this article so that you, my fellow engineers, can not only pass interviews with flying colors, but also build…

Saeloun Blog 

Rails 6 - ActiveSupport Deprecations in Unicode and Chars support in favour of String

Rails has support for working with Unicode characters using the ActiveSupport multibyte chars functionality.

For example:

string = "Çafé"

string.mb_chars.downcase.to_s
=> "çafé"

Unicode and Chars in ActiveSupport had their own implementation for methods like downcase, upcase, swapcase, normalize, etc.

Rails 6 deprecated below methods in ActiveSupport in favor of using String methods directly.

These String methods are available from Ruby 2.3+ onwards and hence…

Saeloun Blog 

Rails 6 adds rails db:system:change command

Let’s create a new Rails app.

rails new sample

Our database.yml contains configuration specific to sqlite3 because rails creates the application with sqlite3 as the default database.

Now if we want to change our database from sqlite3 to PostgreSQL or any other database. Then, we have to manually modify our database.yml to add PostgreSQL related configuration.

default: &default
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>

development:
  <<: *default
  database: sample_development

test:
  <<: *default
  database: sample_test

production:
  <<: *default
  database: sample_production
  username: sample
  password: <%=…
RubyGuides 

7 Major Differences Between Java & Ruby

How do you move from Java to Ruby?

In this guide, you’ll learn what are the major differences between the two languages to help you make the jump.

It’s great for the many people looking to move from Java/C# to Ruby.

But…

If you’re just curious about the differences, then this is also for you.

Let’s do this!

Static Typing vs Dynamic Typing

Typing style is the biggest & most notable difference when looking at code for either programming language.

Here’s the situation:

  • Java uses static typing
  • Ruby uses dynamic typing

What does that mean, exactly?

Typing refers to how variables & method arguments work.

A strongly (or statically) typed language has to declare what types (classes) every…

Rails with Jason 

029 - AWS Deployment with Andreas Wittig

Me and Andreas talk about various AWS deployment options including EC2, Elastic Beanstalk, Heroku (which uses AWS under the hood), ECS, Packer, Fargate, Ansible, Chef, and more!

All Ruby Podcasts by Devchat.tv 

RR 448: How To Avoid Catastrophes with Jon Druse

Jon Druse is a developer from Tennessee and has been using Rails for 15 years. He starts the show by sharing some of the background behind his RailsConf talk “How To Lose 50 Milion Records in 5 Minutes” and the various mistakes that were made that lead to such a dramatic loss. The loss of these records lead the company to refactor and rewrite the entire app in MongoDB. Jon talks about the decision to use Mongo. One of the main points of his talk was that their mistake was discovered because they were trying to figure out wy Elastic Search was getting slow. He counsels listeners to avoid working your way into a poor status quo and accepting it rather than doing something to fix it. If this…

Ruby Conferences 'n' Camps in 2020 - What's Upcoming? 

Ruby by the Bay (Ruby for Good, West Coast Edition) @ Marin Headlands (near San Francisco), California, United States - Ruby Conferences 'n' Camps Update

Conferences 'n' Camps

What's News? What's Upcoming in 2020?

Ruby by the Bay (Ruby for Good, West Coast Edition)
Apr/3-6 (4d) Fri-Mon @ Marin Headlands (near San Francisco), California, United States • (Updates)

See all Conferences 'n' Camps in 2020».

Ruby Conferences 'n' Camps in 2020 - What's Upcoming? 

RubyNess @ Inverness, Scotland, United Kingdom - Ruby Conferences 'n' Camps Update

Conferences 'n' Camps

What's News? What's Upcoming in 2020?

RubyNess
Jul/16+17 (2d) Thu+Fri @ Inverness, Scotland, United Kingdom • (Updates)

See all Conferences 'n' Camps in 2020».

Julia Evans 

New zine: Become a SELECT Star!

On Friday I published a zine about SQL called “Become a SELECT Star!”

You can get it for $12 at https://wizardzines.com/zines/sql. If you buy it, you’ll get a PDF that you can either read on your computer or print out. You can also get a pack of all 7 zines so far.

Here’s the cover and table of contents:

why SQL?

I got excited about writing a zine about SQL because at my old job I wrote a ton of SQL queries (mostly related to machine learning) and by doing that I learned there are a lot of weird things about SQL! For example – SQL queries don’t actually start with SELECT. And the way NULL behaves isn’t really intuitive at first.

It’s been really fun to go back and try to explain…

The Official BigBinary Blog | BigBinary 

Rails 6.1 introduces class_names helper

This blog is part of our Rails 6.1 series.

Rails 6.1 adds class_names view helper method to conditionally add CSS classes. class_names helper accepts String, Hash and Array as arguments and returns string of class names built from arguments.

Before Rails 6.1, conditional classes were added by using conditional statements. Let’s take an example of adding an active class to navigation link based on the current page.

Rails 6.0.0

<li class="<%= current_page?(dashboards_path) ? 'active' : '' %>">
  <%= link_to "Home", dashboards_path %>
</li>

Rails 6.1.0

>> class_names(active: current_page?(dashboards_path))
=> "active"

# Default classes can be added with conditional classes
>> class_names
Test Double | Our Blog 

Conditional Rendering Tactics for React Components

A common situation when writing React components is needing to render a particular component only under certain conditions. There are many ways to accomplish this, but the route you take often has nuanced implications or differing utility based on the current state of the code/component/system.
The Bike Shed 

231: Fun and Useful

On this week's episode, Steph shares more of her Ember adventures, specifically sharing some of her work with the Mirage API mocking and prototyping library, and her search for factories and more ergonomic data in tests.

Chris shares some struggles he's had recently with automation and tooling around deployment and releasing packages, and they discuss the inherent trade-offs that we have to consider when automating anything.

Lastly they touch on Twitter's alt text accessibility features, and answer a listener question about using React without having an API, and instead just using it as a more dynamic view layer.

Code with Jason 

What kinds of Rails tests I write and what kinds I don’t

The challenge of deciding what kinds of tests to write

There are a lot of different kinds of tests a developer could possibly write. In RSpec there are model specs, feature specs, view specs, helper specs, routing specs, controller specs, and request specs. Do you need to write all these different types of tests? If not, which ones should you skip?

The two types of tests I write

In my Rails apps I usually only write two kinds of tests. To use framework-agnostic language, I write model tests and acceptance tests. To use RSpec-specific language, I write model specs and feature specs. Let’s talk about each of these two in a little more detail.

Model tests are relatively isolated. A model test…

GoRails Screencasts 

Tracking online users with timestamps

We can use timestamps in our database to track of online users in your Rails
Remote Ruby 

Mental Health, Rails Upgrades, Jason's New Project, Bootstrap Shift, and More

Saeloun Blog 

Rails 6.1 adds support for multiple storage services to Active Storage

Rails 5.2 added a built-in solution for handling file uploads using Active Storage.

Let’s say, we have an Candidate model that has two attachments resume and cover_letter.

class Candidate < ApplicationRecord
  has_one_attached :resume
  has_one_attached :cover_letter
end

# Attach cover_letter to the candidate.
candidate = Candidate.last
candidate.cover_letter.attach(
  io: File.open("path/to/cover_letter"),
  filename: "cover_letter.txt",
  content_type: "text/plain"
)

Before Rails 6.1, only one cloud storage service (Amazon S3, Google cloud storage, Microsoft Azure storage) could be used for overall application.

But, there could be cases where our application might require to…

Drifting Ruby Screencasts 

Emojis from Scratch

In this episode, we look at attaching emojis to our comments model, allowing them to fill in some emotional cues.
Alfredo Motta 

Not So Random Software #12 – Software Architecture

Welcome back to Not So Random Software. This week’s links are dedicated to Software Architecture. Experts might define it as the art of taking decisions that are hard to change. Being a Software Architect is a role that you can either do full time — mindful of any ivory tower risk — or opportunistically — […]
The Life of a Radar 

ROM + Dry Showcase: Part 1 - Application + Database setup

The rom-rb and dry-rb sets of gems have come out in the last couple of years. These gems allow an alternative take on building a Ruby application, separate from Rails or Sinatra, or anything else like that.

In this series of blog posts, I am going to show you how to build a simple application that I'm calling "Bix" using some of these gems. By the end of this series, the application will:

This part will cover how to start building out an application's architecture. We'll also work on having this…

The Life of a Radar 

ROM + Dry Showcase: Part 2 - Validations & Transactions

This is the 2nd part of a 4 part series.

In this part, we're going to look at how to add data validation to our application. Our application currently has a way of creating users, but there's nothing preventing those users being created without their first_name or last_name set. In this part, we'll add some code to validate that both of these fields are set. We're going to add this code by using a gem called dry-validation.

When we've added this code, it's going to sit apart from the repositories and relations that we've built already, and we will need a way of connecting these pieces. The way that we will connect these pieces is through the dry-monads

When…

Andy Croll 

Calculate a mean average from a Ruby array

Ruby doesn’t provide a native method to generate an average (mean) value from an array of integers. Its built-in Math library focuses on more complex calculations and there’s no built-in #average or #mean method on Array.

This leaves us free to create our own implementation, introducing the opportunity to shoot ourselves in the foot.

Ensure you use…

Array#sum when calculating the mean average from an array of integers:

a = [1, 2, 3, 4, 5, 6, 7, 8]

a.sum(0.0) / a.size
#=> 4.5

Why?

Using the #sum method from Array is many, many times faster than using the alternative, inject.

The #sum method was added to Array in Ruby 2.4, which is why you might see alternative implementations in…

The Bike Shed 

230: The Broken Road

On this week's episode, Chris and Steph revisit the long-lived feature branch Chris has been working on and chat about adventures with Yalc. They also dive into the common questions and concerns associated with coding bootcamps, thoughtbot's exciting new partnership with Resilient Coders, and what it would be like to "start over".

This episode is brought to you by Clubhouse. Click through to get 2 free months on any paid plan.

Sponsored By:

Remote Ruby 

New Jumpstart Features, Postponing Southeast Ruby 2020, and (Possibly) a New Online Ruby Conference

Appfolio Engineering 

How Do I Use Rails Ruby Bench?

How do I do these explorations with Rails Ruby Bench? How could you do them? There’s full source code, but source code is only one piece of the story.

So today, let’s look at that. The most common way I do it is with AWS, so I’m going to describe it that way. Watch this space for a local version in later weeks!

An Experiment

Rails Ruby Bench is a benchmark, which means it’s mostly useful for experiments in the tradition of the scientific method. It exists to answer questions about performance, so it’s important that I have a question in mind. Here’s one: does Ruby’s new compacting GC make a difference in performance currently? I’ve chosen that question partly because it’s subtle - the answer…

Code with Jason 

How to deploy a Ruby on Rails application to AWS Elastic Beanstalk

Overview

This tutorial will show you how to deploy a Rails application to AWS Elastic Beanstalk.

Using Elastic Beanstalk is just one of many (perhaps an infinite number of!) AWS deployment options. Each approach has different pros and cons. I’ll briefly go over some of them because it’s good to understand the pros and cons of various approaches (at least to an extent) before choosing one.

Manual EC2 deployment

One option is to do things “the old fashioned way” and manually set up a Rails application on a single EC2 instance. This is the approach I go over in this AWS/Rails deployment post and it’s perfectly fine for hobby projects where the stakes are low.

The downside to manual EC2…

Awesome Ruby Newsletter 

💎 Issue 193 - Sandi Metz, Author of POODR - Rails with Jason Podcast

Scott Bartell 

Different Ways to Set Attributes in ActiveRecord (Rails 6)

Rails 6 has a rich API that allows you to update your ActiveRecord objects in several different ways. Some methods have slightly different behavior which can sometimes result in unexpected consequences so it’s important to understand their differences.

Note: This article has been updated for Rails 6. Check out similar versions for Rails 3 (external link), Rails 4 (external link) and Rails 5.

Here’s a cheat sheet highlighting the differences between all the methods available for setting attributes in Rails 6:

Cheat Sheet

Method Uses Default Accessor Saves to Database Runs Validations Runs Callbacks Updates updated_at/on Respects…
Ruby Weekly 

Performing concurrent HTTP requests in Ruby and Rails

#486 — January 30, 2020

Read on the Web

Ruby Weekly

Optimization Techniques by the Benchmark Winners — Lessons from the Sequel and Roda gems extracted from Jeremy Evans' Ruby Kaigi talk. “These techniques may not be the best to write at application code level but good when building libraries or to optimize the critical path of your application. The ideas and principles are universally applicable.”

Juanito Fatas

How to Perform Concurrent HTTP Requests in Ruby and Rails — Ah, concurrency and Ruby. Will it ever be safe and easy? We can hope, but in the meantime here’s why it’s unsafe and an easy way to enjoy…

Paweł Urbanek

Monitor Ruby…

Ruby on Rails Podcast 

305: Rails Camp USA with Bobbilee Hartman

Bobbilee Hartman is a Developer Advocate at Square. She is more widely known as the founder of Rails Camp West, the long-standing unplugged retreat for web developers in the United States. She pitches Brittany on attending this year and answers all of her questions about the getaway.

Links for this episode:

rossta.net 

A guide to NPM version constraints for Rubyists

In this post, I want to answer the following question for Rubyists:

What do the tilde ~ and caret ^ designations mean for version constraints in a package.json file?

To answer this question, we'll compare how Rubyists declare Ruby project dependencies in a Gemfile with conventions used to declare NPM module dependencies in a package.json file.

Of note, some projects use both Gemfile and package.json. For example, a newly created Rails 6 application will have generated a package.json file because, by default, it ships with Webpack and related NPM dependencies to compile JavaScript assets.

It might include a section like this:

"dependencies": {
  "@rails/ujs": "^6.0.0",
 …
Fast Ruby Blog 

Why Is It Important to Upgrade Your Rails Application?

Technology evolves quickly. When you first created your Rails application, it's likely you did it using the latest version of Rails. As time passes, however, new Rails versions come out and your application becomes more and more out of touch with the latest version. But why is this important? Why does it matter?

There are several different reasons to upgrade your Rails application. In this article, I’ll list what we consider to be the most important ones.

Security

Security is a big issue. You want your application to be as safe as possible and, to accomplish that, one of the pivotal things to do is to make sure Ruby on Rails is up to date. Ruby on Rails is the application framework…

Prathamesh Sonpatki 

User friendly servers list in New Relic

We use New Relic to monitor performance of our Rails app. We have multiple docker containers running our web app and Sidekiq workers.

On New Relic dashboard, the list of servers is displayed in a dropdown as follows.

As you can see the names of the servers are not very intuitive. It will be better if we know which server runs what part of the application.

New Relic allows setting an environment variable NEW_RELIC_PROCESS_HOST_DISPLAY_NAME for this purpose. We can set this per process or container to distinguish between them in the New Relic dashboard.

We set the environment variable inside the docker container images based on whether that container served web app or ran Sidekiq workers.

The end…

Saeloun Blog 

Rails adds ActiveRecord::Relation#annotate for adding SQL comments to ActiveRecord::Relation queries

Rails has added a new method ActiveRecord::Relation#annotate which allows annotating queries generated by ActiveRecord::Relation instance SQL comments.

For eg:

prefix = "Na"
User.where("name LIKE ?", prefix).annotate("users with name starting with #{prefix}").to_sql

=> "SELECT \"users\".* FROM \"users\" WHERE (name LIKE 'Na') /* users with name starting with Na */"

When using annotate the query is generated with the block-style SQL comment.

ActiveRecord::Relation#annotate

  • We can pass multiple arguments to annotate which adds separate blocks.
User.where("name LIKE ?", prefix).annotate("select names", "users with name starting with #{prefix}").select(:name).to_sql

=> "SELECT…
Greater Than Code 

167: Clarity of Thought with Ted M. Young

01:20 - Ted’s Superpower: Translating things for people to understand better.

02:49 - Coding on a Live Stream

  • Curiosity is Useful and Dangerous
  • Comparing Coding to Puzzles

07:13 - Research is a Drug

  • Finding Answers is Gratifying
  • Current Reading Infects Daily Thought
  • Anders Ericsson

10:45 - Connecting the Academic Idea of Expertise to Everyday Context

  • Worked Examples
  • Memory Limits
  • Gaining a Solid Foundation for Training Purposes
  • The Path of Decision-making

16:50 - Code Reviews

  • Learning About Decisions Made Along the Way
  • Pair Programming and Mob Programming
  • Externalizing Your Thinking
  • Curse of Knowledge

19:41 - Recording Yourself Coding/Learning Something New

  • Gaini…
Ruby Tuesday 

Issue #19

  • Remember Sorbet? It gained a lot of attention last year, but was kind of forgotten quickly. Especially now that built-in type ckecking for Ruby is promised in 3.0, its future is unknown. However, if you’d like to know more about the meat, read an article explaining why Sorbet typechecking is fast. It’s a good technical read.
  • For those who like very technical articles, here’s a piece about Ruby’s JIT and how it can be better/different. It’s called MIR: A lightweight JIT compiler project and contains quite a lot of knowledge about language design and implementation.
  • Another one in language implementation department is about Evaluating Ruby in Ruby by Ilya Bylich.
  • Machine learning and…
Saeloun Blog 

Ruby 2.7 - Singleton class yield syntax throws a warning

Singleton classes are classes which can be instantiated only once.

There are various ways to create a singleton class or methods in Ruby as below:

class Logger
  def self.log(msg)
    @@log ||= File.open("log.txt", "a")
    @@log.puts(msg)
  end
end

Logger.log('message 5')

module Logger
  def self.log(msg)
    @@log ||= File.open("log.txt", "a")
    @@log.puts(msg)
  end
end

Singleton class can also contain yield, which when called with a block will execute the block. As shown below

def foo
  class << Object.new
    yield
  end
end

foo { puts "Hello Ruby!" }
  => "Hello Ruby!"

Before Ruby 2.7 this function gets executed without any warnings or errors.

In Ruby 2.7

In Ruby 2.7 a…

Honeybadger Developer Blog 

A Rubyist's Introduction to Character Encoding, Unicode and UTF-8

It's very likely that you've seen a Ruby exception like UndefinedConversionError or IncompatibleCharacterEncodings. It's less likely that you've understood what the exception means. This article will help. You'll learn how character encodings work and how they're implemented in Ruby. By the end, you'll be able to understand and fix these errors much more easily.

So what is a "character encoding" anyway?

In every programming language, you work with strings. Sometimes you process them as input, sometimes you display them as output. But your computer doesn't understand "strings." It only understands bits: 1s and 0s. The process for transforming strings to bits is called character encoding.

Rémi Mercier 

Working with tempfiles

A while back, I needed to create XML files, send them to a distant server and delete them once the transfer completed.

At first, I thought about creating those files into my app’s tmp directory. Then, a cron job would run daily to delete them. It would have worked, but I wasn’t very happy with it.

So after looking on the internet, I came across the Tempfile object (and I - for the umpteenth time - rejoiced in using Ruby).

Tempfile is a utility class for managing temporary files. It behaves just like a File object, and you can perform all the usual file operations on it: reading data, writing data, changing its permissions, etc. the Ruby documentation

How-to tempfile?

Let’…

Rails with Jason 

028 - Sandi Metz, Author of POODR (with Special Guest TJ Stankus)

Sandi, TJ and I talk about OOP in Rails; Java and COBOL; service objects and Interactors; getting bitten by snapping turtles; and Sandi's 11 bicycles.

Paweł U. | Ruby on Rails Web Development Consultant Full Stack Blog 

How to Perform Concurrent HTTP Requests in Ruby and Rails

Ruby MRI does not support parallel CPU bound operations due to the dependency on non-thread safe C extensions. Input/Output operations like HTTP requests, are still a perfectly valid use case for spinning up multiple threads. Read on to learn what tools are available for requests parallelism in Ruby with all their cons and pros.

Global Interpreter Lock and blocking I/O

Let’s start by describing what’s a blocking I/O. Long story short, any operation that does not directly use the CPU cycles from its thread, but instead delegates the work to external processes is a blocking I/O. Typical examples in the context of Ruby on Rails web apps are SQL database queries, reading/writing to files, or…

The Bike Shed 

230: The Broken Road

On this week's episode, Chris and Steph revisit the long-lived feature branch Chris has been working on and chat about adventures with Yalc. They also dive into the common questions and concerns associated with coding bootcamps, share thoughtbot's exciting new partnership with Resilient Coders, and contemplate what it would be like to "start over".

This episode is brought to you by Clubhouse. Click through to get 2 free months on any paid plan.

RubyMine Blog 

RubyMine 2020.1 EAP is Open!

Hello everyone,

Today we are happy to announce the opening of the Early Access Program (EAP) for RubyMine 2020.1! You can get EAP builds from our website, use the Toolbox App, or update to them using snaps if you’re an Ubuntu user. Note that the EAP builds are free to use but expire within 30 days of the build date.

In the first EAP build, you’ll find new options for working with Docker Compose SDKs, support for running Rake tasks from the gutter area, an improved experience for creating tests, and some other nice features. We’ve also fixed up several annoying little issues related to the debugger and to Docker support. Let’s take a look at the most interesting improvements first.

GoRails Screencasts 

How to use Uppy with ActiveStorage

Learn how to implement Uppy as a frontend for uploading files via drag and drop, paste, URL, Google Drive, Dropbox, webcam and more to Active Storage in Rails
Ruby Conferences 'n' Camps in 2020 - What's Upcoming? 

Ruby Retreat New Zealand (NZ) @ Mt Cheeseman (near Christchurch), New Zealand - Ruby Conferences 'n' Camps Update

Conferences 'n' Camps

What's News? What's Upcoming in 2020?

Ruby Retreat New Zealand (NZ)
Mar/27-30 (4d) Fri-Mon @ Mt Cheeseman (near Christchurch), New Zealand • (Updates)

See all Conferences 'n' Camps in 2020».

Notes to self 

Using Elixir Language Server in Sublime Text 3

Elixir LS can bring us some IDE features to our editor of choice thanks to the Language Server Protocol (LSP). If you are like me, you prefer the speed and simplicity of Sublime Text. Let’s see how to compile Elixir Language Server and how to use it within Sublime Text 3 editor via LSP plugin on Fedora.

Before we dive in, let’s make sure that we have already installed both Sublime Text 3 and Elixir programming language. If you are on Fedora, one easy way to get ST3 running is to use Fedy which you can also use to install other cool software and utilities. For Elixir itself, the official elixir package is all that’s needed for Fedora systems.

Next we need to prepare and compile…

Saeloun Blog 

How to pass arguments to methods in ruby and how it affects their arity

We had mentioned in one of our previous blog that the method definition in Ruby is extremely flexible. Let’s delve a little deeper into that statement and talk about the different type of arguments a method can take and how it affects its arity.

Let’s once again use the example from Marc-André Lafortune blog.

> def hi(needed, needed2,
         maybe1 = "42", maybe2 = maybe1.upcase,
         *args,
         named1: 'hello', named2: a_method(named1, needed2),
         **options,
         &block)
  end

> method(:hi).parameters
=> [ [:req, :needed], [:req, :needed2],
     [:opt, :maybe1], [:opt, :maybe2],
     [:rest, :args],
     [:key, :named1], [:key, :named2],
     [:keyrest, :options],
…
Alfredo Motta 

Not So Random Software #11 – The one about Hiring

Welcome back to Not So Random Software. This week’s links are dedicated to Hiring; how to navigate skills shortage landscape, reflections on what you actually need, and tools that might be helpful to get it done. A random article or paper The First Round blog publishes wisdom from the top tech companies in Silicon Valley. […]
Boring Rails: Skip the bullshit and ship fast 

Wrangling slow reports, large file exports, and long-running tasks in Rails with Active Job

In case you don’t like reading (Feb 2020 - Indy.rb Meetup)

In every non-trivial application you’ll have to do something that is just slow. You need to export a large data set to a CSV file. An analyst needs a complicated Excel report. Or maybe you have to connect to an external API and process a whole bunch of data.

So how do you know when it’s time to use background jobs?

If you try building these kinds of reports in a normal Rails controller action, you will see these symptoms:

  • Request timeouts: once response times start creeping past 10+ seconds, you run the risk of timeouts. You might have a report that is slow but just barely finishes, but you know that it scale linearly with…
Kir Shatrov 

Creating productive teams

While I’ve mostly been writing about the tech, lately, my primary interest has been engineering management. This note is an observation of what I’ve seen as a successful pattern being part of at least 2 new teams spawned at work.


The time comes to spawn a new team, either from a group of people that are already working together or from a mix from different groups who don’t know each other really well. This may happen for various reasons, for example, desire to give autonomy to a couple people on the team who’re already working on a pretty isolated thing, or some reorg at the company.

Forming a team may often feel uncomfortable for its members. Maybe they haven’t worked together, and…

Awesome Ruby Newsletter 

💎 Issue 192 - Yukihiro Matsumoto: "Ruby is designed for humans, not machines"

Valentino Gagliardi - RSS Feed 

Understanding the Firefox Dev Tools Architecture, and How to Start Contributing

This year I decided to contribute more to open source projects and since I've made the resolution to switch to Firefox from Chrome I've also got the chance to find an interesting bug to work on.

In this post I want to share my learnings in the hope that more people could start contributing to Firefox.

Contributing to Firefox: a bit of backstory

In Firefox Dev Tools I wanted a "Store as global variable" option in the Scopes panel. The Scopes panel appears in the debugger tab when you stop the script with a breakpoint, much like Chrome Dev Tools.

As of now the only thing that you can do on an object in the panel is adding a watchpoint, that is, a watcher which fires on properties get and set.…

Valentino Gagliardi - RSS Feed 

Understanding the Firefox Dev Tools Architecture, and How to Start Contributing to Firefox

This year I decided to contribute more to open source projects and since I’ve made the resolution to switch to Firefox from Chrome I’ve also got the chance to find an interesting bug to work on.

In this post I want to share my learnings in the hope that more people could start contributing to Firefox.

Enjoy!

Contributing to Firefox: a bit of backstory

In Firefox Dev Tools I wanted a “Store as global variable” option in the Scopes panel. The Scopes panel appears in the debugger tab when you stop the script with a breakpoint, much like Chrome Dev Tools.

As of now the only thing that you can do on an object in the panel is adding a watchpoint, that is, a watcher which fires…

Ruby Weekly 

Matz: 'Ruby is designed for humans, not machines'

#485 — January 23, 2020

Read on the Web

Ruby Weekly

Yukihiro Matsumoto (Matz) Interview from RubyRussia — An enjoyable chat where the “nice” of Matz really shines through. He covers topics like language design successes and failures and how type checking is coming to Ruby. There's a 20 minute video version available too.

Evrone

Modern Ruby Serializers — A look at the history of various serializers, leading to the introduction of SimpleAMS, a new serialization library by the author and how it compares to other options.

Filippos Vasilakis

The Easiest Way to Run Redis — Better monitoring,…

code.dblock.org | tech blog 

Restoring Data into a MongoDB Dokku Container

I’ve been running a pet project using Dokku on DigitalOcean for a number of years with MongoDB, backing up data into Dropbox. See Running Slack Bots on DigitalOcean with Dokku and Backing up MongoDB Databases in Dokku Containers to Dropbox.

Today I had to selectively export data from a backup, and restore this data into a MongoDB running inside a Dokku container. This was a bit tedious.

Exporting a Subset of Data

I am dealing with slack-gamebot data, which contains a teams collection with a row per team and related data in other collections, including users and matches. I wrote a bash script to export this data.

Construct a query string, eg. {"team_id":"ID"} and fetch the _id value for…

Ruby on Rails Podcast 

304: Legacy Code Wisdom with Alexey Chernov

Alexey Chernov is a Ruby on Rails consultant at JetThoughts. Over the years, he has built MVPs and consulted to improve legacy code, scale up the remote team and achieve an effective development process. He and Brittany dive deep into approaching legacy RoR projects.

Links for this episode:

Greater Than Code 

166: From Software Engineer to Management with Phil Wheeler

01:10 - Phil’s Superpower: Putting Himself in Others’ Shoes.

02:03/09:14 From Software Engineer to Management

  • Empathy Through The Career Shift
  • The Learning Curve
  • Making a Conscious Choice To Switch
  • Gaining Leadership Skills
  • Making Your Own Opportunities

03:34 - How Phil Came Into The Greater Than Code Community

05:54 - Commonalities Between Issues Between USA and NZ

  • Inclusion, Equality in Technology

07:05 - Life Science Software Experience

  • Cloud Based, LT
  • Awareness of Accessibility

16:45 - To Get Into Management or Not

18:55 - The Parallels Of Management And Parenting

26:17 - Working From…

Scott Bartell 

Automating Rails Database Migrations on Heroku

One problem that teams tend to run into with Rails apps on Heroku is forgetting to run database migrations before the code that depends on them is released.

Luckily, there is a way to automate the running of database migrations on Heroku and to guarantee that they are always run before the dependent code is released: the Heroku Release Phase.

Heroku Release Phase

The Heroku Release Phase allows you run certain tasks after your app is built but before the app is released.

Heroku Release Phase Diagram

Specifying release phase tasks

To specify the tasks to run during release phase, define a release process type in your app’s Procfile.

In our case we want to run database migrations directly in our release task so we…

Saeloun Blog 

Ruby 2.7 allows placing of comment lines between fluent dots

With Ruby 2.7, comment lines can now be placed between fluent dots.

Before Ruby 2.7

Class
  # .methods or comment
  .inspect
=> syntax error, unexpected '.', expecting end-of-input

After Ruby 2.7

Class
  # .methods or comment
  .inspect
=> "Class"

This feature comes in handy especially when debugging some set of changes or when we need to explain the purpose behind a particular chained method separately.

For instance, following is allowed,

Post
  # Complex scope call which needs separate comment to explain
  .only_published_with_info(filter)
  # .with_single_author # Commented for debugging
  .with_generic_notes

Note that placing one or more blank lines between the chained…

Saeloun Blog 

Rails 6.1 adds query method missing to find orphan records

Rails 6.1 adds a query method missing to search for orphan records within ActiveRecord.

We often find ourselves querying an ActiveRecord model for orphan objects for reasons like cleanup or bulk updates.

Example

Let us consider the following models.

# app/models/manager.rb
class Manager < ApplicationRecord
  has_many :job_listings
end
# app/models/job_listing.rb
class JobListing < ApplicationRecord
  has_many :job_applications
  belongs_to :manager
end
# app/models/job_application.rb
class JobApplication < ApplicationRecord
  belongs_to :job_listing
end

Before Rails 6.1

Now let us try to find all the job listings which do not have a manager assigned.

[1] pry(main)> JobListing.lef…
Martian Chronicles, Evil Martians’ team blog 

What I learned as a developer from accidents in space

Author: Andrey Sitnik, Author of PostCSS and Autoprefixer, Lead Front-end Developer at Evil Martians

Join Andrey Sitnik, the author of PostCSS and Autoprefixer, for a round of tales from the Soviet Space Age and learn the lessons he took from them to become a better developer and open-source maintainer. A failed docking attempt, a dramatic reentry, and a first genuine fender-bender in orbit—what does it all have to do with modern web development? Stay tuned to find out!

I’ve been passionate about space exploration for as long as I can remember: people who know me in person heard more space stories than they signed up for.

Before joining Evil Martians, I used to be an administrator…

Rails with Jason 

027 - Ben Orenstein's Entrepreneurial Journey

In this episode I talk with Ben Orenstein about his entrepreneurial journey.

Fast Ruby Blog 

The Complete Guide to Migrate to Strong Parameters

Migrating from Protected Attributes to Strong Parameters in a Rails project can be a huge step of the upgrade process. Especially when we are upgrading a large application. This guide is meant to help you tackle that step faster and with a lot less pain.

Protected Attributes & Strong Parameters

To give you a bit of context, let's recap what Protected Attributes and Strong Parameters actually are. They are two different Rails implementations for protecting attributes from end-user injection (a.k.a. Mass Assignment)

To understand what the benefits are of Strong Parameters over Protected Attributes, I recommend checking this RailsCasts episode.

Protected Attributes was part of the Rails…

All Ruby Podcasts by Devchat.tv 

MRS 102: Elia Schito

My Ruby Story this week welcomes Elia Schito, a senior developer for Nebulab. Elia has been working with Ruby for the past 12 years. Charles starts off by asking how Elia became a developer.

Host: Charles Max Wood

Joined By Special Guest: Elia Schito

Sponsors

______________________________________

"The MaxCoders Guide to Finding Your Dream Developer Job" by Charles Max Wood is now available on Amazon. Get Your Copy Today!

______________________________________

 

Links

Picks

Charles Max…

All Ruby Podcasts by Devchat.tv 

RR 447: All About Kafka and Oracle with Bob Quillin and Karthik Gaekwad

Bob Quillin and Karthik Gaekwad are on the Oracle developer relations team. Karthik has been on Ruby Rogues previously, and he explains how he went from the Kubernetes team to developer relations. They begin the show by explaining what Kafka is, the leading open-source event streaming platform that Oracle is compatible with. It allows cloud developers to build, publish, and subscribe models for streams of records in addition to many other functions. Systems that used to take a long time to make have become very small and simple with Kafka. Kafka stands out from other message queueing systems because of its robust nature and scalability. 

Bob goes into more depth about the evolution of…

The Bike Shed 

229: Nothing but Positive Fire

On this week's episode, Steph and Chris catch up in their first recording of 2020. They discuss git workflows and the surprisingly strong opinions often associated with them, testing at all levels of your application, Steph gives a quick summary of her Ember adventures, and they round out the discussion with some new years systems building and Star Wars reviews.

This episode is brought to you by Clubhouse. Click through to get 2 free months on any paid plan.

Sponsored By:

The Bike Shed 

229: Nothing but Positive Fire

On this week's episode, Steph and Chris catch up in their first recording of 2020. They discuss git workflows and the surprisingly strong opinions often associated with them, testing at all levels of your application, Steph gives a quick summary of her Ember adventures, and they round out the discussion with some new years systems building and Star Wars reviews.

This episode is brought to you by Clubhouse. Click through to get 2 free months on any paid plan.