Skip to content

Instantly share code, notes, and snippets.

@rockpapergoat
Created February 17, 2012 17:02
Show Gist options
  • Save rockpapergoat/1854372 to your computer and use it in GitHub Desktop.
Save rockpapergoat/1854372 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# cf. http://puppetlabs.com/blog/facter-part-3-caching-and-ttl/
require 'rubygems'
require 'rest_client'
# if you're behind a proxy, define it here
RestClient.proxy = ""
geo_raw=(RestClient.post "http://api.hostip.info/get_html.php", :position=>"true")
geo_data=Hash[*geo_raw.scan(/(.*): (.*)\n/).to_a.flatten]
puts "<result>#{geo_data["City"]}</result>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment