Skip to content

Instantly share code, notes, and snippets.

@milothiesen
Created August 11, 2016 20:02
Show Gist options
  • Save milothiesen/a48a1feb31dd1aa6365ce811cb89e710 to your computer and use it in GitHub Desktop.
Save milothiesen/a48a1feb31dd1aa6365ce811cb89e710 to your computer and use it in GitHub Desktop.
A simple script that gets the user's public IP address and converts it to latitude and longitude coordinates using two APIs. ipify.org and ipapi.co
# A simple script that gets the user's public IP address and converts it to latitude and longitude coordinates using two APIs. ipify.org and ipapi.co
require "net/http"
ip = Net::HTTP.get(URI("https://api.ipify.org"))
puts "My public IP Address is: " + ip
convert_ip_to_lat_long = Net::HTTP.get(URI("https://ipapi.co/#{ip}/latlong/"))
puts "My lat long is: " + convert_ip_to_lat_long
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment