Tutorial by Examples: ch

Use Case CASE can be used in conjunction with SUM to return a count of only those items matching a pre-defined condition. (This is similar to COUNTIF in Excel.) The trick is to return binary results indicating matches, so the "1"s returned for matching entries can be summed for a count o...
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...
$ git branch -d dev Deletes the branch named dev if its changes are merged with another branch and will not be lost. If the dev branch does contain changes that have not yet been merged that would be lost, git branch -d will fail: $ git branch -d dev error: The branch 'dev' is not fully merged...
Normally a change of webpage within an Iframe is initiated from with the Iframe, for example, clicking a link inside the Ifame. However, it is possible to change an IFrame's content from outside the IFrame. You can use an anchor tag whose href attribute is set to the desired URL and whose target at...
Use the isset() function upon the superglobal $_COOKIE variable to check if a cookie is set. Example: // PHP <7.0 if (isset($_COOKIE['user'])) { // true, cookie is set echo 'User is ' . $_COOKIE['user']; else { // false, cookie is not set echo 'User is not logged in'; } ...
Add the following target in your build.xml <!-- Bootstrap ivy --> <target name="ivy.bootstrap" description="Download Apache Ivy"> <!-- Define the version to use --> <property name="ivy.version">2.4.0</property> <!-- ...
On StackExchange sites, code snippets may provide optional syntax highlighting. On sites like Stack Overflow the default language is derived from the tags used in the associated question (if applicable). In addition, a code snippet's syntax highlighting language may also be defined by adding an HTML...
To see the log with changes inline, use the -p or --patch options. git log --patch Example (from Trello Scientist repository) ommit 8ea1452aca481a837d9504f1b2c77ad013367d25 Author: Raymond Chou <[email protected]> Date: Wed Mar 2 10:35:25 2016 -0800 fix readme error link diff ...
To find files/directories with a specific name, relative to pwd: $ find . -name "myFile.txt" ./myFile.txt To find files/directories with a specific extension, use a wildcard: $ find . -name "*.txt" ./myFile.txt ./myFile2.txt To find files/directories matching one of ma...
#include <stdio.h> #define is_const_int(x) _Generic((&x), \ const int *: "a const int", \ int *: "a non-const int", \ default: "of other type") int main(void) { const int i = 1; int j = 1; double...
First, establish if the device is capable of accepting Touch ID input. if (context.CanEvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, out AuthError)) If it does then we can display the Touch ID UI by using: context.EvaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometri...
With Stream Controller add-on enabled, you can use Channel Groups to subscribe to a 1000's of channels from a single client. You do this by creating a channel group and adding channels to the channel group. We'll assume pubnub variable has been initialized properly with your keys. Create a generic ...
foreach is used to iterate over the elements of an array or the items within a collection which implements IEnumerable✝. var lines = new string[] { "Hello world!", "How are you doing today?", "Goodbye" }; foreach (string line in lines) { Con...
When creating animations and other GPU-heavy actions, it's important to understand the will-change attribute. Both CSS keyframes and the transition property use GPU acceleration. Performance is increased by offloading calculations to the device's GPU. This is done by creating paint layers (parts of...
For any file operations, you will need the filesystem module: const fs = require('fs'); Reading a String fs.readFileSync behaves similarly to fs.readFile, but does not take a callback as it completes synchronously and therefore blocks the main thread. Most node.js developers prefer the asynch...
Let's say you want to generate counts or subtotals for a given value in a column. Given this table, "Westerosians": NameGreatHouseAllegienceAryaStarkCerceiLannisterMyrcellaLannisterYaraGreyjoyCatelynStarkSansaStark Without GROUP BY, COUNT will simply return a total number of rows: SELE...
Switch statements compare the value of an expression against 1 or more values and executes different sections of code based on that comparison. var value = 1; switch (value) { case 1: console.log('I will always run'); break; case 2: console.log('I will never run'); break;...
The first argument of re.match() is the regular expression, the second is the string to match: import re pattern = r"123" string = "123zzb" re.match(pattern, string) # Out: <_sre.SRE_Match object; span=(0, 3), match='123'> match = re.match(pattern, string) ma...
pattern = r"(your base)" sentence = "All your base are belong to us." match = re.search(pattern, sentence) match.group(1) # Out: 'your base' match = re.search(r"(belong.*)", sentence) match.group(1) # Out: 'belong to us.' Searching is done anywhere in the ...
Special characters (like the character class brackets [ and ] below) are not matched literally: match = re.search(r'[b]', 'a[b]c') match.group() # Out: 'b' By escaping the special characters, they can be matched literally: match = re.search(r'\[b\]', 'a[b]c') match.group() # Out: '[b]' T...

Page 5 of 109