The ConnectionAdapter defines two callbacks :checkout
(connect) and :checkin
(disconnect).
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.set_callback :checkout, :after do
raw_connection
end
def stub_rails_env_as(env) | |
allow(Rails).to receive(:env).and_return(ActiveSupport::StringInquirer.new(env.to_s)) | |
end |
alias simulator='open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app' |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -d {database} sql.dump |
# add AWS credentials to ENV variables or modify the script to pass in credentials | |
require 'thread' | |
require 'aws-sdk' | |
# settings | |
region = 'my-region' | |
bucket = 'my-bucket' | |
prefix = 'my-prefix' | |
acl = "private" | |
parallel = 25 |
{ | |
"ensure_newline_at_eof_on_save": true, | |
"font_size": 12.0, | |
"trim_trailing_white_space_on_save": true | |
} |
#!/usr/bin/env bash | |
# settings | |
OUTPUT_FILE=monitor.csv | |
# build command | |
cmd="" | |
cpu_headers="" | |
for (( i=4; i<=$(nproc)+4; i++ )) | |
do |
# add this into application.rb | |
initializer_file = Rails.root.join('config', 'initializers', 'my_initializer.rb') | |
reloader = ActiveSupport::FileUpdateChecker.new([initializer_file]) do | |
load initializer_file | |
end | |
ActiveSupport::Reloader.to_prepare do | |
reloader.execute | |
end |
The ConnectionAdapter defines two callbacks :checkout
(connect) and :checkin
(disconnect).
ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.set_callback :checkout, :after do
raw_connection
end
require 'net/http' | |
require 'json' | |
class Client | |
def call(method, url, path=nil, headers={}, body=nil, timeout=60) | |
net_class = Object.const_get("Net::HTTP::#{constantize(method)}") | |
uri = URI("#{url}#{path}") |
require 'find' | |
biggest_file_by_ext = {} | |
Find.find('.') do |path| | |
next if File.directory?(path) | |
# get file info | |
ext = File.extname(path) | |
next unless ext.length > 0 | |
# get file size | |
size = File.size(path) |