ruby-doc.org

...to store the conversion factor from MJ to kWh in a variable, which is 1/3.6. Using BigDecimals for this seems like a good idea, it usually helps with rounding errors...

...are cases where you still have to worry about rounding errors. conversion_factor = BigDecimal('1') / BigDecimal('3.6') # => 0.277777777777777777777777777777777778e0 Here the conversion factor got rounded after some decimal places. If you...

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

...Scan using index_users_on_last_name_and_created_at on users (cost=0.28..140.10 rows=1164 width=187) (actual time=0.045..0.499 rows=1164 loops=1)"} # => {"QUERY PLAN"=>"Planning...

...on production. Consider this history: %%{init: { 'gitGraph': {'showCommitLabel': true, 'mainBranchName': 'production'}} }%% gitGraph commit id: "1" commit id: "2" branch master commit id: "3" commit id: "4" branch my-feature-branch...

...and 4 from master. %%{init: { 'gitGraph': {'showCommitLabel': true, 'mainBranchName': 'production'}} }%% gitGraph commit id: "1" commit id: "2" branch master commit id: "3" commit id: "4" checkout production merge master

...When I erase my query, the popup disappears. - The popup contains a maximum of 10 suggestions. - When I click outside the popup, it disappears. - If I click on a suggestion...

...the issue turns out to be more complicated than anticipated. We suggest a 0,1,2,3 point scale, with the following meaning: 0 points: <= 1h 1 points: <= half a...

config.cache_store = :redis_cache_store, { pool: { timeout: 0.5 }, read_timeout: 0.2, # default 1 second write_timeout: 0.2, # default 1 second # Attempt two reconnects with some wait time in...

reconnect_attempts: [1, 5], # default `1` attempt in Redis 5+ url: REDIS_URL, error_handler: ->(method:, returning:, exception:) { Sentry.capture_exception(exception) }, } Timeouts You probably want to adapt these settings...

...Time.new will initialize with the current Time in your Timezone, DateTime.new initializes at January 1, at an undefined year, without a timezone offset. Comparing or calculating with both datastructures mixed...

...and formatting time of day objects, some of them are listed below: Tod::TimeOfDay.parse "15:30" # => 15:30:00 Tod::TimeOfDay.parse "3:30:45pm" # => 15:30:45 Tod::TimeOfDay.new...

...User < ApplicationRecord end User.first #=> SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1 class User < ApplicationRecord self.implicit_order_column = ['updated_at'] end User.first #=> SELECT "users".* FROM "users" ORDER...

...BY "users"."updated_at" ASC, "users"."id" ASC LIMIT 1

...original `setTimeout()` before it is mocked by `jasmine.clock.install()`. const unmockedTimeout = window.setTimeout function wait(ms = 1) { return new Promise((resolve) => { unmockedTimeout(resolve, ms) }) } it('handles an event', async () => { triggerAnEventOn(this.form)

...bit for a certain condition to occur: async function waitFor(callback) { let msToWait = [0, 1, 5, 10, 100] // we use some exponential fall-off while (true) { let [msToWaitNow, ...msToWaitNext] = msToWait...

...browser.execute_cdp('Network.clearBrowserCache') browser.execute_cdp('Network.emulateNetworkConditions', offline: false, latency: -1, # ms, unlimited downloadThroughput: kbps * 1024 / 8, uploadThroughput: kbps * 1024 / 8, ) end Then 'the Cumulative Layout Shift score should be good...

...entries = entryList.getEntries() entries = dedupe(entries, 'startTime') // Debugging // entries.forEach((item, i) => { // console.dir(item) // console.log( // `${i + 1} current LCP item : ${item.element}: ${Math.max(item.startTime - getActivationStart(), 0)}`, // ) // if (item.element) item.element.style = 'border: 5px dotted lime...

makandra dev

...NOTE: this image ships with a recent version of chrome! services: postgres: image: postgres:17 env: POSTGRES_DB: test POSTGRES_USER: postgres POSTGRES_PASSWORD: postgres PGTZ: "Europe/Berlin" options: >- # Set health...

...checks to wait until postgres has started --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 ports: [ '5432:5432' ] env: DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL...

...function takes a third argument with a normalization setting. For example, a normalization of 1 will divide the rank by 1 + the logarithm of the document length: class Message < ApplicationRecord...

...Arel.sql("search_tsvector @@ #{query_sql}")) .order(Arel.sql("ts_rank_cd(search_tsvector, #{query_sql}, 1) DESC")) } # ... end There are many normalization strategies. See the PostgreSQL documentation for a list.

...array-like already. The behaviour is a bit saner than Array[...]. Array.wrap(nil) # => [] Array.wrap([1,2,3]) # => [1,2,3] Array.wrap(1) # => [1] Array.wrap("foo \n bar") # => ["foo \n bar...

Subclass.setting # => false Base.setting # => true Float#round round to a given number of decimals 1.2345.round(2) # => 1.23 1.2345.round(3) # => 1.235 Hash#deep_merge(!) merge hashes recursively String#squish(!) removes leading...

...single in an example application writes to the Rails log. Started GET "/rails/active_storage/blobs/redirect/..." for ::1 at ... Processing by ActiveStorage::Blobs::RedirectController#show as SVG Parameters: ... ActiveStorage::Blob Load (0.4ms...

...at key:...

...(http://localhost:3000/rails/active_storage/disk/...) Redirected to http://localhost:3000/rails/active_storage/disk/... Completed 302 Found in 18ms (ActiveRecord: 0.4ms (1 query, 0 cached) | GC: 13.3ms) Started GET "/rails/active_storage/disk/..." for ::1...

relishapp.com

When you are using lambdas in RSpec to assert certain changes of a call, you know this syntax: expect { playlist.destroy...

So according to IEEE floating point definition only numbers between -(2^53 - 1) (-9007199254740991) and 2^53 - 1 (9007199254740991) can safely be represented in JavaScript. Number.MAX_SAFE_INTEGER...

...BigInt objects can be used in all major browsers. You can write bigints as 1234567n...

...for an MP4 and an WebM version: Container / Codecs Chrome 80 FF 74 Safari 13 IE 11 Android Browser 80 iOs Safari Samsung Internet MP4, H.264 + AAC ✓ ✓ ✓ ✓ ✓ ✓ ✓ WebM, VP8 + AAC...

...audio playback was verified unless stated otherwise. Operating system Chrome 80 FF 74 Safari 13/9 IE 11 Mobile Chrome Mobile Safari / Samsung Mobile Firefox Ubuntu 18.04 webm webm / / / / /

...foreign key when using Rails’ has_one relationship. This ensures the database enforces the 1:1 constraint and raises an error if your application logic ever violates it.

...digits and decimal separators, an "e" is also allowed (to allow scientific notation like "1e3"). Non-technical users will be confused by this. Your server needs to understand that syntax...

...digits (e.g. to_i in Ruby) you'll end up with wrong values (like 1 instead of 1000). Users can change values with the up and down arrow keys.

...It's good to know them all, but we recommend Option 0 or Option 1. Option 0: Sub-query with conditions from a scope You may also pass the existing...

...FROM posts WHERE user_id IN (SELECT id FROM users WHERE trashed=f); Option 1: Pluck foreign keys and make a second query We can first fetch the IDs of...

...change completely for 2.0, so you might find a bunch of unrelated documentation for 1.2 Here is an example, what smarter_csv does for you: Input: first name,last name...

Dan,McAllister,2,,, Lucy,Laweless,,5,, Miles,O'Brian,,,,21 Nancy,Homes,2,,1, Output: [ {first_name: 'Dan', last_name: 'McAllister', dogs: '2'}, {first_name: 'Lucy', last_name: 'Laweless...

When Rails releases a new version of their gems, they also release a number of npm packages like @rails/activestorage or...

Install the latest bundler version: gem install bundler Fetching bundler-2.3.5.gem Successfully installed bundler-2.3.5 1 gem installed Update the bundler version in Gemfile.lock: bundle update --bundler Confirm it worked:

...cannot use the latest bundler 2 version, so you need to stay on bundler 1...

...integration tests: Capybara.register_driver :chrome do |app| options = Selenium::WebDriver::Chrome::Options.new options.browser_version = '138.0.7204.183' Capybara::Selenium::Driver.new(app, browser: :chrome, options:) end The first time you run a test...

...chromedriver version is installed to the cache ~/.cache/selenium/. You will notice a delay of ~1 minute. Note: This setup does not work, when you use the Rails driven_by method...

...constraint. For example, you can tell Sentry to notify you only if it occurs 10 times per hour. Sentry currently offers three constraints when ignoring an issue:

Occurrences (1 time, 10 times, ..) Number of affected users