Tutorial by Examples: dc

Node.js can also be used to create command line utilities. The example below reads the first argument from the command line and prints a Hello message. To run this code on an Unix System: Create a new file and paste the code below. The filename is irrelevant. Make this file executable with chmo...
To conditionally include a block of code, the preprocessor has several directives (e.g #if, #ifdef, #else, #endif, etc). /* Defines a conditional `printf` macro, which only prints if `DEBUG` * has been defined */ #ifdef DEBUG #define DLOG(x) (printf(x)) #else #define DLOG(x) #endif Norm...
The searched CASE returns results when a boolean expression is TRUE. (This differs from the simple case, which can only check for equivalency with an input.) SELECT Id, ItemId, Price, CASE WHEN Price < 10 THEN 'CHEAP' WHEN Price < 20 THEN 'AFFORDABLE' ELSE 'EXPENSIVE' E...
The key to correctly stretching is in the top and left border. The top border controls horizontal stretching and the left border controls vertical stretching. This example creates rounded corners suitable for a Toast. The parts of the image that are below the top border and to the right of the ...
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. ...
To create a new branch, while staying on the current branch, use: git branch <name> Generally, the branch name must not contain spaces and is subject to other specifications listed here. To switch to an existing branch : git checkout <name> To create a new branch and switch to it...
Output buffering allows you to store any textual content (Text, HTML) in a variable and send to the browser as one piece at the end of your script. By default, php sends your content as it interprets it. <?php // Turn on output buffering ob_start(); // Print some output to the buffer (via...
In this example, we'll be looking at how to store a credit card using the PayPal vault, then reference that stored credit card to process a credit card transaction for a user. The reason why we would want to use the vault is so that we don't have to store sensitive credit card information on our ow...
CASE's shorthand variant evaluates an expression (usually a column) against a series of values. This variant is a bit shorter, and saves repeating the evaluated expression over and over again. The ELSE clause can still be used, though: SELECT Id, ItemId, Price, CASE Price WHEN 5 THEN 'CHEAP' ...
C++14 Lambdas can capture expressions, rather than just variables. This permits lambdas to store move-only types: auto p = std::make_unique<T>(...); auto lamb = [p = std::move(p)]() //Overrides capture-by-value of `p`. { p->SomeFunc(); }; This moves the outer p variable into th...
#include <stdio.h> #include <string.h> int main(void) { /* Always ensure that your string is large enough to contain the characters * and a terminating NUL character ('\0')! */ char mystring[10]; /* Copy "foo" into `mystring`, until a NUL character is en...
Syntax for accessing rows and columns: [, [[, and $ This topic covers the most common syntax to access specific rows and columns of a data frame. These are Like a matrix with single brackets data[rows, columns] Using row and column numbers Using column (and row) names Like a list: Wi...
The pipe operator, %>%, is used to insert an argument into a function. It is not a base feature of the language and can only be used after attaching a package that provides it, such as magrittr. The pipe operator takes the left-hand side (LHS) of the pipe and uses it as the first argument of the ...
Use putAll to put every member of one map into another. Keys already present in the map will have their corresponding values overwritten. Map<String, Integer> numbers = new HashMap<>(); numbers.put("One", 1) numbers.put("Three", 3) Map<String, Integer> othe...
A a pointer to a piece of memory containing n elements may only be dereferenced if it is in the range memory and memory + (n - 1). Dereferencing a pointer outside of that range results in undefined behavior. As an example, consider the following code: int array[3]; int *beyond_array = array + 3; ...
Method Chaining is a technique explained in Martin Fowler's book Domain Specific Languages. Method Chaining is summarized as Makes modifier methods return the host object, so that multiple modifiers can be invoked in a single expression. Consider this non-chaining/regular piece of code (ported...
You can create multiline code snippets by indenting each line with at least four spaces or one tab: #include <stdio.h> int main() { printf("Hello World!\n"); return 0; }
Some parsers allow code to be designated by adding three backticks before and after a section of code. ``` <p><em>This</em> is an HTML example!</p> ``` Optionally, many parsers allow adding syntax highlighting by specifying the code's language immediately after the firs...
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...
Razor has its own comment syntax which begins with @* and ends with *@. Inline Comment: <h1>Comments can be @*hi!*@ inline</h1> Multi-line Comment: @* Comments can spread over multiple lines *@ HTML Comment You can also use the normal HTML comment syntax starting with &...

Page 2 of 28