Retrofit2 comes with support for multiple pluggable execution mechanisms, one of them is RxJava.
To use retrofit with RxJava you first need to add the Retrofit RxJava adapter to your project:
compile 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
then you need to add the adapter when building yo...
RxJava is handy when making serial request. If you want to use the result from one request to make another you can use the flatMap operator:
api.getRepo(repoId).flatMap(repo -> api.getUser(repo.getOwnerId())
.subscribe(/*do something with the result*/);
You can use the zip operator to make request in parallel and combine the results eg:
Observable.zip(api.getRepo(repoId1), api.getRepo(repoId2), (repo1, repo2) ->
{
//here you can combine the results
}).subscribe(/*do something with the result*/);
Placeholders allow you to feed values into a tensorflow graph. Aditionally They allow you to specify constraints regarding the dimensions and data type of the values being fed in. As such they are useful when creating a neural network to feed new training examples.
The following example declares a ...
To perform elementwise multiplication on tensors, you can use either of the following:
a*b
tf.multiply(a, b)
Here is a full example of elementwise multiplication using both methods.
import tensorflow as tf
import numpy as np
# Build a graph
graph = tf.Graph()
with graph.as_default():
...
In the following example a 2 by 3 tensor is multiplied by a scalar value (2).
# Build a graph
graph = tf.Graph()
with graph.as_default():
# A 2x3 matrix
a = tf.constant(np.array([[ 1, 2, 3],
[10,20,30]]),
dtype=tf.float32)
...
Variable tensors are used when the values require updating within a session. It is the type of tensor that would be used for the weights matrix when creating neural networks, since these values will be updated as the model is being trained.
Declaring a variable tensor can be done using the tf.Varia...
Type synonym families are just type-level functions: they associate parameter types with result types. These come in three different varieties.
Closed type-synonym families
These work much like ordinary value-level Haskell functions: you specify some clauses, mapping certain types to others:
{-# ...
Data families can be used to build datatypes that have different implementations based on their type arguments.
Standalone data families
{-# LANGUAGE TypeFamilies #-}
data family List a
data instance List Char = Nil | Cons Char (List Char)
data instance List () = UnitList Int
In the above de...
The intent attribute of a dummy argument in a subroutine or function declares its intended use. The syntax is either one of
intent(IN)
intent(OUT)
intent(INOUT)
For example, consider this function:
real function f(x)
real, intent(IN) :: x
f = x*x
end function
The intent(IN) specif...
It is possible to create custom routing constraint which can be used inside routes to constraint a parameter to specific values or pattern.
This constrain will match a typical culture/locale pattern, like en-US, de-DE, zh-CHT, zh-Hant.
public class LocaleConstraint : IRouteConstraint
{
pri...
You can use raycasts to check if an ai can walk without falling off the edge of a level.
using UnityEngine;
public class Physics2dRaycast: MonoBehaviour
{
public LayerMask LineOfSightMask;
void FixedUpdate()
{
RaycastHit2D hit = Physics2D.Raycas...
A Bag/ultiset stores each object in the collection together with a count of occurrences. Extra methods on the interface allow multiple copies of an object to be added or removed at once. JDK analog is HashMap<T, Integer>, when values is count of copies this key.
TypeGuavaApache Commons Collec...
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...
Compare operation with collections - Create collections
1. Create List
DescriptionJDKguavags-collectionsCreate empty listnew ArrayList<>()Lists.newArrayList()FastList.newList()Create list from valuesArrays.asList("1", "2", "3")Lists.newArrayList("1", &...
Suppose we want to count how many counties are there in Texas:
var counties = dbContext.States.Single(s => s.Code == "tx").Counties.Count();
The query is correct, but inefficient. States.Single(…) loads a state from the database. Next, Counties loads all 254 counties with all of the...
astype() method changes the dtype of a Series and returns a new Series.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0],
'C': ['1.1.2010', '2.1.2011', '3.1.2011'],
'D': ['1 days', '2 days', '3 days'],
...
select_dtypes method can be used to select columns based on dtype.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'],
'D': [True, False, True]})
In [2]: df
Out[2]:
A B C D
0 1 1.0 a True
1 2 2.0 b False
2...
get_dtype_counts method can be used to see a breakdown of dtypes.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': ['a', 'b', 'c'],
'D': [True, False, True]})
In [2]: df.get_dtype_counts()
Out[2]:
bool 1
float64 1
int64 1
obje...
This example shows how to create a prepared statement with an insert statement with parameters, set values to those parameters and then executing the statement.
Connection connection = ... // connection created earlier
try (PreparedStatement insert = connection.prepareStatement(
"i...