Tutorial by Examples: dp

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...
using System.Diagnostics.Contracts; public int DivideNumbers(int numerator, int denominator) { Contract.Requires(denominator != 0); return numerator / denominator; }
After succesfully setup Spring-Boot application all the configuration is handled in an application.properties file. You will find the file at src/main/resources/. Normally there is a need to have a database behind the application. For development its good to have a setup of dev and a prod environme...
The best way to install and configure a Symfony2 project is described in the official documentation as follows: Mac OS X / Linux $ sudo curl -LsS http://symfony.com/installer -o /usr/local/bin/symfony $ sudo chmod a+x /usr/local/bin/symfony Windows c:\> php -r "file_put_contents('sym...
//Create a layout var tableLayout = new sap.ui.commons.layout.MatrixLayout({ layoutFixed : false, columns : 2, width : "100%", height : "100%", widths : [ "20%","80%"] }).addStyleClass('dsAvailLayout'); sap.ui.table.Table.extend(...
WordPress is applying pre_get_posts filter to literally any loop it generates. It means that all changes we are making in our callback function are applied to all exiting loops. Obviously it is not what we want in most scenarios. In most cases we would like to target only main loop, and only for n...
First, we need a custom endpoint builder. public class WSConfigurator extends ServerEndpointConfig.Configurator { @Inject private static Injector injector; @Override public <T> T getEndpointInstance(Class<T> endpointClass) throws InstantiationException { ...
Create a folder Create an index.html inside the new directory. Open it in the Bracket editor Download the Phaser repository from github, then grab the phaser.js file from the build folder. Place the file inside your project directory. Open index.html and link the phaser.js inside the header tag...
Here's how to create an Express server and serve index.html by default (empty path /), and page1.html for /page1 path. Folder structure project root | server.js |____views | index.html | page1.html server.js var express = require('express'); var path = require('path')...
You'll first send the user to the Twitch authorization endpoint. This URL is made up of a the base authorization URL (https://api.twitch.tv/kraken/oauth2/authorize) and query string parameters that define what you're requesting. The required parameters are response_type, client_id, redirect_uri, and...
If there would be another value in the URL like: /Example/ProcessInput/2, the routing rules will threat the last number as a parameter passed into the action ProcessInput of controller Example. public ActionResult ProcessInput(int number) { ViewData["OutputMessage"] = string.format(...
Logs are very important. Recreate an error context can be sometimes very painful due to the lack of information about how and when the error occurred. This example shows: How to add user's data in the error logs How to add post parameters sent when an error occurred How to use WebPr...
using System.Diagnostics.Contracts; public int IncrementByRandomAmount(int input) { Contract.Requires<ArgumentNullException>(input != null); // Don't allow null parameter. Contract.Requires<ArgumentOutOfRangeException>(input < int.MaxValue); // We can't do anything if...
A ThreadPool is an ExecutorService that executes each submitted task using one of possibly several pooled threads, normally configured using Executors factory methods. Here is a basic code to initialize a new ThreadPool as a singleton to use in your app: public final class ThreadPool { priv...
In this very first example, a basic serial write operation is started from an Arduino device. void setup() { // put your setup code here, to run once: Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: Serial.println("Hello World!"); dela...
On Unix-like operating systems, it is possible to use the pkg-config program to find and configure packages that provides a <package>.pc file. In order to use pkg-config, it is necessary to call include(FindPkgConfig) in a CMakeLists.txt. Then, there are 2 possible functions: pkg_search_mo...
A UDP (user datagram protocol) server, unlike TCP, is not stream-based. It is packet-based, i.e. a client sends data in units called "packets" to the server, and the client identifies clients by their address. There is no builtin function that relates different packets sent from the same c...
Requirements MongoDB server running on port usually 27017. (type mongod on command prompt to run mongodb server) Php installed as either cgi or fpm with MongoDB extension installed(MongoDB extension is not bundled with default php) Composer library(mongodb/mongodb).(In the project roo...
Even if the result type of the query isn’t an entity type, if the result contains entity types they will still be tracked by default Example : In the following query, which returns an anonymous type, the instances of Book in the result set will be tracked using (var context = new BookC...
This example has more tests available in unit testing. Employee.vb (Class Library) ''' <summary> ''' Employee Class ''' </summary> Public Class Employee ''' <summary> ''' First name of employee ''' </summary> Public Property FirstName As String = &q...

Page 14 of 21