├── .gitignore ├── LICENSE ├── README.md ├── fetch.rb ├── index.html └── loader.gif /.gitignore: -------------------------------------------------------------------------------- 1 | *.json 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 James Somers 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Hacker Classics 2 | 3 | Hacker News is no different from most of today's web in emphasizing what's new. When you're following a bunch of feeds, it's easy to forget that the web is the greatest library in the history of the world—and that a good library doesn't just have a rack of newspapers, it has a vast collection of books and archives: the stacks. 4 | 5 | The "Hacker Classics" are the gems that occasionally surface on news.yc when a good patron goes diving into the stacks. 6 | 7 | It includes all stories with more than 40 points whose title has a year in parens, like "(1990)", which is the HN convention for classic articles. The database starts at 1900 and goes to 2010. The stories are fetched using the [Algolia HN search API](https://hn.algolia.com/api) and stored in a `stories.json` file next to the index page. 8 | 9 | The page itself is built client-side at load time. 10 | 11 |  12 | -------------------------------------------------------------------------------- /fetch.rb: -------------------------------------------------------------------------------- 1 | require 'open-uri' 2 | require 'nokogiri' 3 | require 'date' 4 | require 'json' 5 | require 'pry' 6 | 7 | POINT_THRESHOLD = 40 8 | 9 | stories = Hash.new { |h, k| h[k] = [] } 10 | 11 | (1900..2010).each do |year| 12 | (0..100).each do |page| 13 | ct = 0 14 | puts "Fetch #{"https://hn.algolia.com/api/v1/search?tags=story&query='#{year}'&page=#{page}"}..." 15 | html = URI.parse("https://hn.algolia.com/api/v1/search?tags=story&query='#{year}'&page=#{page}").read 16 | data = JSON.parse(html) 17 | 18 | data['hits'].each do |h| 19 | if h['title'].include?("(#{year})") && h['points'] > POINT_THRESHOLD 20 | puts " #{h['title']} -- #{h['points']}" 21 | stories[year] << h 22 | ct += 1 23 | end 24 | end 25 | if ct == 0 26 | break 27 | end 28 | end 29 | end 30 | 31 | File.open("./stories.json", "w") do |f| 32 | f.puts JSON.generate(stories) 33 | end -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 |Hacker News is no different from most of today's web in emphasizing what's new. When you're following a bunch of feeds, it's easy to forget that the web is the greatest library in the history of the world—and that a good library doesn't just have a rack of newspapers, it has a vast collection of books and archives: the stacks.
118 | 119 |Here, then, are the gems that occasionally surface on news.yc when a good patron goes diving into the stacks. You can see how this page is built on Github.