Tutorial by Examples: o

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, 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...
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 ...
To Copy Data from a CSV file to a table COPY <tablename> FROM '<filename with path>'; To insert into table user from a file named user_data.csv placed inside /home/user/: COPY user FROM '/home/user/user_data.csv'; To Copy data from pipe separated file to table COPY user FROM '/h...
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...
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 }
Opening a database is an asynchronous operation. We need to send a request to open our database and then listen for events so we know when it's ready. We'll open a DemoDB database. If it doesn't exist yet, it will get created when we send the request. The 2 below says that we're asking for version...
If you want to connect to an HBase server, first you need to make sure that the IP of the server is in your /etc/hosts file for example add the line 255.255.255.255 hbase Then you can use the Java API to connect to zookeeper, you only have to specify the client port and the zookeeper address ...
There are two ways to define an anonymous function: the full syntax and a shorthand. Full Anonymous Function Syntax (fn [x y] (+ x y)) This expression evaluates to a function. Any syntax you can use with a function defined with defn (&, argument destructuring, etc.), you can also do with wi...
(defn print-some-items [[a b :as xs]] (println a) (println b) (println xs)) (print-some-items [2 3]) This example prints the output 2 3 [2 3] The argument is destructured and the items 2 and 3 are assigned to the symbols a and b. The original argument, the entire vector [2 ...
In the node JS command prompt, inside your loopback project, type the following command to create a new model. slc loopback:model If you have installed LoopBack CLI tool, you can create model with: lb model The command prompt will request informations about the model to create. In this examp...

Page 456 of 1038