Tutorial by Examples: ar

There are several ways to use a std::vector as a C array (for example, for compatibility with C libraries). This is possible because the elements in a vector are stored contiguously. C++11 std::vector<int> v{ 1, 2, 3 }; int* p = v.data(); In contrast to solutions based on previous C++ st...
This page describes how to use the Meteor command-line tool (for example, when downloading packages, deploying your app, etc) behind a proxy server. Like a lot of other command-line software, the Meteor tool reads the proxy configuration from the HTTP_PROXY and HTTPS_PROXY environment variables (th...
To get the “available” area of the screen (i.e. not including any bars on the edges of the screen, but including window chrome and other windows: var availableArea = { pos: { x: window.screen.availLeft, y: window.screen.availTop }, size: { width: window.scr...
A common pitfall is confusing the equality comparison operators is and ==. a == b compares the value of a and b. a is b will compare the identities of a and b. To illustrate: a = 'Python is fun!' b = 'Python is fun!' a == b # returns True a is b # returns False a = [1, 2, 3, 4, 5] b = a ...
Unlike classes, which are passed by reference, structures are passed through copying: first = "Hello" second = first first += " World!" // first == "Hello World!" // second == "Hello" String is a structure, therefore it's copied on assignment. Structu...
Declare a new variable with var, followed by a name, type, and value: var num: Int = 10 Variables can have their values changed: num = 20 // num now equals 20 Unless they're defined with let: let num: Int = 10 // num cannot change Swift infers the type of variable, so you don't always ha...
Local variables are defined within a function, method, or closure: func printSomething() { let localString = "I'm local!" print(localString) } func printSomethingAgain() { print(localString) // error } Global variables are defined outside of a function, method, or c...
Generally, Math functions that are given non-numeric arguments will return NaN. Math.floor("a") The square root of a negative number returns NaN, because Math.sqrt does not support imaginary or complex numbers. Math.sqrt(-1)
- (void)methodWithBlock:(returnType (^)(paramType1, paramType2, ...))name;
In order to compare the equality of custom classes, you can override == and != by defining __eq__ and __ne__ methods. You can also override __lt__ (<), __le__ (<=), __gt__ (>), and __ge__ (>). Note that you only need to override two comparison methods, and Python can handle the rest (== ...
Output buffering allows you to store any textual content (Text, HTML) in a variable and send to the browser as one piece at the end of your script. By default, php sends your content as it interprets it. <?php // Turn on output buffering ob_start(); // Print some output to the buffer (via...
import multiprocessing def fib(n): """computing the Fibonacci in an inefficient way was chosen to slow down the CPU.""" if n <= 2: return 1 else: return fib(n-1)+fib(n-2) p = multiprocessing.Pool() print(p.map(fib,[38,37,3...
<script src= "http://player.twitch.tv/js/embed/v1.js"></script> <div id="{PLAYER_DIV_ID}"></div> <script type="text/javascript"> var options = { width: 854, height: 480, channel: "{CHANNEL}" ...
In this example, we'll be looking at how to store a credit card using the PayPal vault, then reference that stored credit card to process a credit card transaction for a user. The reason why we would want to use the vault is so that we don't have to store sensitive credit card information on our ow...
To join all of an array's elements into a string, you can use the join method: console.log(["Hello", " ", "world"].join("")); // "Hello world" console.log([1, 800, 555, 1234].join("-")); // "1-800-555-1234" As you can see in ...
You can overload all basic arithmetic operators: + and += - and -= * and *= / and /= & and &= | and |= ^ and ^= >> and >>= << and <<= Overloading for all operators is the same. Scroll down for explanation Overloading outside of class/struct: //operator...
You can overload the 2 unary operators: ++foo and foo++ --foo and foo-- Overloading is the same for both types (++ and --). Scroll down for explanation Overloading outside of class/struct: //Prefix operator ++foo T& operator++(T& lhs) { //Perform addition return lhs; } ...
You can overload all comparison operators: == and != > and < >= and <= The recommended way to overload all those operators is by implementing only 2 operators (== and <) and then using those to define the rest. Scroll down for explanation Overloading outside of class/struct: ...
You can even overload the array subscript operator []. You should always (99.98% of the time) implement 2 versions, a const and a not-const version, because if the object is const, it should not be able to modify the object returned by []. The arguments are passed by const& instead of by value...
To find files/directories with a specific name, relative to pwd: $ find . -name "myFile.txt" ./myFile.txt To find files/directories with a specific extension, use a wildcard: $ find . -name "*.txt" ./myFile.txt ./myFile2.txt To find files/directories matching one of ma...

Page 13 of 218