Skip to content

Instantly share code, notes, and snippets.

@lharries
Last active March 3, 2018 20:32
Show Gist options
  • Save lharries/95e2eacb7a8262243ed7c0bc546f69c0 to your computer and use it in GitHub Desktop.
Save lharries/95e2eacb7a8262243ed7c0bc546f69c0 to your computer and use it in GitHub Desktop.
Hacker news time traveller

Hacker news time traveller

Shows the top hacker news articles for a random time in history (excluding the current year)

Instructions

Copy and past the code below into your web browsers console

dateRange = 1

year = Math.floor(Math.random() * ((new Date()).getFullYear() - 2010) + 2010)
day = Math.floor(Math.random()* 365)

start = new Date()
start.setFullYear(year)
start.setDate(day)

end = new Date()
end.setFullYear(year)
end.setDate(day + dateRange)

url = "https://hn.algolia.com/?query=&sort=byPopularity&prefix&page=0&dateRange=custom&type=story&dateStart=" + (+start).toString().slice(0, -3) + "&dateEnd=" + (+ end).toString().slice(0, -3)

window.location.href = url
@ksaj
Copy link

ksaj commented Mar 3, 2018

This is a great way to get some interesting links and comment threads while occasionally observing progress (or the lack thereof).

@lharries
Copy link
Author

lharries commented Mar 3, 2018

@ksaj my thoughts exactly!

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