Tutorial by Examples: 2

'use strict'; // This is an example of a /api/controllers/HomeController.js module.exports = { // This is the index action and the route is mapped via /config/routes.js index(req, res) { // Return a view without view model data // This typically will return the view defined at /v...
'use strict'; const co = require('co'); module.exports = { // This is the index action and the route is mapped via /config/routes.js index(req, res) { co(function* index() { // Return a view without view model data // This typically will return the view defined at /vie...
import Session Class use yii\web\Session; Create a session $session = Yii::$app->session; $session->open(); // open a session $session->close(); // close a session Store the value in session variable. $session = Yii::$app->session; $session->set('name', 'stack'); OR ...
Padding Remember, members of a struct are usually padded to ensure they are aligned on their natural boundary: struct t { int a, b, c, d; // a is at offset 0, b at 4, c at 8, d at 0ch char e; // e is at 10h short f; // f is at 12h (naturally aligned) lo...
In SQL Server 2016 finally they have introduced Split string function : STRING_SPLIT Parameters: It accepts two parameters String: Is an expression of any character type (i.e. nvarchar, varchar, nchar or char). separator : Is a single character expression of any character type (e.g. nv...
PM2 lets you run your nodejs scripts forever. In the event that your application crashes, PM2 will also restart it for you. Install PM2 globally to manager your nodejs instances npm install pm2 -g Navigate to the directory in which your nodejs script resides and run the following command each t...
Enabling gzip compression can reduce the size of the transferred response by up to 90%, which can significantly reduce the amount of time to download the resource, reduce data usage for the client, and improve the time to first render of your pages. — PageSpeed Insights Compression can be ena...
Fetching resources over the network is both slow and expensive: the download may require multiple roundtrips between the client and server, which delays processing and may block rendering of page content, and also incurs data costs for the visitor. All server responses should specify a caching p...
<?xml version="1.0" encoding="UTF-8"?> <Configuration> <Appenders> <Console name="STDOUT" target="SYSTEM_OUT"> <PatternLayout pattern="%d %-5p [%t] %C{2} %m%n"/> </Console> </Appenders&gt...
If you want to migrate from existing log4j 1.x in your project to log4j 2.x then remove all existing log4j 1.x dependencies and add the following dependency: Log4j 1.x API Bridge Maven Build <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> ...
PhpStorm already ships with a lot of predefined language schemes that are based on common code style guidelines and standards like PSR-2. There is kind of a hidden feature in the code style settings pages where you can import these standards and set them as your current configuration. To do so simp...
Contains the subpattern from the corresponding set of parentheses in the last successful pattern matched, not counting patterns matched in nested blocks that have been exited already, or nil if the last pattern match failed. These variables are all read-only.
This error occurs when tables are not adequately structured to handle the speedy lookup verification of Foreign Key (FK) requirements that the developer is mandating. CREATE TABLE `gtType` ( `type` char(2) NOT NULL, `description` varchar(1000) NOT NULL, PRIMARY KEY (`type`) ) ENGINE=InnoD...
Suggested max len First, I will mention some common strings that are always hex, or otherwise limited to ASCII. For these, you should specify CHARACTER SET ascii (latin1 is ok) so that it will not waste space: UUID CHAR(36) CHARACTER SET ascii -- or pack into BINARY(16) country_code CHAR(2) CHAR...
Yii2 provides efficient ways to retrieve data from the database.Consider an example of a simple employee table having fields emp_id, emp_name and emp_salary. In order to retrieve the employee names and their salaries, we use the query. select emp_name,emp_salary from employee To generate the abo...
// Global.asax.cs calls this method at application start public static void Register(HttpConfiguration config) { // New code config.EnableCors(); } //Enabling CORS for controller after the above registration [EnableCors(origins: "http://example.com", headers: "*"...
public static void Register(HttpConfiguration config) { var corsAttr = new EnableCorsAttribute("http://example.com", "*", "*"); config.EnableCors(corsAttr); }
Android 6 (API23) introduced Doze mode which interferes with AlarmManager. It uses certain maintenance windows to handle alarms, so even if you used setExactAndAllowWhileIdle() you cannot make sure that your alarm fires at the desired point of time. You can turn this behavior off for your app using...
Interface declaration for downloading a file public interface ApiInterface { @GET("movie/now_playing") Call<MovieResponse> getNowPlayingMovies(@Query("api_key") String apiKey, @Query("page") int page); // option 1: a resource relative to your bas...
using System; using System.Linq; using System.Security.Cryptography; namespace YourCryptoNamespace { /// <summary> /// Salted password hashing with PBKDF2-SHA1. /// Compatibility: .NET 3.0 and later. /// </summary> /// <remarks>See http://crackstation.net/h...

Page 5 of 21