If the namespace is not used then the commands will perform on top of the default database.
bundle exec rake db:create
bundle exec rake db:migrate
By using the namespace we are going to use all the configuration for our alternate DB.
require "timeout" | |
module WaitSteps | |
extend RSpec::Matchers::DSL | |
matcher :become_true do | |
match do |block| | |
begin | |
Timeout.timeout(Capybara.default_wait_time) do | |
sleep(0.1) until value = block.call |
def deep_merge(hash1, hash2) | |
result = hash1.dup | |
hash2.keys.each do |key| | |
if hash2[key].is_a?(Hash) && hash1[key].is_a?(Hash) | |
result[key] = deep_merge(hash1[key], hash2[key]) | |
else | |
result[key] = hash2[key] | |
end | |
end |
# config/initializers/hacks.rb | |
Dir[Rails.root.join("lib/hacks/**/*.rb")].each { |file| require file } |
# HACK to enable using protected methods from Rails 4.2 and initial states as default attributes for ActiveRecord | |
module StateMachine | |
module Integrations | |
module ActiveModel | |
public :around_validation | |
end | |
module ActiveRecord | |
public :around_save |
# Capistrano 2 | |
before "deploy", "friday:good_luck" | |
namespace :friday do | |
friday_jumper = %{ | |
┓┏┓┏┓┃ | |
┛┗┛┗┛┃⟍ ○⟋ | |
┓┏┓┏┓┃ ∕ Friday | |
┛┗┛┗┛┃ノ) |
ruby_print = ->(a, b = 28, c = 1) { puts ("ruby" * a).center(b) * c } ; [[2, 14, 2], [3, 14, 2], 7, 7, 7, 6, 5, 4, 3, 2, 1].map { |i| ruby_print.call(*i) } | |
rubyruby rubyruby | |
rubyrubyruby rubyrubyruby | |
rubyrubyrubyrubyrubyrubyruby | |
rubyrubyrubyrubyrubyrubyruby | |
rubyrubyrubyrubyrubyrubyruby | |
rubyrubyrubyrubyrubyruby | |
rubyrubyrubyrubyruby | |
rubyrubyrubyruby |
require "net/http" | |
def start_server | |
# Remove the X to enable the parameters for tuning. | |
# These are the default values as of Ruby 2.2.0. | |
@child = spawn(<<-EOC.split.join(" ")) | |
XRUBY_GC_HEAP_FREE_SLOTS=4096 | |
XRUBY_GC_HEAP_INIT_SLOTS=10000 | |
XRUBY_GC_HEAP_GROWTH_FACTOR=1.8 | |
XRUBY_GC_HEAP_GROWTH_MAX_SLOTS=0 |
# The same algorithm which is used in Google Analytics (https://support.google.com/analytics/answer/2731565?hl=en): | |
# Time-based expiry (including end of day): | |
# - After 30 minutes of inactivity | |
# - At midnight | |
# Enable dynamic scripting for Groovy (https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-scripting.html#_enabling_dynamic_scripting) | |
# ! WARNING: please read about security first | |
# Usage: | |
# |
ssh [email protected] -t "screen -DR session_name" | |
tmux -CC attach -t session_name || tmux -CC new -s session_name |