Skip to content

Instantly share code, notes, and snippets.

@ldodds
Created Dec 29, 2021
Embed
What would you like to do?
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