Tutorial by Examples: ai

std::sort, found in the standard library header algorithm, is a standard library algorithm for sorting a range of values, defined by a pair of iterators. std::sort takes as the last parameter a functor used to compare two values; this is how it determines the order. Note that std::sort is not stable...
Imagine the following XML: <root> <element>hello</element> <another> hello </another> <example>Hello, <nested> I am an example </nested>.</example> </root> The following XPath expression: //*[text() = 'hel...
To make a Haskell program executable you must provide a file with a main function of type IO () main :: IO () main = putStrLn "Hello world!" When Haskell is compiled it examines the IO data here and turns it into a executable. When we run this program it will print Hello world!. If y...
We can bind a class as a Singleton: public function register() { App::singleton('my-database', function() { return new Database(); }); } This way, the first time an instance of 'my-database' will be requested to the service container, a new instance will be created. Al...
Solution 1: $('#parent').prepend($('#child')); Solution 2: $('#child').prependTo($('#parent')); Both solutions are prepending the element #child (adding at the beginning) to the element #parent. Before: <div id="parent"> <span>other content</span> </di...
Solution 1: $('#parent').append($('#child')); Solution 2: $('#child').appendTo($('#parent')); Both solutions are appending the element #child (adding at the end) to the element #parent. Before: <div id="parent"> <span>other content</span> </div> <d...
chrome.runtime.getManifest() returns the extension's manifest in a form of a parsed object. This method works both on content scripts and all extension pages, it requires no permissions, Example, obtaining the extension's version string: var version = chrome.runtime.getManifest().version;
A Value Converter can be used alongside other value converters and you can infinitely chain them using the | pipe separator. ${myString | toUppercase | removeCharacters:'&,%,-,+' | limitTo:25} The above theoretical example firstly applies toUppercase which capitalizes our string. Then it app...
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...
Set memory limit and disable swap limit docker run -it -m 300M --memory-swap -1 ubuntu:14.04 /bin/bash Set both memory and swap limit. In this case, container can use 300M memory and 700M swap. docker run -it -m 300M --memory-swap 1G ubuntu:14.04 /bin/bash
When creating Random instances with the same seed, the same numbers will be generated. int seed = 5; for (int i = 0; i < 2; i++) { Console.WriteLine("Random instance " + i); Random rnd = new Random(seed); for (int j = 0; j < 5; j++) { Console.Write(rnd.Next(...
from container to host docker cp CONTAINER_NAME:PATH_IN_CONTAINER PATH_IN_HOST from host to container docker cp PATH_IN_HOST CONTAINER_NAME:PATH_IN_CONTAINER If I use jess/transmission from https://hub.docker.com/r/jess/transmission/builds/bsn7eqxrkzrhxazcuytbmzp/ , the files in the contai...
Send-MailMessage -From [email protected] -Subject "Email Subject" -To [email protected] -SmtpServer smtp.com
$parameters = @{ From = '[email protected]' To = '[email protected]' Subject = 'Email Subject' Attachments = @('C:\files\samplefile1.txt','C:\files\samplefile2.txt') BCC = '[email protected]' Body = 'Email body' BodyAsHTML = $False CC = '[email protected]' Credential = Get-Crede...
When an extension method returns a value that has the same type as its this argument, it can be used to "chain" one or more method calls with a compatible signature. This can be useful for sealed and/or primitive types, and allows the creation of so-called "fluent" APIs if the me...
Method chaining is a programming strategy that simplifies your code and beautifies it. Method chaining is done by ensuring that each method on an object returns the entire object, instead of returning a single element of that object. For example: function Door() { this.height = ''; this.w...
This is an example of how to use the generic type TFood inside Eat method on the class Animal public interface IFood { void EatenBy(Animal animal); } public class Grass: IFood { public void EatenBy(Animal animal) { Console.WriteLine("Grass was eaten by: {0}",...
Using iris dataset: import sklearn.datasets iris_dataset = sklearn.datasets.load_iris() X, y = iris_dataset['data'], iris_dataset['target'] Data is split into train and test sets. To do this we use the train_test_split utility function to split both X and y (data and target vectors) randomly w...
await operator and async keyword come together: The asynchronous method in which await is used must be modified by the async keyword. The opposite is not always true: you can mark a method as async without using await in its body. What await actually does is to suspend execution of the code ...

Page 9 of 47