Get college/university from ip address - geolocation

I have a list of ip addresses many of which will be from a university network. What is the best way to find out which universities are in this list?

You could use http://ipinfo.io (a service I built) for this. Here's some example output from the API:
$ curl ipinfo.io/128.32.0.1
{
"ip": "128.32.0.1",
"hostname": "No Hostname",
"city": "Berkeley",
"region": "California",
"country": "US",
"loc": "37.8668,-122.2536",
"org": "AS25 University of California at Berkeley",
"postal": "94720"
}
Notice the org field, "AS25 University of California at Berkeley". You can get just those details by appending /org to the URL:
$ curl ipinfo.io/128.32.0.1/org
AS25 University of California at Berkeley
You can do a bulk lookup of your IP addresses by putting them in a file and running the following command:
$ cat ips.txt | xargs -I% curl -s http://ipinfo.io/%/org | paste ips.txt -
128.32.0.1 AS25 University of California at Berkeley
128.62.76.244 AS18 University of Texas at Austin
24.32.142.2 AS7018 AT&T Services, Inc.
171.64.84.194 AS32 Stanford University
18.9.44.47 AS3 Massachusetts Institute of Technology
67.188.232.130 AS7922 Comcast Cable Communications, Inc.
You can find out more details about the API at http://ipinfo.io/developers.

Universities and colleges used to be their own Internet Service Provider (ISP) and you should be able to get these universities.
I played with a world uinversity names database collected from LinkedIn and Webometric and with an old IP-ISP database I had under my hand (dating from 2012) to get a list of about 5800 universities / colleges.
The list is probably not exhaustive because the name of the IP-ISP database may differs from the university names database and because the IP-ISP database could be a bit outdated.
But, it should be a good start if you don't want to use any API.
Then, you should be able to do something similar to:
SELECT * FROM `isp_universities`
WHERE INET_ATON('192.16.181.4')
BETWEEN from_dec AND to_dec
to obtain:
192.16.181.0 to 192.16.181.255
Massachusetts Institute of Technology
http://www.mit.edu/
Take a look here, I pushed the database on Bitbucket.

Related

How to get in-app or subscription info from server side?

Is it possbile to get In-app (or subscription) information (at least price, currency) for iOS application by bundle id or product id from server side?
I know that iOS clients possible to do it using their SDK.
Maybe exists service like iTunes Lookup API?
In StoreKit you have SKProduct and there you have the price
You can check it here
https://developer.apple.com/library/ios/documentation/StoreKit/Reference/StoreKit_Collection/
I think the answer is no, they intend you to fetch the IAPs from within the app. Here is an example of what is returned from the iTunes affiliate search API. AFAIK there is no other API to query app information. They don't mention other ways in their guide to obtaining IAP information.
http://itunes.apple.com/lookup?id=828578246
{
"resultCount": 1,
"results": [
{
"isGameCenterEnabled": true,
"screenshotUrls": [
"http://a2.mzstatic.com/us/r30/Purple49/v4/67/01/ff/6701ff5c-55d3-0ea6-d868-8d803072483b/screen696x696.jpeg",
"http://a2.mzstatic.com/us/r30/Purple69/v4/7c/14/5f/7c145fc0-d7af-cfce-eede-f35ad50a779e/screen696x696.jpeg",
"http://a3.mzstatic.com/us/r30/Purple69/v4/cc/0a/43/cc0a4393-a006-f485-a4b5-59049b16da18/screen696x696.jpeg",
"http://a5.mzstatic.com/us/r30/Purple69/v4/e1/76/23/e1762373-849f-9935-7880-34b62365db8c/screen696x696.jpeg",
"http://a5.mzstatic.com/us/r30/Purple69/v4/84/2f/63/842f635e-ccb1-7802-3fc3-020024a8d786/screen696x696.jpeg"
],
"ipadScreenshotUrls": [
"http://a2.mzstatic.com/us/r30/Purple69/v4/26/ea/ca/26eacabe-8606-de7e-c49a-aeb961c44a22/sc1024x768.jpeg",
"http://a4.mzstatic.com/us/r30/Purple49/v4/11/60/5a/11605ad9-c93a-92d2-2abf-faff83c7e5e4/sc1024x768.jpeg",
"http://a4.mzstatic.com/us/r30/Purple69/v4/bb/b5/8e/bbb58e8a-f6fb-7a4d-e6b9-02ad3007d601/sc1024x768.jpeg",
"http://a2.mzstatic.com/us/r30/Purple69/v4/82/d5/34/82d53417-01aa-e6eb-f0f6-c57e76dae3d9/sc1024x768.jpeg",
"http://a4.mzstatic.com/us/r30/Purple49/v4/04/ad/f4/04adf415-1a40-58b6-6d82-6e47394668e4/sc1024x768.jpeg"
],
"appletvScreenshotUrls": [],
"artworkUrl60": "https://is4-ssl.mzstatic.com/image/thumb/Purple71/v4/14/68/e7/1468e7e9-9dc8-4493-2738-bba066cd03c4/source/60x60bb.jpg",
"artworkUrl512": "https://is4-ssl.mzstatic.com/image/thumb/Purple71/v4/14/68/e7/1468e7e9-9dc8-4493-2738-bba066cd03c4/source/512x512bb.jpg",
"artworkUrl100": "https://is4-ssl.mzstatic.com/image/thumb/Purple71/v4/14/68/e7/1468e7e9-9dc8-4493-2738-bba066cd03c4/source/100x100bb.jpg",
"artistViewUrl": "https://itunes.apple.com/us/developer/big-fish-games-inc/id292594310?uo=4",
"kind": "software",
"features": [
"gameCenter",
"iosUniversal"
],
"supportedDevices": [
"iPhone4",
"iPad2Wifi",
"iPad23G",
"iPhone4S",
"iPadThirdGen",
"iPadThirdGen4G",
"iPhone5",
"iPodTouchFifthGen",
"iPadFourthGen",
"iPadFourthGen4G",
"iPadMini",
"iPadMini4G",
"iPhone5c",
"iPhone5s",
"iPhone6",
"iPhone6Plus",
"iPodTouchSixthGen"
],
"advisories": [],
"trackCensoredName": "Gummy Drop!",
"userRatingCountForCurrentVersion": 325,
"sellerUrl": "http://www.bigfishgames.com/mobile-games/ios-games/",
"contentAdvisoryRating": "4+",
"languageCodesISO2A": [
"NL",
"EN",
"FR",
"DE",
"IT",
"JA",
"KO",
"PT",
"RU",
"ES"
],
"fileSizeBytes": "89165452",
"averageUserRatingForCurrentVersion": 4.5,
"trackViewUrl": "https://itunes.apple.com/us/app/gummy-drop!/id828578246?mt=8&uo=4",
"trackContentRating": "4+",
"minimumOsVersion": "7.0",
"formattedPrice": "Free",
"currency": "USD",
"wrapperType": "software",
"version": "2.14.0",
"artistId": 292594310,
"artistName": "Big Fish Games, Inc",
"genres": [
"Games",
"Arcade",
"Puzzle",
"Entertainment"
],
"price": 0,
"description": "Stop crushing & start squishing! Match your way around this candy world! LET’S GO GUMMY! ®\n\nTravel WHEREVER and WHENEVER you want! From Sydney to Tokyo, San Francisco, New York City, Paris, London, Rome, Berlin, New Orleans, Barcelona, Shanghai, Los Angeles, Seoul, Havana, Rio de Janeiro, St. Petersburg, Mexico City, Cape Town, Budapest, Tahiti, Cairo, Marrakesh, Dubai, Bangkok, Athens, Amsterdam, Hawaii, Hong Kong, Singapore, New Delhi, Venice and more coming soon!\n\nFEATURES\n• Play over 10,000 gummified levels across dozens of world cities – MORE levels than any other Match-3 game!\n• Travel to any city, anytime! Earn travel vouchers to unlock the city of your choice.\n• Exciting Achievements! See your accomplishments in your Passport.\n• Unique boosts! Including Shuffle, Lightning, Shovel, and more!\n• Huge rewards! Score in-game items just for playing.\n• Daily Events! Collect sweet bursts of resources and rewards.\n\nREVIEWS\nBetter than Candy Crush (5 STARS)\nLove the way the game travels around the world.\n\nFinally a Straight Up Game Experience (5 STARS)\nThis is an amazing game that is what it says - FREE. You can keep playing a challenging de-stressor without any bait and switch. Love It!!!!!!!!\n\nFun game (5 STARS)\nThis game starts easily and increases in difficulty as you get better. Fun to watch the cities grow as you add details.\n\nCan’t get enough of Gummy Drop! ? Visit our Headquarters, like us on Facebook of follow us on Twitter for sweet musings, matching tips, gummy stories, and tasty giveaways!\n\nGummy Drop! Headquarters: www.bigfishgames.com/gummyHQ \nFacebook: Search Gummy Drop \nTwitter: #GummyDrop \n \n*Note for updates - having trouble seeing your progress after an update? Try connecting with Facebook again and that should do the trick!*",
"trackName": "Gummy Drop!",
"trackId": 828578246,
"bundleId": "com.bigfishgames.worldsagaaapluniversalF2P",
"releaseDate": "2014-09-08T19:29:51Z",
"primaryGenreName": "Games",
"isVppDeviceBasedLicensingEnabled": true,
"currentVersionReleaseDate": "2016-08-23T17:26:54Z",
"releaseNotes": "Join us in the newest city, Queenstown!\nPlay over 360 brand new levels of Gummy matching fun today!\n\nOther improvements:\n•Optimizations and bug fixes to improve overall game performance.\n\nThanks for the continued support and feedback, and be sure to keep an eye out for more exciting updates!\n\nExperiencing issues? Please visit http://bigfi.sh/GummyHQ",
"sellerName": "Big Fish Games, Inc",
"primaryGenreId": 6014,
"genreIds": [
"6014",
"7003",
"7012",
"6016"
],
"averageUserRating": 4.5,
"userRatingCount": 46621
}
]
}
I found a third-party service which allows do this.
Appfigures. In docs they have the type of product inapp. Service may return price and currency. It looks like that I need.
But need to check it in practice.
If somebody know other service which possible to do that, please, share them. Thanks!

Youtube video id (or URL) to "user" and "channel"

Given a URL or ID of a Youtube video, is it possible to get the (1) name of the "user" who had uploaded it and (2) channel that it belongs to? If so, what is the API request?
So, for example: lets' say I have a video ID: "VulCl5QfewE" corresponding to the video at: https://www.youtube.com/watch?v=VulCl5QfewE
I then want to extract the name of the user, which is: "TheYoungTurks" and the URL of the user is:
https://www.youtube.com/user/TheYoungTurks
I also want to be able to extract the name of the channel, which is: "UC1yBKRuGpC1tSM73A0ZjYjQ" and the URL of the channel is:
https://www.youtube.com/channel/UC1yBKRuGpC1tSM73A0ZjYjQ
Finally, (as a "side, ancillary question") I am a bit confused what is the difference between a "channel" and a "user". Can a user have multiple channels? I did read the link here: https://www.reddit.com/r/youtube/comments/2vsyit/whats_the_difference_between_user_and_channel/ but I am trying to understand the use case behind it.
Cheers
If you want to retrieve the channel informations from a videoId, you need to use the ressource videos.list with the parameters:
part: snippet
id: "VulCl5QfewE" //for example
GET https://www.googleapis.com/youtube/v3/videos?part=snippet&id=VulCl5QfewE&key={YOUR_API_KEY}
The result show you the channelID of the user:
"items": [
{
"kind": "youtube#video",
"etag": "\"iDqJ1j7zKs4x3o3ZsFlBOwgWAHU/IcNtD4uunskZTQuIeM0YQRcc5HY\"",
"id": "VulCl5QfewE",
"snippet": {
"publishedAt": "2015-08-05T01:11:24.000Z",
"channelId": "UC1yBKRuGpC1tSM73A0ZjYjQ",
Then use this information to get the name of the channel with the ressource channel.list
part: snippet
id: UC1yBKRuGpC1tSM73A0ZjYjQ
GET https://www.googleapis.com/youtube/v3/channels?part=snippet&id=UC1yBKRuGpC1tSM73A0ZjYjQ&key={YOUR_API_KEY}
Part of the result:
"snippet": {
"title": "The Young Turks",
"description": "The Largest Online News Show in the World. Hosted by Cenk Uygur & Ana Kasparian. LIVE weekdays 6-8pm ET. \n\nYoung Turk (n), 1. Young progressive or insurgent member of an institution, movement, or political party. 2. Young person who rebels against authority or societal expectations. (American Heritage Dictionary)\n\nThe Young Turks were the first original talk show on Sirius satellite radio and the first live, daily webcast on the internet. But that is not the revolution.\n\nWe are a rare show that combines all of the news that people care about in one place. We are not afraid to talk about politics and entertainment and sports and pop culture. But that is not the revolution either. \n\nGet The Young Turks\u200b Mobile App Today! \n\nDownload the iOS version here: https://itunes.apple.com/us/app/the-young-turks/id412793195? \n\nDownload the Android version here: https://play.google.com/store/apps/details?id=com.tyt",
"publishedAt": "2005-12-21T20:46:51.000Z",
Finally, (as a "side, ancillary question") I am a bit confused what is
the difference between a "channel" and a "user". Can a user have
multiple channels? I did read the link here:
https://www.reddit.com/r/youtube/comments/2vsyit/whats_the_difference_between_user_and_channel/
but I am trying to understand the use case behind it.
There is a link with Google+ account, check https://productforums.google.com/forum/#!topic/youtube/3MsBApaK2Hw

Incorrect results from geoLite2 IP database

Searching for IP 54.73.154.147 using latest GeoLite2 IP database I get the following results:
Seattle, US, United States
But the IP address is actually from a AWS server spun up in Ireland. If I submit the same IP to the GeoIP Precision test page (https://www.maxmind.com/en/geoip-demo) I get the correct results:
Dublin, IE, Ireland
Can anyone think of a reason as to why Im getting such erroneous results?
The reason that you are getting two different results is because they simply are different versions of databases and the one you search on their web interface is apparently more accurate and more up-to-date. GeoLite2 is not very accurate and you need to update it every week to receive accurate information since IP addresses are changing every minute. For example I purchased a few IP addresses and I can use one today and shift to another one tomorrow as I please. Bigger companies do that more often and most of these IP addresses can go from one country to another.
And if you just want to stick with MaxMind product you can use this url to request the json:
https://www.maxmind.com/geoip/v2.1/city/{{ip.address}}?use-downloadable-db=1&demo=1
Note that only 25 requests are allow a day in theory (but easily hackable). Don't ask me how to hack it because it is against the rules of Stackoverflow.
As #michael pointed out, you can't do anything if geolite's database is wrong.
Here is antoher alternative: userinfo.io. It's actually a merge of several databases so it can be more accurate.
I tested it with your IP and it returns the right location.
{
"ip_address": "54.73.154.147",
"position": {
"latitude": 53.3331,
"longitude": -6.2489
},
"continent": {
"name": "Europe",
"code": "EU"
},
"country": {
"name": "Ireland",
"code": "IE"
},
"city": {
"name": "Dublin"
}
}
You can currently use the javascript wrapper or the java wrapper.
I had exactly the same problem. My EC2 server is in Ireland, but geoip shows US.
I switched to freegeoip.net, which seems accurate for this case.
An example of usage in PHP:
$json_data = file_get_contents("http://freegeoip.net/json/" . $hostname);
return json_decode($json_data, TRUE);
This Script will solve your issue .
i had tested it with your ip address and it is giving correct result
<?php
/*Get user ip address*/
//$ip_address=$_SERVER['REMOTE_ADDR'];
$ip_address="54.73.154.147";
/*Get user ip address details with geoplugin.net*/
$geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_address;
$addrDetailsArr = unserialize(file_get_contents($geopluginURL));
/*Get City name by return array*/
$city = $addrDetailsArr['geoplugin_city'];
/*Get Country name by return array*/
$country = $addrDetailsArr['geoplugin_countryName'];
$latitude = $addrDetailsArr['geoplugin_latitude'];
$logitude = $addrDetailsArr['geoplugin_longitude'];
/*Comment out these line to see all the posible details*/
/*echo '<pre>';
print_r($addrDetailsArr);
die();*/
if(!$city){
$city='Not Define';
}if(!$country){
$country='Not Define';
}
echo '<strong>IP Address</strong>:- '.$ip_address.'<br/>';
echo '<strong>City</strong>:- '.$city.'<br/>';
echo '<strong>Country</strong>:- '.$country.'<br/>';
echo '<strong>Latitude</strong>:- '.$latitude.'<br/>';
echo '<strong>Longitude</strong>:- '.$logitude.'<br/>';
?>

How to find out user's country and city from IP address?

I know I can get user's IP address like this:
remote_ip = request.remote_ip
Now I was wondering how can I find out user's country and city from his IP address? I've found this buy it is only for country:
http://api.hostip.info/country.php
City can be found like this:
http://api.hostip.info
The problem is it is not showing the city correctly. I am currently in one of the biggest cities in the world and it says it is an unknown city.
What would be the best way to find out user's country and city from his IP address? I am looking for a free solution or at least something really cheap.
Thank you :)
You could try geocoder gem to obtain location by ip address:
Geocoder.search('5.18.186.107').first.city # => "Saint Petersburg"
Geocoder.search('213.180.204.26').first.country # => "Turkey"
Or even use built-in functionality w/o transitional actions:
# somewhere in your action
result = request.location # returns Geocoder::Result object
By default it uses http://freegeoip.net/ service for IP resolving, so in case you do not want to use any additional gems you can communicate with it using REST API.
You could try my API, https://ipinfo.io. It returns JSON by default, with a bunch of different fields:
$ curl ipinfo.io
{
"ip": "24.6.61.239",
"hostname": "c-24-6-61-239.hsd1.ca.comcast.net",
"city": "Mountain View",
"region": "California",
"country": "US",
"loc": "37.3845,-122.0881",
"org": "AS7922 Comcast Cable Communications, LLC",
"postal": "94040"
}
It's free for up to 1000 requests per day. See https://ipinfo.io/developers for more details.
You can run a WHOIS with the IP address. I'm not sure if this can be done with code but if you want to do it only for a few IP's then sites like http://www.tools.whois.net/whoisbyip/ can provide information including city location. I believe different sites offer different depths of information.
One more solution is to use ruby gem for Yandex locator (https://tech.yandex.ru/locator/). Yandex locator is a service that finds mobile devices in a region delineated by a circle. The service returns longitude, latitude and precision. https://github.com/sergey-chechaev/yandex_locator
client = YandexLocator::Client.new(api_key: 'api key', version: '1.0')
result = client.lookup(ip: { address_v4: '178.247.233.3' })
result.position
# => {"altitude"=>0.0, "altitude_precision"=>30.0, "latitude"=>41.00892639160156, "longitude"=>28.96711158752441, "precision"=>100000.0, "type"=>"ip"}

How to create a new sprint in JIRA programmatically?

I'm migrating a number of projects from one JIRA instance to another using JSON importer. Although the importer can assign issues to existing sprints, the sprints themselves must already exist -- a limitation of the current version of JIRA Importer.
We've been creating sprints by hand 'till now, but some of our projects have a large number of them, which make the manual process both tedious and error-prone.
It does not appear like JIRA REST API can create new sprints either -- although people talk about the greenhopper/1.0/sprint/create endpoint, it does not exist.
Is there, perhaps, some other way to create sprints programmatically? I have no problems with obtaining the full list of them from the source JIRA instance, it is creating them in the target instance, that does not seem possible...
Any hope? Can I INSERT new records into the AO_60DB71_SPRINT-table with a SQL-client? Thanks!
This can be done using the JIRA Agile API. See JIRA Agile REST API Reference
So, for example using curl:
## Request JIRA Sprint POST Create
curl -X "POST" "https://jira.foobar.com/rest/agile/1.0/sprint" \
-H 'Content-Type: application/json' \
-u 'myusername:mypassword' \
-d $'{
"startDate": "2018-04-23T00:00:00.000+01:00",
"name": "Cool Sprint",
"endDate": "2018-05-03T13:00:00.000+01:00",
"originBoardId": 1072
}'
The response of which would be:
{
"id": 1130,
"self": "https://jira.foobar.com/rest/agile/1.0/sprint/1130",
"state": "future",
"name": ""Cool Sprint",
"startDate": "2018-04-23T01:00:00.000+02:00",
"endDate": "2018-05-03T14:00:00.000+02:00",
"originBoardId": 1072
}

Resources