Tutorial by Examples: pre

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...
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 ...
using System.Diagnostics.Contracts; public int DivideNumbers(int numerator, int denominator) { Contract.Requires(denominator != 0); return numerator / denominator; }
using System.Diagnostics.Contracts; public int DivideNumbers(int numerator, int denominator) { Contract.Requires<ArgumentOutOfRangeException>(denominator != 0); return numerator / denominator; }
Use the tar (tape archive) command to compress your files and folders. It is similar to creating .ZIP files in Windows environment. Syntax: tar -zcvf <output tar file> <source file> Example: tar -zcvf outputfile.tar.gz source file Here’s what those switches actually mean: -c: Cr...
By default Sitecore adds all versions of the item to the sitecore_master_index. The drawback of that is that if users are using workflows and adding lots of versions all of them will be added to the search results in the content editor. Configuration: <event name="item:versionAdded" &...
Set custom user agent and navigate to Uri: var userAgent = "my custom user agent"; var uri = new Uri("http://useragentstring.com/"); var requestMessage = new HttpRequestMessage(HttpMethod.Get, uri); requestMessage.Headers.Add("User-Agent", userAgent); this.webVie...
Arrays in MATLAB are held as continuous blocks in memory, allocated and released automatically by MATLAB. MATLAB hides memory management operations such as resizing of an array behind easy to use syntax: a = 1:4 a = 1 2 3 4 a(5) = 10 % or alternatively a = [a, 10] a = ...
<div> The time is now <%= DateTime.Now.ToString() %> </div>
When you have entered something into IEx which expects a completion, such as a multiline string, IEx will change the prompt to indicate that it is waiting for you finish by changing the prompt to have an ellipsis (...) rather than iex. If you find that IEx is waiting for you to finish an expression...
After including oclazyload.js in your index file, declare ocLazyLoad as a dependency in app.js //Make sure you put the correct dependency! it is spelled different than the service! angular.module('app', [ 'oc.lazyLoad', 'ui-router' ])
Usually to use the converter, we have to define it as resource in the following way: <converters:SomeConverter x:Key="SomeConverter"/> It is possible to skip this step by defining a converter as MarkupExtension and implementing the method ProvideValue. The following example conve...
You can also loop over a variable list. From vars: favorite_snacks: - hotdog - ice cream - chips and then the loop: - name: create directories for storing my snacks file: path=/etc/snacks/{{ item }} state=directory with_items: '{{ favorite_snacks }}' If you are using Ansible ...
It is possible to create more complex loops with dictionaries. From vars: packages: - present: tree - present: nmap - absent: apache2 then the loop: - name: manage packages package: name={{ item.value }} state={{ item.key }} with_items: '{{ packages }}' Or, if you don't like ...
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...
Default behavior is to de-select row when clicked twice. In some use cases, you might want to disable this de-selecting behavior. Note table.deselectItem(item) method will imperatively deselect an item. This works with both item or index (when using items array) as an argument. Working jsBin &lt...
Suppose you are searching for a Title Case pattern in a large text file and you want to edit a incorrect regular expression: First, go into Ex mode by typing q: You will now see all the commands that you typed in commandline mode, press j to go the regular expression you want to edit (/\v[A-Z]\w...
Mapreduce is a programming model to do processing on (very) large amounts of data. Traditional 'HPC' (High Performance Computing) speeds up large calculations on relatively large amounts of data by creating a set of highly connected computers (using things like extremely quick networking, and quick...
#!/usr/bin/env node var fs = require('fs'); var path = require('path'); var jshint = require('jshint').JSHINT; var async = require('async'); var foldersToProcess = [ 'js' ]; foldersToProcess.forEach(function(folder) { processFiles("www/" + folder); }); function proce...
After a statement was executed, a call to sqlite3_reset() brings it back into the original state so that it can be re-executed. Typically, while the statement itself stays the same, the parameters are changed: const char *sql = "INSERT INTO MyTable(ID, Name) VALUES (?, ?)"; sqlite3_stmt...

Page 24 of 34