on CI and local
export RUBYOPT="-W:deprecated" # show warnings, deprecations only
# A script to migrate Sidekiq's redis to a new server. | |
# This obviously can work for any redis, but I only handled | |
# data types that Sidekiq uses. | |
require 'redis' | |
old_redis = Redis.new url: 'redis://old-redis:6379' | |
new_redis = Redis.new url: 'redis://new-redis:6379' | |
unknowns = [] |
on CI and local
export RUBYOPT="-W:deprecated" # show warnings, deprecations only
module AMS | |
module V09 | |
class Serializer < ActiveModel::Serializer | |
def serializable_hash(adapter_options = nil, | |
options = {}, | |
adapter_instance = self.class.serialization_adapter_instance) | |
object.nil? ? nil : super | |
end | |
end |
#!/usr/bin/env ruby | |
require(Dir.pwd + "/config/environment") | |
ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config| | |
ActiveRecord::Base.establish_connection(db_config.config) | |
context = ActiveRecord::Base.connection.migration_context | |
missing_migrations = [] |
List moved
Please use https://github.com/bf4/learning to fork and pull changes.
#!/usr/bin/env bash | |
git ls-files db/migrate/*.rb | sort | tail -1 | \ | |
ruby -e "schema_version=STDIN.read[/\d+/]; init_schema=%(db/migrate/#{schema_version}_init_schema.rb); | |
%x(git rm -f db/migrate/*.rb; | |
mkdir db/migrate; | |
git mv db/schema.rb #{init_schema}; | |
rake db:migrate; | |
git add db/schema.rb; git commit -m 'Squashed migrations')" |
require "active_record" | |
databases = ActiveRecord::Tasks::DatabaseTasks.setup_initial_database_yaml | |
db_namespace = namespace :db do | |
if Rails.version.start_with?("6.0") | |
# https://github.com/rails/rails/pull/38770/files | |
namespace :rollback do | |
ActiveRecord::Tasks::DatabaseTasks.for_each(databases) do |name| |
# Based on logfmt: | |
# https://www.brandur.org/logfmt | |
# For more complete implementation see: | |
# see https://github.com/arachnid-cb/logfmtr/blob/master/lib/logfmtr/base.rb | |
# For usage see: | |
# https://blog.codeship.com/logfmt-a-log-format-thats-easy-to-read-and-write/ | |
# https://engineering.heroku.com/blogs/2014-09-05-hutils-explore-your-structured-data-logs/ | |
# For Ruby parser see: | |
# https://github.com/cyberdelia/logfmt-ruby |
#!/usr/bin/env ruby | |
# List all keys stored in memcache. | |
# Credit to Graham King at http://www.darkcoding.net/software/memcached-list-all-keys/ for the original article on how to get the data from memcache in the first place. | |
require 'net/telnet' | |
require 'csv' | |
headings = %w(id expires bytes key) | |
rows = [] |