Tutorial by Examples: di

FOREIGN KEY constraint can be added on existing tables that are still not in relationship. Imagine that we have Company and Employee tables where Employee table CompanyId column but don't have foreign key relationship. ALTER TABLE statement enables you to add foreign key constraint on an existing c...
A commonly used utility library is Lodash. To install it into your Aurelia CLI driven application first you need to install it using Npm. npm install lodash --save Now in your preferred IDE/code editor open up the following file in your project directory: aurelia_project/aurelia.json and scroll do...
print "Hello World" import clr from System import Console Console.WriteLine("Hello World")
Rather than use clearRect which makes all pixels transparent you may want a background. To clear with a gradient // create the background gradient once var bgGrad = ctx.createLinearGradient(0,0,0,canvas.height); bgGrad.addColorStop(0,"#0FF"); bgGrad.addColorStop(1,"#08F"); ...
Right click on the solution, Add new project From the Test section, select an Unit Test Project Pick a name for the assembly - if you are testing project Foo, the name can be Foo.Tests Add a reference to the tested project in the unit test project references
When we use @SpringApplicationConfiguration it will use configuration from application.yml [properties] which in certain situation is not appropriate. So to override the properties we can use @TestPropertySource annotation. @TestPropertySource( properties = { "spring...
Full width table cell background images <html xmlns:v="urn:schemas-microsoft-com:vml"> <head> <style> v:* { behavior: url(#default#VML); display: inline-block; } </style> </head> <body> <center> <...
Mink provides an interface for web drivers (like Goutte and Selenium) as well as a MinkContext which, when extended, provides additional web language for our steps. To install Mink (and the default Goutte driver): $ composer require --dev behat/mink-extension="^2.0" $ composer require -...
Django 1.10 introduced a new middleware style where process_request and process_response are merged together. In this new style, a middleware is a callable that returns another callable. Well, actually the former is a middleware factory and the latter is the actual middleware. The middleware facto...
The predicate function matches can be used to evaluate strings on the fly without use of any object declarations. IF matches( val = 'Not a hex string' regex = '[0-9a-f]*' ). cl_demo_output=>display( 'This will not display' ). ELSEIF matches( val = '6c6f7665' reg...
For more complex applications, flat execution profiles may be difficult to follow. This is why many profiling tools also generate some form of annotated callgraph information. gperf2dot converts text output from many profilers (Linux perf, callgrind, oprofile etc.) into a callgraph diagram. You can...
Bootstrapping Magento by calling: require_once 'app/Mage.php'; Mage::app(); // Your code This is the simplest way but not really the Magento way because we're not using class that extends Mage_Shell_Abstract - the class which when extended provides us with tools to parse command line arguments...
The std::nth_element algorithm takes three iterators: an iterator to the beginning, nth position, and end. Once the function returns, the nth element (by order) will be the nth smallest element. (The function has more elaborate overloads, e.g., some taking comparison functors; see the above link for...
We're going to use the expression tree API to create a CalculateSalesTax tree. In plain English, here's a summary of the steps it takes to create the tree. Check if the product is taxable If it is, multiply the line total by the applicable tax rate and return that amount Otherwise return 0 ...
When pasting text through a terminal emulator, the auto-indent feature may destroy the indentation of the pasted text. For example: function () { echo 'foo' echo 'bar' echo 'baz' } will be pasted as: function () { echo 'foo' echo 'bar' echo 'baz' ...
Creating a list of KeyValuePair: Dictionary<int, int> dictionary = new Dictionary<int, int>(); List<KeyValuePair<int, int>> list = new List<KeyValuePair<int, int>>(); list.AddRange(dictionary); Creating a list of keys: Dictionary<int, int> dictionary ...
Text is saved encoded (see also Strings topic) then sometimes you may need to change its encoding, this example assumes (for simplicity) that file is not too big and it can be entirely read in memory: public static void ConvertEncoding(string path, Encoding from, Encoding to) { File.WriteAllT...
Newtonsoft's Json.NET allows you to bind json dynamically (using ExpandoObject / Dynamic objects) without the need to create the type explicitly. Serialization dynamic jsonObject = new ExpandoObject(); jsonObject.Title = "Merchent of Venice"; jsonObject.Author = "William Shakes...
This simple example shows how to start multiple threads in Java. Note that the threads are not guaranteed to execute in order, and the execution ordering may vary for each run. public class HelloMultithreading { public static void main(String[] args) { for (int i = 0; i < 10; i...
The power of AppleScript lies in being able to automate many Mac applications. To find out what you can automate, you need to read an app's scripting dictionary. To do so, launch Script Editor, and select File > Open Dictionary… Once you choose an app, its dictionary will open up in a new win...

Page 94 of 164