Skip to content

Instantly share code, notes, and snippets.

@dreamr
dreamr / gist:7028011
Last active December 25, 2015 19:29
I was showing method chaining to someone, @jgarcia I think
reporter = Reporting::Reporter.new
def do_shit
reporter.add_msg_line "Starting do shit"
rescue Exception => e
reporter.add_msg_line "There was an error! #{e.message}"
ensure
reporter.send_event("do Shit")
end
@dreamr
dreamr / gist:6995089
Last active December 25, 2015 14:59
firing up a new ec2 server

firing up a new ec2 server

NOTE!! Bug in knife ec2 - v

  • knife the server once
  • log in with generic ubuntu once
    • fix encrypted dbag value
    • ensure edbs is at /etc/chef/encrypted_data_bag_secret has the correct key (get from dreamr)
(ruby-1.9.3) ~/proj/hvst/infrastructure $ knife ec2 server create -r 'role[base], role[app--rails]' -I ami-daac32ea -f m1.medium -G hvst-base -x ubuntu -Z us-west-2b -N app02.hvst.com
Instance ID: i-295ba41e
Flavor: m1.medium
Image: ami-daac32ea
Region: us-west-2
Availability Zone: us-west-2b
Security Groups: hvst-base
Tags: {"Name"=>"app02.hvst.com"}
SSH Key: staginghvstcom
how do I get from here (app01)
(ruby-1.9.3) ~/proj/hvst/infrastructure $ knife node show app01.hvst.com
Node Name: app01.hvst.com
Environment: _default
FQDN: app01.hvst.com
IP: 54.218.202.46
Run List: role[base], role[app--rails]
Roles: base, internal--shell, internal--logs, internal--security, internal--mailer, internal--monitoring, internal--datadog, internal--system_tools, app--rails, internal--development, internal--image_tools
Recipes: base, runit, chef-client, omnibus_updater, chef-client::config, ohai, hvst::route53, tmux, grc, zsh, users::sysadmins, hostname, resolver, ntp, logwatch, logrotate, papertrail-cookbook, openssh, sysctl, iptables, hvst::iptables, sudo, denyhosts, chkrootkit, rkhunter, postfix::sasl_auth, postfix::aliases, datadog::dd-agent, datadog::dd-handler, datadog::network, htop, monit, newrelic-sysmond, sysstat, curl, git, rsync, vim, xml, xslt, zip, build-essential, postgresql::libpq, imagemagick, imagemagick::devel, hvst::ruby, nodejs, hvst::rails, hv
@dreamr
dreamr / gist:6749273
Last active December 24, 2015 05:19
git workflow
### Git Workflow
Answering the following questions helps you choose a branch workflow:
* Where do important phases of development occur?
* How can you identify (and backport) groups of related change?
* Do you have work which often needs to be updated in multiple distinct long-lived branches?
* What happens when emergency patches are required?
* What should a branch for a particular purpose (including user-tactical) be named?
* What is the lifecycle of a branch?
CREATE OR REPLACE FUNCTION GETUTCDATE() RETURNS TIMESTAMP AS '
SELECT CAST(LOCALTIMESTAMP AT TIME ZONE ''UTC'' AS TIMESTAMP);
' LANGUAGE SQL VOLATILE;
GETUTCDATE();
@dreamr
dreamr / gist:6672685
Last active December 23, 2015 17:59
learning aid for the jr devs, passing ruby lambdas as first class args
printer = ->(msg) { puts "#{msg}" }
logger = ->(msg) { File.open("test.txt", "a") {|f| f.write(msg) } }
class Person
def initialize(first_name, last_name)
@first_name, @last_name = first_name,
last_name
end
@dreamr
dreamr / gist:6672090
Last active December 23, 2015 17:59
ruby self trick - learning aid for the jr devs
require "forwardable"
class Items
include Enumerable
extend Forwardable
def_delegators :@all, :each, :map, :inject,
:reduce, :select, :reject
attr_reader :all, :filtered
alias rtest='ruby -Ilib -Itest '
alias gs="git status"
alias gcb="git checkout -b "
alias gch="git checkout "
alias gca="git commit -a"
alias gpo="git push origin "
alias gri="git rebase -i "
alias gfo="git fetch origin"
alias gl='git log --pretty='\''format:%Cblue%h%d%Creset %ar %Cgreen%an%Creset %s'\'' --graph'
create_table "bonds", :force => true do |t|
t.string "currency"
t.string "display_name"
t.decimal "current_yield", :precision => 19, :scale => 4
t.decimal "previous_yield", :precision => 19, :scale => 4
t.datetime "close_date"
t.string "ric"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end