Tutorial by Examples: sin

For one-time, non-constant requests for a user's physical activity, use the Snapshot API: // Remember to initialize your client as described in the Remarks section Awareness.SnapshotApi.getDetectedActivity(client) .setResultCallback(new ResultCallback<DetectedActivityResult>() { ...
// Remember to intialize your client as described in the Remarks section Awareness.SnapshotApi.getLocation(client) .setResultCallback(new ResultCallback<LocationResult>() { @Override public void onResult(@NonNull LocationResult locationResult) { Location lo...
// Remember to initialize your client as described in the Remarks section Awareness.SnapshotApi.getPlaces(client) .setResultCallback(new ResultCallback<PlacesResult>() { @Override public void onResult(@NonNull PlacesResult placesResult) { List<PlaceLike...
// Remember to initialize your client as described in the Remarks section Awareness.SnapshotApi.getWeather(client) .setResultCallback(new ResultCallback<WeatherResult>() { @Override public void onResult(@NonNull WeatherResult weatherResult) { Weather weathe...
#If Vba7 Then ' It's important to check for Win64 first, ' because Win32 will also return true when Win64 does. #If Win64 Then Declare PtrSafe Function GetFoo64 Lib "exampleLib32" () As LongLong #Else Declare PtrSafe Function GetFoo Lib "exampl...
Variables in Visual Basic are declared using the Dim keyword. For example, this declares a new variable called counter with the data type Integer: Dim counter As Integer A variable declaration can also include an access modifier, such as Public, Protected, Friend, or Private. This works in conju...
# application.rb config.time_zone = 'Eastern Time (US & Canada)' config.active_record.default_timezone = :local
In some cases it is necessary to calculate a variable amount of values on separate Futures. Assume to have a List[Future[Int]], but instead a List[Int] needs to be processed. Then the question is how to turn this instance of List[Future[Int]] into a Future[List[Int]]. For this purpose there is the s...
Keeping a GUI responsive while running a lengthy process requires either some very elaborate "callbacks" to allow the GUI to process its message queue, or the use of (background) (worker) threads. Kicking off any number of threads to do some work usually isn't a problem. The fun starts wh...
Following example shows steps involved in initializing a view from XIB. This is not a complex operation but exact steps need to be followed in order to do it right way first time, avoiding exceptions. How does loadNibNamed Works Main steps are: Create XIB Create class .h and .m Define outlet...
Static server assets must be placed in the private directory. Text files Text files can be accessed by using the Assets.getText(assetPath, [asyncCallback]) method. For example, the following JSON file is named my_text_asset.json and is located in the private directory: { "title": &...
This is very common, you memorize a path to a file or folder, you open up Vim and try to write what you've just memorized, but you are not 100% sure it's correct, so you close the editor and start over. When you want the path completion feature, and you have a file /home/ubuntu/my_folder/my_file a...
Apart from the built-in colormaps defined in the colormaps reference (and their reversed maps, with '_r' appended to their name), custom colormaps can also be defined. The key is the matplotlib.cm module. The below example defines a very simple colormap using cm.register_cmap, containing a single c...
anyNA reports whether any missing values are present; while is.na reports missing values elementwise: vec <- c(1, 2, 3, NA, 5) anyNA(vec) # [1] TRUE is.na(vec) # [1] FALSE FALSE FALSE TRUE FALSE ìs.na returns a logical vector that is coerced to integer values under arithmetic operation...
If you want to detect when your user starts or finishes an activity such as walking, running, or any other activity of the DetectedActivityFence class, you can create a fence for the activity that you want to detect, and get notified when your user starts/finishes this activity. By using a Broadcast...
The symbol NA is for a logical missing value: class(NA) #[1] "logical" This is convenient, since it can easily be coerced to other atomic vector types, and is therefore usually the only NA you will need: x <- c(1, NA, 1) class(x[2]) #[1] "numeric" If you do need a s...
The normal obj.save() method will use the default database, or if a database router is used, it will use the database as specified in db_for_write. You can override it by using: obj.save(using='other_db') obj.delete(using='other_db') Similarly, for reading: MyModel.objects.using('other_db').al...
Ansible uses the concept of roles to better allow modular code and avoid repeating yourself. A role is simply a folder structure that Ansible knows where to load vars files, tasks and handlers from. An example might look something like this: apache/ ├── defaults │   └── main.yml ├── files │   ...
Above I noticed an example to remove items from a List within a Loop and I thought of another example that may come in handy this time using the Iterator interface. This is a demonstration of a trick that might come in handy when dealing with duplicate items in lists that you want to get rid of. N...
The left-shift operator (<<) can be used in flag enum declarations to ensure that each flag has exactly one 1 in binary representation, as flags should. This also helps to improve readability of large enums with plenty of flags in them. [Flags] public enum MyEnum { None = 0, Fl...

Page 51 of 161