...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
...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...
...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
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...
...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...
...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? }
...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...
...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...
...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 ++++++++++++++++++++++++++++++
...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...
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...
...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...
OpenAI is currently limiting the Audio generating API endpoint to text bodies with a maximum of 4096 characters.
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...
...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...
[ -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...
...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 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 $?
...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...
...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...