Tutorial by Examples

Content has been moved back to good 'ol Servlets wiki page
Strategy: Strategy is a behavioural pattern, which allows to change the algorithm dynamically from a family of related algorithms. UML of Strategy pattern from Wikipedia : import java.util.*; /* Interface for Strategy */ interface OfferStrategy { public String getName(); public dou...
To add a method to a button, first create an action method: Objective-C -(void) someButtonAction{ NSLog(@"Button is tapped"); } Swift func someButtonAction() { print("Button is tapped") } Now to add this action method to your button, you have to wri...
from scipy.sparse import csr_matrix A = csr_matrix([[1,0,2],[0,3,0]]) >>>A <2x3 sparse matrix of type '<type 'numpy.int64'>' with 3 stored elements in Compressed Sparse Row format> >>> A.todense() matrix([[1, 0, 2], [0, 3, 0]]) >>&g...
Sometimes it is necessary or desirable to place the legend outside the plot. The following code shows how to do it. import matplotlib.pylab as plt fig, ax = plt.subplots(1, 1, figsize=(10,6)) # make the figure with the size 10 x 6 inches fig.suptitle('Example of a Legend Being Placed Outside of...
An Explain infront of a select query shows you how the query will be executed. This way you to see if the query uses an index or if you could optimize your query by adding an index. Example query: explain select * from user join data on user.test = data.fk_user; Example result: id select_type...
The type alias keyword combination gives a new name for a type, but the type keyword in isolation declares a new type. Let's examine one of the most fundamental of these types: Maybe type Maybe a = Just a | Nothing The first thing to note is that the Maybe type is declared with a type ...
There are several sort functions for arrays in php: sort() Sort an array in ascending order by value. $fruits = ['Zitrone', 'Orange', 'Banane', 'Apfel']; sort($fruits); print_r($fruits); results in Array ( [0] => Apfel [1] => Banane [2] => Orange [3] => Zitr...
Fired when component or directive properties have been initialized. (Before those of the child directives) import { Component, OnInit } from '@angular/core'; @Component({ selector: 'so-oninit-component', templateUrl: 'oninit-component.html', styleUrls: ['oninit-component.'] }) ...
Fired when the component or directive instance is destroyed. import { Component, OnDestroy } from '@angular/core'; @Component({ selector: 'so-ondestroy-component', templateUrl: 'ondestroy-component.html', styleUrls: ['ondestroy-component.'] }) class OnDestroyComponent implements...
Fired when one or more of the component or directive properties have been changed. import { Component, OnChanges, Input } from '@angular/core'; @Component({ selector: 'so-onchanges-component', templateUrl: 'onchanges-component.html', styleUrls: ['onchanges-component.'] }) class ...
Fire after the initialization of the content of the component or directive has finished. (Right after OnInit) import { Component, AfterContentInit } from '@angular/core'; @Component({ selector: 'so-aftercontentinit-component', templateUrl: 'aftercontentinit-component.html', styl...
Fire after the view has been fully initialized. (Only available for components) import { Component, AfterContentChecked } from '@angular/core'; @Component({ selector: 'so-aftercontentchecked-component', templateUrl: 'aftercontentchecked-component.html', styleUrls: ['aftercontentc...
Fires after initializing both the component view and any of its child views. This is a useful lifecycle hook for plugins outside of the Angular 2 ecosystem. For example, you could use this method to initialize a jQuery date picker based on the markup that Angular 2 has rendered. import { Component,...
Fire after the check of the view, of the component, has finished. (Only available for components) import { Component, AfterViewChecked } from '@angular/core'; @Component({ selector: 'so-afterviewchecked-component', templateUrl: 'afterviewchecked-component.html', styleUrls: ['afte...
Allows to listen for changes only on specified properties import { Component, DoCheck, Input } from '@angular/core'; @Component({ selector: 'so-docheck-component', templateUrl: 'docheck-component.html', styleUrls: ['docheck-component.'] }) class DoCheckComponent implements DoChe...
CREATE TRIGGER BooksDeleteTrigger ON MyBooksDB.Books AFTER DELETE AS INSERT INTO BooksRecycleBin SELECT * FROM deleted; GO
You can start some slow process in parallel and then collect the results when they are done: Public Sub Main() Dim results = Task.WhenAll(SlowCalculation, AnotherSlowCalculation).Result For Each result In results Console.WriteLine(result) Next End Sub Async Functio...
You can create an IEnumerable of Task by passing AddressOf AsyncMethod to the LINQ Select method and then start and wait all the results with Task.WhenAll If your method has parameters matching the previous LINQ chain call, they will be automatically mapped. Public Sub Main() Dim tasks = Enum...
Import the CoreLocation module in your classes that use CoreLocation functionality. //Swift import CoreLocation //Objective-C #import <CoreLocation/CoreLocation.h>

Page 379 of 1336