Tutorial by Examples: ci

Implicit parameters can be useful if a parameter of a type should be defined once in the scope and then applied to all functions that use a value of that type. A normal function call looks something like this: // import the duration methods import scala.concurrent.duration._ // a normal method...
With the shape-outside CSS property one can define shape values for the float area so that the inline content wraps around the shape instead of the float's box. CSS img:nth-of-type(1) { shape-outside: circle(80px at 50% 50%); float: left; width: 200px; } img:nth-of-type(2) { shape-ou...
If you need to get a specific language or version of an item, you can use these overloads of GetItem() Sitecore.Context.Database.GetItem("/sitecore/content/Sitecore", Language.Current, new Version(5));
A hexadecimal number is a value in base-16. There are 16 digits, 0-9 and the letters A-F (case does not matter). A-F represent 10-16. An octal number is a value in base-8, and uses the digits 0-7. A binary number is a value in base-2, and uses the digits 0 and 1. All of these numbers result in ...
A common way to download Go dependencies is by using the go get <package> command, which will save the package into the global/shared $GOPATH/src directory. This means that a single version of each package will be linked into each project that includes it as a dependency. This also means that...
Import the numpy module to use any part of it. import numpy as np Most examples will use np as shorthand for numpy. Assume "np" means "numpy" in code examples. x = np.array([1,2,3,4])
Draw samples from a normal (gaussian) distribution # Generate 5 random numbers from a standard normal distribution # (mean = 0, standard deviation = 1) np.random.randn(5) # Out: array([-0.84423086, 0.70564081, -0.39878617, -0.82719653, -0.4157447 ]) # This result can also be achieved with t...
The following method computes the Nth Fibonacci number using recursion. public int fib(final int n) { if (n > 2) { return fib(n - 2) + fib(n - 1); } return 1; } The method implements a base case (n <= 2) and a recursive case (n>2). This illustrates the use of re...
4.0 Declare an associative array declare -A aa Declaring an associative array before initialization or use is mandatory. Initialize elements You can initialize elements one at a time as follows: aa[hello]=world aa[ab]=cd aa["key with space"]="hello world" You can al...
Arithmetic if statement allows one to use three branches depending on the result of an arithmetic expression if (arith_expr) label1, label2, label3 This if statement transfers control flow to one of the labels in a code. If the result of arith_expr is negative label1 is involved, if the result i...
Python lists are 0-based i.e. the first element in the list can be accessed by the index 0 arr = ['a', 'b', 'c', 'd'] print(arr[0]) >> 'a' You can access the second element in the list by index 1, third element by index 2 and so on: print(arr[1]) >> 'b' print(arr[2]) >> '...
Declaring a generic interface interface IResult<T> { wasSuccessfull: boolean; error: T; } var result: IResult<string> = .... var error: string = result.error; Generic interface with multiple type parameters interface IRunnable<T, U> { run(input: T): U; } ...
If you set opacity on an element it will affect all its child elements. To set an opacity just on the background of an element you will have to use RGBA colors. Following example will have a black background with 0.6 opacity. /* Fallback for web browsers that don't support RGBa */ background-color...
Null coalescing is a new operator introduced in PHP 7. This operator returns its first operand if it is set and not NULL. Otherwise it will return its second operand. The following example: $name = $_POST['name'] ?? 'nobody'; is equivalent to both: if (isset($_POST['name'])) { $name = $_P...
Using an incorrect format specifier in the first argument to printf invokes undefined behavior. For example, the code below invokes undefined behavior: long z = 'B'; printf("%c\n", z); Here is another example printf("%f\n",0); Above line of code is undefined behavior. %...
By default, Django renders ForeignKey fields as a <select> input. This can cause pages to be load really slowly if you have thousands or tens of thousand entries in the referenced table. And even if you have only hundreds of entries, it is quite uncomfortable to look for a particular entry amo...
Implicit classes make it possible to add new methods to previously defined classes. The String class has no method withoutVowels. This can be added like so: object StringUtil { implicit class StringEnhancer(str: String) { def withoutVowels: String = str.replaceAll("[aeiou]", &quo...
To create a JAR containing all of its dependencies, it is possible to use the built-in descriptor format jar-with-dependencies. The following example configures an execution of the Assembly Plugin bound to the package phase, using this built-in descriptor and declaring a main class of com.example: ...
Two ways to replace: by regex or by exact match. Note: the original String object will be unchanged, the return value holds the changed String. Exact match Replace single character with another single character: String replace(char oldChar, char newChar) Returns a new string resulting from...
An explicit intent is used for starting an activity or service within the same application package. In this case the name of the intended class is explicitly mentioned: Intent intent = new Intent(this, MyComponent.class); startActivity(intent); However, an implicit intent is sent across the sys...

Page 9 of 42