Tutorial by Examples: ti

mapWithState, similarly to updateState, can be used to create a stateful DStream based on upcoming data. It requires StateSpec: import org.apache.spark.streaming._ object StatefulStats { val state = StateSpec.function( (key: String, current: Option[Double], state: State[StatCounter]) =&g...
/** * @param n Number to be rounded. * @param precision Decimal places. * @return Rounded Number */ function roundDecimal(n:Number, precision:Number):Number { var factor:int = Math.pow(10, precision); return (Math.round(n * factor) / factor); } Examples: trace(0.9 - 1); // -0...
function isDaylightSavings(d:Date):Boolean { var months:uint = 12; var offset:uint = d.timezoneOffset; var offsetCheck:Number; while (months--) { offsetCheck = (new Date(d.getFullYear(), months, 1)).timezoneOffset; if (offsetCheck != offset) ret...
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...
yii migrate/down # revert the most recently applied migration yii migrate/down 3 # revert the most 3 recently applied migrations
public function safeUp() { $this->createTable('news', [ 'id' => $this->primaryKey(), 'title' => $this->string()->notNull(), 'content' => $this->text(), ]); $this->insert('news', [ 'title' => 'test 1', 'conte...
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/redo # redo the last applied migration yii migrate/redo 3 # redo the last 3 applied migrations
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...
SELECT * FROM table1, table2 SELECT table1.column1, table1.column2, table2.column1 FROM table1, table2 This is called cross product in SQL it is same as cross product in sets These statements return the selected columns from multiple tables in one query....
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...
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...
An anonymous function is just a function that doesn't have a name. // Anonymous function function() { return "Hello World!"; }; In PHP, an anonymous function is treated like an expression and for this reason, it should be ended with a semicolon ;. An anonymous function should b...
You can call a function in Racket by wrapping it in parentheses with the arguments after it. This looks like (function argument ...). > (define (f x) x) > (f 1) 1 > (f "salmon") "salmon" > (define (g x y) (string-append x y)) > (g "large" "sal...
A common pattern in C# is using bool TryParse(object input, out object value) to safely parse objects. The out var declaration is a simple feature to improve readability. It allows a variable to be declared at the same time that is it passed as an out parameter. A variable declared this way is sco...
Local functions are defined within a method and aren't available outside of it. They have access to all local variables and support iterators, async/await and lambda syntax. This way, repetitions specific to a function can be functionalized without crowding the class. As a side effect, this improves...
Preconditions allows methods to provide minimum required values for input parameters Example... void DoWork(string input) { Contract.Requires(!string.IsNullOrEmpty(input)); //do work } Static Analysis Result...

Page 92 of 505