The first step in optimizing for speed is finding the slowest sections of code. The Timer VBA function returns the number of seconds elapsed since midnight with a precision of 1/256th of a second (3.90625 milliseconds) on Windows based PCs. The VBA functions Now and Time are only accurate to a secon...
6.0
Since C# 6.0 it is possible to use string interpolation in place of String.Format.
string name = "John";
string lastname = "Doe";
Console.WriteLine($"Hello {name} {lastname}!");
Hello John Doe!
More examples for this under the topic C# 6.0 features: Stri...
The Flex compiler (mxmlc) is one of the most important parts of the Flex SDK. You can edit AS3 code in any text editor you like. Create a main class file that extends from DisplayObject.
You can trigger builds at the command line as follows:
mxmlc -source-path="." -default-size [width in...
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...
We can bind a class as a Singleton:
public function register()
{
App::singleton('my-database', function()
{
return new Database();
});
}
This way, the first time an instance of 'my-database' will be requested to the service container, a new instance will be created. Al...
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...
$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...
use lib 'includes';
use MySuperCoolModule;
use lib 'includes'; adds the relative directory includes/ as another module search path in @INC. So assume that you have a module file MySyperCoolModule.pm inside includes/, which contains:
package MySuperCoolModule;
If you want, you can group as ma...
First define the service (in this case it uses the factory pattern):
.factory('dataService', function() {
var dataObject = {};
var service = {
// define the getter method
get data() {
return dataObject;
},
// define the setter method
...
/**
* @param year Full year as int (ex: 2000).
* @param month Month as int, zero-based (ex: 0=January, 11=December).
*/
function daysInMonth(year:int, month:int):int {
return (new Date(year, ++month, 0)).date;
}
We can use Predefined Constants for Date format in date() instead of the conventional date format strings since PHP 5.1.0.
Predefined Date Format Constants Available
DATE_ATOM - Atom (2016-07-22T14:50:01+00:00)
DATE_COOKIE - HTTP Cookies (Friday, 22-Jul-16 14:50:01 UTC)
DATE_RSS - RSS (Fri, 22...
A std::vector can be useful for returning a dynamic number of variables of the same type. The following example uses int as data type, but a std::vector can hold any type that is trivially copyable:
#include <vector>
#include <iostream>
// the following function returns all integers...
BeautifulSoup has a limited support for CSS selectors, but covers most commonly used ones. Use select() method to find multiple elements and select_one() to find a single element.
Basic example:
from bs4 import BeautifulSoup
data = """
<ul>
<li class="item&quo...
.SD
.SD refers to the subset of the data.table for each group, excluding all columns used in by.
.SD along with lapply can be used to apply any function to multiple columns by group in a data.table
We will continue using the same built-in dataset, mtcars:
mtcars = data.table(mtcars) # Let's not ...
NLog.Extensions.Logging is the official NLog provider for Microsoft's in .NET Core and ASP.NET Core. Here and here are instruction and example respectively.
Using Razor @functions keyword gives the capability of introducing classes and methods for inline use within a Razor file:
@functions
{
string GetCssClass(Status status)
{
switch (status)
{
case Status.Success:
return "alert-success&qu...
To access pixel values in an OpenCV cv::Mat object, you first have to know the type of your matrix.
The most common types are:
CV_8UC1 for 8-bit 1-channel grayscale images;
CV_32FC1 for 32-bit floating point 1-channel grayscale images;
CV_8UC3 for 8-bit 3-channel color images; and
CV_32FC3 ...