Skip to content

Instantly share code, notes, and snippets.

@luonghuy24
luonghuy24 / even_fibonacci_numbers.rb
Created May 17, 2018 11:58
Even Fibonacci Numbers
# sum of the even-valued terms in the Fibonacci sequence (starting with 1 and 2) whose values do not exceed four million
result = 0
current_number, next_number = 1 , 2
while current_number < 4000000
if current_number % 2 == 0
result += current_number
end
current_number, next_number = next_number, current_number + next_number
@luonghuy24
luonghuy24 / gist:2261fa1c9c0096b9f183ddbf5fffd68c
Created October 17, 2017 04:57 — forked from dhh/gist:1014971
Use concerns to keep your models manageable
# autoload concerns
module YourApp
class Application < Rails::Application
config.autoload_paths += %W(
#{config.root}/app/controllers/concerns
#{config.root}/app/models/concerns
)
end
end