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 :deploy do | |
set :db_user, 'set_db_user' | |
set :db_password, 'set_db_password' | |
set(:environment) { rails_env } | |
set :master, 'localhost' | |
set :slaves, [] | |
set :database_name, "dbprefix_#{rails_env}" | |
# memcached config => [hostname:port] | |
set :memcache_servers, ['localhost:11211'] |
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 'erubis' | |
require 'aws-sdk' | |
module CapistranoExtentions | |
# Run a git command in the `current_path` directory | |
def git(command) | |
run "cd #{current_path} && umask 002 && git #{command}" | |
end | |
# Capture the result of a git command run within the `current_path` directory |
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/deploy.rb | |
def tagged_servers(tag_key, tag_value, default=[]) | |
@ec2 ||= AWS::EC2.new(ec2_endpoint: 'ec2.ap-northeast-1.amazonaws.com') | |
ret = @ec2.instances.map do |instance| | |
next if instance.tags[tag_key] != tag_value | |
next if instance.status != :running | |
instance.dns_name.empty? ? instance.ip_address : instance.dns_name | |
end.compact | |
return default if ret.empty? | |
ret |
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 'rubygems' | |
require 'mechanize' | |
require 'rainbow' | |
m = Mechanize.new | |
m.get('http://www.meigensyu.com/quotations/view/random/') do |random| | |
m.get(random.uri) do |page| | |
text = page.parser.xpath('//div[@class="meigenbox"]/div[@class="text"]').text | |
puts Rainbow(text).color(:blue) | |
end |