Tutorial by Examples: dc

Syntax: SELECT * FROM table_name Using the asterisk operator * serves as a shortcut for selecting all the columns in the table. All rows will also be selected because this SELECT statement does not have a WHERE clause, to specify any filtering criteria. This would also work the same way if you...
// Java: String joined = things.stream() .map(Object::toString) .collect(Collectors.joining(", ")); // Kotlin: val joined = things.joinToString() // ", " is used as separator, by default
You can embed another template body into your template via {{template "mysharedtemplate" .}} to reuse shared components. Here is an example that creates a header template that can be reused at the top of all other template bodies. It also uses CSS to stylize the output so that it is easier...
A lambda expression evaluated in a class' member function is implicitly a friend of that class: class Foo { private: int i; public: Foo(int val) : i(val) {} // definition of a member function void Test() { auto lamb = [](Foo &foo, int val) ...
A newline can be included in a single-string or double-quoted string. Note that backslash-newline does not result in a newline, the line break is ignored. newline1=' ' newline2=" " newline3=$'\n' empty=\ echo "Line${newline1}break" echo "Line${newline2}break" ...
Variable substitutions should only be used inside double quotes. calculation='2 * 3' echo "$calculation" # prints 2 * 3 echo $calculation # prints 2, the list of files in the current directory, and 3 echo "$(($calculation))" # prints 6 Outside of doubl...
Some regular expression flavors allow named capture groups. Instead of by a numerical index you can refer to these groups by name in subsequent code, i.e. in backreferences, in the replace pattern as well as in the following lines of the program. Numerical indexes change as the number or arrangemen...
Given the flavors, the named capture group may looks like this: (?'name'X) (?<name>X) (?P<name>X) With X being the pattern you want to capture. Let's consider the following string: Once upon a time there was a pretty little girl... Once upon a time there was a unicorn with an h...
As you may (or not) know, you can reference a capture group with: $1 1 being the group number. In the same way, you can reference a named capture group with: ${name} \{name} g\{name} Let's take the preceding example and replace the matches with The hero of the story is a ${subject}. T...
BuildConfigField Gradle allows buildConfigField lines to define constants. These constants will be accessible at runtime as static fields of the BuildConfig class. This can be used to create flavors by defining all fields within the defaultConfig block, then overriding them for individual build fla...
You can see what "hunks" of work would be staged for commit using the patch flag: git add -p or git add --patch This opens an interactive prompt that allows you to look at the diffs and let you decide whether you want to include them or not. Stage this hunk [y,n,q,a,d,/,s,e,?]? ...
There are two Dockerfile directives to specify what command to run by default in built images. If you only specify CMD then docker will run that command using the default ENTRYPOINT, which is /bin/sh -c. You can override either or both the entrypoint and/or the command when you start up the built im...
/// <summary> /// This interface can do Foo /// </summary> public interface ICanDoFoo { // ... } /// <summary> /// This Bar class implements ICanDoFoo interface /// </summary> public class Bar : ICanDoFoo { // ... } Result Interface summary Clas...
To show all staged and unstaged changes, use: git diff HEAD NOTE: You can also use the following command: git status -vv The difference being that the output of the latter will actually tell you which changes are staged for commit and which are not.
Prefer public class Order { public OrderLine AddOrderLine(OrderLine orderLine) { if (orderLine == null) throw new ArgumentNullException(nameof(orderLine)); ... } } Over public class Order { public OrderLine AddOrderLine(OrderLine orderLine) { ...
All Java exceptions are instances of classes in the Exception class hierarchy. This can be represented as follows: java.lang.Throwable - This is the base class for all exception classes. Its methods and constructors implement a range of functionality common to all exceptions. java.lang.Excep...
The null coalescing operator makes it easy to ensure that a method that may return null will fall back to a default value. Without the null coalescing operator: string name = GetName(); if (name == null) name = "Unknown!"; With the null coalescing operator: string name = GetN...
Swift label.backgroundColor = UIColor.redColor() label.backgroundColor = .redColor() Swift 3 label.backgroundColor = UIColor.red Objective-C label.backgroundColor = [UIColor redColor];
Directives are one of the most powerful features of angularjs. Custom angularjs directives are used to extend functionality of html by creating new html elements or custom attributes to provide certain behavior to an html tag. directive.js // Create the App module if you haven't created it yet va...
Breaking out of the loop and continuing to the next iteration is also supported in Go, like in many other languages: for x := 0; x < 10; x++ { // loop through 0 to 9 if x < 3 { // skips all the numbers before 3 continue } if x > 5 { // breaks out of the loop once x...

Page 3 of 28