Tutorial by Examples: o

if ([object respondsToSelector:@selector(someOptionalMethodInProtocol:)]) { [object someOptionalMethodInProtocol:argument]; }
Move Blue to the beginning of the array: NSMutableArray *myColors = [NSMutableArray arrayWithObjects: @"Red", @"Green", @"Blue", @"Yellow", nil]; NSUInteger fromIndex = 2; NSUInteger toIndex = 0; id blue = [[[self.array objectAtIndex:fromIndex] retain]...
Every authenticated user has a Firebase uid that's unique across all providers and is returned in the result of every authentication method. A good way to store your user's data is to create a node to keep all the users's data and to protect it using your security rules - Database { "use...

or

Evaluates to the first truthy argument if either one of the arguments is truthy. If both arguments are falsey, evaluates to the second argument. x = True y = True z = x or y # z = True x = True y = False z = x or y # z = True x = False y = True z = x or y # z = True x = False y = Fa...

not

It returns the opposite of the following statement: x = True y = not x # y = False x = False y = not x # y = True
Oracle's CONNECT BY functionality provides many useful and nontrivial features that are not built-in when using SQL standard recursive CTEs. This example replicates these features (with a few additions for sake of completeness), using SQL Server syntax. It is most useful for Oracle developers findin...
Deleting files The unlink function deletes a single file and returns whether the operation was successful. $filename = '/path/to/file.txt'; if (file_exists($filename)) { $success = unlink($filename); if (!$success) { throw new Exception("Cannot delete $filename&qu...
An implicit conversion allows the compiler to automatically convert an object of one type to another type. This allows the code to treat an object as an object of another type. case class Foo(i: Int) // without the implicit Foo(40) + 2 // compilation-error (type mismatch) // defines how t...
This example will guide you through setting up a back end serving an a Hello World HTML page. Installing Requirements Order matters for this step! sudo apt-get install apache2 Setting up the HTML Apache files live in /var/www/html/. Lets quickly get there. Make sure you're in your root ...
Checking if session cookies have been created Session name is the name of the cookie used to store sessions. You can use this to detect if cookies for a session have been created for the user: if(isset($_COOKIE[session_name()])) { session_start(); } Note that this method is generally not ...
for typescript 2.x: definitions from DefinitelyTyped are available via @types npm package npm i --save lodash npm i --save-dev @types/lodash but in case if you want use types from other repos then can be used old way: for typescript 1.x: Typings is an npm package that can automatically insta...
Constants can be defined inside classes using a const keyword. class Foo { const BAR_TYPE = "bar"; // reference from inside the class using self:: public function myMethod() { return self::BAR_TYPE; } } // reference from outside the class using <Class...
In Swift, we can exponentiate Doubles with the built-in pow() method: pow(BASE, EXPONENT) In the code below, the base (5) is set to the power of the exponent (2) : let number = pow(5.0, 2.0) // Equals 25
This function lets you iterate over the Cartesian product of a list of iterables. For example, for x, y in itertools.product(xrange(10), xrange(10)): print x, y is equivalent to for x in xrange(10): for y in xrange(10): print x, y Like all python functions that accept a v...
Any data structure that supports __getitem__ can have their nested structure formatted: person = {'first': 'Arthur', 'last': 'Dent'} '{p[first]} {p[last]}'.format(p=person) # 'Arthur Dent' Object attributes can be accessed using getattr(): class Person(object): first = 'Zaphod' la...
Lambda functions in C++ are syntactic sugar that provide a very concise syntax for writing functors. As such, equivalent functionality can be obtained in C++03 (albeit much more verbose) by converting the lambda function into a functor: // Some dummy types: struct T1 {int dummy;}; struct T2 {int ...
There are two main versions of IntelliJ IDEA: the Community edition and the Ultimate edition. The Community edition is free and is not lacking for features in terms of Java SE development. Windows & Linux Download IntelliJ IDEA from the JetBrains website, and follow installation procedures. If...
Introduction: This simple function generates infinite series of numbers. For example... for number in itertools.count(): if number > 20: break print(number) Note that we must break or it prints forever! Output: 0 1 2 3 4 5 6 7 8 9 10 Arguments: count() ta...
There are a couple of ways to delete a column in a DataFrame. import numpy as np import pandas as pd np.random.seed(0) pd.DataFrame(np.random.randn(5, 6), columns=list('ABCDEF')) print(df) # Output: # A B C D E F # 0 -0.895467 0.386902...
This example assumes you know how to test a Flask app using pytest Below is an API that takes a JSON input with integer values a and b e.g. {"a": 1, "b": 2}, adds them up and returns sum a + b in a JSON response e.g. {"sum": 3}. # hello_add.py from flask import Flask...

Page 157 of 1038