Created
November 7, 2014 08:50
-
-
Save ku/84af637e2d9b82ac307b to your computer and use it in GitHub Desktop.
random sqwiggle snapshot changer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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