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

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

...class that includes your module, and no longer exists after your test has finished. 1. Defining the class and assigning to a constant (preferred) describe Notifier do before do

linux.die.net

...commits into patch files. Those can be used to apply to a different repository [1] or by someone else (e.g. sent when sent to them via e-mail).

...the patch file created earlier. More information git format-patch git apply git am [1] Note that you can add other git repositories/directories as a remote source. Sometimes you don...

An example would be an AngularJS application where the following HTML actually works. [1] Hello Capybara will fail to find that link, even though looking it up via the...

...and click_link work, simply add href="#" to your element: Hello >> find_link("Hello") => # [1] Note that while it does work in your application (links are usually styled correctly, and...

...Both requests scan the users table and see that the name is available Worker #1 passes validation and sucessfully creates a user with the available name Worker #2 passes validation...

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

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

end (::) failed steps (::) Got 2 failures from failure aggregation block "multiple expectations": 1) first expectation failed 2) second expectation failed As you can see, the test is not...

...def full_filename 'thumbnail.jpg' end process(take_frame: [at: 0.seconds]) process(resize_to_limit: [1280, 720]) end def take_frame(at:) raise TakeFrameError, "Input file does not exist, capturing a...

...File.exist?(current_path) run_ffmpeg! '-ss', ffmpeg_target_second(at), '-i', current_path, '-vframes', '1', '-qscale:v', '2', current_path raise TakeFrameError, "Something went wrong while capturing a frame for...

...expansion to either set a default or check mandatory arguments Mandatory parameter hello() { NAME=${1:?provide name as first parameter} echo "Hello $NAME!" } $ hello # $?=1 bash: 1: provide name as...

...first parameter $ hello Foo # $?=1 Hello Foo! Parameter with default hello() { NAME=${1:-Marvin} echo "Hello $NAME!" } $ hello # $?=0 Hello Marvin! $ hello Foo # $?=1

Example Compound selectors like ... .datepicker .prev, .datepicker .next, .datepicker .switch padding-bottom: 1rem ul li, ol li list-style-type: none can be simplified by using the :is...

...pseudo selector ... .datepicker :is(.prev, .next, .switch) padding-bottom: 1rem :is(ul, ol) li list-style-type: none Hint The specificity of :is() is equals to its most specific argument...

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

...when constructing an array ['foo', *nil] # => ['foo'] Remove blank values from collections Array array = [1, "", nil, 2, " ", [], {}, false, true] # Any Rails version array.reject(&:blank?) # => [1, 2, true]

...array.compact_blank # => [1, 2, true] Hash hash = { a: 1, b: "", c: nil, d: 2, e: " ", f: [], g: {}, h: false, i: true } # Any Rails version hash.reject { |key, value| value.blank? }

...that is shared between all classes of your application: ActiveRecord::Base.class_eval do @@counter = 1 end When encountering such code, Ruby will warn you: warning: class variable access from toplevel...

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

makandra dev

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

...Usage: linearcommits FOO-123456 # Alternative usage: linearcommits https://linear.app/some-workspace/issue/FOO-123456 function linearcommits { if test "$1" then local LINEAR_ID=$(echo "$1" | grep "[^/]*$" -o) # Extract linear ID from URLs

...linearcommits ABC-165086636 --stat: commit 048054b1df87576f7c59cc0161cc331c44d2ea6b Author: Foo Bar <foo@bar.com> Date: Fri Apr 5 14:24:24 2019 +0200 [ABC-165086636] Linear issue Title app/assets/javascripts/test.js | 22 ++++++++++++++++++++++ app/models/test.rb | 30 ++++++++++++++++++++++++++++++

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

makandra Operations

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

postgresql.org

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

github.com

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 lot of unnecessary email notifications. Often times we tend to use > /dev/null 2>&1 to just suppress all the output. This will hide errors though, and hinder debugging.

#!/bin/bash echo "all good until now" echo "everything is broken" >> /dev/stderr exit 1 $ chronic ./good.sh $ echo $? 0 $ chronic ./bad.sh all good until now everything is broken $ echo $?

makandra Operations

loop until state change wait 60 seconds (vrrp_garp_master_refresh) send 1 GARP/NA package (vrrp_garp_master_refresh_repeat) The timings here are default which can be...

...is full, no more packages are enqueued. This is logged as follows: Jun 29 16:49:53 myhost Keepalived_vrrp[787]: Error 11 sending ndisc unsolicited neighbour advert on eth0...