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
#format it | |
bash "format-ebs" do | |
code "mkfs.ext4 /dev/sdf" | |
not_if "e2label /dev/sdf" | |
end |
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 | |
# | |
# A pre-commit hook to test if jammit needs to be run | |
# In case you don't like on the fly stuff | |
# | |
require 'rubygems' | |
require 'jammit' | |
def check_assets(config) |
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
# /etc/profile.d/prompt.sh | |
# Chef managed | |
extra="" | |
<%- @color ||= '' %> | |
if type rvm-prompt >/dev/null 2>&1; then | |
extra+="\[\e[1;36m\](\$(rvm-prompt i v g)) " | |
fi | |
export PS1="<%= @color %>[\u@\h] \[\e[1;35m\]\w\[\e[0m\] $extra\[\e[0m\]\$ " |
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
#monkey patch to get timeout, it's a bit cleaner to define a module and use .send (I think) | |
module PatchedNetHTTPService | |
def self.included(base) | |
base.extend ClassMethods | |
base.class_eval do | |
class << self | |
alias_method_chain :make_request, :timeout | |
end | |
end |
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
#trace mongo in RPM | |
Mongo::Collection.class_eval do | |
include NewRelic::Agent::MethodTracer | |
add_method_tracer :find | |
add_method_tracer :find_one | |
add_method_tracer :find_and_modify | |
add_method_tracer :update | |
add_method_tracer :insert | |
add_method_tracer :save | |
add_method_tracer :remove |
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
# geo.rb | |
# Formulas from | |
# | |
# haversine formula to compute the great circle distance between two points given their latitude and longitudes | |
# | |
# Copyright (C) 2008, 360VL, Inc | |
# Copyright (C) 2008, Landon Cox | |
# | |
# http://www.esawdust.com (Landon Cox) |
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 'chef/mixin/command' | |
class Chef | |
class Recipe | |
include Chef::Mixin::Command | |
def install_egg(name, options={}) | |
version = options.delete(:version) | |
module_name = options.delete(:module) || 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
# vim:ts=2:expandtab | |
require 'rubygems' | |
require 'open-uri' | |
require 'json' | |
#http://wiki.apache.org/couchdb/Compaction | |
if JSON::parse(open("http://localhost:5984/chef").read)["disk_size"] > 100_000_000 | |
res = Net::HTTP.post_form(URI.parse('http://localhost:5984/chef/_compact'), {}) | |
puts res.body |
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
# bash like brace expansion | |
# | |
# {1,2}.3.4.{5,6}.7.8.{9,10} becomes | |
# [1.3.4.5.7.8.9, | |
# 2.3.4.5.7.8.9, | |
# 1.3.4.6.7.8.9, | |
# 2.3.4.6.7.8.9, | |
# 1.3.4.5.7.8.10, | |
# 2.3.4.5.7.8.10, | |
# 1.3.4.6.7.8.10, |
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
#inspired (a lot) by http://blog.gugl.org/archives/47 | |
# Note, to achieve this I should only have to define a formatter. | |
# why BufferedLogger instead of Logger with a buffered IO? | |
# I suspect there is a reason for BufferedLogger so I'll keep it | |
class LineLogger < ActiveSupport::BufferedLogger | |
SEVERITIES = Severity.constants.inject([]) {|arr,c| arr[Severity.const_get(c)] = c; arr} | |
attr_writer :formatter |