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...
...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...
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...
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...
Is your application doing something expensive every few seconds? Maybe an animated slider that rotates images? Maybe you are updating data over the network every five minutes? It's a...
...this if the your document tab is not even visible to the user. This saves your user's battery and data plan. You can ask document.visibilityState or document.hidden whether this...
...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...
...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...
...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...
...HTML's accepts a single file. You can allow multiple files via . But sometimes, selecting multiple files is not enough and can be cumbersome for the user. Enter webkitdirectory:
...webkitdirectory switches the browser's file picker to select a directory. All files inside that directory, and inside any nested subdirectories, will be selected for the file input.
...status code 400) |_http-title: 400 The plain HTTP request was sent to HTTPS port | ssl-cert: Subject: commonName=www.makandracards.com/countryName=DE | Not valid before: 2015-10-14T12...
...Not valid after: 2016-10-14T12:42:03+00:00 |_ssl-date: 2016-08-05T11:33:52+00:00; +9d23h48m18s from local time. | tls-nextprotoneg: | h2
When restoring a barman PITR backup you may encounter this error: Copying required WAL segments. EXCEPTION: {'ret': 2, 'err': '/bin/sh: 1: cannot open /var/lib/barman/foopostgres/wals/00000007.history: No such file\n', 'out': ''}
...present in the wals directory of your backup. The most likely reason is that someone deleted this file in the past. If you do not need this file for restoring...
...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...
...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...
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...
...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...
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...
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...
...in coding lies in crafting precise prompts. The main challenge is learning how to structure prompts effectively to guide the model toward accurate results. Further evidence supporting this is the...
...that Aider already writes ~70% of its own code (as of 02/2025). However, when starting out, your results may fall short of efficiently generating large portions of your code with...
As developers we are dealing with many tasks every week. We need a system to organize ourselves. Goals After completing this card you should have: A to-do list that...
...never forget a task that a colleague or customer gives us. A habit of splitting any kind of task or project into actionable first steps. A habit of fully completing...
Although regular expression syntax is 99% interchangeable between languages, keep this in mind: By default, the dot character (".") does not match a line feed (newline, line break, "\n") in any...
...use the /s modifier in Ruby. It changes the RegExp to interpret text as Shift JIS encoded which you probably don't want. Javascript There is no modifier to make...
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...