Tutorial by Examples: o

If the SQL statement is constructed like this: SQL = "SELECT * FROM Users WHERE username = '" + user + "' AND password ='" + pw + "'"; db.execute(SQL); Then a hacker could retrieve your data by giving a password like pw' or '1'='1; the resulting SQL statement will ...
Define the function using the vararg keyword. fun printNumbers(vararg numbers: Int) { for (number in numbers) { println(number) } } Now you can pass as many parameters (of the correct type) into the function as you want. printNumbers(0, 1) // Prints "0&qu...
Arrays can be passed into vararg functions using the Spread Operator, *. Assuming the following function exists... fun printNumbers(vararg numbers: Int) { for (number in numbers) { println(number) } } You can pass an array into the function like so... val numbers = intArray...
The orderBy() method specifies the ORDER BY fragment of a SQL query.For example consider our employee table having fields emp_id, emp_first_name, emp_last_name and emp_salary.Suppose we need to order the result by increasing order of employee salaries.We can do it in sql as given below. Select * fr...
Without replacement With combn, each vector appears in a column: combn(LETTERS, 3) # Showing only first 10. [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] [1,] "A" "A" "A" "A" "A" "A" "A" "A" &quo...
Below are examples of generating 5 random numbers using various probability distributions. Uniform distribution between 0 and 10 runif(5, min=0, max=10) [1] 2.1724399 8.9209930 6.1969249 9.3303321 2.4054102 Normal distribution with 0 mean and standard deviation of 1 rnorm(5, mean=0, sd=1) [1...
Box boxlty - box line type boxlwd - box line width boxcol - box line color boxfill - box fill colors Median medlty - median line type ("blank" for no line) medlwd - median line widht medcol - median line color medpch - median point (NA for no symbol) medcex - median point s...
fn is_prime(n: u64) -> bool { (2..n).all(|divisor| n % divisor != 0) } Of course this is isn't a fast test. We can stop testing at the square root of n: (2..n) .take_while(|divisor| divisor * divisor <= n) .all(|divisor| n % divisor != 0)
Without replacement choose(length(LETTERS), 5) [1] 65780 With replacement length(letters)^5 [1] 11881376
When the app is based on more than one criteria, instead of creating a lot of flavors you can define flavor dimensions. The flavor dimensions define the cartesian product that will be used to produce variants. Example: flavorDimensions("dimA", "dimB") productFlavors { ...
You can set the behavior of the FAB in XML. For example: <android.support.design.widget.FloatingActionButton app:layout_behavior=".MyBehavior" /> Or you can set programmatically using: CoordinatorLayout.LayoutParams p = (CoordinatorLayout.LayoutParams) fab.getLayoutPara...
Use the following commands to create bookmarks and access bookmarks from within Emacs. Let us say that you are editing a file called foobar.org and suppose that you visit this file frequently to edit / view contents. It would be convenient to access this file with couple of key strokes rather than...
Items are added to a Collection by calling its .Add method: Syntax: .Add(item, [key], [before, after]) ParameterDescriptionitemThe item to store in the Collection. This can be essentially any value that a variable can be assigned to, including primitive types, arrays, objects, and Nothing.keyO...
Items are removed from a Collection by calling its .Remove method: Syntax: .Remove(index) ParameterDescriptionindexThe item to remove from the Collection. If the value passed is a numeric type or Variant with a numeric sub-type, it will be interpreted as a numeric index. If the value passed i...
The number of items in a Collection can be obtained by calling its .Count function: Syntax: .Count() Sample Usage: Public Sub Example() Dim foo As New Collection With foo .Add "One" .Add "Two" .Add "Three" .Add...
Items can be retrieved from a Collection by calling the .Item function. Syntax: .Item(index) ParameterDescriptionindexThe item to retrieve from the Collection. If the value passed is a numeric type or Variant with a numeric sub-type, it will be interpreted as a numeric index. If the value pas...
Keys Unlike a Scripting.Dictionary, a Collection does not have a method for determining if a given key exists or a way to retrieve keys that are present in the Collection. The only method to determine if a key is present is to use the error handler: Public Function KeyExistsInCollection(ByVal key...
The easiest way to clear all of the items from a Collection is to simply replace it with a new Collection and let the old one go out of scope: Public Sub Example() Dim foo As New Collection With foo .Add "One" .Add "Two" .Add "Thre...
Using variables in a string You can concatenate strings using variables inside a double-quoted string. This does not work with properties. $string1 = "Power" $string2 = "Shell" "Greetings from $string1$string2" Using the + operator You can also join strings usin...
The -Command parameter is used to specify commands to be executed on launch. It supports multiple data inputs. -Command <string> You can specify commands to executed on launch as a string. Multiple semicolon ;-separated statements may be executed. >PowerShell.exe -Command "(Get-Date...

Page 620 of 1038