function getDistanceFromLatLonInKm(lat1, lon1, lat2, lon2) {
var R, dLat, dLon, a, c, d;
R = 6371; // Radius of the earth in km
dLat = deg2rad(lat2-lat1);
dLon = deg2rad(lon2-lon1);
a =
Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) *
Math.sin(dLon/2) * Math.sin(dLon/2)
;
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
d = R * c; // Distance in km
return parseFloat(d.toFixed(1));
}
function deg2rad(deg) {
return deg * (Math.PI/180);
}
var fx = {
/**
* Get distance in meters between two coordinate points.
*/
findDistance: function(loc1, loc2) {
var R, dLat, dLon, a, c, d;
R = 6371000; // Radius of the earth in meters
dLat = fx.deg2rad(loc2.lat - loc1.lat);
dLon = fx.deg2rad(loc2.lng - loc1.lng);
a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(fx.deg2rad(loc1.lat)) * Math.cos(fx.deg2rad(loc2.lat)) *
Math.sin(dLon/2) * Math.sin(dLon/2);
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
d = R * c; // Distance in meters
return parseInt(d);
},
/**
* Convert degrees to radians
*/
deg2rad: function(deg) {
return deg * (Math.PI / 180);
}
};
console.log(fx.findDistance({
lat: 42.658261,
lng: 23.285241
}, {
lat: 42.659616,
lng: 23.285649
}));
Just calling git rm --cached
on each of the files you want to remove from revision control should be fine. As long as your local ignore patterns are correct you won't see these files included in the output of git status.
#include <stdio.h>
#include <string.h>
void encrypt(char password[], int key) {
unsigned int i;
for(i = 0; i < strlen(password); i++) {
password[i] = password[i] - key;
}
}
void decrypt(char password[], int key) {
unsigned int i;
for(i = 0; i < strlen(password); i++) {
password[i] = password[i] + key;
}
}
int main() {
char password[50];
printf("Enter the password: \n ");
scanf("%s", password);
printf("Passwrod = %s\n", password);
encrypt(password, 0xFACA);
printf("Encrypted value = %s\n", password);
decrypt(password, 0xFACA);
printf("Decrypted value = %s\n", password);
return 0;
}
run with
gcc -o main *.c
./main
There is no .length property in C. The .length property can only be applied to arrays in object oriented programming (OOP) languages. The .length property is inherited from the object class; the class all other classes & objects inherit from in an OOP language. Also, one would use .length-1 to return the number of the last index in an array; using just the .length will return the total length of the array.
I would suggest something like this:
int i, j;
for(i = 0; i < (sizeof(my_array) / sizeof(my_array[0])); i++) {
for(j = 0; j < (sizeof(my_array) / sizeof(my_array[0])); j++) {
printf("%d", my_array[i][j]);
printf("\n");
}
}
The line (sizeof(my_array) / sizeof(my_array[0]))
will give you the size of the array in question. The sizeof property will return the length in bytes, so one must divide the total size of the array in bytes by how many bytes make up each element, each element takes up 4 bytes because each element is of type int, respectively. The array is of total size 16 bytes and each element is of 4 bytes so 16/4 yields 4 the total number of elements in your array because indexing starts at 0 and not 1.
SSHFS is a tool that uses SSH to enable mounting of a remote filesystem on a local machine; the network is (mostly) transparent to the user.