- disable backups (
backup_retention=0) - disable multi-AZ and autovacuum
pg_dump -Fc(compressed) andpg_restore -j(parallel)- Increase
maintenance_work_mem
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'nokogiri' | |
| require 'open-uri' | |
| # Get a Nokogiri::HTML:Document for the page we're interested in... | |
| doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove')) | |
| # Do funky things with it using Nokogiri::XML::Node methods... | |
| #### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ActiveSupport::Notifications.subscribe 'halted_callback.action_controller' do |name, start, finish, id, payload| | |
| Rails.logger.warn { '=' * 80 } | |
| Rails.logger.warn { "HALTED CALLBACK: #{ payload[:filter] }" } | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Updated for Ruby 2.3 | |
| string_t = None | |
| def get_rstring(addr): | |
| s = addr.cast(string_t.pointer()) | |
| if s['basic']['flags'] & (1 << 13): | |
| return s['as']['heap']['ptr'].string() | |
| else: | |
| return s['as']['ary'].string() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "csv" | |
| require "date" | |
| puts CSV::HeaderConverters.keys.inspect # => [:downcase, :symbol] | |
| # Add new header converter | |
| CSV::HeaderConverters[:remap] = lambda do |raw_value| | |
| raw_value = raw_value.to_sym | |
| case raw_value | |
| when :country |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Vim Script | |
| =========== | |
| #Defining functions | |
| ```VimL | |
| fun! Foo() | |
| " function body | |
| endfun |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'thor' | |
| class SubCommandBase < Thor | |
| def self.banner(command, namespace = nil, subcommand = false) | |
| "#{basename} #{subcommand_prefix} #{command.usage}" | |
| end | |
| def self.subcommand_prefix |
TIL attr_* methods are optomized.
class Whatever
def foo
@foo
end
attr_reader :bar
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # spec_helper.rb | |
| RSpec.configure do |config| | |
| ... | |
| # テスト完了後一度だけ実行される | |
| config.after(:suite) do | |
| DatabaseCleaner.clean_with(:truncation) | |
| end | |
| # 各テスト実行前に実行される | |
| config.before(:each) do |spec| |