Tutorial by Examples

Generators are functions which are able to pause and then resume execution. This allows to emulate async functions using external libraries, mainly q or co. Basically it allows to write functions that wait for async results in order to go on: function someAsyncResult() { return Promise.resolve...
Stream operations fall into two main categories, intermediate and terminal operations, and two sub-categories, stateless and stateful. Intermediate Operations: An intermediate operation is always lazy, such as a simple Stream.map. It is not invoked until the stream is actually consumed. This can...
If you want to Download image as Bitmap using Picasso following code will help you: Picasso.with(mContext) .load(ImageUrl) .into(new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { // Todo: Do some...
Connect to MongoDB, print 'Connected!' and close the connection. const MongoClient = require('mongodb').MongoClient; var url = 'mongodb://localhost:27017/test'; MongoClient.connect(url, function(err, db) { // MongoClient method 'connect' if (err) throw new Error(err); console.log(&q...
Insert a document called 'myFirstDocument' and set 2 properties, greetings and farewell const MongoClient = require('mongodb').MongoClient; const url = 'mongodb://localhost:27017/test'; MongoClient.connect(url, function (err, db) { if (err) throw new Error(err); db.collection('myCollect...
Get all documents in the collection 'myCollection' and print them to the console. const MongoClient = require('mongodb').MongoClient; const url = 'mongodb://localhost:27017/test'; MongoClient.connect(url, function (err, db) { if (err) throw new Error(err); var cursor = db.collection('my...
Find a document with the property { greetings: 'Hellu' } and change it to { greetings: 'Whut?' } const MongoClient = require('mongodb').MongoClient; const url = 'mongodb://localhost:27017/test'; MongoClient.connect(url, function (err, db) { if (err) throw new Error(err); db.collecti...
Delete a document with the property { greetings: 'Whut?' } const MongoClient = require('mongodb').MongoClient; const url = 'mongodb://localhost:27017/test'; MongoClient.connect(url, function (err, db) { if (err) throw new Error(err); db.collection('myCollection').deleteOne(// Delete...
Delete ALL documents with a 'farewell' property set to 'okay'. const MongoClient = require('mongodb').MongoClient; const url = 'mongodb://localhost:27017/test'; MongoClient.connect(url, function (err, db) { if (err) throw new Error(err); db.collection('myCollection').deleteMany(// M...
.find() method allows us to search through the descendants of these elements in the DOM tree and construct a new jQuery object from the matching elements. HTML <div class="parent"> <div class="children" name="first"> <ul> ...
You can use the plus (+) operator to concatenate strings: 'Dart ' + 'is ' + 'fun!'; // 'Dart is fun!' You can also use adjacent string literals for concatenation: 'Dart ' 'is ' 'fun!'; // 'Dart is fun!' You can use ${} to interpolate the value of Dart expressions within strings. The curly...
A string can be either single or multiline. Single line strings are written using matching single or double quotes, and multiline strings are written using triple quotes. The following are all valid Dart strings: 'Single quotes'; "Double quotes"; 'Double quotes in "single" quo...
Programmatically generating a String is best accomplished with a StringBuffer. A StringBuffer doesn't generate a new String object until toString() is called. var sb = new StringBuffer(); sb.write("Use a StringBuffer"); sb.writeAll(["for ", "efficient ", "stri...
for arg; do echo arg=$arg done A for loop without a list of words parameter will iterate over the positional parameters instead. In other words, the above example is equivalent to this code: for arg in "$@"; do echo arg=$arg done In other words, if you catch yourself wri...
A tuple is simply a concatenation of multiple values: of possibly different types whose number and types is known statically For example, (1, "Hello") is a 2 elements tuple composed of a i32 and a &str, and its type is denoted as (i32, &'static str) in a similar fashion as i...
An array is a stack-allocated, statically-sized list of objects of a single type. Arrays are usually created by enclosing a list of elements of a given type between square brackets. The type of an array is denoted with the special syntax: [T; N] where T is the type of its elements and N their count...
# The following shell function will be used to generate completions for # the "nuance_tune" command. _nuance_tune_opts () { local curr_arg prev_arg curr_arg=${COMP_WORDS[COMP_CWORD]} prev_arg=${COMP_WORDS[COMP_CWORD-1]} # The "config" option takes a file arg, so ...
template <class InputIterator, class T> InputIterator find (InputIterator first, InputIterator last, const T& val); Effects Finds the first occurrence of val within the range [first, last) Parameters first => iterator pointing to the beginning of the range last => iterator p...
template <class InputIterator, class T> typename iterator_traits<InputIterator>::difference_type count (InputIterator first, InputIterator last, const T& val); Effects Counts the number of elements that are equal to val Parameters first => iterator pointing to the beginnin...
template <class InputIterator, class UnaryPredicate> typename iterator_traits<InputIterator>::difference_type count_if (InputIterator first, InputIterator last, UnaryPredicate red); Effects Counts the number of elements in a range for which a specified predicate function is true P...

Page 685 of 1336