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
| find . -type f -mtime -4h -d 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
| #!/usr/bin/env ruby | |
| @slave_status = Hash[%x(mysql -uroot -e 'SHOW SLAVE STATUS \\\G').split(/\s*\n\s*/).map { |e| spl = e.split(/\:\s*/); spl.size == 2 ? [spl.first, spl.last] : nil }.compact] | |
| def slave_healthy? | |
| @slave_status['Slave_IO_Running'] == 'Yes' && | |
| @slave_status['Slave_SQL_Running'] == 'Yes' && | |
| @slave_status['Seconds_Behind_Master'] != 'NULL' && | |
| @slave_status['Seconds_Behind_Master'].to_i < 1800 | |
| 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
| #!/usr/bin/env ruby | |
| # | |
| # How to make Ruby httpclient throw Encoding::CompatibilityError with Image/IO object on EY Server. | |
| # Use case is update a Facebook object with a parameter containing UTF-8 escaped strings and a file upload. | |
| # Execute with 'bundle exec <script>' on a Gemfile containing httpclient or use system gem | |
| # The problem lies in Encoding and the request.dump method used by FbGraph debug. | |
| # On Engine Yard servers the POSTing with httpclient with multipart Content-Types ( a file upload + the UTF-8 body content) causes | |
| # issue when reading the image from disk. If the image is a string, no problem. |
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
| #!/usr/bin/env ruby | |
| # | |
| # How to make Ruby httpclient throw Encoding::CompatibilityError with Image/IO object. | |
| # Use case is update a Facebook object with a parameter containing UTF-8 escaped strings and a file upload. | |
| # This has been duplicated on OSX 10.7 and Engine Yard, Gentoo. | |
| # Execute with 'bundle exec <script>' on a Gemfile containing httpclient or use system gem | |
| # The problem lies in Encoding and the request.dump method used by FbGraph debug. | |
| # On Engine Yard servers the POSTing with httpclient with multipart Content-Types ( a file upload + the UTF-8 body content) causes |
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
| require 'fog' | |
| # Fetch and save backup on TARGET | |
| storage = Fog::Storage.new({:provider => 'AWS', :aws_access_key_id => ENV['AWS_KEY'], :aws_secret_access_key => ENV['AWS_SECRET']}) | |
| dir = storage.directories.get('<YOUR DIR>') | |
| file = dir.files.get "<S3 PATH TO FILE>" | |
| output = File.new "<LOCAL FILE PATH>", "w" | |
| output.write file.body | |
| output.close |
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
| Sidekiq.redis {|conn| conn.smembers('workers').map{|w| msg = conn.get("worker:#{w}"); msg ? [w, Sidekiq.load_json(msg)] : nil; }.compact.map{|w| w[1]["queue"]}} |
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
| Sidekiq.redis {|conn| conn.smembers('workers').map{|w| msg = conn.get("worker:#{w}"); msg ? [w, Sidekiq.load_json(msg)] : nil; }.compact} |
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
| 1. Convert PEM into pub SSH key file: | |
| ssh-keygen -e -f amazon-ec2-key.pem >> amazon-ec2-key.pem.pub | |
| 2. Generate a PEM from a SSH key: | |
| openssl rsa -in my_tunneler -outform pem > my_tunneler.pem |
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
| #!/bin/bash | |
| # from http://ubuntuserverguide.com/2012/06/how-to-installing-nginx-with-php5-and-mysql-support-on-ubuntu-server-12-04-lts.html | |
| PHP_SCRIPT=/usr/sbin/php-fastcgi | |
| FASTCGI_USER=www-data | |
| FASTCGI_GROUP=www-data | |
| PID_DIR=/var/run/php-fastcgi | |
| PID_FILE=/var/run/php-fastcgi/php-fastcgi.pid | |
| RET_VAL=0 | |
| case "$1" in |
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
| ls | egrep -e '^[a-z0-9]{8}-.*' | xargs du | awk '{ SUM += $1} END {print SUM/1024/1024}' |