...a minifier that is good enough for most cases. If you're looking to squeeze out as many bytes as possible, you can consider compressing with Terser instead.

...will increase your build times significantly, but produce the smallest output: Terser (3 pass) Terser (1 pass) esbuild application.js 163.6 kB 163.7 kB 181.6 kB application.js (gzipped)

...utilities provided are query methods, user interactions, dom expectations and interacting with components of several frontend frameworks, which allows us to worry less about the details happening in the browser...

...find a necessity to use methods like waitFor, because your code itself may trigger something asynchronous (e.g. animations or setTimeout). Let's see what the docs state on this method...

...text option were able to find nodes based on rendered text, even if it spans over multiple elements in the HTML. Imagine a page that includes this HTML: Hi!

Even though the text is separated by a tag in the HTML, it is matched until Capybara 2 which used to "squish" text prior to the comparison...

...for their gem version, while npm only allows 3 digits and a pre-release suffix. To map gem versions and npm versions, Rails is going to use a naming scheme...

7.0.1.1 7.0.101 7.0.0.rc1 7.0.0-rc1 The old scheme Earlier Rails used the following scheme, which didn't work well with version ranges in your package.json:

...index is not as global as you might think. Actually, it is scoped to a so-called "stacking context". z-indexes only have meaning within their stacking context, while stacking...

...contexts are treated as a single unit in their parent stacking context. This means indices like 99999 should never actually be needed. Creating a new stacking context

stackoverflow.com

Access the Method object Dead simple: Get the method object and ask for its owner: "foo".method(:upcase) # => # "foo".method(:upcase).owner # => String Look up a method's source location...

...Ruby 1.9 adds a method Method#source_location that returns file and line number where that method is defined. class Example; def method() end; end # => nil Example.new.method(:method).source_location...

makandra dev

git shortlog -s -n [commit-range] -n, --numbered Sort output according to the number of commits per author -s, --summary Suppress commit descriptions, only provide commit count [commit-range]

...tagname.. for "everything after that tag" Example output for spreewald: 60 Tobias Kraze 12 Henning Koch 7 Dominik Schöler 6 Thomas Eisenbarth 5 Martin Straub 3 Minh Hemmer...

Using ffmpeg, you can easily re-encode a video to reduce its file size. Command Do it like this: ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset slow -c...

...a copy -movflags +faststart output.mp4 Arguments -i input.mp4 specifies your input file -c:v libx264 specifies H.264 encoding. Use -c:v libx265 for H.265/HEVC. It's an excellent modern encoding...

medium.freecodecamp.com

...tools in the Chrome JavaScript console. Make the whole page editable This is not special to Chrome, but still a clever thing: document.body.contentEditable=true Taking time You can easily measure...

...the time on the console with named timers: console.time('myTime'); // Start timer console.timeEnd('myTime'); // End timer and print the time Reference previously inspected elements (from the Elements panel)

For Selenium tests, your browser starts in your local timezone, or whatever your system's environment specifies. This is usually good enough. To test any timezone-dependent behavior in Chrome...

page.driver.browser.execute_cdp('Emulation.setTimezoneOverride', timezoneId: 'Asia/Tokyo') Important: This change is permanent throughout the browser session. You need to remove the time zone override at the end of each test explicitly...

SimpleForm is a great approach to simplifying your forms, and it comes with lots of well-defined input types. However, the :grouped_select type seems to be overly complicated for...

Consider this example, from the documentation: form.input :country_id, collection: @continents, as: :grouped_select, group_method: :countries While that looks easy enough at a first glance, look closer. The...

makandra dev

YJIT is Ruby's default just-in-time compiler. It is considered production-ready since Ruby 3.2 (source). To activate YJIT you need two steps: Your ruby binary needs to...

...be compiled with YJIT support. You need to enable YJIT. Getting a Ruby with YJIT support We usually install Ruby with tools like rbenv or asdf. This compiles the ruby...

When defining a trait using the Modularity gem, you must take extra steps to define constants to avoid caveats (like when defining subclasses through traits). tl;dr In traits, always...

...define constants with explicit self. If your trait defines a constant inside the as_trait block, it will be bound to the trait module, not the class including the trait...

If you use the selenium-webdriver gem, it will sneakily phone home once every hour whenever you run a browser based feature spec. Check if you're affected

...with Ruby's Time.at.) Opt out You can opt out either globally: # .bashrc export SE_AVOID_STATS=true or project based # spec_helper.rb ENV['SE_AVOID_STATS'] = 'true'

rubyinside.com

...op]=-operators work the same way, but actually they don't. ||= and &&= Those are special cases, because the assignment will only happen if the first variable passes the check (false...

...and true for &&). a ||= b # => a || (a = b) a &&= b # => a && (a = b) But still, if reading a has any side effects, they will take place regardless of to what...

Set profile.password_manager_leak_detection to false in your Selenium Chrome options to disable password leak detection and suppress the warning. Problem When running Selenium tests with recent...

...a data breach…" This alert can break automated test runs, especially in CI/CD pipelines. Solution You can disable Chrome’s password leak detection to prevent this warning from appearing.

github.com

...tasks like filtering large files for arbitrary keywords. When additional context is needed for search results, you might find yourself adding flags like -B5 -A10 to your query. Now, every...

...search result covers 16 lines of your bash. There is another way: You can easily pipe your search results to the VIM editor and cycle through them. Example: Searching for...

...how to add it to your Rails console. Welcome banner Modern versions of irb show a pretty banner which prints IRB version, Ruby version, a random IRB command hint,

How to disable If you prefer not to see this banner, update your ~/.irbrc (or create, if you don't have one yet) and add: IRB.conf[:SHOW_BANNER] = false...

...the method __dir__. Read this card for more information about __FILE__ and __dir__. Example Structure: . ├── bin │   ├── format_changelog ├── CHANGELOG.md bin/format_changelog: #!/usr/bin/env ruby changelog_path = ? # How to get the path to...

Turns out, Cucumber::MultilineArgument::DataTable#diff! caches some stuff. Code of the following form will not work as intended: Then('some table should look like') do |expected_table| patiently do...

...actually patient, will keep failing if it failed the first time end end Instead, simply use expected_table.dup.diff!(actual_table...

...Get number of CPUs of your machine. nproc --all Open up Redis configuration file. sudo vim /etc/redis/redis.conf Find databases row and increase it, e.g. set to 32: databases 32

...and close config file, then restart Redis: sudo service redis-server restart Confirm your configuration has been updated. The following command should return "OK". redis-cli select `nproc --all...

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

...you can use reset: user.posts.reset # discards cache, but does not load anything yet user.posts # SQL query happens to load new state # => [...] Note that reset returns the association/scope. Hence, the above...

...will not seem to work on the Rails console, just because the return value is inspected and thus resolved right away. Try it like this: user.posts.reset; nil # no query

...USERNAME" to be a collision. If you use MySQL this will lead to issues, since string comparisons are case-insensitive in MySQL. (If you use PostgreSQL, read this instead.)

...and "USER", this will not trigger a validation error, but may fail with an SQL error due to duplicate index key. You can change Rails' behaviour, by saying