text:
Q: How to determine if a point is in a 2D triangle? Is there an easy way to determine if a point is inside a triangle? It's 2D, not 3D.

A: Here is a solution in python that is efficient, documented and contains three unittests. It's professional-grade quality and ready to be dropped into your project in the form of a module as is.
import unittest

###############################################################################
def point_in_triangle(point, triangle):
    """Returns True if the point is inside the triangle
    and returns False if it falls outside.
    - The argument *point* is a tuple with two elements
    containing the X,Y coordinates respectively.
    - The argument *triangle* is a tuple with three elements each
    element consisting of a tuple of X,Y coordinates.

    It works like this:
    Walk clockwise or counterclockwise around the triangle
    and project the point onto the segment we are crossing
    by using the dot product.
    Finally, check that the vector created is on the same side
    for each of the triangle's segments.
    """
    # Unpack arguments
    x, y = point
    ax, ay = triangle[0]
    bx, by = triangle[1]
    cx, cy = triangle[2]
    # Segment A to B
    side_1 = (x - bx) * (ay - by) - (ax - bx) * (y - by)
    # Segment B to C
    side_2 = (x - cx) * (by - cy) - (bx - cx) * (y - cy)
    # Segment C to A
    side_3 = (x - ax) * (cy - ay) - (cx - ax) * (y - ay)
    # All the signs must be positive or all negative
    return (side_1 < 0.0) == (side_2 < 0.0) == (side_3 < 0.0)

###############################################################################
class TestPointInTriangle(unittest.TestCase):

    triangle = ((22 , 8),
                (12 , 55),
                (7 , 19))

    def test_inside(self):
        point = (15, 20)
        self.assertTrue(point_in_triangle(point, self.triangle))

    def test_outside(self):
        point = (1, 7)
        self.assertFalse(point_in_triangle(point, self.triangle))

    def test_border_case(self):
        """If the point is exactly on one of the triangle's edges,
        we consider it is inside."""
        point = (7, 19)
        self.assertTrue(point_in_triangle(point, self.triangle))

###############################################################################
if __name__ == "__main__":
    suite = unittest.defaultTestLoader.loadTestsFromTestCase(TestPointInTriangle)
    unittest.TextTestRunner().run(suite)

There is an additional optional graphical test for the algorithm above to confirm its validity:
import random
from matplotlib import pyplot
from triangle_test import point_in_triangle

###############################################################################
# The area #
size_x = 64
size_y = 64

# The triangle #
triangle = ((22 , 8),
            (12 , 55),
            (7 , 19))

# Number of random points #
count_points = 10000

# Prepare the figure #
figure = pyplot.figure()
axes = figure.add_subplot(111, aspect='equal')
axes.set_title("Test the 'point_in_triangle' function")
axes.set_xlim(0, size_x)
axes.set_ylim(0, size_y)

# Plot the triangle #
from matplotlib.patches import Polygon
axes.add_patch(Polygon(triangle, linewidth=1, edgecolor='k', facecolor='none'))

# Plot the points #
for i in range(count_points):
    x = random.uniform(0, size_x)
    y = random.uniform(0, size_y)
    if point_in_triangle((x,y), triangle): pyplot.plot(x, y, '.g')
    else:                                  pyplot.plot(x, y, '.b')

# Save it #
figure.savefig("point_in_triangle.pdf")

Producing the following graphic:

A: Since there's no JS answer,
Clockwise & Counter-Clockwise solution:
function triangleContains(ax, ay, bx, by, cx, cy, x, y) {

    let det = (bx - ax) * (cy - ay) - (by - ay) * (cx - ax)

    return  det * ((bx - ax) * (y - ay) - (by - ay) * (x - ax)) >= 0 &&
            det * ((cx - bx) * (y - by) - (cy - by) * (x - bx)) >= 0 &&
            det * ((ax - cx) * (y - cy) - (ay - cy) * (x - cx)) >= 0

}

EDIT: fixed two typos (about sign & comparison).
https://jsfiddle.net/jniac/rctb3gfL/

function triangleContains(ax, ay, bx, by, cx, cy, x, y) {

    let det = (bx - ax) * (cy - ay) - (by - ay) * (cx - ax)

    return  det * ((bx - ax) * (y - ay) - (by - ay) * (x - ax)) > 0 &&
            det * ((cx - bx) * (y - by) - (cy - by) * (x - bx)) > 0 &&
            det * ((ax - cx) * (y - cy) - (ay - cy) * (x - cx)) > 0

}

let width = 500, height = 500

// clockwise
let triangle1 = {

    A : { x: 10, y: -10 },
    C : { x: 20, y: 100 },
    B : { x: -90, y: 10 },

    color: '#f00',

}

// counter clockwise
let triangle2 = {

    A : { x: 20, y: -60 },
    B : { x: 90, y: 20 },
    C : { x: 20, y: 60 },

    color: '#00f',

}

let scale = 2
let mouse = { x: 0, y: 0 }

// DRAW >

let wrapper = document.querySelector('div.wrapper')

wrapper.onmousemove = ({ layerX:x, layerY:y }) => {

    x -= width / 2
    y -= height / 2
    x /= scale
    y /= scale

    mouse.x = x
    mouse.y = y

    drawInteractive()

}

function drawArrow(ctx, A, B) {

    let v = normalize(sub(B, A), 3)
    let I = center(A, B)

    let p

    p = add(I, rotate(v, 90), v)
    ctx.moveTo(p.x, p.y)
    ctx.lineTo(I.x, I .y)
    p = add(I, rotate(v, -90), v)
    ctx.lineTo(p.x, p.y)

}

function drawTriangle(ctx, { A, B, C, color }) {

    ctx.beginPath()
    ctx.moveTo(A.x, A.y)
    ctx.lineTo(B.x, B.y)
    ctx.lineTo(C.x, C.y)
    ctx.closePath()

    ctx.fillStyle = color + '6'
    ctx.strokeStyle = color
    ctx.fill()

    drawArrow(ctx, A, B)
    drawArrow(ctx, B, C)
    drawArrow(ctx, C, A)

    ctx.stroke()

}

function contains({ A, B, C }, P) {

    return triangleContains(A.x, A.y, B.x, B.y, C.x, C.y, P.x, P.y)

}

function resetCanvas(canvas) {

    canvas.width = width
    canvas.height = height

    let ctx = canvas.getContext('2d')

    ctx.resetTransform()
    ctx.clearRect(0, 0, width, height)
    ctx.setTransform(scale, 0, 0, scale, width/2, height/2)

}

function drawDots() {

    let canvas = document.querySelector('canvas#dots')
    let ctx = canvas.getContext('2d')

    resetCanvas(canvas)

    let count = 1000

    for (let i = 0; i < count; i++) {

        let x = width * (Math.random() - .5)
        let y = width * (Math.random() - .5)

        ctx.beginPath()
        ctx.ellipse(x, y, 1, 1, 0, 0, 2 * Math.PI)

        if (contains(triangle1, { x, y })) {

            ctx.fillStyle = '#f00'

        } else if (contains(triangle2, { x, y })) {

            ctx.fillStyle = '#00f'

        } else {

            ctx.fillStyle = '#0003'

        }

        ctx.fill()

    }

}

function drawInteractive() {

    let canvas = document.querySelector('canvas#interactive')
    let ctx = canvas.getContext('2d')

    resetCanvas(canvas)

    ctx.beginPath()
    ctx.moveTo(0, -height/2)
    ctx.lineTo(0, height/2)
    ctx.moveTo(-width/2, 0)
    ctx.lineTo(width/2, 0)
    ctx.strokeStyle = '#0003'
    ctx.stroke()

    drawTriangle(ctx, triangle1)
    drawTriangle(ctx, triangle2)

    ctx.beginPath()
    ctx.ellipse(mouse.x, mouse.y, 4, 4, 0, 0, 2 * Math.PI)

    if (contains(triangle1, mouse)) {

        ctx.fillStyle = triangle1.color + 'a'
        ctx.fill()

    } else if (contains(triangle2, mouse)) {

        ctx.fillStyle = triangle2.color + 'a'
        ctx.fill()

    } else {

        ctx.strokeStyle = 'black'
        ctx.stroke()

    }

}

drawDots()
drawInteractive()

// trigo

function add(...points) {

    let x = 0, y = 0

    for (let point of points) {

        x += point.x
        y += point.y

    }

    return { x, y }

}

function center(...points) {

    let x = 0, y = 0

    for (let point of points) {

        x += point.x
        y += point.y

    }

    x /= points.length
    y /= points.length

    return { x, y }

}

function sub(A, B) {

    let x = A.x - B.x
    let y = A.y - B.y

    return { x, y }

}

function normalize({ x, y }, length = 10) {

    let r = length / Math.sqrt(x * x + y * y)

    x *= r
    y *= r

    return { x, y }

}

function rotate({ x, y }, angle = 90) {

    let length = Math.sqrt(x * x + y * y)

    angle *= Math.PI / 180
    angle += Math.atan2(y, x)

    x = length * Math.cos(angle)
    y = length * Math.sin(angle)

    return { x, y }

}
* {
    margin: 0;
}

html {
    font-family: monospace;
}

body {
    padding: 32px;
}

span.red {
    color: #f00;
}

span.blue {
    color: #00f;
}

canvas {
    position: absolute;
    border: solid 1px #ddd;
}

red triangle is clockwise

blue triangle is couter clockwise

    <canvas id="dots"></canvas>
    <canvas id="interactive"></canvas>

I'm using here the same method as described above: a point is inside ABC if it is respectively on the "same" side of each line AB, BC, CA.

A: What I do is precalculate the three face normals,

*

*in 3D by cross product of side vector and the face normal vector.

*in 2D by simply swapping components and negating one,
then inside/outside for any one side is when a dot product of the side normal and the vertex to point vector, change sign. Repeat for other two (or more) sides.
Benefits:

*

*a lot is precalculated so great for multiple point testing on same triangle.

*early rejection of common case of more outside than inside points. (also if point distribution weighted to one side, can test that side first.)

A: Here is an efficient Python implementation:
def PointInsideTriangle2(pt,tri):
    '''checks if point pt(2) is inside triangle tri(3x2). @Developer'''
    a = 1/(-tri[1,1]*tri[2,0]+tri[0,1]*(-tri[1,0]+tri[2,0])+ \
        tri[0,0]*(tri[1,1]-tri[2,1])+tri[1,0]*tri[2,1])
    s = a*(tri[2,0]*tri[0,1]-tri[0,0]*tri[2,1]+(tri[2,1]-tri[0,1])*pt[0]+ \
        (tri[0,0]-tri[2,0])*pt[1])
    if s<0: return False
    else: t = a*(tri[0,0]*tri[1,1]-tri[1,0]*tri[0,1]+(tri[0,1]-tri[1,1])*pt[0]+ \
              (tri[1,0]-tri[0,0])*pt[1])
    return ((t>0) and (1-s-t>0))

and an example output:

A: I wrote this code before a final attempt with Google and finding this page, so I thought I'd share it. It is basically an optimized version of Kisielewicz answer. I looked into the Barycentric method also but judging from the Wikipedia article I have a hard time seeing how it is more efficient (I'm guessing there is some deeper equivalence). Anyway, this algorithm has the advantage of not using division; a potential problem is the behavior of the edge detection depending on orientation.
bool intpoint_inside_trigon(intPoint s, intPoint a, intPoint b, intPoint c)
{
    int as_x = s.x - a.x;
    int as_y = s.y - a.y;

    bool s_ab = (b.x - a.x) * as_y - (b.y - a.y) * as_x > 0;

    if ((c.x - a.x) * as_y - (c.y - a.y) * as_x > 0 == s_ab)
        return false;
    if ((c.x - b.x) * (s.y - b.y) - (c.y - b.y)*(s.x - b.x) > 0 != s_ab)
        return false;
    return true;
}

In words, the idea is this: Is the point s to the left of or to the right of both the lines AB and AC? If true, it can't be inside. If false, it is at least inside the "cones" that satisfy the condition. Now since we know that a point inside a trigon (triangle) must be to the same side of AB as BC (and also CA), we check if they differ. If they do, s can't possibly be inside, otherwise s must be inside.
Some keywords in the calculations are line half-planes and the determinant (2x2 cross product). Perhaps a more pedagogical way is probably to think of it as a point being inside iff it's to the same side (left or right) to each of the lines AB, BC and CA. The above way seemed a better fit for some optimization however.

A: If you know the co-ordinates of the three vertices and the co-ordinates of the specific point, then you can get the area of the complete triangle. Afterwards, calculate the area of the three triangle segments (one point being the point given and the other two being any two vertices of the triangle). Thus, you will get the area of the three triangle segments. If the sum of these areas are equal to the total area (that you got previously), then, the point should be inside the triangle. Otherwise, the point is not inside the triangle. This should work. If there are any issues, let me know. Thank you.

A: C# version of the barycentric method posted by andreasdr and Perro Azul. I added a check to abandon the area calculation when s and t have opposite signs (and neither is zero), since potentially avoiding one-third of the multiplication cost seems justified.
public static bool PointInTriangle(Point p, Point p0, Point p1, Point p2)
{
    var s = (p0.X - p2.X) * (p.Y - p2.Y) - (p0.Y - p2.Y) * (p.X - p2.X);
    var t = (p1.X - p0.X) * (p.Y - p0.Y) - (p1.Y - p0.Y) * (p.X - p0.X);

    if ((s < 0) != (t < 0) && s != 0 && t != 0)
        return false;

    var d = (p2.X - p1.X) * (p.Y - p1.Y) - (p2.Y - p1.Y) * (p.X - p1.X);
    return d == 0 || (d < 0) == (s + t <= 0);
}

update 2021:This version correctly handles triangles specified in either winding direction (clockwise vs. counterclockwise). Note that for points that lie exactly on the triangle edge, some other answers on this page give inconsistent results depending on the order in which the triangle's three points are listed. Such points are considered "in" the triangle, and this code correctly returns true regardless of winding direction.

A: If you are looking for speed, here is a procedure that might help you.
Sort the triangle vertices on their ordinates. This takes at worst three comparisons. Let Y0, Y1, Y2 be the three sorted values. By drawing three horizontals through them you partition the plane into two half planes and two slabs. Let Y be the ordinate of the query point.
if Y < Y1
    if Y <= Y0 -> the point lies in the upper half plane, outside the triangle; you are done
    else Y > Y0 -> the point lies in the upper slab
else
    if Y >= Y2 -> the point lies in the lower half plane, outside the triangle; you are done
    else Y < Y2 -> the point lies in the lower slab

Costs two more comparisons. As you see, quick rejection is achieved for points outside of the "bounding slab".
Optionally, you can supply a test on the abscissas for quick rejection on the left and on the right (X <= X0' or X >= X2'). This will implement a quick bounding box test at the same time, but you'll need to sort on the abscissas too.
Eventually you will need to compute the sign of the given point with respect to the two sides of the triangle that delimit the relevant slab (upper or lower). The test has the form:
((X - Xi) * (Y - Yj) > (X - Xi) * (Y - Yj)) == ((X - Xi) * (Y - Yk) > (X - Xi) * (Y - Yk))

The complete discussion of i, j, k combinations (there are six of them, based on the outcome of the sort) is out of the scope of this answer and "left as an exercise to the reader"; for efficiency, they should be hard-coded.
If you think that this solution is complex, observe that it mainly involves simple comparisons (some of which can be precomputed), plus 6 subtractions and 4 multiplies in case the bounding box test fails. The latter cost is hard to beat as in the worst case you cannot avoid comparing the test point against two sides (no method in other answers has a lower cost, some make it worse, like 15 subtractions and 6 multiplies, sometimes divisions).
UPDATE:
Faster with a shear transform
As explained just above, you can quickly locate the point inside one of the four horizontal bands delimited by the three vertex ordinates, using two comparisons.
You can optionally perform one or two extra X tests to check insideness to the bounding box (dotted lines).
Then consider the "shear" transform given by X'= X - m Y, Y' = Y, where m is the slope DX/DY for the highest edge. This transform will make this side of the triangle vertical. And since you know on what side of the middle horizontal you are, it suffices to test the sign with respect to a single side of the triangle.

Assuming you precomputed the slope m, as well as the X' for the sheared triangle vertices and the coefficients of the equations of the sides as X = m Y + p, you will need in the worst case

*

*two ordinate comparisons for vertical classification;

*optionally one or two abscissa comparisons for bounding box rejection;

*computation of X' = X - m Y;

*one or two comparisons with the abscissas of the sheared triangle;

*one sign test X >< m' Y + p' against the relevant side of the sheared triangle.

A: This is the simplest concept to determine if a point is inside or outside the triangle or on an arm of a triangle.
Determination of a point is inside a triangle by determinants:

The simplest working code:
#-*- coding: utf-8 -*-

import numpy as np

tri_points = [(1,1),(2,3),(3,1)]

def pisinTri(point,tri_points):
    Dx , Dy = point

    A,B,C = tri_points
    Ax, Ay = A
    Bx, By = B
    Cx, Cy = C

    M1 = np.array([ [Dx - Bx, Dy - By, 0],
                    [Ax - Bx, Ay - By, 0],
                    [1      , 1      , 1]
                  ])

    M2 = np.array([ [Dx - Ax, Dy - Ay, 0],
                    [Cx - Ax, Cy - Ay, 0],
                    [1      , 1      , 1]
                  ])

    M3 = np.array([ [Dx - Cx, Dy - Cy, 0],
                    [Bx - Cx, By - Cy, 0],
                    [1      , 1      , 1]
                  ])

    M1 = np.linalg.det(M1)
    M2 = np.linalg.det(M2)
    M3 = np.linalg.det(M3)
    print(M1,M2,M3)

    if(M1 == 0 or M2 == 0 or M3 ==0):
            print("Point: ",point," lies on the arms of Triangle")
    elif((M1 > 0 and M2 > 0 and M3 > 0)or(M1 < 0 and M2 < 0 and M3 < 0)):
            #if products is non 0 check if all of their sign is same
            print("Point: ",point," lies inside the Triangle")
    else:
            print("Point: ",point," lies outside the Triangle")

print("Vertices of Triangle: ",tri_points)
points = [(0,0),(1,1),(2,3),(3,1),(2,2),(4,4),(1,0),(0,4)]
for c in points:
    pisinTri(c,tri_points)

A: In general, the simplest (and quite optimal) algorithm is checking on which side of the half-plane created by the edges the point is.
Here's some high quality info in this topic on GameDev, including performance issues.
And here's some code to get you started:
float sign (fPoint p1, fPoint p2, fPoint p3)
{
    return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);
}

bool PointInTriangle (fPoint pt, fPoint v1, fPoint v2, fPoint v3)
{
    float d1, d2, d3;
    bool has_neg, has_pos;

    d1 = sign(pt, v1, v2);
    d2 = sign(pt, v2, v3);
    d3 = sign(pt, v3, v1);

    has_neg = (d1 < 0) || (d2 < 0) || (d3 < 0);
    has_pos = (d1 > 0) || (d2 > 0) || (d3 > 0);

    return !(has_neg && has_pos);
}

A: Solve the following equation system:
p = p0 + (p1 - p0) * s + (p2 - p0) * t

The point p is inside the triangle if 0 <= s <= 1 and 0 <= t <= 1 and s + t <= 1.
s,t and 1 - s - t are called the barycentric coordinates of the point p.

A: I just want to use some simple vector math to explain the barycentric coordinates solution which Andreas had given, it will be way easier to understand.

*

*Area A is defined as any vector given by s * v02 + t * v01, with condition s >= 0 and t >= 0. If any point inside the triangle v0, v1, v2, it must be inside Area A.

*If further restrict s, and t belongs to [0, 1]. We get Area B which contains all vectors of s * v02 + t * v01, with condition s, t belongs to [0, 1]. It is worth to note that the low part of the Area B is the mirror of Triangle v0, v1, v2. The problem comes to if we can give certain condition of s, and t, to further excluding the low part of Area B.

*Assume we give a value s, and t is changing in [0, 1]. In the following pic, point p is on the edge of v1v2. All the vectors of s * v02 + t * v01 which are along the dash line by simple vector sum. At v1v2 and dash line cross point p, we have:

(1-s)|v0v2| / |v0v2| = tp|v0v1| / |v0v1|
we get 1 - s = tp, then 1 = s + tp. If any t > tp, which 1 < s + t where is on the double dash line, the vector is outside the triangle, any t <= tp, which 1 >= s + t where is on single dash line, the vector is inside the triangle.
Then if we given any s in [0, 1], the corresponding t must meet 1 >= s + t, for the vector inside triangle.

So finally we get v = s * v02 + t * v01, v is inside triangle with condition s, t, s+t belongs to [0, 1]. Then translate to point, we have
p - p0 = s * (p1 - p0) + t * (p2 - p0), with s, t, s + t in [0, 1]
which is the same as Andreas' solution to solve equation system
p = p0 + s * (p1 - p0) + t * (p2 - p0), with s, t, s + t belong to [0, 1].

A: Other function in python, faster than Developer's method (for me at least) and inspired by Cédric Dufour solution:
def ptInTriang(p_test, p0, p1, p2):
     dX = p_test[0] - p0[0]
     dY = p_test[1] - p0[1]
     dX20 = p2[0] - p0[0]
     dY20 = p2[1] - p0[1]
     dX10 = p1[0] - p0[0]
     dY10 = p1[1] - p0[1]

     s_p = (dY20*dX) - (dX20*dY)
     t_p = (dX10*dY) - (dY10*dX)
     D = (dX10*dY20) - (dY10*dX20)

     if D > 0:
         return (  (s_p >= 0) and (t_p >= 0) and (s_p + t_p) <= D  )
     else:
         return (  (s_p <= 0) and (t_p <= 0) and (s_p + t_p) >= D  )

You can test it with:
X_size = 64
Y_size = 64
ax_x = np.arange(X_size).astype(np.float32)
ax_y = np.arange(Y_size).astype(np.float32)
coords=np.meshgrid(ax_x,ax_y)
points_unif = (coords[0].reshape(X_size*Y_size,),coords[1].reshape(X_size*Y_size,))
p_test = np.array([0 , 0])
p0 = np.array([22 , 8])
p1 = np.array([12 , 55])
p2 = np.array([7 , 19])
fig = plt.figure(dpi=300)
for i in range(0,X_size*Y_size):
    p_test[0] = points_unif[0][i]
    p_test[1] = points_unif[1][i]
    if ptInTriang(p_test, p0, p1, p2):
        plt.plot(p_test[0], p_test[1], '.g')
    else:
        plt.plot(p_test[0], p_test[1], '.r')

It takes a lot to plot, but that grid is tested in 0.0195319652557 seconds against 0.0844349861145 seconds of Developer's code.
Finally the code comment:
# Using barycentric coordintes, any point inside can be described as:
# X = p0.x * r + p1.x * s + p2.x * t
# Y = p0.y * r + p1.y * s + p2.y * t
# with:
# r + s + t = 1  and 0 < r,s,t < 1
# then: r = 1 - s - t
# and then:
# X = p0.x * (1 - s - t) + p1.x * s + p2.x * t
# Y = p0.y * (1 - s - t) + p1.y * s + p2.y * t
#
# X = p0.x + (p1.x-p0.x) * s + (p2.x-p0.x) * t
# Y = p0.y + (p1.y-p0.y) * s + (p2.y-p0.y) * t
#
# X - p0.x = (p1.x-p0.x) * s + (p2.x-p0.x) * t
# Y - p0.y = (p1.y-p0.y) * s + (p2.y-p0.y) * t
#
# we have to solve:
#
# [ X - p0.x ] = [(p1.x-p0.x)   (p2.x-p0.x)] * [ s ]
# [ Y - p0.Y ]   [(p1.y-p0.y)   (p2.y-p0.y)]   [ t ]
#
# ---> b = A*x ; ---> x = A^-1 * b
#
# [ s ] =   A^-1  * [ X - p0.x ]
# [ t ]             [ Y - p0.Y ]
#
# A^-1 = 1/D * adj(A)
#
# The adjugate of A:
#
# adj(A)   =   [(p2.y-p0.y)   -(p2.x-p0.x)]
#              [-(p1.y-p0.y)   (p1.x-p0.x)]
#
# The determinant of A:
#
# D = (p1.x-p0.x)*(p2.y-p0.y) - (p1.y-p0.y)*(p2.x-p0.x)
#
# Then:
#
# s_p = { (p2.y-p0.y)*(X - p0.x) - (p2.x-p0.x)*(Y - p0.Y) }
# t_p = { (p1.x-p0.x)*(Y - p0.Y) - (p1.y-p0.y)*(X - p0.x) }
#
# s = s_p / D
# t = t_p / D
#
# Recovering r:
#
# r = 1 - (s_p + t_p)/D
#
# Since we only want to know if it is insidem not the barycentric coordinate:
#
# 0 < 1 - (s_p + t_p)/D < 1
# 0 < (s_p + t_p)/D < 1
# 0 < (s_p + t_p) < D
#
# The condition is:
# if D > 0:
#     s_p > 0 and t_p > 0 and (s_p + t_p) < D
# else:
#     s_p < 0 and t_p < 0 and (s_p + t_p) > D
#
# s_p = { dY20*dX - dX20*dY }
# t_p = { dX10*dY - dY10*dX }
# D = dX10*dY20 - dY10*dX20

A: Java version of barycentric method:
class Triangle {
    Triangle(double x1, double y1, double x2, double y2, double x3,
            double y3) {
        this.x3 = x3;
        this.y3 = y3;
        y23 = y2 - y3;
        x32 = x3 - x2;
        y31 = y3 - y1;
        x13 = x1 - x3;
        det = y23 * x13 - x32 * y31;
        minD = Math.min(det, 0);
        maxD = Math.max(det, 0);
    }

    boolean contains(double x, double y) {
        double dx = x - x3;
        double dy = y - y3;
        double a = y23 * dx + x32 * dy;
        if (a < minD || a > maxD)
            return false;
        double b = y31 * dx + x13 * dy;
        if (b < minD || b > maxD)
            return false;
        double c = det - a - b;
        if (c < minD || c > maxD)
            return false;
        return true;
    }

    private final double x3, y3;
    private final double y23, x32, y31, x13;
    private final double det, minD, maxD;
}

The above code will work accurately with integers, assuming no overflows.  It will also work with clockwise and anticlockwise triangles.  It will not work with collinear triangles (but you can check for that by testing det==0).
The barycentric version is fastest if you are going to test different points with the same triangle.
The barycentric version is not symmetric in the 3 triangle points, so it is likely to be less consistent than Kornel Kisielewicz's edge half-plane version, because of floating point rounding errors.
Credit: I made the above code from Wikipedia's article on barycentric coordinates.

A: By using the analytic solution to the barycentric coordinates (pointed out by Andreas Brinck) and:

*

*not distributing the multiplication over the parenthesized terms

*avoiding computing several times the same terms by storing them

*reducing comparisons (as pointed out by coproc and Thomas Eding)

One can minimize the number of "costly" operations:
function ptInTriangle(p, p0, p1, p2) {
    var dX = p.x-p2.x;
    var dY = p.y-p2.y;
    var dX21 = p2.x-p1.x;
    var dY12 = p1.y-p2.y;
    var D = dY12*(p0.x-p2.x) + dX21*(p0.y-p2.y);
    var s = dY12*dX + dX21*dY;
    var t = (p2.y-p0.y)*dX + (p0.x-p2.x)*dY;
    if (D<0) return s<=0 && t<=0 && s+t>=D;
    return s>=0 && t>=0 && s+t<=D;
}

Code can be pasted in Perro Azul jsfiddle or try it by clicking "Run code snippet" below

var ctx = $("canvas")[0].getContext("2d");
var W = 500;
var H = 500;

var point = { x: W / 2, y: H / 2 };
var triangle = randomTriangle();

$("canvas").click(function(evt) {
    point.x = evt.pageX - $(this).offset().left;
    point.y = evt.pageY - $(this).offset().top;
    test();
});

$("canvas").dblclick(function(evt) {
    triangle = randomTriangle();
    test();
});

test();

function test() {
    var result = ptInTriangle(point, triangle.a, triangle.b, triangle.c);

    var info = "point = (" + point.x + "," + point.y + ")\n";
    info += "triangle.a = (" + triangle.a.x + "," + triangle.a.y + ")\n";
    info += "triangle.b = (" + triangle.b.x + "," + triangle.b.y + ")\n";
    info += "triangle.c = (" + triangle.c.x + "," + triangle.c.y + ")\n";
    info += "result = " + (result ? "true" : "false");

    $("#result").text(info);
    render();
}

function ptInTriangle(p, p0, p1, p2) {
    var A = 1/2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
    var sign = A < 0 ? -1 : 1;
    var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
    var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;

    return s > 0 && t > 0 && (s + t) < 2 * A * sign;
}

function render() {
    ctx.fillStyle = "#CCC";
    ctx.fillRect(0, 0, 500, 500);
    drawTriangle(triangle.a, triangle.b, triangle.c);
    drawPoint(point);
}

function drawTriangle(p0, p1, p2) {
    ctx.fillStyle = "#999";
    ctx.beginPath();
    ctx.moveTo(p0.x, p0.y);
    ctx.lineTo(p1.x, p1.y);
    ctx.lineTo(p2.x, p2.y);
    ctx.closePath();
    ctx.fill();
    ctx.fillStyle = "#000";
    ctx.font = "12px monospace";
    ctx.fillText("1", p0.x, p0.y);
    ctx.fillText("2", p1.x, p1.y);
    ctx.fillText("3", p2.x, p2.y);
}

function drawPoint(p) {
    ctx.fillStyle = "#F00";
    ctx.beginPath();
    ctx.arc(p.x, p.y, 5, 0, 2 * Math.PI);
    ctx.fill();
}

function rand(min, max) {
 return Math.floor(Math.random() * (max - min + 1)) + min;
}

function randomTriangle() {
    return {
        a: { x: rand(0, W), y: rand(0, H) },
        b: { x: rand(0, W), y: rand(0, H) },
        c: { x: rand(0, W), y: rand(0, H) }
    };
}

Click: place the point.
Double click: random triangle.

<canvas width="500" height="500"></canvas>

Leading to:

*

*variable "recalls": 30

*variable storage: 7

*additions: 4

*subtractions: 8

*multiplications: 6

*divisions: none

*comparisons: 4

This compares quite well with Kornel Kisielewicz solution (25 recalls, 1 storage, 15 subtractions, 6 multiplications, 5 comparisons), and might be even better if clockwise/counter-clockwise detection is needed (which takes 6 recalls, 1 addition, 2 subtractions, 2 multiplications and 1 comparison in itself, using the analytic solution determinant, as pointed out by rhgb).

A: A simple way is to:

find the vectors connecting the
  point to each of the triangle's three
  vertices and sum the angles between
  those vectors. If the sum of the
  angles is 2*pi then the point is
  inside the triangle.

Two good sites that explain alternatives are:
blackpawn and wolfram

A: I agree with Andreas Brinck, barycentric coordinates are very convenient for this task. Note that there is no need to solve an equation system every time: just evaluate the analytical solution. Using Andreas' notation, the solution is:
s = 1/(2*Area)*(p0y*p2x - p0x*p2y + (p2y - p0y)*px + (p0x - p2x)*py);
t = 1/(2*Area)*(p0x*p1y - p0y*p1x + (p0y - p1y)*px + (p1x - p0x)*py);

where Area is the (signed) area of the triangle:
Area = 0.5 *(-p1y*p2x + p0y*(-p1x + p2x) + p0x*(p1y - p2y) + p1x*p2y);

Just evaluate s, t and 1-s-t. The point p is inside the triangle if and only if they are all positive.
EDIT: Note that the above expression for the area assumes that the triangle node numbering is counter-clockwise. If the numbering is clockwise, this expression will return a negative area (but with correct magnitude). The test itself (s>0 && t>0 && 1-s-t>0) doesn't depend on the direction of the numbering, however, since the expressions above that are multiplied by 1/(2*Area) also change sign if the triangle node orientation changes.
EDIT 2: For an even better computational efficiency, see coproc's comment below (which  makes the point that if the orientation of the triangle nodes (clockwise or counter-clockwise) is known beforehand, the division by 2*Area in the expressions for s and t can be avoided). See also Perro Azul's jsfiddle-code in the comments under Andreas Brinck's answer.

A: There are pesky edge conditions where a point is exactly on the common edge of two adjacent triangles. The point cannot be in both, or neither of the triangles. You need an arbitrary but consistent way of assigning the point. For example, draw a horizontal line through the point. If the line intersects with the other side of the triangle on the right, the point is treated as though it is inside the triangle. If the intersection is on the left, the point is outside.
If the line on which the point lies is horizontal, use above/below.
If the point is on the common vertex of multiple triangles, use the triangle with whose center the point forms the smallest angle.
More fun: three points can be in a straight line (zero degrees), for example (0,0) - (0,10) - (0,5). In a triangulating algorithm, the "ear" (0,10) must be lopped off, the "triangle" generated being the degenerate case of a straight line.

A: I needed point in triangle check in "controlable environment" when you're absolutely sure that triangles will be clockwise. So, I took Perro Azul's jsfiddle and modified it as suggested by coproc for such cases; also removed redundant 0.5 and 2 multiplications because they're just cancel each other.
http://jsfiddle.net/dog_funtom/H7D7g/

var ctx = $("canvas")[0].getContext("2d");
var W = 500;
var H = 500;

var point = {
    x: W / 2,
    y: H / 2
};
var triangle = randomTriangle();

$("canvas").click(function (evt) {
    point.x = evt.pageX - $(this).offset().left;
    point.y = evt.pageY - $(this).offset().top;
    test();
});

$("canvas").dblclick(function (evt) {
    triangle = randomTriangle();
    test();
});

test();

function test() {
    var result = ptInTriangle(point, triangle.a, triangle.b, triangle.c);

    var info = "point = (" + point.x + "," + point.y + ")\n";
    info += "triangle.a = (" + triangle.a.x + "," + triangle.a.y + ")\n";
    info += "triangle.b = (" + triangle.b.x + "," + triangle.b.y + ")\n";
    info += "triangle.c = (" + triangle.c.x + "," + triangle.c.y + ")\n";
    info += "result = " + (result ? "true" : "false");

    $("#result").text(info);
    render();
}

function ptInTriangle(p, p0, p1, p2) {
    var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y);
    var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y);

    if (s <= 0 || t <= 0) return false;

    var A = (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);

    return (s + t)  0;
}

function render() {
    ctx.fillStyle = "#CCC";
    ctx.fillRect(0, 0, 500, 500);
    drawTriangle(triangle.a, triangle.b, triangle.c);
    drawPoint(point);
}

function drawTriangle(p0, p1, p2) {
    ctx.fillStyle = "#999";
    ctx.beginPath();
    ctx.moveTo(p0.x, p0.y);
    ctx.lineTo(p1.x, p1.y);
    ctx.lineTo(p2.x, p2.y);
    ctx.closePath();
    ctx.fill();
    ctx.fillStyle = "#000";
    ctx.font = "12px monospace";
    ctx.fillText("1", p0.x, p0.y);
    ctx.fillText("2", p1.x, p1.y);
    ctx.fillText("3", p2.x, p2.y);
}

function drawPoint(p) {
    ctx.fillStyle = "#F00";
    ctx.beginPath();
    ctx.arc(p.x, p.y, 5, 0, 2 * Math.PI);
    ctx.fill();
}

function rand(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}

function randomTriangle() {
    while (true) {
        var result = {
            a: {
                x: rand(0, W),
                y: rand(0, H)
            },
            b: {
                x: rand(0, W),
                y: rand(0, H)
            },
            c: {
                x: rand(0, W),
                y: rand(0, H)
            }
        };
        if (checkClockwise(result.a, result.b, result.c)) return result;
    }
}

Click: place the point.
Double click: random triangle.

<canvas width="500" height="500"></canvas>

Here is equivalent C# code for Unity:
public static bool IsPointInClockwiseTriangle(Vector2 p, Vector2 p0, Vector2 p1, Vector2 p2)
{
    var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y);
    var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y);

    if (s <= 0 || t <= 0)
        return false;

    var A = (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);

    return (s + t) = 0;
}

*

*pointInTriangle(p, p0, p1, p2) - for counter-clockwise triangles

*pointInTriangle(p, p0, p1, p2) - for clockwise triangles

Look in jsFiddle (performance test included), there's also winding checking in a separate function. Or press "Run code snippet" below

var ctx = $("canvas")[0].getContext("2d");
var W = 500;
var H = 500;

var point = { x: W / 2, y: H / 2 };
var triangle = randomTriangle();

$("canvas").click(function(evt) {
    point.x = evt.pageX - $(this).offset().left;
    point.y = evt.pageY - $(this).offset().top;
    test();
});

$("canvas").dblclick(function(evt) {
    triangle = randomTriangle();
    test();
});

document.querySelector('#performance').addEventListener('click', _testPerformance);

test();

function test() {
    var result = checkClockwise(triangle.a, triangle.b, triangle.c) ? pointInTriangle(point, triangle.a, triangle.c, triangle.b) : pointInTriangle(point, triangle.a, triangle.b, triangle.c);

    var info = "point = (" + point.x + "," + point.y + ")\n";
    info += "triangle.a = (" + triangle.a.x + "," + triangle.a.y + ")\n";
    info += "triangle.b = (" + triangle.b.x + "," + triangle.b.y + ")\n";
    info += "triangle.c = (" + triangle.c.x + "," + triangle.c.y + ")\n";
    info += "result = " + (result ? "true" : "false");

    $("#result").text(info);
    render();
}

function _testPerformance () {
 var px = [], py = [], p0x = [], p0y = [], p1x = [], p1y = [], p2x = [], p2y = [], p = [], p0 = [], p1 = [], p2 = [];

 for(var i = 0; i < 1000000; i++) {
    p[i] = {x: Math.random() * 100, y: Math.random() * 100};
    p0[i] = {x: Math.random() * 100, y: Math.random() * 100};
    p1[i] = {x: Math.random() * 100, y: Math.random() * 100};
    p2[i] = {x: Math.random() * 100, y: Math.random() * 100};
  }
  console.time('optimal: pointInTriangle');
  for(var i = 0; i < 1000000; i++) {
    pointInTriangle(p[i], p0[i], p1[i], p2[i]);
  }
  console.timeEnd('optimal: pointInTriangle');

  console.time('original: ptInTriangle');
  for(var i = 0; i < 1000000; i++) {
   ptInTriangle(p[i], p0[i], p1[i], p2[i]);
  }
  console.timeEnd('original: ptInTriangle');
}

function pointInTriangle (p, p0, p1, p2) {
 return (((p1.y - p0.y) * (p.x - p0.x) - (p1.x - p0.x) * (p.y - p0.y)) | ((p2.y - p1.y) * (p.x - p1.x) - (p2.x - p1.x) * (p.y - p1.y)) | ((p0.y - p2.y) * (p.x - p2.x) - (p0.x - p2.x) * (p.y - p2.y))) >= 0;
}

function ptInTriangle(p, p0, p1, p2) {
    var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y);
    var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y);

    if (s <= 0 || t <= 0) return false;

    var A = (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
    return (s + t)  0;
}

function drawTriangle(p0, p1, p2) {
    ctx.fillStyle = "#999";
    ctx.beginPath();
    ctx.moveTo(p0.x, p0.y);
    ctx.lineTo(p1.x, p1.y);
    ctx.lineTo(p2.x, p2.y);
    ctx.closePath();
    ctx.fill();
    ctx.fillStyle = "#000";
    ctx.font = "12px monospace";
    ctx.fillText("1", p0.x, p0.y);
    ctx.fillText("2", p1.x, p1.y);
    ctx.fillText("3", p2.x, p2.y);
}

function drawPoint(p) {
    ctx.fillStyle = "#F00";
    ctx.beginPath();
    ctx.arc(p.x, p.y, 5, 0, 2 * Math.PI);
    ctx.fill();
}

function rand(min, max) {
 return Math.floor(Math.random() * (max - min + 1)) + min;
}

function randomTriangle() {
    return {
        a: { x: rand(0, W), y: rand(0, H) },
        b: { x: rand(0, W), y: rand(0, H) },
        c: { x: rand(0, W), y: rand(0, H) }
    };
}

<button id="performance">Run performance test (open console)</button>

Click: place the point.
Double click: random triangle.

<canvas width="500" height="500"></canvas>

Inspired by this:
http://www.phatcode.net/articles.php?id=459

A: The easiest way and it works with all types of triangles is simply determine the angles of the P point A, B , C points angles. If any of the angles are bigger than 180.0 degree then it is outside, if 180.0 then it is on the circumference and if acos cheating on you and less than 180.0 then it is inside.Take a look for understanding http://math-physics-psychology.blogspot.hu/2015/01/earlish-determination-that-point-is.html

A: Honestly it is as simple as Simon P Steven's answer however with that approach you don't have a solid control on whether you want the points on the edges of the triangle to be included or not.
My approach is a little different but very basic. Consider the following triangle;

In order to have the point in the triangle we have to satisfy 3 conditions

*

*ACE angle (green) should be smaller than ACB angle (red)

*ECB angle (blue) should be smaller than ACB angle (red)

*Point E and Point C shoud have the same sign when their x and y values are applied to the equation of the |AB| line.

In this method you have full control to include or exclude the point on the edges individually. So you may check if a point is in the triangle including only the |AC| edge for instance.
So my solution in JavaScript would be as follows;

function isInTriangle(t,p){

  function isInBorder(a,b,c,p){
    var m = (a.y - b.y) / (a.x - b.x);                     // calculate the slope
    return Math.sign(p.y - m*p.x + m*a.x - a.y) === Math.sign(c.y - m*c.x + m*a.x - a.y);
  }

  function findAngle(a,b,c){                               // calculate the C angle from 3 points.
    var ca = Math.hypot(c.x-a.x, c.y-a.y),                 // ca edge length
        cb = Math.hypot(c.x-b.x, c.y-b.y),                 // cb edge length
        ab = Math.hypot(a.x-b.x, a.y-b.y);                 // ab edge length
    return Math.acos((ca*ca + cb*cb - ab*ab) / (2*ca*cb)); // return the C angle
  }

  var pas = t.slice(1)
             .map(tp => findAngle(p,tp,t[0])),             // find the angle between (p,t[0]) with (t[1],t[0]) & (t[2],t[0])
       ta = findAngle(t[1],t[2],t[0]);
  return pas[0] < ta && pas[1] < ta && isInBorder(t[1],t[2],t[0],p);
}

var triangle = [{x:3, y:4},{x:10, y:8},{x:6, y:10}],
      point1 = {x:3, y:9},
      point2 = {x:7, y:9};

console.log(isInTriangle(triangle,point1));
console.log(isInTriangle(triangle,point2));

A: bool isInside( float x, float y, float x1, float y1, float x2, float y2, float x3, float y3 ) {
  float l1 = (x-x1)*(y3-y1) - (x3-x1)*(y-y1),
    l2 = (x-x2)*(y1-y2) - (x1-x2)*(y-y2),
    l3 = (x-x3)*(y2-y3) - (x2-x3)*(y-y3);
  return (l1>0 && l2>0  && l3>0) || (l1<0 && l2<0 && l3<0);
}

It can not be more efficient than this! Each side of a triangle can have independent position and orientation, hence three calculations: l1, l2 and l3 are definitely needed involving 2 multiplications each. Once l1, l2 and l3 are known, result is just a few basic comparisons and boolean operations away.

A: One of the easiest ways to check if the area formed by the vertices of triangle
(x1,y1),(x2,y2),(x3,y3) is positive or not.
Area can by calculated by the formula:

1/2 [x1(y2–y3) + x2(y3–y1) + x3(y1–y2)]

or python code can be written as:
def triangleornot(p1,p2,p3):
    return (1/ 2) [p1[0](p2[1]–p3[1]) + p2[0] (p3[1]–p1[1]) + p3[0] (p1[0]–p2[0])]

A: bool point2Dtriangle(double e,double f, double a,double b,double c, double g,double h,double i, double v, double w){
    /* inputs: e=point.x, f=point.y
               a=triangle.Ax, b=triangle.Bx, c=triangle.Cx
               g=triangle.Ay, h=triangle.By, i=triangle.Cy */
    v = 1 - (f * (b - c) + h * (c - e) + i * (e - b)) / (g * (b - c) + h * (c - a) + i * (a - b));
    w = (f * (a - b) + g * (b - e) + h * (e - a)) / (g * (b - c) + h * (c - a) + i * (a - b));
    if (*v > -0.0 && *v < 1.0000001 && *w > -0.0 && *w < *v) return true;//is inside
    else return false;//is outside
    return 0;
}

almost perfect Cartesian coordinates converted from barycentric
are exported within *v (x) and *w (y) doubles.
Both export doubles should have a * char before in every case, likely: *v and *w
Code can be used for the other triangle of a quadrangle too.
Hereby signed wrote only triangle abc from the clockwise abcd quad.
A---B
|..\\.o|
|....\\.|
D---C

the o point is inside ABC triangle
for testing with with second triangle call this function CDA direction, and results should be correct after *v=1-*v; and *w=1-*w; for the quadrangle


text:
Q: ilike expression support in bigquery BigQuery throws an error when 'ilike' expression is used. What is the alternative for doing case insensitive like query?
Below is the relevant part of the query.
SELECT id FROM `performance_last30days` WHERE device ilike 'DESKTOP'
Syntax error: Expected ")" but got "ilike"

A: SELECT id
FROM `performance_last30days`
WHERE UPPER(device) LIKE '%DESKTOP%'

or
SELECT id
FROM `performance_last30days`
WHERE REGEXP_CONTAINS(device, r'(?i)DESKTOP')

redpajama_set_name: RedPajamaStackExchange


text:
Q: Display grouping info across multiple columns I would like to design a rdlc-report with the following table-appearance.
Grp1  Grp2  ColA  ColB
Group title 1 -> merged cells!
------Group title 2 -> merged cells
------------Row1A Row1B
------------Row2A Row2B
------Group title 3 -> merged cells
------------Row3A Row3B

Is this design possible? I have difficulties merging the group by column with the adjacent columns on the right.
-Victor

A: Got it. I had to choose row groups instead of column groups in the tablix wizard. After that the column merge worked as I wished.


text:
Q: mime_content_type() not recognized by MAMP 1.9 Pro PHP 5.2.13 I'm a PHP and MAMP newbie.  I've got a PHP 5.2.13 site I'm supporting which calls out to the mime_content_type() function, but that function is not recognized on my machine.  I keep getting this:
Fatal error: Call to undefined function mime_content_type()
The googles all say indecipherable things about "mime magic".  Is there some extension I need to install in my MAMP PHP instance so that mime_content_type() will be recognized?

A: The function mime_content_type is deprecated in favor of Fileinfo, which is a PECL extension that has recently been moved into PHP's source. You can try using Fileinfo and see if it's available; it's installed by default since PHP 5.3.0. However, if you're using an older version or changed some configuration or something, you might have to install it.
Try the code below. If it works, you're done; if it doesn't, you'll have to install Fileinfo. The package is described here.
Using Fileinfo, you would replace $type=mime_content_type($filename), for example, with:
$finfo=finfo_open(FILEINFO_MIME_TYPE);
$type=finfo_file($finfo, $filename);
finfo_close($finfo);

A: It's been deprecated for a while now.
You're better off writing your own function, or taking some hints from the docs and comments on php.net


text:
Q: Trying hard to solve error 1064 I have tried hard but not getting the solutin regading sp below.. plz help !!
CREATE PROCEDURE AccountLedgerViewUnderBank()

begin

WITH GroupInMainGroup (accountGroupId,HierarchyLevel) AS
(
select accountGroupId,
1 as HierarchyLevel
from tbl_AccountGroup where accountGroupId='9'
UNION ALL
select e.accountGroupId,
G.HierarchyLevel + 1 AS HierarchyLevel
from tbl_AccountGroup as e,GroupInMainGroup G
where e.groupUnder=G.accountGroupId

)
SELECT
ledgerId AS 'Account Ledger Id',
acccountLedgerName AS 'Account Ledger Name'
FROM tbl_AccountLedger

where accountGroupId IN (select accountGroupId from GroupInMainGroup
)
end ; //

The error showing
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use near 'Group
InMainGroup (accountGroupId,HierarchyLevel) AS
(
select accountGroupId,
1 a' at line 6

A: It looks like you're trying to use a CTE, which is not supported with MySQL (at time of writing).
Subqueries are supported with most versions of MySQL, so you may be able to rewrite it as something like:
CREATE PROCEDURE AccountLedgerViewUnderBank()

begin

SELECT      ledgerId AS 'Account Ledger Id',
            acccountLedgerName AS 'Account Ledger Name'
FROM        tbl_AccountLedger

where       accountGroupId
    IN     (select accountGroupId
            from tbl_AccountGroup where accountGroupId='9'
            UNION ALL
            select e.accountGroupId
            from tbl_AccountGroup as e,GroupInMainGroup G
            where e.groupUnder=G.accountGroupId)
end ; //


text:
Q: Express.js http call inside route doesn't update variable I'm building a REST api on top of express.js. I am having trouble updating variables inside my routes.
Example:
I'm calling app.get("/wp/page/create/:id", function(req, res)
Inside this route I start by calling a http request using request-promise library. The response of this call I use in a nested http call.
I use a global variable for the headers for the nested call, and it's to the header a i need to make changes by using the etag variable.
Code:
global.postHeaders = headers;
postHeaders['X-HTTP-Method'] = "MERGE";
postHeaders['Content-Type'] = 'application/json;odata=verbose';
postHeaders['X-RequestDigest'] = spContext;

request.get({
url: "xxx",
headers: headers,
json: true
}).then(function(response) {
    var etag = response.d.__metadata.etag
    postHeaders['If-Match'] = etag;

    request.post({
       url: "xxx",
       type: "POST",
       body: data,
       headers: postHeaders,
       json: true
       }).then(function(data) {
          res.send(data).end()
          console.log("All done!");
      })
})

When i start the server up and enter the route everything works fine. When i when try to hit it again the etag variables is still the same, even though it should be updated.
If I restart the server it works the again on the first attempt but fails on the second/third.
Any idea what I am doing wrong?

A: I have resolved the issues. The simple solution was to clear the headers containing the variable.
global.postHeaders = headers;
postHeaders['X-HTTP-Method'] = "MERGE";
postHeaders['Content-Type'] = 'application/json;odata=verbose';
postHeaders['X-RequestDigest'] = spContext;

request.get({
 url: "xxx",
 headers: headers,
 json: true
 }).then(function(response) {
var etag = response.d.__metadata.etag
postHeaders['If-Match'] = etag;

   request.post({
     url: "xxx",
     type: "POST",
     body: data,
     headers: postHeaders,
     json: true
     }).then(function(data) {
      postHeaders['If-Match'] = "";
      res.send(data).end()
      console.log("All done!");
  })
})

A: postHeaders is a global variable. is headers in global.postHeaders = headers; also a global varaible ? Whatever you are trying to do here is grossly wrong. postHeaders variable will be shared across multiple request. so you will hit a scenario where postHeaders['If-Match'] value might be empty string or the etag .
Try this instead of the first line
var postHeaders = Object.assign({}, headers);
Not sure what you are trying, but at-least this statement will subside the huge error in the code. This will create a new header object for each request.


text:
Q: Checkstyle CustomImportOrder more than 3 definable groups? My company's Java import order standard would require more than the three definable groups that I see in checkstle, which are STANDARD_JAVA_PACKAGE, THIRD_PARTY_PACKAGE, and SPECIAL_IMPORTS.  My question has two parts:

*

*Is there a way to define more custom regular expressions, or use regexes directly in the VALUE for customImportOrderRules?

*Can I do this at all, since com.our_company is supposed to come after all the other com. imports.
The import rules are approximately

*

*Static imports

*java.*

*javax.*

*com.* EXCEPT our company

*nthing.*

*org.*

*pthing.*

*com.mycompany.*

*anything else

Since we also enforce blank lines between groups, I can't combine 5, 6, and 7 into one and depend on sort order to keep things clean.  Worst case is that we already have this defined in Intellij and just have to remember to auto-order imports every time.

A: Answering your questions:

*

*According to this ticket it looks like there is no way to achieve what you need using just CustomImportOrder. Instead you should use ImportOrder, complete example below.

*It is possible using ImportOrder
This should work for your case:
<module name="ImportOrder">
    <property name="option" value="top"/>
    <property name="groups" value="/^java\./,javax,/^com\.(?!mycompany)/,nthing.org,pthing,com.mycompany"/>
    <property name="ordered" value="true"/>
    <property name="separated" value="true"/>
    <property name="separatedStaticGroups" value="true"/>
    <property name="sortStaticImportsAlphabetically" value="true"/>
</module>

Small clarification. Inside the groups property there are two groups /^com\.(?!mycompany)/ and com.mycompany, first one is the regexp that use negative look-ahead, second one is just common prefix string for the import.


text:
Q: Is there a difference between @property and @propertyName.settter Recently I was dealing with properties and came across getters and setters. In most examples this kinda syntax was used
class ClassName():
    def __init__(self, xSize: int, ySize: int):
        self.xSize: int = xSize
        self.ySize: int = ySize

    @property
    def propertyName(self):
        return self._propertyName

    @propertyName.setter
    def propertyName(self, field: list):
        self._propertyName = field

My question is, is there a difference between that and this? In my code I tried both and they seemed to be working the same.
class ClassName():
    def __init__(self, xSize: int, ySize: int):
        self.xSize: int = xSize
        self.ySize: int = ySize

    @propertyName.getter
    def propertyName(self):
        return self._propertyName

    @playingField.setter
    def playingField(self, field: list):
        self._propertyName = field

A: Your first code is (mostly) equivalent (after desugaring the decorator syntax) to
class ClassName():
    def __init__(self, xSize: int, ySize: int):
        self.xSize: int = xSize
        self.ySize: int = ySize

    def propertyName(self):
        return self._propertyName

    propertyName = property(propertyName)

    def property_name(self, field: list):
        self._propertyName = field

    propertyName = propertyName.setter(propertyName)

(Decorator syntax takes care of evaluating propertyName.setter before the def statement rebinds the name, though.)
propertyName.setter is a method that takes a function as an argument and returns a new instance of property. When used as a decorator, it replaces the original property with the new one. It does not modify the existing property.
Your second code fails if you haven't yet defined propertyName when youu try to access propertyName.getter. If yours appears to work, it's because you are somehow executing it in an environment where a previous definition of propertyName is still in scope with an appropriate value.
There is nothing particularly magical about decorator syntax or properties. It's all straightforward function application and name binding.


text:
Q: Adding a background image to a card component from props I tried to insert a background image into the card component from props, got no error but the image did not display in the card component either. I can't really tell what I'm doing wrong. Please I need a better idea/way to go about fixing this issue. Thanks
project.js
import React from "react";
import { Card, CardTitle, CardText, CardActions, Button } from "react-mdl";

const Project = ({ image, technology, description, projectName }) => {
  return (

      <Card
        shadow={0}
        style={{ width: "320px", height: "320px", margin: "auto" }}
      >
        <CardTitle
          expand
          style={{
            color: "#fff",
            background: `url(${image})`,
          }}
        >
          {technology}
        </CardTitle>

{projectName}

        <CardText>{description}</CardText>
        <CardActions border>
          <Button colored>View Updates</Button>
        </CardActions>
      </Card>

  );
};

export default Project;

projects.js
import React from "react";
import { projectList } from "./projectList";
import Project from "./project";

const Projects = () => {
  return (

      {projectList.map((user, i) => {
        return (
          <Project
            key={i}
            id={projectList[i].id}
            technology={projectList[i].technology}
            projectName={projectList[i].projectName}
            description={projectList[i].description}
            image={projectList[i].image}
          />
        );
      })}

  );
};

export default Projects;

The image is imported into the projectList.js array of objects
projectList.js
import MIT from "../img/mit.png";

export const projectList = [
  {
    id: 1,
    technology: "HTML | CSS | Bootstrap",
    projectName: "Lorem",
    description: "Lorem Ipsum is simply dummy text.",
    image: { MIT },
  },
  {
    id: 2,
    technology: "Reactjs",
    projectName: "Lorem",
    description: "Lorem Ipsum is simply dummy text.",
    image: { MIT },
  },
  {
    id: 3,
    technology: "React Native",
    projectName: "Lorem",
    description: "Lorem Ipsum is simply dummy text.",
    image: { MIT },
  },
  {
    id: 4,
    technology: "Vue",
    projectName: "Lorem",
    description: "Lorem Ipsum is simply dummy text.",
    image: { MIT },
  },
  {
    id: 5,
    technology: "Angular",
    projectName: "Lorem",
    description: "Lorem Ipsum is simply dummy text.",
    image: { MIT },
  },

];

A: The example shows setting a Card background like this:
<Card shadow={0} style={{width: '320px', height: '320px', margin: 'auto'}}>
    <CardTitle expand style={{color: '#fff', background: 'url(http://www.getmdl.io/assets/demos/dog.png) bottom right 15% no-repeat #46B6AC'}}>Update</CardTitle>
    <CardText>
        Lorem ipsum dolor sit amet, consectetur adipiscing elit.
        Aenan convallis.
    </CardText>
    <CardActions border>
        <Button colored>View Updates</Button>
    </CardActions>
</Card>

Try using inline CSS to set a height and width or background property such as cover. Maybe the image is there but it doesn't have a height or width and isn't displaying.
Also, have you tried just putting the image in a img tag to test that it works in your component? Most likely the image isn't imported correctly or it is and it isn't showing because it lacks height and width.
Try something like this:
background: 'url(http://www.getmdl.io/assets/demos/welcome_card.jpg) center / cover'

A: The error is from projectList.js, the image key in the objects of the array.
Should have been like this
import MIT from "../img/mit.png";

export const projectList = [
  {
    id: 1,
    technology: "HTML | CSS | Bootstrap",
    projectName: "Lorem",
    description: "Lorem Ipsum is simply dummy text.",
    image: `${MIT}`,
  }
]


text:
Q: Best approach to Users Profile Images in Rails App I am new to Rails and have been diving into many tutorials and online material. I am now beginning to plan/develop my own app. From all the reading I have done I am yet to come across an industry standard way of handling user profile pictures. I have bullet point what I intend to do (below) and would like some suggestions whether this is a good approach and on the right track or whether there is a much better/secure/standard way:

*

*add a 'ProfilePhotoPath' column to my User Model/Table of type String, which will hold the location path/name of the photo

*on sign-up form implement an image upload functionality to upload profile pic and store at specified location (reference in step 1 above)

note: I have come across the 'paperclip gem' and 'imagemagick', is this a better easier approach to what I want to achieve?

A: There are two better ways to upload profile image using Carrierwave or Paperclip.
If you want to use Carrierwave then refer this tutorial Image Upload using Carrierwave
And if you want to go for Paperclip, then refer this links Upload image using Paperclip video tutorial
Another link with steps is Upload profile image using Paperclip

A: Most people use Paperclip or a more robust solution would be Carrierwave.
Both are really good. I would tell you to learn Paperclip first.
It's fairly easy if you're just starting out.
Edit: checkout this link. Click the green 'run' button to see the app.
http://runnable.com/UnnhcBiQoFhwAAEb/how-to-upload-files-using-paperclip-for-ruby-on-rails


text:
Q: Hyperledger indy validator-info basic explanation I am playing with hyperledger indy and it's validator-info, but I really cannot find what does the number in brackets (next to a node alias) mean.
I believe it has something with primary node but it's just my assumption and I have never seen any note about the number in indy's documentation. Could somebody explain me what does the number next to node alias eg. Node1  (0) or Node2  (1) mean?
Reachable Hosts:   4/4
  Node2 (1)
  Node1 (0)
  Node3
  Node4
Unreachable Hosts: 0/4

When I stop the Node2 I can see the Node2 has become Unreachable. The sign (1) is still next to Node2 as you can see below.
Reachable Hosts:   3/4
  Node4
  Node1 (0)
  Node3
Unreachable Hosts: 1/4
  Node2 (1)

However after couple of minutes (±5mins) number (1) for Node2 has disappeared.
Reachable Hosts:   3/4
  Node4
  Node3
  Node1 (0)
Unreachable Hosts: 1/4
  Node2

When I start Node2 again it becomes reachable again but the number next to Node2 is not here.
Reachable Hosts:   4/4
  Node1 (0)
  Node3
  Node2
  Node4
Unreachable Hosts: 0/4

*

*What has happened with the number?

*What does the number mean?

*Is there some delay or why I needed to wait
few minutes until (1) for Node2 disappeared.

*Even after 20+mins
the (1) has not been assigned to any of the Reachable hosts. Why?

A: Alright, after several hours of investigating history of git commits and INDY's jira I've found INDY-967 ticket.
There was a request for few additional features that will enhance validator-info usefulness.
Request:

Indicate the nodes that are the current primaries.  In the verbose human-readable output, this can be indicated by the primary number in parenthesis after the name of the nodes that are primaries, in this fashion:

Actually there is a comment similar to my OP - why the number has disappeared. And there is an answer for the question as well.

if node is primary for instance and it is disconnected for more than 2-3 min then whole instance is removed. if we do not have instance we cannot have primary for it, so it is expected that unreachable node is not a primary.
  also it is possible that some instance has no primary during view change

*

*What has happened with the number?

The instance has been disconnected and after few minutes consensus has decided to remove the instance so there is no need to keep the node as primary.

*

*What does the number mean?

The number indicates primary nodes. The (0) is primary node of 1st BFT protocol instance and (1) is second primary node from second BFT protocol instance - something like backup of (0) as it is defined in RBFT protocol white paper.

*

*Is there some delay or why I needed to wait few minutes until (1) for Node2 disappeared.

The delay is a period of time until consensus with new backup BFT protocol instance is reached. The 1 should be assigned to another node.

*

*Even after 20+mins the (1) has not been assigned to any of the Reachable hosts. Why?

My current assumption is that until primary BFT instance is the same the consensus and RBFT / Indy-Plenum's RBFT doesn't run new "election" aka view-change for primary instance or "round-robin" assignment with BFT instances. So if the node which is not available had backup primary replica it doesn't matter and doesn't require update of BFT instances.

A: Unlike other BFT protocols, RBFT focuses more on the worst-case performance. As a result, it runs the f+1 instance of the BFT protocol. One such instance is called a master instance, and others are called backup instances. The node assigned (0) is the primary node of the master instance, and the node assigned (1) or other number is the primary node of the backup instance. In case there is a considerable difference in the performance of the primary of the master and backup instance, then a view change is called to change the primary node of all the instances.


text:
Q: CSS - a tag width and height in IE I have the following code which works fine in all browsers other than IE.

test2

jquery:
$("a").hover( function () {
    $(".test").fadeOut();
});

css:
div {
    width:200px;
    height:100px;
    background-color:#B22;
    position:relative;
}

a {
    width:100%;
    height:100%;
    position:absolute;
    top:0px;
    left:0px;
    text-decoration:none;
}

The a tag is not spanning 100% width and height of the div. The odd thing is though, by removing the image from the div and only having the a tag in there, it works fine in all browsers including IE.
Does anyone know what might be happening to the a tag when there's an image in the div?

A: Use display:block and left:0; right:0; top:0; bottom:0 for 100% width and height.
See this http://jsfiddle.net/fliptheweb/RESTy/

A: Try removing the position declarations and use the image as a background for the anchor.
a {
    width:100%;
    height:100%;
    display: block;
    text-decoration:none;
    background-image: url(myimage.jpg);
}

An anchor is an inline element, it will not accept height and width as is. Givingit a position effectively sets it to a block element, but it may have other effects too. Try this, see what happens :)

A: Just use
$("a, img").hover( function () {
    $(".test").fadeOut();
});

DEMO:
http://jsfiddle.net/a4GAW/3/
Update:
If you click the img, you can use this workaround
$("img").click(function(){
    document.location = $(this).next("a").attr("href");
});

DEMO: http://jsfiddle.net/a4GAW/5/


text:
Q: AWS Cloudformation Parameters - How to make Subnet options available based on VPC I'm creating an EMR Cluster cloudformation template which will be used to create EMRs in different regions.
Since it's for multiple regions, I'm passing the vpc and subnet options as parameters so that we can choose the relevant during stack creation.
Parameters:
  VPC:
    Description: Choose the VPC for this EMR
    Type: AWS::EC2::VPC::Id

  Subnet:
    Description: Choose the subnet for this EMR
    Type: AWS::EC2::Subnet::Id

  KeyName:
    Description: Choose the keypair to login
    Type: AWS::EC2::KeyPair::KeyName

When I create the stack with this template, CF shows all the VPCs available in the region and all the subnets in available VPCs. How to modify it so that Subnet dropdown shows only the subnets available in the VPC we choose?

A: You cannot. Unfortunately not even by using lambda and custom attribute, because data for dropdowns are collected before select form is shown to user.


text:
Q: Bash mail doesn't preserve new-line from grep I am trying to grep something in the script and sending it as an email.The new line in the grep output is not being reflected in the email even if I use double quotes for the variable everywhere. Can someone point out the mistake or provide a workaround? Thanks.
Note: the \n added in the script are reflected but I want the grep output stored in "${Err_state}" separated by a newline.
Code:
Err_state=`qstat | grep ${PP_Jname}* | grep 'Eqw' | cut -f3 -d' '`
if [ ! -z "${Err_state}" ]; then
        err_msg="PostProcessing failed for :\n $Err_state \n\n Pls look into logs \n"
        SendEmail "$err_msg"

function SendEmail() {
err_msg="${1}"
err_msg="\n\nERROR: \n"${err_msg}"\n\n Terminating script...\n";
`echo -e "ERROR generated AutoProcess.sh:\n "${err_msg}"\n" | /bin/mail -s "OS_AutoProcess_wrapper.sh: ERROR" ${email_address}`
exit 1;
}


text:
Q: Get Real Time Date From a Site(ex. Weather Prediction ) With Python We have a Site that values are change every 20 millisecond for example
Weather Prediction sites. and I want to get real data and save them on redis in real time with python.
If I Use Request Library in python actually my program should be send a https request to server and get response that action may delay much more than 100 millisecond and I Can't get Real Time changes value.
So I don't Know Which Library is Useful for me?

A: For extracting data from a website without sending HTTP Requests to the Server to reload the whole webpage is to use Selenium Web driver instead.
Typically, on the web there are 2 types of websites:

*

*Static Websites - the ones that show the webpage fetched from the backend, and don't update on the frontend

*Dynamic Websites - the ones that are developed using a Front-end like React/Angular/Vue and fetch updates from the backend using API, without reloading the whole webpage.
To scrape a Static Website, its recommended to use the Requests Package, since it sends a HTTP/HTTPS Request to reload the whole webpage. Since in your case, the webpage is dynamic, you should work with Selenium. In the Selenium Code, you should first pass the website to be targeted, and then you can write a loop, which triggers a function to fetch the contents after every few milliseconds.
Tip: Use Selenium with headless to prevent the browser window from opening.
PS: Scraping is not legal with a lot of websites, since you are accessing their content programmatically. These websites have their own API's which are paid to provide you with the required content. So scrape at your own risk.


text:
Q: Are query execution plans stored anywhere in postgresql? I am trying to figure out if PostgreSQL query execution plans are stored somewhere (possibly as complimentary to pg_stat_statements and pg_prepared_statements) in a way they are available for longer than the duration of the session. I understand that PREPARE does cache a sql statement in pg_prepared_statements, though the plan itself does not seem to be available in any view as far as I can tell.
I am not sure if there is a doc explaining the life cycle of a query plan for PostgreSQL but from what it sounds in the EXPLAIN documentation, PostgreSQL does not cache query plans at all. Is this accurate?
Thanks!

A: PostgreSQL has no shared storage for execution plans, so they cannot be reused across database sessions.
There are two ways to cache an execution plan within a session:

*

*Use prepared statements with the SQL statements PREPARE and EXECUTE. The plan will be cached for the life time of the prepared statement, usually until your session ends.

*Use PL/pgSQL functions. The plans for all static SQL statements (that is, statements that are not run with EXECUTE) in such a function will be cached for the session life time.
Other than that, execution plans are not cached in PostgreSQL.


text:
Q: Growth of the reciprocal gamma function in the critical strip I was wondering if there are any results that studied the growth of $\left|\frac{1}{\Gamma(s)}\right|$ where $0 < \Re(s) < 1$ and as $\Im(s) \to \infty$? Any pointers to any results, papers, references will be highly appreciated.
Thanks.

A: According to Gradshteyn-Ryzhik: Tables of integrals... 8.328.1, for fixed real $x$ and for $|y|\to\infty$ one has
$$
|\Gamma(x+iy)|\sim\sqrt{2\pi}e^{-\frac\pi 2|y|}|y|^{x-\frac12}.
$$


text:
Q: Loading node modules failed I created an ASP.NET MVC project in Visual Studio 2017 with Angular 2,
installed node.
package.json
{
  "version": "1.0.0",
  "name": "asp.net",
  "private": true,
  "scripts": {
    "webpack-script": "webpack",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "-vs-binding": {
    "BeforeBuild": [
      "webpack-script"
    ]
  },
  "devDependencies": {
    "bootstrap": "^4.0.0-beta",
    "clean-webpack-plugin": "^0.1.16",
    "imports-loader": "^0.7.1",
    "jquery": "^2.2.4",
    "popper.js": "^1.12.5",
    "ts-loader": "^2.3.5",
    "typescript": "^2.5.2",
    "webpack": "^3.5.6",
    "concurrently": "2.2.0",
    "systemjs-builder": "0.15.32",
    "json-server": "0.8.21",
    "jsonwebtoken": "7.1.9"
  },
  "dependencies": {
    "@angular/animations": "^4.3.6",
    "@angular/common": "^4.3.6",
    "@angular/compiler": "^4.3.6",
    "@angular/compiler-cli": "^4.3.6",
    "@angular/core": "^4.3.6",
    "@angular/forms": "^4.3.6",
    "@angular/http": "^4.3.6",
    "@angular/platform-browser": "^4.3.6",
    "@angular/platform-browser-dynamic": "^4.3.6",
    "@angular/platform-server": "^4.3.6",
    "@angular/router": "^4.3.6",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.4",
    "reflect-metadata": "^0.1.10",
    "rxjs": "5.0.1",
    "zone.js": "^0.8.4",
    "core-js": "^2.4.1",
    "classlist.js": "^1.1.20150312",
    "systemjs": "0.19.40",
    "bootstrap": "^4.0.0-beta",
    "font-awesome": "^4.7.0",
    "intl": "^1.2.5",
    "html5-history-api": "^4.2.8",
    "file-loader": "^0.11.2",
    "css-loader": "^0.28.7",
    "jquery": "^2.2.4",
    "popper": "^1.0.0",
    "style-loader": "^0.18.2",
    "url-loader": "^0.5.9",
    "webpack": "^3.5.6"
  }
}

systemjs.config.js
(function (global) {
    var map = {
        'app': 'app', // 'dist',
        '@angular': 'node_modules/@angular',
        'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
        'rxjs': 'node_modules/rxjs'
    };
    // packages tells the System loader how to load when no filename and/or no extension
    var packages = {
        'app': { main: 'main.js', defaultExtension: 'js' },
        'rxjs': { defaultExtension: 'js' },
        'angular2-in-memory-web-api': { main: 'index.js', defaultExtension: 'js' },
    };
    var ngPackageNames = [ // <-----
        'common',
        'compiler',
        'core',
        'http',
        'platform-browser',
        'platform-browser-dynamic',
        'router',
        'router-deprecated',
        'upgrade',
    ];
    // Individual files (~300 requests):
    function packIndex(pkgName) {
        packages['@angular/' + pkgName] = { main: 'index.js', defaultExtension: 'js' };
    }
    // Bundled (~40 requests):
    function packUmd(pkgName) {
        packages['@angular/' + pkgName] = { main: pkgName + '.umd.js', defaultExtension: 'js' };
    };
    // Most environments should use UMD; some (Karma) need the individual index files
    var setPackageConfig = System.packageWithIndex ? packIndex : packUmd;
    // Add package entries for angular packages
    ngPackageNames.forEach(setPackageConfig);
    var config = {
        map: map,
        packages: packages
    }
    System.config(config);
})(this);

_Layout.cshtml in the head section I added
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<base href="/" />
<title>@ViewData["Title"] - LanguageSchool.Web</title>

<environment include="Development">
    <script src=@Url.Content("~/node_modules/html5-history-api/history.min.js")></script>
    <script src="./node_modules/classlist.js/classList.min.js"></script>
    <script src="./node_modules/core-js/client/shim.min.js"></script>
    <script src="node_modules/intl/dist/Intl.complete.js"></script>
    <script src="node_modules/zone.js/dist/zone.min.js"></script>
    <script src="node_modules/reflect-metadata/Reflect.js"></script>
    <script src="./node_modules/systemjs/dist/system.src.js"></script>
    <script src="rxjs.module.min.js"></script>
    <script src="systemjs.config.js"></script>
    <script>
        System.import("app/main").catch(function (err) { console.error(err); });
    </script>
    <link href="node_modules/bootstrap/dist/css/bootstrap.min.css"
          rel="stylesheet" />
    <link href="node_modules/font-awesome/css/font-awesome.min.css"
          rel="stylesheet" />
    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
    <link rel="stylesheet" href="~/css/site.css" />
</environment>

But when I try to load the page I get a number of errors:

Loading failed for the  with source
  "https://localhost:44341/node_modules/html5-history-api/history.min.js".
  localhost:44341:10 Loading failed for the  with source
  "https://localhost:44341/node_modules/classlist.js/classList.min.js".
  localhost:44341:11 Loading failed for the  with source
  "https://localhost:44341/node_modules/core-js/client/shim.min.js".
  localhost:44341:12 Loading failed for the  with source
  "https://localhost:44341/node_modules/intl/dist/Intl.complete.js".
  localhost:44341:13 Loading failed for the  with source
  "https://localhost:44341/node_modules/zone.js/dist/zone.min.js".
  localhost:44341:14 Loading failed for the  with source
  "https://localhost:44341/node_modules/reflect-metadata/Reflect.js".
  localhost:44341:15 Loading failed for the  with source
  "https://localhost:44341/node_modules/systemjs/dist/system.src.js".
  localhost:44341:16 Loading failed for the  with source
  "https://localhost:44341/rxjs.module.min.js".  localhost:44341:17
  Loading failed for the  with source
  "https://localhost:44341/systemjs.config.js".

Updates:
main.ts
window["$"] = window["jQuery"] = require("jquery");

import { platformBrowserDynamic } from "@angular/platform-browser-dynamic";
import { AppModule } from "./app.module";
platformBrowserDynamic().bootstrapModule(AppModule).
    then(success => console.log('Bootstrap success')).
    catch(error => console.log(error));

app.modules.ts
import { NgModule } from "@angular/core";
import { BrowserModule } from "@angular/platform-browser";
import { AppComponent } from "./app.component";

@NgModule({
    imports: [BrowserModule],
    declarations: [AppComponent],
    bootstrap: [AppComponent]
})
export class AppModule { }

app.components.ts
import { Component } from "@angular/core";

@Component({
    selector: "app",
    template: `<div class="bg-success p-a-1 text-xs-center">
This is SportsStore
</div>`
})
export class AppComponent { }

A: Take a look at the source paths you set. Your compiler can not find the files.
You haven't set them properly.
 <script src=@Url.Content("~/node_modules/html5-history-api/history.min.js")></script>
<script src="./node_modules/classlist.js/classList.min.js"></script>
<script src="./node_modules/core-js/client/shim.min.js"></script>
<script src="node_modules/intl/dist/Intl.complete.js"></script>
<script src="node_modules/zone.js/dist/zone.min.js"></script>
<script src="node_modules/reflect-metadata/Reflect.js"></script>
<script src="./node_modules/systemjs/dist/system.src.js"></script>
<script src="rxjs.module.min.js"></script>
<script src="systemjs.config.js"></script>
<script>
    System.import("app/main").catch(function (err) { console.error(err); });
</script>
<link href="node_modules/bootstrap/dist/css/bootstrap.min.css"
      rel="stylesheet" />
<link href="node_modules/font-awesome/css/font-awesome.min.css"
      rel="stylesheet" />
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />


text: Q: Why is uncorrelated(exogeneity) "good enough" for identification in regression? Let the model $y=x+x^2-1$ be exactly correct, where $x\sim N(0,1)$, then $x^2\sim \chi^2_{(1)}$.  Say we want to estimate the model $y=\beta x-1+\epsilon$ by least squares.  Let $(y_i,x_i)_{i=1}^n\overset{iid}{\sim}$.  So we should have an omitted variable bias.  Solving for $\beta$, you get $$\overset{\wedge}{\beta}\rightarrow\frac{cov(x,y)+E(x)}{var(x)}=\frac{cov(x,x+x^2)+E(x)}{var(x)}=\beta+\frac{cov(x,x^2)}{var(x)}+\frac{E(x)}{var(x)}=\beta$$ as $cov(x,x^2)=0$, and $E(x)=0$.  So it seems like we identified $x$ correctly by $\beta$, but the marginal effect of $x$ is $\frac{dy}{dx}=\beta+2x$, so we haven't identified the effect of $x$. So why don't we need the error term and the regressors to be independent, instead of just uncorrelated?  This question is really a precursor for why in GMM, specifically IV, we need our instruments to only be uncorrelated with the error term, and not independent of it, as without that, we don't identify the complete effect of $x$.  It seems like especially for non-linear regressions, we would need independence to identify the effect of our independent variable.


text:
Q: Linux Mint gcc++ : can't install gcc++ because of broken packages I am a student of CS and new to Linux Mint 18.2.
I am trying to run a simple project in Clion but apparently I have a problem with my gcc++ compiler.
I try to run this command in terminal:
sudo apt-get install gcc++

and gets the following:
    Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting 'gcc-4.9-hppa-linux-gnu' for regex 'gcc+'
Note, selecting 'libsfgcc1-dbg-armhf-cross' for regex 'gcc+'

Long list of Note, selecting ......
and the end of this is:
The following packages have unmet dependencies:
 gcc-4.7-plugin-dev : Depends: libgmpv4-dev (>= 2:5.0.1~) but it is not going to be installed
 gcc-4.8-aarch64-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.8-arm-linux-gnueabihf : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.8-multilib : Depends: libc6-dev-x32 (>= 2.11) but it is not going to be installed
 gcc-4.8-powerpc-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.8-powerpc64le-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.9-aarch64-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.9-arm-linux-gnueabi : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.9-arm-linux-gnueabihf : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.9-multilib : Depends: libc6-dev-x32 (>= 2.11) but it is not going to be installed
 gcc-4.9-powerpc-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.9-powerpc64le-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-4.9-s390x-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-aarch64-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-alpha-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-arm-linux-gnueabi : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-arm-linux-gnueabihf : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-hppa-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-m68k-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-mips-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-mips64-linux-gnuabi64 : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-mips64el-linux-gnuabi64 : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-mipsel-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-multilib : Depends: libc6-dev-x32 (>= 2.11) but it is not going to be installed
 gcc-5-powerpc-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-powerpc-linux-gnuspe : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-powerpc64-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-powerpc64le-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-s390x-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-sh4-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-5-sparc64-linux-gnu : Conflicts: gcc-multilib but 4:5.3.1-1ubuntu1 is to be installed
 gcc-multilib : Conflicts: gcc-4.9-aarch64-linux-gnu but 4.9.3-13ubuntu2cross1 is to be installed
                Conflicts: gcc-4.9-arm-linux-gnueabi but 4.9.3-13ubuntu2cross1 is to be installed
                Conflicts: gcc-4.9-arm-linux-gnueabihf but 4.9.3-13ubuntu2cross1 is to be installed
                Conflicts: gcc-4.9-powerpc-linux-gnu but 4.9.3-13ubuntu2cross1 is to be installed
                Conflicts: gcc-4.9-powerpc64le-linux-gnu but 4.9.3-13ubuntu2cross1 is to be installed
                Conflicts: gcc-4.9-s390x-linux-gnu but 4.9.3-13ubuntu2cross1 is to be installed
                Conflicts: gcc-5-aarch64-linux-gnu
                Conflicts: gcc-5-alpha-linux-gnu
                Conflicts: gcc-5-arm-linux-gnueabi
                Conflicts: gcc-5-arm-linux-gnueabihf
                Conflicts: gcc-5-hppa-linux-gnu
                Conflicts: gcc-5-m68k-linux-gnu
                Conflicts: gcc-5-mips-linux-gnu
                Conflicts: gcc-5-mips64-linux-gnuabi64
                Conflicts: gcc-5-mips64el-linux-gnuabi64
                Conflicts: gcc-5-mipsel-linux-gnu
                Conflicts: gcc-5-powerpc-linux-gnu
                Conflicts: gcc-5-powerpc-linux-gnuspe
                Conflicts: gcc-5-powerpc64-linux-gnu
                Conflicts: gcc-5-powerpc64le-linux-gnu
                Conflicts: gcc-5-s390x-linux-gnu
                Conflicts: gcc-5-sh4-linux-gnu
                Conflicts: gcc-5-sparc64-linux-gnu
                Conflicts: gcc-5-aarch64-linux-gnu:i386
                Conflicts: gcc-5-arm-linux-gnueabihf:i386
                Conflicts: gcc-5-powerpc-linux-gnu:i386
                Conflicts: gcc-5-powerpc64le-linux-gnu:i386
                Conflicts: gcc-5-alpha-linux-gnu:i386
                Conflicts: gcc-5-arm-linux-gnueabi:i386
                Conflicts: gcc-5-hppa-linux-gnu:i386
                Conflicts: gcc-5-m68k-linux-gnu:i386
                Conflicts: gcc-5-mips-linux-gnu:i386
                Conflicts: gcc-5-mips64-linux-gnuabi64:i386
                Conflicts: gcc-5-mips64el-linux-gnuabi64:i386
                Conflicts: gcc-5-mipsel-linux-gnu:i386
                Conflicts: gcc-5-powerpc-linux-gnuspe:i386
                Conflicts: gcc-5-powerpc64-linux-gnu:i386
                Conflicts: gcc-5-s390x-linux-gnu:i386
                Conflicts: gcc-5-sh4-linux-gnu:i386
                Conflicts: gcc-5-sparc64-linux-gnu:i386
 gcc-snapshot : Depends: libc6-dev-x32 (>= 2.11) but it is not going to be installed
                Depends: libc6-x32 (>= 2.23) but it is not going to be installed
 gccgo-4.7-multilib : Depends: libx32go0 (>= 4.7.4-3ubuntu12) but it is not going to be installed
 gccgo-4.8-multilib : Depends: libx32go4 (>= 4.8.5-4ubuntu2) but it is not going to be installed
 gccgo-4.9-multilib : Depends: libx32go5 (>= 4.9.3-13ubuntu2) but it is not going to be installed
 gccgo-5-multilib : Depends: libx32go7 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
 gccgo-6-multilib : Depends: libx32go9 (>= 6.0.1-0ubuntu1) but it is not going to be installed
 lib32gcc-4.7-dev : Depends: libx32gomp1 (>= 4.7.4-3ubuntu12) but it is not going to be installed
                    Depends: libx32itm1 (>= 4.7.4-3ubuntu12) but it is not going to be installed
                    Depends: libx32quadmath0 (>= 4.7.4-3ubuntu12) but it is not going to be installed
 lib32gcc-4.8-dev : Depends: libx32gomp1 (>= 4.8.5-4ubuntu2) but it is not going to be installed
                    Depends: libx32itm1 (>= 4.8.5-4ubuntu2) but it is not going to be installed
                    Depends: libx32atomic1 (>= 4.8.5-4ubuntu2) but it is not going to be installed
                    Depends: libx32asan0 (>= 4.8.5-4ubuntu2) but it is not going to be installed
                    Depends: libx32quadmath0 (>= 4.8.5-4ubuntu2) but it is not going to be installed
 lib32gcc-4.9-dev : Depends: libx32gomp1 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                    Depends: libx32itm1 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                    Depends: libx32atomic1 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                    Depends: libx32asan1 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                    Depends: libx32ubsan0 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                    Depends: libx32cilkrts5 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                    Depends: libx32quadmath0 (>= 4.9.3-13ubuntu2) but it is not going to be installed
 lib32gcc-5-dev : Depends: libx32gomp1 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                  Depends: libx32itm1 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                  Depends: libx32atomic1 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                  Depends: libx32asan2 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                  Depends: libx32ubsan0 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                  Depends: libx32cilkrts5 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                  Depends: libx32quadmath0 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
 lib64gcc-4.7-dev:i386 : Depends: libx32gcc1:i386 (>= 1:4.7.4-3ubuntu12) but it is not going to be installed
 lib64gcc-4.8-dev:i386 : Depends: libx32gcc1:i386 (>= 1:4.8.5-4ubuntu2) but it is not going to be installed
                         Depends: libx32asan0:i386 (>= 4.8.5-4ubuntu2) but it is not going to be installed
 lib64gcc-4.9-dev:i386 : Depends: libx32gcc1:i386 (>= 1:4.9.3-13ubuntu2) but it is not going to be installed
                         Depends: libx32asan1:i386 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                         Depends: libx32ubsan0:i386 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                         Depends: libx32cilkrts5:i386 (>= 4.9.3-13ubuntu2) but it is not going to be installed
 lib64gcc-5-dev:i386 : Depends: libx32gcc1:i386 (>= 1:5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                       Depends: libx32asan2:i386 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                       Depends: libx32ubsan0:i386 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                       Depends: libx32cilkrts5:i386 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
 libx32gcc-4.7-dev : Depends: libx32gomp1 (>= 4.7.4-3ubuntu12) but it is not going to be installed
                     Depends: libx32itm1 (>= 4.7.4-3ubuntu12) but it is not going to be installed
                     Depends: libx32quadmath0 (>= 4.7.4-3ubuntu12) but it is not going to be installed
 libx32gcc-4.8-dev : Depends: libx32gomp1 (>= 4.8.5-4ubuntu2) but it is not going to be installed
                     Depends: libx32itm1 (>= 4.8.5-4ubuntu2) but it is not going to be installed
                     Depends: libx32atomic1 (>= 4.8.5-4ubuntu2) but it is not going to be installed
                     Depends: libx32asan0 (>= 4.8.5-4ubuntu2) but it is not going to be installed
                     Depends: libx32quadmath0 (>= 4.8.5-4ubuntu2) but it is not going to be installed
 libx32gcc-4.9-dev : Depends: libx32gomp1 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                     Depends: libx32itm1 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                     Depends: libx32atomic1 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                     Depends: libx32asan1 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                     Depends: libx32ubsan0 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                     Depends: libx32cilkrts5 (>= 4.9.3-13ubuntu2) but it is not going to be installed
                     Depends: libx32quadmath0 (>= 4.9.3-13ubuntu2) but it is not going to be installed
 libx32gcc-5-dev : Depends: libx32gomp1 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                   Depends: libx32itm1 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                   Depends: libx32atomic1 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                   Depends: libx32asan2 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                   Depends: libx32ubsan0 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                   Depends: libx32cilkrts5 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
                   Depends: libx32quadmath0 (>= 5.4.0-6ubuntu1~16.04.5) but it is not going to be installed
 libx32gcc1 : Depends: libc6-x32 (>= 2.16) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

How can I fix this?

A: You need to install the g++ package:
sudo apt install g++

(Trying to install gcc++ produces the strange results you're getting because gcc++ doesn't match a package name, so apt-get interprets it as a regex and tries to install all the matching packages, which it can't because they conflict with each other.)


text:
Q: I can not get Openshift oc command line tool 32 bit version for linux (ubuntu) On project overview page of Openshift v3 (developer preview) by going to help->Command Line Tools , it only shows 64 bit version for linux but not 32 bit.

A: You can get the oc tool directly from the OpenShift Origin Git Repo: https://github.com/openshift/origin/releases/tag/v1.2.2
They provide a 32-bit client for linux there!


text:
Q: Unexpected OutOfMemoryException in ILNumerics The following VB .net code gives me an out of memory exception. Does anybody knows why?
Dim vArray As ILArray(Of Double) = ILMath.rand(10000000)

Using ILScope.Enter(vArray)
   For i As Integer = 1 To 100
     vArray = ILMath.add(vArray, vArray)
   Next
End Using

Thank you very much.

A: In this toy example you can simply remove the artificial scope and it will run fine:
Dim vArray As ILArray(Of Double) = ILMath.rand(10000000)

For i As Integer = 1 To 100
    vArray = ILMath.add(vArray, vArray)
Next
Console.WriteLine("OK: " + vArray(0).ToString())
Console.ReadKey()

However, in a more serious situation, ILScope will be your friend. As stated on the ILNumerics page an artificial scope ensures a deterministic memory management:

All arrays created inside the scope are disposed once the block was
  left.

Otherwise one had to rely on the GC for cleanup. And, as you know, this involves a gen 2 collection for large objects – with all disadvantages in terms of performance.
In order to be able to dispose the arrays they need to be collected and tracked somehow. Whether or not this qualifies for the term 'memory leak' is rather a philosophical question. I will not go into it here. The deal is: after the instruction pointer runs out of the scope these arrays are taken care of: their memory is put into the memory pool and will be reused. As a consequence, no GC will be triggered.
The scheme is especially useful for long running operations and for large data. Currently, the arrays are released only AFTER the scope block was left. So if you create an algorithm/ loop which requires more memory than available on your machine you need to clean up DURING the loop already:
    Dim vArray As ILArray(Of Double) = ILMath.rand(10000000)

    For i As Integer = 1 To 100
        Using ILScope.Enter
            vArray.a = ILMath.add(vArray, vArray)
            ' ...
        End Using
    Next

Here, the scope cleans up the memory after each iteration of the loop. This affects all local arrays assigned within the loop body. If we want an array value to survive the loop iteration we can assign to its .a property as shown with vArray.a.


text:
Q: How to add functionality of Google SIgn-In in Phonegap Hybrid HTML app How to implement Google Login in Phonegap App & also how to check whether the user is logged in or not as soon as the user opens up the app ? I am already aware of the EddyVerbruggen Plugin but it doesn't tells the status of login, it just logs in the user and also its trysilentLogin method doesn't works (yields error : 4) . Without knowing the login status how can I direct my users to the welcome page of my app.
HTML :
<body onload="init()">
</body>

config.xml :
    <plugin name="cordova-plugin-googleplus" source="npm" spec="5.2.1">

    </plugin>

login.js  :
function init()
{

    document.addEventListener("deviceready", onDeviceReady, false);

}

    var onDeviceReady = function()
                            {

        window.plugins.googleplus.trySilentLogin(
            {

                'scopes': '',
                'offline': false
            },
            function (obj) {

                alert(JSON.stringify(obj)); // do something useful instead of alerting

                        alert(' YES LOGGED IN ::: GOOGLE ');

            },
            function (msg) {

              alert(' GOOGLE LOGIN error: ' + msg); //here comes the error : 4

            }
        );


text:
Q: Should I build individual apps or build one with a coded log in? I'm building apps for multiple Home Owners Associations (HOAs). Each app is branded with their community logo, etc., and would have a short property code to log-in.
At first, the thought was to build individual apps for each property. Now, I'm wondering if it'd be better and more efficient to have a single "portal" app that initially asks for their specific property-code.
After code entry it would bring them to their property's dashboard.
What would I generally need set up on the back end to build that?
Is it better than creating individual apps for each property?
Any informed opinions are appreciated.

A: You should submit a single app that allows the user to select their property. Submitting multiple, essentially identical, apps will lead to rejection during review.
This is covered by clause 4.3 of the App Store Review Guidelines

4.3 Spam
Don't create multiple Bundle IDs of the same app. If your app has different versions for specific locations, sports teams, universities, etc., consider submitting a single app and provide the variations using in-app purchase.

Note that using in-app purchase is just an example. It is not required and would not apply in the situation you describe.
Unfortunately, your other question regarding a back end is too broad for this site and is asking for recommendations. These are off-topic.


text:
Q: Quick blox - Signature generation issue I am trying to use this link to get described response:
{
  "session": {
    "application_id": 2,
    "created_at": "2012-04-03T07:34:48Z",
    "device_id": null,
    "id": 743,
    "nonce": 1308205278,
    "token": "0e7bc95d85c0eb2bf052be3d29d3df523081e87f",
    "ts": 1333438438,
    "updated_at": "2012-04-03T07:34:48Z",
    "user_id": null
  }
}

But now it say application not found:
<?xml version="1.0" encoding="UTF-8"?>
<errors>
  <error>No application found</error>
</errors>

Can't go ahead to test another requests. This is a shell script I used for getting curl request:
timestamp=`date +%s`

body="application_id=HIDDENAPPLICATIONIDHERE&auth_key=HIDDENAUTHKEYHERE&nonce=2342546&timestamp=$timestamp"

signature=`echo -n $body | openssl sha -hmac HIDDENSECRETHERE`

body=$body"&signature="$signature

#echo $body
#echo $signature

#exit 0

curl -X POST \
-H "QuickBlox-REST-API-Version: 0.1.0" \
-d $body \
https://api.quickblox.com/session.xml

So there some info regrding this maybe I've created shell script to a wrong way:

HMAC-SHA function of the body of the request, with a key auth_secret.
  Request body is formed as the sorted (sorting alphabetically, as
  symbols, not as bytes) by increase the string array 'parameter=value',
  separated with the symbol "&". For the parameters passed as a
  user[id]=123 is used just such a line of user[id]=123

Also I've prepped a Swift project how to generate signature and get session, but still has the same error with no application found.
Any recommendation? Thanks

A: Please verify Application ID parameter because server return:
<?xml version="1.0" encoding="UTF-8"?>
<errors>
  <error>No application found</error>
</errors>

For example generate signature (Java):
    Random random = new Random();

    String nonce = Integer.toString(random.nextInt());
    long time = System.currentTimeMillis() / 1000;
    String timestamp = Long.toString(time);
    String signature;

    String str = "application_id=" + applicationId + "&" + "auth_key=" + authKey + "&" + "nonce="
            + nonce + "&" + "timestamp=" + timestamp + "&" + "user[login]=" + adminLogin + "&" + "user[password]="
            + adminPassword;

    signature = UtilsMethods.calculateHMAC_SHA(str, authSecret);

calculateHMAC_SHA:
private static final String HMAC_SHA1_ALGORITHM = "HmacSHA1";

    public static String calculateHMAC_SHA(String data, String key) throws SignatureException {
        String result = null;
        try {

            // get an hmac_sha1 key from the raw key bytes
            SecretKeySpec signingKey = new SecretKeySpec(key.getBytes(), HMAC_SHA1_ALGORITHM);

            // get an hmac_sha1 Mac instance and initialize with the signing key
            Mac mac = Mac.getInstance(HMAC_SHA1_ALGORITHM);
            mac.init(signingKey);

            byte[] digest = mac.doFinal(data.getBytes());

            StringBuilder sb = new StringBuilder(digest.length * 2);
            String s;
            for (byte b : digest) {
                s = Integer.toHexString(0xFF & b);
                if (s.length() == 1) {
                    sb.append('0');
                }

                sb.append(s);
            }

            result = sb.toString();

        } catch (Exception e) {
            throw new SignatureException("Failed to generate HMAC : " + e.getMessage());
        }

        return result;
    }