...request and model using implicit and convoluted protocols. We prefer a different approach. We believe that among all the classes in a Rails project, controllers are some of the hardest...
...to test and understand and should receive special care. It is our belief that: Controllers should be short and tidy Controllers should receive the same amount of programming discipline as...
CSS variables are very different from preprocessor variables. While preprocessors use variables to compile a static piece of CSS, CSS...
...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
The Truemail gem (not to be confused with truemail.io) allows validating email addresses, e.g. when users enter them into a...
Ruby has the class Rational which allows you to store exact fractions. Any calculation on these variables will now use...
The standard way to abort async code is that your function takes a AbortSignal { signal } property. The caller can use...
...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...
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
...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...
Event delegation is a pattern where a container element has a single event listener that handles events for all descendants...
...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...
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...
TL;DR When using Cache-Control on a Rails application, make sure the Vary: Accept header is set.
Occasionally you need to do something directly on the server -- like having all records recalculate something that cannot be done...
...notification service: Use @Input() id: number with component input binding; Update notification.service.ts: Define notification$: BehaviorSubject: Store the last fetched notification; Update notification$ when a new notification is fetched; Using Efficient...
...keywords in your prompts. LLMs excel at pattern recognition, and specific terminology reduces ambiguity. Beyond that giving examples for high level APIs of your imagened class design or using an...
...only a millisecond or two: class FatModelMaterializedJson < ApplicationRecord def self.refresh ActiveRecord::Base.connection.execute(<<~SQL) DO $$ BEGIN IF ( (SELECT last_refreshed_at FROM aggregated_names LIMIT 1) < (SELECT MAX(updated_at) FROM...
...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...
This note shows how to merge an ugly feature branch with multiple dirty WIP commits back into the master as...
...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...
...helper in many views, but in the index view I hide the label to better fit the layout. Here is the helper: module IconHelper def icon(*args, &block) options = args.extract...
...Tue, 09 Oct 2018 In most of the cases it would be better to use Date.strptime as you can provide a date or time pattern to match against. Date.strptime('Foobar...
...there" or "fill that space" (they're not suited for photographs and the like). Benefits are the MUCH smaller file size and the crisp and sharp rendering at any scale...
...actually all browsers pretend to support SVG, some barely complex use cases get you beyond common browser support. In the basic scenario, you use SVGs instead of PNG or JPG...