Tutorial by Examples: amp

/** * The buildscript {} block is where you configure the repositories and * dependencies for Gradle itself--meaning, you should not include dependencies * for your modules here. For example, this block includes the Android plugin for * Gradle as a dependency because it provides the addition...
/** * The first line in the build configuration applies the Android plugin for * Gradle to this build and makes the android {} block available to specify * Android-specific build options. */ apply plugin: 'com.android.application' /** * The android {} block is where you configure all...
import pandas as pd import numpy as np np.random.seed(0) rng = pd.date_range('2015-02-24', periods=10, freq='T') df = pd.DataFrame({'Val' : np.random.randn(len(rng))}, index=rng) print (df) Val 2015-02-24 00:00:00 1.764052 2015-02-24 00:01:00 0.400157 2015-02...
In Python you can compare a single element using two binary operators--one on either side: if 3.14 < x < 3.142: print("x is near pi") In many (most?) programming languages, this would be evaluated in a way contrary to regular math: (3.14 < x) < 3.142, but in Python it ...
Factories can be used in conjunction with Inversion of Control (IoC) libraries too. The typical use case for such a factory is when we want to create an object based on parameters that are not known until run-time (such as the current User). In these cases it can be sometimes be difficult (if no...
If your project has no external dependency and has foo.ml as its main entry point, you can compile a bytecode version with ocamlbuild foo.byte To get a native executable, run ocamlbuild foo.native
Table Item The following class contains 2 properties a name (String) and the size (double). Both properties are wrapped in JavaFX properties to allow the TableView to observe changes. import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleDoubleProperty; import javafx.be...
The following example encrypts data by using a hybrid cryptosystem consisting of AES GCM and OAEP, using their default parameter sizes and an AES key size of 128 bits. OAEP is less vulnerable to padding oracle attacks than PKCS#1 v1.5 padding. GCM is also protected against padding oracle attacks. ...
You can use the following extension method for comparing the contents of two IList< T > instances of the same type. By default the items are compared based on their order within the list and the items themselves, passing false to the isOrdered parameter will compare only the items themselves ...
To document a function, it is often helpful to have an example script which uses your function. The publish function in Matlab can then be used to generate a help file with embedded pictures, code, links, etc. The syntax for documenting your code can be found here. The Function This function uses ...
Folds are (higher-order) functions used with sequences of elements. They collapse seq<'a> into 'b where 'b is any type (possibly still 'a). This is a bit abstract so lets get into concrete practical examples. Calculating the sum of all numbers In this example, 'a is an int. We have a list of...
The datetime module can convert a POSIX timestamp to a ITC datetime object. The Epoch is January 1st, 1970 midnight. import time from datetime import datetime seconds_since_epoch=time.time() #1469182681.709 utc_date=datetime.utcfromtimestamp(seconds_since_epoch) #datetime.datetime(2016, 7, 2...
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...
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...
superman-directive.js angular.module('myApp', []) .directive('superman', function() { return { // restricts how the directive can be used restrict: 'E', templateUrl: 'superman-template.html', controller: function() { this.message = "I'm superman!&qu...
<p ng-bind="message"></p> This 'message' has to be attached to the current elements controller's scope. $scope.message = "Hello World"; At a later point of time , even if the message model is updated , that updated value is reflected in the HTML element. When ...
Template <div id="example"> a={{ a }}, b={{ b }} </div> JavaScript var vm = new Vue({ el: '#example', data: { a: 1 }, computed: { // a computed getter b: function () { // `this` points to the vm instance return this.a + 1 }...
The minimum required to use Webpack is the following command: webpack ./src/index.js ./dist/bundle.js // this is equivalent to: webpack source-file destination-file Web pack will take the source file, compile to the output destination and resolve any dependencies in the source files.
This example shows setting up a small application with 3 routes, each with it's own view and controller, using the controllerAs syntax. We configure our router at the angular .config function We inject $routeProvider into .config We define our route names at the .when method with a route defini...
Hibernate (and embedded H2 DB) <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/...

Page 6 of 46