The next example can be used to determine whether a enumeration has the FlagsAttribute specified. The methodology used is based on Reflection.
This example will give a True result:
Dim enu As [Enum] = New FileAttributes()
Dim hasFlags As Boolean = enu.GetType().GetCustomAttributes(GetType(FlagsAt...
The next example is intended to count the amount of flags in the specified flag combination.
The example is provided as a extension method:
<DebuggerStepThrough>
<Extension>
<EditorBrowsable(EditorBrowsableState.Always)>
Public Function CountFlags(ByVal sender As [Enum]) As In...
The next code illustrates how to find the nearest value of a Enum.
First we define this Enum that will serve to specify search criteria (search direction)
Public Enum EnumFindDirection As Integer
Nearest = 0
Less = 1
LessOrEqual = 2
Greater = 3
GreaterOrEqual = 4
End Enum...
There are a number of guidelines to follow when creating and using
header files in a C project:
Idemopotence
If a header file is included multiple times in a translation unit
(TU), it should not break builds.
Self-containment
If you need the facilities declared in a header file, you sh...
Modern headers should be self-contained, which means that a program that needs to use the facilities defined by header.h can include that header (#include "header.h") and not worry about whether other headers need to be included first.
Recommendation: Header files should be self-contained...
Headers are a crucial consistency checking mechanism, but they should be
as small as possible.
In particular, that means that a header should not include other headers
just because the implementation file will need the other headers.
A header should contain only those headers necessary for a con...
Google's Include What You Use project, or IWYU, ensures source files include all headers used in the code.
Suppose a source file source.c includes a header arbitrary.h which in turn coincidentally includes freeloader.h, but the source file also explicitly and independently uses the facilities from ...
If a singleshot timer is required, it is quiet handy to have the slot as lambda function right in the place where the timer is declared:
QTimer::singleShot(1000, []() { /*Code here*/ } );
Due to this Bug (QTBUG-26406), this is way is only possible since Qt5.4.
In earlier Qt5 versions it has to ...
Gmail Example
MAIL_URL=smtp://username%40gmail.com:[email protected]:465/
Note: This setup only allows 2000 emails to be sent per day. Please see https://support.google.com/a/answer/176600?hl=en for alternative configurations.
Setup
First, install the necessary packages with:
npm install express cors mongoose
Code
Then, add dependencies to server.js, create the database schema and the name of the collection, create an Express.js server, and connect to MongoDB:
var express = require('express');
var cors = require('...
This can be useful if you're writing a game or something that needs to execute a piece of code every a few seconds.
import android.os.Handler;
public class Timer {
private Handler handler;
private boolean paused;
private int interval;
private Runnable task = new Runnable ...
MSBuild evaluates PropertyGroup, Choose and ItemGroup elements that are directly under the Project element before those that are in Target elements.
Directly under the Project element, PropertyGroup and Choose elements are evaluated in the order in which they appear, and then ItemGroup elements a...