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

makandra dev

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

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

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')

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

Sometimes you want to find the inverse of an ActiveRecord scope. Depending on what you want to achieve, this is quite easy with Rails 7, and a bit more complicated...

...with Rails 6 and below, or when the inverse scope may contain NULL values. There are two different ways of "inverting a scope": As an example, consider the following model...

xaprb.com

...result is mutual exclusivity that works in a distributed environment, and it’s dead simple to implement. Ruby implementation An implementation as a Rubygem seems to be with_advisory_lock...

...It has support for MySQL, PostgreSQL and SQLite. Unfortunately, it has a horrible caveat in MySQL: With MySQL (at least <= v5.5), if you ask for a different advisory lock within...

When you need the DOM node of a tag (e.g. to read extra attributes, or to modify the DOM near it), you can usually reference it via document.currentScript. However, document.currentScript is unsupported in ancient browsers, like Internet Explorer 11 or wkhtmltopdf's Webkit engine. If you are not running async scripts, you can easily polyfill it: document.scripts[document.scripts.length - 1] It works because document.scripts grows with each tag that was evaluated. That is also the reason why this solution will not work reliably for async code. Demo: https://codepen.io/foobear/pen/poRLxQm

...Rubygems page for your Gem (example). Here are some values you can fill: Gem::Specification.new do |s| s.name = 'my-gem' s.homepage = 'https://github.com/makandra/my-gem' s.metadata = { 'source_code_uri' => s.homepage,

...tracker_uri' => s.homepage + '/issues', 'changelog_uri' => s.homepage + '/blob/master/CHANGELOG.md', 'rubygems_mfa_required' => 'true', } ...

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 element. Custom elements will be ignored during HTML validation, but their children will still be validated. Styling new elements Browsers will give unknown elements a default style of display...

Sentry offers a UI to define custom fingerprint and stack trace rules at https://sentry.io/settings/projects/$project-id/issue-grouping. Fingerprint rules have this syntax: 1 or more key:value conditions, followed by...

...as a wildcard for n characters. Overriding the fingerprint from within the application (with the sentry-ruby gem) You can also set a custom fingerprint from within the application:

makandra dev
stackoverflow.com

...you to find a parental element using CSS or XPath. If you previously did something like this: field.find(:xpath, './ancestor::div[contains(@class, "form-group")]') ..and prefer CSS, you may...

...absence of error end end end Standard validations can be tested with less code The shoulda-matchers gem gives you some RSpec matchers to test the application of standard Rails...

...validations. Under the hood should-matchers uses the same recipe as outlined above (set invalid state, run validations, check for message, etc.), but your tests will have a lot less...

If you need to implement newsletter sending, rapidmail is a solid option. Support is very fast, friendly and helpful, and the initial setup is simple. Since rapidmail works via SMTP...

...you can simply ask the Ops team to configure SMTP credentials for your application. You also do not need to use rapidmail’s built-in newsletter feature. Instead, you can...

makandra dev
github.com

The shell variable PS1 holds your bash prompt. You might want to change it to serve your needs best. Here is how to: General non-printing escape sequences in your...

=> ✔ mycomputer ~/projects/platforms master > _ # Arne's epic timestamped prompt with return status indicator and status-colored (green if fresh, or red if unstaged, or yellow if staged) git branch:

...you know from "How to tell ActiveRecord how to preload associations (either JOINs or separate queries)", you can tell ActiveRecord explicitly if it should use a LEFT OUTER JOIN or...

...a separate query to preload associations. Here is some special case, where a simple includes is not possible. For the diagram below we want to sort the rides by the...

dev.to

...you read this file with the Nokogiri default (DOM) parser, it creates a tree structure with all branches and leaves. It allows you to easily navigate through it via css/xpath...

The only problem is that if you read the whole file into memory, it takes a significant amount of RAM. It is really ineffective to pay for a server...

Pie sometimes does not properly redraw elements upon changes. This often happens when the change comes from somewhere further up the DOM. Consider something like: Active element Inactive element

li .content { -webkit-box-shadow: #666 0px 2px 3px; -moz-box-shadow: #666 0px 2px 3px; box-shadow: #666 0px 2px 3px; behavior: url(/PIE.htc); background: white; } li.active .content...

...by default, effectively allowing anyone to upload an unlimited amount of files to your storage. The DirectUploadController from @rails/activestorage bypasses your form controller because it uploads the file using an...

...AJAX request that runs directly, before any form roundtrip happens. This is a comfortable solution to allow in-form uploads with progress, errors etc. Otherwise, the file would be uploaded...

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

...all the world to admire. For private gems this is very bad. To make sure this cannot happen, rubygems 2.2+ allows you to restrict eligible push hosts: Gem::Specification.new 'my...

...gem', '1.0' do |s| # ... s.metadata['allowed_push_host'] = 'https://gems.my-company.example' end In case you already messed up, follow these instructions to get your gem removed. Of course, it's not...

When you create e.g. a sidebar box that contains headlines and paragraphs, the final paragraph's margin in that box will create an undesired 'bottom padding' inside that box.

...is a Sass mixin that you can apply to such boxes. It makes the last child's bottom margin disappear: =hide_last_margin >*:last-child margin-bottom: 0

makandra dev

git checkout is the swiss army of git commands. If you prefer a semantically more meaningful command for restoring tasks, use git restore instead. With this command you...

... do unstaging - git restore --staged ... discard staged changes - git restore --staged --worktree ... discard unstaged changes - git restore ... restore deleted files - git restore ... restore historic versions - git restore --source