Tutorial by Examples: ear

If you want to extend a class as-if you are a static function, for example for class Something add static looking function fromString, this can only work if the class has a companion object and that the extension function has been declared upon the companion object: class Something { compani...
This example generates random values between 0 and 2147483647. Random rnd = new Random(); int randomNumber = rnd.Next();
Generate a random number between 0 and 1.0. (not including 1.0) Random rnd = new Random(); var randomDouble = rnd.NextDouble();
Generate a random number between minValue and maxValue - 1. Random rnd = new Random(); var randomBetween10And20 = rnd.Next(10, 20);
Oracle supports DATE (includes time to the nearest second) and TIMESTAMP (includes time to fractions of a second) datatypes, which allow arithmetic (addition and subtraction) natively. For example: To get the next day: select to_char(sysdate + 1, 'YYYY-MM-DD') as tomorrow from dual; To get the ...
Whenever a Python script is invoked from the command line, the user may supply additional command line arguments which will be passed on to the script. These arguments will be available to the programmer from the system variable sys.argv ("argv" is a traditional name used in most programmi...
This example adds a list of places with image and name by using an ArrayList of custom Place objects as dataset. Activity layout The layout of the activity / fragment or where the RecyclerView is used only has to contain the RecyclerView. There is no ScrollView or a specific layout needed. <?x...
Consider this simple class: class SmsUtil { public bool SendMessage(string from, string to, string message, int retryCount, object attachment) { // Some code } } Before C# 3.0 it was: var result = SmsUtil.SendMessage("Mehran", "Maryam", "Hello...
setTimeout Executes a function, after waiting a specified number of milliseconds. used to delay the execution of a function. Syntax : setTimeout(function, milliseconds) or window.setTimeout(function, milliseconds) Example : This example outputs "hello" to the console after 1 secon...
4.0 Declare an associative array declare -A aa Declaring an associative array before initialization or use is mandatory. Initialize elements You can initialize elements one at a time as follows: aa[hello]=world aa[ab]=cd aa["key with space"]="hello world" You can al...
When you want to allow only certain keys in your arrays, especially when the array comes from request parameters, you can use array_intersect_key together with array_flip. $parameters = ['foo' => 'bar', 'bar' => 'baz', 'boo' => 'bam']; $allowedKeys = ['foo', 'bar']; $filteredParameters =...
#include <stdio.h> #define ARRLEN (10) int main (void) { int n[ ARRLEN ]; /* n is an array of 10 integers */ size_t i, j; /* Use size_t to address memory, that is to index arrays, as its guaranteed to be wide enough to address all of the possible availab...
The random() function can be used to generate pseudo-random numbers: void setup() { Serial.begin(9600); } void loop() { long randomNumber = random(500); // Generate a random number between 0 and 499 Serial.println(randomNumber); randomNumber = random(100, 1000); // Genera...
name:"john doe"~1 Searches for multiple terms within a specific term distance (~1), i.e will find text containing john anonymous doe but not john second name doe
name:john Searches for a single term (joe) in a single field (name)
+firstname:john +surname:doe Matches documents where firstname is john and surname is doe. + predix indicates that the search term must occur (AND). +firstname:john -surname:doe Matches documents where firstname is john and surname is not doe. - predix indicates that the search term must not occu...
name:"john doe" Searches for multiple terms in specific order.
name:(john doe^5) The ^ indicator can be used to boost a search term to increase it's relevance level meaning that documents containing doe are more relevant than ones containing john
name:john* The * indicator allows you to do a wildcard search matching 0 or more characters after the search term john, will return documents containing john, johnson, john's, johnny and so on. name:do? The ? indicator allows you to do a wildcard search with a single character in the search term,...
age:[50 TO 60] Matches documents where age is between 50 and 60 including 50 and 60 age:{50 TO 60} Matches documents where age is between 50 and 60 excluding 50 and 60 age:[* TO 60] Matches documents where age is less than or equal to 60 age:[50 TO *] Matches documents where age is greater th...

Page 4 of 21