Tutorial by Examples: api

var express = require('express'); var cors = require('cors'); // Use cors module for enable Cross-origin resource sharing var app = express(); app.use(cors()); // for all routes var port = process.env.PORT || 8080; app.get('/', function(req, res) { var info = { 'string_value...
On the profile view, show the profile fields of a user or group in a list as well as the address fields on a google map. - # app/views/profiles/show.html.haml %h1 Contact Information .profile_fields = render @profile_fields .google_map{data: address_fields: @address_fields.to_json } The ap...
rvest is a package for web scraping and parsing by Hadley Wickham inspired by Python's Beautiful Soup. It leverages Hadley's xml2 package's libxml2 bindings for HTML parsing. As part of the tidyverse, rvest is piped. It uses xml2::read_html to scrape the HTML of a webpage, which can then be sub...
This multimap allows duplicate key-value pairs. JDK analogs are HashMap<K, List>, HashMap<K, Set> and so on. Key's orderValue's orderDuplicateAnalog keyAnalog valueGuavaApacheEclipse (GS) CollectionsJDKnot definedInsertion-orderyesHashMapArrayListArrayListMultimapMultiValueMapFastListMu...
To create a new Rails 5 API, open a terminal and run the following command: rails new app_name --api The following file structure will be created: create create README.rdoc create Rakefile create config.ru create .gitignore create Gemfile create app create app/as...
Types & Protocols Type and protocol names should start with an uppercase letter. Example: protocol Collection {} struct String {} class UIView {} struct Int {} enum Color {} Everything else... Variables, constants, functions and enumeration cases should start with a lowercase letter. Exa...
MySQL does not provide a built-in way to create pivot queries. However, these can be created using prepared statements. Assume the table tbl_values: IdNameGroupValue1PeteA102PeteB203JohnA10 Request: Create a query that shows the sum of Value for each Name; the Group must be column header and Name...
Basic HTTP calls don't provide code-reusability, however. And they can get confused with all the other features you're trying to implement. For those reasons, it's common to implement an API wrapper. Foo = { identify: function(input){ return Http.get('http://foo.net/api/identify/' + input...
After creating an API wrapper, it's likely that you may want to create an Atmosphere package to redistribute it and share it between applications. The files of your package will probably look something like this. packages/foo-api-wrapper/package.js packages/foo-api-wrapper/readme.md packages/foo-...
At this point, you're still building your package, so you'll need to add the package to your application: meteor add myaccount:foo And eventually publish it to Atmosphere: meteor publish myaccount:foo
Now that we have all those pieces put together, you should now be able to make calls like the following from within your app: Foo.identify('John'); Foo.record_action_on_item('view', "HackerNews'); Obviously you'll want to adjust function names, arguments, urls, and the like, to create the ...
<style name="AppTheme" parent="Theme.AppCompat"> <item name="android:colorEdgeEffect">@color/my_color</item> </style>
5.0 The ripple animation is shown when user presses clickable views. You can use the same ripple color used by your app assigning the ?android:colorControlHighlight in your views. You can customize this color by changing the android:colorControlHighlight attribute in your theme: This effect colo...
This attribute can change the background of the Status Bar icons (at the top of the screen) to white. <style name="AppTheme" parent="Theme.AppCompat"> <item name="android:windowLightStatusBar">true</item> </style>
The navigation bar (at the bottom of the screen) can be transparent. Here is the way to achieve it. <style name="AppTheme" parent="Theme.AppCompat"> <item name="android:windowTranslucentNavigation">true</item> </style> The Status Bar (t...
5.0 This attribute is used to change the navigation bar (one, that contain Back, Home Recent button). Usually it is black, however it's color can be changed. <style name="AppTheme" parent="Theme.AppCompat"> <item name="android:navigationBarColor">@col...
This example assumes that you have experience in creating Rails applications. To create an API-only app in Rails 5, run rails new name-of-app --api Add active_model_serializers in Gemfile gem 'active_model_serializers' install bundle in terminal bundle install Set the ActiveModelSeriali...
//iterates over a map, getting the key and value at once var map = hashMapOf(1 to "foo", 2 to "bar", 3 to "baz") for ((key, value) in map) { println("Map[$key] = $value") }
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 initialize your client as described in the Remarks section Awareness.SnapshotApi.getHeadphoneState(client) .setResultCallback(new ResultCallback<HeadphoneStateResult>() { @Override public void onResult(@NonNull HeadphoneStateResult headphoneStateResult) {...

Page 3 of 12