Tutorial by Examples

Swift myButton.titleLabel?.font = UIFont(name: "YourFontName", size: 20) Objective C myButton.titleLabel.font = [UIFont fontWithName:@"YourFontName" size:20];

Map

Returns the changed object, but the original object remains as it was. For example: arr = [1, 2, 3] arr.map { |i| i + 1 } # => [2, 3, 4] arr # => [1, 2, 3] map! changes the original object: arr = [1, 2, 3] arr.map! { |i| i + 1 } # => [2, 3, 4] arr # => [2, 3, 4] Note: you can...
Here is an example of a method that would live inside a SQLiteOpenHelper subclass. It uses the searchTerm String to filter the results, iterates through the Cursor's contents, and returns those contents in a List of Product Objects. First, define the Product POJO class that will be the container f...
Arrays You can iterate over nested arrays: [[1, 2], [3, 4]].each { |(a, b)| p "a: #{ a }", "b: #{ b }" } The following syntax is allowed too: [[1, 2], [3, 4]].each { |a, b| "a: #{ a }", "b: #{ b }" } Will produce: "a: 1" "b: 2" ...
CSS can be applied in multiple places: inline (Node.setStyle) in a stylesheet to a Scene as user agent stylesheet (not demonstrated here) as "normal" stylesheet for the Scene to a Node This allows to change styleable properties of Nodes. The following example demonst...
The simplest example of an injection in an Angular app - injecting $scope to an Angular Controller: angular.module('myModule', []) .controller('myController', ['$scope', function($scope) { $scope.members = ['Alice', 'Bob']; ... }]) The above illustrates an injection of a $scope into ...
There is also an option to dynamically request components. You can do it using the $injector service: myModule.controller('myController', ['$injector', function($injector) { var myService = $injector.get('myService'); }]); Note: while this method could be used to prevent the circular depen...
Equivalently, we can use the $inject property annotation to achieve the same as above: var MyController = function($scope) { // ... } MyController.$inject = ['$scope']; myModule.controller('MyController', MyController);
To start with multi-threading, you would need the pthreads-ext for php, which can be installed by $ pecl install pthreads and adding the entry to php.ini. A simple example: <?php // NOTE: Code uses PHP7 semantics. class MyThread extends Thread { /** * @var string * Variab...
Any class can configure its own string formatting syntax through the __format__ method. A type in the standard Python library that makes handy use of this is the datetime type, where one can use strftime-like formatting codes directly within str.format: >>> from datetime import datetime &...
The Switch statement works very well with Enum values enum CarModel { case Standard, Fast, VeryFast } let car = CarModel.Standard switch car { case .Standard: print("Standard") case .Fast: print("Fast") case .VeryFast: print("VeryFast") } Since we ...
Ansible can be installed on CentOS or other Red Hat based systems. Firstly you should install the prerequisites: sudo yum -y update sudo yum -y install gcc libffi-devel openssl-devel python-pip python-devel then install Ansible with pip: sudo pip install ansible I can recommend for you to u...
From MSDN: An enumeration type (also named an enumeration or an enum) provides an efficient way to define a set of named integral constants that may be assigned to a variable. Essentially, an enum is a type that only allows a set of finite options, and each option corresponds to a number. By d...
.' is the correct way to transpose a vector or matrix in MATLAB. ' is the correct way to take the complex conjugate transpose (a.k.a. Hermitian conjugate) of a vector or matrix in MATLAB. Note that for the transpose .', there is a period in front of the apostrophe. This is in keeping with the ...
To duplicate a table, simply do the following: CREATE TABLE newtable LIKE oldtable; INSERT newtable SELECT * FROM oldtable;
WITH CTE (StudentId, Fname, LName, DOB, RowCnt) as ( SELECT StudentId, FirstName, LastName, DateOfBirth as DOB, SUM(1) OVER (Partition By FirstName, LastName, DateOfBirth) as RowCnt FROM tblStudent ) SELECT * from CTE where RowCnt > 1 ORDER BY DOB, LName This example uses a Common Table ...
Match any: Must match at least one string. In this example the product type must be either 'electronics', 'books', or 'video'. SELECT * FROM purchase_table WHERE product_type LIKE ANY ('electronics', 'books', 'video'); Match all (must meet all requirements). In this example both 'united...
CREATE SEQUENCE orders_seq START WITH 1000 INCREMENT BY 1; Creates a sequence with a starting value of 1000 which is incremented by 1.
a reference to seq_name.NEXTVAL is used to get the next value in a sequence. A single statement can only generate a single sequence value. If there are multiple references to NEXTVAL in a statement, they use will use the same generated number. NEXTVAL can be used for INSERTS INSERT INTO Orders (Or...
// Calculate what day of the week is 36 days from this instant. System.DateTime today = System.DateTime.Now; System.TimeSpan duration = new System.TimeSpan(36, 0, 0, 0); System.DateTime answer = today.Add(duration); System.Console.WriteLine("{0:dddd}", answer);

Page 193 of 1336