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
# Copy to Rails console and call with a class parameter. Assumes | |
# /var/tmp exists and is writable | |
require 'csv' | |
def export_objects(klass) | |
objects = klass.last(10000) | |
CSV.open("/var/tmp/#{klass}.csv", 'w') do |row| | |
row << klass.attribute_names | |
objects.each do |o| | |
row << o.attributes.values |
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
#!/usr/bin/env ruby | |
# Don't remove devops containers that might be databases | |
def database_container?(line) | |
line.match?(/postgres/) || line.match?(/redis/) | |
end | |
# docker ps -f "before=containerId" | grep expression > /var/tmp/containers.txt | |
File.open('/var/tmp/containers.txt').each do |line| | |
next if database_container?(line) |
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
mysql> SELECT r.trx_id waiting_trx_id, r.trx_mysql_thread_id waiting_thread, r.trx_query waiting_query, | |
b.trx_id blocking_trx_id, b.trx_mysql_thread_id blocking_thread, b.trx_query blocking_query | |
FROM information_schema.innodb_lock_waits w | |
INNER JOIN information_schema.innodb_trx b ON b.trx_id = w.blocking_trx_id | |
INNER JOIN information_schema.innodb_trx r ON r.trx_id = w.requesting_trx_id\G |
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
[mysqld] | |
# Slow Log | |
#slow_query_log = 1 | |
#log_queries_not_using_indexes = 1 | |
#long_query_time = 1 | |
# Allow GROUP BY to work like it did before MySQL 5.7.5, for Rails 3.2 | |
# compatibility, i.e., remove ONLY_FULL_GROUP_BY from the default | |
sql_mode = "STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" |