Skip to content

Instantly share code, notes, and snippets.

@jaredculp
Created January 26, 2019 16:58
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 jaredculp/fed96cfd91103e42ee07588dbd49dad8 to your computer and use it in GitHub Desktop.
Save jaredculp/fed96cfd91103e42ee07588dbd49dad8 to your computer and use it in GitHub Desktop.
Delete Facebook: export birthdays
require 'net/http'
class Birthday
def initialize(date, name)
@date = date
@name = name
end
def ics
"BEGIN:VEVENT\r\nDTSTART;VALUE=DATE:#{@date}\r\nRRULE:FREQ=YEARLY\r\nSUMMARY:Birthday #{@name}\r\nEND:VEVENT\r\n"
end
end
cal = ENV['FB_CALENDAR_URL']
raise "Must specify FB_CALENDAR_URL" unless cal
data = Net::HTTP.get(URI(cal))
puts "BEGIN:VCALENDAR\r\n"
birthdays = data.split("BEGIN:VEVENT").drop(1)
.map { |x| x.split("\r\n") }
.map { |x| Birthday.new(x[1].split(":")[1], x[2].split(":")[1]) }
.each { |x| puts x.ics }
puts "END:VCALENDAR\r\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment