Skip to content

Instantly share code, notes, and snippets.

@davidnunez
Last active December 13, 2015 21:08
Show Gist options
  • Save davidnunez/4974967 to your computer and use it in GitHub Desktop.
Save davidnunez/4974967 to your computer and use it in GitHub Desktop.
ruby script to randomly pick and open tagged items in pinboard for review
require 'pinboard_api'
PinboardApi.username = "USERNAME"
PinboardApi.password = "PASSWORD"
posts = PinboardApi::Post.all(tag: ARGV[0], meta:true)
posts = posts.reject {|post| post.tags.include? "@done"}
ARGV[1].to_i.times do
post = posts.delete_at(rand(posts.length))
attributes = {description: post.description, extended: post.extended, hash: post.hash, meta: post.meta, url: post.url, tags: post.tags.push("@done"),time: post.time}
post = PinboardApi::Post.new(attributes)
post.save(replace: true)
puts "opening: #{post.url} with #{post.tags}"
system "open #{post.url}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment