This file contains hidden or 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
| # start FactoryBot id sequence at a different number. Naive approach. | |
| # other idea https://github.com/thoughtbot/factory_bot/issues/350#issuecomment-14475441 | |
| FactoryBot.define do | |
| factory :app do | |
| sequence(:id) { |n| 1.to_s.ljust(self.instance.class.name.size, "0").to_i + n } | |
| end | |
| end |
This file contains hidden or 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 "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
| gem "rotp" |
This file contains hidden or 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 | |
| # ruby ruby_trap.rb | |
| begin | |
| require "bundler/inline" | |
| end | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| gem "rspec", "~> 3" |
This file contains hidden or 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
| process, thread, msg = workers.select { |process, thread, msg| Sidekiq::Job.new(msg['payload']).display_class == 'GenerateInvoices | |
| Job' }.first | |
| job = Sidekiq::Job.new(msg['payload']) | |
| puts "job class: #{job.display_class}, time: #{Time.at(message['run_at'])}" |
This file contains hidden or 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
| # lib/sidekiq/memory_sampling_middleware.rb | |
| # frozen_string_literal: true | |
| class Sidekiq::MemorySamplingMiddleware | |
| attr_accessor :logger | |
| def initialize(options = { logger: Sidekiq::Logging.logger }) | |
| self.logger = options.fetch(:logger) { raise 'Missing logger parameter in options' } | |
| end | |
| CLASS_KEY = 'class' |
This file contains hidden or 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 "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
| # Activate the gem you are reporting the issue against. |
This file contains hidden or 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
| # With get process mem Gem from Richard | |
| class MemoryDiff | |
| class << self | |
| def print_usage_before_and_after(description) | |
| mem = GetProcessMem.new.mb | |
| puts "MEM:BEFORE:#{description.inspect} - MEMORY USAGE(MB): #{mem.round(2)}mb" | |
| yield | |
| after_mem = GetProcessMem.new.mb | |
| puts "MEM:AFTER:#{description.inspect} - MEMORY USAGE(MB): #{after_mem.round(2)}mb. Diff: #{display_diff(after_mem - mem)}" |
This file contains hidden or 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
| class ChildProcess | |
| class Ps | |
| attr_accessor :pid, :ppid, :state, :command | |
| def to_s | |
| "pid: '#{pid}', ppid: '#{ppid}', state: '#{state}', command: '#{command}'" | |
| end | |
| end | |
| attr_reader :list |
This file contains hidden or 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
| pid = Process.pid | |
| puts "Current process pid : #{pid}" | |
| child_pids = [] | |
| 6.times.each do |i| | |
| child_pids << Process.fork do | |
| Process.setproctitle("ruby childp n #{i} with #{i * 3}s") | |
| puts "sleeping #{i * 3}s"; sleep i * 3 | |
| end |
This file contains hidden or 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 "bundler/inline" | |
| gemfile(true) do | |
| source "https://rubygems.org" | |
| git_source(:github) { |repo| "https://github.com/#{repo}.git" } | |
| # Activate the gem you are reporting the issue against. |