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

...above). Paste this: #!/bin/bash exec < /dev/tty # Get the current branch name branch_name=$(git branch --show-current) # Get the name of the branch that was just merged reflog_message=$(git...

blog.bigbinary.com

...behavior, you can explicitely tell ActiveRecord how to preload associations with either JOINs or separate queries. This card gives an overview of the different options to preload associations, but

...for preloading! Please have a look on on our card why you should be super careful with complex eager_load or includes queries. Thus, as a general guideline.includes or .eager...

...applications can be used by multiple users at the same time. A typical application server like Passenger has multiple worker processes for a single app. In a distributed deployment setup...

...like we use at makandra you will even have multiple application servers, each with their own worker pool. This means that your code needs to deal with concurrent data access...

...some behavior you may eventually run into when upgrading your application. This aims to save you some time understanding what happens under the hood to possibly discover problems faster as...

...renamed to denylists. You will have to rename all occurrences in your code. Make sure that you have defined a trait for validating the extensions and content types in all...

Here is a bash script that I use to auto-configure displays on Ubuntu 24.04 with Xorg. Background Ubuntu always sets the primary display to the 1st (i.e. internal) display...

...bottom-aligned (the default would be aligned at their top edges). As an oddly specific bonus (you may not need this), I adjust my internal display's resolution when connected...

github.com

Scroll and touch event listeners tend to be computationally expensive as they are triggered very often. Every time the event is fired, the browser needs to wait for the event...

...quoted from WICG's explainer on passive event listeners. See this demo video for a side-by-side comparison. While there are particular scenarios where an author may indeed want...

...for gems allows to add metadata to your gem, some of which have a special meaning and are helpful for users. You can provide links to your Github bugtracker or...

...file that are then used on the rubygems page of your gem (in the sidebar, e.g. see gem page of consul). Here are some keys that should be filled:

...implementation changes. The information below is validated for the current list of browsers we support. By default your html and body elements are only as high as the actual page...

...html and body elements will only be around 40 pixels high, regardless of the size of your browser window. You might be surprised by this, since setting a background on...

...browser trust the certificate so it does not show warnings for your own certificate. Easy: self-signed certificate To just create a certificate for localhost, you can use the following...

...can then access your application at https://localhost:3000/. Your browser will complain about the self-signed certificate, but you can ignore the warning in that case, since you are...

The git doc states on the difference of these two commands: git-restore[1] is about restoring files in the working tree from either the index or another commit. This...

...The command can also be used to restore the content in the index with --staged, or restore both the working tree and the index with --staged --worktree. By default, if...

...Saving files to a directory that is not shared between deploys or servers If you save your uploads to a made up directory like "RAILS_ROOT/uploads", this directory goes away...

...after every deploy (since every release gets a new). Also this directory is not shared between multiple application servers, so your uploads are randomly saved to one local filesystem or...

We recommend configuring Selenium's unhandled prompt behavior to "ignore". When running tests in a real browser, we use Selenium. Each browser is controlled by a specific driver...

...e.g. Selenium::WebDriver::Chrome for Chrome. There is one quirk to all drivers (at least those following the W3C webdriver spec) that can be impractical: When any user prompt (like...

...desktop users may encounter some weird quirks: Aside from allowing only digits and decimal separators, an "e" is also allowed (to allow scientific notation like "1e3"). Non-technical users will...

...be confused by this. Your server needs to understand that syntax. If it converts only digits (e.g. to_i in Ruby) you'll end up with wrong values (like...

Event delegation is a pattern where a container element has a single event listener that handles events for all descendants that match a CSS selector. This pattern was popularized by...

...element was clicked!") }) This technique has some advantages: When you have many descendants, you save time by only registering a single listener. When the descendants are changed dynamically via JavaScript...

...has to decide whether and how to do authorization. The usual approaches are: Using send_file with a regular controller. This is secure, but potentially slow, especially for large collections...

...This is fast (because Apache can deliver assets without going through Rails), but less secure. When going with the "unguessable URL" approach, it is possible to somewhat increase security by...

When building an application that sends e-mails to users, you want to avoid those e-mails from being classified as spam. Most obvious scoring issues will not be relevant...

...to you because you are not a spammer. However, your application must do one thing by itself: When sending HTML e-mails, you should include a plain-text body or...

Both knapsack and parallel_tests have the option to split groups by historic execution time. The required logs for this might be outdated since you manually have to update and...

...consistently up to date with no extra effort locally and/or remotely. How to always split by execution logs Parallel Tests The parallel_tests gem has the option flag --group-by...

makandra dev

...handy when values have an implicit ordering. Let's imagine a record Issue(criticality: string). criticality should have the following three possible values: critical, medium, low. Sorting with Issue.all.order(criticality...

...critical' issue This happens because the database column backing the criticality attribute is a string and PG will use a collation to determine the result of comparisons. In most collations...

Most forms have a single submit button that will save the record when pressed. Sometimes a form needs additional submit buttons like "accept" or "reject". Such buttons usually attempt...

...a state transition while updating the record. To process a form with multiple buttons, your server-side code will need to know which button was pressed. To do so you...

To make CSS rules dependent on the screen size, we use media queries: @media (max-width: 500px) { // rules for screen widths of 500px or smaller } Browsers will automatically enable and...

...disable the conditional rules as the screen width changes. To detect responsive breakpoints from JavaScript, you may use the global matchMedia() function. It is supported in all browsers:

Browsers come with a set of built-in elements like or . When we need a new component not covered by that, we often build it from and tags. An alternative...

...Custom elements will be ignored for the purposes HTML validation, but their children will still be validated. Styling new elements Browsers will give unknown elements a default style of display...

jsfiddle.net

When you need test images, instead of using services like lorempixel or placehold.it you may generate test images yourself. Here we build a simple SVG image and wrap it into...

...a data: URI. All browsers support SVG, and you can easily adjust it yourself. Simply set it as an image's src attribute. JavaScript Simple solution in modern JavaScript, e.g...

When debugging slow SQL queries, it’s helpful to understand the database engine's query plan. Whenever you execute a declarative SQL query, the database generates a "query plan" that...

...outlines the exact steps the engine will take to execute the query. Most of the time, we don’t need to worry about this plan because SQL engines are highly...

...exception, Rails will look at the exception's class and choose an appropriate HTTP status code and error page for the response. For instance, an ActiveRecord::RecordNotFound will cause Rails...

...render a red "The page you were looking for doesn't exist" with a status code of "404" (not found). The mapping from exception classes to error types is a...