Tutorial by Examples: ces

The default Angular router allows navigation to and from any route unconditionally. This is not always the desired behavior. In a scenario where a user may conditionally be allowed to navigate to or from a route, a Route Guard may be used to restrict this behavior. If your scenario fits one of the...
For the character entity character(len=5), parameter :: greeting = "Hello" a substring may be referenced with the syntax greeting(2:4) ! "ell" To access a single letter it isn't sufficient to write greeting(1) ! This isn't the letter "H" but greeting(1:...
The complex entity complex, parameter :: x = (1., 4.) has real part 1. and complex part 4.. We can access these individual components as real(x) ! The real component aimag(x) ! The complex component x%re ! The real component y%im ! The complex component The x%.. form is new to F...
The process.env property returns an object containing the user environment. It returns an object like this one : { TERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vi...
Interfaces should be named with nouns or noun phrases, or adjectives that describe behaviour. For example IComponent uses a descriptive noun, ICustomAttributeProvider uses a noun phrase and IPersistable uses an adjective. Interface names should be prefixed with the letter I, to indicate that the ty...
There are multiple ways to create a sequence. You can use functions from the Seq module: // Create an empty generic sequence let emptySeq = Seq.empty // Create an empty int sequence let emptyIntSeq = Seq.empty<int> // Create a sequence with one element let singletonSeq = Seq.s...
A common usecase for the ready() hook is to access the DOM, e.g. to initiate a Javascript plugin, get the dimensions of an element etc. The problem Due to Vue's asynchronous DOM update mechanism, it's not guaranteed that the DOM has been fully updated when the ready() hook is called. This usually ...
The general format for namespaces is: <Company>.(<Product>|<Technology>)[.<Feature>][.<Subnamespace>]. Examples include: Fabrikam.Math Litware.Security Prefixing namespace names with a company name prevents namespaces from different companies from having the sa...
Sometimes you may want to have a lambda expression implementing more than one interface. This is mostly useful with marker interfaces (such as java.io.Serializable) since they don't add abstract methods. For example, you want to create a TreeSet with a custom Comparator and then serialize it and se...
The C-API is the most powerful way to access PostgreSQL and it is surprisingly comfortable. Compilation and linking During compilation, you have to add the PostgreSQL include directory, which can be found with pg_config --includedir, to the include path. You must link with the PostgreSQL client s...
Although people often say Sass as the name of this CSS-preprocessor, they often mean the SCSS-syntax. Sass uses the .sass file extension, while SCSS-Sass uses the .scss extension. They are both referred to as "Sass". Speaking generally, the SCSS-syntax is more commonly used. SCSS looks li...
Use charAt() to get a character at the specified index in the string. var string = "Hello, World!"; console.log( string.charAt(4) ); // "o" Alternatively, because strings can be treated like arrays, use the index via bracket notation. var string = "Hello, World!";...
Sometimes, you don't want to trigger metamethods, but really write or read exactly the given key, without some clever functions wrapped around the access. For this, lua provides you with raw table access methods: -- first, set up a metatable that allows no read/write access local meta = { __i...
import std.stdio; void main() { int[] arr = [1, 2, 3, 4, 5]; auto arr2 = arr[1..$ - 1]; // .. is the slice syntax, $ represents the length of the array writeln(arr2); // [2, 3, 4] arr2[0] = 42; writeln(arr[1]); // 42 }
If you have an instance of a generic type but for some reason don't know the specific type, you might want to determine the generic arguments that were used to create this instance. Let's say someone created an instance of List<T> like that and passes it to a method: var myList = new List&lt...
To process lists, we can simply pattern match on the constructors of the list type: listSum :: [Int] -> Int listSum [] = 0 listSum (x:xs) = x + listSum xs We can match more values by specifying a more elaborate pattern: sumTwoPer :: [Int] -> Int sumTwoPer [] = 0 sumTwoPer (x1...
Access the nth element of a list (zero-based): list = [1 .. 10] firstElement = list !! 0 -- 1 Note that !! is a partial function, so certain inputs produce errors: list !! (-1) -- *** Exception: Prelude.!!: negative index list !! 1000 -- *** Exception: Prelude.!!: inde...
Declare a BluetoothAdapter first. BluetoothAdapter mBluetoothAdapter; Now create a BroadcastReceiver for ACTION_FOUND private final BroadcastReceiver mReceiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); //...
Python 2.x2.7 In Python 2 filter, map and zip built-in functions return a sequence. map and zip always return a list while with filter the return type depends on the type of given parameter: >>> s = filter(lambda x: x.isalpha(), 'a1b2c3') >>> s 'abc' >>> s = map(lambd...
#include <stdio.h> void print_all(FILE *stream) { int c; while ((c = getc(stream)) != EOF) putchar(c); } int main(void) { FILE *stream; /* call netstat command. netstat is available for Windows and Linux */ if ((stream = popen("netstat", &qu...

Page 11 of 40