Skip to content

Instantly share code, notes, and snippets.

desc "creates database & database user"
task :create_database do
set :root_password, Capistrano::CLI.password_prompt("MySQL root password: ")
set :db_user, Capistrano::CLI.ui.ask("Application database user: ")
set :db_pass, Capistrano::CLI.password_prompt("Password: ")
set :db_name, Capistrano::CLI.ui.ask("Database name: ")
run "mysql --user=root --password=#{root_password} -e \"CREATE DATABASE IF NOT EXISTS #{db_name}\""
run "mysql --user=root --password=#{root_password} -e \"GRANT ALL PRIVILEGES ON #{db_name}.* TO '#{db_user}'@'localhost' IDENTIFIED BY '#{db_pass}' WITH GRANT OPTION\""
@andhapp
andhapp / webapp.rb
Created November 18, 2010 23:11 — forked from igrigorik/webapp.rb
require 'rubygems'
require 'rack'
class Object
def webapp
class << self
define_method :call do |env|
func, *attrs = env['PATH_INFO'].split('/').reject(&:empty?)
[200, {}, send(func, *attrs)]
end
#!/usr/bin/env ruby
require 'rbconfig'
RUBY = Config::CONFIG['bindir'] + '/' + Config::CONFIG['RUBY_INSTALL_NAME'] + Config::CONFIG['EXEEXT']
BOLD = "\e[1m"
WHITE = "\e[37m"
RED = "\e[31m"
GREEN = "\e[32m"
YELLOW = "\e[33m"
BLACK_BG = "\e[40m"
BLUE_BG = "\e[44m"
ruby -e 'puts Object.constants.grep( /RUBY/ ).map{ |c| "##{[c, Object.const_get(c)].inspect}"}'
# :PROCESS: ruby, "ruby %f 2>&1"
# :BRACKET_CODE: "[ruby]", "[/ruby]"
# :TEXT:
#
# In the <a
# href="http://devver.net/blog/2009/06/a-dozen-or-so-ways-to-start-sub-processes-in-ruby-part-1/">previous
# article</a> we looked at some basic methods for starting subprocesses in Ruby.
# One thing all those methods had in common was that they didn't permit a lot of
# communication between parent process and child. In this article we'll examine
# a few built-in Ruby methods which give us the ability to have a two-way