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 Paperclip | |
class AutoOrient < Paperclip::Processor | |
def initialize(file, options = {}, *args) | |
@file = file | |
end | |
def make( *args ) | |
dst = Tempfile.new([@basename, @format].compact.join(".")) | |
dst.binmode | |
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
# capistrano deployment | |
require "bundler/capistrano" | |
require "capistrano/ext/multistage" | |
set :stages, %w(canary production) | |
set :default_stage, "canary" | |
set :application, "lolcats" | |
set :deploy_to, "/srv/#{application}" |
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 'net/smtp' | |
require 'optparse' | |
module SendFile | |
class CommandlineOptions | |
attr_accessor :options |
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
class Account | |
include NewRelic::Agent::MethodTracer | |
def check_usage | |
end | |
def send_invoice | |
end | |
add_method_tracer :check_usage |
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
require "securerandom" | |
class RollingCounter | |
# :call-seq: RollingCounter.new(redis_client, max_window_seconds) -> counter | |
# | |
# Create a new counter instance, that will store/retrieve counts with | |
# +redis_client+ and return counts within the last +max_window_seconds+ | |
# seconds. | |
# |
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
config.jobs = ActiveSupport::OrderedOptions.new | |
# Controls whether or not workers report heartbeats | |
config.jobs.heartbeat_enabled = true | |
# How often workers should send heartbeats | |
config.jobs.heartbeat_interval_seconds = 60 | |
# How long a worker can go without sending a heartbeat before they're considered dead | |
config.jobs.heartbeat_timeout_seconds = 3 * 60 | |
# How often to check for dead workers | |
config.jobs.dead_worker_polling_interval_seconds = 60 |
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 | |
## disconnect | |
# ./disconnect.rb -u yourusername [-o /your/path] [-p yourhttpproxyserver] | |
# | |
# This is a command-line utility for the bulk-downloading of run data from | |
# the connect.garmin.com web application, which has lackluster export | |
# capabilities. | |
# |
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 | |
# ansible-vault-git-diff -- show what changed in a vaulted file at a specific commit | |
commit="$1" | |
file="$2" | |
if [ -z "$2" ]; then | |
echo "Usage: $0 <commit> <file>" | |
exit 1 | |
fi |
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
# Using v1 of Ruby aws-sdk as currently v2 seems not able to do this (broken?). | |
require 'aws-sdk-v1' | |
key = YOUR_AWS_KEY | |
secret = YOUR_AWS_SECRET | |
region = YOUR_AWS_REGION | |
AWS.config(access_key_id: key, secret_access_key: secret, region: region) | |
s3 = AWS::S3.new | |
bucket = s3.buckets[bucket_name] |
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
$ curl --silent -i http://ojp.nationalrail.co.uk/ | grep 'Powered-By' | |
X-Powered-By: An infinite number of monkeys |
OlderNewer