Skip to content

Instantly share code, notes, and snippets.

@iveney
Created December 6, 2011 21:57
Show Gist options
  • Save iveney/1440205 to your computer and use it in GitHub Desktop.
Save iveney/1440205 to your computer and use it in GitHub Desktop.
alfred extension for finding your ip location
<?php
$ip = $argv[1];
$tags = get_meta_tags("http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=$argv[1]");
print "{$tags['city']}, {$tags['region']}, {$tags['country']}";
?>
#Desc: Find ip location
#Use: If not provided with IP, then find the current ip
IP="{query}"
if [ -z "$IP" ]; then
IP=$(curl --silent http://icanhazip.com)
fi
location=$(php -f ip_location.php -- $IP)
echo $IP
echo $location
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment