Tutorial by Examples: c

First create a BroadcastReceiver class to handle the incoming Location updates: public class LocationReceiver extends BroadcastReceiver implements Constants { @Override public void onReceive(Context context, Intent intent) { if (LocationResult.hasResult(intent)) { ...
A repository pattern can be used to encapsulate data storage specific code in designated components. The part of your application, that needs the data will only work with the repositories. You will want to create a repository for each combination of item you store and your database technology. Read...
We will take vehicle hierarchy example as depicted below. Vehicle.java package com.thejavageek.jpa.entities; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.Inheritance...
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...
In some very specific scenarios we would feel the need to perform a specific action for each flag of the source enumeration. We can write a simple Generic extension method to realize this task. <DebuggerStepThrough> <Extension> <EditorBrowsable(EditorBrowsableState.Always)> Pu...
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...
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...
If a particular header file is included more than once in a translation unit (TU), there should not be any compilation problems. This is termed 'idempotence'; your headers should be idempotent. Think how difficult life would be if you had to ensure that #include <stdio.h> was only included ...
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...
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 ...
The C standard says that there is very little difference between the #include <header.h> and #include "header.h" notations. [#include <header.h>] searches a sequence of implementation-defined places for a header identified uniquely by the specified sequence between the &l...
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 ...
The config location for your runner is: Debian/Ubuntu/CentOS /etc/gitlab-runner/config.toml if run as root ~/.gitlab-runner/config.toml if run as non-root Windows config.toml where your binary is located A minimal config.toml can look like this: concurrent = 1 [[runners]] name = "E...
groups More detailed information about user and group numerical IDs can be found with the id command.
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 ...
// World physics self.physicsWorld.gravity = CGVectorMake(0, -9.8);
Firstly, we set node category let groundBody: UInt32 = 0x1 << 0 let boxBody: UInt32 = 0x1 << 1 Then add Ground type node and Box type node. let ground = SKSpriteNode(color: UIColor.cyanColor(), size: CGSizeMake(self.frame.width, 50)) ground.position = CGPointMake(CGRectGetMidX(sel...
Set scene as delegate //set your scene as SKPhysicsContactDelegate class yourScene: SKScene, SKPhysicsContactDelegate self.physicsWorld.contactDelegate = self; Then you have to implement one or the other of the contact functions: optional func didBegin(contact:) and/or optional fund didEnd...
=SUMPRODUCT((A1:A100<>"")/COUNTIF(A1:A100,A1:A100&"")) counts unique cell values within A1:A100, excluding blank cells and ones with an empty string (""). How does it do that? Example: A1:A100 = [1, 1, 2, "apple", "peach", &qu...
=SUMPRODUCT(IF(FREQUENCY(MATCH(A1:A100,A1:A100,0),MATCH(A1:A100,A1:A100,0))>0,1))

Page 533 of 826