Performing COUNT(*) on large tables is slow. Sometimes you don’t need the exact number once results exceed a certain...

...all Unpoly updates work using AJAX requests, you won't get the more detailled better_errors page with the interactive REPL. Below is an event listener that automatically repeats the...

...full CSS and JavaScript. The code assumes you are using Ruby on Rails with better_errors, which is the default error view that modern Rails versions employ. If you are...

makandra dev

...changes you make to the database will be rolled back on exit. Warning Changes beyond the database (deleting files, sending emails, etc) cannot be rolled back...

postgresql.org

TL;DR PostgreSQL handles Rails 4+ text and string columns the same. Some libraries may still reflect on the column...

github.com

The parallel-gem is quite easy to use and can speed up rendering time if you want to render the...

...shared_examples_for can have parameters. You can simply hand over arguments from it_behaves_like: shared_examples_for 'string equaling another string' do |expected_string| it 'is equal to...

...subject).to eq(expected_string) end end describe 'some string' do subject { 'foo' } it_behaves_like 'string equaling another string', 'foo' end RSpec 1 Use it_should_act_like from...

Capybara provides execute_script and evaluate_script to execute JavaScript code in a Selenium-controlled browser. This however is not...

When users type into a Tom Select control, the options list is updated with a short delay which can feel...

In a web application you sometimes have tasks that can not be processed during a request but need to go...

When HTTP clients make an request they can define which response formats they can process. They do it by adding...

I encountered a unlucky behavior of byebug 11.1.3 (the most recent version at time of writing) when using it with Rails 6 and it's new autoloading component, zeitwerk. There...

Rails' url_for is useful for generating routes from a Hash, but can lead to an open redirect vulnerability.

For Rails models where only one of multiple attributes may be filled out at the same time, there is no...

There is no one-liner in Ruby or ActiveSupport with the behavior described above. There have been discussions about adding a method like Enumerable#find_map:

When two classes implement the same behavior (methods, callbacks, etc.), you should extract that behavior into a trait or module. This card describes how to test that extracted behavior without...

...repeating yourself. Note that the examples below use Modularity traits to extract shared behavior. This is simply because we like to do it that way at makandra. The same techniques...

Building application assets with esbuild is the new way to do it, and it's great, especially in combination with...

I recently enjoyed debugging a Cucumber step that tried to be retryable using a patiently block: Then /^"([^"]*)" should( not)? be...

...not scale the icon with the font size. One option that seems to work better is to use the mask CSS feature. The idea is to have an element with...

...var(--icon-url) center / contain no-repeat // this can probably be done in a better way: vertical-align: text-bottom margin-bottom: -.1em // depends on the icons @each $icon in...

This card explains how to generate an entity relationship diagram for your Rails application. We also show how to limit...

Since I use this a lot in my daily work and there were no scripts working properly for me, I...

github.com

...find(..., visible: true) or find(..., visible: :visible). Note that you could change the default behavior by setting the ignore_hidden_elements config option. However, ignoring invisible elements is a useful...

IRB 1.2 (shipped with Ruby 2.7, but works on 2.5+) brings pretty syntax highlighting and multiline cursor navigation. However, pasting...

Modern CSS offers the field-sizing property to allow elements to automatically adjust size (width and/or height) to fit their...

We're always striving towards keeping our website's JavaScript as small as possible. If you're using webpack(er...