Tutorial by Examples

Use & to capture functions from other modules. You can use the captured functions directly as function parameters or within anonymous functions. Enum.map(list, fn(x) -> String.capitalize(x) end) Can be made more concise using &: Enum.map(list, &String.capitalize(&1)) Captu...
We often encounter a situation where a property we're trying to extract doesn't exist in the object/array, resulting in a TypeError (while destructuring nested objects) or being set to undefined. While destructuring we can set a default value, which it will fallback to, in case of it not being found...
We are not limited to destructuring an object/array, we can destructure a nested object/array. Nested Object Destructuring var obj = { a: { c: 1, d: 3 }, b: 2 }; var { a: { c: x, d: y }, b: z } = obj; console.log(x, y, z); // 1,3,2 Nested Array ...
\documentclass{article}% or book, report, ... \begin{document} See \cite{citeA} or \cite{citeB} or \cite{citeA, citeB}. \begin{thebibliography}{x} % \bibitem{<biblabel>} <citation> \bibitem{citeA} {\scshape Author, A}, {\itshape A title}, Journal of So-and-So, 2000....
round() tie breaking In Python 2, using round() on a number equally close to two integers will return the one furthest from 0. For example: Python 2.x2.7 round(1.5) # Out: 2.0 round(0.5) # Out: 1.0 round(-0.5) # Out: -1.0 round(-1.5) # Out: -2.0 In Python 3 however, round() will retur...
adduser command adds a user to the system. In order to add a new user type: sudo adduser <user_name> example: sudo adduser tom After typing the above command, you will be prompted to enter details about the new user, such as new password, user Full name, etc. Below is the information ...
using System; namespace TypeConversionApplication { class ExplicitConversion { static void Main(string[] args) { double d = 5673.74; int i; // cast double to int. i = (int)d; Console.WriteLine(i); Cons...
An Interface's function known as a "contract" of functionality. It means that it declares properties and methods but it doesn't implement them. So unlike classes Interfaces: Can't be instantiated Can't have any functionality Can only contain methods * (Properties and Events are metho...
Don't you hate it when interfaces pollute you class with too many members you don't even care about? Well I got a solution! Explicit Implementations public interface IMessageService { void OnMessageRecieve(); void SendMessage(); string Result { get; set; } int Encoding { get; se...
Dictionary<TKey, TValue> is a map. For a given key there can be one value in the dictionary. using System.Collections.Generic; var people = new Dictionary<string, int> { { "John", 30 }, {"Mary", 35}, {"Jack", 40} }; // Reading data Console.Wri...
To register your device for push notifications, add the following code to your AppDelegate file in didFinishLaunchingWithOptions method: Swift func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { // Override point for c...
Strict-Transport-Security: max-age=31536000; includeSubDomains Strict-Transport-Security is a promise to the browser that all future requests to this domain will be secure. For the future time period max-age: All outgoing HTTP requests from the browser will be converted to HTTPS on the client...
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload HSTS is activated only after a successful HTTPS request to the server with a valid certificate. There is still a risk of a first-time user accessing the site, at which point a Man-in-the-Middle attack is possible. To make th...
Note: Before upgrading your Rails app, always make sure to save your code on a version control system, such as Git. To upgrade from Rails 4.2 to Rails 5.0, you must be using Ruby 2.2.2 or newer. After upgrading your Ruby version if required, go to your Gemfile and change the line: gem 'rails', '...
export class MyViewModel { selectedFiles; } <template> <input type="file" files.bind="selectedFiles"> </template>
Strings Array When selecting a value in the select dropdown and providing an array of strings, the selected value will be bound to the select element's value property as a string that we can display using string interpolation. export class MyViewModel { animals = []; favouriteAnimal = nu...
Basic Checkboxes export class MyViewModel { favoriteColors = []; colors = ['Red', 'Yellow', 'Pink', 'Green', 'Purple', 'Orange', 'Blue']; } <template> <label repeat.for="color of colors"> <input type="checkbox" value.bind="color" ch...
Basic Radios export class MyViewModel { favoriteColor = null; colors = ['Red', 'Yellow', 'Pink', 'Green', 'Purple', 'Orange', 'Blue']; } <template> <label repeat.for="color of colors"> <input type="radio" name="colors" value.bind=&q...
Binding to the browser native style attribute using Aurelia. If using string interpolation, you should use the css alias so styling works in Internet Explorer. Style String export class MyViewModel { constructor() { this.styleString = 'color: #F2D3D6; background-color: #333'; } } &l...
When using show.bind the element remains in the page and is either hidden or visible through the use of display:none or display:block behind the scenes. export class MyViewModel { isVisible = false; } <template> <div show.bind="isVisible"><strong>I can be b...

Page 464 of 1336