Skip to content

Instantly share code, notes, and snippets.

@tommorris
Created April 11, 2013 16:01
Show Gist options
  • Save tommorris/5364658 to your computer and use it in GitHub Desktop.
Save tommorris/5364658 to your computer and use it in GitHub Desktop.
code I use to sync my posts up with app.net versions
require "nokogiri"
require "open-uri"
data = Nokogiri::XML(open("https://alpha-api.app.net/feed/rss/users/49269/posts"))
items = data.xpath("//item//atom:link/@href", "atom" => "http://www.w3.org/2005/Atom").map(&:to_s).map {|i| i.split("/").last.to_i }.zip(data.xpath("//item//link").map(&:text))
items.each do |i|
p = Post.find(i[0])
unless p.properties.has_key?('appdotnet')
p.properties['appdotnet'] = i[1]
p.save
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment