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...
You can use the if binding to determine whether or not the child elements of the node should be created.
<div class="product-info">
<h2> Product1 </h2>
<img src="../products/product1.jpg"/>
<span data-bind="if:featured">
...
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...
Types of columns can be checked by .dtypes atrribute of DataFrames.
In [1]: df = pd.DataFrame({'A': [1, 2, 3], 'B': [1.0, 2.0, 3.0], 'C': [True, False, True]})
In [2]: df
Out[2]:
A B C
0 1 1.0 True
1 2 2.0 False
2 3 3.0 True
In [3]: df.dtypes
Out[3]:
A int64
...
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...
In PaaS sites such as Heroku, it is usual to receive the database information as a single URL environment variable, instead of several parameters (host, port, user, password...).
There is a module, dj_database_url which automatically extracts the DATABASE_URL environment variable to a Python dictio...
To connect to MySQL you need to use the MySQL Connector/J driver. You can download it from http://dev.mysql.com/downloads/connector/j/ or you can use Maven:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version...
When you create a function in TypeScript you can specify the data type of the function's arguments and the data type for the return value
Example:
function sum(x: number, y: number): number {
return x + y;
}
Here the syntax x: number, y: number means that the function can accept two argum...
Example:
function hello(name: string): string {
return `Hello ${name}!`;
}
Here the syntax name: string means that the function can accept one name argument and this argument can only be string and (...): string { means that the return value can only be a string
Usage:
hello('StackOverfl...
You can start the mongo shell by running the following command inside your Meteor project:
meteor mongo
Please note: Starting the server-side database console only works while Meteor is running the application locally.
After that, you can list all collections by executing the following command...
Android Studio can configure Kotlin automatically in an Android project.
Install the plugin
To install the Kotlin plugin, go to File > Settings > Editor > Plugins > Install JetBrains Plugin... > Kotlin > Install, then restart Android Studio when prompted.
Configure a project
Cr...
TeX formulae can be inserted in the plot using the rc function
import matplotlib.pyplot as plt
plt.rc(usetex = True)
or accessing the rcParams:
import matplotlib.pyplot as plt
params = {'tex.usetex': True}
plt.rcParams.update(params)
TeX uses the backslash \ for commands and symbols, whic...