Jasmine: Creating DOM elements efficiently
Jasmine specs for the frontend often need some DOM elements to work with. Because creating them is such a common...
Jasmine: Cleaning up the DOM after each test
Jasmine specs that work with DOM elements often leave elements in the DOM after they're done. This will leak...
Inspect and Debug CSS Flexbox and Grid Layouts by using the Layouts Tab in Dev Tools
tl;dr In Chrome DevTools in the Layouts tab you have handy options to debug CSS Flexbox and Grid. Including...
Do not use unitless zeros in CSS calc functions
While in CSS zero is usually referenced without specifying a unit (e.g. padding: 0), you must not use a unitless...
Organizing custom Date(Time) formats
Large Rails projects tend to define multiple custom ways to format Dates or DateTimes. This often leads to duplicated format...
Sass: get rid of deprecation warnings in dependencies
TLDR: sass >= 1.35.0 has the option quietDeps to silence deprecation warnings from dependencies. quietDeps: If true, the compiler must not...
Chrome DevTools: Event Listener Breakpoints
tl;dr In Chrome DevTools in the Sources tab you can activate Event Listener Breakpoints for debugging events. Example
Chrome DevTools: DOM Breakpoints - Breakpoints on HTML Elements
tl;dr In Chrome DevTools in the Elements tab or in Firefox in the Inspector tab you can right click...
Chrome DevTools: Quick Bite - Store Element in Global Variable
tl;dr In the Elements tab in the Chrome DevTools you can right click on an element and select Store...
ActiveType::Object: Be careful when overriding the initialize method
ActiveType::Object inherits from ActiveRecod::Base and is designed to behave like an ActiveRecord Object, just without the database...
Temporary solution for connection errors with rubygems
If you're experiencing that your bundle install command fails with an error message like this, rubygems.org might...
Debug flaky tests with an Unpoly observeDelay
Unpoly's [up-observe], [up-autosubmit] and [up-validate] as well as their programmatic variants up.observe() and up.autosubmit...
Rails: Validations of Dates, Numerics and Strings with ComparisonValidator
tl;dr Since Rails 7+ you can use ComparisonValidator for validations like greater_than, less_than, etc. on dates, numerics...
Careful when using Time objects for generating ETags
You can use ETags to allow clients to use cached responses, if your application would send the same contents as...
Use capybara and not rspec matchers
One rule of thumb I try to follow in capybara tests is using capybara matchers and not plain rspec matchers...
RubyMine: Find and Replace with Regex (Capture Groups and Backreferences)
tl;dr In RubyMine you can use find and replace with capture groups (.*?) and backreferences $1 (if you have several...
SEO: The subtle differences of robots.txt disallow vs meta robots no-index
The robots.txt file and HTML tag can be used to control the behavior of search engine crawlers. Both have different...
Prefer using Dir.mktmpdir when dealing with temporary directories in Ruby
Ruby's standard library includes a class for creating temporary directories. Similar to Tempfile it creates a unique directory name...
Rails: Comparison of Dates - before? and after?
tl;dr Since Rails 6+ you can use before? and after? to check if a date/time is before or after...
Careful: `fresh_when last_modified: ...` without an object does not generate an E-Tag
To allow HTTP 304 responses, Rails offers the fresh_when method for controllers. The most common way is to pass...
JSON APIs: Default design for common features
When you build a JSON API you need to come up with a style to represent attributes, pagination, errors or...
CSS: :is() pseudo selector
tl;dr The :is() pseudo selector - specificity of its most specific argument - matches against a comma-separated list of selectors...
CSS: :where() pseudo selector
tl;dr The :where() pseudo selector - zero specificity - matches against a comma-separated list of selectors. Example Compound selectors like...
Generating and streaming ZIP archives on the fly
When your Rails application offers downloading a bunch of files as ZIP archive, you basically have two options: