I hereby claim:
- I am skojin on github.
- I am skojin (https://keybase.io/skojin) on keybase.
- I have a public key ASBIneplQGFfIiZhlB6VN72mbLa_bwt0kBG4NLr-tcJzAwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
| # Each record of this class store one extra attribute for each model | |
| # Used to store not important data need for reports, data sync, and etc | |
| class ExtraValue < ActiveRecord::Base | |
| belongs_to :record, polymorphic: true | |
| scope :type, ->(klass){ where(record_type: klass) } | |
| scope :record, ->(r){ where(record_id: r.id, record_type: r.class) } | |
| class << self |
| */5 * * * * aws cloudwatch put-metric-data --metric-name MyPassengerCount --namespace "System/Linux" --dimensions "InstanceId=$(ec2metadata --instance-id)" --unit Count --value $(ps ax | grep "[P]assenger RackApp" | wc -l) | |
| */5 * * * * aws cloudwatch put-metric-data --metric-name MyDJWorkersCount --namespace "System/Linux" --dimensions "InstanceId=$(ec2metadata --instance-id)" --unit Count --value $(ps ax | grep "[d]elayed_job" | wc -l) | |
| */5 * * * * aws cloudwatch put-metric-data --metric-name MyCometServerCount --namespace "System/Linux" --dimensions "InstanceId=$(ec2metadata --instance-id)" --unit Count --value $(ps ax | grep "[b]randrep_comet_server" | wc -l) | |
| # N of Passenger processed that older then 1 hour | |
| */30 * * * * aws cloudwatch put-metric-data --metric-name MyOldPassengerCount --namespace "System/Linux" --dimensions "InstanceId=$(ec2metadata --instance-id)" --unit Count --value $(ps axo etimes,args | grep "RackApp" | awk '{if ($1 >= (1 * 3600)) print $0}' | wc -l) |
| COOKIE = ARGV[0] | |
| TO = ARGV[1] || 'json/bookmarks' | |
| `mkdir -p #{TO}` | |
| %w{films serials books games person}.each do |type| | |
| print "#{type} " | |
| (1..99).each do |page| | |
| json = `curl 'http://#{type}.imhonet.ru/web.php?path=favorites/all/&domain=#{type}&page=#{page}' --silent -H '#{COOKIE}' -H 'Accept-Encoding: gzip, deflate, sdch' -H 'Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36' -H 'Accept: application/json' -H 'Referer: http://films.imhonet.ru/favorites/all/' -H 'X-Requested-With: XMLHttpRequest' -H 'Connection: keep-alive' --compressed` | |
| break unless json[0] == '{' # if content is not json, then pager ended | |
| print '.' |
| # recursive freeze of hash, array | |
| module DeepFreeze | |
| extend self | |
| def freeze(obj_or_enumerable) | |
| if obj_or_enumerable.respond_to?(:each) | |
| obj_or_enumerable.each { |v| DeepFreeze.freeze(v) } | |
| end | |
| obj_or_enumerable.freeze | |
| obj_or_enumerable |
| SELECT CONCAT(table_schema, '.', table_name), CONCAT(ROUND(table_rows / 1000000, 2), 'M') rows, CONCAT(ROUND(data_length / ( 1024 * 1024 * 1024 ), 2), 'G') DATA, CONCAT(ROUND(index_length / ( 1024 * 1024 * 1024 ), 2), 'G') idx, CONCAT(ROUND(( data_length + index_length ) / ( 1024 * 1024 * 1024 ), 2), 'G') total_size, ROUND(index_length / data_length, 2) idxfrac FROM information_schema.TABLES ORDER BY data_length + index_length DESC LIMIT 20; |
| server { | |
| listen 80 default_server; | |
| proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
| proxy_set_header Host $host; | |
| location / { | |
| proxy_pass http://desthost.com; | |
| } | |
| } |
| module UpdateIgnore | |
| def update_ignore(updates, conditions) | |
| set = updates.map{|k,v| "#{connection.quote_column_name(k)} = #{connection.quote v}" }.join(', ') | |
| connection.update "UPDATE IGNORE #{quoted_table_name} SET #{set} WHERE #{self.where(conditions).where_clauses.join('AND')}" | |
| end | |
| end |
| module ActiveRecordSelectAttributesExtension | |
| # Returns an array of arrays containing the field values. | |
| # Order is the same as that returned by +columns+. | |
| # select_rows("id, type") => [[1, 'one'], [2, 'one'], [3, 'two']] | |
| def select_rows(fields = nil) | |
| scope = fields ? self.scoped.select(fields) : self.scoped | |
| connection.select_rows(scope.to_sql) | |
| end |
| class ApplicationController < ActionController::Base | |
| include ColorizedPrint if Rails.env.development? | |
| end |