...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...
...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...
...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...
...before="2014-7-4" You can use references like "2 years 1 day 3 minutes ago" and "yesterday": git log --after="yesterday...
...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...
...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...
...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
...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
...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...
it "doesn't use logical negation for include, exhibit A" do expect([1, 2, 3]).to include(3, 4, 5) end it "doesn't use logical negation for...
...include, exhibit B" do expect([1, 2, 3]).not_to include(3, 4, 5) end end Exhibit A fails with: expected [1, 2, 3] to include 4 and 5
...simple as a tuple of start and end state. const keyframes = [ { opacity: 0 }, { opacity: 1 }, ] const animation = element.animate(keyframes, { duration: 1000 }) After the animation has finished, the animation keyframes will...
...that allows you to wait for animations to finish. const animation = element.animate(keyframes, { duration: 1000 }) await animation.finished alert('animation finished!') Side note: When animations are cancelled, the promise is rejected...
In modern Rails versions you can also use ActiveRecord's pluck method. User.active.pluck(:id) => [1, 5, 23, 42] If you are plucking from the id column in particular you can...
User.active.ids => [1, 5, 23, 42] For a DISTINCT selection, use distinct on your scope (not the resulting array). Article.distinct.pluck(:state) # SELECT DISTINCT state FROM articles => ['draft', 'published']
...Use RAILS_ROOT as a placeholder for the remote Rails root directory. # * Append ` || test $? =1;` to grep calls in order to avoid exit code 1 (= "nothing found") # * To be able...
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 :where...
...pseudo selector ... .datepicker :where(.prev, .next, .switch) padding-bottom: 1rem :where(ul, ol) li list-style-type: none Hint The specificity of :where() is always zero! If you need or...
irb(main):001:0> require 'json' => true irb(main):002:0> JSON.parse('{"qty": 1, "qty": -1}') => {"qty"=>-1} Character Collision irb(main):009:0> JSON.parse('{"qty": 1, "qty\ud800...
...incomplete surrogate pair at 'qty\ud800": -1}') irb(main):007:0> JSON.parse('{"qty": 1, "qty"": -1}') JSON::ParserError (784: unexpected token at '{"qty": 1, "qty"": -1}') This one was unexpected...