...or every even-numbered item. However, :nth-child can do more. In modern CSS specifications (Level 4), there’s an additional feature that lets you use :nth-child in combination...

...with a list of css selectors. This way, you can target the nth-child within a subset of siblings matching a selector. For example: .container .foo %span.my-selector .bar

...set the Sass options. Webpacker const sassLoaderConfig = environment.loaders.get('sass') const sassLoaderIndex = sassLoaderConfig.use.findIndex(config => { return config.loader === 'sass-loader' }) // Disable deprecation warnings inside dependencies sassLoaderConfig.use[sassLoaderIndex].options.sassOptions.quietDeps = true sassLoaderConfig.use[sassLoaderIndex].options.sassOptions.silenceDeprecations = ['import...

module.exports = { module: { rules: [ { test: /\.s[ac]ss$/i, use: [ "style-loader", "css-loader", { loader: "sass-loader", options: { sassOptions: { quietDeps: true, silenceDeprecations: ['import'], }, }, }, ], }, ], }, }; ESBuild esbuild.build({ // ... plugins: [ sassPlugin({ quietDeps: true, silenceDeprecations...

Update: This is now documented on Edgeguides Ruby on Rails: If you set the :validate option to true, then associated objects will be validated whenever you save this...

...default, this is false: associated objects will not be validated when this object is saved. Setup # post.rb class Post < ActiveRecord::Base has_one :attachment end # attachment.rb class Attachment < ActiveRecord::Base...

morris-photographics.com

Some browsers render PNG images with color profiles and other shenanigans, some don't. The cleanest way to have consistent colors across browsers is to convert all your images to...

...a standard color profile, strip the image's original profile and attach the standard profile. If you can't be bothered to convert color profiles, a quicker (but less effective...

Detecting if a Javascript is running under Selenium WebDriver is super-painful. It's much easier to detect the current Rails environment instead. You might be better of checking against...

...the name of the current Rails environment. To do this, store the environment name in a data-environment of your . E.g., in your application layout: <html data-environment=<%= Rails.env %>>

...for an option like Yarn's --frozen-lockfile which validates that. Here is what seems to be the way to do it. Using npm clean-install Running npm clean-install...

...versions while npm clean-install will complain. You can use npm ci as a shortcut for npm clean-install. Combine with a cache The idea of a "clean install" is...

When using Rails to truncate strings, you may end up with strings that are still too long for their container or are not as long as they could be. You...

...did not use it. Since Firefox 7 you can! Note that this only works for single-line texts. If you want to truncate tests across multiple lines, use a JavaScript...

Whenever you have to deal with randomness in a jasmine test there are some spy strategies to help you out! Let's say we have a method Random.shuffle(array) to...

...shuffle an array randomly and a class that uses shuffle within the constructor. returnValue & returnValues it('shuffles the array', () => { spyOn(Random, 'shuffle').and.returnValue([3, 2, 1])

...window manager that provides neat features like automatic layouting of windows, good multi-display support with per display workspaces and more. Since it is only a window manager, you will...

...menus, automatic updates etc. Fortunately, you can run Awesome within MATE, by following these steps (tested on Ubuntu MATE 16.04): Awesome + MATE Create the following file at /usr/share/xsessions/Xsession.desktop: [Desktop Entry...

...popup on all browsers. When you integrate a date picker popup, remember to also set autocomplete="off" on the text input that opens the calendar on click. Otherwise the autocomplete...

...suggestions will cover the calendar box and make it unusable: If you are using a tool like Unpoly you might want to set autocomplete="off" in the JavaScript that also...

makandra dev

...they reach approx. 100MB: $ ls -lh log/ -rw-r--r-- 1 user group 55M Sep 15 09:54 development.log -rw-r--r-- 1 user group 101M Aug...

...development.log.0 This behavior is a built-in feature of Ruby's standard Logger class, which Rails uses by default. To control the maximum file size, set config.log_file_size...

To set a cookie in your test browser for cucumber tests, you need to know which driver you are using. Use the step below according to your driver.

...to "([^\"]+)"$/ do |key, value| headers = {} Rack::Utils.set_cookie_header!(headers, key, value) cookie_string = headers['Set-Cookie'] Capybara.current_session.driver.browser.set_cookie(cookie_string) end Note that Rack::Utils is only used to...

Native promises have no methods to inspect their state. You can use the promiseState function below to check whether a promise is fulfilled, rejected or still pending: promiseState(promise, function...

// `state` now either "pending", "fulfilled" or "rejected" }); Note that the callback passed to promiseState will be called asynchronously in the next microtask. Usage example: Tests Note Since this card...

Somewhat regularly, you will need to filter a list down to some items and then map them to another value. You can of course chain map and compact, or select/filter...

...if i.even? }.compact => [4, 8, 12] or >> [1, 2, 3, 4, 5, 6].select(&:even?).map { |i| i * 2 } => [4, 8, 12] you can just do...

Select2 is a fantastic library for advanced dropdown boxes, but it depends on jQuery. Alternatives Tom Select There is a selectize.js fork called Tom Select. It is well tested, comes...

...with Bootstrap 3, Bootstrap 4 and Bootstrap 5 styles and is easy to use. You might miss some advanced features. Known issues: Dynamic opt-groups in AJAX requests are not...

regular-expressions.info

...ae]y => grey or gray => but NOT graay or graey [0-9] matches a SINGLE digit in the range from 0 to 9 [0-9a-fA-F] hexadecimal digit...

...with caution. Mostly you'll want to use it for small expressions, e.g. for nested sub-regexes. For more details have a look at the card on quantifier modes.

Most of the time, when you are interested in any log output, you see the logs directly on your console or you tail / grep some logfile in a separate terminal...

...In rare cases it's helpful to redirect the Logger output temporary to e.g. STDOUT. Rails.logger = Logger.new(STDOUT) ActiveRecord::Base.logger = Logger.new(STDOUT) User.save! #=> D, [2025-09-08T11...

When you have string contents (e.g. a generated binary stream, or data from a remote source) that you want to store as a file using Carrierwave, here is a simple...

While you could write your string to a file and pass that file to Carrierwave, why even bother? You already have your string (or stream). However, a plain StringIO...

...t easily customizable. Example usage /slackfont Comic Neue to use "Comic Neue" (if installed) /slackfont system-ui to use your desktop's system font in Slack. /slackfont (without an argument...

...the default font. Some fonts may be unavailable If you installed Slack through Snap, only system-wide installed fonts (i.e. fonts located in /usr/share/fonts/ or /usr/local/share/fonts/) are available.

...to run JS tests. Given a Vue project that uses Jest (via vue-cli-service) with the following package.json: { "scripts": { "test": "vue-cli-service test:unit --testMatch='**/tests/**/*.test.js' --watch...

...allows us to run Jest tests with yarn test. The only downside of this setup is that debugger statements are ignored with the CLI approach - there are no Browser Devtools...

Starting Terminator with split screens is quite simple: Just store a layout and start Terminator with the --layout option. However, if you want to run custom commands in your terminals...

...command exits. You accomplish this by tweaking bash to run a command before actually starting. Pimp your .bashrc Add this to the end of .bashrc: # hack to keep a bash...

atlassian.com

Git log offers useful options for filtering. This card provides a short overview. By message Only commits that include a specific string in their commit message git log --grep="tracker...

By file Only commits that introduced changes to a specific file git log -- foo.rb bar.rb Note In case the file was renamed or moved the --follow option can be...

...Before merging back: reinstate reverted features in a temporary branch, then merge that branch. Scenario Consider your team has been working on several features in a branch, made many changes...

...fix them, if necessary. Maybe tests were added that expect the removed functionality as a side-effect. Merge the master into your branch regularly, especially when you have multiple teams...

open-ui.org

tl;dr When browsers start to adapt proposals from Open UI, it might not be necessary to use any 3rd party libraries to have nice components and controls in web...

...applications e.g. selects. It would require only a minimum of CSS and Javascript to get them working and looking good. The purpose of the Open UI, a W3C Community Group...