Tutorial by Examples: c

Circe provides compile-time derived codecs for en/decode json into case classes. A simple example looks like this: import io.circe._ import io.circe.generic.auto._ import io.circe.parser._ import io.circe.syntax._ case class User(id: Long, name: String) val user = User(1, "John Doe&qu...
The code below implements a very simple complex number type for which the underlying field is automatically promoted, following the language's type promotion rules, under application of the four basic operators (+, -, *, and /) with a member of a different field (be it another complex<T> or so...
To take a photo, first we need to declare required permissions in AndroidManifest.xml. We need two permissions: Camera - to open camera app. If attribute required is set to true you will not be able to install this app if you don't have hardware camera. WRITE_EXTERNAL_STORAGE - This permission i...
You will have to inject $filter: angular .module('filters', []) .filter('percentage', function($filter) { return function (input) { return $filter('number')(input * 100) + ' %'; }; });
By default, a filter has a single parameter: the variable it is applied on. But you can pass more parameter to the function: angular .module('app', []) .controller('MyController', function($scope) { $scope.example = 0.098152; }) .filter('percentage', function($filter) { return...
ng-include allows you to delegate the control of one part of the page to a specific controller. You may want to do this because the complexity of that component is becoming such that you want to encapsulate all the logic in a dedicated controller. An example is: <div ng-include src=&q...
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]] ...
In Highcharts, there is an array containing the default colors for the chart's series. When all colors are used, new colors are pulled from the start again. Defaults colors for version 4.x and 5.x are: colors: [ '#7cb5ec', '#434348', '#90ed7d', '#f7a35c', '#8085e9', ...
BrandVersions SupportedInternet Explorer6.0 +Firefox2.0 +Chrome1.0 +Safari4.0 +Opera9.0 +iOS (Safari)3.0 +Android Browser2.0 + Highcharts supports jQuery version 1.6+ for legacy browsers, and 2.0+ for modern browsers.
iex> [1, 2, 3] -- [1, 3] [2] -- removes the first occurrence of an item on the left list for each item on the right.
{ "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...
- name: copy ssl key/cert/ssl_include files copy: src=files/ssl/{{ item }} dest=/etc/apache2/ssl/ with_items: - g_chain.crt - server.crt - server.key - ssl_vhost.inc
A simple query that selects all users from the #__users table with a username that matches John $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('*'); $query->from('#__users'); $query->where('username = '. $db->q('John')); $db->setQuery($query); ...
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' }, ...
The angular.isObject return true if and only if the argument passed to it is an object, this function will also return true for an Array and will return false for null even though typeof null is object . angular.isObject(value) This function is useful for type checking when you need a defined ...

Page 292 of 826