Tutorial by Examples: e

The practice of replacing an object with a test double that verifies expectations, for instance asserting that a method has been called, is referred to as mocking. Lets assume we have SomeService to test. class SomeService { private $repository; public function __construct(Repository $r...
Since arrays are reference types, an array variable can be null. To declare a null array variable, you must declare it without a size: Dim array() As Integer Or Dim array As Integer() To check if an array is null, test to see if it Is Nothing: Dim array() As Integer If array Is Nothing Th...
Since arrays are reference types, it is possible to have multiple variables pointing to the same array object. Dim array1() As Integer = {1, 2, 3} Dim array2() As Integer = array1 array1(0) = 4 Console.WriteLine(String.Join(", ", array2)) ' Writes "4, 2, 3"
If we want to replace only the first occurrence in a line, we use sed as usual: $ cat example aaaaabbbbb aaaaaccccc aaaaaddddd $ sed 's/a/x/' example xaaaabbbbb xaaaaccccc xaaaaddddd But what if we want to replace all occurrences? We just add the g pattern flag at the end: $ sed 's/a/x/...
A form gives the user a way to change data in your application, in a structured way. To mutate a simple array of data, we create a form using a form builder: use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\NumberType; use Symfony\Component\F...
A custom form type is a class which defines a reusable form component. Custom form components can be nested to create complicated forms. Instead of creating a form in the controller using a form builder, you can use your own type to make the code more readable, reusable and maintanable. Create a c...
manifest.json { "name": "Hello Page", "description": "Add 'Hello' to the current page.", "version": "1.0", "permissions": [ "activeTab" ], "background": { "scripts": [&quo...
Field-Symbols are ABAP's equivalent to pointers, except that Field-Symbols are always dereferenced (it is not possible to change the actual address in memory). Declaration To declare a Field-Symbol the keyword FIELD-SYMBOLS must be used. Types can be generic (ANY [... TABLE]) to handle a wide vari...
Essential for data references is the addition REF TO after TYPE. Dynamic Creation of Structures If the type of a structure should be decided on runtime, we can define our target structure as reference to the generic type data. DATA wa TYPE REF TO data. To give wa a type we use the statement CR...
AppBundle/Entity/Person.php <?php namespace AppBundle\Entity; /** * Person */ class Person { /** * @var int */ private $id; /** * @var string */ private $name; /** * @var int */ private $age; /** ...
AppBundle/Entity/Person.php <?php namespace AppBundle\Entity; use DoctrineORM\Mapping as ORM; use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity; /** * @ORM\Entity * @ORM\Table(name="persons") * @ORM\Entity(repositoryClass="AppBundle\Entity\PersonRe...
Postgresql-simple is a mid-level Haskell library for communicating with a PostgreSQL backend database. It is very simple to use and provides a type-safe API for reading/writing to a DB. Running a simple query is as easy as: {-# LANGUAGE OverloadedStrings #-} import Database.PostgreSQL.Simple ...
It is possible to define a data type with field labels. data Person = Person { age :: Int, name :: String } This definition differs from a normal record definition as it also defines *record accessors which can be used to access parts of a data type. In this example, two record accessors are de...
One of the most common obstacles using classes is finding the proper approach to handle private states. There are 4 common solutions for handling private states: Using Symbols Symbols are new primitive type introduced on in ES2015, as defined at MDN A symbol is a unique and immutable data typ...
To Copy table to standard o/p COPY <tablename> TO STDOUT (DELIMITER '|'); To export table user to Standard ouput: COPY user TO STDOUT (DELIMITER '|'); To Copy table to file COPY user FROM '/home/user/user_data' WITH DELIMITER '|'; To Copy the output of SQL statement to file COPY (sql st...
Data can be exported using copy command or by taking use of command line options of psql command. To Export csv data from table user to csv file: psql -p \<port> -U \<username> -d \<database> -A -F<delimiter> -c\<sql to execute> \> \<output filename with path&gt...
You can use using in order to set an alias for a namespace or type. More detail can be found in here. Syntax: using <identifier> = <namespace-or-type-name>; Example: using NewType = Dictionary<string, Dictionary<string,int>>; NewType multiDictionary = new NewType(); /...
Directive code angular.module('myModule', []) .directive('myDirective', function() { return { template: '<div>{{greeting}} {{name}}!</div>', scope: { name: '=', greeting: '@' } }; }); The test describe('myDirective', function() ...
Dedicated Workers A dedicated web worker is only accessible by the script that called it. Main application: var worker = new Worker('worker.js'); worker.addEventListener('message', function(msg) { console.log('Result from the worker:', msg.data); }); worker.postMessage([2,3]); worker.j...
You can test for IndexedDB support in the current environment by checking for the presence of the window.indexedDB property: if (window.indexedDB) { // IndexedDB is available }

Page 530 of 1191