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
# Ip.valid? '1.2.3.4' | |
module Ip | |
def self.pattern | |
@pattern ||= { | |
# pattern to match a single ip address or cidr | |
:ip => %r{^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})(?:\/\d{1,2})?$}, | |
} | |
end | |
def self.valid? address |
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 'benchmark' | |
require 's3_multi_upload' | |
config = { | |
:access_key_id => 'xxx', | |
:secret_access_key => 'xxx', | |
:bucket => :s3_multi_upload, | |
:file => 'ubuntu-12.04-beta2-dvd-amd64.iso', # 1.6 gb | |
} |
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
%w[sequel aws-sdk socket logger json pathname config upload].each {|l| require l} | |
module MysqlBackup | |
class Agent | |
include Config | |
attr_accessor :summary, :pool, :path, :log, :db | |
def initialize pool | |
# intent |
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 Enumerable | |
def sum | |
self.reduce :+ | |
end | |
def mean | |
self.sum / self.size | |
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
require 'sequel' | |
config = { | |
:database => { | |
:adapter => 'mysql2', | |
:database => 'mysql_backup_reports', | |
:host => '1.2.3.4', | |
:user => 'backup', | |
:password => 'pants' | |
}, |
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 'net/https' | |
require 'uri' | |
config = { | |
nagios: { | |
url: 'https://nagios.domain.tld/nagios/cgi-bin/cmd.cgi', | |
auth: ['user', 'password'], # basic auth | |
command_types: [22, 23], # enable / disable | |
}, | |
retry_limit: 3, |
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
set -l GITHUB https://raw.github.com/lunks/fish-nuggets/master/functions | |
curl --create-dirs -o ~/.config/fish/functions/rvm.fish $GITHUB/rvm.fish | |
curl -o ~/.config/fish/functions/cd.fish $GITHUB/cd.fish |
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
set PATH $HOME/.rbenv/bin $PATH | |
set PATH $HOME/.rbenv/shims $PATH | |
rbenv rehash >/dev/null ^&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
# | |
# a simple cap recipe for deploying rack apps (such as sinatra or rails) using unicorn | |
# via scp using a dedicated deploy user with sudo access to run commands as the daemon user | |
# | |
# app options | |
set :application, 'app' | |
set :repository, '.' # deploy from the current working directory | |
# deploy options |
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 'thread' | |
class ThreadPool | |
attr_reader :size | |
def initialize size = 24 | |
@size = size | |
@queue = Queue.new | |
@pool = size.times.collect do | |
Thread.new do |
OlderNewer