Skip to content

Instantly share code, notes, and snippets.

@kdrakon
Last active February 8, 2016 20:50
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 kdrakon/5d695c8e5cc08bfde48e to your computer and use it in GitHub Desktop.
Save kdrakon/5d695c8e5cc08bfde48e to your computer and use it in GitHub Desktop.
HotLikeScoreCalculator [http://blabr.io?5d695c8e5cc08bfde48e]

HotLikeScoreCalculator

total_likes = slider "total likes on a comment that day"
oldest_content = 11481 #days ago
date_weight_scale = 15 #days
epoch_diff_from_jan_1 = 16480 #days ago
order = (l) -> log(max(l, 1)) / log(10)
age_adjust = (age) -> age - oldest_content
score = (l, age) -> order(l) + (age_adjust(age) / date_weight_scale)
sample_ages = linspace epoch_diff_from_jan_1, epoch_diff_from_jan_1+365, 5
sample_days = (d - epoch_diff_from_jan_1 for d in sample_ages)
sample_scores = (score(total_likes, a) for a in sample_ages)
plot "score distribution", sample_days, sample_scores
#!vanilla
layout [1, 1]
settings
showCodeOnLoad: true
popupWidgetEditor: true
showAuthor: true
background: ""
plot "score distribution",
title: "score distribution"
width: 1000, height: 200
xlabel: "day of the year (0 = Jan 1 2016, 365 = Dec 31 2016)", ylabel: "score"
# xaxis: {min: 0, max: 1}
# yaxis: {min: 0, max: 1}
series: {lines: lineWidth: 1}
colors: ["red", "blue"]
grid: {backgroundColor: "white"}
pos: 1, order: 1
slider "total likes on a comment that day",
min: 0, max: 200, step: 1, init: 5
prompt: "total likes on a comment that day:"
unit: ""
pos: 1, order: 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment