Tutorial by Examples: c

Sometimes it's necessary to set an array to zero, after the initialization has been done. #include <stdlib.h> /* for EXIT_SUCCESS */ #define ARRLEN (10) int main(void) { int array[ARRLEN]; /* Allocated but not initialised, as not defined static or global. */ size_t i; for(i ...
You can filter what routes are available using constraints. There are several ways to use constraints including: segment constraints, request based constraints advanced constraints For example, a requested based constraint to only allow a specific IP address to access a route: constraints(...
String literals in Swift are delimited with double quotes ("): let greeting = "Hello!" // greeting's type is String Characters can be initialized from string literals, as long as the literal contains only one grapheme cluster: let chr: Character = "H" // valid let chr...
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...
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 ...
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', ...
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...
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 ...
If the function parameter is None, then the identity function will be used: list(filter(None, [1, 0, 2, [], '', 'a'])) # discards 0, [] and '' # Out: [1, 2, 'a'] Python 2.x2.0.1 [i for i in [1, 0, 2, [], '', 'a'] if i] # equivalent list comprehension Python 3.x3.0.0 (i for i in [1, 0...
filter (python 3.x) and ifilter (python 2.x) return a generator so they can be very handy when creating a short-circuit test like or or and: Python 2.x2.0.1 # not recommended in real use but keeps the example short: from itertools import ifilter as filter Python 2.x2.6.1 from future_built...
There is a complementary function for filter in the itertools-module: Python 2.x2.0.1 # not recommended in real use but keeps the example valid for python 2.x and python 3.x from itertools import ifilterfalse as filterfalse Python 3.x3.0.0 from itertools import filterfalse which works...
[0-9] and \d are equivalent patterns (unless your Regex engine is unicode-aware and \d also matches things like ②). They will both match a single digit character so you can use whichever notation you find more readable. Create a string of the pattern you wish to match. If using the \d notation, you...

Page 26 of 826