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 | |
# These are custom Rake tasks to decrypt credentials in plain files and encrypt them back after changes (useful for editing in your local IDE if the development environment is Docker, where `rails credentials:edit` can't open your IDE): | |
# ```bash | |
# # Decrypt credentials | |
# bin/rails credentials:decrypt | |
# # Encrypt credentials | |
# bin/rails credentials:encrypt |
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
require 'spec_helper' | |
class Dummy | |
def go(a:) | |
end | |
end | |
RSpec.describe 'test' do | |
# All these tests should fail, but the misbehavior makes "with double with `have_received`" pass. | |
subject { Dummy.new.go(args) } |
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 BM | |
def self.bm(name) | |
@stats ||= {} | |
@stats[name] ||= { time: 0, times_called: 0, avg_time: 0 } | |
start_time = Time.zone.now | |
yield | |
@stats[name][:time] += (Time.zone.now - start_time) | |
@stats[name][:times_called] += 1 | |
@stats[name][:avg_time] = @stats[name][:time].to_f / @stats[name][:times_called] | |
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
p `heroku apps -o barkibu`.split("\n").drop(1).map { |app| app.gsub(/\s\(.*\)/, '') }.each_with_object({}) { |app, collector| collector[app] = `heroku ps -a #{app}` }.keep_if { |k,v| !(v =~ /No dynos/) }.keys |
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
#!/usr/bin/ruby | |
require 'fileutils' | |
def basename(file) | |
File.basename(file, File.extname(file)) | |
end | |
def all | |
Dir.glob('*').map |
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
#!/usr/bin/env ruby | |
require 'fileutils' | |
require 'byebug' | |
VERBOSE = false | |
DRY_RUN = false | |
class Conflict | |
SUFFIX_SEPARATOR = '-' |
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
LOG_FILENAME = 'heroku-logs' | |
REQUEST_START_REGEX = /(.+)Started (.+) \"(.+)\"/ | |
REDIRECT_REGEX = /(.+)Redirected to (.+barkibu.com)(.+)/ | |
log_lines = File.readlines(LOG_FILENAME) | |
redirects = [] | |
last_request = {} | |
log_lines.each do |line| |
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
LOG_FILENAME = 'heroku-logs' | |
REQUEST_START_REGEX = /(.+)Started (.+) \"(.+)\"/ | |
REDIRECT_REGEX = /(.+)Redirected to (.+barkibu.com)(.+)/ | |
log_lines = File.readlines(LOG_FILENAME) | |
redirects = [] | |
last_request = {} | |
log_lines.each do |line| |
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
#!/usr/bin/env ruby | |
require 'json' | |
exec 'rspec --format json --out rspec_results.json' unless File.exists? 'rspec_results.json' | |
results = JSON.parse(File.read 'rspec_results.json') | |
total_runtime = results['summary']['duration'] | |
total_examples = results['examples'] |
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
mysqldump -h origin.server.com -u the_origin_user -p the_origin_database --ignore-table=the_origin_database.that_huge_table | tee dump.sql | mysql the_database -u the_user --password=ThePassword | |
mysqldump -h origin.server.com -u the_origin_user -p the_origin_database that_huge_table --no-data | mysql the_database -u the_user --password=ThePassword | |
mysqldump -h origin.server.com -u the_origin_user -p the_origin_database that_huge_table | mysql the_database -u the_user --password=ThePassword |
NewerOlder