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

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

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:

makandra Curriculum

...administrator before publication. Requirements Movies in MovieDB should have one of the following workflow states: draft pending published declined A movie always begins as a draft and then transitions through...

...as it's getting reviewed. This could be a typical state flow for a movie: stateDiagram-v2 [*] --> draft draft --> pending pending --> declined: Reason declined --> pending pending --> published Changes to the...

To get a good overview about load, cpu frequency, temperature sensors, etc. we found s-tui quite useful. It's included in Ubuntu's default repositories: $ sudo apt install...

$ s-tui While it's possible to run s-tui as root for even more information and optionally also make use of stress for benchmarking, those methods did...

Goals Know how to use the native DOM API to do the following: Selecting all elements matching a given CSS selector Selecting all descendants of a given element matching...

...a given CSS selector Registering event listeners Changing an element's CSS classes Changing an element's attributes Making the same change to a list of elements, e.g. hiding them...

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

github.com

Phusion Passenger changed the way how it gets restarted several times. Through the project's history, these all were valid: touch tmp/restart.txt sudo passenger-config restart-app /path/to/app passenger-config...

gem 'capistrano-passenger', require: false Add to your Capfile: require 'capistrano/passenger' Declare which server role should be restarted (optional). Usually passenger tries to restart all servers with the app...

Why secure-only cookies used to be necessary Cookies have an optional secure flag. It tells the browser to not send the cookie for a non-https request.

...users from http:// to https://. The reason was that most users will only enter a scheme-less domain like makandra.de into their location bar, which will default to http://makandra.de...

Understanding your type of cronjob Some cronjobs must only run on a single server. E.g. when you run nightly batch operations on the database, it should probably run on a...

...single server. Running it on multiple servers would likely result in deadlocks or corrupt data. Some cronjobs must always run on all servers. E.g. starting a sidekiq process on reboot...

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

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

Migrating data from a legacy into a new system can be a surprisingly large undertaking. We have done this a few times. While there are significant differences from project to...

...project, we do have a list of general suggestions. Before you start, talk to someone who has done it before, and read the following hints: Understand the old system

...can reset the min-width. Say you have a simple grid layout: .container .first-item .second-item .third-item .container display: grid grid-template-columns: 100px 1fr 100px Your expectation...

...correct as the grid layout will try to do that: +---------+----------------------------+---------+ | | - 10 characters long | | +---------+----------------------------+---------+ However, if .second-item's content is too large to fit into the reserved space, it will...

...latest commits are not ready for production? Then use git merge master~n to skip the n-last commits. Tip A big advantage of merging vs. cherry-picking is that...

In a nutshell: Use git rebase --onto target-branch source-commit target-branch means "branch you want to be based on" source-commit means "commit before your first feature commit...

...Let's say my-feature-branch is based on master and we want it to be based on production. Consider this history: %%{init: { 'gitGraph': {'showCommitLabel': true, 'mainBranchName': 'production'}} }%% gitGraph

The following two hints are taken from Github's Ruby style guide: If your regular expression mentions a lot of forward slashes, you can use the alternative delimiters %r(...), %r...

...complex, you can use the /x modifier to ignore whitespace and comments: regexp = %r{ start # some text \s # white space char (group) # first group (?:alt1|alt2) # some alternation end

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