EzDevInfo.com

location interview questions

Top location frequently asked interview questions

How do I get the current GPS location programmatically in Android?

I need to get my current location using GPS programmatically. How do I do that?


Source: (StackOverflow)

Where are C/C++ main function's parameters?

In C/C++, the main function receives parameters which is of type char*.

int main(int argc, char* argv[]){
  return 0;
}

argv is array of char*, they point to strings. Where do these string locate? Are they on heap, or stack, or somewhere else?


Source: (StackOverflow)

Advertisements

Where does git config --global get written to?

Using the git config --global command to set things up, where is the file?

eg :

git config --global core.editor "blah"

Its not at these places :-

C:\Program Files\Git\etc\gitconfig

C:\myapp\.git\config

I have not env set?

git version 1.6.5.1.1367.gcd48 on Windows7


Source: (StackOverflow)

location.host vs location.hostname and cross-browser compatibility?

Which one of these is the most effective vs checking if the user agent is accessing via the correct domain.

We would like to show a small js based 'top bar' style warning if they are accessing the domain using some sort of web proxy (as it tends to break the js).

We were thinking about using the following:

var r = /.*domain\.com$/;
if (r.test(location.hostname)) {
    // showMessage ...
}

That would take care of any subdomains we ever use.

Which should we use host or hostname?

In Firefox 5 and Chrome 12:

console.log(location.host);
console.log(location.hostname);

.. shows the same for both.

Is that because the port isn't actually in the address bar?

http://www.w3schools.com/jsref/obj_location.asp says host contains the port.

Should location.host/hostname be validated or can we be pretty certain in IE6+ and all the others it will exist?


Source: (StackOverflow)

Why I have to call 'exit' after redirection through header('Location..') in PHP?

You know that if you want to redirect an user in PHP you can use the header function:

header('Location: http://smowhere.com');

It is also well known that it is a good practice to put also an exit; after the header call, to prevent execution of other php code. So my question is: could the code after the header-location call be effectively executed? In which cases? Can a malicious user be able to completely ignore the header('Location..') call? How?


Source: (StackOverflow)

Fastest Way to Find Distance Between Two Lat/Long Points

I currently have just under a million locations in a mysql database all with longitude and latitude information.

I am trying to find the distance between one point and many other points via a query. It's not as fast as I want it to be especially with 100+ hits a second.

Is there a faster query or possibly a faster system other than mysql for this? I'm using this query:

SELECT 
  name, 
   ( 3959 * acos( cos( radians(42.290763) ) * cos( radians( locations.lat ) ) 
   * cos( radians(locations.lng) - radians(-71.35368)) + sin(radians(42.290763)) 
   * sin( radians(locations.lat)))) AS distance 
FROM locations 
WHERE active = 1 
HAVING distance < 10 
ORDER BY distance;

Source: (StackOverflow)

Python + Django page redirect

How do I accomplish a simple redirect (e.g. cflocation in ColdFusion, or header(location:http://) in django)?


Source: (StackOverflow)

How do I get the full path to a Perl script that is executing?

I have Perl script and need to determine the full path and filename of the script during execution. I discovered that depending on how you call the script $0 varies and sometimes contains the fullpath+filename and sometimes just filename. Because the working directory can vary as well I can't think of a way to reliably get the fullpath+filename of the script.

Anyone got a solution?


Source: (StackOverflow)

What's the difference between window.location= and window.location.replace()?

Is there a difference between these two lines?

var url = "http://www.google.com/";
window.location = url;
window.location.replace (url);

Source: (StackOverflow)

Where does npm install packages?

Can someone tell me where can I find the Node.js modules, which I installed using npm?


Source: (StackOverflow)

Android mock location on device?

How can I mock my location on a physical device (Nexus One)? I know you can do this with the emulator in the Emulator Control panel, but this doesn't work for a physical device.


Source: (StackOverflow)

Redirect using AngularJS

I'm trying to redirect to another route using:

$location.path("/route");

But for some reason it is not working. I did an auto-complete widget using jQuery-UI and I'm calling a function from the scope once the user selects an option. I debugged it and it enters the function but it is never redirected to the other route. It only changes the route when I press a key.

I think it is kind of strange but I haven't figured out how to solve this. I used

window.location = "#/route";

and it works but I want to use the path() function.

Does anybody have any idea why this is happening?


Source: (StackOverflow)

jquery: change the URL address without redirecting? [duplicate]

Possible Duplicate:
Modify Address Bar URL in AJAX App to Match Current State

How can I change the URL address without redirecting the page?

For instance, when I click on this link below:

<a rel='nofollow' href="http://mysite.com/projects/article-1" class="get-article">link</a>

I will grab the URL from the link:

var path = object.attr('href');

If I do this below, the page will be redirected:

window.location = path;

I want to do something like this site, when you click on the image, the ajax call will fetch the requested page and the URL address on the window will be changed too, so that it has a path for what you click.


Source: (StackOverflow)

Android Location Providers - GPS or Network Provider?

In my application I would like to determine the user's current location. I do however have a couple of questions in this regard:

  1. There are different Location Providers, which one is the most accurate? The GPS Provider or the Network Provider?

  2. In how far do those available provider differ? How do they function?

  3. Could you please provide me with some code-snippets or tutorials on how to get started with implementing GPS functionality in my application?


Source: (StackOverflow)

iPhone - Backgrounding to poll for events

For quite a while I'd been looking into a way in my iPhone app to poll every X minutes to check the data counters. After much reading of the Background Execution documentation and a few trial apps I'd dismissed this as impossible without abusing the background APIs.

Last week I found this application which does exactly that. http://itunes.apple.com/us/app/dataman-real-time-data-usage/id393282873?mt=8

It runs in the background and keeps track of the count of Cellular/WiFi data you've used. I suspect that the developer is registering his app as tracking location changes but the location services icon isn't visible while the app is running, which I thought was a requirement.

Does anyone have any clues as to how this can be accomplished?


Source: (StackOverflow)