Tutorial by Examples

Classic unit tests test state, but it can be impossible to properly test methods whose behavior depends on other classes through state. We test these methods through interaction tests, which verify that the system under test correctly calls its collaborators. Since the collaborators have their own...
Use the UseCors() extension method on the IApplicationBuilder in the Configure method to apply the CORS policy to all requests. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddCors(); } public void Configure(IApplicationBuilder app) { ...
To enable a certain CORS policy for specific controllers you have to build the policy in the AddCors extension within the ConfigureServices method: services.AddCors(cors => cors.AddPolicy("AllowAll", policy => { policy.AllowAnyOrigin() .AllowAnyMethod() ...
The policy builder allows you to build sophisticated policies. app.UseCors(builder => { builder.WithOrigins("http://localhost:5000", "http://myproductionapp.com") .WithMethods("GET", "POST", "HEAD") .WithHeaders(&quo...
To get SSIS working for a SQL Server 2005 environment Acquire SQL Server 2005 (x86 or 64 bit) images. Mount the second disk and launch the installation wizard "Next" your way through the dialogs until you see see this screen. Under Client Components, ensure Business Intelligence De...
Open the psql command line tool connected to the database where your table is. Then type the following command: \d tablename To get extended information type \d+ tablename If you have forgotten the name of the table, just type \d into psql to obtain a list of tables and views in the current ...
Let's say you have a table called person: CREATE TABLE person ( person_id BIGINT NOT NULL, last_name VARCHAR(255) NOT NULL, first_name VARCHAR(255), age INT NOT NULL, PRIMARY KEY (person_id) ); You can create a new table of people over 30 like this: CREATE TABLE p...
Intellij IDEA attempts to appeal to the wide Java fanbase which uses Eclipse for their development by allowing developers to migrate their Eclipse projects over to an IDEA structure with a few simple clicks! First, start IDEA and click Import Project from the startup window: Then, select your Ec...
Date always have a different format, they can be parsed using a specific parse_dates function. This input.csv: 2016 06 10 20:30:00 foo 2016 07 11 19:45:30 bar 2013 10 12 4:30:00 foo Can be parsed like this : mydateparser = lambda x: pd.datetime.strptime(x, "%Y %m %d %H:%M:%S...
Create a YAML file in the config/ directory, for example: config/neo4j.yml The content of neo4j.yml can be something like the below (for simplicity, default is used for all environments): default: &default host: localhost port: 7474 username: neo4j password: root development: ...
Navigator is React Native's default navigator. A Navigator component manages a stack of route objects, and provides methods for managing that stack. <Navigator ref={(navigator) => { this.navigator = navigator }} initialRoute={{ id: 'route1', title: 'Route 1' }} renderScene={this.ren...
Redux is the most common state management library used with React-Native. The following example demonstrates how to use the fetch API and dispatch changes to your applications state reducer using redux-thunk. export const fetchRecipes = (action) => { return (dispatch, getState) => { f...
Consider entities Customer, Purchase and PurchaseItem as follows: public class Customer { public string Id { get; set } // A unique Id that identifies customer public string Name {get; set; } } public class Purchase { public string Id { get; set } public string CustomerId...
PropertyInfo[] stringProps = typeof (string).GetProperties();//string properties PropertyInfo[] builderProps = typeof(StringBuilder).GetProperties();//stringbuilder properties var query = from s in stringProps join b in builderProps on new { s.Name, s.P...
One of the major benefit of Fourier Transform is its ability to inverse back in to the Time Domain without losing information. Let us consider the same Signal we used in the previous example: A1=10; % Amplitude 1 A2=10; % Amplitude 2 w1=2*pi*0.2; % Angular f...
Let's say we have a simple table called person: CREATE TABLE person ( person_id BIGINT, name VARCHAR(255). age INT, city VARCHAR(255) ); The most basic insert involves inserting all values in the table: INSERT INTO person VALUES (1, 'john doe', 25, 'new york'); If you wa...
You can insert multiple rows in the database at the same time: INSERT INTO person (name, age) VALUES ('john doe', 25), ('jane doe', 20);
You can insert data in a table as the result of a select statement: INSERT INTO person SELECT * FROM tmp_person WHERE age < 30; Note that the projection of the select must match the columns required for the insert. In this case, the tmp_person table has the same columns as person.
Beware that numbers can accidentally be converted to strings or NaN (Not a Number). JavaScript is loosely typed. A variable can contain different data types, and a variable can change its data type: var x = "Hello"; // typeof x is a string x = 5; // changes typeof x to...
GridViews allow commands to be sent from a GridView row. This is useful for passing row-specific information into an event handler as command arguments. To subscribe to a command event: <asp:GridView ID="GridView1" ... OnRowCommand="GridView1_RowCommand"> Buttons are t...

Page 319 of 1336