Let's say you want to host domains first.com
and second.com
.
Create folders for their files:
# lib/tasks/db.rake | |
namespace :db do | |
desc "Dumps the database to db/APP_NAME.dump" | |
task :dump => :environment do | |
cmd = nil | |
with_config do |app, host, db, user| | |
cmd = "pg_dump --host #{host} --username #{user} --verbose --clean --no-owner --no-acl --format=c #{db} > #{Rails.root}/db/#{app}.dump" | |
end | |
puts cmd |
# spec/rails_helper.rb or spec/spec_helper.rb | |
# ... | |
# require custom matchers from the "support" directory: | |
Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } | |
# ----- | |
# support/matchers/be_success.rb | |
RSpec::Matchers.define :be_success do | |
match do |actual| |
Давай представим ситуацию, когда тебе, в зависимости от какой-то логики нужно вернуть данные разного типа, например есть такая функция:
def function(foo, bar)
result = if foo > bar
10
else
"wrong"
end
end
📆 Jun 22-23, 2017
🌏 Web site: http://reddotrubyconf.com/ Twitter: http://twitter.com/reddotrubyconf
💁 Ping me @cheeaun on Twitter or leave a comment below if you found some awesome stuff for #rdrc2017. This gist will be updated whenever there's new stuff.
🕙 Previously, on RedDotRubyConf...
Output on Ruby 2.6, MacBook Pro (13-inch, 2017, 3.5 GHz Intel Core i7)
Note: I manually removed some BigDecimal
deprecation warnings
Rehearsal ------------------------------------------------
as_json 0.122644 0.000508 0.123152 ( 0.123823)
fast_jsonapi 0.184139 0.000829 0.184968 ( 0.186195)
grape_entity 0.709880 0.003083 0.712963 ( 0.714929)
blueprinter 0.220149 0.004481 0.224630 ( 0.225596)
# Original source: https://gist.github.com/hopsoft/56ba6f55fe48ad7f8b90 | |
# Merged with: https://gist.github.com/kofronpi/37130f5ed670465b1fe2d170f754f8c6 | |
# Benefits of: https://gist.github.com/e12e/e0c7d2cc1d30d18c8050b309a43450ac | |
# And fixes of: https://gist.github.com/joelvh/f50b8462611573cf9015e17d491a8a92 | |
namespace :db do | |
desc 'Dumps the database to backups' | |
task dump: :environment do | |
dump_fmt = ensure_format(ENV['format']) | |
dump_sfx = suffix_for_format(dump_fmt) | |
backup_dir = backup_directory(Rails.env, create: true) |
// Function calls n-times before get '()'; | |
const closureFn = firstArgument => { | |
let sum = firstArgument; | |
return function callMe(nextArgument) { | |
if (nextArgument) { | |
sum += nextArgument; | |
return callMe; | |
} | |
return sum; |