Tutorial by Examples: air

The struct template std::pair can bundle together exactly two return values, of any two types: #include <utility> std::pair<int, int> foo(int a, int b) { return std::make_pair(a+b, a-b); } With C++11 or later, an initializer list can be used instead of std::make_pair: C++11 ...
Comparing sets In R, a vector may contain duplicated elements: v = "A" w = c("A", "A") However, a set contains only one copy of each element. R treats a vector like a set by taking only its distinct elements, so the two vectors above are regarded as the same: set...
updateState by key can be used to create a stateful DStream based on upcoming data. It requires a function: object UpdateStateFunctions { def updateState(current: Seq[Double], previous: Option[StatCounter]) = { previous.map(s => s.merge(current)).orElse(Some(StatCounter(current))) } ...
mapWithState, similarly to updateState, can be used to create a stateful DStream based on upcoming data. It requires StateSpec: import org.apache.spark.streaming._ object StatefulStats { val state = StateSpec.function( (key: String, current: Option[Double], state: State[StatCounter]) =&g...
By convention, the functor (-)/2 is often used to denote pairs of elements in Prolog. For example, the term -(A, B) denotes the pair of elements A and B. In Prolog, (-)/2 is defined as an infix operator. Therefore, the term can be written equivalently as A-B. Many commonly available predicates also...
When we have two separate array and we want to make key value pair from that two array, we can use array's reduce function like below: var columns = ["Date", "Number", "Size", "Location", "Age"]; var rows = ["2001", "5", "B...
A simple example on how to read a UTF text file synchronously. import flash.filesystem.File; import flash.filesystem.FileMode; import flash.filesystem.FileStream; //First, get a reference to the file you want to load var myFile:File = File.documentsDirectory.resolvePath("lifestory.txt&...
We will use the built in tooth growth dataset. We are interested in whether there is a statistically significant difference in tooth growth when the guinea pigs are given vitamin C vs orange juice. Here's the full example: teethVC = ToothGrowth[ToothGrowth$supp == 'VC',] teethOJ = ToothGrowth[To...
Some regex engines (such as .NET) can handle context-free expressions, and will work it out. But that's not the case for most standard engines. And even if they do, you'll end up having a complex hard-to-read expression, whereas using a parsing library could make the job easier. How to find all p...
An object can only be deallocated by delete if it was allocated by new and is not an array. If the argument to delete was not returned by new or is an array, the behavior is undefined. An object can only be deallocated by delete[] if it was allocated by new and is an array. If the argument to delet...
Pair allows us to treat two objects as one object. Pairs can be easily constructed with the help of template function std::make_pair. Alternative way is to create pair and assign its elements (first and second) later. #include <iostream> #include <utility> int main() { std::p...
Usage: $ nodetool repair [-h | -p | -pw | -u] <flags> [ -- keyspace_name [table_name]] Default Repair Option $ nodetool repair This command will repair the current node's primary token range (i.e. range which it owns) along with the replicas of other token ranges it has in all tables a...
OPENJSON function parse JSON text and returns all key:value pairs at the first level of JSON: declare @json NVARCHAR(4000) = N'{"Name":"Joe","age":27,"skills":["C#","SQL"]}'; SELECT * FROM OPENJSON(@json); keyvaluetypeNameJoe1age272ski...
In this example you will learn how to generate RSA-OAEP key pair and how to convert private key from this key pair to base64 so you can use it with OpenSSL etc. Please note that this process can also be used for public key you just have to use prefix and suffix below: -----BEGIN PUBLIC KEY----- --...
So, have you ever wondered how to use your PEM RSA key pair that was generated by OpenSSL in Web Cryptography API? If the answers is yes. Great! You are going to find out. NOTE: This process can also be used for public key, you only need to change prefix and suffix to: -----BEGIN PUBLIC KEY----- ...
Use swap (from Data.Tuple) to swap the components of a pair. import Data.Tuple (swap) swap (1, 2) -- evaluates to (2, 1) Or use pattern matching. case (1, 2) of (x, y) => (y, x) -- evaluates to (2, 1)
int[string] aa = ["x": 5, "y": 6]; // The value can be set by its key: aa["x"] = 7; assert(aa["x"] == 7); // if the key does not exist will be added aa["z"] = 8; assert(aa["z"] == 8);
Let's assume an associative array aa: int[string] aa = ["x": 5, "y": 6]; Items can be removed by using .remove(), if key exits will be removed and remove returns true: assert(aa.remove("x")); if the given key does not exist remove does nothing and returns false:...
Run repair on a particular partition range. nodetool repair -pr Run repair on the whole cluster. nodetool repair Run repair in parallel mode. nodetool repair -par
Now that you know how to connect with Redis from Node.js, let’s see how to store key-value pairs in Redis storage. Storing Strings All the Redis commands are exposed as different functions on the client object. To store a simple string use the following syntax: client.set('framework', 'Angula...

Page 1 of 2