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 HasAttributesFor | |
module ActiveRecord | |
def self.included(ar) | |
ar.extend ClassMethods | |
end | |
module ClassMethods | |
def has_attributes_for(association) | |
primary_key_name = reflect_on_association(association).primary_key_name | |
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
# work in progress | |
domain=www.somedomain.com | |
root_domain=`echo $domain | sed 's:www\.::'` | |
while true; do | |
clear | |
if [ `dig $domain +short | wc -l` -gt 1 ]; then | |
echo 'still bad...'; | |
else | |
echo 'Caching servers are ok now!!!!!!!!!!!!!!!!!!' | |
for nameserver in `dig $root_domain NS +short`; do |
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 'rubygems' | |
require 'eventmachine' | |
module Console | |
PROMPT = "\n>> ".freeze | |
def post_init | |
send_data PROMPT | |
send_data "\0" | |
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
ruby_block do | |
myserver_ip = wait_for_database_ip | |
end | |
mysql_user "foo" do | |
server_ip myserver_ip | |
.... | |
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
ruby_block do | |
resource = resource("mysql_user:foo") | |
resource.server_ip = wait_for_server_ip | |
end | |
mysql_user "foo" do | |
server_ip nil | |
.... | |
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
# Cookbook Name:: s3fs | |
# Recipe:: default | |
if ['solo', 'app', 'util', 'app_master'].include?(node[:instance_role]) | |
http_request "reporting for s3fs" do | |
url node[:reporting_url] | |
message :message => "configuring s3fs" | |
action :post | |
epic_fail true |
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
function make_doc_2d() { | |
defaults write com.apple.dock no-glass -boolean YES | |
killall Dock | |
} | |
function make_doc_3d() { | |
defaults write com.apple.dock no-glass -boolean NO | |
killall Dock | |
} |
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 'rubygems' | |
require 'eventmachine' | |
$stdout.sync = true | |
$stderr.sync = true | |
EM.run { | |
EM.add_periodic_timer(0.1) { | |
$stdout.write "stdout\n" |
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 EventMachine | |
def self.system3(cmd, *args, &cb) | |
cb ||= args.pop if args.last.is_a? Proc | |
init = args.pop if args.last.is_a? Proc | |
# merge remaining arguments into the command | |
cmd = ([cmd] + args.map{|a|a.to_s.dump}).join(' ') | |
new_stderr = $stderr.dup |
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
service "apache2" do | |
action [:stop] | |
end | |
service "apache2" do | |
action [:start] | |
end |
OlderNewer