Tutorial by Examples: f

{ echo "contents of home directory" ls ~ } > output.txt
Other examples couldn't clearly explain to me how to trigger the conditional logic. This example also shows that underlying commands will also listen to the -Confirm flag! <# Restart-Win32Computer #> function Restart-Win32Computer { [CmdletBinding(SupportsShouldProcess=$true,Conf...
It is possible to effectively apply a function (cb) which returns a promise to each element of an array, with each element waiting to be processed until the previous element is processed. function promiseForEach(arr, cb) { var i = 0; var nextPromise = function () { if (i >= arr.leng...
import pandas as pd df = pd.DataFrame(np.random.randn(5, 5), columns=list('ABCDE')) To generate various summary statistics. For numeric values the number of non-NA/null values (count), the mean (mean), the standard deviation std and values known as the five-number summary : min: minimum (smal...
Supported by IE11+ View Result Use these 3 lines to vertical align practically everything. Just make sure the div/image you apply the code to has a parent with a height. CSS div.vertical { position: relative; top: 50%; transform: translateY(-50%); } HTML <div class="vertica...
Clojure uses prefix notation, that is: The operator comes before its operands. For example, a simple sum of two numbers would be: (+ 1 2) ;; => 3 Macros allow you to manipulate the Clojure language to a certain degree. For example, you could implement a macro that let you write code in infi...
DefaultIfEmpty is used to return a Default Element if the Sequence contains no elements. This Element can be the Default of the Type or a user defined instance of that Type. Example: var chars = new List<string>() { "a", "b", "c", "d" }; chars.Defaul...
The following method computes the sum of integers from 0 to N using recursion. public int sum(final int n) { if (n > 0) { return n + sum(n - 1); } else { return n; } } This method is O(N) and can be reduced to a simple loop using tail-call optimization. In f...
The following method computes the value of num raised to the power of exp using recursion: public long power(final int num, final int exp) { if (exp == 0) { return 1; } if (exp == 1) { return num; } return num * power(num, exp - 1); } This illustrates ...
<root xmlns="http://test/"> <element xmlns:example="http://foobar/"> <example:hello_world attribute="another example" /> </element> </root> The expression /root will return nothing, because there is no non-namespaced ...
Let's say we have the following function: (defn nat-num-count [nums] (count (remove neg? nums))) We can write a spec for this function by defining a function spec of the same name: (clojure.spec/fdef nat-num-count :args (s/cat :nums (s/coll-of number?)) :ret integer? ...
Hibernate can use two types of fetch when you are mapping the relationship between two entities: EAGER and LAZY. In general, the EAGER fetch type is not a good idea, because it tells JPA to always fetch the data, even when this data is not necessary. Per example, if you have a Person entity and th...
While there are many parameters that can be changed and variations that can be added depending on the desired functionality, this example lays out the basic framework for launching PowerPoint. Note: This code requires that the PowerPoint reference has been added to the active VBA Project. See th...
$ man -w find /usr/share/man/man1/find.1.gz $ man -w printf /usr/share/man/man1/printf.1.gz $ man -w man /usr/share/man/man1/man.1.gz
Suppose we have an interface: interface IPerson { name: string; age: number; breath(): void; } And we want to create more specific interface that has the same properties of the person, we can do it using the extends keyword: interface IManager extends IPerson { managerId:...
The most common way to test Angular 2 apps is with the Jasmine test framework. Jasmine allows you to test your code in the browser. Install To get started, all you need is the jasmine-core package (not jasmine). npm install jasmine-core --save-dev --save-exact Verify To verify that Jasmine is...
You can search for man pages containing a particular string in their description using: man -k <string> For example: man -k unzip Might return: man -k unzip IO::Uncompress::Bunzip2(3pm) - Read bzip2 files/buffers IO::Uncompress::Gunzip(3pm) - Read RFC 1952 files/buffers IO::Uncom...
An example XML file <Sample> <Account> <One number="12"/> <Two number="14"/> </Account> <Account> <One number="14"/> <Two number="16"/> </Account&gt...
The default Angular router allows navigation to and from any route unconditionally. This is not always the desired behavior. In a scenario where a user may conditionally be allowed to navigate to or from a route, a Route Guard may be used to restrict this behavior. If your scenario fits one of the...
File app.routes Protected routes have canActivate binded to Guard import { provideRouter, Router, RouterConfig, CanActivate } from '@angular/router'; //components import { LoginComponent } from './login/login.component'; import { DashboardComponent } from './dashboard/dashboard.component'; ...

Page 93 of 457