Tutorial by Examples

Python classes support properties, which look like regular object variables, but with the possibility of attaching custom behavior and documentation. class MyClass(object): def __init__(self): self._my_string = "" @property def string(self): "&...
import { Pipe, PipeTransform } from '@angular/core'; import { DatePipe } from '@angular/common' @Pipe({name: 'ifDate'}) export class IfDate implements PipeTransform { private datePipe: DatePipe = new DatePipe(); transform(value: any, pattern?:string) : any { if (typeof value === ...
Custom sigils can be made by creating a method sigil_X where X is the letter you want to use (this can only be a single letter). defmodule Sigils do def sigil_j(string, options) do # Split on the letter p, or do something more useful String.split string, "p" end # Use t...
Ensure you have the most recent Node.js LTS installed. If you use Homebrew this can be done with brew install node4-lts. Open Terminal and type npm install -g nativescript. If you get an EACCES error, use sudo npm install -g nativescript. In the command prompt type ruby -e "$(curl -fsSL htt...
Ensure you have the latest nodeJS LTS installed Open command prompt and type $ npm install -g nativescript In the command prompt type $ @powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://www.nativescript.org/setup/win'))" - ...
Visual Studio Code is an open-source and feature-rich code editor from Microsoft. To set it up it for NativeScript development, open the Command Palette (F1 or ⌘+Shift+P) and type ext install NativeScript. Once the NativeScript extension is installed, the debugger should allow you to set breakpoint...
In the following example, the greet function inside Greeter module is run in a separate process: defmodule Greeter do def greet do IO.puts "Hello programmer!" end end iex> spawn(Greeter, :greet, []) Hello #PID<0.122.0> Here #PID<0.122.0> is the ...
Named Functions defmodule Math do # one way def add(a, b) do a + b end # another way def subtract(a, b), do: a - b end iex> Math.add(2, 3) 5 :ok iex> Math.subtract(5, 2) 3 :ok Private Functions defmodule Math do def sum(a, b) do a...
Elixir matches a function call to its body based on the value of its arguments. defmodule Math do def factorial(0): do: 1 def factorial(n): do: n * factorial(n - 1) end Here, factorial of positive numbers matches the second clause, while factorial(0) matches the first. (ignoring negat...
Guard clauses enables us to check the arguments before executing the function. Guard clauses are usually preferred to if and cond due to their readability, and to make a certain optimization technique easier for the compiler. The first function definition where all guards match is executed. Here is...
You can pass default parameters to any named function using the syntax: param \\ value: defmodule Example do def func(p1, p2 \\ 2) do IO.inspect [p1, p2] end end Example.func("a") # => ["a", 2] Example.func("b", 4) # => ["b", ...
C99 Type Declaration A structure with at least one member may additionally contain a single array member of unspecified length at the end of the structure. This is called a flexible array member: struct ex1 { size_t foo; int flex[]; }; struct ex2_header { int foo; char...
Enable USB Debugging on your device and from command line type adb devices. If everything is OK, the response should be: List of devices attached 1234567890 device Where 1234567890 is the device's id. If multiple devices are connected, you should see all of them: List of devices at...
The following example declares a piece of code to be written in Racket, and then prints the string Hello, world. #lang racket "Hello, world!" Racket code can either be run directly from the command line or on the DrRacket IDE. Typing racket on the command line will start a REPL, and t...
Named vector can be created in several ways. With c: xc <- c('a' = 5, 'b' = 6, 'c' = 7, 'd' = 8) which results in: > xc a b c d 5 6 7 8 with list: xl <- list('a' = 5, 'b' = 6, 'c' = 7, 'd' = 8) which results in: > xl $a [1] 5 $b [1] 6 $c [1] 7 $d [1] 8 Wi...
Binding is the process of assigning an object to an identifier or variable name. Early binding (also known as static binding) is when an object declared in Excel is of a specific object type, such as a Worksheet or Workbook. Late binding occurs when general object associations are made, such as the ...
NOW() + INTERVAL 1 DAY -- This time tomorrow CURDATE() - INTERVAL 4 DAY -- Midnight 4 mornings ago Show the mysql questions stored that were asked 3 to 10 hours ago (180 to 600 minutes ago): SELECT qId,askDate,minuteDiff FROM ( SELECT qId,askDate, TIMESTAMPDIFF(MINUTE,askDate,no...
To clone a specific branch of a repository, type --branch <branch name> before the repository url: git clone --branch <branch name> <url> [directory] To use the shorthand option for --branch, type -b. This command downloads entire repository and checks out <branch name>. ...
An Option is a discriminated union with two cases, None or Some. type Option<'T> = Some of 'T | None
A sequence is a series of elements that can be enumerated. It is an alias of System.Collections.Generic.IEnumerable and lazy. It stores a series of elements of the same type (can be any value or object, even another sequence). Functions from the Seq.module can be used to operate on it. Here is a s...

Page 414 of 1336