Tutorial by Examples

In ASP.NET Core there are several different ways we can localize/globalize our app. It's important to pick a way that suits your needs. In this example you'll see how we can make a multilingual ASP.NET Core app that reads language specific strings from .json files and store them in memory to provi...
There are two ways to define functions with multiple parameters in F#, Curried functions and Tupled functions. let curriedAdd x y = x + y // Signature: x:int -> y:int -> int let tupledAdd (x, y) = x + y // Signature: x:int * y:int -> int All functions defined from outside F# (such as ...
Type erasure is a way to hide the type of an object from code using it, even though it is not derived from a common base class. In doing so, it provides a bridge between the worlds of static polymorphism (templates; at the place of use, the exact type must be known at compile time, but it need not b...
The stack is a small region of memory into which temporary values are placed during execution. Allocating data into the stack is very fast compared to heap allocation, as all the memory has already been assigned for this purpose. int main() { int a = 0; //Stored on the stack return a; } ...
The term 'heap' is a general computing term meaning an area of memory from which portions can be allocated and deallocated independently of the memory provided by the stack. In C++ the Standard refers to this area as the Free Store which is considered a more accurate term. Areas of memory allocate...
There are situations when we don't want to rely upon Free Store for allocating memory and we want to use custom memory allocations using new. For these situations we can use Placement New, where we can tell `new' operator to allocate memory from a pre-allocated memory location For example int a4b...
A std::string containing a number can be converted into an integer type, or a floating point type, using conversion functions. Note that all of these functions stop parsing the input string as soon as they encounter a non-numeric character, so "123abc" will be converted into 123. The s...
Arithmetic operations are performed elementwise on Numpy arrays. For arrays of identical shape, this means that the operation is executed between elements at corresponding indices. # Create two arrays of the same size a = np.arange(6).reshape(2, 3) b = np.ones(6).reshape(2, 3) a # array([0, 1...
app/pipes.pipe.ts import { Pipe, PipeTransform } from '@angular/core'; @Pipe({name: 'truthy'}) export class Truthy implements PipeTransform { transform(value: any, truthy: string, falsey: string): any { if (typeof value === 'boolean'){return value ? truthy : falsey;} else return va...
Enumerable.Repeat generates a sequence of a repeated value. In this example it generates "Hello" 4 times. var repeats = Enumerable.Repeat("Hello", 4); foreach (var item in repeats) { Console.WriteLine(item); } /* output: Hello Hello Hello Hell...
import random probability = 0.3 if random.random() < probability: print("Decision with probability 0.3") else: print("Decision with probability 0.7")
The fundamental concept of the customizer is that admins can live preview changes to their site, and then permanently add them. The following can be copied and pasted into a theme's functions.php file to Add a customizer section called My First Section Add a customizer setting called Hello Worl...
MySQL3.19 Checks if a string matches a regular expression (defined by another string). SELECT 'bedded' REGEXP '[a-f]' -- returns True SELECT 'beam' REGEXP '[a-f]' -- returns False
Instantiating a socket can be done in various ways. by 2 line declaration & instantiation: First we need to define a variable which will hold a Socket class object: Socket socket; then we can create a Socket class object: socket = new Socket(); We can also make a one line defin...
The simplest way to run your job is to use mpiexec or mpirun (they are usually the same thing and aliases of each other). mpiexec -n 2 ./my_prog
Alternate return is a facility to control the flow of execution on return from a subroutine. It is often used as a form of error handling: real x call sub(x, 1, *100, *200) print*, "Success:", x stop 100 print*, "Negative input value" stop 200 print*, "Input va...
Installing aws cli in Ubuntu / Debian Instance sudo apt-get install -y python-dev python-pip sudo pip install awscli aws --version aws configure Installing aws cli using python Using pip you can install aws cli in windows, OS X and Linux sudo pip install awscli Configuring the AWS Comman...
Unit Test Unit tests are used to ensure that your code has no syntax error and to test the logic of your code to work as what you expected. Quick example: src/AppBundle/Calculator/BillCalculator.php <?php namespace AppBundle\Calculator; use AppBundle\Calculator\TaxCalculator; class Bi...

Page 371 of 1336