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
Dir["db/migrate/*"].each do |v| | |
next if v == "." or v == ".." or v == ".svn" | |
version = File.basename(v).split('_').first | |
begin | |
ActiveRecord::Base.connection.execute("INSERT INTO schema_migrations values ('#{version}')") | |
rescue => e | |
p e | |
exit | |
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
module QueryTrace | |
def self.enable! | |
::ActiveRecord::LogSubscriber.send(:include, self) | |
end | |
def self.append_features(klass) | |
super | |
klass.class_eval do | |
unless method_defined?(:log_info_without_trace) | |
alias_method :log_info_without_trace, :sql |
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
root@li615-48:~# echo -e "your-username:`perl -le 'print crypt("your-password","salt")'`" > /path/to/httpasswd |
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
module SerializedAttrAccessor | |
module ClassMethods | |
def define_serialized_attr_accessor(attribute) | |
self.class_eval %Q{ | |
def #{attribute}=(val) | |
self.serialized_column[:#{attribute}] = val | |
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
Dir[Rails.root.join('app', 'models', '*')].each do |path| | |
file = File.basename(path, '.rb') | |
begin | |
klass = file.classify.constantize | |
if klass.respond_to?(:select) | |
max_id = klass.maximum(:id).to_i + 1 | |
sequence = ActiveRecord::Base.connection.execute("SELECT nextval('#{klass.table_name}_id_seq')").first['nextval'].to_i | |
if sequence <= max_id | |
puts "Updating sequence for #{klass.table_name}" |
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
# Get number of lines | |
grep "Processing" log/development.log | wc -l | |
# Replace LINE_NUMBER the minimum line number | |
grep "Processing" log/development.log | awk 'NR > LINE_NUMBER { print $3 }' | sort | uniq |
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
sudo apt-get install munin munin-node -y | |
cd /munin/parent/dir | |
mkdir munin | |
sudo chown munin:munin munin | |
sudo vim /etc/munin/munin.conf | |
Add htmldir to conf: | |
htmldir /munin/parent/dir/munin |