Using ActiveRecord's #signed_id and .find_signed methods you can create URLs that expire after some time. No conditionals or additional database columns required...
We usually ship applications that self-host webfonts to comply with GDPR. Many popular web fonts are available as NPM packages provided by Fontsource. We recommend using those instead of...
...downloading and bundling font files yourself. (See below for a list of benefits.) Usage Go to fontsource.org and search for the font you want to add (or a font that...
Sometimes huge refactorings or refactoring of core concepts of your application are necessary for being able to meet new requirements or to keep your application maintainable on the long run...
...different parts. Try to make tests green for each part of your refactoring as soon as possible and only move to the next big part if your tests are fixed...
...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...
Getting started with Claude Code is super simple. Once you've made yourself familiar with it, you may want to improve your workflow. Here are a few quick tips that...
...are relevant to most users. Keyboard Shortcuts There are lots of keyboard shortcuts. Here are the most relevant ones. Insert a Newline To add a newline without submitting your prompt...
...translation data {...
...} can not be used with :count => 1. key 'one' is missing. They seem to appear out of the blue and the error message is more confusing than helpful...
...all models on the activerecord.attributes level (or activemodel.attributes) instead of having the same translation string in each model's attribute block: # I18n file like en.yml en: activerecord: attributes: updated_at...
AuthExternal pwauth Require group admin You need to first install libapache2-mod-auth-sys-group. You don't get any error message if you haven't installed it but...
...it doesn't work. sudo apt-get install libapache2-mod-auth-sys-group
...full trace reveals that ActionPack's action_controller/integration.rb is breaking while doing this: cookies = @headers['Set-Cookie'] cookies = cookies.to_s.split("\n") unless cookies.is_a?(Array) cookies.each do |cookie| name, value = cookie.match...
...happened for me. That is how my cookie looked when debugging: (rdb:1) puts headers['Set-Cookie'] remember_token=abcdef123456; path=/; expires=Mon, 31-Dec-2029 23:03:29 GMT...
There are cases when you need to select DOM elements without jQuery, such as: when jQuery is not available when your code is is extremely performance-sensitive
...an entire HTML document (which is hard to represent as a jQuery collection). To select descendants of a vanilla DOM element (i.e. not a jQuery collection), one option is to...
This card will show you how to use git rebase --onto without confusion. Use case You've got two feature branches (one and two), where two depends on one. Now...
...branched two from it (i.e. after code review the commits of branch one are squashed). Thus the commit history of branch one has changed. Branch two's history however didn...
DirectUpload allows you to upload files to your file storage without having to wait for the form to submit. It creates AJAX requests to persist the file within your form...
...and wraps them in a little API. This card will show you how to use it in order to create in-place file uploads with progress and a remove button...
...to know them all, but we recommend Option 0 or Option 1. Option 0 (recommended): Sub-query with conditions from a scope You may also pass the existing User.active scope...
...the joined table: Post.where(user: User.active) This will make a single query. It uses a sub-query, which is slow in MySQL, but fast in PostgreSQL: SELECT * FROM posts WHERE...
Sometimes it might be helpful to have a version history for a gem, e.g. when you want to see if there is a newer Rails 2 version of your currently...
At first you should search your gem at RubyGems. Example: will_paginate version history. The "Tags" tab at GitHub might be helpful as well...
Use this MySQL command to show further info about a table: SHOW CREATE TABLE tags; This will output a table schema like this: CREATE TABLE `tags` ( `id` int(11) NOT...
SELECT pg_size_pretty(pg_database_size('some-database')); Example SELECT pg_size_pretty(pg_database_size('cards_p')); ---------------- 13 GB (1 row) SELECT pg_database_size('cards_p');
------------------ 13524832927 (1 row) Related PostgreSQL: Show size of all databases PostgreSQL: How to show table sizes
A flaky test is a test that is often green, but sometimes red. It may only fail on some PCs, or only when the entire test suite is run.
...JavaScript periodically requests updates from a server to keep a in sync with the latest server-site data. Sometimes the test ended right after a polling request was sent, but...
...project, as a developer you need to follow the following guidelines (e.g. by using something like this issue checklist template). In order to reduce the number of rejects we get...
...from clients, we want to review all code written before it goes to the staging server. Note This process is tailored to our specific needs and tools at makandra. While...
...of pain like me, you can get to Xfce's native window manager by saying: xfwm4 --replace
You are not using javascript tests The file is served from a public folder (not via controller) Problem description If you deliver files from a public folder it might...
...be that the Content-Disposition header is not set. That's why the following spreewald step might raise an error: Then I should get a download with filename "..." expected: /filename...
...Ruby. def and define_method differ in which one they use. def Ruby keyword, starts a method definition Opens a new, isolated scope. Variables defined outside are not accessible inside...
...and vice versa. Defines an instance method on the receiver (specified before the method name, e.g. def object.foo); implicit receiver is the default definee The default definee is not self...
SVG files often contain redundant information, like editor metadata or hidden elements. When esbuild handles your static assets, you can easily optimize SVG files using svgo as a plugin. Here...
...is how to do it. Adding svgo as an esbuild plugin Add the svgo package to your project's package.json Adjust your esbuild.config.js like so: const esbuild = require('esbuild')
Database connections are not thread-safe. That's why ActiveRecord uses a separate database connection for each thread. For instance, the following code uses 3 database connections: 3.times do
...a new connection end end These three connections will remain connected to the database server after the threads terminate. This only affects threads that use ActiveRecord. You can rely on...
...a request, you want to keep track of how much of the runtime was spent waiting on it, how many calls it took, and the ratio of input to output...
...catches prompt bloat, runaway tool-call loops, and regressions from model changes just by scrolling the log. The same pattern applies to any slow external API you want visibility on...
If you want to know your public key's fingerprint, do this: ssh-keygen -lf ~/.ssh/my.key.pub This may be necessary to authenticate your key on GitHub because of recent events...
...them (to pull etc): ERROR: Hi foobear, it's GitHub. We're doing an SSH key audit. Please visit https://github.com/settings/ssh/audit/... to approve this key so we know it...