This is an attempt to list some of those things: On the server Always optimize: Don't do stupid things with the database. Avoid "n + 1" queries. Don...

...Use form models. Optimize on demand: Don't optimize without knowing what's actually slow. Measure first, for example by using a performance monitoring tool like NewRelic, Scout, AppSignal, Skylight...

...is hard coded. A popular example is extension_allowlist, which returns an array of strings and let's you only upload files that have a filename with an extension that...

...matches an entry in that array. Another useful validation can be size_range, which gives you a little bit of control over how your storage gets polluted.

Spreewald comes with a selector_for helper that matches an English term like the user's profile into a CSS selector. This is useful for steps that refer to a...

...particular section of the page, like the following: Then I should see "Bruce" within the user's profile ^^^^^^^^^^^^^^^^^^ If you're too lazy to manually translate English to a CSS...

makandra dev

This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the ActiveRecord ORM used with Ruby on Rails, but the techniques...

We will be using this example tree (from the acts_as_nested_set docs): root | +-- Child 1 | | | +-- Child 1.1 | | | +-- Child 1.2 | +-- Child 2 | +-- Child 2.1 | +-- Child 2.2

...update your window title whenever you switch directories, simply specify a PROMPT_COMMAND environment variable. set-window-title() { echo -en "\033]0;$(pwd | sed -e "s;^$HOME;~;")\a" } if [[ "$PROMPT...

...COMMAND" ]]; then export PROMPT_COMMAND="$PROMPT_COMMAND;set-window-title" else export PROMPT_COMMAND=set-window-title fi You may put that into your ~/.bashrc to persist and automatically activate...

...number of different versions for Ruby, Rails and many gems. To be able to switch between projects easily, we must control every dependency our applications has. Goals Understand what a...

...with their dependencies and version history. Bundler overview and workflow How to update a single gem conservatively: A major bundler caveat How to manage versions in a Gemfile

github.com

The maintenance mode is enabled on all application server as soon as the file /public/system/maintenance.html is present. Installation Add this line to your application's Gemfile: gem 'capistrano...

...application's web interface by writing a #{maintenance_basename}.html file to each web server. The servers must be configured to detect the presence of this file, and if it...

Code splitting is a feature of esbuild that can keep huge libraries out of the main bundle. How code splitting works Like Webpack esbuild lets you use the await import...

...code on demand: // application.js const { fun } = await import('library.js') fun() However, esbuild's code splitting is disabled by default. The code above would simply inline (copy) library.js into application.js:

Note: Consider using MATE instead of Gnome 3 on newer system Awesome is a very good tiling window manager that provides neat features like automatic layouting of windows, good multi...

Improve your font-rendering Copy /etc/xdg/awesome/rc.lua to ~/.config/awesome/rc.lua. Take a look, it's pretty self-explanatory. You can instantly apply changes by reloading Awesome with Meta-Ctrl-R.

Stepping forward from JavaScript Basics, the goal of this card is for you to be able to read and write more complex ES6+ code. The JavaScript Object Model

...s also a video of that talk in our internal library. The first three sections of the article Inheritance and the prototype chain on mdn also gives a good introduction...

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

...the everyday use without any parameter tweaking I'm using a collection of tiny scripts in my ~/bin folder that can then be used as bash functions. And: It's...

...video-to-audio /path/to/cake.mp4 cake.mp3 audio-to-audio /path/to/cake.mp3 cake.aac image-to-image /path/to/cake.png cake.jpg stateDiagram-v2 text --> image: Dall-E 3 text --> audio: GPT TTS image --> text: GPT Vision...

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

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

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

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

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

In this card we will learn to write code that scales with a large number of database records. We will do this by pushing work out of Ruby and into...

...a scope of movies matching the following query format: The query is a list of space-separated words that all need to appear in the movie title for the movie...

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

...you want to automatically delete old container images from your Elastic Container Registry, the solution is a quite simple ECR Lifecycle Rule that deletes images e.g. 7 days after they...

...is a floating tag always associated with the image currently deployed to production, the situation suddenly is not so simple any more. ECR does not provide a keep action in...

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

...rails_performance (https://github.com/igorkasyanchuk/rails_performance) provides a lot of valuable information with very little setup cost. It only needs Redis which we use in the majority of our applications anyway...

Only problematic requests (> 500 ms) Longer history than "Recent requests" The "500 Errors" screen self-explanatory and hopefully always empty The "Custom Events" screen Let's you easily add...

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

...JavaScript for both lists? For this your JavaScript must be abstract enough to not contain screen-specific references (such as selectors or URLs). Note that it's OK for the...