text:
{-# LANGUAGE OverloadedStrings #-}

module Spark.Core.DatasetSpec where

import qualified Data.Text as T
import Test.Hspec
import qualified Data.Vector as V

import Spark.Core.Dataset
import Spark.Core.Functions
import Spark.Core.Column
import Spark.Core.StructuresInternal
import Spark.Core.Internal.ContextInternal
import Spark.Core.Internal.Utilities
import Spark.Core.Internal.DAGStructures
import Spark.Core.Internal.ComputeDag

nName :: String -> NodeName
nName = NodeName . T.pack

spec :: Spec
spec = do
  describe "create a dataframe" $ do
    it "should not explode" $
      let x = dataset ([1 ,2, 3, 4]::[Int]) in
        nodeName x `shouldBe` nName "distributedliteral_6e1287"

    it "renaming should work" $
      let x = dataset ([1 ,2, 3]::[Int]) @@ "ds1" in
        nodeName x `shouldBe` nName "ds1"

  describe "check localset" $ do
    it "should not explode" $
      let x = dataset ([1 ,2, 3]::[Int]) in
        nodeName x `shouldBe` nName "distributedliteral_d412ac"

    it "renaming should work" $
      let x = dataset ([1 ,2, 3]::[Int]) @@ "ds1" in
        nodeName x `shouldBe` nName "ds1"

  describe "column syntax" $
    it "should not explode" $ do
      let ds = dataset ([1 ,2, 3]::[Int])
      let c1 = ds/-"c1"
      c1 `shouldBe` c1

  describe "Logical dependencies" $ do
    it "should work" $ do
      let ds = dataset ([1 ,2, 3, 4]::[Int])
      let ds1 = dataset ([1]::[Int]) `depends` [untyped ds]
      let g = traceHint (T.pack "g=") $ computeGraphToGraph $ forceRight $ buildComputationGraph ds1
      V.length (gVertices g) `shouldBe` 2

--   describe "simple test" $ do
--     it "the type should match" $ do
--       let
--        n1 = constant "xxx"
--        n = NodeType $ T.pack "org.spark.Constant" in
--         (nodeOp n1) `shouldBe` n

--     it "no name" $ do
--       let n1 = constant "xxx"
--           t = NodeName $ T.pack "org.spark.Constant" in
--         (nodeName n1) `shouldBe` t

--     it "some name" $ do
--       let n1 = constant "xxx" @@ "name"
--           t = NodeName $ T.pack "name" in
--         (nodeName n1) `shouldBe` t


text:
published: true
title: Chocolate Cream Icing/Ganache
layout: post
categories: [frosting]
rating: 0
---
### Servings

### Ingredients
- 1/2 Cup Whipping Cream
- 1 Cup Bittersweet or Semisweet Chocolate Pieces

### Directions
1. In small saucepan bring whipping cream just to boiling over medium-high heat.  Remove from heat.  Pour over chocolate pieces in medium bowl (DO NOT STIR).  Let stand 5 minutes.  Stir until smooth.  Cool 15 minutes.
2. Makes 1 1/4 Cups.

### Source

redpajama_set_name: RedPajamaGithub


text:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project default="create_run_jar" name="Create Runnable Jar for Project JavaSim">
    <target name="create_run_jar">
        <jar destfile="dist/RaindropRainbow.jar"
        	manifest="MANIFEST.MF"
    		filesetmanifest="mergewithoutmain">
        	<fileset dir="bin"/>
        	<zipfileset dir="./" includes="info.json" fullpath="info.json" />
        </jar>
    	<copy file="dist/RaindropRainbow.jar" tofile="/Users/mark/Documents/JavaSim/RaindropRainbow.jar"/>
    </target>
</project>


text:
package Core;
import Monsters.Affixes.*;

/**
 *
 * @author Alexis
 */
public class Monster {
    protected String Name;
    protected int Level;
    protected long ExpToGive;
    protected int Health;
    protected Gold GoldToGive;
    public boolean IsAlive;
    protected Affixe availableAffixes[];

    public Monster() {}
    public Monster(int lvl) {
        this.Level = lvl;
        this.GoldToGive = new Gold();
        this.Health = 15;
        this.IsAlive = true;
        //this.ComputeHealth();
        this.ComputeExpToGive();
        this.ComputeGoldToGive();
        this.setAffixe();
    }

    public void setAffixe() {};

    public void getHit(int dmg) {
        if(this.Health > dmg) {
            this.Health -= dmg;
        }
        else {
            this.die();
        }
    }

    public void die() {
        this.Health = 0;
        this.IsAlive = false;
    }

    public void ComputeExpToGive() {
        this.ExpToGive = this.Level * 2;
    }

    public void ComputeHealth() {
        this.Health = this.Level*5;
    }

    public long GetExpToGive() {
        return this.ExpToGive;
    }

    public void ComputeGoldToGive() {
        this.GoldToGive.setAmount(this.Level * 3);
    }

    public int GetGoldToGive() {
        return this.GoldToGive.getAmount();
    }

    public int GetHealth() {
        return this.Health;
    }

}


text:
package com.grarak.kerneladiutor.views.recyclerview.downloads;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.grarak.kerneladiutor.R;
import com.grarak.kerneladiutor.utils.Utils;
import com.grarak.kerneladiutor.utils.ViewUtils;
import com.grarak.kerneladiutor.utils.tools.SupportedDownloads;
import com.grarak.kerneladiutor.views.recyclerview.RecyclerViewItem;

/**
 * Created by willi on 06.07.16.
 */
public class KernelItemView extends RecyclerViewItem {

    private final SupportedDownloads.KernelContent mKernelContent;

    public KernelItemView(SupportedDownloads.KernelContent content) {
        mKernelContent = content;
    }

    @Override
    public int getLayoutRes() {
        return R.layout.rv_kernel_item_view;
    }

    @Override
    public void onCreateView(View view) {
        super.onCreateView(view);

        final ImageView icon = (ImageView) view.findViewById(R.id.icon);
        TextView title = (TextView) view.findViewById(R.id.title);
        TextView summary = (TextView) view.findViewById(R.id.summary);

        ViewUtils.loadImagefromUrl(mKernelContent.getLogo(), icon, 300, 300);

        title.setText(Utils.htmlFrom(mKernelContent.getName()).toString());
        summary.setText(Utils.htmlFrom(mKernelContent.getShortDescription()));

        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (getOnItemClickListener() != null) {
                    getOnItemClickListener().onClick(KernelItemView.this);
                }
            }
        });
    }

    @Override
    protected boolean cardCompatible() {
        return false;
    }
}


text:
#region FreeBSD

// Copyright (c) 2013, The Tribe
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
//
//  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
//
//  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the
//    documentation and/or other materials provided with the distribution.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#endregion

using System;

using HBase.Stargate.Client.TypeConversion;

using Newtonsoft.Json.Linq;

namespace HBase.Stargate.Client.Api
{
	/// <summary>
	///    A Filter that stops after the given row. There is no "RowStopFilter" because
	///    <see cref="ScannerOptions" /> allows you to specify a stop row.
	/// </summary>
	public class InclusiveStopFilter : TypeValueFilterBase
	{
		private readonly string _row;

		/// <summary>
		///    Initializes a new instance of the <see cref="InclusiveStopFilter" /> class.
		/// </summary>
		/// <param name="row">The row.</param>
		public InclusiveStopFilter(string row)
		{
			_row = row;
		}

		/// <summary>
		/// Gets the token to use as the value.
		/// </summary>
		/// <param name="codec">The codec to use for encoding values.</param>
		protected override JToken GetValueJToken(ICodec codec)
		{
			return new JValue(codec.Encode(_row));
		}
	}
}


text:
"""
Test available runners on a variety of workflows.
"""

import pytest
import sys

def test_run(workflow, backend):
    if not backend.supports(workflow.requires):
        pytest.skip("Workflow not supported on this backend.")

    if workflow.python_version is not None and \
            not sys.version_info >= workflow.python_version:
        required = ".".join(map(str, workflow.python_version))
        running = ".".join(map(str, sys.version_info[0:3]))
        pytest.skip("Workflow requires Python >= {}, running Python {}."
                    .format(required, running))

    if workflow.raises is not None:
        with pytest.raises(workflow.raises):
            backend.run(workflow.make())
    else:
        result = backend.run(workflow.make())
        workflow.check_assertions(result)


text:
from unittest import mock

from django.core.checks import Error, Warning as DjangoWarning
from django.db import connection, models
from django.test.testcases import SimpleTestCase
from django.test.utils import isolate_apps, modify_settings, override_settings

@isolate_apps('invalid_models_tests')
class RelativeFieldTests(SimpleTestCase):

    def test_valid_foreign_key_without_accessor(self):
        class Target(models.Model):
            # There would be a clash if Model.field installed an accessor.
            model = models.IntegerField()

        class Model(models.Model):
            field = models.ForeignKey(Target, models.CASCADE, related_name='+')

        field = Model._meta.get_field('field')
        self.assertEqual(field.check(), [])

    def test_foreign_key_to_missing_model(self):
        # Model names are resolved when a model is being created, so we cannot
        # test relative fields in isolation and we need to attach them to a
        # model.
        class Model(models.Model):
            foreign_key = models.ForeignKey('Rel1', models.CASCADE)

        field = Model._meta.get_field('foreign_key')
        self.assertEqual(field.check(), [
            Error(
                "Field defines a relation with model 'Rel1', "
                "which is either not installed, or is abstract.",
                obj=field,
                id='fields.E300',
            ),
        ])

    @isolate_apps('invalid_models_tests')
    def test_foreign_key_to_isolate_apps_model(self):
        """
        #25723 - Referenced model registration lookup should be run against the
        field's model registry.
        """
        class OtherModel(models.Model):
            pass

        class Model(models.Model):
            foreign_key = models.ForeignKey('OtherModel', models.CASCADE)

        field = Model._meta.get_field('foreign_key')
        self.assertEqual(field.check(from_model=Model), [])

    def test_many_to_many_to_missing_model(self):
        class Model(models.Model):
            m2m = models.ManyToManyField("Rel2")

        field = Model._meta.get_field('m2m')
        self.assertEqual(field.check(from_model=Model), [
            Error(
                "Field defines a relation with model 'Rel2', "
                "which is either not installed, or is abstract.",
                obj=field,
                id='fields.E300',
            ),
        ])

    @isolate_apps('invalid_models_tests')
    def test_many_to_many_to_isolate_apps_model(self):
        """
        #25723 - Referenced model registration lookup should be run against the
        field's model registry.
        """
        class OtherModel(models.Model):
            pass

        class Model(models.Model):
            m2m = models.ManyToManyField('OtherModel')

        field = Model._meta.get_field('m2m')
        self.assertEqual(field.check(from_model=Model), [])

    def test_many_to_many_with_useless_options(self):
        class Model(models.Model):
            name = models.CharField(max_length=20)

        class ModelM2M(models.Model):
            m2m = models.ManyToManyField(Model, null=True, validators=[lambda x: x])

        field = ModelM2M._meta.get_field('m2m')
        self.assertEqual(ModelM2M.check(), [
            DjangoWarning(
                'null has no effect on ManyToManyField.',
                obj=field,
                id='fields.W340',
            ),
            DjangoWarning(
                'ManyToManyField does not support validators.',
                obj=field,
                id='fields.W341',
            ),
        ])

    def test_many_to_many_with_useless_related_name(self):
        class ModelM2M(models.Model):
            m2m = models.ManyToManyField('self', related_name='children')

        field = ModelM2M._meta.get_field('m2m')
        self.assertEqual(ModelM2M.check(), [
            DjangoWarning(
                'related_name has no effect on ManyToManyField with '
                'a symmetrical relationship, e.g. to "self".',
                obj=field,
                id='fields.W345',
            ),
        ])

    def test_ambiguous_relationship_model_from(self):
        class Person(models.Model):
            pass

        class Group(models.Model):
            field = models.ManyToManyField('Person', through='AmbiguousRelationship')

        class AmbiguousRelationship(models.Model):
            person = models.ForeignKey(Person, models.CASCADE)
            first_group = models.ForeignKey(Group, models.CASCADE, related_name='first')
            second_group = models.ForeignKey(Group, models.CASCADE, related_name='second')

        field = Group._meta.get_field('field')
        self.assertEqual(field.check(from_model=Group), [
            Error(
                "The model is used as an intermediate model by "
                "'invalid_models_tests.Group.field', but it has more than one "
                "foreign key from 'Group', which is ambiguous. You must "
                "specify which foreign key Django should use via the "
                "through_fields keyword argument.",
                hint=(
                    'If you want to create a recursive relationship, use '
                    'ManyToManyField("self", through="AmbiguousRelationship").'
                ),
                obj=field,
                id='fields.E334',
            ),
        ])

    def test_ambiguous_relationship_model_to(self):

        class Person(models.Model):
            pass

        class Group(models.Model):
            field = models.ManyToManyField('Person', through="AmbiguousRelationship", related_name='tertiary')

        class AmbiguousRelationship(models.Model):
            # Too much foreign keys to Person.
            first_person = models.ForeignKey(Person, models.CASCADE, related_name="first")
            second_person = models.ForeignKey(Person, models.CASCADE, related_name="second")
            second_model = models.ForeignKey(Group, models.CASCADE)

        field = Group._meta.get_field('field')
        self.assertEqual(field.check(from_model=Group), [
            Error(
                "The model is used as an intermediate model by "
                "'invalid_models_tests.Group.field', but it has more than one "
                "foreign key to 'Person', which is ambiguous. You must specify "
                "which foreign key Django should use via the through_fields "
                "keyword argument.",
                hint=(
                    'If you want to create a recursive relationship, use '
                    'ManyToManyField("self", through="AmbiguousRelationship").'
                ),
                obj=field,
                id='fields.E335',
            ),
        ])

    def test_relationship_model_with_foreign_key_to_wrong_model(self):
        class WrongModel(models.Model):
            pass

        class Person(models.Model):
            pass

        class Group(models.Model):
            members = models.ManyToManyField('Person', through="InvalidRelationship")

        class InvalidRelationship(models.Model):
            person = models.ForeignKey(Person, models.CASCADE)
            wrong_foreign_key = models.ForeignKey(WrongModel, models.CASCADE)
            # The last foreign key should point to Group model.

        field = Group._meta.get_field('members')
        self.assertEqual(field.check(from_model=Group), [
            Error(
                "The model is used as an intermediate model by "
                "'invalid_models_tests.Group.members', but it does not "
                "have a foreign key to 'Group' or 'Person'.",
                obj=InvalidRelationship,
                id='fields.E336',
            ),
        ])

    def test_relationship_model_missing_foreign_key(self):
        class Person(models.Model):
            pass

        class Group(models.Model):
            members = models.ManyToManyField('Person', through="InvalidRelationship")

        class InvalidRelationship(models.Model):
            group = models.ForeignKey(Group, models.CASCADE)
            # No foreign key to Person

        field = Group._meta.get_field('members')
        self.assertEqual(field.check(from_model=Group), [
            Error(
                "The model is used as an intermediate model by "
                "'invalid_models_tests.Group.members', but it does not have "
                "a foreign key to 'Group' or 'Person'.",
                obj=InvalidRelationship,
                id='fields.E336',
            ),
        ])

    def test_missing_relationship_model(self):
        class Person(models.Model):
            pass

        class Group(models.Model):
            members = models.ManyToManyField('Person', through="MissingM2MModel")

        field = Group._meta.get_field('members')
        self.assertEqual(field.check(from_model=Group), [
            Error(
                "Field specifies a many-to-many relation through model "
                "'MissingM2MModel', which has not been installed.",
                obj=field,
                id='fields.E331',
            ),
        ])

    def test_missing_relationship_model_on_model_check(self):
        class Person(models.Model):
            pass

        class Group(models.Model):
            members = models.ManyToManyField('Person', through='MissingM2MModel')

        self.assertEqual(Group.check(), [
            Error(
                "Field specifies a many-to-many relation through model "
                "'MissingM2MModel', which has not been installed.",
                obj=Group._meta.get_field('members'),
                id='fields.E331',
            ),
        ])

    @isolate_apps('invalid_models_tests')
    def test_many_to_many_through_isolate_apps_model(self):
        """
        #25723 - Through model registration lookup should be run against the
        field's model registry.
        """
        class GroupMember(models.Model):
            person = models.ForeignKey('Person', models.CASCADE)
            group = models.ForeignKey('Group', models.CASCADE)

        class Person(models.Model):
            pass

        class Group(models.Model):
            members = models.ManyToManyField('Person', through='GroupMember')

        field = Group._meta.get_field('members')
        self.assertEqual(field.check(from_model=Group), [])

    def test_too_many_foreign_keys_in_self_referential_model(self):
        class Person(models.Model):
            friends = models.ManyToManyField('self', through="InvalidRelationship", symmetrical=False)

        class InvalidRelationship(models.Model):
            first = models.ForeignKey(Person, models.CASCADE, related_name="rel_from_set_2")
            second = models.ForeignKey(Person, models.CASCADE, related_name="rel_to_set_2")
            third = models.ForeignKey(Person, models.CASCADE, related_name="too_many_by_far")

        field = Person._meta.get_field('friends')
        self.assertEqual(field.check(from_model=Person), [
            Error(
                "The model is used as an intermediate model by "
                "'invalid_models_tests.Person.friends', but it has more than two "
                "foreign keys to 'Person', which is ambiguous. You must specify "
                "which two foreign keys Django should use via the through_fields "
                "keyword argument.",
                hint='Use through_fields to specify which two foreign keys Django should use.',
                obj=InvalidRelationship,
                id='fields.E333',
            ),
        ])

    def test_foreign_key_to_abstract_model(self):
        class AbstractModel(models.Model):
            class Meta:
                abstract = True

        class Model(models.Model):
            rel_string_foreign_key = models.ForeignKey('AbstractModel', models.CASCADE)
            rel_class_foreign_key = models.ForeignKey(AbstractModel, models.CASCADE)

        fields = [
            Model._meta.get_field('rel_string_foreign_key'),
            Model._meta.get_field('rel_class_foreign_key'),
        ]
        expected_error = Error(
            "Field defines a relation with model 'AbstractModel', "
            "which is either not installed, or is abstract.",
            id='fields.E300',
        )
        for field in fields:
            expected_error.obj = field
            self.assertEqual(field.check(), [expected_error])

    def test_m2m_to_abstract_model(self):
        class AbstractModel(models.Model):
            class Meta:
                abstract = True

        class Model(models.Model):
            rel_string_m2m = models.ManyToManyField('AbstractModel')
            rel_class_m2m = models.ManyToManyField(AbstractModel)

        fields = [
            Model._meta.get_field('rel_string_m2m'),
            Model._meta.get_field('rel_class_m2m'),
        ]
        expected_error = Error(
            "Field defines a relation with model 'AbstractModel', "
            "which is either not installed, or is abstract.",
            id='fields.E300',
        )
        for field in fields:
            expected_error.obj = field
            self.assertEqual(field.check(from_model=Model), [expected_error])

    def test_unique_m2m(self):
        class Person(models.Model):
            name = models.CharField(max_length=5)

        class Group(models.Model):
            members = models.ManyToManyField('Person', unique=True)

        field = Group._meta.get_field('members')
        self.assertEqual(field.check(from_model=Group), [
            Error(
                'ManyToManyFields cannot be unique.',
                obj=field,
                id='fields.E330',
            ),
        ])

    def test_foreign_key_to_non_unique_field(self):
        class Target(models.Model):
            bad = models.IntegerField()  # No unique=True

        class Model(models.Model):
            foreign_key = models.ForeignKey('Target', models.CASCADE, to_field='bad')

        field = Model._meta.get_field('foreign_key')
        self.assertEqual(field.check(), [
            Error(
                "'Target.bad' must be unique because it is referenced by a foreign key.",
                hint=(
                    'Add unique=True to this field or add a UniqueConstraint '
                    '(without condition) in the model Meta.constraints.'
                ),
                obj=field,
                id='fields.E311',
            ),
        ])

    def test_foreign_key_to_non_unique_field_under_explicit_model(self):
        class Target(models.Model):
            bad = models.IntegerField()

        class Model(models.Model):
            field = models.ForeignKey(Target, models.CASCADE, to_field='bad')

        field = Model._meta.get_field('field')
        self.assertEqual(field.check(), [
            Error(
                "'Target.bad' must be unique because it is referenced by a foreign key.",
                hint=(
                    'Add unique=True to this field or add a UniqueConstraint '
                    '(without condition) in the model Meta.constraints.'
                ),
                obj=field,
                id='fields.E311',
            ),
        ])

    def test_foreign_key_to_partially_unique_field(self):
        class Target(models.Model):
            source = models.IntegerField()

            class Meta:
                constraints = [
                    models.UniqueConstraint(
                        fields=['source'],
                        name='tfktpuf_partial_unique',
                        condition=models.Q(pk__gt=2),
                    ),
                ]

        class Model(models.Model):
            field = models.ForeignKey(Target, models.CASCADE, to_field='source')

        field = Model._meta.get_field('field')
        self.assertEqual(field.check(), [
            Error(
                "'Target.source' must be unique because it is referenced by a "
                "foreign key.",
                hint=(
                    'Add unique=True to this field or add a UniqueConstraint '
                    '(without condition) in the model Meta.constraints.'
                ),
                obj=field,
                id='fields.E311',
            ),
        ])

    def test_foreign_key_to_unique_field_with_meta_constraint(self):
        class Target(models.Model):
            source = models.IntegerField()

            class Meta:
                constraints = [
                    models.UniqueConstraint(
                        fields=['source'],
                        name='tfktufwmc_unique',
                    ),
                ]

        class Model(models.Model):
            field = models.ForeignKey(Target, models.CASCADE, to_field='source')

        field = Model._meta.get_field('field')
        self.assertEqual(field.check(), [])

    def test_foreign_object_to_non_unique_fields(self):
        class Person(models.Model):
            # Note that both fields are not unique.
            country_id = models.IntegerField()
            city_id = models.IntegerField()

        class MMembership(models.Model):
            person_country_id = models.IntegerField()
            person_city_id = models.IntegerField()

            person = models.ForeignObject(
                Person,
                on_delete=models.CASCADE,
                from_fields=['person_country_id', 'person_city_id'],
                to_fields=['country_id', 'city_id'],
            )

        field = MMembership._meta.get_field('person')
        self.assertEqual(field.check(), [
            Error(
                "No subset of the fields 'country_id', 'city_id' on model 'Person' is unique.",
                hint=(
                    'Mark a single field as unique=True or add a set of '
                    'fields to a unique constraint (via unique_together or a '
                    'UniqueConstraint (without condition) in the model '
                    'Meta.constraints).'
                ),
                obj=field,
                id='fields.E310',
            )
        ])

    def test_foreign_object_to_partially_unique_field(self):
        class Person(models.Model):
            country_id = models.IntegerField()
            city_id = models.IntegerField()

            class Meta:
                constraints = [
                    models.UniqueConstraint(
                        fields=['country_id', 'city_id'],
                        name='tfotpuf_partial_unique',
                        condition=models.Q(pk__gt=2),
                    ),
                ]

        class MMembership(models.Model):
            person_country_id = models.IntegerField()
            person_city_id = models.IntegerField()
            person = models.ForeignObject(
                Person,
                on_delete=models.CASCADE,
                from_fields=['person_country_id', 'person_city_id'],
                to_fields=['country_id', 'city_id'],
            )

        field = MMembership._meta.get_field('person')
        self.assertEqual(field.check(), [
            Error(
                "No subset of the fields 'country_id', 'city_id' on model "
                "'Person' is unique.",
                hint=(
                    'Mark a single field as unique=True or add a set of '
                    'fields to a unique constraint (via unique_together or a '
                    'UniqueConstraint (without condition) in the model '
                    'Meta.constraints).'
                ),
                obj=field,
                id='fields.E310',
            ),
        ])

    def test_foreign_object_to_unique_field_with_meta_constraint(self):
        class Person(models.Model):
            country_id = models.IntegerField()
            city_id = models.IntegerField()

            class Meta:
                constraints = [
                    models.UniqueConstraint(
                        fields=['country_id', 'city_id'],
                        name='tfotpuf_unique',
                    ),
                ]

        class MMembership(models.Model):
            person_country_id = models.IntegerField()
            person_city_id = models.IntegerField()
            person = models.ForeignObject(
                Person,
                on_delete=models.CASCADE,
                from_fields=['person_country_id', 'person_city_id'],
                to_fields=['country_id', 'city_id'],
            )

        field = MMembership._meta.get_field('person')
        self.assertEqual(field.check(), [])

    def test_on_delete_set_null_on_non_nullable_field(self):
        class Person(models.Model):
            pass

        class Model(models.Model):
            foreign_key = models.ForeignKey('Person', models.SET_NULL)

        field = Model._meta.get_field('foreign_key')
        self.assertEqual(field.check(), [
            Error(
                'Field specifies on_delete=SET_NULL, but cannot be null.',
                hint='Set null=True argument on the field, or change the on_delete rule.',
                obj=field,
                id='fields.E320',
            ),
        ])

    def test_on_delete_set_default_without_default_value(self):
        class Person(models.Model):
            pass

        class Model(models.Model):
            foreign_key = models.ForeignKey('Person', models.SET_DEFAULT)

        field = Model._meta.get_field('foreign_key')
        self.assertEqual(field.check(), [
            Error(
                'Field specifies on_delete=SET_DEFAULT, but has no default value.',
                hint='Set a default value, or change the on_delete rule.',
                obj=field,
                id='fields.E321',
            ),
        ])

    def test_nullable_primary_key(self):
        class Model(models.Model):
            field = models.IntegerField(primary_key=True, null=True)

        field = Model._meta.get_field('field')
        with mock.patch.object(connection.features, 'interprets_empty_strings_as_nulls', False):
            results = field.check()
        self.assertEqual(results, [
            Error(
                'Primary keys must not have null=True.',
                hint='Set null=False on the field, or remove primary_key=True argument.',
                obj=field,
                id='fields.E007',
            ),
        ])

    def test_not_swapped_model(self):
        class SwappableModel(models.Model):
            # A model that can be, but isn't swapped out. References to this
            # model should *not* raise any validation error.
            class Meta:
                swappable = 'TEST_SWAPPABLE_MODEL'

        class Model(models.Model):
            explicit_fk = models.ForeignKey(
                SwappableModel,
                models.CASCADE,
                related_name='explicit_fk',
            )
            implicit_fk = models.ForeignKey(
                'invalid_models_tests.SwappableModel',
                models.CASCADE,
                related_name='implicit_fk',
            )
            explicit_m2m = models.ManyToManyField(SwappableModel, related_name='explicit_m2m')
            implicit_m2m = models.ManyToManyField(
                'invalid_models_tests.SwappableModel',
                related_name='implicit_m2m',
            )

        explicit_fk = Model._meta.get_field('explicit_fk')
        self.assertEqual(explicit_fk.check(), [])

        implicit_fk = Model._meta.get_field('implicit_fk')
        self.assertEqual(implicit_fk.check(), [])

        explicit_m2m = Model._meta.get_field('explicit_m2m')
        self.assertEqual(explicit_m2m.check(from_model=Model), [])

        implicit_m2m = Model._meta.get_field('implicit_m2m')
        self.assertEqual(implicit_m2m.check(from_model=Model), [])

    @override_settings(TEST_SWAPPED_MODEL='invalid_models_tests.Replacement')
    def test_referencing_to_swapped_model(self):
        class Replacement(models.Model):
            pass

        class SwappedModel(models.Model):
            class Meta:
                swappable = 'TEST_SWAPPED_MODEL'

        class Model(models.Model):
            explicit_fk = models.ForeignKey(
                SwappedModel,
                models.CASCADE,
                related_name='explicit_fk',
            )
            implicit_fk = models.ForeignKey(
                'invalid_models_tests.SwappedModel',
                models.CASCADE,
                related_name='implicit_fk',
            )
            explicit_m2m = models.ManyToManyField(SwappedModel, related_name='explicit_m2m')
            implicit_m2m = models.ManyToManyField(
                'invalid_models_tests.SwappedModel',
                related_name='implicit_m2m',
            )

        fields = [
            Model._meta.get_field('explicit_fk'),
            Model._meta.get_field('implicit_fk'),
            Model._meta.get_field('explicit_m2m'),
            Model._meta.get_field('implicit_m2m'),
        ]

        expected_error = Error(
            ("Field defines a relation with the model "
             "'invalid_models_tests.SwappedModel', which has been swapped out."),
            hint="Update the relation to point at 'settings.TEST_SWAPPED_MODEL'.",
            id='fields.E301',
        )

        for field in fields:
            expected_error.obj = field
            self.assertEqual(field.check(from_model=Model), [expected_error])

    def test_related_field_has_invalid_related_name(self):
        digit = 0
        illegal_non_alphanumeric = '!'
        whitespace = '\t'

        invalid_related_names = [
            '%s_begins_with_digit' % digit,
            '%s_begins_with_illegal_non_alphanumeric' % illegal_non_alphanumeric,
            '%s_begins_with_whitespace' % whitespace,
            'contains_%s_illegal_non_alphanumeric' % illegal_non_alphanumeric,
            'contains_%s_whitespace' % whitespace,
            'ends_with_with_illegal_non_alphanumeric_%s' % illegal_non_alphanumeric,
            'ends_with_whitespace_%s' % whitespace,
            'with',  # a Python keyword
            'related_name\n',
            '',
            ',',  # non-ASCII
        ]

        class Parent(models.Model):
            pass

        for invalid_related_name in invalid_related_names:
            Child = type('Child%s' % invalid_related_name, (models.Model,), {
                'parent': models.ForeignKey('Parent', models.CASCADE, related_name=invalid_related_name),
                '__module__': Parent.__module__,
            })

            field = Child._meta.get_field('parent')
            self.assertEqual(Child.check(), [
                Error(
                    "The name '%s' is invalid related_name for field Child%s.parent"
                    % (invalid_related_name, invalid_related_name),
                    hint="Related name must be a valid Python identifier or end with a '+'",
                    obj=field,
                    id='fields.E306',
                ),
            ])

    def test_related_field_has_valid_related_name(self):
        lowercase = 'a'
        uppercase = 'A'
        digit = 0

        related_names = [
            '%s_starts_with_lowercase' % lowercase,
            '%s_tarts_with_uppercase' % uppercase,
            '_starts_with_underscore',
            'contains_%s_digit' % digit,
            'ends_with_plus+',
            '_+',
            '+',
            '試',
            '試驗+',
        ]

        class Parent(models.Model):
            pass

        for related_name in related_names:
            Child = type('Child%s' % related_name, (models.Model,), {
                'parent': models.ForeignKey('Parent', models.CASCADE, related_name=related_name),
                '__module__': Parent.__module__,
            })
            self.assertEqual(Child.check(), [])

    def test_to_fields_exist(self):
        class Parent(models.Model):
            pass

        class Child(models.Model):
            a = models.PositiveIntegerField()
            b = models.PositiveIntegerField()
            parent = models.ForeignObject(
                Parent,
                on_delete=models.SET_NULL,
                from_fields=('a', 'b'),
                to_fields=('a', 'b'),
            )

        field = Child._meta.get_field('parent')
        self.assertEqual(field.check(), [
            Error(
                "The to_field 'a' doesn't exist on the related model 'invalid_models_tests.Parent'.",
                obj=field,
                id='fields.E312',
            ),
            Error(
                "The to_field 'b' doesn't exist on the related model 'invalid_models_tests.Parent'.",
                obj=field,
                id='fields.E312',
            ),
        ])

    def test_to_fields_not_checked_if_related_model_doesnt_exist(self):
        class Child(models.Model):
            a = models.PositiveIntegerField()
            b = models.PositiveIntegerField()
            parent = models.ForeignObject(
                'invalid_models_tests.Parent',
                on_delete=models.SET_NULL,
                from_fields=('a', 'b'),
                to_fields=('a', 'b'),
            )

        field = Child._meta.get_field('parent')
        self.assertEqual(field.check(), [
            Error(
                "Field defines a relation with model 'invalid_models_tests.Parent', "
                "which is either not installed, or is abstract.",
                id='fields.E300',
                obj=field,
            ),
        ])

    def test_invalid_related_query_name(self):
        class Target(models.Model):
            pass

        class Model(models.Model):
            first = models.ForeignKey(Target, models.CASCADE, related_name='contains__double')
            second = models.ForeignKey(Target, models.CASCADE, related_query_name='ends_underscore_')

        self.assertEqual(Model.check(), [
            Error(
                "Reverse query name 'contains__double' must not contain '__'.",
                hint=("Add or change a related_name or related_query_name "
                      "argument for this field."),
                obj=Model._meta.get_field('first'),
                id='fields.E309',
            ),
            Error(
                "Reverse query name 'ends_underscore_' must not end with an "
                "underscore.",
                hint=("Add or change a related_name or related_query_name "
                      "argument for this field."),
                obj=Model._meta.get_field('second'),
                id='fields.E308',
            ),
        ])

@isolate_apps('invalid_models_tests')
class AccessorClashTests(SimpleTestCase):

    def test_fk_to_integer(self):
        self._test_accessor_clash(
            target=models.IntegerField(),
            relative=models.ForeignKey('Target', models.CASCADE))

    def test_fk_to_fk(self):
        self._test_accessor_clash(
            target=models.ForeignKey('Another', models.CASCADE),
            relative=models.ForeignKey('Target', models.CASCADE))

    def test_fk_to_m2m(self):
        self._test_accessor_clash(
            target=models.ManyToManyField('Another'),
            relative=models.ForeignKey('Target', models.CASCADE))

    def test_m2m_to_integer(self):
        self._test_accessor_clash(
            target=models.IntegerField(),
            relative=models.ManyToManyField('Target'))

    def test_m2m_to_fk(self):
        self._test_accessor_clash(
            target=models.ForeignKey('Another', models.CASCADE),
            relative=models.ManyToManyField('Target'))

    def test_m2m_to_m2m(self):
        self._test_accessor_clash(
            target=models.ManyToManyField('Another'),
            relative=models.ManyToManyField('Target'))

    def _test_accessor_clash(self, target, relative):
        class Another(models.Model):
            pass

        class Target(models.Model):
            model_set = target

        class Model(models.Model):
            rel = relative

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Target.model_set' for "
                "'invalid_models_tests.Model.rel' clashes with field name "
                "'invalid_models_tests.Target.model_set'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.model_set', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.rel'."
                ),
                obj=Model._meta.get_field('rel'),
                id='fields.E302',
            ),
        ])

    def test_clash_between_accessors(self):
        class Target(models.Model):
            pass

        class Model(models.Model):
            foreign = models.ForeignKey(Target, models.CASCADE)
            m2m = models.ManyToManyField(Target)

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Target.model_set' for "
                "'invalid_models_tests.Model.foreign' clashes with reverse "
                "accessor for 'invalid_models_tests.Model.m2m'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.foreign' or "
                    "'invalid_models_tests.Model.m2m'."
                ),
                obj=Model._meta.get_field('foreign'),
                id='fields.E304',
            ),
            Error(
                "Reverse accessor 'Target.model_set' for "
                "'invalid_models_tests.Model.m2m' clashes with reverse "
                "accessor for 'invalid_models_tests.Model.foreign'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.m2m' or "
                    "'invalid_models_tests.Model.foreign'."
                ),
                obj=Model._meta.get_field('m2m'),
                id='fields.E304',
            ),
        ])

    def test_m2m_to_m2m_with_inheritance(self):
        """ Ref #22047. """

        class Target(models.Model):
            pass

        class Model(models.Model):
            children = models.ManyToManyField('Child', related_name="m2m_clash", related_query_name="no_clash")

        class Parent(models.Model):
            m2m_clash = models.ManyToManyField('Target')

        class Child(Parent):
            pass

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Child.m2m_clash' for "
                "'invalid_models_tests.Model.children' clashes with field "
                "name 'invalid_models_tests.Child.m2m_clash'.",
                hint=(
                    "Rename field 'invalid_models_tests.Child.m2m_clash', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.children'."
                ),
                obj=Model._meta.get_field('children'),
                id='fields.E302',
            )
        ])

    def test_no_clash_for_hidden_related_name(self):
        class Stub(models.Model):
            pass

        class ManyToManyRel(models.Model):
            thing1 = models.ManyToManyField(Stub, related_name='+')
            thing2 = models.ManyToManyField(Stub, related_name='+')

        class FKRel(models.Model):
            thing1 = models.ForeignKey(Stub, models.CASCADE, related_name='+')
            thing2 = models.ForeignKey(Stub, models.CASCADE, related_name='+')

        self.assertEqual(ManyToManyRel.check(), [])
        self.assertEqual(FKRel.check(), [])

@isolate_apps('invalid_models_tests')
class ReverseQueryNameClashTests(SimpleTestCase):

    def test_fk_to_integer(self):
        self._test_reverse_query_name_clash(
            target=models.IntegerField(),
            relative=models.ForeignKey('Target', models.CASCADE))

    def test_fk_to_fk(self):
        self._test_reverse_query_name_clash(
            target=models.ForeignKey('Another', models.CASCADE),
            relative=models.ForeignKey('Target', models.CASCADE))

    def test_fk_to_m2m(self):
        self._test_reverse_query_name_clash(
            target=models.ManyToManyField('Another'),
            relative=models.ForeignKey('Target', models.CASCADE))

    def test_m2m_to_integer(self):
        self._test_reverse_query_name_clash(
            target=models.IntegerField(),
            relative=models.ManyToManyField('Target'))

    def test_m2m_to_fk(self):
        self._test_reverse_query_name_clash(
            target=models.ForeignKey('Another', models.CASCADE),
            relative=models.ManyToManyField('Target'))

    def test_m2m_to_m2m(self):
        self._test_reverse_query_name_clash(
            target=models.ManyToManyField('Another'),
            relative=models.ManyToManyField('Target'))

    def _test_reverse_query_name_clash(self, target, relative):
        class Another(models.Model):
            pass

        class Target(models.Model):
            model = target

        class Model(models.Model):
            rel = relative

        self.assertEqual(Model.check(), [
            Error(
                "Reverse query name for 'invalid_models_tests.Model.rel' "
                "clashes with field name 'invalid_models_tests.Target.model'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.model', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.rel'."
                ),
                obj=Model._meta.get_field('rel'),
                id='fields.E303',
            ),
        ])

    @modify_settings(INSTALLED_APPS={'append': 'basic'})
    @isolate_apps('basic', 'invalid_models_tests')
    def test_no_clash_across_apps_without_accessor(self):
        class Target(models.Model):
            class Meta:
                app_label = 'invalid_models_tests'

        class Model(models.Model):
            m2m = models.ManyToManyField(Target, related_name='+')

            class Meta:
                app_label = 'basic'

        def _test():
            # Define model with the same name.
            class Model(models.Model):
                m2m = models.ManyToManyField(Target, related_name='+')

                class Meta:
                    app_label = 'invalid_models_tests'

            self.assertEqual(Model.check(), [])

        _test()
        self.assertEqual(Model.check(), [])

@isolate_apps('invalid_models_tests')
class ExplicitRelatedNameClashTests(SimpleTestCase):

    def test_fk_to_integer(self):
        self._test_explicit_related_name_clash(
            target=models.IntegerField(),
            relative=models.ForeignKey('Target', models.CASCADE, related_name='clash'))

    def test_fk_to_fk(self):
        self._test_explicit_related_name_clash(
            target=models.ForeignKey('Another', models.CASCADE),
            relative=models.ForeignKey('Target', models.CASCADE, related_name='clash'))

    def test_fk_to_m2m(self):
        self._test_explicit_related_name_clash(
            target=models.ManyToManyField('Another'),
            relative=models.ForeignKey('Target', models.CASCADE, related_name='clash'))

    def test_m2m_to_integer(self):
        self._test_explicit_related_name_clash(
            target=models.IntegerField(),
            relative=models.ManyToManyField('Target', related_name='clash'))

    def test_m2m_to_fk(self):
        self._test_explicit_related_name_clash(
            target=models.ForeignKey('Another', models.CASCADE),
            relative=models.ManyToManyField('Target', related_name='clash'))

    def test_m2m_to_m2m(self):
        self._test_explicit_related_name_clash(
            target=models.ManyToManyField('Another'),
            relative=models.ManyToManyField('Target', related_name='clash'))

    def _test_explicit_related_name_clash(self, target, relative):
        class Another(models.Model):
            pass

        class Target(models.Model):
            clash = target

        class Model(models.Model):
            rel = relative

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Target.clash' for "
                "'invalid_models_tests.Model.rel' clashes with field name "
                "'invalid_models_tests.Target.clash'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.clash', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.rel'."
                ),
                obj=Model._meta.get_field('rel'),
                id='fields.E302',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.rel' "
                "clashes with field name 'invalid_models_tests.Target.clash'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.clash', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.rel'."
                ),
                obj=Model._meta.get_field('rel'),
                id='fields.E303',
            ),
        ])

@isolate_apps('invalid_models_tests')
class ExplicitRelatedQueryNameClashTests(SimpleTestCase):

    def test_fk_to_integer(self, related_name=None):
        self._test_explicit_related_query_name_clash(
            target=models.IntegerField(),
            relative=models.ForeignKey(
                'Target',
                models.CASCADE,
                related_name=related_name,
                related_query_name='clash',
            )
        )

    def test_hidden_fk_to_integer(self, related_name=None):
        self.test_fk_to_integer(related_name='+')

    def test_fk_to_fk(self, related_name=None):
        self._test_explicit_related_query_name_clash(
            target=models.ForeignKey('Another', models.CASCADE),
            relative=models.ForeignKey(
                'Target',
                models.CASCADE,
                related_name=related_name,
                related_query_name='clash',
            )
        )

    def test_hidden_fk_to_fk(self):
        self.test_fk_to_fk(related_name='+')

    def test_fk_to_m2m(self, related_name=None):
        self._test_explicit_related_query_name_clash(
            target=models.ManyToManyField('Another'),
            relative=models.ForeignKey(
                'Target',
                models.CASCADE,
                related_name=related_name,
                related_query_name='clash',
            )
        )

    def test_hidden_fk_to_m2m(self):
        self.test_fk_to_m2m(related_name='+')

    def test_m2m_to_integer(self, related_name=None):
        self._test_explicit_related_query_name_clash(
            target=models.IntegerField(),
            relative=models.ManyToManyField('Target', related_name=related_name, related_query_name='clash'))

    def test_hidden_m2m_to_integer(self):
        self.test_m2m_to_integer(related_name='+')

    def test_m2m_to_fk(self, related_name=None):
        self._test_explicit_related_query_name_clash(
            target=models.ForeignKey('Another', models.CASCADE),
            relative=models.ManyToManyField('Target', related_name=related_name, related_query_name='clash'))

    def test_hidden_m2m_to_fk(self):
        self.test_m2m_to_fk(related_name='+')

    def test_m2m_to_m2m(self, related_name=None):
        self._test_explicit_related_query_name_clash(
            target=models.ManyToManyField('Another'),
            relative=models.ManyToManyField(
                'Target',
                related_name=related_name,
                related_query_name='clash',
            )
        )

    def test_hidden_m2m_to_m2m(self):
        self.test_m2m_to_m2m(related_name='+')

    def _test_explicit_related_query_name_clash(self, target, relative):
        class Another(models.Model):
            pass

        class Target(models.Model):
            clash = target

        class Model(models.Model):
            rel = relative

        self.assertEqual(Model.check(), [
            Error(
                "Reverse query name for 'invalid_models_tests.Model.rel' "
                "clashes with field name 'invalid_models_tests.Target.clash'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.clash', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.rel'."
                ),
                obj=Model._meta.get_field('rel'),
                id='fields.E303',
            ),
        ])

@isolate_apps('invalid_models_tests')
class SelfReferentialM2MClashTests(SimpleTestCase):

    def test_clash_between_accessors(self):
        class Model(models.Model):
            first_m2m = models.ManyToManyField('self', symmetrical=False)
            second_m2m = models.ManyToManyField('self', symmetrical=False)

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Model.model_set' for "
                "'invalid_models_tests.Model.first_m2m' clashes with reverse "
                "accessor for 'invalid_models_tests.Model.second_m2m'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.first_m2m' or "
                    "'invalid_models_tests.Model.second_m2m'."
                ),
                obj=Model._meta.get_field('first_m2m'),
                id='fields.E304',
            ),
            Error(
                "Reverse accessor 'Model.model_set' for "
                "'invalid_models_tests.Model.second_m2m' clashes with reverse "
                "accessor for 'invalid_models_tests.Model.first_m2m'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.second_m2m' or "
                    "'invalid_models_tests.Model.first_m2m'."
                ),
                obj=Model._meta.get_field('second_m2m'),
                id='fields.E304',
            ),
        ])

    def test_accessor_clash(self):
        class Model(models.Model):
            model_set = models.ManyToManyField("self", symmetrical=False)

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Model.model_set' for "
                "'invalid_models_tests.Model.model_set' clashes with field "
                "name 'invalid_models_tests.Model.model_set'.",
                hint=(
                    "Rename field 'invalid_models_tests.Model.model_set', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.model_set'."
                ),
                obj=Model._meta.get_field('model_set'),
                id='fields.E302',
            ),
        ])

    def test_reverse_query_name_clash(self):
        class Model(models.Model):
            model = models.ManyToManyField("self", symmetrical=False)

        self.assertEqual(Model.check(), [
            Error(
                "Reverse query name for 'invalid_models_tests.Model.model' "
                "clashes with field name 'invalid_models_tests.Model.model'.",
                hint=(
                    "Rename field 'invalid_models_tests.Model.model', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.model'."
                ),
                obj=Model._meta.get_field('model'),
                id='fields.E303',
            ),
        ])

    def test_clash_under_explicit_related_name(self):
        class Model(models.Model):
            clash = models.IntegerField()
            m2m = models.ManyToManyField("self", symmetrical=False, related_name='clash')

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Model.clash' for "
                "'invalid_models_tests.Model.m2m' clashes with field name "
                "'invalid_models_tests.Model.clash'.",
                hint=(
                    "Rename field 'invalid_models_tests.Model.clash', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.m2m'."
                ),
                obj=Model._meta.get_field('m2m'),
                id='fields.E302',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.m2m' "
                "clashes with field name 'invalid_models_tests.Model.clash'.",
                hint=(
                    "Rename field 'invalid_models_tests.Model.clash', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.m2m'."
                ),
                obj=Model._meta.get_field('m2m'),
                id='fields.E303',
            ),
        ])

    def test_valid_model(self):
        class Model(models.Model):
            first = models.ManyToManyField("self", symmetrical=False, related_name='first_accessor')
            second = models.ManyToManyField("self", symmetrical=False, related_name='second_accessor')

        self.assertEqual(Model.check(), [])

@isolate_apps('invalid_models_tests')
class SelfReferentialFKClashTests(SimpleTestCase):

    def test_accessor_clash(self):
        class Model(models.Model):
            model_set = models.ForeignKey("Model", models.CASCADE)

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Model.model_set' for "
                "'invalid_models_tests.Model.model_set' clashes with field "
                "name 'invalid_models_tests.Model.model_set'.",
                hint=(
                    "Rename field 'invalid_models_tests.Model.model_set', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.model_set'."
                ),
                obj=Model._meta.get_field('model_set'),
                id='fields.E302',
            ),
        ])

    def test_reverse_query_name_clash(self):
        class Model(models.Model):
            model = models.ForeignKey("Model", models.CASCADE)

        self.assertEqual(Model.check(), [
            Error(
                "Reverse query name for 'invalid_models_tests.Model.model' "
                "clashes with field name 'invalid_models_tests.Model.model'.",
                hint=(
                    "Rename field 'invalid_models_tests.Model.model', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.model'."
                ),
                obj=Model._meta.get_field('model'),
                id='fields.E303',
            ),
        ])

    def test_clash_under_explicit_related_name(self):
        class Model(models.Model):
            clash = models.CharField(max_length=10)
            foreign = models.ForeignKey("Model", models.CASCADE, related_name='clash')

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Model.clash' for "
                "'invalid_models_tests.Model.foreign' clashes with field name "
                "'invalid_models_tests.Model.clash'.",
                hint=(
                    "Rename field 'invalid_models_tests.Model.clash', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.foreign'."
                ),
                obj=Model._meta.get_field('foreign'),
                id='fields.E302',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.foreign' "
                "clashes with field name 'invalid_models_tests.Model.clash'.",
                hint=(
                    "Rename field 'invalid_models_tests.Model.clash', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.foreign'."
                ),
                obj=Model._meta.get_field('foreign'),
                id='fields.E303',
            ),
        ])

@isolate_apps('invalid_models_tests')
class ComplexClashTests(SimpleTestCase):

    # New tests should not be included here, because this is a single,
    # self-contained sanity check, not a test of everything.
    def test_complex_clash(self):
        class Target(models.Model):
            tgt_safe = models.CharField(max_length=10)
            clash = models.CharField(max_length=10)
            model = models.CharField(max_length=10)

            clash1_set = models.CharField(max_length=10)

        class Model(models.Model):
            src_safe = models.CharField(max_length=10)

            foreign_1 = models.ForeignKey(Target, models.CASCADE, related_name='id')
            foreign_2 = models.ForeignKey(Target, models.CASCADE, related_name='src_safe')

            m2m_1 = models.ManyToManyField(Target, related_name='id')
            m2m_2 = models.ManyToManyField(Target, related_name='src_safe')

        self.assertEqual(Model.check(), [
            Error(
                "Reverse accessor 'Target.id' for "
                "'invalid_models_tests.Model.foreign_1' clashes with field "
                "name 'invalid_models_tests.Target.id'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.id', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.foreign_1'."
                ),
                obj=Model._meta.get_field('foreign_1'),
                id='fields.E302',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.foreign_1' "
                "clashes with field name 'invalid_models_tests.Target.id'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.id', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.foreign_1'."
                ),
                obj=Model._meta.get_field('foreign_1'),
                id='fields.E303',
            ),
            Error(
                "Reverse accessor 'Target.id' for "
                "'invalid_models_tests.Model.foreign_1' clashes with reverse "
                "accessor for 'invalid_models_tests.Model.m2m_1'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.foreign_1' or "
                    "'invalid_models_tests.Model.m2m_1'."
                ),
                obj=Model._meta.get_field('foreign_1'),
                id='fields.E304',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.foreign_1' "
                "clashes with reverse query name for "
                "'invalid_models_tests.Model.m2m_1'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.foreign_1' or "
                    "'invalid_models_tests.Model.m2m_1'."
                ),
                obj=Model._meta.get_field('foreign_1'),
                id='fields.E305',
            ),

            Error(
                "Reverse accessor 'Target.src_safe' for "
                "'invalid_models_tests.Model.foreign_2' clashes with reverse "
                "accessor for 'invalid_models_tests.Model.m2m_2'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.foreign_2' or "
                    "'invalid_models_tests.Model.m2m_2'."
                ),
                obj=Model._meta.get_field('foreign_2'),
                id='fields.E304',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.foreign_2' "
                "clashes with reverse query name for "
                "'invalid_models_tests.Model.m2m_2'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.foreign_2' or "
                    "'invalid_models_tests.Model.m2m_2'."
                ),
                obj=Model._meta.get_field('foreign_2'),
                id='fields.E305',
            ),

            Error(
                "Reverse accessor 'Target.id' for "
                "'invalid_models_tests.Model.m2m_1' clashes with field name "
                "'invalid_models_tests.Target.id'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.id', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.m2m_1'."
                ),
                obj=Model._meta.get_field('m2m_1'),
                id='fields.E302',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.m2m_1' "
                "clashes with field name 'invalid_models_tests.Target.id'.",
                hint=(
                    "Rename field 'invalid_models_tests.Target.id', or "
                    "add/change a related_name argument to the definition for "
                    "field 'invalid_models_tests.Model.m2m_1'."
                ),
                obj=Model._meta.get_field('m2m_1'),
                id='fields.E303',
            ),
            Error(
                "Reverse accessor 'Target.id' for "
                "'invalid_models_tests.Model.m2m_1' clashes with reverse "
                "accessor for 'invalid_models_tests.Model.foreign_1'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.m2m_1' or "
                    "'invalid_models_tests.Model.foreign_1'."
                ),
                obj=Model._meta.get_field('m2m_1'),
                id='fields.E304',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.m2m_1' "
                "clashes with reverse query name for "
                "'invalid_models_tests.Model.foreign_1'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.m2m_1' or "
                    "'invalid_models_tests.Model.foreign_1'."
                ),
                obj=Model._meta.get_field('m2m_1'),
                id='fields.E305',
            ),
            Error(
                "Reverse accessor 'Target.src_safe' for "
                "'invalid_models_tests.Model.m2m_2' clashes with reverse "
                "accessor for 'invalid_models_tests.Model.foreign_2'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.m2m_2' or "
                    "'invalid_models_tests.Model.foreign_2'."
                ),
                obj=Model._meta.get_field('m2m_2'),
                id='fields.E304',
            ),
            Error(
                "Reverse query name for 'invalid_models_tests.Model.m2m_2' "
                "clashes with reverse query name for "
                "'invalid_models_tests.Model.foreign_2'.",
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Model.m2m_2' or "
                    "'invalid_models_tests.Model.foreign_2'."
                ),
                obj=Model._meta.get_field('m2m_2'),
                id='fields.E305',
            ),
        ])

    def test_clash_parent_link(self):
        class Parent(models.Model):
            pass

        class Child(Parent):
            other_parent = models.OneToOneField(Parent, models.CASCADE)

        errors = [
            ('fields.E304', 'accessor', " 'Parent.child'", 'parent_ptr', 'other_parent'),
            ('fields.E305', 'query name', '', 'parent_ptr', 'other_parent'),
            ('fields.E304', 'accessor', " 'Parent.child'", 'other_parent', 'parent_ptr'),
            ('fields.E305', 'query name', '', 'other_parent', 'parent_ptr'),
        ]
        self.assertEqual(Child.check(), [
            Error(
                "Reverse %s%s for 'invalid_models_tests.Child.%s' clashes with "
                "reverse %s for 'invalid_models_tests.Child.%s'."
                % (attr, rel_name, field_name, attr, clash_name),
                hint=(
                    "Add or change a related_name argument to the definition "
                    "for 'invalid_models_tests.Child.%s' or "
                    "'invalid_models_tests.Child.%s'." % (field_name, clash_name)
                ),
                obj=Child._meta.get_field(field_name),
                id=error_id,
            )
            for error_id, attr, rel_name, field_name, clash_name in errors
        ])

@isolate_apps('invalid_models_tests')
class M2mThroughFieldsTests(SimpleTestCase):
    def test_m2m_field_argument_validation(self):
        """
        ManyToManyField accepts the ``through_fields`` kwarg
        only if an intermediary table is specified.
        """
        class Fan(models.Model):
            pass

        with self.assertRaisesMessage(ValueError, 'Cannot specify through_fields without a through model'):
            models.ManyToManyField(Fan, through_fields=('f1', 'f2'))

    def test_invalid_order(self):
        """
        Mixing up the order of link fields to ManyToManyField.through_fields
        triggers validation errors.
        """
        class Fan(models.Model):
            pass

        class Event(models.Model):
            invitees = models.ManyToManyField(Fan, through='Invitation', through_fields=('invitee', 'event'))

        class Invitation(models.Model):
            event = models.ForeignKey(Event, models.CASCADE)
            invitee = models.ForeignKey(Fan, models.CASCADE)
            inviter = models.ForeignKey(Fan, models.CASCADE, related_name='+')

        field = Event._meta.get_field('invitees')
        self.assertEqual(field.check(from_model=Event), [
            Error(
                "'Invitation.invitee' is not a foreign key to 'Event'.",
                hint="Did you mean one of the following foreign keys to 'Event': event?",
                obj=field,
                id='fields.E339',
            ),
            Error(
                "'Invitation.event' is not a foreign key to 'Fan'.",
                hint="Did you mean one of the following foreign keys to 'Fan': invitee, inviter?",
                obj=field,
                id='fields.E339',
            ),
        ])

    def test_invalid_field(self):
        """
        Providing invalid field names to ManyToManyField.through_fields
        triggers validation errors.
        """
        class Fan(models.Model):
            pass

        class Event(models.Model):
            invitees = models.ManyToManyField(
                Fan,
                through='Invitation',
                through_fields=('invalid_field_1', 'invalid_field_2'),
            )

        class Invitation(models.Model):
            event = models.ForeignKey(Event, models.CASCADE)
            invitee = models.ForeignKey(Fan, models.CASCADE)
            inviter = models.ForeignKey(Fan, models.CASCADE, related_name='+')

        field = Event._meta.get_field('invitees')
        self.assertEqual(field.check(from_model=Event), [
            Error(
                "The intermediary model 'invalid_models_tests.Invitation' has no field 'invalid_field_1'.",
                hint="Did you mean one of the following foreign keys to 'Event': event?",
                obj=field,
                id='fields.E338',
            ),
            Error(
                "The intermediary model 'invalid_models_tests.Invitation' has no field 'invalid_field_2'.",
                hint="Did you mean one of the following foreign keys to 'Fan': invitee, inviter?",
                obj=field,
                id='fields.E338',
            ),
        ])

    def test_explicit_field_names(self):
        """
        If ``through_fields`` kwarg is given, it must specify both
        link fields of the intermediary table.
        """
        class Fan(models.Model):
            pass

        class Event(models.Model):
            invitees = models.ManyToManyField(Fan, through='Invitation', through_fields=(None, 'invitee'))

        class Invitation(models.Model):
            event = models.ForeignKey(Event, models.CASCADE)
            invitee = models.ForeignKey(Fan, models.CASCADE)
            inviter = models.ForeignKey(Fan, models.CASCADE, related_name='+')

        field = Event._meta.get_field('invitees')
        self.assertEqual(field.check(from_model=Event), [
            Error(
                "Field specifies 'through_fields' but does not provide the names "
                "of the two link fields that should be used for the relation "
                "through model 'invalid_models_tests.Invitation'.",
                hint="Make sure you specify 'through_fields' as through_fields=('field1', 'field2')",
                obj=field,
                id='fields.E337',
            ),
        ])

    def test_superset_foreign_object(self):
        class Parent(models.Model):
            a = models.PositiveIntegerField()
            b = models.PositiveIntegerField()
            c = models.PositiveIntegerField()

            class Meta:
                unique_together = (('a', 'b', 'c'),)

        class Child(models.Model):
            a = models.PositiveIntegerField()
            b = models.PositiveIntegerField()
            value = models.CharField(max_length=255)
            parent = models.ForeignObject(
                Parent,
                on_delete=models.SET_NULL,
                from_fields=('a', 'b'),
                to_fields=('a', 'b'),
                related_name='children',
            )

        field = Child._meta.get_field('parent')
        self.assertEqual(field.check(from_model=Child), [
            Error(
                "No subset of the fields 'a', 'b' on model 'Parent' is unique.",
                hint=(
                    'Mark a single field as unique=True or add a set of '
                    'fields to a unique constraint (via unique_together or a '
                    'UniqueConstraint (without condition) in the model '
                    'Meta.constraints).'
                ),
                obj=field,
                id='fields.E310',
            ),
        ])

    def test_intersection_foreign_object(self):
        class Parent(models.Model):
            a = models.PositiveIntegerField()
            b = models.PositiveIntegerField()
            c = models.PositiveIntegerField()
            d = models.PositiveIntegerField()

            class Meta:
                unique_together = (('a', 'b', 'c'),)

        class Child(models.Model):
            a = models.PositiveIntegerField()
            b = models.PositiveIntegerField()
            d = models.PositiveIntegerField()
            value = models.CharField(max_length=255)
            parent = models.ForeignObject(
                Parent,
                on_delete=models.SET_NULL,
                from_fields=('a', 'b', 'd'),
                to_fields=('a', 'b', 'd'),
                related_name='children',
            )

        field = Child._meta.get_field('parent')
        self.assertEqual(field.check(from_model=Child), [
            Error(
                "No subset of the fields 'a', 'b', 'd' on model 'Parent' is unique.",
                hint=(
                    'Mark a single field as unique=True or add a set of '
                    'fields to a unique constraint (via unique_together or a '
                    'UniqueConstraint (without condition) in the model '
                    'Meta.constraints).'
                ),
                obj=field,
                id='fields.E310',
            ),
        ])


text:
> An array of replacement patterns for custom symbols can be passed as a second parameter

```js
symbols.process( String, patterns );
```

Replacement patterns follow this format:

```js
var patterns = [
  {
    pattern: /foo/, // the pattern to replace
    replacement: 'bar' // the replacement. can be a string or a function.
  }
];
```

## Example

This is the pattern and replacement used to for alerts:

```js
var patterns = [
  {
    pattern: symbols.makeDelims(['!!', '!!']),
    replacement: function (match, inner) {
      var arr = inner.split('|');
      var text = arr[0];
      var modifier = arr[1] ? ' alert-' + arr[1] : '';
      return '<span class="alert' + modifier + '">' + text + '</span>';
    }
  }
];
```
Take a look at [index.js](./index.js) to see how the others are created.

## .makeDelims()

For patterns, the `makeDelims` utility method is a convenience for more easily creating custom symbols:

```js
symbols.makeDelims(['!!', '!!'])
```

The [delims](https://github.com/jonschlinkert/delims) library is used to create delimiters, visit that project to learn about usage and available options.


text:
<?php

namespace ephFrame\core;

class Library
{
	protected static $paths = array(
		'ephFrame' => '',
	);

	public static function add($namespace, $path)
	{
		$realpath = realpath($path);
		if (!is_dir($realpath)) {
			throw new LibraryPathNotFoundException($path);
		}
		self::$paths[$namespace] = $realpath;
		return true;
	}

	public static function load($path)
	{
		foreach(self::$paths as $namespace => $libPath) {
			if (strncasecmp($path, $namespace, strlen($namespace)) === 0) {
				$path = $libPath.DIRECTORY_SEPARATOR.substr(str_replace('\\', DIRECTORY_SEPARATOR, $path), strlen($namespace)+1).'.php';
				break;
			}
		}
		if (is_file($path)) {
			return require $path;
		}
		return false;
	}

	public static function register()
	{
		spl_autoload_register(array($this, 'load'), true, true);
	}
}

spl_autoload_register('\ephFrame\core\Library::load');

class LibraryException extends \Exception {}

class LibraryPathNotFoundException extends LibraryException
{
	public function __construct($filename)
	{
		return parent::__construct(sprintf('Path "%s" could not be found.', $filename));
	}
}


text:
#ifndef WEBRTC_BASE_FORMAT_MACROS_H_
#define WEBRTC_BASE_FORMAT_MACROS_H_

// This file defines the format macros for some integer types and is derived
// from Chromium's base/format_macros.h.

// To print a 64-bit value in a portable way:
//   int64_t value;
//   printf("xyz:%" PRId64, value);
// The "d" in the macro corresponds to %d; you can also use PRIu64 etc.
//
// To print a size_t value in a portable way:
//   size_t size;
//   printf("xyz: %" PRIuS, size);
// The "u" in the macro corresponds to %u, and S is for "size".

#include "webrtc/typedefs.h"

#if defined(WEBRTC_POSIX)

#if (defined(_INTTYPES_H) || defined(_INTTYPES_H_)) && !defined(PRId64)
#error "inttypes.h has already been included before this header file, but "
#error "without __STDC_FORMAT_MACROS defined."
#endif

#if !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
#endif

#include <inttypes.h>

#if !defined(PRIuS)
#define PRIuS "zu"
#endif

// The size of NSInteger and NSUInteger varies between 32-bit and 64-bit
// architectures and Apple does not provides standard format macros and
// recommends casting. This has many drawbacks, so instead define macros
// for formatting those types.
#if defined(WEBRTC_MAC)
#if defined(WEBRTC_ARCH_64_BITS)
#if !defined(PRIdNS)
#define PRIdNS "ld"
#endif
#if !defined(PRIuNS)
#define PRIuNS "lu"
#endif
#if !defined(PRIxNS)
#define PRIxNS "lx"
#endif
#else  // defined(WEBRTC_ARCH_64_BITS)
#if !defined(PRIdNS)
#define PRIdNS "d"
#endif
#if !defined(PRIuNS)
#define PRIuNS "u"
#endif
#if !defined(PRIxNS)
#define PRIxNS "x"
#endif
#endif
#endif  // defined(WEBRTC_MAC)

#else  // WEBRTC_WIN

#include <inttypes.h>

#if !defined(PRId64)
#define PRId64 "I64d"
#endif

#if !defined(PRIu64)
#define PRIu64 "I64u"
#endif

#if !defined(PRIx64)
#define PRIx64 "I64x"
#endif

#if !defined(PRIuS)
#define PRIuS "Iu"
#endif

#endif

#endif  // WEBRTC_BASE_FORMAT_MACROS_H_


text:
struct __attribute__((packed)) gdb_registers {
	union {
		uint64_t x;
		uint32_t w;
	} x[31];
	uint64_t sp;
	uint64_t pc;
	uint32_t cpsr;
	union {
		uint64_t q[2];
		double d;
		float s;
	} v[32];
	uint32_t fpsr;
	uint32_t fpcr;
};

// A type for register IDs.
typedef uint16_t reg_id_t;

// An invalid register ID.
#define INVALID_REG_ID	((reg_id_t)(-1))

// Information describing a register to GDB.
struct gdb_register_info {
	const char *name;		// The register's name.
	const char *altname;		// An alternative name for the register.
	uint8_t generic;		// The GDB generic name of this register.
	uint8_t type;			// The GDB type of this register.
	uint8_t encoding;		// The GDB encoding of this register.
	uint8_t format;			// The GDB format of this register.
	uint8_t group;			// The GDB group of this register.
	uint8_t set;			// The register set to which this register belongs.
	uint16_t offset;		// The offset in the struct gdb_registers.
	uint16_t bitsize;		// The size of this register in bits.
	reg_id_t ehframe_reg;		// The exception handler frame register number.
	reg_id_t dwarf_reg;		// The DWARF register number.
	reg_id_t value_regs[4];		// A list of registers that contain this register.
	reg_id_t invalidate_regs[4];	// A list of registers to invalidate if this one is set.
};

// The list of gdb_register_info structs.
extern const struct gdb_register_info gdb_register_info[];
extern const unsigned gdb_register_count;

// Lookup tables for the string values of the generic, type, encoding, format, and group fields.
extern const char *const gdb_register_generic_name[];
extern const char *const gdb_register_type_name[];
extern const char *const gdb_register_encoding_name[];
extern const char *const gdb_register_format_name[];
extern const char *const gdb_register_group_name[];

// Information describing a register set to GDB.
struct gdb_register_set_info {
	const char *description;
};

// The list of register sets.
extern const struct gdb_register_set_info gdb_register_set_info[];
extern const unsigned gdb_register_set_count;

#endif


text:
<?php
  get_header();
?>

<?php if ( have_posts() ) : ?>

              <?php while ( have_posts() ) : the_post(); ?>
              <?php
                $channel = get_post_meta( get_the_ID(), 'channel', true );

                $image_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' )[0];

                $response = get_donations($channel);
                $total = $response['total'];
                $kids_helped_count = floor( intval( $response['total'] ) / 250 ) ;
                $target=get_post_meta( get_the_ID(), 'target', true);
                $target=isset($target)?$target:1000;

              ?>

                <div class="mdl-card__title mdl-card--expand mdl-color--teal-300" style="background:url('<?php echo ( $image_url ) ?>') center / cover;">

		  <?php if ( isset($target) && !empty($target) && $target!='0' ) { ?>

<?php echo $target; ?>  USD Target

		   <?php } else { ?>

		   <?php }?>

<?php echo intval( $total ); ?> USD raised

<?php echo( $response['count']); ?> Supporters

                  <a href="<?php echo post_permalink(); ?>" class="mdl-button mdl-js-button mdl-js-ripple-effect"><?php explode(' ', the_title(), 2); ?>

              <?php endwhile; ?>

<?php endif; ?>
<?php get_footer(); ?>


text:
package appModel.renderProject;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

import javafx.application.Platform;
import photonApi.FrameRegion;
import photonApi.FrameStatus;
import photonApi.PhEngine;
import photonApi.PhFrame;
import photonApi.Rectangle;

/**
 * A query that can peek into frames while they are still rendering. The
 * result will be presented by the associating view.
 */
public class RenderFrameQuery implements Runnable
{
	private static final long MIN_DELAY_MS = 50;
	private static final long MAX_DELAY_MS = 2000;

	private PhEngine                 m_engine;
	private PhFrame                  m_peekingFrame;
	private RenderFrameView          m_view;

	private ScheduledExecutorService m_executor;
	private long                     m_currentQueryDelayMs;
	private volatile int             m_channelIndex;
	private volatile boolean         m_isCancelRequested;

	/**
	 * Constructs a query that can be scheduled by external routines.
	 */
	public RenderFrameQuery(
		PhEngine        engine,
		PhFrame         peekingFrame,
		RenderFrameView view)
	{
		m_engine              = engine;
		m_peekingFrame        = peekingFrame;
		m_view                = view;

		m_executor            = null;
		m_currentQueryDelayMs = MIN_DELAY_MS;
		m_channelIndex        = 0;
		m_isCancelRequested   = false;
	}

	public void scheduleAdaptively(ScheduledExecutorService executor)
	{
		m_executor            = executor;
		m_currentQueryDelayMs = MIN_DELAY_MS;
		m_isCancelRequested   = false;

		m_executor.submit(this);
	}

	/**
	 * Thread-safe
	 */
	public void setChannel(int channelIndex)
	{
		assert(channelIndex >= 0);

		m_channelIndex = channelIndex;
	}

	/**
	 * Thread-safe
	 */
	public void cancelAdaptivelyScheduled()
	{
		m_isCancelRequested = true;
	}

	@Override
	public void run()
	{
		// Scheduled executors will silently consumes errors and stop running,
		// at least we can get an error message by this try-catch block.
		try
		{
			query();
		}
		catch(Throwable t)
		{
			t.printStackTrace();
		}
	}

	private void query()
	{
		Rectangle updatedRegion = new Rectangle();
		FrameStatus status = m_engine.asyncPeekUpdatedFrame(m_channelIndex, m_peekingFrame, updatedRegion);
		if(status != FrameStatus.INVALID)
		{
			FrameRegion updatedFrameRegion = m_peekingFrame.copyRegionRgb(updatedRegion);
			Platform.runLater(() ->
			{
				m_view.showPeeked(updatedFrameRegion, status);
			});
		}

		if(m_executor != null && !m_isCancelRequested)
		{
			if(status == FrameStatus.INVALID)
			{
				// increase delay linearly if no updated frame is retrieved
				m_currentQueryDelayMs = Math.min(m_currentQueryDelayMs + MIN_DELAY_MS, MAX_DELAY_MS);
			}
			else
			{
				// decrease delay exponentially if updated frame is retrieved
				m_currentQueryDelayMs = Math.max(m_currentQueryDelayMs / 2, MIN_DELAY_MS);
			}

			m_executor.schedule(this, m_currentQueryDelayMs, TimeUnit.MILLISECONDS);
		}
	}
}


text:
// Copyright 2009 the Sputnik authors.  All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/**
* @name: S12.6.2_A4_T3;
* @section: 12.6.2, 12.2;
* @assertion: "break" within a "while" Statement is allowed and performed as described in 12.8;
* @description: "break" and VariableDeclaration within a "while" Statement;
*/

do_out : while(1===1) {
    if (__in__do__before__break) break;
    var __in__do__before__break="once";
    do_in : while (1) {
        var __in__do__IN__before__break="in";
        break do_out;
        var __in__do__IN__after__break="the";
    } ;
    var __in__do__after__break="lifetime";
} ;

//////////////////////////////////////////////////////////////////////////////
//CHECK#1
if (!(__in__do__before__break&&__in__do__IN__before__break&&!__in__do__IN__after__break&&!__in__do__after__break)) {
	$ERROR('#1: Break inside do-while is allowed as its described at standard');
}
//
//////////////////////////////////////////////////////////////////////////////


text:
A Pen created at CodePen.io. You can find this one at http://codepen.io/mattjuggins/pen/WGRRYx.

 A circular calendar and clock display, with and added weather and daily activity widget mock-ups.


text:
import React from 'react';
import { shallow } from 'enzyme';

import CheckBox from './CheckBox';

describe('RadioButton Unit Test', () => {
    it('should render correctly', () => {
        const check = shallow(<CheckBox name="test" label="test" />);
        expect(check.text()).toEqual('test');
        expect(check.find('input').props().checked).toEqual(false);
    });
    it('should change state', () => {
        const check = shallow(<CheckBox name="test" value="test" />);
        check.find('input').simulate('click');
        expect(check.find('input').props().checked).toEqual(true);
    });
});


text:
        Hooks

    <form class="form-inline" role="form">

        Filter
        <input ng-model="filterText" type="text" class="form-control input-sm" placeholder="Filter" ng-enter="filter(filterText);">
        <button type="button" class="btn btn-primary btn-sm" ng-click="filter(filterText);">Filter</button>

        {{ filterError }}

              <button type="button" class="btn btn-primary btn-sm">Add New</button>

    </form>

                Name
                Entity Type
                Owners
                Actions

                {{ hook.name }}

                    {{hook.entity_type}}

                {{owner}}

                        Edit

                        Remove

                        Clone

                        History


text:
/**********************************************************************************************
* CountUp script by Praveen Lobo (http://PraveenLobo.com/techblog/javascript-countup-timer/)
* This notice MUST stay intact(in both JS file and SCRIPT tag) for legal use.
* http://praveenlobo.com/blog/disclaimer/
**********************************************************************************************/
function CountUp(initDate, id) {
    this.beginDate = new Date(initDate);
    this.countainer = document.getElementById(id);
    this.numOfDays = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
    this.borrowed = 0, this.years = 0, this.months = 0, this.days = 0;
    this.hours = 0, this.minutes = 0, this.seconds = 0;
    this.updateNumOfDays();
    this.updateCounter();
}

CountUp.prototype.updateNumOfDays = function () {
    var dateNow = new Date();
    var currYear = dateNow.getFullYear();
    if ((currYear % 4 == 0 && currYear % 100 != 0) || currYear % 400 == 0) {
        this.numOfDays[1] = 29;
    }
    var self = this;
    setTimeout(function () { self.updateNumOfDays(); }, (new Date((currYear + 1), 1, 2) - dateNow));
}

CountUp.prototype.datePartDiff = function (then, now, MAX) {
    var diff = now - then - this.borrowed;
    this.borrowed = 0;
    if (diff > -1) return diff;
    this.borrowed = 1;
    return (MAX + diff);
}

CountUp.prototype.calculate = function () {
    var currDate = new Date();
    var prevDate = this.beginDate;
    this.seconds = this.datePartDiff(prevDate.getSeconds(), currDate.getSeconds(), 60);
    this.minutes = this.datePartDiff(prevDate.getMinutes(), currDate.getMinutes(), 60);
    this.hours = this.datePartDiff(prevDate.getHours(), currDate.getHours(), 24);
    this.days = this.datePartDiff(prevDate.getDate(), currDate.getDate(), this.numOfDays[currDate.getMonth()]);
    this.months = this.datePartDiff(prevDate.getMonth(), currDate.getMonth(), 12);
    this.years = this.datePartDiff(prevDate.getFullYear(), currDate.getFullYear(), 0);
}

CountUp.prototype.addLeadingZero = function (value) {
    return value < 10 ? ("0" + value) : value;
}

CountUp.prototype.formatTime = function () {
    this.seconds = this.addLeadingZero(this.seconds);
    this.minutes = this.addLeadingZero(this.minutes);
    this.hours = this.addLeadingZero(this.hours);
}

CountUp.prototype.updateCounter = function () {
    this.calculate();
    this.formatTime();
    this.countainer.innerHTML = (this.years > 0 ? "" + this.years + " " + (this.years == 1 ? "year" : "years") + "" : "") +
        (this.months > 0 ? " " + this.months + " " + (this.months == 1 ? "month" : "months") + "" : "") +
        (this.days > 0 ? " " + this.days + " " + (this.days == 1 ? "day" : "days") + "" : "") +
        (this.hours > 0 ? " " + this.hours + " " + (this.hours == 1 ? "hour" : "hours") + "" : "") +
        " " + this.minutes + " " + (this.minutes == 1 ? "minute" : "minutes") + "" +
        " " + this.seconds + " " + (this.seconds == 1 ? "second" : "seconds") + "";
    var self = this;
    setTimeout(function () { self.updateCounter(); }, 1000);
}


text:
Imports NLog
Imports Transporter_AEHF.Objects.Enumerations
Imports Transporter_AEHF.Objects.Positioners
Imports Transporter_AEHF.Objects.SwitchDrivers
'*************************
'THIS NEEDS LOGGING
'*************************
Public Class PositionerController

    Private _positioner As iPositioner
    Private _azimuthArray As List(Of Double) '() As Double
    Private _elevationArray As List(Of Double) '() As Double
    Private _switchDriver As BurchfieldSwitchDriverUnit
    Private _type As PumaEnums.PositionerModel
    Private _address As String
    Private _isconnected As Boolean

    Private _log As Logger = LogManager.GetCurrentClassLogger
    Private _loggerSelection As String

    Public Sub New(ByVal type As PumaEnums.PositionerModel, ByVal address As String, ByVal loggerSelection As String)
        _loggerSelection = loggerSelection
        _type = type
        _address = address
        _azimuthArray = New List(Of Double)
        _elevationArray = New List(Of Double)
    End Sub

    Public Sub Errorhandlingtest()
        Dim myarray = {0, 0, 0, 0}
        Dim tst = myarray(4)
        Try
        Catch ex As Exception
            Throw
        End Try
    End Sub

    Public Sub Connect()
        If Not _isconnected Then
            Select Case _type
                Case PumaEnums.PositionerModel.Burchfield
                    _positioner = New BurchfieldUnit()
                    _positioner.Connect(_address, "4000", PumaEnums.ConnectionType.Ip, _loggerSelection)
                    _isconnected = True
                Case PumaEnums.PositionerModel.DirectedPerception
                    'AT THIS POINT I'M JUST HARD CODING A CABLE WRAP INTO THE FLIR
                    _positioner = New FlirUnit()
                    _positioner.Connect("COM" & _address, "", PumaEnums.ConnectionType.Com, False, True)
                    _isconnected = True
            End Select
        End If
    End Sub

    Public Sub PrepPositionerForSurvey()
        _positioner.Initialize()
    End Sub

    Public Function SetElevationAngle(ByVal degree As Integer) As String
        Dim ans As String = String.Empty
        ans = _positioner.MoveTiltToPosition(degree)
        Return ans
    End Function

    Public Function MovePanToPosition(ByVal degree As Integer) As String
        Dim ans As String = String.Empty
        ans = _positioner.MovePanToPosition(degree)
        Return ans
    End Function

    Public Function Halt() As String
        Dim ans As String = String.Empty
        ans = _positioner.Halt()
        Return ans
    End Function

    Function IsPanHomeSet() As Boolean
        Dim ans As Boolean
        ans = _positioner.isPanHomeSet()
        Return ans
    End Function

    Public Function RotatePan(ByVal pd As PumaEnums.PanRotationDirection) As String
        Dim ans As Boolean
        ans = _positioner.RotatePan(pd)
        Return ans
    End Function

    Public Function RotateTilt(ByVal td As PumaEnums.TiltRotationDirection) As String
        Dim ans As Boolean
        ans = _positioner.RotateTilt(td)
        Return ans
    End Function

    Public Sub StowPan()
        _positioner.StowPan()
    End Sub

    Public Sub StowTilt()
        _positioner.StowTilt()
    End Sub

    'This function is only used if the positioner is also being used as a switch driver.
    'This was necessary because the switch driver and positioner need to share a connection
    'Therefore a seperate RFSwitchController and PositionerController was not possible.
    'Luckily there is only one funciton in the RFSwitchController
    Function EnableDriveLine(ByVal driveLine As Integer) As Boolean
        Dim ans As Boolean

        Try
            If _switchDriver Is Nothing Then _switchDriver = New BurchfieldSwitchDriverUnit()
            _switchDriver.Connect("", _positioner)
            ans = _switchDriver.EnableDriveLine(driveLine)
        Catch ex As Exception
            Throw ex
        End Try
        Return ans
    End Function

    Public Sub ResetPan()
        _positioner.ResetPan()
    End Sub

    Public Sub ResetTilt()
        _positioner.ResetTilt()
    End Sub

    Property AzimuthArray() As List(Of Double) ' Double()
        Get
            Return _azimuthArray
        End Get
        Set(value As List(Of Double)) ' Double())
            _azimuthArray = value
        End Set
    End Property

    Property ElevationArray() As List(Of Double) ' Double()
        Get
            Return _elevationArray
        End Get
        Set(value As List(Of Double)) ' Double())
            _elevationArray = value
        End Set
    End Property

    Property PanPosition()
        Get
            Return _positioner.GetPanPosition
        End Get
        Set(value)

        End Set
    End Property

    Property TiltPosition()
        Get
            Return _positioner.GetTiltPosition
        End Get
        Set(value)

        End Set
    End Property

    ReadOnly Property IsConnected()
        Get
            Return _isconnected
        End Get
    End Property

    Property Positioner As IPositioner
        Get
            Return _positioner
        End Get
        Set(value As IPositioner)

        End Set
    End Property
End Class