Compare JS and Ruby REEGEX
Example #1 /!+|\?+/g
RUBY s.scan(/!+|\?+/).inspect == JS s.match(/!+|\?+/g)
INPUT: "!!!??"
RUBY [\"!!!\", \"??\"] == JS [ '!!!', '??' ]
| desc "Get test" | |
| task :get_test do | |
| sh "git fetch" | |
| sh "git checkout test" # (0) This swithes current dir and brings problems. | |
| sh "git pull" | |
| end | |
| task :get_web do | |
| sh "git checkout test -- web" | |
| sh "git reset HEAD web" # (1) Need to do this to avoid STAGE web dir. |
| # https://www.codewars.com/kata/reviews/5a1554137ef16335fc00366e/groups/5a15592839caeb68ca001184 | |
| def isomorph(a, b) | |
| sa, sb = a.each_char.to_set, b.each_char.to_set | |
| sa.size == sb.size && sa.size == a.each_char.zip(b.each_char).to_set.size | |
| end |
| class Trolotron | |
| def initialize(name) | |
| @name = name | |
| end | |
| def is_troll? | |
| true | |
| end | |
| def to_s |
| # https://www.codewars.com/kata/stone-bridge-primes/train/ruby | |
| def solve(x,y) | |
| a = [] | |
| for itr in 0..2 | |
| p "iteration #{itr}" | |
| i_fora = 2 | |
| for i in itr..itr+i_fora | |
| a << calc(i,itr) | |
| end | |
| end |
| # https://www.codewars.com/kata/stone-bridge-primes/train/ruby | |
| require "prime" | |
| def solve(x,y) | |
| a = [] | |
| for m in 0..10 | |
| for n in 0..10 | |
| a << calc(m,n) | |
| end | |
| end |
| # https://www.codewars.com/kata/stone-bridge-primes/train/ruby | |
| # this Decission past test but fails submit. | |
| require "prime" | |
| def solve(x,y) | |
| @a ||= calc_all | |
| @a.select{|e| e >= x and e < y }.size | |
| end |
| def i_speak_french(sentence) | |
| p sentence | |
| sentence.split(".").map{|i| send i}.join("") | |
| end | |
| def send s | |
| s.gsub(/\b[[:alnum:]]+\b/,"baguette").gsub(/(^\s*)(\b[[:alnum:]]+\b)/,'\1Baguette') + " Encore!" | |
| end |
Compare JS and Ruby REEGEX
Example #1 /!+|\?+/g
RUBY s.scan(/!+|\?+/).inspect == JS s.match(/!+|\?+/g)
INPUT: "!!!??"
RUBY [\"!!!\", \"??\"] == JS [ '!!!', '??' ]
| # https://stackoverflow.com/a/3236342/8574922 | |
| class Rand | |
| set_trace_func proc { |event, file, line, id, binding, classname| | |
| # only interested in events of type 'call' (Ruby method calls) | |
| # see the docs for set_trace_func for other supported event types | |
| puts "#{classname} #{id} called" if event == 'call' | |
| } | |
| end |
| # v1: | |
| response = Namespace::Abstract::Service.new( | |
| param1: val1, | |
| param2: val2, | |
| ).perform | |
| track_errors(response) | |
| response | |
| # v2: | |
| Namespace::Abstract::Service.new( |