The simplest case is just preforming a task for a fixed known number of times. Say we want to display the numbers between 1 to n, we can write:
n = 5;
for k = 1:n
display(k)
end
The loop will execute the inner statement(s), everything between the for and the end, for n times (5 in this ex...
The right-hand side of the assignment in a for loop can be any row vector. The left-hand side of the assignment can be any valid variable name. The for loop assigns a different element of this vector to the variable each run.
other_row_vector = [4, 3, 5, 1, 2];
for any_name = other_row_vector
...
If the right-hand side of the assignment is a matrix, then in each iteration the variable is assigned subsequent columns of this matrix.
some_matrix = [1, 2, 3; 4, 5, 6]; % 2 by 3 matrix
for some_column = some_matrix
display(some_column)
end
(The row vector version is a normal case of thi...
yii migrate/create <name>
The required name argument gives a brief description about the new migration. For example, if the migration is about creating a new table named news, you may use the name create_news_table and run the following command
yii migrate/create create_news_table
<?php
use yii\db\Migration;
class m150101_185401_create_news_table extends Migration
{
public function up()
{
}
public function down()
{
echo "m101129_185401_create_news_table cannot be reverted.\n";
return false;
}
/*
// Use safeUp/safeDown to run migra...
By default, migrations are applied to the same database specified by the db application component. If you want them to be applied to a different database, you may specify the db command-line option like shown below:
yii migrate --db=db2
yii migrate/history # showing the last 10 applied migrations
yii migrate/history 5 # showing the last 5 applied migrations
yii migrate/history all # showing all applied migrations
yii migrate/new # showing the first 10 new migrations
yii migrate/new 5 # showing the first 5 ...
yii migrate/mark 150101_185401 # using timestamp to specify the migration
yii migrate/mark "2015-01-01 18:54:01" # using a string that can be parsed by strtotime()
yii migrate/mark m150101_185401_create_news_table # using full name
yii migrate/mark 13...
yii migrate
This command will list all migrations that have not been applied so far. If you confirm that you want to apply these migrations, it will run the up() or safeUp() method in every new migration class, one after another, in the order of their timestamp values. If any of the migrations fa...
Set memory limit and disable swap limit
docker run -it -m 300M --memory-swap -1 ubuntu:14.04 /bin/bash
Set both memory and swap limit. In this case, container can use 300M memory and 700M swap.
docker run -it -m 300M --memory-swap 1G ubuntu:14.04 /bin/bash
WCF tracing is built on top of System.Diagnostics. To use tracing, you should define trace sources in the configuration file or in code.
Tracing is not enabled by default. To activate tracing, you must create a trace listener and set a trace level other than "Off" for the selected trace s...
We can use Predefined Constants for Date format in date() instead of the conventional date format strings since PHP 5.1.0.
Predefined Date Format Constants Available
DATE_ATOM - Atom (2016-07-22T14:50:01+00:00)
DATE_COOKIE - HTTP Cookies (Friday, 22-Jul-16 14:50:01 UTC)
DATE_RSS - RSS (Fri, 22...
Installation Requirements
The minimum requirement by this project template is that your Web server supports PHP 5.4.0.
Yii2-advanced-app can be installed in two ways. They are
Installing via Composer
Installing from an Archive File
1) Installing via Composer
If you do not already have Comp...
First, download the compiler and components.
Next, add Swift to your path. On macOS, the default location for the downloadable toolchain is /Library/Developer/Toolchains. Run the following command in Terminal:
export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}...
Technically, autoloading works by executing a callback when a PHP class is required but not found. Such callbacks usually attempt to load these classes.
Generally, autoloading can be understood as the attempt to load PHP files (especially PHP class files, where a PHP source file is dedicated for a ...