we use the ro gem
a-2:~/git/dojo4/www $ ls public/ro/
chiclets pages people posts
# regarding : http://gist.github.com/157782 | |
# regarding : http://drawohara.com/post/151193800/ruby-symbol-to-hash | |
# | |
class Symbol | |
def to_h(&block) | |
Hash[to_sym, block && (block.call || eval(to_s, block))] | |
end | |
end |
# regarding : http://gist.github.com/157782 | |
# regarding : http://drawohara.com/post/151193800/ruby-symbol-to-hash | |
# | |
class Binding | |
def map *vars | |
vars.flatten.compact.inject({}){|h,v| h.update v => eval(v.to_s, self)} | |
end | |
alias_method '>', 'map' | |
end |
# regarding : http://gist.github.com/157782 | |
# regarding : http://drawohara.com/post/151193800/ruby-symbol-to-hash | |
# | |
class Binding | |
def > *vars | |
vars.flatten.compact.inject({}){|h,v| h.update v => eval(v.to_s, self)} | |
end | |
end |
we use the ro gem
a-2:~/git/dojo4/www $ ls public/ro/
chiclets pages people posts
def run! | |
pid = fork do | |
exec_pid = fork do | |
$0 = "heaven[#{Heaven.current_sha}] : executing deployment of #{application_name}" | |
out_file = File.new(log, "w") | |
STDIN.reopen("/dev/null") | |
STDOUT.reopen(out_file) | |
STDERR.reopen(out_file) |
sentence = "there is a wild rose" | |
letters = sentence.gsub(' ','').split(//) |
# An idea on how to sort and filter Ruby collections in a functional | |
# style | |
# Just using Struct for convenience, this could be a normal class. | |
User = Struct.new(:first_name, :last_name, :admin) do | |
def self.sort_by_name | |
# Define a new sort | |
lambda do |x,y| | |
# last name, first name DESC |
function silencing_stderr() { | |
$* 2>/dev/null | |
} | |
function branch_names() { | |
git br | awk '{print $1}' | grep -v '*' | xargs | |
} | |
function most_recent_commit() { | |
git log . | grep "Date: " | cut -c 9- | head -1 |
# via http://blog.zerosum.org/2011/03/02/better-aws-access-control-with-iam-and-fog.html | |
require 'fog' | |
username = 'testuser' | |
bucket = 'uniquebucketname1234' | |
aws_credentials = { | |
:aws_access_key_id => 'YOUR-ACCESS-KEY-ID', | |
:aws_secret_access_key => 'YOUR-SECRET-ACCESS-KEY' |
#!/usr/bin/env ruby | |
require 'set' | |
# This code is meant to demonstrate the difficulty of actually applying .gitignore semantics manually. It supports a key subset of .gitignore | |
# behaviors, including: | |
# * Anchored and unanchored patterns/globs. | |
# * Un-ignoring of patterns/globs, with the same quirky semantics as git. | |
# * Escaping a leading hash in a pattern. | |
# * User-wide exclusion list. | |
# * Top-of-repo .gitignore. |