Tutorial by Examples: sin

// This iterates through a range between two DateTimes // with the given iterator (any of the Add methods) DateTime start = new DateTime(2016, 01, 01); DateTime until = new DateTime(2016, 02, 01); // NOTICE: As the add methods return a new DateTime you have // to overwrite dt in the itera...
Example: Invoke different constructors by passing relevant parameters import java.lang.reflect.*; class NewInstanceWithReflection{ public NewInstanceWithReflection(){ System.out.println("Default constructor"); } public NewInstanceWithReflection( String a){ ...
You should already have your backend REST resource available. On the client side (GWT) your need to Add RestyGwt dependency to your project with maven <dependency> <groupId>org.fusesource.restygwt</groupId> <artifactId>restygwt</artifactId> <vers...
To check if a required gem is installed, from within your code, you can use the following (using nokogiri as an example): begin found_gem = Gem::Specification.find_by_name('nokogiri') require 'nokogiri' .... <the rest of your code> rescue Gem::LoadError end However, this can ...
Quite often it's necessary to send/upload a file to a remote server, for example, an image, video, audio or a backup of the application database to a remote private server. Assuming the server is expecting a POST request with the content, here's a simple example of how to complete this task in Andro...
You can get the current location and local places of user by using the Google Places API. Ar first, you should call the PlaceDetectionApi.getCurrentPlace() method in order to retrieve local business or other places. This method returns a PlaceLikelihoodBuffer object which contains a list of PlaceLi...
All integers or pointers can be used in an expression that is interpreted as "truth value". int main(int argc, char* argv[]) { if (argc % 4) { puts("arguments number is not divisible by 4"); } else { puts("argument number is divisible by 4"); } ... ...
Melting: The basics Melting is used to transform data from wide to long format. Starting with a wide data set: DT = data.table(ID = letters[1:3], Age = 20:22, OB_A = 1:3, OB_B = 4:6, OB_C = 7:9) We can melt our data using the melt function in data.table. This returns another data.table in long...
To use the library, you must include it as a dependency with the following line: compile project(':[library root directory]')
You can check if a value is included in an array using the inclusion: helper. The :in option and its alias, :within show the set of acceptable values. class Country < ApplicationRecord validates :continent, inclusion: { in: %w(Africa Antartica Asia Australia ...
For queries, Realm provides the realmResults.asObservable() method. Observing results is only possible on looper threads (typically the UI thread). For this to work, your configuration must contain the following realmConfiguration = new RealmConfiguration.Builder(context) // ...
In order to dynamically decide what beans to inject, we can use FactoryBeans. These are classes which implement the factory method pattern, providing instances of beans for the container. They are recognized by Spring and can be used transparently, without need to know that the bean comes from a fac...
Some languages have a native structure for sets. To make a set in Go, it's best practice to use a map from the value type of the set to an empty struct (map[Type]struct{}). For example, with strings: // To initialize a set of strings: greetings := map[string]struct{}{ "hi": {}, ...
Quantitative data is often read in as strings that must be converted to numeric types before processing. The types of all list items can be converted with either a List Comprehension or the map() function. # Convert a list of strings to integers. items = ["1","2","3",...
Reflection is useful but fragile. Consider this: let mi = typeof<System.String>.GetMethod "StartsWith" The problems with this kind of code are: The code doesn't work because there are several overloads of String.StartsWith Even if there wouldn't be any overloads right now la...
Using the Library Database, we try to find the last book added to the database for each author. For this simple example we assume an always incrementing Id for each record added. SELECT MostRecentBook.Name, MostRecentBook.Title FROM ( SELECT Authors.Name, Books.Title, ...
Comments are used to explain code when the basic code itself isn't clear. Python ignores comments, and so will not execute code in there, or raise syntax errors for plain english sentences. Single-line comments begin with the hash character (#) and are terminated by the end of line. Single lin...
Transact-SQL supports two forms of comment writing. Comments are ignored by the database engine, and are meant for people to read. Comments are preceded by -- and are ignored until a new line is encountered: -- This is a comment SELECT * FROM MyTable -- This is another comment WHERE Id = 1; ...
1 - Include the CoreLocation.framework in your project; this is accomplished by clicking on: root directory -> build phases -> Link Binary With Libraries Click on the (+) button, look for CoreLocation.framework and click add. 2- Modify the info.plist file to ask for permission to use user...
In this example, a private static instance of the class is declared at its beginning. The value of a static field is shared between instances, so if a new instance of this class gets created the if will find a reference to the first Singleton object, destroying the new instance (or its game object)...

Page 65 of 161