Last active
January 10, 2022 18:26
-
-
Save mekanoid/956fa9610e91e1e0ccae445f444888ea to your computer and use it in GitHub Desktop.
Diverse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## String handling | |
https://www.arduino.cc/reference/en/language/variables/data-types/stringobject/ | |
Functions | |
LANGUAGE charAt() | |
LANGUAGE compareTo() | |
LANGUAGE concat() | |
LANGUAGE c_str() | |
LANGUAGE endsWith() | |
LANGUAGE equals() | |
LANGUAGE equalsIgnoreCase() | |
LANGUAGE getBytes() | |
LANGUAGE indexOf() | |
LANGUAGE lastIndexOf() | |
LANGUAGE length() | |
LANGUAGE remove() | |
LANGUAGE replace() | |
LANGUAGE reserve() | |
LANGUAGE setCharAt() | |
LANGUAGE startsWith() | |
LANGUAGE substring() | |
myString.substring(from) | |
myString.substring(from, to) | |
LANGUAGE toCharArray() | |
LANGUAGE toDouble() | |
LANGUAGE toInt() | |
LANGUAGE toFloat() | |
LANGUAGE toLowerCase() | |
LANGUAGE toUpperCase() | |
LANGUAGE trim() | |
Operators | |
LANGUAGE [] (element access) | |
LANGUAGE + (concatenation) | |
LANGUAGE += (append) | |
LANGUAGE == (comparison) | |
LANGUAGE > (greater than) | |
LANGUAGE >= (greater than or equal to) | |
LANGUAGE < (less than) | |
LANGUAGE <= (less than or equal to) | |
LANGUAGE != (different from) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A simple function that takes two GPS coordinates as input and outputs the distance between them in meter. | |
* This example has been provided by chris from androidsnippets | |
*/ | |
private double gps2m(float lat_a, float lng_a, float lat_b, float lng_b) { | |
float pk = (float) (180/3.14169); | |
float a1 = lat_a / pk; | |
float a2 = lng_a / pk; | |
float b1 = lat_b / pk; | |
float b2 = lng_b / pk; | |
float t1 = FloatMath.cos(a1)*FloatMath.cos(a2)* | |
FloatMath.cos(b1)*FloatMath.cos(b2); | |
float t2 = FloatMath.cos(a1)*FloatMath.sin(a2)* | |
FloatMath.cos(b1)*FloatMath.sin(b2); | |
float t3 = FloatMath.sin(a1)*FloatMath.sin(b1); | |
double tt = Math.acos(t1 + t2 + t3); | |
return 6366000*tt; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*-------------------------------------------------------- | |
* Function: makePassword | |
* Make a password with choosen length from a salt string | |
* | |
* Parameters: | |
* lenght - Lenght of the password | |
* | |
* Returns: | |
* String containing a random password | |
* | |
*------------------------------------------------------ */ | |
function makePassword($lenght) { | |
$salt = "abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ23456789"; // Salt to select chars from | |
srand((double)microtime()*1000000); // Start the random generator | |
$password=""; // Set the inital variable | |
for ($i=0;$i<$lenght;$i++) // Loop and create password | |
$password = $password . substr ($salt, rand() % strlen($salt), 1); | |
return $password; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment