Tutorial by Examples

Git will usually open an editor (like vim or emacs) when you run git commit. Pass the -m option to specify a message from the command line: git commit -m "Commit message here" Your commit message can go over multiple lines: git commit -m "Commit 'subject line' message here Mor...
var a = Math.random(); Sample value of a: 0.21322848065742162 Math.random() returns a random number between 0 (inclusive) and 1 (exclusive) function getRandom() { return Math.random(); } To use Math.random() to get a number from an arbitrary range (not [0,1)) use this function to get a...
The attribute tools:ignore can be used in xml files to dismiss lint warnings. BUT dismissing lint warnings with this technique is most of the time the wrong way to proceed. A lint warning must be understood and fixed... it can be ignored if and only if you have a full understanding of it's meaning...
Interactive Shell The Bash shell is commonly used interactively: It lets you enter and edit commands, then executes them when you press the Return key. Many Unix-based and Unix-like operating systems use Bash as their default shell (notably Linux and macOS). The terminal automatically enters an int...
git rm filename To delete the file from git without removing it from disk, use the --cached flag git rm --cached filename
Extensions can contain functions and computed/constant get variables. They are in the format extension ExtensionOf { //new functions and get-variables } To reference the instance of the extended object, self can be used, just as it could be used To create an extension of String that adds ...
Extensions can contain convenience initializers. For example, a failable initializer for Int that accepts a NSString: extension Int { init?(_ string: NSString) { self.init(string as String) // delegate to the existing Int.init(String) initializer } } let str1: NSString = &qu...
This example show how to subscribe, and once that is successful, publishing a message to that channel. It also demonstrates the full set of parameters that can be included in the subscribe's message callback function. pubnub = PUBNUB({ publish_key : 'your_pub_key', ...
# No import needed # No import required... from functools import reduce # ... but it can be loaded from the functools module from functools import reduce # mandatory reduce reduces an iterable by applying a function repeatedly on the next element of an iterable and the cumulative resul...
def multiply(s1, s2): print('{arg1} * {arg2} = {res}'.format(arg1=s1, arg2=s2, res=s1*s2)) return s1 * s2 asequence = [1, 2, 3] Given an initializer the function is started by applying it to the...
import operator reduce(operator.mul, [10, 5, -3]) # Out: -150
reduce will not terminate the iteration before the iterable has been completly iterated over so it can be used to create a non short-circuit any() or all() function: import operator # non short-circuit "all" reduce(operator.and_, [False, True, True, True]) # = False # non short-circu...
# First falsy element or last element if all are truthy: reduce(lambda i, j: i and j, [100, [], 20, 10]) # = [] reduce(lambda i, j: i and j, [100, 50, 20, 10]) # = 10 # First truthy element or last element if all falsy: reduce(lambda i, j: i or j, [100, [], 20, 0]) # = 100 reduce(la...
Publish and Subscribe for Node.JS Install PubNub NPM Package. npm install [email protected] Example Publish Subscribe with Node.JS var channel = "hello_world"; var pubnub = require("pubnub")({ publish_key : "your_pub_key" , subscribe_key : "your_sub_ke...
When it comes to adding/removing channels to/from your channel groups, you need to have must have the manage permission for those channel groups. But you should never grant clients the permission to manage the channel groups that they will subscribe to. If they did, then they could add any channel t...
Presence works by sending messages when a user joins, leaves, or times out from a particular channel. You can listen for these messages to track who is in a channel, and how long since they did anything. First, make sure each user as a UUID. Set this when you initialize PubNub: var pubnub = PUBNUB...
In addition to .done, .fail and .always promise callbacks, which are triggered based on whether the request was successful or not, there is the option to trigger a function when a specific HTTP Status Code is returned from the server. This can be done using the statusCode parameter. $.ajax({ t...
For example, you can take the absolute value of each element: list(map(abs, (1, -1, 2, -2, 3, -3))) # the call to `list` is unnecessary in 2.x # Out: [1, 1, 2, 2, 3, 3] Anonymous function also support for mapping a list: map(lambda x:x*2, [1, 2, 3, 4, 5]) # Out: [2, 4, 6, 8, 10] or convert...
For example calculating the average of each i-th element of multiple iterables: def average(*args): return float(sum(args)) / len(args) # cast to float - only mandatory for python 2.x measurement1 = [100, 111, 99, 97] measurement2 = [102, 117, 91, 102] measurement3 = [104, 102, 95, 101] ...
Xcode projects are used to organize source files, library dependencies, and other resources, as well as the settings and steps required to build the project's products. Workspaces are groups of projects and other files. Create a project You can create a New Project (⇧⌘N) from a number of built-in ...

Page 42 of 1336