$ RUBYOPT=W0 ./bin/rspec spec/
...
$ RUBYOPT=W0 bundle exec rspec spec/
...
$ RUBYOPT=W0 rspec
...
$ RUBYOPT=W0 ...
...
$VERBOSE = nil
def suppress_warnings original_verbose = $VERBOSE $VERBOSE = nil yield ensure $VERBOSE = original_verbose end suppress_warnings do require 'some_gem_with_warnings' end
RSpec.configure do |config| config.warnings = false end
RSpec.configure do |config|
config.deprecation_stream = File.open('log/rspec_deprecations.log', 'w')
end$VERBOSE = nil if ENV['SUPPRESS_WARNINGS'] == 'true'
logger.tagged('Your Tag') { logger.info('Message') }
# config/application.rb
config.log_tags = [:method_on_request_object, lambda { |request| request.method.modifier_method }]
# config/application.rb
config.log_tags = [ :request_id, lambda { |request| "#{request.headers['HTTP_X_OS']} #{request.headers['HTTP_X_OS_VERSION']}" } ]
# app/models/user.rb
has_one :four_car_garage
has_many :cars
validates :cars, length: { maximum: 4 }
In terminal
vim todo.txt
Colon (:) (lowercase) q vim :q
Just don't use MacVim @joe :D
This is obviously a joke, it's impossible to quit Vim.
When you want to write destructive migrations please use if_exists: true when you’re trying to remove a table and check for a table existence when you want to add or remove a column ActiveRecord::Base.connection.table_exists?
Case 1:
def up
drop_table :kittens, if_exists: true
end
Case 2:
def up
return unless ActiveRecord::Base.connection.table_exists?(:kittens)
add_column :kittens, :kind, :integer
end
Open term (or equivalent) and paste the following one-liner:
defaults write com.apple.dock persistent-apps -array-add '{tile-data={}; tile-type="spacer-tile";}'; killall Dock
When the Dock restarts, there should be a draggable blank space that you can move anywhere. Repeat to your heart's desire.
$ curl -X POST -H 'Content-type: application/json' --data '{"text": "Something important"}' https://hooks.slack.com/services/YOUR/TOKENIZED/URL
{ "text": "Hello, Slack!", "username": "WebhookBot", "icon_emoji": ":ghost:" }
{ "text": "Hello, World!" }
curl -X POST -H 'Content-Type: application/json' --data @message.json https://hooks.slack.com/services/YOUR/TOKENIZED/URL
If you want to override previously set order (even through default_scope), use reorder() instead.
E.g.
User.order('id ASC').reorder('name DESC')
would ignore ordering by id completely
Ever wanted to display the structure of the current directory except or two directories?
#NPM or yarn project
tree -I node_modules
# Elixir Mix project
tree -I 'deps|test'