Tutorial by Examples: c

String#replace can have a function as its second argument so you can provide a replacement based on some logic. "Some string Some".replace(/Some/g, (match, startIndex, wholeString) => { if(startIndex == 0){ return 'Start'; } else { return 'End'; } }); // will retur...
#include <SoftwareSerial.h> // its always better to change the default tx and rx as the may interfere with other process in future. // configure tx , rx by defualt they will be 0 and 1 in arduino UNO SoftwareSerial blue(3,2); void setup() { // preferred baud rate/data transfer rat...
app.js angular.module('myApp', ['ui.router']) .controller('controllerOne', function() { this.message = 'Hello world from Controller One!'; }) .controller('controllerTwo', function() { this.message = 'Hello world from Controller Two!'; }) .controller('controllerThree', funct...
The command prompt comes pre-installed on all Windows NT, Windows CE, OS/2 and eComStation operating systems, and exists as cmd.exe, typically located in C:\Windows\system32\cmd.exe On Windows 7 the fastest ways to open the command prompt are: Press , type "cmd" and then press Enter....
In iTunesConnect, select the app which you want to add an IAP to. Click on features and you will see this: Click the plus. You will then need to select which type of IAP you want to make. Then you will need to fill out all of the information for your IAP. If you have any trouble you can cons...
nginx consists of modules which are controlled by directives specified in the configuration file. Simple Directives A simple directive consists of the name and parameters separated by spaces and ends with a semicolon (;). Block Directive A block directive has the same structure as a simple direc...
Syntax Syntax: log_format name string ...; Syntax: access_log path [format [buffer=size] [gzip[=level]] [flush=time] [if=condition]]; access_log off; Using them together log_format compression '$remote_addr - $remote_user [$time_local] ' '"$request" $status...
Stream is especially useful when you want to run multiple operations on a collection. This is because Stream is lazy and only does one iteration (whereas Enum would do multiple iterations, for example). numbers = 1..100 |> Stream.map(fn(x) -> x * 2 end) |> Stream.filter(fn(x) -> rem(x...
You can add your own validations adding new classes inheriting from ActiveModel::Validator or from ActiveModel::EachValidator. Both methods are similar but they work in a slightly different ways: ActiveModel::Validator and validates_with Implement the validate method which takes a record as an arg...
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...
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: ...
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...
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...

Page 197 of 826