The static method Date.now returns the number of milliseconds that have elapsed since 1 January 1970 00:00:00 UTC. To get the number of milliseconds that have elapsed since that time using an instance of a Date object, use its getTime method.
// get milliseconds using static method now of Date
co...
Laravel allows access to a variety of classes called Services. Some services are available out of the box, but you can create them by yourself.
A service can be used in multiple files of the application, like controllers. Let's imagine a Service OurService implementing a getNumber() method returnin...
The Service Container is the main Application object. It can be used as a Dependency Injection Container, and a Registry for the application by defining bindings in the Service Providers
Service Providers are classes where we define the way our service classes will be created through the applicatio...
Using the Control.Invoke() method you may move the execution of a method or function from a background thread to the thread that the control was created on, which is usually the UI (User Interface) thread. By doing so your code will be queued to run on the control's thread instead, which removes the...
This method will work on modern versions of Arch, CentOS, CoreOS, Debian, Fedora, Mageia, openSUSE, Red Hat Enterprise Linux, SUSE Linux Enterprise Server, Ubuntu, and others. This wide applicability makes it an ideal as a first approach, with fallback to other methods if you need to also identify o...
The default namespace is the namespace corresponding to the absence of any prefix. It can be declared with the special xmlns attribute.
<?xml version="1.0"?>
<foo xmlns="http://www.example.com/my-namespace">
<!-- the element foo is in the namespace
htt...
Elements and attributes behave differently with respect to default namespaces. This is often the source of confusion.
An attribute whose name has no prefix lives in no namespace, also when a default namespace is in scope.
<?xml version="1.0"?>
<foo attr="value" xmlns=...
C++11
Deriving a class may be forbidden with final specifier. Let's declare a final class:
class A final {
};
Now any attempt to subclass it will cause a compilation error:
// Compilation error: cannot derive from final class:
class B : public A {
};
Final class may appear anywhere in cl...
Addition + and subtraction - operations can be used to combine delegate instances. The delegate contains a list of the assigned delegates.
using System;
using System.Reflection;
using System.Reflection.Emit;
namespace DelegatesExample {
class MainClass {
private delegate void MyD...
You can easily add a breakpoint to your code by clicking on the grey column to the left of the line of your VBA code where you want execution to stop. A red dot appears in the column and the breakpoint code is also highlighted in red.
You can add multiple breakpoints throughout your code and resumi...
Once a model object has been fetched, it becomes a fully realized instance of the class. As such, any additional methods can be accessed in forms and serializers (like Django Rest Framework).
Using python properties is an elegant way to represent additional values that are not stored in the databa...
This example will show you how to quickly get a hello world Aurelia application up and running using the Aurelia CLI.
Prerequisites
The Aurelia CLI is a Node.js based application, so make sure you install it first before proceeding. You will need Node.js 4.4.7 or later.
You will also need a Git c...
While Value Converters can be comprised of either a toView or fromView method, in the below example we will be creating a basic Value Converter which just uses the toView method which accepts the value being sent to the view as the first argument.
to-uppercase.js
export class ToUppercaseValueConve...
A bi-directional value converter utilizes two methods in your Value Converter class: toView and fromView these methods are aptly named to signify which direction the data is flowing.
In our example we will be creating a prepend Value Converter which will make sure that an amount entered in our app ...
A Value Converter can be used alongside other value converters and you can infinitely chain them using the | pipe separator.
${myString | toUppercase | removeCharacters:'&,%,-,+' | limitTo:25}
The above theoretical example firstly applies toUppercase which capitalizes our string. Then it app...
When you use or, it will either return the first value in the expression if it's true, else it will blindly return the second value. I.e. or is equivalent to:
def or_(a, b):
if a:
return a
else:
return b
For and, it will return its first value if it's false, else it r...
Stateless components are getting their philosophy from functional programming. Which implies that: A function returns all time the same thing exactly on what is given to it.
For example:
const statelessSum = (a, b) => a + b;
let a = 0;
const statefulSum = () => a++;
As you can see fro...
Recursion occurs when a function call causes that same function to be called again before the original function call terminates. For example, consider the well-known mathematical expression x! (i.e. the factorial operation). The factorial operation is defined for all nonnegative integers as follows:...
$scope.$emit
Using $scope.$emit will fire an event name upwards through the scope hierarchy and notify to the $scope.The event life cycle starts at the scope on which $emit was called.
Working wireframe :
$scope.$broadcast
Using $scope.$broadcast will fire an event down the $scope. We can list...