Tutorial by Examples

import Foundation typealias Result = ([Dog]) -> Void class DoggyService { func deliverDoggies(_ result: @escaping Result) { let firstDoggy = Dog(name: "Alfred", breed: Breed.labrador.rawValue, age: 1) let secondDoggy = Dog(name: "Vinny&quot...
import Foundation class DoggyPresenter { // MARK: - Private fileprivate let dogService: DoggyService weak fileprivate var dogView: DoggyView? init(dogService: DoggyService){ self.dogService = dogService } func attachView(_ attach: Bool, view: DoggyView...
import UIKit class DoggyListViewController: UIViewController, UITableViewDataSource { @IBOutlet weak var emptyView: UIView? @IBOutlet weak var tableView: UITableView? @IBOutlet weak var spinner: UIActivityIndicatorView? fileprivate let dogPresenter = DoggyPresenter(dogSe...
You'll often want to assign something to an object if it is None, indicating it has not been assigned. We'll use aDate. The simplest way to do this is to use the is None test. if aDate is None: aDate=datetime.date.today() (Note that it is more Pythonic to say is None instead of == None.) ...
This is a tutorial to create a hello world example: Used for this example: Android Studio 2.3; To Start use Android Studio to create a new Project with an empty activity. Then we add some simple functionality to the App that we can test: We add a button which when clicks displays "Hello World...
Getting set up to use webdev takes some time, if you're doing anything more than tweaking a bit of text. Here are the initial setup steps: $ mkdir site $ cd site $ git clone [email protected]:dart-lang/site-webdev.git $ source ./scripts/env-set.sh $ ./scripts/install-dart-sdk.sh $ ./s...
Detailed instructions on getting qt5 set up or installed.
This code will prompt you to create the directory with :w, or just do it with :w!: augroup vimrc-auto-mkdir autocmd! autocmd BufWritePre * call s:auto_mkdir(expand('<afile>:p:h'), v:cmdbang) function! s:auto_mkdir(dir, force) if !isdirectory(a:dir) \ && (a:f...
It is very common for C functions to accept pointers to other functions as arguments. Most popular example is setting an action to be executed when a button is clicked in some GUI toolkit library. It is possible to pass Haskell functions as C callbacks. To call this C function: void event_callback...
Yesod project can be created with stack new using following templates: yesod-minimal. Simplest Yesod scaffold possible. yesod-mongo. Uses MongoDB as DB engine. yesod-mysql. Uses MySQL as DB engine. yesod-postgres. Uses PostgreSQL as DB engine. yesod-postgres-fay. Uses PostgreSQL as DB engine....
In this example, we will try to find JavaScript data which containing backgroundColor:'#FFF'. Then, we will change value of backgroundColor '#FFF' ⇨ '#ddd'. This code uses getWholeData() and setWholeData() methods to manipulate JavaScript data. Alternatively, html() method can be used to get data of...
Mutable global items (called static mut, highlighting the inherent contradiction involved in their use) are unsafe because it is difficult for the compiler to ensure they are used appropriately. However, the introduction of mutually exclusive locks around data allows memory-safe mutable globals. Th...
Run-time memory management with Rc can be very useful, but it can also be difficult to wrap one's head around, especially if your code is very complex and a single instance is referenced by tens or even hundreds of other types in many scopes. Writing a Drop trait that includes println!("Droppi...
A SIMPLE TEMPLATE Let’s start with a very simple template that shows our name and our favorite thing: <div> Hello my name is {{name}} and I like {{thing}} quite a lot. </div> {}: RENDERING To render a value, we can use the standard double-curly syntax: My name is {{name}} P...
Background To get the product of a register and a constant and store it in another register, the naïve way is to do this: imul ecx, 3 ; Set ecx to 5 times its previous value imul edx, eax, 5 ; Store 5 times the contend of eax in edx Use lea Multiplications are expensive operation...
Processing provides the method triangle in order to draw a triangle. The code below draws a nearly equilateral triangle of 25 pixels between each defining point. void setup() { size(500, 500); background(0); } void draw() { triangle(0, 0, 25, 0, 12, 12); } The signature of tria...
Detailed instructions on getting cocoa-touch set up or installed.
Start with a properly configured gradle project. In your project-local (not top-level) build.gradle append extensions plugin declaration below your Kotlin plugin, on top-level indentation level. buildscript { ... } apply plugin: "com.android.application" ... apply plugin: &quo...
Assuming we have an activity with an example layout called activity_main.xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layou...
Android extensions also work with multiple Android Product Flavors. For example if we have flavors in build.gradle like so: android { productFlavors { paid { ... } free { ... } } } And for example, only the free flavor has ...

Page 1191 of 1336