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...
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", ...
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...
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>.
...
Autoboxing can come at a substantial memory overhead. For example:
Map<Integer, Integer> square = new HashMap<Integer, Integer>();
for(int i = 256; i < 1024; i++) {
square.put(i, i * i); // Autoboxing of large integers
}
will typically consume substantial amount of memory (...
To change password of current user just type:
sudo passwd
It will ask you to enter your current password:
[sudo] password for <user>:
And then you will be asked to enter new password:
Enter new UNIX password:
And finally you will be asked to re-enter your password:
Retype new UNIX...
It is common within applications to need to have code like this :
a = a + 1
or
a = a * 2
There is an effective shortcut for these in place operations :
a += 1
# and
a *= 2
Any mathematic operator can be used before the '=' character to make an inplace operation :
-= decrement the va...
If you've got multiple implementations of the same interface, Spring can autowire them all into a collection object. I'm going to use an example using a Validator pattern1
Foo Class:
public class Foo {
private String name;
private String emailAddress;
private String errorMessage;...
All of the Bitwise operators (except ~) have their own in place versions
a = 0b001
a &= 0b010
# a = 0b000
a = 0b001
a |= 0b010
# a = 0b011
a = 0b001
a <<= 2
# a = 0b100
a = 0b100
a >>= 2
# a = 0b001
a = 0b101
a ^= 0b011
# a = 0b110
If you have both Python 3 and Python 2 installed, you can specify which version of Python you would like pip to use. This is useful when packages only support Python 2 or 3 or when you wish to test with both.
If you want to install packages for Python 2, run either:
pip install [package]
or:
p...
private static void explicitTaskParallism()
{
Thread.CurrentThread.Name = "Main";
// Create a task and supply a user delegate by using a lambda expression.
Task taskA = new Task(() => Console.WriteLine($"Hello from task {nameof(taskA)}.")...
private static void Main(string[] args)
{
var a = new A();
var b = new B();
//implicit task parallelism
Parallel.Invoke(
() => a.DoSomeWork(),
() => b.DoSomeOtherWork()
);
}