Rubyland

news, opinion, tutorials, about ruby, aggregated
Sources About
Scott Watermasysk 

🔥QMK ⌨️

I have no clue what it takes to implement QMK on a keyboard. However, after using it on two different keyboards, I find it hard to fathom buying a keyboard that does not have any support for it.

See: QMK.

The good news is there is a huge list of keyboards that can be flashed to use QMK.

Code with Jason 

How to install nginx and Passenger on an EC2 instance for Rails hosting

Note: I must give credit to Passenger docs, from which some of this is directly lifted.

sudo apt-get update
sudo apt-get install nginx
sudo service nginx restart

I recommend executing each of the following groups of commands separately, one at a time. That way it’s easier to tell whether each group of commands was successful or not.

sudo apt-get install -y dirmngr gnupg
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates

sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger bionic main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update

sudo apt-get install -y…
Code with Jason 

How to deploy a Ruby on Rails application to AWS

Overview

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

There are a number of ways this task could be tackled. It can be done manually or it can be done using an infrastructure-as-code approach, with a tool like Ansible.

This tutorial shows how to deploy Rails to AWS manually.

Before you dive in, be forewarned: it’s an absolute fucking monster of a task. There are a large number of steps involved, many of them tricky and error-prone. Be prepared for the full process to involve hours or even days of potentially frustrating work.

Contents

This post is a work in progress. The items below will turn into links one-by-one as I finish each section. The size of the setup…

Code with Jason 

How to launch an EC2 instance for hosting a Rails application

This post is the first in my series on how to deploy a Ruby on Rails application to AWS (currently a work in progress).

This post will walk you through launching an EC2 instance using the AWS console GUI. By the end of this post you’ll have an Ubuntu EC2 instance up and running.

1. Choose the instance type

Log into your AWS console and go to the EC2 section under the Services menu.

On the left-hand menu, click Instances.

On the subsequent page, click Launch Instance.

You’ll be shown a list of possible instance types. Select Ubuntu Server (ami-0d5d9d301c853a04a).

On the next screen click Review and Launch without changing anything.

Click Launch on the screen that follows.

2. Create and…

Honeybadger Developer Blog 

FounderQuest S2 E8 | The 2019 Thanksgiving Freestyle Episode

This week on FounderQuest things get wild and the guys throw the show notes out the window. They are kicking it freestyle on this special Thanksgiving episode. All of today’s hard-hitting questions are answered: 

  • Dark meat or light meat? 
  • Turkey or duck? 
  • Roaring fire in the background on New Year’s Eve or the progress meter of a database upgrade?
  • Feature freezes before Thanksgiving or after?
  • Why is Northgate Mall being torn down?
  • Should you bother putting decorative lights outside your home if they aren't visible from inside?

You will also learn the guys' December plans and a teaser on what secret plans are being worked on for Honeybadger.

Time travel with Josh, Starr, and Ben on…

Remote Ruby 

Introducing Andrew Mason, CI Tooling, Ruby 2.7 Features, Rails 6.1 on the Radar

Appfolio Engineering 

JIT and Ruby's MJIT

Arthur Rackham explains Ruby debugging

Arthur Rackham explains Ruby debugging

If you already know lots about JIT in general and Ruby’s MJIT in particular… you may not learn much new in this post. But in case you wonder “what is JIT?” or “what is MJIT?” or “what’s different about Ruby’s JIT?” or perhaps “why in the world did they decide to do THAT?”…

Well then, perhaps I can help explain!

Assisting me in this matter will be Arthur Rackham, famed early-twentieth-century children’s illustrator whose works are now in the public domain. This whole post is adapted from slides to a talk I gave at Southeast Ruby in 2018.

I…

Awesome Ruby Newsletter 

💎 Issue 185 - Rubyconf 2019 — Main takeaways from the keynote — Ruby 3.0 and the road ahead

Julia Evans 

Challenge: find Twitter memes with suffix arrays

This challenge is a mix of data analysis and using fun algorithms! It’s the second challenge in a a short series of programming challenge I’m writing with Julian. (the first one was to write a tiny fun window manager)

Twitter has a lot of memes. For example, if you search Twitter for Flight attendant: is there a doctor on this flight?, you’ll find a bunch of tweets making jokes like this:

Flight Attendant: is there a doctor on board?
Parent: *nudging* That should've been you
Me: Not now, this is serious
Parent: Not asking for a hacker to help, are they?
Me: AAAAAAAA\x00\xd0X?\xfc\x7fBBBBj\x0bX\x99Rfh-p\x89\xe1Rjhh/bash/bin\x89\xe3RQS\x89\xe1\xcd\x80
Parent:~#

or if you search as a…

Ruby Weekly 

Some more of what's new in Ruby 2.7

#479 — December 5, 2019

Read on the Web

Ruby Weekly

Ruby 2.7 Adds Shorthand Syntax for Argument Forwarding — In short, you can use the syntax ... in parameter or argument lists to basically ‘pass through’ (or forward) arguments from one method to another. “It acts similar to calling super without any arguments.”

Narendra Rajput

What’s New in Ruby 2.7? — There’s a lot coming in 2.7 (due on Christmas Day), including controversial features like pattern matching, numbered parameters, and keyword argument changes. Also, this will be the last point release before 3.0 a year from now.

Guy Maliar

Powe…

Blog 

Ruby on Rails FAQ—What You Need to Know to Choose Right

To build a Web application that effortlessly serves your target audience, you have to make sure your chosen technology stack has the necessary capabilities.

Semaphore 

Semaphore 2.0 Welcomes Open Source Developers with Free Continuous Integration

We’re happy to announce free continuous integration pipelines for open source organizations on Semaphore 2.0. Each open source organization receives unlimited CI/CD minutes for building public repositories. The plan includes four e1-standard-2 Linux machines and one a1-standard-4 macOS machine for running up to four parallel jobs on Linux or Docker, and one on macOS.

The release includes the following features specifically made for open source developers:

  • Whitelisting of trusted contributors who are allowed to trigger CI via cross-repository pull requests.
  • Control over which, if any, secrets are to be exported.
  • Public access to workflows and job logs.
  • Build badges.

Why choose…

Saeloun Blog 

Ruby 2.7 adds shorthand syntax for arguments forwarding

Ruby 2.7 added a new shorthand syntax ... for forwarding arguments to a method.

Need for a new operator

Currently we do have * and ** operators for single and keyword arguments. These are used to specify any number of arguments or convert array or hashes to several arguments.

The ... operator

The idea of ... operator is to capture all and forward arguments irrespective of type. So we can forward single, keyword arguments or blocks.

Its a shorthand syntax to forward everything. It acts similar to calling super without any arguments.

Lets take a look at it with an example. Consider we define a method that accepts some regular, keyword and block arguments.

def bar(*args, **kws,…
rossta.net 

Overpacking: A Common Webpacker Mistake

I recently encountered a Rails app at work that was spending nearly seven minutes precompiling assets:

CI Screenshot: Precompile assets, 6:56

I looked in the Gemfile and found the project was using Webpacker. My spidey sense started to tingle.

I've seen this before.

Leaning on prior experience, I found the problem, moved some files around, and pushed a branch with the fix up to CI.

CI Screenshot: Precompile assets, 0:44

The build step dropped from nearly seven minutes to less than one. Big improvement! When I heard from the team, the fix also greatly improved the local development experience; before, re-compiling Webpack assets on page refreshes would take a painfully long time.

So what were the changes?

A…

Julia Evans 

Solutions to the tiny window manager challenge

Hello! Last week I posted a small programming challenge to write a tiny window manager that bounces windows around the screen.

I’ll write a bit about my experience of solving the challenge, or you can just skip to the end to see the solutions.

what’s a window manager?

An X window manager is a program that sends messages to the X server (which is in charge of drawing your windows) to tell it which windows to display and where.

I found out that you can trace those events with xtrace. Here’s some example output from xtrace (for the toy window manager which is just moving windows about)

000:<:02d8: 20: Request(12): ConfigureWindow window=0x004158e5 values={x=560 y=8}
000:<:02da: 20:…
Remote Ruby 

Building Chat Applications, GitHub Actions, HatchBox Features, and Mistakes

In this pre-Thanksgiving episode released post-Thanksgiving, we talk about what it was like working with ActionCable and React on Podia's latest feature, messaging. We also talk through GitHub actions, some of the features of HatchBox (including using DigitalOcean Spaces as a drop-in S3 replacement), and a plethora of mistakes I (Jason) have made over the last two weeks. Best yet, we cram it into forty minutes.
Ruby Conferences 'n' Camps in 2020 - What's Upcoming? 

Rubyfuza @ Cape Town, South Africa - Ruby Conferences 'n' Camps Update

Conferences 'n' Camps

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

Rubyfuza
Feb/6-8 (3d) Thu-Sat @ Cape Town, South Africa • (Updates)

See all Conferences 'n' Camps in 2020».

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

ParisRB Conf @ Paris, France - Ruby Conferences 'n' Camps Update

Conferences 'n' Camps

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

ParisRB Conf
Feb/18+19 (2d) Tue+Wed @ Paris, France • (Updates)

See all Conferences 'n' Camps in 2020».

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

RubyConf Australia @ Melbourne, Victoria, Australia - Ruby Conferences 'n' Camps Update

Conferences 'n' Camps

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

RubyConf Australia
Feb/20+21 (2d) Thu+Fri @ Melbourne, Victoria, Australia • (Updates)

See all Conferences 'n' Camps in 2020».

The Official BigBinary Blog | BigBinary 

Rails 6.1 adds *_previously_was attribute methods

This blog is part of our Rails 6.1 series.

Rails 6.1 adds *_previously_was attribute methods for dirty tracking the previous attribute value after the model is saved or reset. *_previously_was returns the previous attribute value that was changed before the model was saved

Before Rails 6.1, to retrieve the previous attribute value, we used *_previous_change or previous_changes.

Here is how it can be used.

Rails 6.0.0

>> user = User.new
=> #<User id: nil, name: nil, email: nil, created_at: nil, updated_at: nil>

>> user.name = "Sam"

# *_was returns the original value. In this example, the name was initially nil.
>> user.name_was
=> nil
>> user.save!

# After save, the original value is…

Rails 6.1.0

>> user = User.find_by(name: "Sam")
=> #<User id: 1, name: "Sam", email:…
Saeloun Blog 

Rails 6 adds ActiveSupport::ParameterFilter

There are cases when we do not want sensitive data like passwords, card details etc in log files. Rails provides filter_parameters to achive this.

For example, if we have to filter secret_code of user then we need to set filter_parameters in the application.rb as below:

config.filter_parameters += ["secret_code"]

After sending request to server, our request parameters will look like these:

Parameters: {"authenticity_token"=>"ZKeyrytDDqYbjgHm+ZZicqVrKU/KetThIkmHsFQ/91mQ/eGmIJkELhypgVvAbAg1OR+fN5TA8qk0PrOzDOtAKA==", "user"=>{"first_name"=>"First Name", "last_name"=>"Last Name", "email"=>"abc@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "secret_code"=>"[FIL…

Now if we do User.last then:

> User.last
#=> #<User id: 2, first_name: "First Name", last_name: "Last Name", email: "abc@gmail.com", password_digest: "$2a$12$m6bZtRRBSDCzowE9p/z6ceffMyMYQQ7jSxsTlX8/Oba...", secret_code: "12345", created_at: "2019-11-29…
All Ruby Podcasts by Devchat.tv 

RR 440: Swagger and OpenAPI with Josh Ponelat

Today the panel discusses the difference between Swagger and Open API with Josh Ponelat. Josh details the difference between the two. Swagger is a set of protocols around describing restful APIs. Swagger was taken over by a company called SmartBear, who donated the donated the specification to the Open Linux Foundation, and that became the Open API. Swagger is the tooling surrounding these specifications. Open API is a standardized way to describe a restful API in a YAML file. Once you’ve got a YAML file to describe your API, you can use tooling like Swagger to leverage that and take it to the next level. Using the Open API process is useful for situations where you already have an API in…

The Bike Shed 

224: The One Manhattan Rule

On this week's episode, Chris catches us up on his latest keyboard adventures and Steph shares her first impression of working with Ember.

They also dive into Chris's experience triaging errors Sentry, their love for Elm, how teams achieve a consistent velocity, and Steph's upcoming workshop on how to stay agile when building a healthcare product. To bring it home, they respond to a listener who's wondering when is it a good idea to convert a loose data structure (e.g.: hash) into a class?

If you're enjoying The Bike Shed, we'd love it if you could give it a rating or review on iTunes. Thanks!

Test Double | Our Blog 

From NoOps to AllOps

I have really enjoyed Micah’s recent posts, Embracing NoOps and Are you really ready for serverless?. We share a firm belief that all code is a liability, and that includes “infrastructure as code” code.
Honeybadger Developer Blog 

FounderQuest S2 E7 | Is Offering A Free Plan Worth The Hassle?

This week on FounderQuest, Josh is back and shares his hot takes from RubyConf in Nashville. Be wary of the ghost pepper oil!

There’s no such thing as a free lunch, however, there is such a thing as a free Honeybadger plan. The guys talk about their decision to offer a free plan alongside Honeybadger's paid plans and how it impacted the overall business. The guys also break down some of the costs involved with the plan such as cannibalization of paid accounts and customer support time.

Listeners will also learn about Ben’s Eye of Sauron approach to fiscal management and an acquisition strategy based around companies named after honey badgers.

You know something else that's free?…

Honeybadger Developer Blog 

GitHub Student Developer Pack Holiday Challenge

Hey GitHub Student Developer Packers!

For the month of December, we are issuing a challenge to help you grow as a developer so you can crush bugs and deploy web apps with confidence using your free Honeybadger account.

If leveling-up your developer skills isn't enough incentive to join the challenge, you will also be entered into a drawing for a $100 Netflix gift card (or other music/video streaming service of your choice).

How to enter:

  1. Create a publicly-deployed web app with Honeybadger enabled.
  2. Upload it to GitHub.
  3. Tweet @honeybadgerapp with a link to your project's repo and the public URL using the #GitHubPack tag or email support@honeybadger.io with GitHubPack in the subject line…

Fine print:

The contest winner will be chosen at random and we will…

Hi, we're Arkency 

Ruby - raise Exception.new or raise Exception - they're both the same

TLDR: You can use raise Exception and raise Exception.new - they’re identical as a result and it’s 4 characters less.

In my previous post (OOP Refactoring: from a god class to smaller objects | Arkency Blog I’ve used some code with raising exceptions:

  def add_task(task)
    raise Duplicate if @tasks.include?(task)
    @tasks << task
  end

or

  def assign_task(task, developer)
    raise AlreadyAssigned if task.assigned?
    task.assign_developer
  end

The way I’m raising the exception here is that I raise it without calling .new. This may look as if I’m raising a class, not an object.

Some people asked me if this actually works and if it’s the same.

We already know the short answer,…

OmbuLabs Blog 

Blogcop: A GitHub app that helps you manage your Jekyll blog

At OmbuLabs we use Jekyll to generate our blog. If you are not familiar with it, here is a quick description from the Jekyll site:

"Jekyll is a simple, extendable, static site generator. You give it text written in your favorite markup language and it churns through layouts to create a static website. Throughout that process you can tweak how you want the site URLs to look, what data gets displayed in the layout, and more."

Problem

Jekyll has been working great for us over the years, but one thing that was missing was a way to manage outdated articles. Basically, we wanted the ability to unpublish articles that have not been updated for a few months, so we can review and update them.

Riding Rails 

Rails 6.0.2.rc1, 5.2.4, and something different…

Hey readers! This is Kasper bringing you the latest news in Rails. I’m writing from deep winter-like Copenhagen, starting on the last month of the decade.

Speaking of progress, Rails recently crossed 75.000 commits on GitHub. Last time we marked commit progress was over 4 years ago for 50.000. I happened to write that issue too, you can read it here.

Rails 6.0.2.rc1 released

As always, this release is loaded with fixes and improvements. It’s currently set to ship Monday Dec 2 and so far no regressions have been found as far as I know. Final day to test the release candidate on your app, try it out ✌️

Rails 5.2.4 released

The final bug fix release of Rails 5.2, now it’ll only get…

Ruby Inside - Medium 

What’s new in Ruby 2.7?

With Rubyconf 2019 behind us and Ruby 2.7 releasing this December, it’s the perfect time to go through what are the new features in the newest 2.x Ruby version and also the last release before 3.0.

What defines this version of Ruby is a mix of quality-of-life improvements such as Symbol#start_with? and Enumerable#filter_map, big yet often controversial features such as pattern matching and numbered arguments and bug fixes.

What also makes this version special is that it is the last one before Ruby 3.0 that is due will be released in Dec 2020 and has been presented by Matz in this year’s Rubyconf keynotes (https://www.youtube.com/watch?v=2g9R7PUCEXo&list=PLE7tQUdRKcyZDE8nFrKaqkpd-XK4huygU&inde…

Saeloun Blog 

Dir#glob and Dir#[] no longer allow NUL-separated glob pattern in Ruby 2.7

Dir#glob and Dir#[] return an array of matching filenames depending upon the parameter.

Example

2.6.5 :001 > Dir.glob("foo.txt")
 => ["foo.txt"]
2.6.5 :002 > Dir.glob(["foo.txt", "test.rb"])
 => ["foo.txt", "test.rb"]

Before

With Dir#glob and Dir#[], there is a possibility of unintended file operations because they do not check NULL characters.

2.6.5 :001 > Dir.glob("foo.*\0bar.*")
(irb):1: warning: use glob patterns list instead of nul-separated patterns
 => ["foo.txt", "bar.txt"]
2.6.5 :002 > 
2.6.5 :003 > Dir["index.html\0show.html"]
(irb):2: warning: use glob patterns list instead of nul-separated patterns
 => ["index.html", "show.html"]

In the first example above, the…

Drifting Ruby Screencasts 

From jQuery to ES6

jQuery has been a great tool for many years, but we've seen a transition in the past years where applications have dropped jQuery and moved to vanilla javascript. In this episode, we look at some common jQuery examples and the ES6 equivalencies.
Andy Croll 

Ensure you correctly build your caching keys

Caching is a hugely powerful tool in maintaining the performance of often requested pages and partials in your application.

It can also cause confusing behaviour (mostly “stuff not updating on the page”) when you test your app in a production environment.

Rails has great built-in support for many types of caching, in particular its “view fragment caching”. This stores the resulting text of parts of your views in very fast storage, say Redis or Memcache, saving your application building the views every time a page is rendered.

The framework includes an elegant way of using the cache based on using a model’s id, its updated_at timestamp, and an automatically-generated digest of the…

Alfredo Motta 

Not So Random Software - Week #3

Here is the third week of Not So Random Software. Met multiple people being close to burnout lately, so this week my mind is exploring how we can do good work while keeping our mind and body healthy. A random tool I have been using Insight Timer for a long time now for meditation. I […]
Hi, we're Arkency 

OOP Refactoring: from a god class to smaller objects

In the early years of my programming career, I got infected by the OOP thinking. It made (and still does) sense to model the problem in terms of objects and methods operating on that object.

However, at the beginning, my OOP code resulted in a god class - a class that knows almost everything.

Let’s say I work on a Project Management app. Usually my User class and Project class would be big, like this:

class Project

  def initialize
    @tasks = []
    @members = []
    @budget = Budget.new
  end

  def add_task(task)
    raise Duplicate if @tasks.include?(task)
    @tasks << task
  end

  def tasks
    @tasks
  end

  def assign(developer)
    @members << developer
  end

  def assign_…
Karol Galanciak - Distributed Systems Architect and Ruby on Rails expert 

From ActiveRecord callbacks to Publish/Subscribe pattern and event-driven design

Imagine that you are working on a large legacy application that also contains the dreaded ActiveRecord callbacks in the models handling most of the business logic. At some point, and under a certain level complexity, the mess caused by that choice might become hard to keep under control, the risk of introducing bugs will increase and the teams(s) working on the application will be way less productive. That will most likely lead to an attempt to find a better way of designing the application. The problem, though, might be that the scope of the application is so huge that introducing any meaningful changes to the application will take weeks, if not months.

Does it mean the application is…

Awesome Ruby Newsletter 

💎 Issue 184 - Refactoring Ruby with Monads

RubyMine Blog 

RubyMine 2019.3 Released: RuboCop Severities Mapping, Better Run Anything, and More

RubyMine 2019.3

RubyMine 2019.3 is here! In this release, we’ve been working with your feedback to improve the performance and quality of RubyMine, although we have also managed to get some new features in there as well. Visit the What’s New page for a detailed overview of the new v2019.3. Here are some of the biggest highlights:

RuboCop

  • Configure mapping for RuboCop and IDE inspection severities
    RuboCop severities

Rails

  • Run Rails generators and Rake tasks with Run Anything
    Run Anything

Code Style

  • Align method chains by the initial receiver or leading dots
    Align method chains

Copyright

  • Add copyright notices for Ruby files
    Copyright

HTTP Client

  • Use dynamic variables in .http files
    Dynamic variables
  • Run all the requests in a file
    Run all requests

Check out the What’s New…

Ruby Weekly 

Ruby 2.7.0 Preview 3 Released

#478 — November 28, 2019

Read on the Web

Ruby Weekly

Ruby 2.7.0 Preview 3 Released — We’re now less than a month from the final release of Ruby 2.7 (which, fingers crossed, should be on Christmas Day, as is the tradition). If you want to get playing with pattern matching, the improved irb, and other new features though, the current preview release is pretty stable.

Yui Naruse

The .: Syntax For Referencing Methods Is Cancelled — One new feature that was expected to appear in Ruby 2.7 (and which was only just dropped in preview 3) was .: as a short hand for referencing methods. This thread covers the reasons…

The Life of a Radar 

They fixed the keyboard

Consider this post a sequel to my The 2018 MacBook Pro Keyboard Drives Me Crazy (Aug '19) post from earlier in the year.

In that post, I listed the following complaints about the 2018 MacBook Pro keyboard:

  • duplicated "o's" that I've had to go back and fix, or missing ones -- guess how fun it is to write a book about a Toy Robot with this particular problem
  • double spaces -- or no spaces
  • a Command key that registers 9 out of every 10 times
  • words like "times" that inexplicably get spelled like "timies", or "about" that gets spelled like "abouot"

I've now been using a brand-new 2019 MacBook Pro for about 5 hours and I've been using the keyboard extensively during the setup of this machine.

Giant Robots Smashing Into Other Giant Robots 

Faking External Services in Tests with Adapters

When faking external services in tests, I like to start with a simple solution and only progress to a more complex one if I need it. That’s why I usually start with a simple class that acts as the public interface to adapters and make an in-memory adapter for tests. Let’s see a concrete example.

Faking an SMS client

Suppose we need to use Twilio’s SMS service. We don’t want to make a request to Twilio’s api every time we send a message in a test, and in some tests, we’d like to assert that the correct messages are being “sent”.

Let’s first create an SmsClient class that will be the interface for the rest of our code to send messages.

class SmsClient
  cattr_accessor :adapter
Saeloun Blog 

Rails 6 bulk insert records

There are cases when we want to insert records in bulk. For eg., we have a list of users in CSV and we want to import these users in our application.

Rails has methods like delete_all or update_all to delete and update bulk records respectively. Similar method to insert bulk records was missing.

Rails 6 added insert_all, insert_all! and upsert_all to ActiveRecord::Persistence, to solve the above issue.

Before Rails 6

Before Rails 6, bulk insert was achieved -

users = []
10.times do |i|
  users << User.new(name: "user #{i}")
end
User.import users
  • Creating records one by one
10.times do |i|
  User.create!(name: "user #{i}")
end
  • Using the SQL…
Saeloun Blog 

Ruby 2.7 adds Enumerator#produce

Ruby 2.7 has added Enumerator#produce to generate Enumerator from any custom data-transformation.

Before

Let’s say we want to print the first 10 numbers of fibonacci series.

The code to achieve this would look like:

result = Enumerator.new do |yielder|
  base_1 = 0
  base_2 = 1
  loop do
    yielder.yield base_1
    base_1, base_2 = base_2, base_1 + base_2
  end
end

result.take(10)
=> [0, 1, 1, 2, 3, 5, 8, 13, 21, 34]

As shown above, we need to use loop and yield in order to achieve the required results.

Enumerator#produce

We can now use Enumerator#produce in Ruby 2.7 to achieve this in a simpler way:

Enumerator.produce([0, 1]) { |base_1, base_2| [base_2, base_1 + base_2] }.take

Enumerator.p…

Valentino Gagliardi 

How to create PDF files with Python and Weasyprint

In this tutorial you’ll learn how to create beautiful PDF files with Python and Weasyprint, a Python library for converting HTML to PDF.

How to create PDF files with Python and Weasyprint

Requirements

To follow along with the tutorial you’ll need:

  • Python 3.x installed on your computer
  • A code editor (VsCode or Pycharm CE)
  • a basic understanding of HTML, CSS, and Python

What we will build?

In this guide we’ll create a multi-page PDF file with Python. The PDF will be an exam with questions and answers.

I actually use this Python script in the real world. Every time I run a workshop I give quizzes to the attendees. But every person gets a different version of the quiz, with randomized questions and answers!

And now…

OmbuLabs Blog 

Making Your Clients Better Product Owners

Different clients bring different projects, perspectives, workflows, and experiences, as well as different challenges. Before starting a project, one of those challenges is to define who will be the Product Owner.

Ideally, you would be able to assign the role internally or to the client based solely on the characteristics of the project. However, that's not always the case. It might just be that the client insists on being the Product Owner or that you are a small team and can't really assign the role internally. Whatever the reason, you might end up in a situation where your client isn't really a good Product Owner.

Here I'll share some strategies we implement to help our clients become…

Riding Rails 

Rails 5.2.4 has been released!

Hi everyone,

I am happy to announce that Rails 5.2.4 has been released.

CHANGES since 5.2.3

To view the changes for each gem, please read the changelogs on GitHub:

To see a summary of changes, please read the release on GitHub:

5.2.4 CHANGELOG

Full listing

To see the full list of changes, check out all the commits on GitHub.

SHA-256

If you’d like to verify that your gem is the same as the one I’ve uploaded, please use these SHA-256…

Riding Rails 

Rails 6.0.2.rc1 has been released!

Hi everyone,

I am happy to announce that Rails 6.0.2.rc1 has been released.

If no regressions are found, expect the final release on Monday, December 2, 2019. If you find one, please open an issue on GitHub and mention me (@rafaelfranca) on it, so that we can fix it before the final release.

CHANGES since 6.0.1

To view the changes for each gem, please read the changelogs on GitHub:

To see a…

EquiValent 

Software Philosophy Quotes and Memes

Testing

unit-test

Language speed

unit-test

Conway’s law

Conway’s law is an adage stating that organizations design systems that mirror their own communication structure.

If project you work for has 3 different teams that communicate in isolation, you will end up with 3 different versions of same Software those teams suppose to be building.

Agile

There is difference between "Agile" and "agile web development". Original agile manifesto was about people and practical approaches that fit the team.

Today software age is trying to push bunch of “must have” software (like Jira) and processes (like Scrum) as a way how to be proper "Agile" company.

In the original agile web development these were…

Scott Watermasysk 

Rebuilt on Eleventy

I recently rebuilt my site Eleventy.

The process took a bit longer than I hoped, but overall I feel like I am in better shape going forward.

My main reasons for switching from Jekyll were speed and flexibility.

I am still not 100% done, but I wanted to do more to track and share links I find interesting. I also merged my previous "shorts" and "posts" under one category of blog.

Ruby Magic by AppSignal 

Configurable Ruby Modules: The Module Builder Pattern

In this post, we’ll explore how to create Ruby modules that are configurable by users of our code — a pattern that allows gem authors to add more flexibility to their libraries.

Most Ruby developers are familiar with using modules to share behavior. After all, this is one of their main use cases, according to the documentation:

Modules serve two purposes in Ruby, namespacing and mixin functionality.

Rails added some syntactic sugar in the form of ActiveSupport::Concern, but the general principle remains the same.

The Problem

Using modules to provide mixin functionality is usually straightforward. All we have to do is bundle up some methods and include our module elsewhere:

1
2
3
4
5
6
7…
All Ruby Podcasts by Devchat.tv 

RR 439: Human Powered Rails: Automated Crowdsourcing In Your RoR App with Andrew Glass

Andrew Glass is a Brooklyn based Rubyist operating a small independent devshop called Bang Equals. He has held many ‘enrichment jobs’, including being a ball person at US Open for 5 years, traveling for judging Guinness World Record attempts, and will be a balloon holder in the Macy’s Thanksgiving Day Parade this year. Today the panel is discussing his about his 2018 RailsConf talk, Human Powered Rails: Automated Crowdsourcing In Your Ruby on Rails App. In his talk, he shows the audience how to use Amazon Mechanical Turk. Amazon Mechanical Turk lets you post tasks, set a price point, and then people can go and complete the task. This is often done with tasks that can’t be done with machine…

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

UUID Primary Key in Rails 6 with PostgreSQL and Active Record

UUID is an alternative primary key type for SQL databases. It offers some non-obvious advantages compared to standard integer-based keys. Rails 6 release fresh out of beta introduces a new feature in ActiveRecord that makes working with UUID primary keys more straightforward. In this tutorial, we will dive deep into UUIDs with all their cons and pros.

Advantages of using UUIDs over integers

UUID is a random string in a predefined format. Sample value looks like that:

ccbb63c0-a8cd-47b7-8445-5d85e9c80977

UUID is superior to integer-based primary keys in many ways. One caveat might be the size of database indexes, but for non-big-data tables, you shouldn’t notice the difference between…

The Bike Shed 

223: Terrible and Easy

Julia Evans 

Challenge: Write a bouncy window manager

Hello! I’m writing a short series of programming challenges with Julian, and this is the first one!

the challenge

requirements

The goal here is to make a very silly Linux window manager that bounces its windows around the screen, like in the gif above.

anti-requirements

The window manager doesn’t need to do anything else! It doesn’t need to support:

  • moving or resizing windows
  • switching between windows
  • minimizing windows
  • literally any of the other things you might normally expect a window manager to do

It turns out implementing this kind of toy window manager is surprisingly approachable!

the setup: start with tinywm

All the instructions here only work on Linux (since this is…

rossta.net 

Using Bootstrap with Rails Webpacker

In this post, I'll demonstrate how to set up a Rails application with Bootstrap for Webpacker.

If you'd prefer to skip the post and go straight to the demo app, you can find it here: https://github.com/rossta/rails-webpacker-bootstrap-demo

The examples and demo app described in this post use the following dependencies:

# Ruby/Rails
Rails 6.0.1
Ruby 2.6.5
Webpacker 4.2.0

# npm
@rails/webpacker 4.2.0
bootstrap 4.3.1
jQuery 3.4.1
popper.js 1.16.0

We'll assume we're working from a recently-created Rails 6 app with the default Webpacker installation. The examples may also work with other versions Rails that support Webpacker 4.

When the Webpacker install is run, i.e. bin/rails…

JetRockets 

How to add HTTP Basic auth to Amber application

Saeloun Blog 

Ruby 2.7 adds supports for Comparable#clamp with a range

Clamp method was added to Comparable module in Ruby 2.4.

Comparable#clamp

The method is used to clamp an object within a specific range of values.

20.clamp(0, 5)
=> 5

20.clamp(0, 50)
=> 20

20.clamp(30, 50)
=> 30

Similarly, strings can also be clamped within a range.

"p".clamp("a", "z")
=> "p"
 
"p".clamp("s", "z")
=> "s"

"p".clamp("a", "g")
=> "g"

"king".clamp("kingdom", "kingship")
=> "kingdom"

One way to use clamping effectively is to define the minimum and maximum values for the globally used entities in configurations or constants and use them app-wide.

Example,

We have a constant to define range for the score

SCORE_RANGE = (1..10)

In order to clamp the input score value…

Remote Ruby 

Better Late Than Never

RubyGuides 

What Can You Do With Ruby? (Hint: Infinite Possibilities)

Many people are attracted to Ruby because Ruby on Rails makes building web applications faster.

That’s fine.

But then, when you find out how beautiful Ruby is, you fall in love with the language!

Now the question is…

Is Ruby limited to what Rails can do?

No!

Not at all.

Ruby is a general programming language.

In theory, you can make anything you want with Ruby.

Now:

How practical it’s to make something is another story.

It depends on what gems & libraries are available because these gems do a lot of the heavy lifting for you.

Practical things you can do with Ruby:

Ruby on Rails Podcast 

297: The Functional Rubyist with Joe Leo

Joe Leo is the CEO of Def Method, an agile Ruby software consultancy, and the co-author of The Well-Grounded Rubyist, Third Edition. He and Brittany discussed functional programming in Ruby and their thoughts on the Ruby community after Rubyconf 2019.

Links for this episode:

Brought to you by:

Mirror Placement

If you are a Rails developer currently in the market, a startup seeking to grow your team, or just simply…

Test Double | Our Blog 

A First Look at Github Actions

GitHub Actions, the new offering for CI/CD and other automated workflows, is still in beta just out of beta and looks promising. In order to get myself acquainted with GitHub Actions, I used the nodenv test suite as a chance to try it out.
Alfredo Motta 

Not So Random Software - Week #2

Here is the second week of Not So Random Software. My mind has been on time management lately and you might notice some signal in the randomness of these links. A random tool I have been using Timing for the last three months to track my time automatically. It is so good that it feels […]
Ruby News 

Ruby 2.7.0-preview3 Released

We are pleased to announce the release of Ruby 2.7.0-preview3.

A preview version is released to gather feedback for the final release planned for December. This preview3 is mainly released to confirm the compatibility of keyword arguments.

It also introduces a number of new features and performance improvements, most notably:

  • Compaction GC
  • Pattern Matching
  • REPL improvement
  • Separation of positional and keyword arguments

Compaction GC

This release introduces Compaction GC which can defragment a fragmented memory space.

Some multi-threaded Ruby programs may cause memory fragmentation, leading to high memory usage and degraded speed.

The GC.compact method is introduced for…

rails - Sips & Bits by michelada.io 

Ruby on Rails

Ruby on Rails

Ruby es un lenguaje de programación. Fue creado hace 20 años por Yukihiro "Matz" Matsumoto. Según la mayoría de las medidas de popularidad del lenguaje de programación, Ruby se encuentra entre los diez primeros, aunque generalmente es el décimo (más o menos) en popularidad, y en gran parte debido a la popularidad de Rails. Al igual que Java o el lenguaje C, Ruby es un lenguaje de programación de propósito general, aunque es mejor conocido por su uso en la programación web.

Rails es una biblioteca de software que extiende el lenguaje de programación Ruby. David Heinemeier Hansson es su creador. Le dio el nombre de "Ruby on Rails", aunque a menudo simplemente se llama "Rails". Es un código de…

Riding Rails 

Rails 5.2.4.rc1 has been released!

Hi everyone,

I am happy to announce that Rails 5.2.4.rc1 has been released.

This is going to be the last bug fix release of the 5.2 series, so please test the releases candidates and report regressions so we can fix before the final release.

If no regressions are found, expect the final release on Wednesday, November 27, 2019. If you find one, please open an issue on GitHub and mention me (@rafaelfranca) on it, so that we can fix it before the final release.

CHANGES since 5.2.3

To view the changes for each gem, please read the changelogs on GitHub:

Appfolio Engineering 

RubyConf Nashville

Hey, folks! I’d love to call out a little fun Ruby news from RubyConf in Nashville.

Ruby 3.0 and Ruby Core

We’ve been saying for awhile that Ruby 3.0 will ‘probably’ happen next year (2020.) It has now been formally announced that Ruby 3 will definitely happen next year. From the same Matz Q&A, we heard that he’s still not planning to allow emoji operators. 🤷

Additionally, it looks like a lot of “Async” gems for use with Fibers will be pulled into Ruby Core. In general, it looks like there’s a lot of interesting Fiber-related change coming.

Artichoke

I like to follow alternative (non-MRI) Ruby implementations. Artichoke is a Ruby interpreter running in Rust and mruby (an embedded lightweight…

Honeybadger Developer Blog 

FounderQuest S2 E6 | Marketing On Marketplaces

Ben and Starr are putting the entire weight of FounderQuest on their backs this week as they forge ahead without Josh for this episode. Fear not listener, just because it's two-thirds of the presenters doesn't mean you aren't getting a full serving of the FounderQuest goodness that you are used to. Behold the buffet of subject choices that await you!

GitHub Student Developer Pack

Ben talks about Honeybadger's decision to participate in the GitHub Student Developer Pack and the playing the long-game to get new customers.

Marketplaces

The guys go over their experiences with marketplaces. It can take quite a bit of developer time to set up each listing since most popular marketplaces, such…

iridakos - ruby articles 

Mongoid - Inheritance: change embedded document's type via nested attributes

I recently faced some issues when trying to update a nested document’s type via nested attributes using the mongoid gem. Bare with me if this sentence doesn’t make any sense yet.

Use case

Suppose we have a document named Person that embeds a document that can be any of the types Book or BoardGame which inherit from the class Item.

Item

class Item
  include Mongoid::Document

  embedded_in :person, inverse_of: :item

  field :name
end

Book

class Book < Item
  field :authors, type: Array
end

BoardGame

class BoardGame < Item
  field :players, type: Integer
end

Person

class Person
  include Mongoid::Document

  embeds_one :item, inverse_of: :person
  accepts_nested_attributes_for :i…

The problems

To simplify the post I won’t go with the scenario of…

Awesome Ruby Newsletter 

💎 Issue 183 - Welcome to RubyConf! Live stream link

Ruby Weekly 

10 new things in Active Record

#477 — November 21, 2019

Read on the Web

Ruby Weekly

Ruby Next: A Way to Transpile Modern Ruby Code to Run on Ruby 2.5 or mruby? — If you’ve used Babel in the JavaScript world, the concept here may be familiar to you. Ruby Next is designed to let us code using cutting edge (or even experimental) Ruby features and then transpile that code to run on Ruby 2.5 or mruby, say. It's still early days, but interesting. Here’s a slidedeck with more info.

Vladimir Dementyev

Isolating Rails Engines with RuboCopEngines provide a convenient way to break larger apps into a loosely coupled collection of smaller…

Saeloun Blog 

Rails 6 adds each_value method to ActionController::Parameters

Rails 6, has added a new utility method each_value on ActionController::Parameters.

This method as the name suggests iterates over and yields each value of the ActionController::Parameters just like Hash#each_value.

Hash#each_value vs ActionController::Parameters#each_value

It’s different from Hash#each_value in that it converts all the hashes in values to ActionController::Parameters object before yielding the values to block, instead of simply returning the value.

Example

Consider the example below, we define a ActionController::Parameters with user profile details

params = ActionController::Parameters.new({
  name: {
    first: "Narendra",
    last: "Rajput"
  },
  gender:…
Julia Evans 

What makes a programming exercise good?

I’ve been thinking about programming exercises lately, because I want to move into teaching people skills. But what makes a good programming exercise? I asked about this on Twitter today and got some useful responses so here are some criteria:

it’s fun

This one is sort of self-explanatory and I think it’s really important. Programming is fun and learning is fun so I can’t see why programming exercises would need to be boring.

it teaches you something you care about

I don’t think this has to strictly mean “relevant to your job right this second” – people don’t just have jobs, we also want to make art and games and fun personal projects and sometimes just understand the world around us.…

Ruby on Rails Podcast 

296: Conscious Coding Practice with Noah Gibbs

Brittany is live from Rubyconf 2019! Noah Gibbs is a Ruby Fellow for AppFolio, working on the core Ruby language and related tooling. After over 30 years of communicating with computers, Noah now believes that communicating with humans may not be a passing fad, and he's trying it out.

Links for this episode:

Brought to you by:

Mirror Placement

If you are a Rails developer currently in the market, a startup seeking to grow your team, or just simply curious to hear about market and salary trends, Brian at Mirror Placement would love to chat with you. He will send you a turkey!

You can reach him at brian@mirrorplacement.com. Turkeys are in limited…

All Ruby Podcasts by Devchat.tv 

The MaxCoders Guide To Finding Your Dream Developer Job

"The MaxCoders Guide to Finding Your Dream Developer Job" by Charles Max Wood is available on Amazon. Get your copy here today only for $2.99!

GoRails Screencasts 

Testing Times & Dates with Rails

Rails provides several helper methods for testing times and dates in your applications. You can now freeze time and time travel like in the movies!
Code with Jason 

How I approach test coverage metrics

Different developers have different opinions about test coverage. Some engineering organizations not only measure test coverage but have rules around it. Other developers think test coverage is basically BS and don’t measure it at all.

I’m somewhere in between. I think test coverage is a useful metric but only in a very approximate and limited sort of way.

If I encounter two codebases, one with 10% coverage and another with 90% coverage, I can of course probably safely conclude that the latter codebase has a healthier test suite. But if there’s a difference of 90% and 100% I’m not convinced that that means much.

I personally measure test coverage on my projects, but I don’t try to optimize…

EquiValent 

Custom domain / subdomain for website hosted on AWS S3

You can configure Amazon Web Services (AWS) S3 buckets to host static websites (e.g. static HTML+CSS+JavaScript website or Single Page App (SPA) Frontend )

In this Article I’ll show you how to set AWS S3 bucket:

  1. AWS S3 bucket as a Subdomain website
  2. AWS S3 bucket as a Custom Domain website
  3. How to secure it with https://

Storing files on AWS S3 is super cheap (pricing). Price depends on how much data you store (around $0.03 per GB) and Data transfer (like $0.09 per GB). If you configure it the right way the cost of hosting your website will be less than $0.1 per month

The core principle is that you need to name your S3 bucket same way how the domain / subdomain will be named.

Pat Shaughnessy 

Using Result Combinator Functions in Rust


Rust’s Result type can help you control your program’s
flow by checking for errors in a succinct, elegant way

Using Rust for the first time, error handling was my biggest stumbling block. Was this value a Result<T, E> or just a T? And the right T? The right E? I couldn’t just write the code I wanted to write. It felt confusing and overly elaborate.

But after a while, I started to get a feel for the basics of using Result. I discovered that the combinator methods Result provides, like map, or_else and ok, made error handling fun. Well, maybe that's a bit of an overstatement. They made using Result a bit easier, at least.

So far my favorite Result combinator method is and_then.…

Saeloun Blog 

Who was hiring at RubyConf 2019?

The following companies were hiring at RubyConf 2019 organized this year in Nashville, TN.

ActBlue

AdHawk

Airbnb

Anvyl

Appriss

BackerKit

Bendyworks

Bold Penguin

Braintree

Cookpad

CoverMyMeds

def method

Doximity

E&E NEWS

Envoy

ezCater

Finalsite

Fleetio

Flexport

Fullscript

General Dynamics

Global Impact

Gravitational

Guild Education

Hover

Invoca

Justworks

Kenna Security

Mastery Logistics Systems

Movable Ink

Nava PBC

Nexmo

Nikola

OMBULABS

OneMain Financial

One Medical

Optoro

Planet Argon

Privia Health

RAMSEY Solutions

ReviewTrackers

Runtastic

Shopify

Simply Business

Snapdocs

SportsEngine

Springbuk

Street Easy

Stripe

Square

Test Double

thought…

Martian Chronicles, Evil Martians’ team blog 

Pulling the trigger: How to update counter caches in your Rails app without Active Record callbacks

Author: Dmitry Tsepelev, Back-end Developer at Evil Martians

In this article, we experiment with triggers as a tool for keeping aggregated data consistent when using Active Record and your favorite SQL database. Instead of using sophisticated tools such as ElasticSearch for filtering and searching, we will demonstrate a simple approach that achieves the same result with some out-of-the-box database features. As a bonus, learn how to avoid nasty race conditions!

Sometimes you need to sort and filter records in the database by some aggregated values. For instance, you might be building a paginated list of users in an admin panel, and you want to implement filtering by the number of…

Semaphore 

CI/CD for Spring Boot Microservices

Continuous Integration (CI) is a software engineering practice in which we test our code on every update. The practice creates a strong feedback loop that reveals errors as soon as they are introduced. Consequently, we can spend more of our time coding features rather than hunting bugs.

Once we’re confident about the code, we can move on to Continuous Delivery (CD). Continuous Delivery goes through all the steps that make the release so each successful update will have a corresponding package—ready for deployment.

I believe that practice is the best school. That is why I’ve prepared a demo project that you can practice on. As you follow the steps, you’ll learn how CI/CD can help you…

Depfu 

When do we create pull requests?

Did you ever wonder when Depfu will send you the PR for a new version?

We haven’t been super transparent about that in the past as we were also experimenting with different strategies. But one major theme has become apparent: we’re not that interested in real-time. We think updating as soon as possible after a new version gets released rarely make sense. When it does make sense we do send you updates right away and when it doesn’t, we now allow you to control it yourself.

There are a few layers of latency when it comes to new releases in Depfu:

When do we detect new releases?

Only very few registries support webhooks for new releases, so we unified on polling registries regularly…

All Ruby Podcasts by Devchat.tv 

RR 438: Deviating from the Rails Core

Today Charles and Dave are discussing deviating from the Rails core. Dave doesn’t care for JavaScript frameworks or microservices as he believes that they add too much complexity. These things may become necessary when your project gets massive, but otherwise we shouldn’t jump to these as a first option. If you don’t need the frontend powerhouse features, you may want to see how far you can get with Rails and a minimal frontend. React may not always be the solution that you need. They discuss jQuery versus Stimulus. They both prefer jQuery over Stimulus as they find it less invasive and clunky, and it’s easier to drop things in. 

Dave talks about his experience with ElasticSearch and how…

Honeybadger Developer Blog 

FounderQuest S2 E5 | Should You Comply With Compliance?

On this week's episode of FounderQuest Josh, Ben, and Starr talk about their SOC 2 and GDPR compliance efforts. They go over the different strategies to handle compliance, the potential costs involved, and discuss if it's worth the time and money.

When embarking on their compliance research, the guys also stumbled across some surprising claims companies are using to stretch the truth on actually being compliant. Learn a few of the 50 shades of compliance* that they found.

Also, Josh's Halloween costume is revealed!🦇

Comply with FounderQuest and listen here!

Honeybadger Developer Blog 

Lights, Camera, GitHub Actions!

Here at Honeybadger, we are big fans of GitHub Actions' workflow automation and CI/CD features. We like it so much that we decided to add two of our own contributions to the community!

Now you can trace stacks at light speed by uploading your source maps to Honeybadger directly from GitHub using your original, un-minified Javascript code.

Example:

on:
  push:
    branches:
      - master

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - uses: honeybadger-io/github-upload-sourcemap-action@master
      with:
        api_key: ${{ secrets.HONEYBADGER_API_KEY }}
        minified_url: https://example.com/assets/application.min.js
        minified_file:…
Julia Evans 

Some notes on vector drawing apps

For the last year and a half I’ve been using the iPad Notability app to draw my zines. Last week I decided I wanted more features, did a bit of research, and decided to switch to Affinity Designer (a much more complicated program). So here are a few quick notes about it.

The main difference between them is that Notability is a simple note taking app (aimed at regular people), and Affinity Designer is a vector graphics app (aimed at illustrators / graphic designers), like Adobe Illustrator.

I’ve never used a serious vector graphics program before, so it’s been cool to learn what kinds of features are available!

Notability is super simple

This is what the Notability UI looks like.…

Julia Evans 

How containers work: overlayfs

I wrote a comic about overlay filesystems for a potential future container zine this morning, and then I got excited about the topic and wanted to write a blog post with more details. Here’s the comic, to start out:

container images are big

Container images can be pretty big (though some are really small, like alpine linux is 2.5MB). Ubuntu 16.04 is about 27MB, and the Anaconda Python distribution is 800MB to 1.5GB.

Every container you start with an image starts out with the same blank slate, as if it made a copy of the image just for that container to use. But for big container images, like that 800MB Anaconda image, making a copy would be both a waste of disk space and pretty…

RubyGuides 

How to Use Flash Messages in Rails

What are flash messages?

A flash message is a way to communicate information with the users of your Rails application so they can know what happens as a result of their actions.

Example messages:

  • “Password changed correctly” (confirmation)
  • “User not found” (error)

You set these flash messages in your controllers, then you render them in your views. Your users can then act accordingly.

Let’s learn exactly how this works!

How to Use Flash Messages

You can work with these notification messages using the flash helper method.

It behaves a lot like a Ruby hash.

The flash object has methods like keys, any? or each & you can access a particular message with [].

What types of flash messages can…

Rémi Mercier 

A beginners’ introduction to Ruby classes and objects

When you start learning Ruby, you often hear that everything is - or evaluates as - an object. And you’re usually like “🤔 Come again”?

So, here’s an introduction to objects and classes in Ruby for my fellow Ruby junior developers out there.

What is an object?

An object is a piece - any piece - of data (regardless of the language you're using). That's it.

Some types of data:

  • 'Hey there' is a string.
  • 1 is an integer.
  • 5 is another integer.
  • 👶 is a baby.
  • [] is an empty array.

a schema explaining how different babies are different objects in real life, yet sharing common data types and behaviors

Easy right?

Objects and classes 101

Now, to handle objects, Ruby creates a set of abstractions handling common behaviors for the same objects: classes.

Let’s dive in:

1 and 5 are different integers,…

EquiValent 

Create AWS S3 bucket as a static website with AWS CLI

In this TIL note I’ll create static website hosted on AWS S3 bucket using only AWS CLI.

We will create dummy static website on bucket called happy-bunny

Create bucket

# create s3 bucket via AWS CLI
aws s3api create-bucket --bucket happy-bunny --region eu-west-1  --create-bucket-configuration LocationConstraint=eu-west-1

# ..or with profile option
aws s3api create-bucket --bucket happy-bunny --region eu-west-1  --create-bucket-configuration LocationConstraint=eu-west-1 --profile equivalent

  • --profile nameofprofil is only necesarry if you have multiple AWS accounts on your laptop (E.g work one is default and personal is equivalent)
  • to understand why the LocationConstraint read here

Set bucket public policy

create a file /tmp/bucket_policy.json with this content:

{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "PublicReadGetObject",
   …
The Life of a Radar 

Rough Edges

Our job as software developers is to make functional software.

A user should be able to use our software to accomplish tasks that might otherwise take a long time if they were doing it without computers. This has a wide-and-varied range, of course. But the main thing is that we need to make software that works.

If we didn't do that, we would find ourselves out of a job very quickly.

However, functional software shouldn't just be the only thing we strive for.

We should also strive to eliminiate rough edges in our software. We can do this through a process of quality assurance testing, introspection and by plain old taking feedback from our users and acting on it.

We need to listen to real…

code.dblock.org | tech blog 

Pros and Cons of Going from Management Back to Individual Contributor

There’s much written about becoming an Engineering Manager, but little about going back to being an Individual Contributor. This is not surprising because it often feels like a demotion or giving up. This is my story and thoughts on leaving a CTO role and going back to being an individual contributor. I am six months into a Principal Engineer role.

About 15 years ago I began to see how every technical problem was a people problem, and naturally felt that the best way to solve technical issues, and to grow my career was to aim for active leadership positions. I also saw how much more value I could deliver with a team versus as a solo individual, and wanted to not only influence others, but…

Riding Rails 

Rails 6.0.1, database connection improvements, and more

Hey there! This is Daniel bringing you the latest news in Rails. I am writing from RubyConf in Nashville, so come find me and say hello if you are here too!

Rails 6.0.1 released

As always, this release is loaded with fixes and improvements. Today seems like a good day to upgrade, don’t you think?

Introduce role manager to manage connections

I am a big fan of detailed commit messages, and this commit has an impressive one. This change will help to eventually support sharding in Rails.

Disable logging for jobs with sensitive arguments

Do you have any jobs that include sensitive arguments like passwords? You probably don’t want to see those arguments showing up in your logs. Now you…

Alfredo Motta 

Not So Random Software - Week #1

I have been trying to write longer articles lately, which obviously means things take longer. On the other hand I would like to share what I have been thinking about more often and get your feedback. So I am starting this Not So Random Software newsletter. Let me know if you find the content helpful! […]
RubySec 

json-jwt improper input validation due to lack of element count when splitting string

RubySec 

rack-cors directory traversal via path

Andy Croll 

Write One Test

Rails comes with a built-in testing framework and many Rubyists evangelise various methods of testing: Behaviour Driven Development, 100% test coverage, Red-Green-Refactor.

But perhaps you’ve never really ‘got it’ or ever seen the benefits of an established testing culture. As a result you might not have any tests in your Rails application.

Instead of…

…not having any tests:

Perhaps…

…just write one “smoke” test.

test/system/home_page_test.rb

class HomePageTest < ApplicationSystemTestCase
  test "show homepage" do
    visit "/"
    assert_text "Text on your homepage"
  end
end

You can run this test by typing bundle exec rails test:system.

Why?

This single test does two major…

Code with Jason 

Exosuit demo video #2: launching an EC2 instance from Exosuit’s web UI

Exosuit is a tool I’ve been working on to make Rails-AWS deployments almost as easy as Rails-Heroku deployments.

Back in late September 2019, I coded up an initial version of Exosuit and released a demo video of what I had built.

Since then a lot has changed, including my conception of what Exosuit even is.

My original thought was that Exosuit would be mainly a command-line tool, with a web UI in a supporting role. Now my thinking is that Exosuit will be mainly a web UI tool, with a command-line tool in a supporting role.

Here’s what I’m currently imagining the launch process to look like, roughly:

  1. Create an Exosuit account
  2. Connect Exosuit with your AWS account and let Exosuit launch an…
code.dblock.org | tech blog 

Building AWS Data Exchange and the Value of Simple Ideas at Scale

Six months ago I joined AWS to work on a new service, AWS Data Exchange, launched today. AWS Data Exchange makes it easy to find, subscribe to, and use third-party data in the cloud.


This is just the starting line for AWS Data Exchange.

Building the service I learned the value of simple ideas executed at scale. The service is conceptually simple, solving a number of existing customer problems. It splits the provider and subscriber responsibilities into two distinct processes - providers take care of publishing data updates, and subscribers receive data and updates with less effort. All the heavy lifting and shifting of data is done by AWS Data Exchange on top of Amazon S3, at scale,…

With a Twist 

Avoiding nil in Ruby programs (and NULL in databases)

Most Ruby developers see the following exception in production, no matter how well taken care their codebase is:

1
NoMethodError: undefined method `name' for nil:NilClass

And the search begins. Was it a user? Or another object that would respond to #name if present? Was it a typo? Many different statements can return nil:

1
2
3
4
5
6
session[:blog_pozt]    # => nil
session[:current_user] # => nil
@currentz_uzer         # => nil
array[length + 1]      # => nil
if false then 1 end    # => nil
empty_method()         # => nil

Our preference is to return anything but nil. A quick improvement is to return a symbol! Authentication Ruby gems return nil on current_user by default, but we can do…

1
2
3
4
5
6
def current_user
Scott Watermasysk 

Alfred Color Workflow

I saw a mention by @adamwathan about an Alfred workflow for working with colors. After a little digging, I was lead to @tylereich's Alfred Color Workflow.

It works with both CSS colors (Hex, RGB, HSL, Named Colors) and NSColor (although I only tried CSS).

Setting it up takes a couple of steps, but this has more to do with the OS X security model than Alfred or the developer's work.

  1. Download the Workflow
  2. Open in and add it to Alfred
  3. Type a Hex color, named color (c blue), etc.

At this point, OS X is going to tell you it cannot verify the developer. To move forward, go to System Preferences → Security and Privacy → Allow Colors.

Once this is complete, try step #3 above again. You will again…

Awesome Ruby Newsletter 

💎 Issue 182 - The Delegation Challenge of Ruby 2.7 (ruby 3 keyword arg changes)

Appfolio Engineering 

Intern Experience at Appfolio

My experience at Appfolio for the past 5 months has been nothing short of amazing. TL;DR - I've made more friends and participated in more 'extra-curricular' activities than my other two internships combined. If beautiful weather 24/7, programming in paradise, biking, rock climbing, D&D, dancing, or Disney World catch your fancy, read on.

# Day 1

My mentor greeted me at the door with a peach flavored smoothie to welcome me to the team. Everyone I passed by on my first day said 'hi' or waved to all us new hires on our morning tour. My computer already had most of the necessary technologies installed, and I was ready to start programming immediately! Appfolio has a well-organized onboarding…

Ruby Weekly 

Ruby roots, Stripe's approach to testing, and the 'ambiguous' operator

#476 — November 14, 2019

Read on the Web

Ruby Weekly

Ruby's Roots and Matz's Leadership — Noah summarizes a recent talk Ruby’s creator, Matz, gave about the history of Ruby, where he got various language feature ideas from, and what he thinks Ruby’s greatest invention was (psst.. blocks!)

Noah Gibbs

The Delegation Challenge of Ruby 2.7 — This is a somewhat odd situation where a change to arguments changes delegation so things are handled differently in Ruby 2.6, 2.7, and 3.0. It’s a tough nut to crack and a great example of language design related edge cases.

Benoit Daloze

Happy Rails…

Semaphore 

In Continuous Integration, Run Fast and Fundamental Tests First

While it’s great to keep your entire CI/CD pipeline fast, on many occasions you don’t even need to run all tests to get the feedback you need.

Unit tests run the fastest, because they test a very small piece of code in complete isolation from the rest of the system. For example, they usually don’t touch the database.

Unit tests deal with fundamental business logic, and are the most numerous, as is commonly depicted in the “test pyramid” diagram:

test pyramidTest pyramid

A failure in unit tests is a sign of a fundamental problem, which makes running the remaining high-level and long-running tests irrelevant.

For these reasons, projects with test suites that run for anything longer than a…

GoRails Screencasts 

How to Test Background Jobs with Active Job

Learn how to test Active Job in your Ruby on Rails application
EquiValent 

RSpec mocks in Rails native tests (minitest)

I love RSpec but recently I’ve decided to build sideproject with 100% Rails 6 vanilla environment (that means no extra gems, just what is inside Rails 6, including the Minitest test environment)

Problem is Minitest stubs and mocks suuuucks !

If you are interested in Minitest mocks check this article

So I want to use Rails Minitest but RSpec mocks and this is how:

# Gemfile

# ...

group :test do
  # ...
  gem 'rspec-mocks'
end

# ...

note, no rails-rspec is not required

# test/test_helper

# ...
require 'rspec/mocks/minitest_integration'
# ...

require 'test_helper'

class AddPhoneControllerTest < ActionDispatch::IntegrationTest
  test 'POST create add phone to inzerat when…
Ruby on Rails Podcast 

295: Power the World with Rails with Bindiya Mansharamani & Andrew Derenge

Bindiya Mansharamani, Director of Engineering, & Andrew Derenge, Principal Engineer at RigUp joined Brittany to discuss RigUp's GraphQL design choices, engineering culture and the career path to achieve senior and director level.

Links for this episode:

Brought to you by:

Mirror Placement

If you are a Rails developer currently in the market, a startup seeking to grow your team, or just simply curious to hear about market and salary trends, Brian at Mirror Placement would love to chat with you. He will send you a turkey!

You can reach him at…

avdi.codes 

Exploring, Pathmaking, Traveling

Lately Jess and I have been talking about the work of software development, particularly project setup.

Some of the work that we do when is purely experimental. “What happens when I push this button?” “What sub-commands are available?” “What is possible with this library?” “Will this fix it?” That’s exploring.

Exploring can be aimless. It can also be deliberate. We can make hypotheses and prove or disprove them. “I don't understand this framework, but I hypothesize that a change to this file will be be reflected in the UI”. This kind of code science can help us build a model: a limited theory of how software works.

This is like looking at the map and saying “I think that I'm here,…

Saeloun Blog 

Handling attachments in Action Text in Rails 6

This is part two of our multipart series exploring Action Text, In part 1, we looked at basic of how we can get started with providing WYSIWYG support in our Apps using ActionText.

This blog post will deal with file attachments in Action Text.

Quick setup

We have discussed setup steps in Part 1. Here we will just list a set of commands to setup a new rails app and enable Action Text which one can execute so as to follow along this post.

Create a new rails app:

$ rails new blog_app --database=postgresql

Switch to app directory:

$ cd blog_app

Create database:

$ rails db:create

Enable support for action_text:

$ rails action_text:install
$ rails db:migrate

Add scaffold for post…