The Truemail gem (not to be confused with truemail.io) allows validating email addresses, e.g. when users enter them into a...

ruby-doc.org

Ruby has the class Rational which allows you to store exact fractions. Any calculation on these variables will now use...

makandra dev
developer.mozilla.org

The standard way to abort async code is that your function takes a AbortSignal { signal } property. The caller can use...

...Rails code is doing the delivery you can do your usual authentication and authorization beforehand. There are few exceptions where you want to store confidential files in the public folder...

...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...

makandra dev

Static error pages To add a few basic styles to the default error pages in Rails, just edit the default...

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...

github.com

...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...

...or use a more mature solution like Webpack. Modules shared between entry points always become chunks When two entry points import the same module, that module automatically a separate file...

...a way to set a minimum file size for chunking, or to control chunking behavior per import. However there is currently no configuration at all. Modules imported by multiple entry...

makandra dev

...I am really pleased with it -- but only on a desktop computer. Have you benchmarked the framework also on smartphones and tablets? Unfortunately I must say, that it does not...

...as a jQuery collection: let $element = $(element) An API object to call additional JavaScript behavior added by a library: var player = flowplayer($element) player.play() Framework activation layers (like Angular directives...

...confident about upgrading Rails, have a look at Rails LTS. How many update steps? Besides the Rails upgrade itself, you might also want to upgrade your other gems and upgrade...

...many cases updating to the highest subversion of the specific rails version is the best choice (e.g. when updating to rails 5 you would update to 5.2.8.12), since the most...

When Paperclip attachments should only be downloadable for selected users, there are three ways to go. The same applies to...

makandra dev

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...

When working with feature branches, stale branches pile up over time. It's best to remove them right after merge, locally and on the remote, but it is a little...

if [[ "$merged_branch_name" =~ ^(master|main|production|Fast-forward)$ ]]; then exit 0 fi # Begin output echo " " echo "> You have just merged the branch \"$merged_branch_name\" into \"$branch_name...

makandra dev

...with power comes responsibility. Code comments can go wrong in many ways: they may become outdated, silently move away from the code they're referring to, restate the obvious, or...

...a comment, prefer improving the code: use descriptive variable/method names, extract more variables/methods to better describe what is happening, have a simple structure. However, there are things code cannot express...

...instead of downloading and bundling font files yourself. (See below for a list of benefits.) Usage Go to fontsource.org and search for the font you want to add (or a...

...s Fontsource details page for available settings. Why? Using an NPM package has some benefits over placing fonts into your repo: All font weights and glyphs are included.

makandra Curriculum

...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...

...future we will be able to transition to display: none by using the transition-behavior: allow-discrete property. This will delay the display change until the transition ends. This is...

Occasionally you need to do something directly on the server -- like having all records recalculate something that cannot be done...

makandra dev
github.com

...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...

...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...