Tutorial by Examples: on

You will have to inject $filter: angular .module('filters', []) .filter('percentage', function($filter) { return function (input) { return $filter('number')(input * 100) + ' %'; }; });
Consider the case of creating a nested list structure by multiplying: li = [[]] * 3 print(li) # Out: [[], [], []] At first glance we would think we have a list of containing 3 different nested lists. Let's try to append 1 to the first one: li[0].append(1) print(li) # Out: [[1], [1], [1]] ...
{ "name": "your/package", "license": "proprietary", "type": "project", "description": "How to load an external private Composer package.", ... "require": { "your/priv...
Looping via recursion is also possible in Kotlin as in most programming languages. fun factorial(n: Long): Long = if (n == 0) 1 else n * factorial(n - 1) println(factorial(10)) // 3628800 In the example above, the factorial function will be called repeatedly by itself until the given conditio...
The Kotlin Standard Library also provides numerous useful functions to iteratively work upon collections. For example, the map function can be used to transform a list of items. val numbers = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 0) val numberStrings = numbers.map { "Number $it" } One of...
Use Conditionals via (syntax is in [brackets]): when [when:] Task: - name: run if operating system is debian command: echo "I am a Debian Computer" when: ansible_os_family == "Debian" loops [with_items:] loops [with_dicts:] Custom Facts [ wh...
Common use when: ansible_os_family == "CentOS" when: ansible_os_family == "Redhat" when: ansible_os_family == "Darwin" when: ansible_os_family == "Debian" when: ansible_os_family == "Windows" All Lists based on discuss here http://comments...
Basic Usage Use the when condition to control whether a task or role runs or is skipped. This is normally used to change play behavior based on facts from the destination system. Consider this playbook: - hosts: all tasks: - include: Ubuntu.yml when: ansible_os_family == "Ubunt...
Directives can be used to build reusable components. Here is an example of a "user box" component: userBox.js angular.module('simpleDirective', []).directive('userBox', function() { return { scope: { username: '=username', reputation: '=reputation' }, ...
Preliminary Install the Cordova cli tools, if you haven't already. $ npm install -g cordova Navigate to your desired working folder. $ cd /path/to/coding/folder Creating the application Create a new application $ cordova create <appProjectName> <appNameSpace> <appName> For ...
iText for Java Importing the iText jars from the Central Maven Repository is the best way to install iText 7. These simple videos explain how to do this using different IDEs: How to import iText 7 in Eclipse to create a Hello World PDF? How to import iText 7 in Netbeans to create a Hello World ...
Behaviours are a list of functions specifications that another module can implement. They are similar to interfaces in other languages. Here’s an example behaviour: defmodule Parser do @callback parse(String.t) :: any @callback extensions() :: [String.t] end And a module that implements ...
Types can represents various kind of things. It can be a single data, a set of data or a function. In F#, we can group the types into two categories.: F# types: // Functions let a = fun c -> c // Tuples let b = (0, "Foo") // Unit type let c = ignore // Records...
1. Add Devise Gem Open up your Gemfile and add this line gem 'devise' Then run; bundle install 2. Set up devise in your app Run the following command in the terminal rails g devise:install 3. Configure Devise Ensure you have defined default url options in your environments files. Open...
Coming from imperative languages many developers wonder how to write a for-loop that exits early as F# doesn't support break, continue or return. The answer in F# is to use tail-recursion which is a flexible and idiomatic way to iterate while still providing excellent performance. Say we want to ...
The following function is returning another function as its result which can be later assigned to a variable and called: func jediTrainer () -> ((String, Int) -> String) { func train(name: String, times: Int) -> (String) { return "\(name) has been trained in the Force \(times)...
Every function has its own function type, made up of the parameter types and the return type of the function itself. For example the following function: func sum(x: Int, y: Int) -> (result: Int) { return x + y } has a function type of: (Int, Int) -> (Int) Function types can thus be use...
Problem: When you use many labels inside a view, you maybe get a warning: How can we fix this warning? Solution: We calculate and set the priorities in order. The priorities must be different from labels. It means which is important will get higher priority. For example, in my case, I set the ve...
Step 1: In Xcode: File -> New -> File -> Resource -> GPX File -> Next -> Give the GPX file a name(It's Taipei in this example) -> Create Step 2: Edit the GPX file <?xml version="1.0"?> <gpx version="1.1" creator="Xcode"> <wpt ...
Often in R you'll want to know things about an object or variable you're working with. This can be useful when reading someone else's code or even your own, especially when using packages that are new to you. Suppose we create a variable a: a <- matrix(1:9, 3, 3) What data type is this? Yo...

Page 162 of 475