Tutorial by Examples

let view = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 100)) view.backgroundColor = UIColor.orange self.view.addSubview(view) UIView.animate(withDuration: 0.75, delay: 0.5, options: .curveEaseIn, animations: { //This will cause view to go from (0,0) to // (self.view.frame.origi...
public class MyDataExporterToExcell { public static void Main() { GetAndExportExcelFacade facade = new GetAndExportExcelFacade(); facade.Execute(); } } public class GetAndExportExcelFacade { // All services below do something by themselves, determine l...
Suppose you have two lists: A and B, and you need to find the elements that exist in both lists. You can do it by just invoking the method List.retainAll(). Example: public static void main(String[] args) { List<Integer> numbersA = new ArrayList<>(); List<Integer> numb...
The following is a simple example of using the strategy pattern without a context class. There are two implementation strategies which implement the interface and solve the same problem in different ways. Users of the EnglishTranslation class can call the translate method and choose which strategy t...
Assuming the call to your web application's login handler looks like this: https://somepage.com/ajax/login.ashx?username=admin&password=123 Now in login.ashx, you read these values: strUserName = getHttpsRequestParameterString("username"); strPassword = getHttpsRequestParameterSt...
Intent: Define an interface for creating an object, but let sub classes decide which class to instantiate. Factory Method lets a class defer instantiation to sub classes. UML diagram: Product: It defines an interface of the objects the Factory method creates. ConcreteProduct: Implements Produc...
The Builder pattern allows you to create an instance of a class with many optional variables in an easy to read way. Consider the following code: public class Computer { public GraphicsCard graphicsCard; public Monitor[] monitors; public Processor processor; public Memory[] r...
Assume you have a application that administers rooms. Assume further that your application operates on a per client basis (tenant). You have several clients. So your database will contain one table for clients, and one for rooms. Now, every client has N rooms. This should mean that you have...
Another way to hide admin bar is to add if ( !current_user_can( 'manage_options' ) ) { add_filter( 'show_admin_bar', '__return_false' , 1000 ); } The users who don't have privileges to access Settings page, won't be able to see the admin bar.
This example demonstrate how to add caching capabilities to DbProductRepository using Decorator pattern. This approach adheres to SOLID principles because it allows you to add caching without violating Single responsibility principle or Open/closed principle. public interface IProductRepository { ...
Input.acceleration is used to read the accelerometer sensor. It returns Vector3 as a result which contains x,y and z axis values in 3D space. void Update() { Vector3 acclerometerValue = rawAccelValue(); Debug.Log("X: " + acclerometerValue.x + " Y: " + acclerometerV...
You can use the DataExtension mechanism to add extra database fields to an existing DataObject: class MyMemberExtension extends DataExtension { private static $db = [ 'HairColour' => 'Varchar' ]; } And apply the extension: # File: mysite/_config/app.yml Member: exten...
You can add public methods to a DataObject using the extension mechanism, for example: class MyMemberExtension extends DataExtension { public function getHashId() { return sha1($this->owner->ID); } } When applied to the Member class, the example above would return...
BigInteger supports the binary logic operations that are available to Number types as well. As with all operations they are implemented by calling a method. Binary Or: BigInteger val1 = new BigInteger("10"); BigInteger val2 = new BigInteger("9"); val1.or(val2); Output:...
Simple case without duplicate keys Stream<String> characters = Stream.of("A", "B", "C"); Map<Integer, String> map = characters .collect(Collectors.toMap(element -> element.hashCode(), element -> element)); // map = {65=A, 66=B, 67=C} ...
'use strict'; // This is an example of a /api/controllers/HomeController.js module.exports = { // This is the index action and the route is mapped via /config/routes.js index(req, res) { // Return a view without view model data // This typically will return the view defined at /v...
'use strict'; const co = require('co'); module.exports = { // This is the index action and the route is mapped via /config/routes.js index(req, res) { co(function* index() { // Return a view without view model data // This typically will return the view defined at /vie...
Headers may be used to declare globally used read-only resources, like string tables for example. Declare those in a separate header which gets included by any file ("Translation Unit") which wants to make use of them. It's handy to use the same header to declare a related enumeration to ...
Given a basic model: class SpreadsheetCells(Base): __tablename__ = 'spreadsheet_cells' id = Column(Integer, primary_key=True) y_index = Column(Integer) x_index = Column(Integer) You can retrieve an ordered list by chaining the order_by method. query = session.query(Spreads...
SELECT * FROM customers WHERE id IN ( SELECT DISTINCT customer_id FROM orders ); The above will give you all the customers that have orders in the system.

Page 467 of 1336