View mysql-backup.sh
This file contains 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 }} |
View thread_counter.rb
This file contains 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 |
View check_image_hotlink_status.rb
This file contains 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| |
View date_time_season.rb
This file contains 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 |
View cap_rolling_restart.rb
This file contains 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 |
View cap_util.rb
This file contains 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 |
View jquery-2.1.1.min.js
This file contains 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
/*! jQuery v2.1.1 | (c) 2005, 2014 jQuery Foundation, Inc. | jquery.org/license */ | |
!function(a,b){"object"==typeof module&&"object"==typeof module.exports?module.exports=a.document?b(a,!0):function(a){if(!a.document)throw new Error("jQuery requires a window with a document");return b(a)}:b(a)}("undefined"!=typeof window?window:this,function(a,b){var c=[],d=c.slice,e=c.concat,f=c.push,g=c.indexOf,h={},i=h.toString,j=h.hasOwnProperty,k={},l=a.document,m="2.1.1",n=function(a,b){return new n.fn.init(a,b)},o=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,p=/^-ms-/,q=/-([\da-z])/gi,r=function(a,b){return b.toUpperCase()};n.fn=n.prototype={jquery:m,constructor:n,selector:"",length:0,toArray:function(){return d.call(this)},get:function(a){return null!=a?0>a?this[a+this.length]:this[a]:d.call(this)},pushStack:function(a){var b=n.merge(this.constructor(),a);return b.prevObject=this,b.context=this.context,b},each:function(a,b){return n.each(this,a,b)},map:function(a){return this.pushStack(n.map(this,function(b,c){return a.call(b, |
View backbone-prototype.js
This file contains 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
// Backbone.js 0.9.1 | |
// (c) 2010-2012 Jeremy Ashkenas, DocumentCloud Inc. | |
// Backbone may be freely distributed under the MIT license. | |
// For all details and documentation: | |
// http://backbonejs.org | |
// | |
// HACKED TO BE PROTOTYPE.JS COMPATIBLE BY [SUBIMAGE AT GMAIL DOT COM] | |
// REQUIRES PROTOTYPE >= 1.7.1 |
View backbone-cashboard_extensions.js
This file contains 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
// Overrides Backbone.js features for our specific use in Cashboard. | |
(function(){ | |
// How many times do we try to re-contact the server | |
// if we're offline or the server is before erroring out? | |
var BACKBONE_RETRY_ATTEMPTS=99; | |
// Max timeout should be 10 seconds. | |
var MAX_TIMEOUT=10000; | |
// Helper function to get a value from a Backbone object as a property | |
// or as a function. |
View .autotest.rb
This file contains 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
Autotest.add_hook :initialize do |at| | |
# Ignore these files | |
%w{ | |
.hg .git .svn stories tmtags Rakefile Capfile README .html | |
spec/spec.opts spec/rcov.opts vendor/gems autotest svn-commit .DS_Store | |
}.each {|exception|at.add_exception(exception)} | |
# Map concerned_with files properly. | |
# app/models/[model]/[concern].rb should map to | |
# test/unit/[model]/[concern]_test.rb |
NewerOlder