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 ActiveRecord | |
| class Migrator | |
| class << self | |
| def get_all_versions | |
| table = Arel::Table.new(schema_migrations_table_name) | |
| # must not be Base.establish_connection b/c that'll drop the mysql2 | |
| # adapter connection and blow up rake db:schema:dump | |
| SchemaMigration.establish_connection(ActiveRecord::Base.configurations['cluster'][Rails.env]) | |
| cluster_migrations = SchemaMigration.connection.select_values(table.project(table['version'])).map{ |v| v.to_i } |
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
| curl -i http://example.com |
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
| ar = User.connection.execute("select id, uid from users order by id asc") | |
| ar.each do |user| | |
| user[1] = 0 if user[1].nil? | |
| UserGlobal.connection.execute("insert into user_globals (id, cluster_id, uid, created_at, updated_at) values (#{user[0]}, 1, #{user[1]}, NOW(),NOW());") | |
| 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
| mysql -u user -p[password] -Nse "show tables like 'tmp%'" database -h host.colo | while read table; do mysql -u user -p[password] -e "drop table $table" database -h host.colo; done |
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
| SELECT * FROM `table` ORDER BY RAND()*probability desc LIMIT 1; | |
| probability is a number from 0 to 1 |
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 tcpdump -i eth0 'port 8125' |
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
| git checkout HEAD -- db/schema.rb |
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
| terminal 1: bundle exec rails s | |
| terminal 2: bundle exec rails s -p 3001 -P tmp/pids/server2.pid |
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
| vim /etc/hosts | |
| 127.0.0.1 c1.localhost |
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
| ack -l 'pattern' | xargs perl -pi -E 's/pattern/replacement/g' |