RSpec 1, RSpec 2 To test whether two arrays have the same elements regardless of order, RSpec 1 and 2 give you the =~ matcher: actual_array.should =~ expected_array Rspec 3
...you can choose one of these two matchers: expect(actual_array).to match_array(['1', '2', '3']) expect(actual_array).to contain_exactly('1', '2', '3') Note how match_array...
Example display configuration Screen 0: minimum 8 x 8, current 5760 x 1200, maximum 32767 x 32767 eDP1 connected 1920x1080+0+0 (normal left inverted right x axis...
...y axis) 276mm x 155mm 1920x1080 60.00*+ 59.93 1680x1050 59.95 59.88 1600x1024 60.17 1400x1050 59.98 1600x900 60.00 1280x1024 60.02 1440x900 59.89 1280x960 60.00 1368x768 60.00 1360x768 59.80 59.96
...rewrite legacy git aliases to make them work with differently named default branches Step 1: Decide which is the most common default branch name of your projects, e.g. master. Define...
...to set a default region and the JAVA_HOME: export EC2_REGION=eu-west-1 export EC2_URL=https://eu-west-1.ec2.amazonaws.com export JAVA_HOME=/usr Add a bash script somewhere in...
...your $PATH (I called it am): #!/bin/bash if [[ $1 == "list" ]]; then cd ~/.aws && git branch -l elif [[ $1 != "" && `cd ~/.aws && git branch | grep $1` ]]; then cd ~/.aws && git checkout $1...
On the other hand – all these items are not to hard to fix. 1, 3, 4, 5, 7, 8, 9, 10 should be easy to do right, and...
...Task['notify:critical_operation']).to receive(:invoke) expect { described_class.clean }.to change(User, :count).from(1).to(0) end Note: Try to avoid logic in rake tasks and prefer to just...
...part of the web". Do not use standards in any stage before (like 2, 1 or 0). Run NODE_ENV=production rake assets:precompile to get compiled output in public/packs...
CSSnext Input: body { font-variant: small-caps; background-image: image-set(url(test_1.svg) 1x, url(test_2.svg) 2x); } Output: body { -webkit-font-feature-settings: "c2sc"; font-feature-settings: "c2sc";
...your first request on opening the input element. The Select2 data format { "results": [ { "id": 1, "text": "Option 1" }, { "id": 2, "text": "Option 2" } ], "pagination": { "more": true } } Basic ajax options
ajax: { url: , data: function (params) { return { query: params.term, page: params.page || 1 } } processResults: function (data, params) { return data }, } }); Further reading: https://select2.org/data-sources/ajax
...XML.inner_text(column).include? expected_column.strip end if first_column.nil? false else row = row[(first_column + 1)..-1] true end end end if first_row.nil? false else rows = rows[(first_row + 1...
Hashes can now be compared like numbers: <, >, <=, >=, which checks for (proper) subsets. {a: 1} >= {a: 1} # => true {a: 1} > {a: 1} # => false Numeric predicates Numeric#positive? and Numeric#negative...
...allow for easy filtering: [1, -4, 2, -100].select &:positive? # => [1, 2] Negative grep Enumerable#grep_v excludes from the result set. It's similar to Rails' #reject:
Option 1: JSON dump In config/webpack/environment.js you can get inspect environment which includes all webpack config options set for the current environment: const { environment } = require('@rails/webpacker') const webpack = require('webpack...
...have the content type "text/plain" And the download should contain the following lines: | Line 1 |
mysql> SELECT @@global.version; +------------------+ | @@global.version | +------------------+ | 5.6.30 | +------------------+ 1 row in set (0,00 sec) MySQL 5.6 Reference Manual says "BLOB and TEXT columns cannot have DEFAULT values". If you want to run...
...an application-side default. You can use a gem like has_defaults for that. 1. Temporally change the migration code Replace things like: create_table "some_table", :force => true do...
...for huge amounts. We recently had this issue in a project with more than 100.000 attachments, where we used a structure like this /attachments/123456789/file.pdf. Even the ls command lasted several...
...the list of possible errors that might be unexpected in the first place. Step 1: Prepare your Uploader for the new structure Implement a new structure, like described in a...
...filter(function() { return this.nodeType === 3; }); } Also check out this list of existing node types. 1 is HTML tag, 3 is text, 8 is comment, etc...
Invocation Result amount(0) 0 amount(0.0) 0 amount(0.5) 0,5 amount(1.5, :minimum_precision => 2) 1,50 amount(1.543, :minimum_precision => 2) 1,543 amount(1.5, :minimum...
...precision => 2, :separator => '.') 1.50 amount(nil) – Rendering money amounts If your amounts are Western hemisphere money amounts, you want some additional prettifications on top of that: Always use a minimum...
...by the group_concat_max_len system variable, which has a default value of 1024. This will cause horrible, data-destroying bugs in production. For this reason you should probably...
...id | user_id | title | +----+---------+-----------------+ | 8 | 5 | How to rock | +----+---------------------------+ | 9 | 5 | Shoes are weird | +----+---------------------------+ | 10 | 5 | Best song | +----+---------------------------+ | 11 | 6 | Sunny day | +----+---------------------------+ | 12 | 6 | Greetings | +----+---------------------------+ For each user_id we...
When your JavaScript bundle is so massive that you cannot load it all up front, I would recommend to load...
...syntax is a bit different. UnderscoreJS In UnderscoreJS, methods always return a value: x = [1, 2, 2] _.uniq(x) // => [1, 2] _(x).uniq() // => [1, 2] If you want to chain...
...call value() to terminate the chain. _.chain(x).uniq().map(function(i) { return i + 10 }).reverse().value() // => [12, 11] LoDash In LoDash, methods called from _ (like _.uniq) will behave as...
...your magic here end end Example structure The resulting directory structure will be: /app-root/public/system/users/avatar/000/001/... (1st record) /app-root/public/system/users/avatar/000/002/... (2nd record) ... /app-root/public/system/users/avatar/000/999/... (999th record) /app-root/public/system/users/avatar/001/000/... (1000th record) ... /app-root/public/system/users/avatar/999/999/... (999'999th record) /app-root/public/system/users/avatar/1000/000...
...1 millionth record) So if you have 500k records, you will still only have 500 directories inside /app-root/public/users/avatar/. And inside each of them, at most 1000 sub-directories.
...queries (simplified; the number at the beginning of each line is the connection ID): 1 Connect 1 BEGIN 1 INSERT INTO foos 1 Quit 2 Connect 2 SELECT COUNT(*) FROM...
BANK_CODE = /\A\d{8}\z/ # Germany BANK_ACCOUNT_NUMBER = /\A\d{1,10}\z/ # Germany ZIP_CODE = /\A\d{5}\z/ # Germany HEX_COLOR = /\A([a-fA-F0...
IP_ADDRESS = /\A(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)(?:\.(?:25[0-5]|(?:2[0-4]|1\d|[1-9])?\d)){3}\z...
...can cause the above error, when the arc cosine of something slightly more than 1.0 is to be computed, e.g. for the (zero) distance between the same coordinates (applies only...
...fix, we just force the value we compute the arc cosine of into [-1; 1] bounds. Put this into a config/initializers/graticule_spherical_distance.rb initializer: Graticule::Distance::Spherical.class_eval do def self.distance(from...
...You still need to include rome/dist/rome.css for its basic positioning styles. rome(element, { weekStart: 1, // Monday weekdayFormat: 'short', // Mon styles: { // Picker overlay container: 'rd-container border rounded-lg shadow bg...