Skip to content

Instantly share code, notes, and snippets.

Rolen Le rolentle

Block or report user

Report or block rolentle

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View any_vs_length.rb
require 'benchmark'
a = []
iterations = 1_000_000
puts "for empty array"
Benchmark.bm do |x|
x.report("length") { iterations.times do; a.length > 0; end }
x.report("any") { iterations.times do; a.any?; end }
end
@rolentle
rolentle / Foo.rb
Created Mar 18, 2018
Puts example
View Foo.rb
class Foo
def hello
puts "hello"
end
end
Foo.new.hello
# What will return?
View gist:736a7121d084ad15abfca47dbe2961db
name: Cardiothoracic Surgery score: 0.00022565003
Explanation
description: sum of:, value: 0.00045130006, details:
description: max of:, value: 9.0260015e-05, details:
description: ConstantScore(name:cardio*), product of:, value: 9.0260015e-05, details:
description: boost, value: 1.0
description: queryNorm, value: 9.0260015e-05
description: ConstantScore(common_terms:cardio*), product of:, value: 9.0260015e-05, details:
description: boost, value: 1.0
description: queryNorm, value: 9.0260015e-05
View gist:c7da72d7e4bbd9194445
/Users/A664724/.rvm/gems/ruby-2.0.0-p451@global/gems/bundler-1.6.1/lib/bundler/runtime.rb:222: warning: Insecure world writable dir /usr/local in PATH, mode 040777
DEPRECATION WARNING: Model based mass assignment security has been extracted
out of Rails into a gem. Please use the new recommended protection model for
params or add `protected_attributes` to your Gemfile to use the old one.
To disable this message remove the `whitelist_attributes` option from your
`config/application.rb` file and any `mass_assignment_sanitizer` options
from your `config/environments/*.rb` files.
See http://guides.rubyonrails.org/security.html#mass-assignment for more information.
View user.rb
class User < ActiveRecord::Base
has_many :trips
has_many :feed_sources
has_many :photos
has_many :statuses
has_many :checkins
validates :name, :presence => true
def possessive_name
You can’t perform that action at this time.