While there are numerous brilliant IP to Geo resolution services, I found that my primary requirement was to simply perform country detection so that I could pre-select a country drop-down list for my web visitors.
CloudFlare provides a great free DNS service, which also happens to include a country detection service. This medly of scripts simply uses that information.
So, it expects that the website you are accessing this on, is hosted with CloudFlare as your DNS provider.
One JS file, and one PHP file. That's really all you need here.
LGPL. Go nuts.