Tutorial by Examples: e

Using HttpClient as RestTemplate's underlying implementation to create HTTP requests allows for automatic handling of basic authentication requests (an http 401 response) when interacting with APIs. This example shows how to configure a RestTemplate to achieve this. // The credentials are stored he...
get_template_part( 'foo/bar', 'page'); will require 'bar-page.php' from the directory 'foo'.
Phalcon uses db service by default to obtain connection to databases. Assuming you have an conguration file with database field set up, you can include or autoload following code to obtain connection with database for your project: $di->set('db', function () use ($config) { $dbconf = $conf...
Phalcon builds up some information about tables it is using, so it is possible to validate data being inserted to them without implementing everything by hand. Those are meta data for models. To speed up and prevent Phalcon from building Meta Data every time page is refreshed, it is possible to cach...
<?php //Create a new SQLite3 object from a database file on the server. $database = new SQLite3('mysqlitedb.db'); //Query the database with SQL $results = $database->query('SELECT bar FROM foo'); //Iterate through all of the results, var_dumping them onto the page while ($row = $resu...
In addition to using LIMIT SQL statements you can also use the SQLite3 function querySingle to retrieve a single row, or the first column. <?php $database = new SQLite3('mysqlitedb.db'); //Without the optional second parameter set to true, this query would return just //the first column of ...
Assume that we have a system that sends out daily reports over email in the form of attached CSV files and that we want to access these. function getCsvFromGmail() { // Get the newest Gmail thread based on sender and subject var gmailThread = GmailApp.search("from:[email protected] sub...
Using core debugger Node.js provides a build in non graphical debugging utility. To start the build in the debugger, start the application with this command: node debug filename.js Consider the following simple Node.js application contained in the debugDemo.js 'use strict'; function addTwoN...
To get Nightwatch working, you'll need a local copy of selenium which is a command-and-control server which manages automated browser instances. You'll also need a web browser which selenium can control, such as chromedriver or phantomjs. Add the following devDependencies to your package.json: { ...
In the root of your application should be a package.json file, where you can define scripts and devDependencies. { "name": "myapp", "version": "1.0.0", "scripts": { "start": "meteor --settings settings-development.json&q...
A basic Nightwatch installation for Meteor will have the following directories and files installed. /myapp /myapp/.meteor/nightwatch.json /client/main.html /client/main.js /client/main.css /tests /tests/nightwatch /tests/nightwatch/assertions /tests/nightwatch/commands /tests/nightwatch/da...
Nightwatch accepts a second globals.json configuration file which injects data into the test runner itself, very similar to how Meteor.settings makes data from the command line available throughout the app. globals.json { "default" : { "url" : "http://localhost:300...
Readable streams can be "piped," or connected, to writable streams. This makes data flow from the source stream to the destination stream without much effort. var fs = require('fs') var readable = fs.createReadStream('file1.txt') var writable = fs.createWriteStream('file2.txt') rea...
NDB relates models as python objects, which can be stored and accessed in the Appengine NoSQL datastore, available to all AppEngine applications. models.py from google.appengine.ext import ndb # https://cloud.google.com/appengine/docs/python/ndb/properties class Series(ndb.Model): &qu...
The first part of this example explains how to implement it. In the second, I will explain how it works. This tries to be a general example. The template for the map (see step 3) and the example functions are fully customizable. ################################# IMPLEMENTATION #####################...
Helpers should extend from Mage_Core_Helper_Abstract: # File: app/code/local/Vendor/Package/Helper/Data.php class Vendor_Package_Helper_Data extends Mage_Core_Helper_Abstract { public function multiply($a, $b) { return $a * $b; } } To be able to access is via Mage::hel...
Use the annotation -- @FixMethodOrder(MethodSorters.DEFAULT). This runs all tests within the class in a deterministic and somewhat predictable order. The implementation hashes the method names and compares them. In the scenario of a tie, it sorts by lexicographical order. Code Segment Below Taken f...
Use the annotation @FixMethodOrder with the method sorter MethodSorters.NAME_ASCENDING. This will run all tests within the class in a deterministic and predictable order. The implementation compares the method names and in the case of a tie, it compares the methods' toString(). Code Segment Below T...
Radio Buttons allow you to let the user choose one element of those given. There are two ways to declare a RadioButton with a text besides it. Either by using the default constructor RadioButton() and setting the text with the setText(String) method or by using the other constructor RadioButton(Stri...
A ToggleGroup is used to manage the RadioButtons so that just one in each group can be selected at each time. Create a simple ToggleGroup like following: ToggleGroup group = new ToggleGroup(); After creating a Togglegroup it can be assigned to the RadioButtons by using setToggleGroup(ToggleGrou...

Page 725 of 1191