Tag Archives: git

midpoint between two latitude and longitude

Questions: I am trying to convert the code snippet given in this http://www.movable-type.co.uk/scripts/latlong.html into java. But I am not getting same result as that of site. Here is my code to find the midpoint between two points where their latitudes and longitudes are given midPoint(12.870672,77.658964,12.974831,77.60935); public static void midPoint(double lat1,double lon1,double lat2,double lon2) { double… Read More »

Reading a Git repository, without Git

Questions: I’m researching the idea of building a super-small (preferably PHP) web app, which will serve (among other things) as a minimal front-end to a git repository. Any library/article for reading a git repository (“.git” folder) without having to execute the “git” process? I’m looking for an API to manage a git repository. I’m only… Read More »

Use PHP composer to clone git repo

Questions: I’m trying to use composer to automatically clone a git repository from github that isn’t in packagist but it’s not working and I can’t figure out what am I doing wrong. I think I have to include it among “repositories” like so: “repositories”: [ { “url”: “https://github.com/l3pp4rd/DoctrineExtensions.git”, “type”: “git” } ], and then probably… Read More »

Is there any legitimate use for bare strings in PHP?

Questions: This question got me thinking about bare strings. When PHP sees a string that’s not enclosed in quotes, it first checks to see if it’s a constant. If not, it just assumes it’s a string and goes on anyway. So for example if I have echo $foo[bar]; If there’s a constant called bar it… Read More »

Encoding byte data into digits

Questions: Is there a common method to encode and decode arbitrary data so the encoded end result consists of numbers only – like base64_encode but without the letters? Fictitious example: $encoded = numbers_encode(“Mary had a little lamb”); echo $encoded; // outputs e.g. 12238433742239423742322 (fictitious result) $decoded = numbers_decode(“12238433742239423742322”); echo $decoded; // outputs “Mary had a… Read More »

How to check, if a php string contains only english letters and digits?

Questions: In JS I used this code: if(string.match(/[^A-Za-z0-9]+/)) but I don’t know, how to do it in PHP. Answers: Use preg_match(). if (!preg_match(‘/[^A-Za-z0-9]/’, $string)) // ‘/[^a-z\d]/i’ should also work. { // string contains only english letters & digits } Questions: Answers: if(ctype_alnum($string)) { echo “String contains only letters and numbers.”; } else { echo “String… Read More »

select within 20 kilometers based on latitude/longitude

Questions: i have a mysql table structured as per the example below: POSTAL_CODE_ID|PostalCode|City|Province|ProvinceCode|CityType|Latitude|Longitude 7|A0N 2J0|Ramea|Newfoundland|NL|D|48.625599999999999|-58.9758 8|A0N 2K0|Francois|Newfoundland|NL|D|48.625599999999999|-58.9758 9|A0N 2L0|Grey River|Newfoundland|NL|D|48.625599999999999|-58.9758 now what i am trying to do is create a query that will select results within selected kilometers of a searched location so lets say they search for “grey river” and select “find all results… Read More »

How to get address location from latitude and longitude in Google Map.? [closed]

Questions: So I have latitude and longitude Like 44.4647452 and 7.3553838. I need to get address like: Milan, Italy, str. Kennedy 89. How I can do it? Answers: simply try to pass your lat and long to the following query string, and you will get a json array, fetch your city from there http://maps.googleapis.com/maps/api/geocode/json?latlng=44.4647452,7.3553838&sensor=true Questions:… Read More »

How to find nearest location using latitude and longitude from sql database?

Questions: I want to find a nearest location from following database table Address Latitude longitude Kathmandu 44600, Nepal 27.7 85.33333330000005 Los, Antoniterstraße 37.09024 -95.71289100000001 Sydney NSW, Australia 49.7480755 8.111794700000019 goa india 15.2993265 74.12399600000003 I have fetched this all data from google maps. Here i have to find nearest location from a place. Suppose i am… Read More »