Sometimes you need to access a dev server running on localhost from another machine that is not part of the...

TL;DR When using Cache-Control on a Rails application, make sure the Vary: Accept header is set.

makandra dev

Field error steps Spreewald's The...

...field should have an error and The...

...field should have the error...

...steps now...

umaar.com

Similar to the Webpack Bundle Analyzer, Chrome's new Lighthouse feature … … shows a visualisation of your JavaScript bundles. It's...

makandra dev
stackoverflow.com

Modern versions of Capybara include a finder method #ancestor which allows you to find a parental element using CSS or...

Jasmine is a great way to unit test your JavaScript components without writing an expensive end-to-end test for...

A flaky test is a test that is often green, but sometimes red. It may only fail on some PCs...

makandra dev

If you want Sidekiq to be able to talk to Redis on staging and production servers, you need to add...

makandra Curriculum

Basic validations Read the Rails Guide on ActiveRecord Validations. You should have an overview which kinds of validations are built...

makandra dev

The gem better_errors offers a detailed error page with an interactive REPL for better debugging. I had the issue...

makandra dev

Inspired by recent "git shortcut" cards I figured it would be nice to have one of these for rebasing a...

Sometimes a link or input field has no visible label. E.g. a text field with a magnifying glass icon 🔎 and...

The RSpec matcher tests if two HTML fragments are equivalent. Equivalency means: Whitespace is ignored Types of attribute quotes are...

We are using Spring in our tests for sequential test execution but not for parallel test execution. And Rails requires...

github.com

age is a simple, modern and secure file encryption tool, format, and Go library. It features small explicit keys, no...

Given you have a strict CSP that only allows elements from your own domain: Content-Security-Policy: script-src 'self' This will block JavaScript handlers inlined as attribute into your HTML elements. Clicking on the following link will only log an error with a strict CSP: click me click me Solution 1: Move the handler into your JavaScript The recommended solution is to move the handler from the HTML to the allowed JavaScript file that we loaded via . In the example above we could invent a new [data-alert] attribute with the alert message: click me Then our JavaScript intercepts clicks on elements with that attribute: document.addEventListener('click', function(event) { let link = event.target.closest('[data-alert]') if (link) { let message = link.dataset.alert alert(message) event.preventDefault() } }) Solution 2: Allow that one handler in your CSP Some browsers allow the CSP directive script-src-attr. This lets you allow the hashes of actual JavaScript code. The SHA256 hash of alert('hello') is vIsp2avtxDy0157AryO+jEJVpLdmka7PI7o7C4q5ABE= (in Base64). We can allow this one event handlers like this: Content-Security-Policy: script-src 'self'; script-src-attr 'unsafe-hashes' 'sha256-vIsp2avtxDy0157AryO+jEJVpLdmka7PI7o7C4q5ABE=' Note the sha256- prefix. This event handler now works when clicked: click me But any other script will still be blocked: click me Dealing with legacy browsers Currently (November 2023) about 75% of browsers support script-src-attr. Here is a forward-looking compromise that many users use with new CSP features: Have a liberal CSP with old directives supported by all browsers Make your CSP stricter with new, more specific directives for browsers that support it The CSP spec supports that approach in that using newer, more specific directives disable older, more general features. In our case this means: For old browsers, allow all inline scripts For new browsers, disallow inline scripts but allow inline handlers with given hashes Here is a CSP directive that works like this: Content-Security-Policy: script-src 'self' 'unsafe-inline'; script-src-elem 'self'; script-src-attr 'unsafe-hashes' 'sha256-vIsp2avtxDy0157AryO+jEJVpLdmka7PI7o7C4q5ABE=' Old browsers will only use script-src. New browsers will use script-src-elem (for tags) and script-src-attr (for inline event handlers), which override the more liberal rules from script-src.

We had a card that described how to install multiple mysql versions using mysql-sandbox. Nowadays with the wide adoption...

Our gem spreewald supports a few helpers for development. In case you notice errors in your Cucumber tests, you might...

If you want to expand your Areca Raid by swapping out the disks for larger ones you will need to...

When using custom properties in your stylesheets, you may want to set a specific property value to an existing variable...

It seems like changing the HTTP_ACCEPT_LANGUAGE is not possible for a headless chrome. On Ubuntu the headless Chrome...

You can throttle the network in your headless chrome via Selenium. This might be useful for debugging issues with flaky...

peter.sh

An extensive list of command line options when booting Chrome. This is useful for building a Capybara driver with custom...

blog.cloudflare.com

What is netfilter's Connection Tracking system? The connection tracking system often referenced as nf_conntrack is part of the...