Skip to content

Instantly share code, notes, and snippets.

@nbashaw
Created November 14, 2012 02:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nbashaw/4069915 to your computer and use it in GitHub Desktop.
Save nbashaw/4069915 to your computer and use it in GitHub Desktop.
# hotness = age_in_minutes / (votes**2.5)
age_in_minutes = (((link.created_at.to_f / 60).floor * 60) - ((Time.now.to_f / 60).floor * 60)) / -60
hotness = age_in_minutes / (link.votes**2.5)
@erithmetic
Copy link

If you're doing Time#to_f#floor, isn't that the same as Time#to_i, which is the number of seconds?

In that case, you can say:

age_in_minutes = (Time.now - link.created_at) / 60.0
hotness = age_in_minutes / (link.votes**2.5)

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