Tutorial by Examples

Assuming you have the following directory of files: You can setup a web server to serve these files as follows: Python 2.x2.3 import SimpleHTTPServer import SocketServer PORT = 8000 handler = SimpleHTTPServer.SimpleHTTPRequestHandler httpd = SocketServer.TCPServer(("localhost"...
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...
There are multiple ways to create a multiline string in PowerShell: You can use the special characters for carriage return and/or newline manually or use the NewLine-environment variable to insert the systems "newline" value) "Hello`r`nWorld" "Hello{0}World" -f [...
Here-strings are very useful when creating multiline strings. One of the biggest benefits compared to other multiline strings are that you can use quotes without having to escape them using a backtick. Here-string Here-strings begin with @" and a linebreak and end with "@ on it's own lin...
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...
When used inside a double-quoted string, the escape character (backtick `) reperesents a special character. `0 #Null `a #Alert/Beep `b #Backspace `f #Form feed (used for printer output) `n #New line `r #Carriage return `t #Horizontal tab `v #Vertical tab (used for pri...

Page 811 of 1336