Tutorial by Examples: c

First define the service (in this case it uses the factory pattern): .factory('dataService', function() { var dataObject = {}; var service = { // define the getter method get data() { return dataObject; }, // define the setter method ...
updateState by key can be used to create a stateful DStream based on upcoming data. It requires a function: object UpdateStateFunctions { def updateState(current: Seq[Double], previous: Option[StatCounter]) = { previous.map(s => s.merge(current)).orElse(Some(StatCounter(current))) } ...
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...
package { import flash.events.Event; public class CustomEvent extends Event { public static const START:String = "START"; public static const STOP:String = "STOP"; public var data:*; public function CustomEvent(type:Strin...
function meridiem(d:Date):String { return (d.hours > 11) ? "pm" : "am"; }
/** * @param year Full year as int (ex: 2000). * @param month Month as int, zero-based (ex: 0=January, 11=December). */ function daysInMonth(year:int, month:int):int { return (new Date(year, ++month, 0)).date; }
function isLeapYear(year:int):Boolean { return daysInMonth(year, 1) == 29; }
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...
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
yii migrate/create create_post_table --fields="title:string,body:text" Generates: /** * Handles the creation for table `post`. */ class m150811_220037_create_post_table extends Migration { /** * @inheritdoc */ public function up() { $this->createTable('post', [ ...
public function up() { $this->createTable('post', [ 'id' => $this->primaryKey() ]); }
public function up() { $this->dropColumn('post', 'position'); $this->renameColumn('post', 'owner_id', 'user_id'); $this->alterColumn('post', 'updated', $this->timestamp()->notNull()->defaultValue('0000-00-00 00:00:00')); }
public function up() { $this->addColumn('post', 'position', $this->integer()); }
public function safeUp() { $this->createTable('news', [ 'id' => $this->primaryKey(), 'title' => $this->string()->notNull(), 'content' => $this->text(), ]); $this->insert('news', [ 'title' => 'test 1', 'conte...
An abstract class is a class that cannot be instantiated. Abstract classes can define abstract methods, which are methods without any body, only a definition: abstract class MyAbstractClass { abstract public function doSomething($a, $b); } Abstract classes should be extended by a child cla...
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....
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...

Page 146 of 826