rmoriz (owner)

Fork Of

Revisions

gist: 184585 Download_button fork
public
Description:
nokogiri
Public Clone URL: git://gist.github.com/184585.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'nokogiri'
require 'open-uri'
require 'tempfile'
 
image_url = Nokogiri::HTML(open('http://api.cheezburger.com/xml/category/cats/lol/random')).xpath('/html/body/lol/lolimageurl').first.content
 
file = Tempfile.new('lolcat.jpg')
file.write(open('image_url')
file.close
 
system "osascript <<END\ntell application \"Finder\"\n set desktop picture to POSIX file \"#{file.path}\"\n end tell\nEND"
 
 
# irb(main):016:0> file
# => #<File:/var/folders/6X/6XMsqrRsGZO8vdOp-8J6oE+++TI/-Tmp-/lolcat.jpg20090910-52471-ve2l0x-0>
# irb(main):017:0> system "osascript <<END\ntell application \"Finder\"\n set desktop picture to POSIX file \"#{file.path}\"\n end tell\nEND"
# 2009-09-10 16:49:53.018 osascript[52494:903] Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: # dlopen(/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types, 262): no suitable image found. Did find:
/Library/ScriptingAdditions/Adobe Unit Types.osax/Contents/MacOS/Adobe Unit Types: no matching architecture in universal wrapper
# osascript: OpenScripting.framework - scripting addition "/Library/ScriptingAdditions/Adobe Unit Types.osax" declares no loadable handlers.
# => true