...argument. Also, the code after the yield in example is not executed! Probably, this behavior was designed to enable programmers writing their own iterators (like while or loop) as methods...
The standard way to abort async code is that your function takes a AbortSignal { signal } property. The caller can use...
...first get a general overview of the most popular solutions. To chose a single "best" of those, ask yourself questions such as: Is the library still maintained? When was the...
...level of our own standards. Does it have a ton of dependencies? Fewer is better, in this case. Sites like the Ruby Toolbox (only for gems) or npm compare may...
...for the event to be processed before continuing - the event could prevent the default behavior. Luckily there is a concept called passive event listeners which is supported by all modern...
...see a performance gain when declaring scroll events as passive. To improve the scrolling behavior you should still try to keep the execution time of your handler to a minimum...
CSS variables are very different from preprocessor variables. While preprocessors use variables to compile a static piece of CSS, CSS...
Event delegation is a pattern where a container element has a single event listener that handles events for all descendants...
...Haml maintainer, this negatively impacted rendering performance. So in Haml 6, they kept this behavior only for a few attributes, which they called "boolean". All other attributes will just render...
...their value as it is given. Behavior of "boolean attributes" remains unchanged No Haml value => no HTML value Boolean Haml value => attribute is rendered depending on that value
...be guessable, but exposing your dev server to the internet is generally not the best idea. In my tests I was not easily able to get a better errors console...
There are two distinct ways of commenting Haml markup: HTML and Ruby. HTML comments This will create an HTML comment...
A common task in web applications is to add client-side JavaScript behavior to existing HTML elements. For instance, in Working with the DOM you built a movie counter...
✔️ Reliable invocation Using the HTML markup above should always result in the same behavior. Components are usually invoked when a particular CSS selector matches a new DOM element. This...
It happens from time to time that a job in a GitLab pipeline fails. Sometimes, however, the error message is...
Occasionally you need to do something directly on the server -- like having all records recalculate something that cannot be done...
There are two ways a logout in SAML can happen: Service Provider (SP) initiated and Identity Provider (IDP) initiated logout...
...ms long. Once a frame renders longer than 16ms, the page will begin to feel staggering and slow. Google Chrome DevTools The Chrome DevTools enable you to precisely investigate and...
...complex. Deeply nested rules and slow selectors are the main cost factors. Using a BEM pattern for CSS should produce relatively fast CSS. Performance issue 4: Slow repaints
...have one of the following workflow states: draft pending published declined A movie always begins as a draft and then transitions through the states as it's getting reviewed. This...
...very nasty fails. Below are the basic changes you need to perform and some behavior you may eventually run into when upgrading your application. This aims to save you some...
...in your uploaders... def extension_white_list %w[jpg jpeg gif png] end must become def extension_allowlist %w[ jpg jpeg png gif ] end Also, every uploader must define allowlists...
GRASP (object-oriented design) Single Responsibility Principle Tell, Don't Ask Best practices for writing code comments Read the following chapters from our book Growing Rails Application...
...has_many :items validates_presence_of :recipient_address, :number end class Invoice::Item < ApplicationRecord belongs_to :invoice belongs_to :product validates_numericality_of :units end class Product < ApplicationRecord validates_presence...
...default when assigning attributes. It works good for a small number of attributes, but becomes more difficult to read when using multiple attributes. Example: class User def initialize(salutation, first...
@newsletter = newsletter end end User.new( 'Mr.', 'John', 'Doe', 'Potsdamer Platz 1', '10117', 'Berlin', '+49 0151 1122334455', 'john.doe@example.com', true ) Using keyword arguments Using keyword arguments is easier for others...
ignore_rules << (pattern || block) end def mute(&block) @muted = true if block begin block.call ensure unmute end end end def unmute @muted = false end def self.current @current ||= new...
If you want to perform a failover on another haproxy backend server this is the way you should do it...
TL;DR When using Cache-Control on a Rails application, make sure the Vary: Accept header is set.
...the number and last point in time when autovacuum and autoanalyze happened for tables belonging to the currently connected database. SELECT relation::regclass, * FROM pg_locks WHERE not granted;
...your commits are the changes. Never use merge. You've found some code that belongs to an earlier commit in your feature branch If you already have a "final" (i.e...
git rebase -i master Move the fixup directly below the commit it belongs to. Change the "pick" in front of the fixup commit to "f". Don't touch...
...the "space" character class For matching whitespaces in a regular expression, the most common and best-known shorthand expression is probably \s. It matches the following whitespace characters: " " (space)