Tutorial by Examples

You should not save props into state. It is considered an anti-pattern. For example: export default class MyComponent extends React.Component { constructor() { super(); this.state = { url: '' } this.onChange = this.onChange.bind(this); ...
Sometimes you doesn't want to simply replace or remove the string. Sometimes you want to extract and process matches. Here an example of how you manipulate matches. What is a match ? When a compatible substring is found for the entire regex in the string, the exec command produce a match. A match i...
Some regex engines (such as .NET) can handle context-free expressions, and will work it out. But that's not the case for most standard engines. And even if they do, you'll end up having a complex hard-to-read expression, whereas using a parsing library could make the job easier. How to find all p...
Because Regular Expressions can do a lot, it is tempting to use them for the simplest operations. But using a regex engine has a cost in memory and processor usage: you need to compile the expression, store the automaton in memory, initialize it and then feed it with the string to run it. And there...
If you want to extract something from a webpage (or any representation/programming language), a regex is the wrong tool for the task. You should instead use your language's libraries to achieve the task. If you want to read HTML, or XML, or JSON, just use the library that parses it properly and ser...
UserType belongs to many Users <-> Users have one UserType One way navigation property with required public class UserType { public int UserTypeId {get; set;} } public class User { public int UserId {get; set;} public int UserTypeId {get; set;} public virtual UserType...
EntityFramewok Fluent API is a powerful and elegant way of mapping your code-first domain models to underlying database. This also can be used with code-first with existing database. You have two options when using Fluent API: you can directly map your models on OnModelCreating method or you can cre...
By using the .HasKey() method, a property can be explicitly configured as primary key of the entity. using System.Data.Entity; // .. public class PersonContext : DbContext { // .. protected override void OnModelCreating(DbModelBuilder modelBuilder) { // .. ...
By using the .HasKey() method, a set of properties can be explicitly configured as the composite primary key of the entity. using System.Data.Entity; // .. public class PersonContext : DbContext { // .. protected override void OnModelCreating(DbModelBuilder modelBuilder) {...
By using the .HasMaxLength() method, the maximum character count can be configured for a property. using System.Data.Entity; // .. public class PersonContext : DbContext { // .. protected override void OnModelCreating(DbModelBuilder modelBuilder) { // .. ...
By using the .IsRequired() method, properties can be specified as mandatory, which means that the column will have a NOT NULL constraint. using System.Data.Entity; // .. public class PersonContext : DbContext { // .. protected override void OnModelCreating(DbModelBuilder modelB...
There are two common ways to encode a POST request body: URL encoding (application/x-www-form-urlencoded) and form data (multipart/form-data). Much of the code is similar, but the way you construct the body data is different. Sending a request using URL encoding Be it you have a server for your s...
GSP supports the usage of <% %> scriptlet blocks to embed Groovy code (this is discouraged): <html> <body> <% out << "Hello GSP!" %> </body> </html> You can also use the <%= %> syntax to output values, like in JSP: <htm...
In GSP the <%= %> syntax is rarely used due to the support for GSP expressions. A GSP expression is similar to a JSP EL expression or a Groovy GString and takes the form ${expr}: <html> <body> Hello ${params.name} </body> </html> However, unlike JSP EL ...
A pointer is declared much like any other variable, except an asterisk (*) is placed between the type and the name of the variable to denote it is a pointer. int *pointer; /* inside a function, pointer is uninitialized and doesn't point to any valid object yet */ To declare two pointer variables...
Media queries are not supported at all in IE8 and below. A Javascript based workaround To add support for IE8, you could use one of several JS solutions. For example, Respond can be added to add media query support for IE8 only with the following code : <!--[if lt IE 9]> <script ...
The POSIX and C standards explicitly state that using fflush on an input stream is undefined behavior. The fflush is defined only for output streams. #include <stdio.h> int main() { int i; char input[4096]; scanf("%i", &i); fflush(stdin); // <-- unde...
"The :nth-child(an+b) CSS pseudo-class matches an element that has an+b-1 siblings before it in the document tree, for a given positive or zero value for n" - MDN :nth-child pseudo-selector12345678910:first-child✔:nth-child(3)✔:nth-child(n+3)✔✔✔✔✔✔✔✔:nth-child(3n)✔✔✔:nth-child(3n+1)...
Using alarm, user can schedule SIGALARM signal to be raised after specified interval. In case user did not blocked, ignored or specified explicit signal handler for this signal, the default action for this signal will be performed on arrival. Per specification default action for SIGALARM is to termi...
You can install Sinatra as a global gem: gem install sinatra or add it to a project's Gemfile # in Gemfile: gem 'sinatra' and run bundle install.

Page 613 of 1336