Tutorial by Examples

{ 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...
The ternary operator can be thought of as an inline if statement. It consists of three parts. The operator, and two outcomes. The syntax is as follows: $value = <operator> ? <true value> : <false value> If the operator is evaluated as true, the value in the first block will be ...
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...
The ember data models have a toJSON method that extracts the relevant data: console.log(model.toJSON()); This method uses the JSONSerializer to create the JSON representation. If you want to log the data in a more app-specific way, you can use serialize: model.serialize(); which uses the se...
Ember has a static global method called runInDebug which can run a function meant for debugging. Ember.runInDebug(() => { // this code only runs in dev mode }); In a production build, this method is defined as an empty function (NOP). Uses of this method in Ember itself are stripped from ...
Schedulers are an RxJava abstraction about processing unit. A scheduler can be backed by a Executor service, but you can implement your own scheduler implementation. A Scheduler should meet this requirement : Should process undelayed task sequencially (FIFO order) Task can be delayed A Sched...
import pandas as pd df = pd.DataFrame({'gender': ["male", "female","female"], 'id': [1, 2, 3] }) >>> df gender id 0 male 1 1 female 2 2 female 3 To encode the male to 0 and female to 1: df.loc[df["gender&quot...
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...
Media queries have an optional mediatype parameter. This parameter is placed directly after the @media declaration (@media mediatype), for example: @media print { html { background-color: white; } } The above CSS code will give the DOM HTML element a white background color wh...
import pylab as plt import numpy as np plt.style.use('ggplot') fig = plt.figure(1) ax = plt.gca() # make some testing data x = np.linspace( 0, np.pi, 1000 ) test_f = lambda x: np.sin(x)*3 + np.cos(2*x) # plot the test data ax.plot( x, test_f(x) , lw = 2) # set the axis labels ax...
Ring is de-facto standard API for clojure HTTP applications, similar to Ruby's Rack and Python's WSGI. We're going to use it with http-kit webserver. Create new Leiningen project: lein new app myapp Add http-kit dependency to project.clj: :dependencies [[org.clojure/clojure "1.8.0&quot...
The cubic-bezier function is a transition timing function which is often used for custom and smooth transitions. transition-timing-function: cubic-bezier(0.1, 0.7, 1.0, 0.1); The function takes four parameters: cubic-bezier(P1_x, P1_y, P2_x, P2_y) These parameters will be mapped to points whic...
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 ...
Any predicate function can be used as a spec. Here's a simple example: (clojure.spec/valid? odd? 1) ;;=> true (clojure.spec/valid? odd? 2) ;;=> false the valid? function will take a spec and a value and return true if the value conforms to the spec and false otherwise. One other inte...

Page 286 of 1336