Tutorial by Examples: er

itertools.takewhile enables you to take items from a sequence until a condition first becomes False. def is_even(x): return x % 2 == 0 lst = [0, 2, 4, 12, 18, 13, 14, 22, 23, 44] result = list(itertools.takewhile(is_even, lst)) print(result) This outputs [0, 2, 4, 12, 18]. Not...
itertools.dropwhile enables you to take items from a sequence after a condition first becomes False. def is_even(x): return x % 2 == 0 lst = [0, 2, 4, 12, 18, 13, 14, 22, 23, 44] result = list(itertools.dropwhile(is_even, lst)) print(result) This outputs [13, 14, 22, 23, 44]. ...
While Value Converters can be comprised of either a toView or fromView method, in the below example we will be creating a basic Value Converter which just uses the toView method which accepts the value being sent to the view as the first argument. to-uppercase.js export class ToUppercaseValueConve...
A bi-directional value converter utilizes two methods in your Value Converter class: toView and fromView these methods are aptly named to signify which direction the data is flowing. In our example we will be creating a prepend Value Converter which will make sure that an amount entered in our app ...
A Value Converter can be used alongside other value converters and you can infinitely chain them using the | pipe separator. ${myString | toUppercase | removeCharacters:'&,%,-,+' | limitTo:25} The above theoretical example firstly applies toUppercase which capitalizes our string. Then it app...
Create project using STS (Spring Starter Project) or Spring Initializr (at https://start.spring.io ). Add a Web Dependency in your pom.xml: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId&...
1) Use ng-repeat sparingly Using ng-repeat in views generally results in poor performance, particularly when there are nested ng-repeat's. This is super slow! <div ng-repeat="user in userCollection"> <div ng-repeat="details in user"> {{details}} </div...
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 ...
/** * @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 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...
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')); }
yii migrate/down # revert the most recently applied migration yii migrate/down 3 # revert the most 3 recently applied migrations
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder( MainActivity.this); alertDialogBuilder.setTitle("Title Dialog"); alertDialogBuilder .setMessage("Message Dialog") .setCancelable(true) ...
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
Program units often make use of literal constants. These cover the obvious cases like print *, "Hello", 1, 1.0 Except in one case, each literal constant is a scalar which has type, type parameters and value given by the syntax. Integer literal constants are of the form 1 -1 -1_1 ...

Page 75 of 417