Tutorial by Examples: ci

A basic join (also called "inner join") queries data from two tables, with their relationship defined in a join clause. The following example will select employees' first names (FName) from the Employees table and the name of the department they work for (Name) from the Departments table:...
Joins can also be performed by having several tables in the from clause, separated with commas , and defining the relationship between them in the where clause. This technique is called an Implicit Join (since it doesn't actually contain a join clause). All RDBMSs support it, but the syntax is usua...
For any iterable (for eg. a string, list, etc), Python allows you to slice and return a substring or sublist of its data. Format for slicing: iterable_name[start:stop:step] where, start is the first index of the slice. Defaults to 0 (the index of the first element) stop one past the last in...
A practical use case of a generator is to iterate through values of an infinite series. Here's an example of finding the first ten terms of the Fibonacci Sequence. def fib(a=0, b=1): """Generator that yields Fibonacci numbers. `a` and `b` are the seed values""" ...
This example uses the Cars Table from the Example Databases. UPDATE Cars SET Status = 'READY' WHERE Id = 4 This statement will set the status of the row of 'Cars' with id 4 to "READY". WHERE clause contains a logical expression which is evaluated for each row. If a...
reduce will not terminate the iteration before the iterable has been completly iterated over so it can be used to create a non short-circuit any() or all() function: import operator # non short-circuit "all" reduce(operator.and_, [False, True, True, True]) # = False # non short-circu...
filter (python 3.x) and ifilter (python 2.x) return a generator so they can be very handy when creating a short-circuit test like or or and: Python 2.x2.0.1 # not recommended in real use but keeps the example short: from itertools import ifilter as filter Python 2.x2.6.1 from future_built...
This is an example of dereferencing a NULL pointer, causing undefined behavior. int * pointer = NULL; int value = *pointer; /* Dereferencing happens here */ A NULL pointer is guaranteed by the C standard to compare unequal to any pointer to a valid object, and dereferencing it invokes undefined...
curl -X POST https://api.dropboxapi.com/2/sharing/list_shared_links \ --header "Authorization: Bearer <ACCESS_TOKEN>" \ --header "Content-Type: application/json" \ --data "{\"path\": \"/test.txt\", \"direct_only\": true}&quo...
Template literals are a special type of string literal that can be used instead of the standard '...' or "...". They are declared by quoting the string with backticks instead of the standard single or double quotes: `...`. Template literals can contain line breaks and arbitrary expression...
Inheritance in Python is based on similar ideas used in other object oriented languages like Java, C++ etc. A new class can be derived from an existing class as follows. class BaseClass(object): pass class DerivedClass(BaseClass): pass The BaseClass is the already existing (parent)...
The -import-objc-header flag specifies a header for swiftc to import: // defs.h struct Color { int red, green, blue; }; #define MAX_VALUE 255 // demo.swift extension Color: CustomStringConvertible { // extension on a C struct public var description: String { return &q...
Static method can be inherited similar to normal methods, however unlike normal methods it is impossible to create "abstract" methods in order to force static method overriding. Writing a method with the same signature as a static method in a super class appears to be a form of overriding,...
INSERT INTO Customers (FName, LName, Email, PreferredContact) VALUES ('Zack', 'Smith', '[email protected]', 'EMAIL'); This statement will insert a new row into the Customers table. Data will only be inserted into the columns specified - note that no value was provided for the PhoneNumber column. ...
// This creates an array with 5 values. const int array[] = { 1, 2, 3, 4, 5 }; #ifdef BEFORE_CPP11 // You can use `sizeof` to determine how many elements are in an array. const int* first = array; const int* afterLast = first + sizeof(array) / sizeof(array[0]); // Then you can iterate ov...
The and-operator (&&) and the or-operator (||) employ short-circuiting to prevent unnecessary work if the outcome of the operation does not change with the extra work. In x && y, y will not be evaluated if x evaluates to false, because the whole expression is guaranteed to be false....
There are three keywords that act as access specifiers. These limit the access to class members following the specifier, until another specifier changes the access level again: KeywordDescriptionpublicEveryone has accessprotectedOnly the class itself, derived classes and friends have accessprivate...
You can use the nil coalescing operator to unwrap a value if it is non-nil, otherwise provide a different value: func fallbackIfNil(str: String?) -> String { return str ?? "Fallback String" } print(fallbackIfNil("Hi")) // Prints "Hi" print(fallbackIfNil(nil)...
Sourcing a file is different from execution, in that all commands are evaluated within the context of the current bash session - this means that any variables, function, or aliases defined will persist throughout your session. Create the file you wish to source sourceme.sh #!/bin/bash export A=...
For lambdas with a single return statement, or multiple return statements whose expressions are of the same type, the compiler can deduce the return type: // Returns bool, because "value > 10" is a comparison which yields a Boolean result auto l = [](int value) { return value &gt...

Page 2 of 42