When configuring prometheus scrape_configs, you may use relabel_configs to filter your metrics or change some fields. Your config...
When using virtual attributes, the attached trait can be useful to automatically copy errors from one attribute to another.
...live: true, host: '127.0.0.1' do watch(%r(^public/assets/esbuild_error_development\.txt$)) # Livereload + ESbuild is not the best combo # We want # - to reload CSS files without doing a full page reload
...this.lockCounter = 0 this.boundLockTurboStreamRendering = this.lockTurboStreamRendering.bind(this) this.boundStartLock = this.startLock.bind(this) this.boundStopLock = this.stopLock.bind(this) // Stream rendering document.addEventListener("turbo:before-stream-render", this.boundLockTurboStreamRendering) // Form submission document.addEventListener("turbo:submit-start", this.boundStartLock) document.addEventListener("turbo:submit-end...
...this.boundStopLock) // Network activity document.addEventListener("turbo:before-fetch-request", this.boundStartLock) document.addEventListener("turbo:before-fetch-response", this.boundStopLock) document.addEventListener("turbo:fetch-request-error", this.boundStopLock) // Frame rendering document.addEventListener("turbo:before-frame-render", this.boundStartLock) document.addEventListener...
Apply Test Driven Development(TDD) to the process of building container images by defining test before writing code and automate...
First find the reference for the entry you want through looking at the stash: $ git stash list stash@{0}: WIP...
To avoid multiple versions of a package, you can manually maintain a resolutions section in your package.json. We recommend you...
Ruby lets you re-use existing RegExp objects by interpolating it into new patterns: locales_pattern = /de|en|fr|es/i...
Our development process makes us deploy very often. As the number of releases grows, junk clogs up the hard drive...
...logged in the CRI log format. This means that every line of the log becomes a JSON object containing additional metadata. According to the fluent-bit docs there is currently...
Ubuntu 18.04 uses systemd to manage services. There are basically two commands for listing all services and manipulating the state...
...seconds, it took from the start until the file transfer was just about to begin. This includes all pre-transfer commands and negotiations that are specific to the particular protocol...
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.
...Powerless but nothing was raised No power to ['creatable_cards'] The reason for this behavior is that the Capybara test server is running in another thread, and the RSpec thread...
We use the whenever gem to automatically update the crontab of the servers we deploy to. By default, whenever will...
On Chrome, Firefox and modern Safari, document.scrollingElement will return the element. The behavior varies on legacy browsers that we no longer support: Old Safari versions, document.scrollingElement will return...
Sometimes you might need to nest a git-project inside another git-project. The right strategy is to use submodules...
Short reference on how to quickly debug the vanilla Rails job adapters. Queue Adapters by Environment Environment Adapter
You can use git worktree to manage multiple working trees attached to the same repository. But why should I use...
...line-height is font-size relative, but the problem is that font-size: 100px behaves differently across font-families, so is line-height always the same or different? Is it...
Action Mailer Basics and Previews Chapter "Task H1: Sending Confirmation Emails" from Agile Web Development with Rails (in our...
Capybara has a variety of finder methods like find_button to help you look up DOM elements. There are also...
...other methods within the Method class are useful for advanced metaprogramming, though this is beyond the scope of this card. Also see Ruby: Finding where a method is defined
...you can use a special form options helper called #collection_check_boxes. It behaves similar to #collection_select, but instead of a single select field it renders a checkbox and...