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
| for request in `grep -e "undefined local variable or method .*html_safe" log/production.log -B 1 | grep FATAL | sed 's/.*FATAL.*\[\(.*\)\]/\1/g'`;do grep "$request" log/production.log | head -n 20 | grep current_user;done | sed 's/.*current_user\(.*\).*/\1/g' | sort | uniq -c | sort -n |
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
| for h in 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24;do echo ""; echo "19/Feb/$h:00"; echo "----------------------"; grep "199.102.210.214 - - \[19\/Feb\/2015\:$h" /var/log/nginx/access.log.1 | wc -l ;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
| grep "19\/Feb\/2015" /var/log/nginx/access.log.1 | sed 's/\(.*\) - - .*/\1/g' | sort | uniq -c | sort -n |
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
| db_name = Rails.configuration.database_configuration[Rails.env]["database"] | |
| sql = "SELECT table_name AS name, table_rows, data_length, index_length FROM information_schema.TABLES WHERE table_schema = '#{db_name}' ORDER BY (data_length + index_length) DESC;" | |
| table_data = ActiveRecord::Base.connection.execute(sql).map{|r| {name: r[0], rows: r[1], data_size: r[2], index_size: r[3]}} |
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
| bash_prompt_command() { | |
| local K="\[\033[0;30m\]" # black | |
| local R="\[\033[0;31m\]" # red | |
| local G="\[\033[0;32m\]" # green | |
| local Y="\[\033[0;33m\]" # yellow | |
| local B="\[\033[0;34m\]" # blue | |
| local M="\[\033[0;35m\]" # magenta | |
| local C="\[\033[0;36m\]" # cyan | |
| local W="\[\033[0;37m\]" # white | |
| local NONE="\[\033[0m\]" |
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 table_name AS "Tables", table_rows, round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" FROM information_schema.TABLES WHERE table_schema = "pyr_revel_prod" ORDER BY (data_length + index_length) DESC; |
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
| redis.subscribe("__keyevent@0__:expired") { |on| on.subscribe { |channel, subscriptions| puts "Subscribed to ##{channel} (#{subscriptions} subscriptions)" }; on.message { |channel, message| puts "Key expired: [#{message}]" }; on.unsubscribe { |channel, subscriptions| puts "Unsubscribed from ##{channel} (#{subscriptions} subscriptions)" }} |
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
| NGINX - Configured to forward root domain requests to SSL, subdomains w/o SSL, and to upgrade /faye to websocket | |
| -------------------------------------------------------------------------------------------------------------------- | |
| upstream my_app_upstream { | |
| server unix:///var/run/my_app/my_app.sock; | |
| } | |
| server { | |
| listen 80; | |
| server_name mydomain.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
| pyr_models = ActiveRecord::Base.subclasses.map(&:name).select{|c| c =~ /Pyr.*/}.sort | |
| pyr_polys = {}.tap{|m| pyr_models.each{|klazz| m[klazz] = begin;obj=klazz.constantize.send(:first); app.polymorphic_path(obj) if obj;rescue Exception => e; e.message;end};nil} | |
| pyr_models_mapped = pyr_polys.select{|k,v| v =~ /\/.*/}.keys | |
| # Those without polymorphic paths | |
| (pyr_models - pyr_models_mapped).sort.each {|m| puts m} | |
| # Those with polymorphic paths |
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
| # Controllers | |
| Dir["#{Rails.root}/../pyr/*/app/controllers/**/*.rb"].each{|p| puts "require #{p}";require p};nil | |
| # Models | |
| Dir["#{Rails.root}/../pyr/*/app/models/**/*.rb"].each{|p| puts "require #{p}";require p};nil |