...as #html_safe will lead to unexpected behavior. E. g. backreferences to captured groups ($1, $2) will be nil even if the group was matched. There is no universal workaround...

...to still be safe after using gsub on them. You can, however, fix the $1 gsub behavior on html_safe strings...

apidock.com

...1,2,3,4].sample # => e.g. 4 If you'd like to cheat and give different weights to each element in the array, you can use the attached initializer to...

[1,2,3,4].weighted_sample([1,1,1,1000])

def all_tags virtual_tags + tags end end > Post.new.virtual_tags => [] # ✔ > Post.find(1).virtual_tags => nil # ☹ > Post.find(1).all_tags => Error: undefined method '+' for nil:NilClass

iana.org

...file to use them (for example like this): file = @attachment.file.path file_extension = File.extname(file)[1..-1] options = {} options[:type] = Mime::Type.lookup_by_extension(file_extension).to_s send_file file...

If you're experiencing problems with your Google Chrome installation after an update, it might help downgrading Chrome to check...

makandra dev
gozer.ectoplasm.org

When used to do: $> cat /proc/cpuinfo processor : 0 vendor_id : GenuineIntel cpu family : 15 model : 4 model name : Intel(R) Xeon(TM) CPU 3.00GHz stepping : 1

...Instead, on Solaris, use psrinfo(1M) $> psrinfo -v Status of virtual processor 0 as of: 09/17/2006 21:45:32 on-line since 08/24/2006 16:16:03. The i386 processor operates...

...and place your service definitions at the root of the file to use version 1. For more on the Compose file format versions, see https://docs.docker.com/compose/compose-file/ $ cat ./docker-compose.yml

...remove docker-compose. Check your docker-compose version $ docker-compose --version docker-compose version 1.17.1, build unknown $ docker-compose version docker-compose version 1.17.1, build unknown docker-py version...

...object, Ruby calls #to_a on the object: o = String.new('O') def o.to_a [1,2,3] end a, b, c = o # Implicit call to #to_a here

...can manually calculate the quarter index like (Date.parse('2011-02-10').month / 3.0).ceil #=> 1 Yes, you do actually divide by 3.0, not 4.0. MySQL has SELECT QUARTER...

...1...

...other request like from ActionCable. Then just set the maximum number of workers to 1 and the other requests have to wait. UNICORN_WORKERS=1 rails server

crazylittlehacks.blogspot.com

...This does not play too nice with Visor, because Visor will always be "window 1" for AppleScript. By modifying the script and replacing in window 1 with in window...

SSHKit 1.9.0 might fail with the following error, when trying to deploy a Rail application. Upgrading the gem to version 1.21.0 fixed the issue. Traceback (most recent call last):

...from /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.9.0/lib/sshkit/runners/parallel.rb:12:in `block (2 levels) in execute' 16: from /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.9.0/lib/sshkit/backends/abstract.rb:29:in `run' 15: from /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/sshkit-1.9.0/lib/sshkit/backends/abstract.rb:29:in `instance_exec' 14: from /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/capistrano-3.14.1/lib/capistrano/tasks/deploy.rake:89:in `block (4 levels...

developer.chrome.com

// 0: { useCapture: false, passive: false, once: false, type: 'up:click', listener: ƒ } // 1: { useCapture: false, passive: false, once: false, type: 'up:click', listener: ƒ } // ...

...code with Bundler versions < 2.0.2. It just looks like the task is frozen: Workaround 1: Just type your OTP code and hit enter, your gem is released afterwards.

If you need to release a gem with a legacy Ruby version like 1.8.7, the workarounds above won't work for you. In this case, switch to a modern...

...Here are two options by example on how to achieve this in Rails. Option 1 Time.use_zone('UTC') { Time.zone.parse('2020-08-09 00:00') } => Sun, 09 Aug...

makandra dev

...a rough estimate of the LOC. find app -name *.rb -exec wc {} \; | awk '{a+=$1;print a}' | tail...

...cause flaky tests Load rbenv on session create Load nvm on session create (part 1 and part 2) Add an open alias

...database in order to import the dump. If any problems occur, proceed as follows: 1. Figure out the original migration status of the dumpfile Convert your dump to plaintext: pg...

...git log --reverse ./db/migrate/20200729124233_add_users.rb commit d4848ad598b2f02cbca7580a2b928d02996abeb4 Author: Some user <some.user@example.com> Date: Thu Jul 30 16:07:51 2020 +0200 Add users commit 7b7fa26b838e576a70dee79d71f194f6a673c500 Author: Some user <some.user@example.com> Date: Tue Aug...

github.com

...Cucumber uses mocha. This note shows to use RSpec stubs and mocks instead. Rspec 1 / Rails 2 Put the following into your env.rb: require 'spec/stubs/cucumber' Rspec 2 / Rails 3

github.com

...your ActiveRecord models with very little code. Traim assumes your API resources will map 1:1 to your ActiveRecord models and database tables. This assumption usually falls apart after a...

coffeescript.org

Coffeescript # wrong 'name' in {name: 'Horst'} # => false # correct 'name' of {name: 'Horst'} # => true 1 in [1,2,3] # => true

When you need the DOM node of a tag (e.g. to read extra attributes, or to modify the DOM near it), you can usually reference it via document.currentScript. However, document.currentScript is unsupported in ancient browsers, like Internet Explorer 11 or wkhtmltopdf's Webkit engine. If you are not running async scripts, you can easily polyfill it: document.scripts[document.scripts.length - 1] It works because document.scripts grows with each tag that was evaluated. That is also the reason why this solution will not work reliably for async code. Demo: https://codepen.io/foobear/pen/poRLxQm

makandra Operations

If you imagine there is something like ncdu or du -ha -d 1 /foo/bar you're wrong. If you want to get the size of all subdirs you...

...users GROUP BY name; With ONLY_FULL_GROUP_BY this now explodes with: ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated...

You need to make sure that any selected value is either (1) the value you group by or (2) passed to an aggregate function like MIN or...