Tutorial by Examples

Creating a custom directive with isolated scope will separate the scope inside the directive from the outside scope, in order to prevent our directive from accidentally change the data in the parent scope and restricting it from reading private data from the parent scope. To create an isolated scop...
Python has several functions built into the interpreter. If you want to get information of keywords, built-in functions, modules or topics open a Python console and enter: >>> help() You will receive information by entering keywords directly: >>> help(help) or within the u...
Mongoose populate is used to show data for referenced documents from other collections. Lets say we have a Person model that has referenced documents called Address. Person Model var Person = mongoose.model('Person', { fname: String, mname: String, lname: String, address: {typ...
Racket functions can also have keyword arguments, which are specified with a keyword followed by the argument expression. A keyword begins with the characters #:, so a keyword argument looks like #:keyword arg-expr. Within a function call this looks like (function #:keyword arg-expr). > (define ...
Use Kernel.inspect to convert anything to string. iex> Kernel.inspect(1) "1" iex> Kernel.inspect(4.2) "4.2" iex> Kernel.inspect %{pi: 3.14, name: "Yos"} "%{pi: 3.14, name: \"Yos\"}"
iex> my_string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit." iex> String.slice my_string, 6..10 "ipsum"
iex> String.split("Elixir, Antidote, Panacea", ",") ["Elixir", "Antidote", "Panacea"]
If you want to create and send signals in your own code (for example, if you are writing an extension), create a new Signal instance and call send when the subscribers should be notified. Signals are created using a Namespace. from flask import current_app from flask.signals import Namespace n...
First, references will be added to the CLR assemblies that will be used. import clr clr.AddReference('System.Windows.Forms') Next the names we will use are imported. from System.Windows.Forms import Application, Form A class will be created for the Hello World form using Form as its subclas...
Threads are the low level parts of a computing system which command processing occurs. It is supported/provided by CPU/MCU hardware. There are also software methods. The purpose of multi-threading is doing calculations in parallel to each other if possible. Thus the desired result can be obtained in...
This example shows a minimal Mockito test using a mocked ArrayList: import static org.mockito.Mockito.*; import static org.junit.Assert.*; import java.util.ArrayList; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRu...
To modify an XML file with XDocument, you load the file into a variable of type XDocument, modify it in memory, then save it, overwriting the original file. A common mistake is to modify the XML in memory and expect the file on disk to change. Given an XML file: <?xml version="1.0" e...
Components are simply instances that implement the Ashley component class. import com.badlogic.ashley.core.Component; import com.badlogic.ashley.core.ComponentMapper; public class Position implements Component { public static final ComponentMapper<Position> Map = ...
Entity systems are how you perform functional operations on sets of entities. Components should typically not have logic associated with them that involves awareness of data or state of other component instances, as that is the job of an entity system. An entity system can not be registered to mor...
Closures are inline anonymous methods that have the ability to use Parent method variables and other anonymous methods which are defined in the parent's scope. In essence, a closure is a block of code which can be executed at a later time, but which maintains the environment in which it was firs...
The IEnumerable<T> interface has a single method, GetEnumerator(), which returns an IEnumerator<T>. While the yield keyword can be used to directly create an IEnumerable<T>, it can also be used in exactly the same way to create an IEnumerator<T>. The only thing that changes ...
When an object implements the IDisposable interface, it can be created within the using syntax: using (var foo = new Foo()) { // do foo stuff } // when it reaches here foo.Dispose() will get called public class Foo : IDisposable { public void Dispose() { Console.WriteL...
Some languages include a list data structure. Common Lisp, and other languages in the Lisp family, make extensive use of lists (and the name Lisp is based on the idea of a LISt Processor). However, Common Lisp doesn't actually include a primitive list datatype. Instead, lists exist by convention....
A cons cell, also known as a dotted pair (because of its printed representation), is simply a pair of two objects. A cons cell is created by the function cons, and elements in the pair are extracted using the functions car and cdr. (cons "a" 4) For instance, this returns a pair whose ...
Following is most basic expression tree that is created by lambda. Expression<Func<int, bool>> lambda = num => num == 42; To create expression trees 'by hand', one should use Expression class. Expression above would be equivalent to: ParameterExpression parameter = Expression.Pa...

Page 328 of 1336