Tutorial by Examples: n

Mapping Applying a function to all elements of an array : array_map('strtoupper', $array); Be aware that this is the only method of the list where the callback comes first. Reducing (or folding) Reducing an array to a single value : $sum = array_reduce($numbers, function ($carry, $number) { ...
The following function can be used to get some basic information about the current browser and return it in JSON format. function getBrowserInfo() { var json = "[{", /* The array containing the browser info */ info = [ navigator.userA...
After your service worker is registered, the browser will try to install & later activate the service worker. Install event listener this.addEventListener('install', function(event) { console.log('installed'); }); Caching One can use this install event returned to cache the assets ne...
MySQL offers a number of different numeric types. These can be broken down into GroupTypesInteger TypesINTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINTFixed Point TypesDECIMAL, NUMERICFloating Point TypesFLOAT, DOUBLEBit Value TypeBIT
Minimal unsigned value is always 0. TypeStorage(Bytes)Minimum Value(Signed)Maximum Value(Signed)Maximum Value(Unsigned)TINYINT1-27-12827-112728-1255SMALLINT2-215-32,768215-132,767216-165,535MEDIUMINT3-223-8,388,608223-18,388,607224-116,777,215INT4-231-2,147,483,648231-12,147,483,647232-14,294,967,2...
MySQL's DECIMAL and NUMERIC types store exact numeric data values. It is recommended to use these types to preserve exact precision, such as for money. Decimal These values are stored in binary format. In a column declaration, the precision and scale should be specified Precision represents the n...
FLOAT and DOUBLE represent approximate data types. TypeStoragePrecisionRangeFLOAT4 bytes23 significant bits / ~7 decimal digits10^+/-38DOUBLE8 bytes53 significant bits / ~16 decimal digits10^+/-308 REAL is a synonym for FLOAT. DOUBLE PRECISION is a synonym for DOUBLE. Although MySQL also permits...
WebSocket provides a duplex/bidirectional communication protocol over a single TCP connection. the client opens a connection to a server that is listening for a WebSocket request a client connects to a server using a URI. A server may listen to requests from multiple clients. Server Endpoint...
It's best for readability (and your sanity) to avoid escaping the escapes. That's where raw strings literals come in. (Note that some languages allow delimiters, which are preferred over strings usually. But that's another section.) They usually work the same way as this answer describes: [A] ba...
In most programming languages, in order to have a backslash in a string generated from a string literal, each backslash must be doubled in the string literal. Otherwise, it will be interpreted as an escape for the next character. Unfortunately, any backslash required by the regex must be a literal ...
Character escaping is what allows certain characters (reserved by the regex engine for manipulating searches) to be literally searched for and found in the input string. Escaping depends on context, therefore this example does not cover string or delimiter escaping. Backslashes Saying that backsla...
The easiest and quickest way to encode a Haskell data type to JSON with Aeson is using generics. {-# LANGUAGE DeriveGeneric #-} import GHC.Generics import Data.Text import Data.Aeson import Data.ByteString.Lazy First let us create a data type Person: data Person = Person { firstName :...
Detailed instructions on excel-formula(s). There are many formulas that you can choose from. They are divided up into 7 different categories and are on the FORMULAS tab in Excel. The categories are: Financial Logical Text Date & Time Lookup & Reference Math & trig More Function...
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...

Page 499 of 1088