Skip to content

Instantly share code, notes, and snippets.

@ku
Created November 7, 2014 08:50
Show Gist options
  • Select an option

  • Save ku/84af637e2d9b82ac307b to your computer and use it in GitHub Desktop.

Select an option

Save ku/84af637e2d9b82ac307b to your computer and use it in GitHub Desktop.
random sqwiggle snapshot changer
require 'sqwiggle-ruby'
require 'net/http'
require 'nokogiri'
require 'uri'
token = 'cli_be6cd40b6ebd25101b3450e34882412b'
flickr_rss = 'https://www.flickr.com/services/feeds/photos_public.gne?id=59591873@N00&lang=en-us'
uri = URI.parse(flickr_rss)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # read into this
rss = http.get(uri.request_uri)
xml = Nokogiri::XML(rss.body)
xml.remove_namespaces!
a = xml.xpath("//link/@href").map(&:value).select do |u|
u.match /\.jpg$/
end
snapshot = a.sample
id = 26108
client = Sqwiggle.client(token)
me = client.users.find id
me.update({name: 'ku', snapshot: snapshot})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment