In Elixir, a common practice is to use anonymous functions. Creating an anonymous function is simple:
iex(1)> my_func = fn x -> x * 2 end
#Function<6.52032458/1 in :erl_eval.expr/5>
The general syntax is:
fn args -> output end
For readability, you may put parenthesis around t...
A metatable defines a set of operations which alter the behaviour of a lua object. A metatable is just an ordinary table, which is used in a special way.
local meta = { } -- create a table for use as metatable
-- a metatable can change the behaviour of many things
-- here we modify the 'tostrin...
To create a background session
// Swift:
let mySessionID = "com.example.bgSession"
let bgSessionConfig = NSURLSessionConfiguration.backgroundSessionConfigurationWithIdentifier(mySessionID)
let session = NSURLSession(configuration: bgSessionConfig)
// add tasks here
//...
Ionic Framework
A Cross-platform mobile application development framework using Angular JS and Front End web technologies.
Official website: http://ionicframework.com/
Documentation: http://ionicframework.com/docs/
Installation and Setup
Installation
Ionic required NPM(Node Package Manager) an...
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
/**
* A very simple Swing example.
*/
public class SwingExample {
/**
* The number of times the ...
You can create a new branch and switch to it using
git checkout -b AP-57
After you use git checkout to create a new branch, you will need to set that upstream origin to push to using
git push --set-upstream origin AP-57
After that, you can use git push while you are on that branch.
By default a property is a primary key if a property on a class is named “ID” (not case sensitive), or the class name followed by "ID". If the type of the primary key property is numeric or GUID it will be configured as an identity column. Simple Example:
public class Room
{
// Pri...
The Windows API documentation for functions taking one or more string as argument will usually look like this:
BOOL WINAPI CopyFile(
_In_ LPCTSTR lpExistingFileName,
_In_ LPCTSTR lpNewFileName,
_In_ BOOL bFailIfExists
);
The datatype for the two string parameters is made of several ...
[^0-9a-zA-Z]
This will match all characters that are neither numbers nor letters (alphanumerical characters). If the underscore character _ is also to be negated, the expression can be shortened to:
[^\w]
Or:
\W
In the following sentences:
Hi, what's up?
I can't wait for 2017!...
[^0-9]
This will match all characters that are not ASCII digits.
If Unicode digits are also to be negated, the following expression can be used, depending on your flavor/language settings:
[^\d]
This can be shortened to:
\D
You may need to enable Unicode character properties support expl...
To get version 5394 use:
svn co --revision r5394 https://svn.example.com/svn/MyRepo/MyProject/trunk
Or the shorter version:
svn co -r 5394 https://svn.example.com/svn/MyRepo/MyProject/trunk
Or by using pegged revisions:
svn co https://svn.example.com/svn/MyRepo/MyProject/trunk@5394
If al...
Dynamic scoping means that variable lookups occur in the scope where a function is called, not where it is defined.
$ x=3
$ func1 () { echo "in func1: $x"; }
$ func2 () { local x=9; func1; }
$ func2
in func1: 9
$ func1
in func1: 3
In a lexically scoped language, func1 would alway...
Suppose we want to receive a function as a parameter, we can do it like this:
function foo(otherFunc: Function): void {
...
}
If we want to receive a constructor as a parameter:
function foo(constructorFunc: { new() }) {
new constructorFunc();
}
function foo(constructorWithParams...
pip doesn't current contain a flag to allow a user to update all outdated packages in one shot. However, this can be accomplished by piping commands together in a Linux environment:
pip list --outdated --local | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip install -U
This command takes all pa...
pip doesn't current contain a flag to allow a user to update all outdated packages in one shot. However, this can be accomplished by piping commands together in a Windows environment:
for /F "delims= " %i in ('pip list --outdated --local') do pip install -U %i
This command takes all pa...
pip assists in creating requirements.txt files by providing the freeze option.
pip freeze > requirements.txt
This will save a list of all packages and their version installed on the system to a file named requirements.txt in the current folder.
pip assists in creating requirements.txt files by providing the freeze option.
pip freeze --local > requirements.txt
The --local parameter will only output a list of packages and versions that are installed locally to a virtualenv. Global packages will not be listed.
Class composition allows explicit relations between objects. In this example, people live in cities that belong to countries. Composition allows people to access the number of all people living in their country:
class Country(object):
def __init__(self):
self.cities=[]
...