Redis database size via Ruby client irb(main):002> Redis.new(url: 'redis://localhost:16380/1').info.fetch('maxmemory_human') => "512.00M" Redis database size via CLI $ redis-cli --port 16380 --database...
...1 INFO memory | grep maxmemory_human maxmemory_human:512.00M Memory footprint If you want to calculate the estimated Redis memory usage of a job, you can measure the consumed...
$ ruby --yjit -e "puts RubyVM::YJIT.enabled?" true # via ENV variable $ RUBY_YJIT_ENABLE=1 ruby -e "puts RubyVM::YJIT.enabled?" true # Start Ruby without YJIT, but enable it later
...to not use the CLI flag --yjit or the ENV variable RUBY_YJIT_ENABLE=1 for starting Rails processes on your server...
end def db_number # Returns a number between 2 and n. # Redis db#1 is used for development. db_number = 1 if rails_env == 'test' normalized_test_number = [ENV...
...TEST_ENV_NUMBER'].to_i, 1].max db_number += normalized_test_number end db_number end def port case rails_env when 'staging' # when 'production' # else 6379 # default Redis port...
...in SQL this looks like SELECT `models`.* FROM `models` WHERE `models`.`id` = 23 LIMIT 1 FOR UPDATE You have to do this at the point where the object is loaded...
# This block is called within a transaction, # account is already locked. account.balance -= 100 account.save! end More on row locking http://dev.mysql.com/doc/refman/5.1/en/innodb-locking-reads.html http://www.postgresql.org/docs/current/interactive/sql-select.html#SQL-FOR-UPDATE-SHARE Other types of...
...shutdown the Elasticsearch cluster, as soon as everything works as expected. flowchart TB subgraph "1" A0[App]-- Search -->ES0[Elasticsearch] A0[App]-- Update -->ES0[Elasticsearch] OS0[OpenSearch] end
...please refer to the breaking changes linked below. On request we may provide OpenSearch 1.x corresponding to Elasticsearch 7.x. How do you update your application? This depends on...
...Add this line to your application's Gemfile: gem 'capistrano', '~> 3.0' gem 'capistrano-maintenance', '~> 1.0' Add this line to you application's Capfile: require 'capistrano/maintenance' Enable task Present a maintenance...
...specifying the REASON and UNTIL environment variables: cap maintenance:enable REASON="hardware upgrade" UNTIL="12pm Central Time" You can use a different template for the maintenance page by setting the...
Always optimize: Don't do stupid things with the database. Avoid "n + 1" queries. Don't do costly calculations live when you can precalculate and cache. Don't...
...instantiate 1000s of records. Use query_diet. Add database indexes. Don't descend into callback hell. Use form models. Optimize on demand: Don't optimize without knowing what's actually...
...you might want to enable logging for the chromedriver itself. Here is how. Option 1: Use Selenium::WebDriver::Service In your test setup, you may already have something like Capybara...
...can also start chromedriver yourself in a terminal on a custom port: chromedriver --port=12345 --verbose --log-path=/tmp/chromedriver.log Then configure Selenium to connect to that port. Like in option...
...distinction between virtual pixels vs. physical pixels. Understand how raster images prepared for a 1:1 pixel ratio look like on high density displays. Understand which classes of devices typically...
...saves CPU time and reduces the bandwidth cost for a request/response exchange to about 1 KB. The most efficient way to produce and compare ETags are the fresh_when and...
...exploit, especially in 2023: The attacker needs to force the victim to make about 1000 requests. The attacker needs to be within the same local network as the victim, so...
Rails log files rotate automatically when they reach approx. 100MB: $ ls -lh log/ -rw-r--r-- 1 user group 55M Sep 15 09:54 development.log -rw-r--r-- 1 user...
...group 101M Aug 22 13:45 development.log.0 This behavior is a built-in feature of Ruby's standard Logger class, which Rails uses by default. To control the maximum...
Rails.logger = Logger.new(STDOUT) ActiveRecord::Base.logger = Logger.new(STDOUT) User.save! #=> D, [2025-09-08T11:12:26.683106 #1094157] DEBUG -- : User Load (1.1ms) SELECT "users".* FROM "users" ORDER BY "users"."id...
...DESC LIMIT $1 [["LIMIT", 1]] Many frameworks in Rails have their own logger configuration and are set on boot. The example above configures the ActiveRecord::Base.logger, but logger also exists...
...and times incomparisons, mind to not compare datetimes with date ranges in MySQL. Visualisation 1. ------- ------- AAA AAA BBB BBB ------- ------- 2. ------- AAA B ------- 3. ------- A BBB ------- 4. ------- AAA BBB ------- 5. -------
...rows, migration performance becomes an issue. We will talk about this in another card. 1. Use the full power of SQL Plain SQL can be very powerful. Once you get...
select_all('SELECT * FROM articles') # => [ { 'name': 'Bioshock Infinite', 'price': 40.0 }, { 'name': 'EVOLAND', 'price': 19.0 } ] As an example, we have Article has_many :vendors. We now introduce a boolean flag...
Execute one query per involved table with a condition like...
...WHERE id IN (123, 125, 170). Execute a single query for a huge table joined from all involved tables...
ActiveRecord prefers option 1, probably because it is less costly. But as soon as your conditions reference another table (like other_table.column), ActiveRecord will go with option 2 and build a...
...echo "$TOKEN" | cut -d. -f1) $ PAYLOAD=$(echo "$TOKEN" | cut -d. -f2) $ b64urldecode() { local data="$1" # base64url -> base64 + padding data=${data//-/+}; data=${data//_//}; local pad=$((4 - ${#data} % 4)); [[ $pad -lt...
...data+=$(printf '=%.0s' $(seq 1 $pad)) echo -n "$data" | base64 -d 2>/dev/null } $ echo "== header =="; b64urldecode "$HEADER" | jq . $ echo "== payload =="; b64urldecode "$PAYLOAD" | jq . To also check for issuing and expiration...
...adds a new feature called capsules. Use cases: a chrome queue limited to 1 for e.g. PDF processing to not overload the application server an api queue, that limits a...
...jobs from the `unsafe` queue one at a time config.capsule("unsafe") do |cap| cap.concurrency = 1 cap.queues = %w[unsafe] end end Some notes: To know the total threads per sidekiq server...
...There is no upper or lower character limit (except for the absolute maximum of 1 GB). The documentation states: There is no performance difference among these three types, apart from...
ActiveRecord::Base.clear_active_connections # <- close additional database connections end render json: Hash[*group_ids_and_html.flatten(1)] end private def load_group(group_id) Group.find(group_id) end def render_group_html...
...a video with a very low resolution and framerate) Create a 21s video with 1fps and 10x10 resolution: ffmpeg -t 21 -s 10x10 -r 1 -f rawvideo -pix_fmt rgb24...
.../dev/zero sample_21_seconds.mp4 Option Explanation -t 21 set the length to 21s -s 10x10 set the resolution the 10 by 10 pixel -r 1 set the framerate to 1...
...margin_top: '200px', # Height of the header, can be px or mm margin_bottom: '150px', # Height of the footer, can be px or mm header_spacing: 52.197, # margin_top converted...
...number or the custom JSON encoded hash: function allQueryInformation() { var pdfInfo = {}; var queryStrings = document.location.search.substring(1).split('&'); for (var query in queryStrings) { if (queryStrings.hasOwnProperty(query)) { var keyValuePair = queryStrings[query].split...
...this releases the commit we need c67e8d8 o Merge pull request #44641 from SkipKayhil/fix-rubocop-errors 1afe117 o Update CHANGELOG [ci skip] 87528db o Revert "Merge pull request #43209 from mpestov/check-basic-auth-credentials"
...branch '6-1-sec' into 6-1-stable 6607333 │ o Preparing for 6.1.4.7 release 1f66424 │ o bumping version b0b5eaf │ o Added image trasnformation validation via configurable allow-list
...fingerprint and stack trace rules at https://sentry.io/settings/projects/$project-id/issue-grouping. Fingerprint rules have this syntax: 1 or more key:value conditions, followed by ->, followed by your custom fingerprint string. Read the...
...address_group(self) do pp.seplist(inspections_tuples, proc { pp.text "," }) do |(name, value)| pp.breakable " " pp.group(1) do pp.text name pp.text ":" pp.breakable pp.text value end end end end private def inspections_tuples...