Tutorial by Examples: ar

There are three ways of creating a new branch feature which tracks the remote branch origin/feature: git checkout --track -b feature origin/feature, git checkout -t origin/feature, git checkout feature - assuming that there is no local feature branch and there is only one remote with the featur...
Here's the 'bare minimum' Arduino sketch. This can be loaded into the Arduino IDE by choosing File > Examples > 01. Basics > Bare Minimum. void setup() { // put your setup code here, to run once } void loop() { // put your main code here, to run repeatedly } Code in the setup...
There are several ways to search a key in std::map or in std::multimap. To get the iterator of the first occurrence of a key, the find() function can be used. It returns end() if the key does not exist. std::multimap< int , int > mmp{ {1, 2}, {3, 4}, {6, 5}, {8, 9}, {3, 4}, {6, 7} }; ...
Constructors can be created with any kinds of arguments. public class TestClass { private String testData; public TestClass(String testData) { this.testData = testData; } } Called like this: TestClass testClass = new TestClass("Test Data"); A class can ...
Reflection is often used as part of software testing, such as for the runtime creation/instantiation of mock objects. It's also great for inspecting the state of an object at any given point in time. Here's an example of using Reflection in a unit test to verify a protected class member contains the...
main = do input <- getContents putStr input Input: This is an example sentence. And this one is, too! Output: This is an example sentence. And this one is, too! Note: This program will actually print parts of the output before all of the input has been fully read in. This m...
main = do line <- getLine putStrLn line Input: This is an example. Output: This is an example.
readFloat :: IO Float readFloat = fmap read getLine main :: IO () main = do putStr "Type the first number: " first <- readFloat putStr "Type the second number: " second <- readFloat putStrLn $ show first ++ " + " ++ show se...
To stop a running container: docker stop <container> [<container>...] This will send the main process in the container a SIGTERM, followed by a SIGKILL if it doesn't stop within the grace period. The name of each container is printed as it stops. To start a container which is stoppe...
SQL TermsMongoDB TermsDatabaseDatabaseTableCollectionEntity / RowDocumentColumnKey / FieldTable JoinEmbedded DocumentsPrimary KeyPrimary Key (Default key _id provided by mongodb itself)
This uses the Dropbox .NET SDK to download a file from the Dropbox API at the remote path to the local file "Test", while tracking progress: var response = await client.Files.DownloadAsync(path); ulong fileSize = response.Response.Size; const int bufferSize = 1024 * 1024; var buffer ...
Note that these only work in the developer tools of certain browsers. $_ gives you the value of whatever expression was evaluated last. "foo" // "foo" $_ // "foo" $0 refers to the DOM element currently selected in the Inspector. So if &l...
While object property notation is usually written as myObject.property, this will only allow characters that are normally found in JavaScript variable names, which is mainly letters, numbers and underscore (_). If you need special characters, such as space, ☺, or user-provided content, this is poss...
Sometimes the property name needs to be stored into a variable. In this example, we ask the user what word needs to be looked up, and then provide the result from an object I've named dictionary. var dictionary = { lettuce: 'a veggie', banana: 'a fruit', tomato: 'it depends on who yo...
Disclaimer: Creating array-like objects is not recommend. However, it is helpful to understand how they work, especially when working with DOM. This will explain why regular array operations don't work on DOM objects returned from many DOM document functions. (i.e. querySelectorAll, form.elements)...
To find a character or another string, you can use std::string::find. It returns the position of the first character of the first match. If no matches were found, the function returns std::string::npos std::string str = "Curiosity killed the cat"; auto it = str.find("cat"); ...
An array can easily be converted into a std::vector by using std::begin and std::end: C++11 int values[5] = { 1, 2, 3, 4, 5 }; // source array std::vector<int> v(std::begin(values), std::end(values)); // copy array to new vector for(auto &x: v) std::cout << x << &q...
You cannot pass a reference (or const reference) directly to a thread because std::thread will copy/move them. Instead, use std::reference_wrapper: void foo(int& b) { b = 10; } int a = 1; std::thread thread{ foo, std::ref(a) }; //'a' is now really passed as reference thread.join()...
What are Array-like Objects? JavaScript has "Array-like Objects", which are Object representations of Arrays with a length property. For example: var realArray = ['a', 'b', 'c']; var arrayLike = { 0: 'a', 1: 'b', 2: 'c', length: 3 }; Common examples of Array-like Objects...
The STUFF() function inserts a string into another string by first deleting a specified number of characters. The following example, deletes "Svr" and replaces it with "Server". This happens by specifying the start_position and length of the replacement. SELECT STUFF('SQL Svr D...

Page 16 of 218