...find out about #fill but it is not really what you are looking for. [1] For arrays of unknown size that you want to grow or shrink to a fixed...

...sized << fill_with while sized.size < expected_size sized end end Use it like this: >> [1, 2, 3].in_size(5) => [1, 2, 3, nil, nil]

...class Article < ActiveRecord::Base named_scope :available, :conditions => { :state => [ 'unassigned', 'draft' ] } end #<Article id: 1, title: "Cooking noodles", state: "unassigned"> #<Article id: 2, title: "How to rock", state: "draft">

>> Article.available # SELECT * FROM `articles` WHERE (`articles`.`state` IN ('unassigned','draft')) => [ #<Article id: 1, title: "Cooking noodles", state: "unassigned">, #<Article id: 2, title: "How to rock", state: "draft"> ]

...form_for(@user) do |form| = form.input :email = form.submit 'Save', class: ['btn', 'btn-primary'] Option 1: Using the form.error method The form.error method renders the first error on :base.

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

...which might not work for testing directly on the VM. $ curl -v http://localhost:12345 * Trying 127.0.0.1:12345... * TCP_NODELAY set * Connected to localhost (127.0.0.1) port 12345 (#0) > GET / HTTP/1.1...

...Host: localhost:12345 > User-Agent: curl/7.68.0 > Accept: */* > * Mark bundle as not supporting multiuse < HTTP/1.1 301 Moved Permanently < Date: Wed, 26 Apr 2023 06:38:09 GMT < Server: Apache

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

phili.pe

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

makandra dev
tpgi.com

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";

makandra dev
select2.org

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

makandra dev
dev.mensfeld.pl

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:

makandra dev

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 |

...the endpoint from our notebook. Fixture JSON file: { "categories":[], "created_at":"2020-01-05 13:42:21.795084", "icon_url":"https://assets.chucknorris.host/img/avatar/chuck-norris.png", "id":"02e1usSQT_yO1AahT6meRg", "updated_at...

...13:42:21.795084", "url":"https://api.chucknorris.io/jokes/02e1usSQT_yO1AahT6meRg", "value":"Paul McCartney eats a vegan diet all the time -- except when he eats in the presence of Chuck Norris." } # spec/chuck_norris_spec.rb require 'webmock/rspec...

stackoverflow.com

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

...one of our servers is trying to access the database. # journalctl -u mariadb Dec 16 00:00:03 cool-server mariadbd[788]: 2022-12-16 0:00:03 34996 [Warning...

...Access denied for user 'root'@'localhost' (using password: NO) Dec 17 00:00:02 cool-server mariadbd[788]: 2022-12-17 0:00:02 89012 [Warning] Access denied for user...

When your JavaScript bundle is so massive that you cannot load it all up front, I would recommend to load...