Tutorial by Examples

Single node Installation Pre-install NodeJS, Python and Java Select your installation document based on your platform http://docs.datastax.com/en/cassandra/3.x/cassandra/install/installTOC.html Download Cassandra binaries from http://cassandra.apache.org/download/ Untar the downloaded file to ...
db.people.insert({name: 'Tom', age: 28}); Or db.people.save({name: 'Tom', age: 28}); The difference with save is that if the passed document contains an _id field, if a document already exists with that _id it will be updated instead of being added as new. Two new methods to insert documents...
Update the entire object: db.people.update({name: 'Tom'}, {age: 29, name: 'Tom'}) // New in MongoDB 3.2 db.people.updateOne({name: 'Tom'},{age: 29, name: 'Tom'}) //Will replace only first matching document. db.people.updateMany({name: 'Tom'},{age: 29, name: 'Tom'}) //Will replace all matchin...
Deletes all documents matching the query parameter: // New in MongoDB 3.2 db.people.deleteMany({name: 'Tom'}) // All versions db.people.remove({name: 'Tom'}) Or just one // New in MongoDB 3.2 db.people.deleteOne({name: 'Tom'}) // All versions db.people.remove({name: 'Tom'}, true) M...
Query for all the docs in the people collection that have a name field with a value of 'Tom': db.people.find({name: 'Tom'}) Or just the first one: db.people.findOne({name: 'Tom'}) You can also specify which fields to return by passing a field selection parameter. The following will exclude t...
Object arrays are covariant, which means that just as Integer is a subclass of Number, Integer[] is a subclass of Number[]. This may seem intuitive, but can result in surprising behavior: Integer[] integerArray = {1, 2, 3}; Number[] numberArray = integerArray; // valid Number firstElement = numb...
You can nest lists to represent sub-items of a list item. <ul> <li>item 1</li> <li>item 2 <ul> <li>sub-item 2.1</li> <li>sub-item 2.2</li> </ul> </li> <li>item 3</li> </ul> ...
Generators are useful when you need to generate a large collection to later iterate over. They're a simpler alternative to creating a class that implements an Iterator, which is often overkill. For example, consider the below function. function randomNumbers(int $length) { $array = []; ...
Our randomNumbers() function can be re-written to use a generator. <?php function randomNumbers(int $length) { for ($i = 0; $i < $length; $i++) { // yield tells the PHP interpreter that this value // should be the one used in the current iteration. yield mt...
One common use case for generators is reading a file from disk and iterating over its contents. Below is a class that allows you to iterate over a CSV file. The memory usage for this script is very predictable, and will not fluctuate depending on the size of the CSV file. <?php class CsvReade...
To be able to use JDBC you need to have the JDBC driver of your database on the class path of your application. There are multiple ways to connect to a database, but the common ways are to either use the java.sql.DriverManager, or to configure and use a database specific implementation of javax.sql...
The AppCompat Support Library defines several useful styles for Buttons, each of which extend a base Widget.AppCompat.Button style that is applied to all buttons by default if you are using an AppCompat theme. This style helps ensure that all buttons look the same by default following the Material D...
Atomic vectors (which excludes lists and expressions, which are also vectors) are subset using the [ operator: # create an example vector v1 <- c("a", "b", "c", "d") # select the third element v1[3] ## [1] "c" The [ operator can also tak...
A list can be subset with [: l1 <- list(c(1, 2, 3), 'two' = c("a", "b", "c"), list(10, 20)) l1 ## [[1]] ## [1] 1 2 3 ## ## $two ## [1] "a" "b" "c" ## ## [[3]] ## [[3]][[1]] ## [1] 10 ## ## [[3]][[2]] ## [1] 20 l1[1] ##...
For each dimension of an object, the [ operator takes one argument. Vectors have one dimension and take one argument. Matrices and data frames have two dimensions and take two arguments, given as [i, j] where i is the row and j is the column. Indexing starts at 1. ## a sample matrix mat <- matr...
Subsetting a data frame into a smaller data frame can be accomplished the same as subsetting a list. > df3 <- data.frame(x = 1:3, y = c("a", "b", "c"), stringsAsFactors = FALSE) > df3 ## x y ## 1 1 a ## 2 2 b ## 3 3 c > df3[1] # Subset a varia...
There are only two string operators: Concatenation of two strings (dot): $a = "a"; $b = "b"; $c = $a . $b; // $c => "ab" Concatenating assignment (dot=): $a = "a"; $a .= "b"; // $a => "ab"
$a = "some string"; results in $a having the value some string. The result of an assignment expression is the value being assigned. Note that a single equal sign = is NOT for comparison! $a = 3; $b = ($a = 5); does the following: Line 1 assigns 3 to $a. Line 2 assigns 5 to $a....
The combined assignment operators are a shortcut for an operation on some variable and subsequently assigning this new value to that variable. Arithmetic: $a = 1; // basic assignment $a += 2; // read as '$a = $a + 2'; $a now is (1 + 2) => 3 $a -= 1; // $a now is (3 - 1) => 2 $a *= 2; //...
The order in which operators are evaluated is determined by the operator precedence (see also the Remarks section). In $a = 2 * 3 + 4; $a gets a value of 10 because 2 * 3 is evaluated first (multiplication has a higher precedence than addition) yielding a sub-result of 6 + 4, which equals to 10...

Page 205 of 1336