Skip to content

Instantly share code, notes, and snippets.

@ldodds
Created December 29, 2021 17:41
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 ldodds/90c779aba13f198b0e6153a88e7cb250 to your computer and use it in GitHub Desktop.
Save ldodds/90c779aba13f198b0e6153a88e7cb250 to your computer and use it in GitHub Desktop.
Quick script to count number of bookmarks recorded in pinboard
require 'dotenv/load'
require 'pinboard'
require 'csv'
pinboard = Pinboard::Client.new(:token => ENV["PINBOARD_TOKEN"])
CSV.open("stats.csv", "w") do |csv|
csv << ["YEAR", "POSTS", "VIA_POCKET"]
#I started social bookmarking in 2004 using del.icio.us, then pinboard from May 2013
#started logging read articles in Pocket to pinboard via IFTTT in mid-2018
(2004..2021).each do |year|
posts_for_year = pinboard.posts(fromdt: Date.new(year,1,1), todt: Date.new(year,12,31))
posts_from_pocket = pinboard.posts(fromdt: Date.new(year,1,1), todt: Date.new(year,12,31), tag: 'Pocket')
csv << [year,posts_for_year.count, posts_from_pocket.count]
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment