Tutorial by Examples

Imagine that a system want to detect apples and oranges in a basket of fruits. System can pick a fruit, extract some property of it (e.g weight of that fruit). Suppose System has a Teacher! that teaches the system which objects are apples and which are oranges. This is an example of a supervised cl...
5 With ES5+, the Object.create function can be used to create an Object with any other Object as it's prototype. const anyObj = { hello() { console.log(`this.foo is ${this.foo}`); }, }; let objWithProto = Object.create(anyObj); objWithProto.foo = 'bar'; objWithProto.hell...
Run command below to install nginx. sudo apt-get install nginx By default, Nginx automatically starts when it is installed. You can access the default Nginx landing page to confirm that the software is running properly by visiting your server's domain name or public IP address in your web browse...
Dim array2D(,) As Integer = {{1, 2, 3}, {4, 5, 6}} ' array2D(0, 0) is 1 ; array2D(0, 1) is 2 ; array2D(1, 0) is 4 Dim array3D(,,) As Integer = {{{1, 2, 3}, {4, 5, 6}}, {{7, 8, 9}, {10, 11, 12}}} ' array3D(0, 0, 0) is 1 ; array3D(0, 0, 1) is 2 ' array3D(0, 1, 0) is 4 ; array3D(1, 0, 0) is 7 ...
Note the parenthesis to distinguish between a jagged array and a multidimensional array SubArrays can be of different length Dim jaggedArray()() As Integer = { ({1, 2, 3}), ({4, 5, 6}), ({7}) } ' jaggedArray(0) is {1, 2, 3} and so jaggedArray(0)(0) is 1 ' jaggedArray(1) is {4, 5, 6} and so jagge...
valgrind ./my-program arg1 arg2 < test-input This will run your program and produce a report of any allocations and de-allocations it did. It will also warn you about common errors like using uninitialized memory, dereferencing pointers to strange places, writing off the end of blocks allocate...
You can also turn on more tests, such as: valgrind -q --tool=memcheck --leak-check=yes ./my-program arg1 arg2 < test-input See valgrind --help for more information about the (many) options, or look at the documentation at http://valgrind.org/ for detailed information about what the output mea...
Here is a program that calls malloc but not free: #include <stdio.h> #include <stdlib.h> int main(int argc, char **argv) { char *s; s = malloc(26); // the culprint return 0; } With no extra arguments, valgrind will not look for this error. But if we turn on...
Unary folds are used to fold parameter packs over a specific operator. There are 2 kinds of unary folds: Unary Left Fold (... op pack) which expands as follows: ((Pack1 op Pack2) op ...) op PackN Unary Right Fold (pack op ...) which expands as follows: Pack1 op (... (Pack(N-1) op Pac...
Binary folds are basically unary folds, with an extra argument. There are 2 kinds of binary folds: Binary Left Fold - (value op ... op pack) - Expands as follows: (((Value op Pack1) op Pack2) op ...) op PackN Binary Right Fold (pack op ... op value) - Expands as follows: Pack1 op (......
wikipedia definition: Command pattern is a behavioral design pattern in which an object is used to encapsulate all information needed to perform an action or trigger an event at a later time UML diagram from dofactory: Basic components and workflow: Command declares an interface for abst...
Quantifiers allows to specify count of repeated strings. Zero or one: /a?/ Zero or many: /a*/ One or many: /a+/ Exact number: /a{2,4}/ # Two, three or four /a{2,}/ # Two or more /a{,4}/ # Less than four (including zero) By default, quantifiers are greedy, whi...
Describes ranges of symbols You can enumerate symbols explicitly /[abc]/ # 'a' or 'b' or 'c' Or use ranges /[a-z]/ # from 'a' to 'z' It is possible to combine ranges and single symbols /[a-cz]/ # 'a' or 'b' or 'c' or 'z' Leading dash (-) is treated as charachter /[-a-c]/ # '-' or 'a' o...
Unions are a specialized struct within which all members occupy overlapping memory. union U { int a; short b; float c; }; U u; //Address of a and b will be equal (void*)&u.a == (void*)&u.b; (void*)&u.a == (void*)&u.c; //Assigning to any union member changes ...
Unions are useful for minimizing memory usage for exclusive data, such as when implementing mixed data types. struct AnyType { enum { IS_INT, IS_FLOAT } type; union Data { int as_int; float as_float; } value; AnyType(int i) : type...
You can test if a string matches several regular expressions using a switch statement. Example case "Ruby is #1!" when /\APython/ puts "Boooo." when /\ARuby/ puts "You are right." else puts "Sorry, I didn't understand that." end This w...
Pointer initialization is a good way to avoid wild pointers. The initialization is simple and is no different from initialization of a variable. #include <stddef.h> int main() { int *p1 = NULL; char *p2 = NULL; float *p3 = NULL; /* NULL is a macro defined in st...
All versions of SharePoint are based around Sites (SPSite (SSOM) or Site (CSOM)) and Webs (SPWeb(SSOM) or Web(CSOM)). A site is not rendered in the UI although it does contain metadata and features that are applied to its children. A web is the basic building block that renders a UI to the user acce...
ClientContext clientContext = new ClientContext(siteUrl); Web oWebsite = clientContext.Web; clientContext.Load(oWebsite); clientContext.ExecuteQuery(); Console.WriteLine("Title: {0} Description: {1}", oWebsite.Title, oWebsite.Description);
ClientContext clientContext = new ClientContext(siteUrl); Web oWebsite = clientContext.Web; clientContext.Load( oWebsite, website => website.Title, website => website.Created); clientContext.ExecuteQuery(); Console.WriteLine("Title: {...

Page 338 of 1336