Tutorial by Examples: am

Code first allows you to create your entities (classes) without using a GUI designer or a .edmx file. It is named Code first, because you can create your models first and Entity framework will create database according to mappings for you automatically. Or you can also use this approach with existin...
Functions can take inputs in form of variables that can be used and assigned inside their own scope. The following function takes two numeric values and returns their sum: function addition (argument1, argument2){ return argument1 + argument2; } console.log(addition(2, 3)); // -> 5 ...
Note: Before deciding which Stream to use please have a look at ParallelStream vs Sequential Stream behavior. When you want to perform Stream operations concurrently, you could use either of these ways. List<String> data = Arrays.asList("One", "Two", "Three", &q...
While using scaffolding is a fast and easy if you are new to Rails or you are creating a new application, later it can be useful just to do it on your own ato avoid the need to go through the scaffold-generated code to slim it down (remove unused parts, etc.). Creating a model can be as simple as c...
Ruby on Rails provides a model generator you can use to create ActiveRecord models. Simply use rails generate model and provide the model name. $ rails g model user In addition to the model file in app/models, the generator will also create: the Test in test/models/user_test.rb the Fixtures ...
A custom component that takes the type of a component as input and creates an instance of that component type inside itself. When the input is updated, the previously added dynamic component is removed and the new one added instead. @Component({ selector: 'dcl-wrapper', template: `<div #...
In your Visual Studio open the Solution Explorer window then right click on your project then choose Manage NuGet Packages from the menu: In the window that opens type EntityFramework in the search box in the top right. Or if you are using Visual Studio 2015 you'll see something like this: ...
You may need to convert a Stream emitting Optional to a Stream of values, emitting only values from existing Optional. (ie: without null value and not dealing with Optional.empty()). Optional<String> op1 = Optional.empty(); Optional<String> op2 = Optional.of("Hello World");...
Add/remove fields in existing tables Create a migration by running: rails generate migration AddTitleToCategories title:string This will create a migration that adds a title column to a categories table: class AddTitleToCategories < ActiveRecord::Migration[5.0] def change add_column...
The checked out file will overwrite not yet commited changes you did in this file. This command will check out the file file.example (which is located in the directory path/to/) and overwrite any changes you might have made to this file. git checkout some-branch path/to/file some-branch can be ...
Example for reading file data_file.csv such as: File: index,header1,header2,header3 1,str_data,12,1.4 3,str_data,22,42.33 4,str_data,2,3.44 2,str_data,43,43.34 7, str_data, 25, 23.32 Code: pd.read_csv('data_file.csv') Output: index header1 header2 header3 0 1 str_dat...
First of all, implement your view holder: implements View.OnClickListener, View.OnLongClickListener Then, register the listeners as follows: itemView.setOnClickListener(this); itemView.setOnLongClickListener(this); Next, override the listeners as follows: @Override public void onClick(Vie...
Properties are members of an object. Each named property is a pair of (name, descriptor). The name is a string that allows access (using the dot notation object.propertyName or the square brackets notation object['propertyName']). The descriptor is a record of fields defining the bevahiour of the pr...
The first step to start Xamarin development on an OS X machine, is to download and install Xamarin Studio Community version from the official website. A few fields need to be filled to download the installer as shown in the picture below. The Xamarin Unified installer takes care of identifying an...
All java Collection<E>s have stream() and parallelStream() methods from which a Stream<E> can be constructed: Collection<String> stringList = new ArrayList<>(); Stream<String> stringStream = stringList.parallelStream(); A Stream<E> can be created from an arra...
Java 8 provides classes called IntSummaryStatistics, DoubleSummaryStatistics and LongSummaryStatistics which give a state object for collecting statistics such as count, min, max, sum, and average. Java SE 8 List<Integer> naturalNumbers = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); IntSu...
In Python 2, an iterator can be traversed by using a method called next on the iterator itself: Python 2.x2.3 g = (i for i in range(0, 3)) g.next() # Yields 0 g.next() # Yields 1 g.next() # Yields 2 In Python 3 the .next method has been renamed to .__next__, acknowledging its “magic” ro...
You can use a column's number (where the leftmost column is '1') to indicate which column to base the sort on, instead of describing the column by its name. Pro: If you think it's likely you might change column names later, doing so won't break this code. Con: This will generally reduce readabilit...
There is already a function sum(). As a result, if we name a variable with the same name sum = 1+3; and if we try to use the function while the variable still exists in the workspace A = rand(2); sum(A,1) we will get the cryptic error: Subscript indices must either be real positive integer...
Step 1 If you already have Django installed, you can skip this step. pip install Django Step 2 Create a new project django-admin startproject hello That will create a folder named hello which will contain the following files: hello/ ├── hello/ │ ├── __init__.py │ ├── settings.py │...

Page 10 of 129