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
namespace :util do | |
desc "apt software update" | |
task :apt_upgrade do | |
run "#{sudo} apt-get update -q" | |
run %Q\#{sudo} sudo apt-get -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade -q -y\ | |
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
desc "Restarts app servers in a rolling fashion, one by one with wait in between" | |
task :rolling_restart, roles: [:passenger] do | |
servers = find_servers_for_task(current_task) | |
servers.each do |s| | |
run "touch #{current_path}/tmp/restart.txt", hosts: s.host | |
puts "#{s.host} restarting...I'm sleep doe." | |
sleep 45 | |
status = capture "sudo passenger-status; true", hosts: s.host | |
# Sometimes nginx/passenger is a bit wonky and fails to restart? | |
# Not sure if it's because of the load balancer fucking things up or what |
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 DateTimeUtils | |
def season | |
case self.month | |
when 3, 4, 5 | |
'Spring' | |
when 6, 7, 8 | |
'Summer' | |
when 9, 10, 11 | |
'Fall' | |
when 12, 1, 2 |
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
# Usage: | |
# CheckImageHotlinkStatus.call('http://some-domain/image.jpg') | |
class CheckImageHotlinkStatus | |
require 'net/http' | |
require 'uri' | |
def self.call(image_url) | |
uri = URI(image_url) | |
req = Net::HTTP::Get.new(uri) | |
req['Referer'] = 'http://your-site-here.com' | |
response = Net::HTTP.start(uri.hostname, uri.port) do |http| |
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 | |
require 'singleton' | |
require 'thread' | |
# Test to see if I remember how to use threads in Ruby properly | |
class ThreadCounter | |
include Singleton | |
NUM_THREADS = 4 |
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 | |
# Backs up MySQL databases with zero downtime using Percona Xtrabackup. | |
# Stores 30 days worth on Amazon s3. | |
# These {{ double bracket }} things are Ansible/Jinja (ansible-vault) variables. | |
# Fill them in for your own usage. | |
MYSQLROOT=root | |
MYSQLPASS="{{ mysql_root_pass }}" | |
S3BUCKET={{ mysql_backup_bucket }} |
OlderNewer