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...
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...
...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...
...before="2014-7-4" You can use references like "2 years 1 day 3 minutes ago" and "yesterday": git log --after="yesterday...
...return this.firstName + " " + this.lastName; }, set fullName(name) { var parts = name.split(" "); this.firstName = parts[0]; this.lastName = parts[1]; } }; The code below shows how this object can be used. Notice the absence of parentheses...
...return this.firstName + " " + this.lastName; }, set: function(name) { var parts = name.split(" "); this.firstName = parts[0]; this.lastName = parts[1]; } }); Browser compatibility Works with IE9+ and real browsers. CoffeeScript CoffeeScript doesn't support getter/setter functions...
Hardcoded solution (preferred solution when using Rails with ActiveJob/Sidekiq or Cronjobs) Dynamic solution 1. Hardcoded solution When you are sending mails from outside the request cycle, e.g. ActiveJob/Sidekiq or...
OpenAI is currently limiting the Audio generating API endpoint to text bodies with a maximum of 4096 characters.
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" find-up() { path=$(pwd) while [[ "$path" != "" && ! -e "$path/$1" ]]; do path=${path%/*} done echo "$path" } automatic-nvm-use() { NVM_PATH=$(find-up .nvmrc | tr...
...the scanf C-operation for plotting. In the most simple application plot 'file' using 1:2 just means plot the content of the first column (as x-axis) against the...
...operations or different functions such as the example from the doc: plot 'file' using 1:($2+$3) '%lf,%lf,%lf', where you reference the n-th column by $n and...
...rendering and DB query durations Good for spotting problematic endpoints The "Recent requests" screen (1 hour history) Shows individual requests Provides the full list of DB queries per request, color...
...are three ways to define your own RSpec matchers, with increasing complexibility and options: 1) Use RSpec::Matchers.define RSpec::Matchers.define :be_a_multiple_of do |expected| match do |actual|
block expectations If you want to use a block expectation like expect { rand(100) }.to produce_different_results, you have to use this syntax and call supports_block_expectations...
...two useful tools for your own usage. Desktop environment pie title Desktop environment "Gnome" : 16 "i3": 2 "sway": 2 "awesome": 1 "bspwm": 1 "mate": 1 "xfce": 1 Gnome dominates (unsuprising...
...most popular i3 and the mostly i3-compatible sway. Shell pie title Shell "bash" : 14 "zsh": 6 "fish": 2 Again, "bash" dominates as the default. Popular command line tools...
...of my favorites: console.log takes many arguments E.g. console.log("Current string:", string, "Current number:", 12) Your output can have hyperlinks to Javascript objects E.g. console.log("Check out the current %o...
...of objects) to console.table(). Example: console.table(["apples", "oranges", "bananas"]) prints: (index) Values 0 "apples" 1 "oranges" 2 "bananas" Grouping output in nested, collapsible sections Great for debugging deeply nested or...
...go to File → Settings → Appearance and set the "Zoom" option to your liking, e.g. 150%. Everything (UI elements, UI font, editor fonts) should be scaled accordingly. Scaling everything manually (classic...
You can configure RubyMine to manually scale everything. 1. Increase UI size Navigate to Help → Custom VM Options. A file will open. Here, simply add the ide.ui.scale option with...
...performance issue: what do you check in the first minute? uptime dmesg | tail vmstat 1 mpstat -P ALL 1 pidstat 1 iostat -xz 1 free -m
...sar -n TCP,ETCP 1 top Also see: How to get a rough picture about a Rails project How to examine an unknown Ruby object
You should look for rows with State: LISTEN. Rows for local address 127.0.0.1 or ::1 (IPv6) can only be reached from your own PC: Netid State Recv-Q...
...Send-Q Local Address:Port Peer Address:Port Process tcp LISTEN 0 1024 127.0.0.1:3000 0.0.0.0:* users:(("ruby",pid=33985,fd=18)) Rows for local address 0.0.0.0 can be reached...
...rename the class and change the column details to fit your purpose. Run it. 1) Deliver attachments through Rails The first way is to store your Carrierwave attachments not in...
...SHA512.hexdigest("--#{Rails.env}--#{model_class_name}--#{model.id}--#{mounted_as}--#{secret}--") # 4 bit per character, so 128 bit for the full hash. Check if still appropriate! hash.slice(0, 32) end end