Tutorial by Examples: v

A Broadcast receiver is an Android component which allows you to register for system or application events. A receiver can be registered via the AndroidManifest.xml file or dynamically via the Context.registerReceiver() method. public class MyReceiver extends BroadcastReceiver { @Override ...
Unlike C++ in C# you can call a virtual method from class constructor (OK, you can also in C++ but behavior at first is surprising). For example: abstract class Base { protected Base() { _obj = CreateAnother(); } protected virtual AnotherBase CreateAnother() { ...
To add a method to a button, first create an action method: Objective-C -(void)someButtonAction:(id)sender { // sender is the object that was tapped, in this case its the button. NSLog(@"Button is tapped"); } Swift func someButtonAction() { print("Button is tapped...
First try use pivot: import pandas as pd import numpy as np df = pd.DataFrame({'Name':['Mary', 'Josh','Jon','Lucy', 'Jane', 'Sue'], 'Age':[34, 37, 29, 40, 29, 31], 'City':['Boston','New York', 'Chicago', 'Los Angeles', 'Chicago', 'Boston'], ...
import pandas as pd import numpy as np df = pd.DataFrame({'Name':['Mary', 'Jon','Lucy', 'Jane', 'Sue', 'Mary', 'Lucy'], 'Age':[35, 37, 40, 29, 31, 26, 28], 'City':['Boston', 'Chicago', 'Los Angeles', 'Chicago', 'Boston', 'Boston', 'Chicago'], ...
Subclass UINavigationController and then override these methods: In Objective-C: - (UIStatusBarStyle)preferredStatusBarStyle { return UIStatusBarStyleLightContent; } In Swift: override func preferredStatusBarStyle() -> UIStatusBarStyle { return .lightContent } Alternativel...
Note that you cannot overload a function based on its return type. For example: // WRONG CODE std::string getValue() { return "hello"; } int getValue() { return 0; } int x = getValue(); This will cause a compilation error as the compiler will not be able to work out wh...
TRUNCATE TABLE Employee; Using truncate table is often better then using DELETE TABLE as it ignores all the indexes and triggers and just removes everything. Delete table is a row based operation this means that each row is deleted. Truncate table is a data page operation the entire data page is...
To move data you first insert it into the target, then delete whatever you inserted from the source table. This is not a normal SQL operation but it may be enlightening What did you insert? Normally in databases you need to have one or more columns that you can use to uniquely identify rows so we w...
public class Dog extends RealmObject { public String name; public int age; } Dog dog = new Dog(); dog.name = "Rex"; dog.age = 1; Realm realm = Realm.getDefaultInstance(); realm.executeTransaction(new Realm.Transaction() { @Override public void execute(Realm re...
@interface Dog : RLMObject @property NSString *name; @property NSInteger age; @end @implementation Dog @end Dog *dog = [Dog new]; dog.name = @"Rex"; dog.age = 1; RLMRealm *realm = [RLMRealm defaultRealm]; [realm transactionWithBlock:^{ [realm addObject:dog]; }]; RLMR...
class Dog {} Dog.schema = { name: 'Dog', properties: { name: 'string', age: 'int', } }; let realm = new Realm(); realm.write(() => { realm.create('Dog', {name: 'Rex', age: 1}); }); let pups = realm.objects('Dog').filtered('age > 2');
You can use the CONVERT function to cast a datetime datatype to a formatted string. SELECT GETDATE() AS [Result] -- 2016-07-21 07:56:10.927 You can also use some built-in codes to convert into a specific format. Here are the options built into SQL Server: DECLARE @convert_code INT = 100 -- See ...
@Provider public class CORSResponseFilter implements ContainerResponseFilter { public void filter( ContainerRequestContext requestContext, ContainerResponseContext responseContext ) throws IOException { MultivaluedMap<String, Object> headers = responseCo...
A class designed to be inherited-from is called a Base class. Care should be taken with the special member functions of such a class. A class designed to be used polymorphically at run-time (through a pointer to the base class) should declare the destructor virtual. This allows the derived parts of...
Bear in mind that declaring a destructor inhibits the compiler from generating implicit move constructors and move assignment operators. If you declare a destructor, remember to also add appropriate definitions for the move operations. Furthermore, declaring move operations will suppress the genera...
To add a header to a recyclerview with a gridlayout, first the adapter needs to be told that the header view is the first position - rather than the standard cell used for the content. Next, the layout manager must be told that the first position should have a span equal to the *span count of the e...
The core concepts of RxJava are its Observables and Subscribers. An Observable emits objects, while a Subscriber consumes them. Observable Observable is a class that implements the reactive design pattern. These Observables provide methods that allow consumers to subscribe to event changes. The ev...
angular.module("app") .service("counterService", function(){ var service = { number: 0 }; return service; });
angular.module("app") // Custom services are injected just like Angular's built-in services .controller("step1Controller", ['counterService', '$scope', function(counterService, $scope) { counterService.number++; // bind to...

Page 37 of 296