Tutorial by Examples: du

Generally, sets are a type of collection which stores unique values. Uniqueness is determined by the equals() and hashCode() methods. Sorting is determined by the type of set. HashSet - Random Sorting Java SE 7 Set<String> set = new HashSet<> (); set.add("Banana"); set.ad...
This design pattern is useful for generating a sequence of asynchronous actions from a list of elements. There are two variants : the "then" reduction, which builds a chain that continues as long as the chain experiences success. the "catch" reduction, which builds a chain t...
It is best practice in any programming language to avoid premature optimization. However, if testing reveals that your code is running too slowly, you may gain some speed by switching off some of the application’s properties while it runs. Add this code to a standard module: Public Sub SpeedUp( _ ...
Laravel allows access to a variety of classes called Services. Some services are available out of the box, but you can create them by yourself. A service can be used in multiple files of the application, like controllers. Let's imagine a Service OurService implementing a getNumber() method returnin...
The Service Container is the main Application object. It can be used as a Dependency Injection Container, and a Registry for the application by defining bindings in the Service Providers Service Providers are classes where we define the way our service classes will be created through the applicatio...
use lib 'includes'; use MySuperCoolModule; use lib 'includes'; adds the relative directory includes/ as another module search path in @INC. So assume that you have a module file MySyperCoolModule.pm inside includes/, which contains: package MySuperCoolModule; If you want, you can group as ma...
SyncAdapter /** * Define a sync adapter for the app. * <p/> * <p>This class is instantiated in {@link SyncService}, which also binds SyncAdapter to the system. * SyncAdapter should only be initialized in SyncService, never anywhere else. * <p/> * <p>The system ca...
To access pixel values in an OpenCV cv::Mat object, you first have to know the type of your matrix. The most common types are: CV_8UC1 for 8-bit 1-channel grayscale images; CV_32FC1 for 32-bit floating point 1-channel grayscale images; CV_8UC3 for 8-bit 3-channel color images; and CV_32FC3 ...
In C, a string is a sequence of characters that is terminated by a null character ('\0'). We can create strings using string literals, which are sequences of characters surrounded by double quotation marks; for example, take the string literal "hello world". String literals are automatica...
It is usually not a good idea to mix signed and unsigned integers in arithmetic operations. For example, what will be output of following example? #include <stdio.h> int main(void) { unsigned int a = 1000; signed int b = -1; if (a > b) puts("a is more than b&quot...
If you want to import a module that doesn't already exist as a built-in module in the Python Standard Library nor as a side-package, you can do this by adding the path to the directory where your module is found to sys.path. This may be useful where multiple python environments exist on a host. im...
import pandas as pd import numpy as np np.random.seed(0) tuples = list(zip(*[['bar', 'bar', 'foo', 'foo', 'qux', 'qux'], ['one', 'two', 'one', 'two','one', 'two']])) idx = pd.MultiIndex.from_tuples(tuples, names=['first', 'second']) df = pd.DataFrame(np.random.randn(6, ...
A callback is a method that gets called at specific moments of an object's lifecycle (right before or after creation, deletion, update, validation, saving or loading from the database). For instance, say you have a listing that expires within 30 days of creation. One way to do that is like this: ...
If need set value 0 to column B, where in column A are duplicated data first create mask by Series.duplicated and then use DataFrame.ix or Series.mask: In [224]: df = pd.DataFrame({'A':[1,2,3,3,2], ...: 'B':[1,7,3,0,8]}) In [225]: mask = df.A.duplicated(keep=False) In...
Use drop_duplicates: In [216]: df = pd.DataFrame({'A':[1,2,3,3,2], ...: 'B':[1,7,3,0,8]}) In [217]: df Out[217]: A B 0 1 1 1 2 7 2 3 3 3 3 0 4 2 8 # keep only the last value In [218]: df.drop_duplicates(subset=['A'], keep='last') Out[218]: ...
The special attribute __name__ of a function, class or module is a string containing its name. import os class C: pass def f(x): x += 2 return x print(f) # <function f at 0x029976B0> print(f.__name__) # f print(C) # <class '__main__.C'> print(C.__name__...
if true do "Will be seen since condition is true." end if false do "Won't be seen since condition is false." else "Will be seen. end unless false do "Will be seen." end unless true do "Won't be seen." else ...
To create a mixin use the @mixin directive. @mixin default-box ($color, $borderColor) { color: $color; border: 1px solid $borderColor; clear: both; display: block; margin: 5px 0; padding: 5px 10px; } You can specify a list of arguments inside a parenthesis followin...
Prefabs are an asset type that allows the storage of a complete GameObject with its components, properties, attached components and serialized property values. There are many scenarios where this is useful, including: Duplicating objects in a scene Sharing a common object across multiple scenes ...
You can alternatively use an Object Declaration that contains the main function for a Kotlin program. package my.program object App { @JvmStatic fun main(args: Array<String>) { println("Hello World") } } The class name that you will run is the name of you...

Page 8 of 47