...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...
Consider the following git diff output. diff --git a/file1.rb b/file1.rb index 806ca88..36d536b 100644 --- a/file1.rb +++ b/file1.rb @@ -1,7 +1,5 @@ -# Here is a useless comment. -# It will be removed...
+ def bar # ... end end diff --git a/file2.rb b/file2.rb index 550e1c6..600f4e3 100644 --- a/file2.rb +++ b/file2.rb @@ -1,6 +1,5 @@ -# Here is another useless comment. class File2
...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...
...you insert a record "by hand". This will cause an error: record = Record.create! record.id # => 100, next automatic id will be 101 Record.create!(id: record.id + 1) # okay, but next automatic id...
...will still be 101 Record.create! # will cause an SQL error 'duplicate key value violates unique constraint "records_pkey"' Workaround In tests, one workaround would be to simply initialize all sequences...
...threads, that handle the incoming requests. Example: A Puma server with 2 workers and 1 thread each can handle 2 request in parallel. A third request has to wait until...
...but once one thread is blocked, another can continue. Example: A Puma server with 1 worker and 2 threads can handle 2 requests. A third request has to wait until...
...webcam in PulseAudio use the following one-liners: # Connected cards $ pactl list short cards 1 alsa_card.pci-0000_00_1f.3 module-alsa-card.c 5 alsa_card.usb-Lenovo_ThinkPad_Thunderbolt_4_Dock...
...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...
...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.
...circle, it is then asked to compute the arc cosine of a result like 1.0000000001. Since this is undefined, MySQL correctly returns NULL (instead of the expected distance of...
...this problem is to discard rounding errors by forcing any results into bounds [-1; 1] before computing the arc cosine on it. Put the following into an initializer like config/initializers/graticule_spherical_to_sql_without_nulls.rb...
...browser process crashes on your users. Although this guide has been written for Angular 1 originally, most of the advice is relevant for all client-side JavaScript code.
link: (scope, element, attributes) -> updateTime = -> var now = new Date(); element.text(now.toString()) setInterval updateTime, 1000 The version below clears the interval and doesn't leak memory: @app.directive 'clock', -> link: (scope...
...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
...you continue, ensure that you've created your certificate in the region us-east-1 (N. Virginia). Otherwise the certificate is not available for CloudFront. The issue
I don't know why this error occurs, but after wasting over 1 hour of time trying to get the certificate to show up in the CloudFront console...
...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...
...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...
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...
...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";
...unexpectedly splat the array elements: block = proc { |a, b| "a=#{a}, b=#{b}" } block.call(1, 2) # "a=1, b=2" block.call([1, 2]) # "a=1, b=2" Note that lambdas...
...behave as expected: block = lambda { |a, b| "a=#{a}, b=#{b}" } block.call(1, 2) # "a=1, b=2" block.call([1, 2]) # ArgumentError: wrong number of arguments (1 for...
...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"> ]
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...
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...
...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...
...have the content type "text/plain" And the download should contain the following lines: | Line 1 |
...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...