Tutorial by Examples: c

XML <Galaxy> <name>Milky Way</name> <CelestialObject name="Earth" type="planet"/> <CelestialObject name="Sun" type="star"/> </Galaxy> XPATH /Galaxy/*[ends-with(lower-case(@type),'tar')] or //*[ends-w...
This example uses Parallel.ForEach to calculate the sum of the numbers between 1 and 10000 by using multiple threads. To achieve thread-safety, Interlocked.Add is used to sum the numbers. using System.Threading; int Foo() { int total = 0; var numbers = Enumerable.Range(1, 10000).ToLis...
ctrl + alt + shift + / (cmd + alt + shift + / on MacOS) should show you the following dialog: Clicking on Registry you will get The key you want to enable/disable is editor.skip.copy.and.cut.for.empty.selection Tested on Linux Ubuntu and MacOS.
Using Code Contracts it is possible to apply a contract to an interface. This is done by declaring an abstract class that implments the interfaces. The interface should be tagged with the ContractClassAttribute and the contract definition (the abstract class) should be tagged with the ContractClas...
While System.Diagnostics.Contracts is included within the .Net Framework. To use Code Contracts you must install the Visual Studio extensions. Under Extensions and Updates search for Code Contracts then install the Code Contracts Tools After the tools are installed you must enable Code Contract...
Dereferencing happens with the . operator: Object obj = new Object(); String text = obj.toString(); // 'obj' is dereferenced. Dereferencing follows the memory address stored in a reference, to the place in memory where the actual object resides. When an object has been found, the requested meth...
When a response contains valid JSON, just use the .json() method on the Response object to get the decoded result: response = requests.get('http://example.com/') decoded_result = response.json() However, this does not fail gracefully; it will raise a JSONDecodeError if the response object is no...
To switch the value of two variables you can use tuple unpacking. x = True y = False x, y = y, x x # False y # True
Docker volumes are not automatically removed when a container is stopped. To remove associated volumes when you stop a container: docker rm -v <container id or name> If the -v flag is not specified, the volume remains on-disk as a 'dangling volume'. To delete all dangling volumes: docker ...
Conditional contexts in Lua (if, elseif, while, until) do not require a boolean. Like many languages, any Lua value can appear in a condition. The rules for evaluation are simple: false and nil count as false. Everything else counts as true. if 1 then print("Numbers work.") ...
K&R void* is a catch all type for pointers to object types. An example of this in use is with the malloc function, which is declared as void* malloc(size_t); The pointer-to-void return type means that it is possible to assign the return value from malloc to a pointer to any other type of ob...
Conditional expressions can be done with ~[ and ~]. The clauses of the expression are separated using ~;. By default, ~[ takes an integer from the argument list, and picks the corresponding clause. The clauses start at zero. (format t "~@{~[First clause~;Second clause~;Third clause~;Fourth cl...
Schema Statics are methods that can be invoked directly by a Model (unlike Schema Methods, which need to be invoked by an instance of a Mongoose document). You assign a Static to a schema by adding the function to the schema's statics object. One example use case is for constructing custom queries:...
What is a Set? A set is a data structure which contains a set of elements with an important property that no two elements in the set are equal. Types of Set: HashSet: A set backed by a hash table (actually a HashMap instance) Linked HashSet: A Set backed by Hash table and linked list, with pre...
With Clipping and Masking you can make some specified parts of elements transparent or opaque. Both can be applied to any HTML element. Clipping Clips are vector paths. Outside of this path the element will be transparent, inside it's opaque. Therefore you can define a clip-path property on elemen...
+ dictionaryWithCapacity: Creates and returns a mutable dictionary, initially giving it enough allocated memory to hold a given number of entries. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:1]; NSLog(@"%@",dict); - init Initializes a newly allocated mut...
- removeObjectForKey: Removes a given key and its associated value from the dictionary. NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithDictionary:@{@"key1":@"Easy",@"key2": @"Tutorials"}]; [dict removeObjectForKey:@"key1"]; NSLog...
A declaration introduces an identifier and describes its type, be it a type, object, or function. A declaration is what the compiler needs to accept references to that identifier. These are declarations: extern int bar; extern int g(int, int); double f(int, double); /* extern can be omitted for f...
When writing a copy assignment operator, it is very important that it be able to work in the event of self-assignment. That is, it has to allow this: SomeType t = ...; t = t; Self-assignment usually doesn't happen in such an obvious way. It typically happens via a circuitous route through vario...
A data race or race condition is a problem that can occur when a multithreaded program is not properly synchronized. If two or more threads access the same memory without synchronization, and at least one of the accesses is a 'write' operation, a data race occurs. This leads to platform dependent, p...

Page 248 of 826