Tutorial by Examples

Note: The singleton is a design pattern. But it also considered an anti-pattern. The use of a singleton should be considered carefully before use. There are usually better alternatives. The main problem with a singleton is the same as the problem with global variables. They introduce external glo...
val and var scala> val a = 123 a: Int = 123 scala> a = 456 <console>:8: error: reassignment to val a = 456 scala> var b = 123 b: Int = 123 scala> b = 321 b: Int = 321 val references are unchangeable: like a final variable in Java, once it has been initial...
Let's pick as an example a function that takes 2 Map and return a Map containing every element in ma and mb: def merge2Maps(ma: Map[String, Int], mb: Map[String, Int]): Map[String, Int] A first attempt could be iterating through the elements of one of the maps using for ((k, v) <- map) and so...
While styling effects can vary depending on the theme, the .table class is used to create a uniform and consistent appearance for tables across an application: <table class="table"> <tr> <th>Season</th> <th>Doctor</th> &l...
Sparse indexes: These can be particularly useful for fields that are optional but which should also be unique. { "_id" : "[email protected]", "nickname" : "Johnnie" } { "_id" : "[email protected]" } { "_id" : "julia@example...
The following is an example for setting and reading cookies using the cookie-parser module: var express = require('express'); var cookieParser = require('cookie-parser'); // module for parsing cookies var app = express(); app.use(cookieParser()); app.get('/setcookie', function(req, res){ ...
In Express, you can define middlewares that can be used for checking requests or setting some headers in response. app.use(function(req, res, next){ }); // signature Example The following code adds user to the request object and pass the control to the next matching route. var express = req...
In Express, you can define unified error handler for handling errors occurred in application. Define then handler at the end of all routes and logic code. Example var express = require('express'); var app = express(); //GET /names/john app.get('/names/:name', function(req, res, next){ if...
The XML document, I will be using throughout the examples is - <a> <b>test-value</b> <d>fragment-d</d> <c-root> <d>fragment-d</d> <e>fragment-e</e> </c-root> </a> The following queries ...
xdmp:estimate(cts:search(fn:doc(), cts:element-value-query(xs:QName("d"), "fragment-d"))) xdmp:estimate can not be used on XPaths unlike fn:count is used in previous example xdmp:estimate actually gives the number of matching fragments
The XML document to consider in this example - <a> <b>test-value</b> <d>fragment-d</d> <c-root> <d>fragment-d</d> <e>fragment-e</e> </c-root> </a> A fragment root is declared on <c-r...
To start with App Development we need Visual studio 2013 or higher version. Download latest community or expression edition from here > https://www.visualstudio.com/products/free-developer-offers-vs Once it has been downloaded and installed Open and Click create new project expand Office...
Once we have visual studio, we need a developer site to deploy apps to SharePoint. Simplest way is to get is > Sign up for a free, one year Office 365 developer account https://profile.microsoft.com/RegSysProfileCenter/wizardnp.aspx?wizid=14b845d0-938c-45af-b061-f798fbb4d170&lcid=1033 Once ...
Lets start with creating our first app Open visual studio and > create new project Enter Name and Location Enter your developer site url created in previous step and select Provider-hosted Popup will open which will as for login Next step it will as for type of applicatio...
Here I'm taking the example of a basic news app Open the SharePoint developer site and create a list to store our news articles Create a custom list and Add 3 more columns Body, Summery, ThumbnailImageUrl Go back to our SharePoint app, Open AppManifest.xml file, click on permission...
We have already created first page which will show all the news articles. This page will show Complete article. Add One more Action Method to HomeController [SharePointContextFilter] public ActionResult Aticle(int ArticleId) { User spUser = null; var spContext = SharePointContext...
<?php echo esc_url(get_bloginfo('url')); ?> or if you needed to link to a sub page <?php echo esc_url(get_bloginfo('url') . '/some-sub-page'); ?>
Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. Middleware functions can execute any code, make changes to res and req objects, end response cycle and call next ...
QStack<T> is a template Qt class providing stack. Its analogue in STL is std::stack. It is last in, first out structure (LIFO). QStack<QString> stack; stack.push("First"); stack.push("Second"); stack.push("Third"); while (!stack.isEmpty()) { cout ...
QVector<T> provides dynamic array template class. It provides better performance in most cases than QList<T> so it should be first choice. It can be initialized in various ways: QVector<int> vect; vect << 1 << 2 << 3; QVector<int> v {1, 2, 3, 4}; Th...

Page 866 of 1336