This example assumes that you have already set up a Firebase Realtime Database. If you are a starter, then please inform yourself here on how to add Firebase to your Android project.
First, add the dependency of the Firebase Database to the app level build.gradle file:
compile 'com.google.firebase...
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)) {
...
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...
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...
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.
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...
class MyClass {
static function my_init_method() {
// do something here
}
}
add_action( 'init', array( 'MyClass', 'my_init_method' ) );
Using a static method of a class to hook a set of instructions. With the init hook, the set of instructions will be executed right after w...
class MyClass {
function my_init_method() {
// do something here
}
}
$obj = new MyClass();
add_action( 'init', array( $obj, 'my_init_method' ) );
Using a method of an object to hook a set of instructions. With the init hook, the set of instructions will be executed right...
The StretchViewport is a Viewporttype, which supports a virtual screen size.
This allowes you to define a fixed (resolution independent) width and height.
The StretchViewport, as the name suggests, stretches the virtual screen, if the virtual aspect ratio does not match the real aspect ratio. The ...
Authentication in Django REST Framework can be configured globally as a subkey of the REST_FRAMEWORK variable in settings.py, just like the rest of the default framework configurations.
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthen...
Authentication can be set for an specific APIView endpoint, by using the authentication_classes variable:
from rest_framework.authentication import SessionAuthentication, BasicAuthentication
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
...
OAuth is not handled by Django REST Framework, but there are a couple of pip modules that implement an OAuth client. The REST Framework documentation suggests one of the following modules:
Django OAuth Toolkit
Django REST Framework OAuth
Django OAuth Toolkit
pip install django-oauth-toolkit
...
The most interesting package for managing real tokens is django-rest-knox which supports multiple tokens per user (and cancelling each token independently), as well as having support for token expiration and several other security mechanisms.
django-rest-knox depends on cryptography. You can find m...
A simple example of Vehicle hierarchy can be taken for single table inheritance strategy.
Abstract Vehicle class:
package com.thejavageek.jpa.entities;
import javax.persistence.DiscriminatorColumn;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persi...
Static initialization is suitable for most situations. When your application must delay the instantiation, use a non-default constructor or perform other tasks before the instantiation, and work in a multithreaded environment, you need a different solution. Cases do exist, however, in which you cann...
To detect a touch in Unity it's quite simple we just have to use Input.GetTouch() and pass it an index.
using UnityEngine;
using System.Collections;
public class TouchExample : MonoBehaviour {
void Update() {
if (Input.touchCount > 0 && Input.GetTouch(0).phase == Touch...