Tutorial by Examples

Attributes are name-value pairs associated with an element. They are represented by values in single or double quotes inside the opening element tag, or the empty element tag if it is an empty element. <document> <anElement foo="bar" abc='xyz'><!-- some content -->&l...
we can annotate fields with @BindView and a view ID for Butter Knife to find and automatically cast the corresponding view in our layout. Binding Views Binding Views in Activity class ExampleActivity extends Activity { @BindView(R.id.title) TextView title; @BindView(R.id.subtitle) TextView ...
CLP(FD) constraints (Finite Domains) implement arithmetic over integers. They are available in all serious Prolog implementations. There are two major use cases of CLP(FD) constraints: Declarative integer arithmetic Solving combinatorial problems such as planning, scheduling and allocation task...
The predicate dif/2 is a pure predicate: It can be used in all directions and with all instantiation patterns, always meaning that its two arguments are different.
List doesn't support "random access", which means it takes more work to get, say, the fifth element from the list than the first element, and as a result there's no List.get nth list function. One has to go all the way from the beginning (1 -> 2 -> 3 -> 4 -> 5). If you need ra...
Packages are bundles of classes. Every class must be declared within a package using the package statement. The package statement is followed by the name of your package, or followed by nothing in the case of adding classes to the top-level package. Sub-packages are created using dot (.) delimitatio...
Arrays can have more than one dimension. The following example creates a two-dimensional array of ten rows and ten columns: int[,] arr = new int[10, 10]; An array of three dimensions: int[,,] arr = new int[10, 10, 10]; You can also initialize the array upon declaration: int[,] arr = new int...
Import the numpy module to use any part of it. import numpy as np Most examples will use np as shorthand for numpy. Assume "np" means "numpy" in code examples. x = np.array([1,2,3,4])
This makes image masked to the shape of the letters of the label: Objective-C self.maskImage.layer.mask = self.maskLabel.layer; self.maskImage.layer.masksToBounds = YES; Swift 3 maskImageView.mask = maskLabel maskImageView.masksToBounds = true Here is the result:
A comment is marked by an apostrophe ('), and ignored when the code executes. Comments help explain your code to future readers, including yourself. Since all lines starting with a comment are ignored, they can also be used to prevent code from executing (while you debug or refactor). Placing an ap...
Sub RemComments() Rem Comments start with "Rem" (VBA will change any alternate casing to "Rem") Rem is an abbreviation of Remark, and similar to DOS syntax Rem Is a legacy approach to adding comments, and apostrophes should be preferred Rem Comments CANNOT appear af...
Usually authentication&authorization processes are performed by built-in cookie and token supports in .net MVC. But if you decide to do it yourself with Session you can use below logic for both page requests and ajax requests. public class SessionControl : ActionFilterAttribute { public o...
This is an example of how to use the generic type TFood inside Eat method on the class Animal public interface IFood { void EatenBy(Animal animal); } public class Grass: IFood { public void EatenBy(Animal animal) { Console.WriteLine("Grass was eaten by: {0}",...
arr = np.arange(10).reshape(2, 5) Using .transpose method: arr.transpose() # Out: # array([[0, 5], # [1, 6], # [2, 7], # [3, 8], # [4, 9]]) .T method: arr.T # Out: # array([[0, 5], # [1, 6], # [2, 7], # ...
arr = np.arange(7) print(arr) # Out: array([0, 1, 2, 3, 4, 5, 6]) Comparison with a scalar returns a boolean array: arr > 4 # Out: array([False, False, False, False, False, True, True], dtype=bool) This array can be used in indexing to select only the numbers greater than 4: arr[arr&...
The numpy.reshape (same as numpy.ndarray.reshape) method returns an array of the same total size, but in a new shape: print(np.arange(10).reshape((2, 5))) # [[0 1 2 3 4] # [5 6 7 8 9]] It returns a new array, and doesn't operate in place: a = np.arange(12) a.reshape((3, 4)) print(a) # ...
Along with classic way of route definition MVC WEB API 2 and then MVC 5 frameworks introduced Attribute routing: public class RouteConfig { public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // This...
Currying, according to Wikipedia, is the technique of translating the evaluation of a function that takes multiple arguments into evaluating a sequence of functions. Concretely, in terms of scala types, in the context of a function that take two arguments, (has arity 2) it is the conversion o...
# Generates 5 random numbers from a uniform distribution [0, 1) np.random.rand(5) # Out: array([ 0.4071833 , 0.069167 , 0.69742877, 0.45354268, 0.7220556 ])
Using random.seed: np.random.seed(0) np.random.rand(5) # Out: array([ 0.5488135 , 0.71518937, 0.60276338, 0.54488318, 0.4236548 ]) By creating a random number generator object: prng = np.random.RandomState(0) prng.rand(5) # Out: array([ 0.5488135 , 0.71518937, 0.60276338, 0.54488318,...

Page 253 of 1336