This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
require 'json' | |
require 'oj' | |
count = 1 | |
numbers_as_string_json = ("," + (1..count).to_a.join(",") + ",").to_json | |
numbers_json = (1..count).to_a.to_json | |
needle = 1000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
require 'json' | |
require 'oj' | |
numbers_as_string_json = ("," + (1..10000).to_a.join(",") + ",").to_json | |
numbers_json = (1..10000).to_a.to_json | |
Benchmark.ips do |x| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
numbers = (1..10000).to_a | |
numbers_as_string = "," + (1..10000).to_a.join(",") + "," | |
Benchmark.ips do |x| | |
x.report("binary search numbers") do |i| | |
while i > 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
require_relative '../rerunner/rerunner.rb' | |
class Car | |
def self.all_blue! | |
puts "all blue called" | |
sleep 0.1 | |
puts "all blue set" | |
@@all_blue = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# tiny rerunner (I use this on local to rerun script) | |
require_relative '../rerunner/rerunner.rb' | |
require 'yaml' | |
require 'psych' | |
yaml = <<~YAML | |
# amazing YAML file | |
# | |
# hello |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from ruamel.yaml import YAML | |
import sys | |
example = """ | |
# hello | |
test: "test\\ntest\\ntest" # a test | |
test2: hello.. #world | |
""" | |
rt_yaml=YAML(typ='rt') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# we should set the locale before the migration | |
task 'set_locale' do | |
begin | |
I18n.locale = (SiteSetting.default_locale || :en) rescue :en | |
rescue I18n::InvalidLocale | |
I18n.locale = :en | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# we should set the locale before the migration | |
task 'set_locale' do | |
begin | |
I18n.locale = (SiteSetting.default_locale || :en) rescue :en | |
rescue I18n::InvalidLocale | |
I18n.locale = :en | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# we should set the locale before the migration | |
task 'set_locale' do | |
begin | |
I18n.locale = (SiteSetting.default_locale || :en) rescue :en | |
rescue I18n::InvalidLocale | |
I18n.locale = :en | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
# we should set the locale before the migration | |
task 'set_locale' do | |
begin | |
I18n.locale = (SiteSetting.default_locale || :en) rescue :en | |
rescue I18n::InvalidLocale | |
I18n.locale = :en | |
end | |
end |