Let's say you want to find the element with the text hello in the following DOM tree: hello world You might think of XPath's contain() function: page.find(:xpath...
...contains(text(), 'hello') and not (./*[contains(text(), 'hello')])]") With jQuery jQuery has a custom selector :contains() that you can use in the same fashion: $(":contains('hello'):not(:has(:contains('hello...
...just barely wider than the container it should fit into, and it wraps a single word to a new line and it's not really pretty? Cry no more, for...
...in some browsers. When browsers encounter a text-wrapping element with text-wrap: balance style, they will try breaking to a new line sooner, if it balances out the width...
...of passwords for the root user and you prefer using a password for root. Solution Step 1 is getting a root mysql shell that allows us to change user credentials...
...and MySQL since they share names of binaries. sudo systemctl stop mysql sudo mysqld_safe --skip-grant-tables & This starts the mysql daemon in the background and we can now...
The standard way to abort async code is that your function takes a AbortSignal { signal } property. The caller can use this signal to send an abort request to your function...
...with a new DOMException('Message here', 'AbortError') when canceled. This already has good browser support and can be polyfilled on older browsers. Example Here is an async function countDown(). It...
...bug) and want to use git bisect to find out when it was introduced? Smart kid. If you have a shell command ready to reveal if your current state is...
...other hand will use the return value of that call to decide if the state is good or bad. First, start bisecting git bisect start Then tell git which revisions...
You can do so much more than console.log(...)! See the attached link for a great breakdown of what the developer console can give you. Some of my favorites: console.log takes...
E.g. console.log("Current string:", string, "Current number:", 12) Your output can have hyperlinks to Javascript objects E.g. console.log("Check out the current %o, it's great", location)
If validations failed for a record, and you want to find out if a specific validation failed, you can leverage ActiveModel's error objects. You rarely need this in application...
...name (e.g. :blank for :presence, :taken for :uniqueness). You may also use where to see all errors of an attribute: >> user.errors.where(:email) => [#<ActiveModel::Error attribute=email, type=blank, options={}>]
Orca is a Linux screen reader. Since it is part of the GNOME project it should come preinstalled with Ubuntu installations. To turn on the screen reader you can either...
...go to Settings > Accessibility and then activate Screen Reader in the "Seeing" section or you can simply type orca in your terminal. Note It may feel quite strange in the...
Capybara-screenshot can automatically save screenshots and the HTML for failed Capybara tests in Cucumber, RSpec or Minitest. Requires Capybara-Webkit, Selenium or poltergeist for making screenshots. Screenshots are saved...
...into $APPLICATION_ROOT/tmp/capybara. Manually saving a page Additionally you can trigger the same behavior manually from the test using Capybara::Session#save_and_open_page and Capybara::Session#save_screenshot...
Geordi provides a pretty neat way to generate beautiful commit messages according to your stories in Linear: geordi commit Geordi reads from a .geordi.yml file inside your repo and connects...
...to Linear to list started and finished stories with their title. Choosing one of them generates a commit message including id and title from Linear app and a link to...
...or not to gem": Gem is really needed (prefer writing your own code for simple requirements without many edge cases) Gem is tested well (coverage and quality)
...the project requirement Try to avoid gems that do much more than your requirement scope needs Gem has a good maturity and maintenance Gem has a good / familiar DSL
...is just awesome. Install via apt-get or brew. Handy commands t ("tree"): Directory-structure based access. You'll see the current directory annotated with the latest change date and...
...date and author. d ("diff"): Like ENTER on a commit, but arrow keys will scroll the diff! /: Search current view (e.g. commit list, diff). Jump to next hit with n...
Sometimes you need to remove high Unicode characters from a string, so all characters have a code point between 0 and 127. The remaining 7-bit-encoded characters ("Low-ASCII...
...can be transported in most strings where escaping is impossible or would be visually jarrring. Note that transliteration this will change the string. If you need to preserve the exact...
Cucumber up to version 2 had a neat feature called Step Argument Transforms which was dropped in favor of Cucumber 3 ParameterTypes. While I strongly encourage you to drop your...
...keep the exact same functionality of your old Transforms while writing them in the style of new ParameterTypes. Why would I want to keep my Transforms? Transforms allowed you to...
Let's say you have a gem which has the following module: module SuperClient def self.foo 'Foo' end def bar 'Bar' end end For reasons you need to override foo...
...library extensions). Try to avoid it if possible. Add a lib/ext/super_client.rb to your project (see How to organize monkey patches in Ruby on Rails projects) Add the extension, which overrides...
...is much more than a lightweight wrapper around Ruby's net/http. In particular: A single HTTPClient instance can re-use persistent connections across threads in a thread-safe way.
...a custom and configurable SSL certificate store (which you probably want to disable by default) Manages cookies Can make asynchronous requests (spins off a thread internally) Allow to set a...
When your Rails application server raises error, Capybara will fail your test when it clears the session after the last step. The effect is a test that passes all steps...
...behavior will help you to detect and fix errors in your application code. However, sometimes your application will explode with an error outside your control. Two examples: A JavaScript library...
CarrierWave comes with some RSpec matchers which will make testing more comfortable. Let's say you have an Uploader like this: class MyUploader < CarrierWave::Uploader::Base include CarrierWave::MiniMagick
...different versions of your uploaded files: version :small do process resize_to_fill: [100, 100] end version :medium do process resize_to_fit: [200, nil] end version :large do
This is a small example on how you can check if your Postgres index can be used by a specific query in you Rails application. For more complex execution plans...
...it might still be a good idea to use the same path of proof. 1. Identify the query your application produces query = User.order(:last_name, :created_at).to_sql
...you have too many inotify instances you may run into limits of your operating system. To find out which process is using them all up you can run:
To query for identical arrays independent of their order you have to either: Sort both the query and database content. If you're on Rails 7.1 you can use...
...the new normalizes macro for this. This solution would still use any indexes on the column. Check for inclusion in both directions, as implemented by the where_array_matches method...
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...
In RSpec you can tag examples or example groups with any tags you like simply by saying describe ReportCreator, slow: true do # .. end describe ReportCreator do it 'generates reports', slow...
# ... end end You can then only run examples with these tags. rspec --tag slow rspec -t slow # Using the parallel_tests gem rake "parallel:spec[,,--tag slow]"
...is defined incorrectly. Raise the attributes hash given to your :reject_if lambda to see if it looks like you expect. If you are nesting forms into nested forms, each...
...a new parent record together with a new child record and will need to save the parent before you can save the child. You can opt to only show the...