Skip to content

Instantly share code, notes, and snippets.

@erithmetic
Forked from nbashaw/gist:4069915
Created November 14, 2012 03:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erithmetic/4070015 to your computer and use it in GitHub Desktop.
Save erithmetic/4070015 to your computer and use it in GitHub Desktop.
# hotness = age_in_minutes / (votes**2.5)
def original_hotness(now, created_at, votes)
age_in_minutes = (((created_at.to_f / 60).floor * 60) - ((now.to_f / 60).floor * 60)) / -60
age_in_minutes / (votes**2.5)
end
def new_hotness(now, created_at, votes)
age_in_minutes = (now - created_at) / 60
age_in_minutes / (votes**2.5)
end
require 'time'
require 'test/unit/assertions'
include Test::Unit::Assertions
now = Time.now
created_at = Time.parse('2012-10-10 13:45:00')
assert_equal original_hotness(now, created_at, 0) , new_hotness(now, created_at, 0)
assert_equal original_hotness(now, created_at, 1) , new_hotness(now, created_at, 1)
assert_equal original_hotness(now, created_at, 100), new_hotness(now, created_at, 100)
puts 'pass!'
@erithmetic
Copy link
Author

not quite...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment