seo – Site Structure: Separating public pages from member pages

Context: I am designing a web application that’s geared toward members-only features. There’s no site features that would be useful to non-members, so most of the website will only be available to authenticated users. Thus, the only public pages will be things like an About Us page (with contact options), a Features/Comparisons page (promote the service relative to competitors), and of course a Home Page.

Problem: My initial thought was that the homepage index.php file, located at the website root, should load the public content for non-authenticated visitors, but should load the main application landing page for authenticated users. My main reason was for members’ ease-of-access — automatic serving of the content they’re actually trying to get to if they’re already logged in, and no need to type / remember / bookmark a more complicated address than mysite.com. But this got me thinking whether that would work best in the long run for issues like SEO and maintainability.

Approaches: I can think of three:

  1. All files are hosted under mysite.com, with no subdomains. When a visitor requests mysite.com/index.php, it checks for authentication, and serves up the correct HTML depending. (This is the approach I mentioned above.)
  2. Public files are hosted under www.mysite.com, while member-only pages are hosted under a subdomain like members.mysite.com. When an authenticated user attempts to access the public www.mysite.com/index.php, they’ll be automatically redirected to members.mysite.com/index.php.
  3. The same as option 2, but instead of being automatically redirected, the user will stay on the public homepage, and will need to navigate to their application landing page via the main nav. (This approach seems best if some of the public pages actually have usefulness to authenticated users, which they won’t on my site, so I’m thinking this option doesn’t make sense?)

Are there other options I’m not thinking of?

Questions:

  • How does each approach affect SEO, if at all?
  • Which of those approaches tends to be easiest to code for and maintain in the long run?

seo – Site Structure: Best practices for separating public pages from member pages

Context: I am designing a web application that’s geared toward members-only features. There’s no site features that would be useful to non-members, so most of the website will only be available to authenticated users. Thus, the only public pages will be things like an About Us page (with contact options), a Features/Comparisons page (promote the service relative to competitors), and of course a Home Page.

Problem: My initial thought was that the homepage index.php file, located at the website root, should load the public content for non-authenticated visitors, but should load the main application landing page for authenticated users. My main reason was for members’ ease-of-access — automatic serving of the content they’re actually trying to get to, and no need to type / remember / bookmark a more complicated address than mysite.com. But this got me thinking whether that would be best practice. I couldn’t find anything with a few Google searches, so….

Approaches: I can think of three:

  1. As mentioned above: All files are hosted under mysite.com, with no subdomains. When a visitor requests mysite.com/index.php, it checks for authentication, and serves up the correct HTML depending.
  2. Public files are hosted under www.mysite.com, while member-only pages are hosted under a subdomain like members.mysite.com. When an authenticated user attempts to access the public www.mysite.com/index.php, they’ll be automatically redirected to members.mysite.com/index.php.
  3. The same as option 2, but instead of being automatically redirected, the user will stay on the public homepage, and will need to navigate to their application landing page via the main nav. (This approach seems best if some of the public pages actually have usefulness to authenticated users, which they won’t on my site, so I’m thinking this option doesn’t make sense?)

Questions:

  • Are there other options I’m not thinking of?
  • Is there a clearly established best practice for this situation?
  • How does each approach affect SEO, if at all?
  • Which of those approaches tends to be easiest to code for and maintain in the long run?

fa.functional analysis – Function spaces and their “minimal” separating set (upto some kind of topological equivalence)

There is a very wide series of questions I have been thinking about and I am wondering if there is any literature on this type of structures.

Let’s start with the set of all functions $mathcal{F}: mathbb{R} to mathbb{R}$. The subsets of this set form a lattice (based on set inclusion). Let $mathbb{P_n}, mathcal{C} text{and} mathcal{C}$ be the rings of polynomials with degree at most $n$, analytic functions, and continuous functions respectively. So that in the lattice structure we have $mathbb{P_0} subset mathbb{P_3} subset mathcal{A} subset mathcal{C} subset mathcal{F}$. For simplicity limit the elements of this lattice to those sets which form a ring of functions (I am not sure why, but this seems like a good restriction).

Suppose we are given a subset of $mathcal{F}$ which is a ring, let’s call this $mathcal{R}$. Suppose we also a set of points $mathbb{S} subset mathbb{R}$. Then we say $mathbb{S}$ is a separating set of $mathcal{R}$, if for any $f,g subset mathcal{R}$ there is an $x in mathbb{S}$, such that $f(x) neq g(x)$. Essentially the values of a function on $mathbb{S}$ uniquely determine the function in $mathcal{R}$.

So, let’s look at what some of these sets look like.

Ring of Functions Separating set
$mathbb{P_0}$ ${x_0 | x_0 in mathbb{R}}$, any singleton
$mathbb{P_n}$ ${x_0, x_1, …, x_n | x_i in mathbb{R}, x_i neq x_j text{ if } i neq j }$, any set of n points
$mathcal{A}$ $mathbb{S} subset mathbb{R}$, such that $mathbb{S}$ has a limit point.
$mathcal{C}$ $mathbb{S} subset mathbb{R}$, such that $mathbb{S}$ is dense in $mathbb{R}$
$mathcal{F}$ $mathbb{R}$

These sets seem to be capturing some kind of topological property. I am not sure about what time of topological equivalence would capture these sets. On the other hand these sets definitely form a lattice as well through inclusion. There is an anti-correspondence between these sets and their corresponding function rings.

Do these functions sets have to be rings? No, but it seems like a good idea.

Does the base field have to be $mathbb{R}$? No, but it is a good starting place.

What I am interested in is if the topological property can be well defined and some kind of lattice be determined on it from which we can recover the lattice of functions. It will probably dictate the structure of the function sets (rings, groups, etc).

optimization – Finding optimal separating value

Problem description

We are given two sorted arrays of even numbers: A and B.
Values of A are generally supposed to be smaller than values of B. So we are asked to find a value X where X is an odd number to predict which set an element belongs to. If an element is smaller than X, it will be assigned to A,and if it is bigger – to B. The value should be optimal, meaning the number of improperly matched values should be minimal.
For example, if A = (2,4,6) and B = (6, 10, 12). Separating value 3 would cause 2 mismatched values 4 and 6. Optimal would be 5 or 7, both causing one improper matched element.
The algorithm is supposed to return an optimal separating value (only one of there are many) and the number of mismatched items.

My ideas

At first I thought about using Binary Search for each element of A to find a number of elements of B smaller than it. Then repeat for B.

A better idea would be to generate candidates for such separating numbers. For example, if we only have values 10, 50, 100 we don’t have to check all odd numbers, we can just check 9, 11, 51, 101. We could then calculate prefix sums, indicating how many numbers from A are bigger than the checked value and how many elements from B are smart than that value. The sum of the two sums for a number would be the total number of errors. The only thing left is to find the value with minimal errors.

Is this approach even near optimal, maybe we can find a better way. Also, calculating such prefix sums can be tricky because if we want not to care about the range of numbers we would have to find a way to skip some numbers and that makes our iteration harder, although possible.

What are your ideas? Some pseudocode or code in Python is very welcome.

image processing – Separating boundaries from WatershedComponents

I am trying to look for local minimum on the boundaries between watershed regions.

Typically the boundaries are not connected and spanning across the whole image so it is possible to do it through

MorphologicalComponents[
  1 - ImageData[Binarize[Colorize[WatershedComponents[image]], 0.1]]
]

The problem is when there are more than two watershed components are intersecting at a point and the boundary collides. The boundaries will then considered as one entity. This is illustrated as the green line in the picture where the watershed components are treated as the foregrounds.

boundary merged

Is there an efficient way to get unique pixels corresponding to the boundaries between two watershed components?

Which is a good way of separating and organizing layers and subdomains code, one that highlights and facilitates a clean architecture?

As I understand, when following the Low Coupling High Cohesion Principle, I should keep together the code that is related to same theme, splitting the code into modules/submodules by its “domain” or, in other words by what “topic” it is about, not by its “type”.

  • E.g. it can be considered a bad idea to keep all interfaces together just because they’re interfaces and keep all classes in other place. Or to keep all controllers in one place just because they’re controllers, and all adapters in other. Etc.

  • A better option is to keep all code relating to shopping cart in one place, and all code related to goods in other. – So as they’re are kinda modules. The Shopping cart folder will contain all code related to it: all controllers, adapters, entities, repositories etc – because they’re all about the same thing.

On the other hand, a good clean architecture implies a clear division onto separate “layers”, so that upper layers know nothing about lower ones.

  • first of all, there is a separate ‘library’ level – like web server, input-output, or data structures (e.g. map or deque) – they should “know” nothing about other layers.
  • then, at the top level there are some domain classes modelling domain entities and their relations, e.g. shopping cart and goods, maybe some business rules – they also “know” nothing about other layers,
  • next, there is some application logic, that describes the way in which your application allows to use those domain objects
  • and there is an infrastructure layer – the classes that use system layer and implement some interfaces required by upper layers.
  • finally, “on top of that all” (actually, at the bottom) – there is also a composition root level, which wires everything together, it may be familiar with every class and their dependencies and supplies them, maybe DI container, main() function etc.

It’d be cool if there’d be a way to highlight that e.g. all objects from one layer are somehow related and should use one layer but not use another.

– How to organize the code? What are best practices?

As a very simplified example – should it be like

- bookstore
    - customers
        - customer entity
        - customers repository interface
        - customers repository implementation
    - books
        - book entity
        - books repository interface
        - books repository implementation
        - book list view
        - book details view
        - amazon book adapter

or like

- domain
    - customers
        - customer entity
        - customer repository interface
    - books
        - book entity
        - books repository interface
- infrastructure
    - repositories
        - books repository implementation
        - customers repository implementation
- views
    - book list view
    - book details view
- adapters
    - amazon book adapter

But I’m not sure if this example illustrates the question well.

optimization – Separating labelled points with a plane, minimizing label variance

Suppose we have observations with associated labels ${({bf x}_1, y_1), ({bf x}_2, y_2), dots, ({bf x}_n, y_n)}$ where ${bf x}_i in mathbb{R}^d$ and $y_i in mathbb{R}$.

Can we efficiently find a separating plane of the observation space $mathbb{R}^d$ such that the sum of the variances of the labels of the observations within both groups is minimized?

That is, if a separating plane is parametrized by $({bf v}, c)$ splitting the space into groups ${bf x}_i^T {bf v} < c$ and ${bf x}_i^T {bf v} geq c$ we can formalize our search problem as:

$$arg min_{{bf v}, c} {Big (text{var}({y_i : {bf x}_i^T {bf v} < c}) + text{var}({y_i : {bf x}_i^T {bf v} geq c})Big)}$$
where $text{var}(S) = frac{1}{|S|}sum_{tin S}{big(t – frac{1}{|S|}smallsum Sbig)}^2$ is the standard definition of variance, optionally with Bessel’s correction applied (either definition is fine).


The context is that I had the idea of replacing the simple single-attribute decision nodes of decision trees with separating planes instead. The above method would find the greedy best split. I was wondering if doing this is even tractable?


Note that given $bf v$ we can find optimal $c$ in $O(n log n)$ time by computing all breakpoints ${bf x}_i^T{bf v}$, sorting, and computing the variances of each breakpoint in an online manner, choosing the best one as $c$. This gives us a randomized approximation algorithm, by repeatedly choosing a random unit vector $bf v$ and finding optimal $c$. This continues for as long as desired, and the best result is returned. In theory given enough time this should return the optimal result (since a minimizing $bf v$ is not unique and has constant probability of being chosen in any iteration), however I don’t know how well it can be expected to approximate given a certain number of iterations.

design – Separating unrelated data to be mapped back for later use

I’m having a use case of a node editor, my node editor has “Sockets”, dots highlighted here
enter image description here

Sockets are distinguished by “EntryType” class, which is a “blueprint” definition for Entry, in this case type name is “Number”, sockets have to access color information according to EntryType.

Here’s an Entry highlighted

enter image description here

EntryType has to store it’s shape (You can see the green socket has squarish shape, while other rhombus) and color.

The problem is that it makes no sense for EntryType to store color and shape information, because EntryType should just indicate a blueprint for entries, and we are mixing completely unrelated data.

So is there a way to separate unrelated data, so we can map it (Visual information) back. Or is that just a made-up problem, that will not affect myself and my development speed?

python – Separating data from string representation of objects, with added extras

Given a string representation of data, I want to extract the information into its corresponding object.

However,

If the string has “|” separators then these should be considered options and need to be picked at random.

If the string data has numbers shown as a range “1-10” then a random value should be chosen between the range. It should also preserve the numerical datatype i.e int or float

I.e

“(1-3,1,1)” returns either (1, 1, 1), (2, 1, 1) or (3, 1, 1)

“(0.2-0.4,1,1)” returns either (0.2, 1, 1), (0.3, 1, 1) or (0.4, 1, 1)

“foo|bar|foobar” returns either “foo”, “bar” or “foobar”

“(1-2,1,2)|”foo”|”bar”|(1,8-10,99)” could return :

“foo”,”bar”, (1, 1, 2), (2, 1, 2), (1, 8, 99), (1, 9, 99) or (1, 10, 99)

This is what I have and it works well. But I cant help think it could be achieved in a more concise way. Let me know what I could have done better.

import re
import random
import ast

def randomize_by_pipe(st_value):
    """
    Used to split strings with the pipe character and randomly choose and option.

    :param: st_value - (str)

    """
    if not st_value is None:
        st_arr = st_value.split("|")
        random.shuffle(st_arr)
        return st_arr(0)
    else:
        return st_value

def randomise_range(text):
    if text is None:
        return text
    else:
        matches = re.findall("d*.*d*-{1}d*.*d*",text)
        
        for match in matches:
            startingPos = 0
            position = text.find(match, startingPos)
            while True:
                position = text.find(match, startingPos)
                if position > -1:
                    txt = text(position:position+len(match))
                    txt = rand_no_from_string(txt)

                    new_text = text(0:position+len(match)).replace(match,str(txt))
                    text = new_text + text(position+len(match):)
                else:
                    break

        try:
            return ast.literal_eval(text)
        except ValueError:
            return text

def rand_no_from_string(txt):
    
    is_int = False
    txt_arr = txt.split("-")
    num_arr = (float(x) for x in txt_arr)
    if int(num_arr(0)) == num_arr(0):
        mul = 1
        is_int = True
    else:
        mul = 1000
    num_arr = (x*mul for x in num_arr)
    
    if num_arr(0) > num_arr(1):
        num_arr(1), num_arr(0) = num_arr(0), num_arr(1)
        
    val = random.randint(num_arr(0),num_arr(1))/mul
    return int(val) if is_int else val
    

Run with:

text="(108-100,0.25-0.75,100)|Foo|Bar|(123,234,234-250)"
randomise_range(randomize_by_pipe(text))

opengl – C++ Help with Separating Axis Theorem

I am trying to detect collision between two triangles using Separating Axis Theorem however I am unaware what is wrong with my code. The CollisionHelper::isTriangleIntersectingTriangle is called every frame and passes in the vertices of both triangles. It never returns true, however. I’ve been stuck on this for days now. Any help is appreciated.

glm::vec3 CalcSurfaceNormal(glm::vec3 tri1, glm::vec3 tri2, glm::vec3 tri3)
{
    //Subtracts each coordinate respectively
    glm::vec3 u = tri2 - tri1;
    glm::vec3 v = tri3 - tri1;

    glm::vec3 nrmcross = glm::cross(u, v);
    nrmcross = glm::normalize(nrmcross);
    return nrmcross;
}

bool SATTriangleCheck(glm::vec3 axis, glm::vec3 tri1vert1, glm::vec3 tri1vert2, glm::vec3 tri1vert3, glm::vec3 tri2vert1, glm::vec3 tri2vert2, glm::vec3 tri2vert3)
{
    int t1v1 = glm::dot(axis, tri1vert1);
    int t1v2 = glm::dot(axis, tri1vert2);
    int t1v3 = glm::dot(axis, tri1vert3);
    int t2v1 = glm::dot(axis, tri2vert1);
    int t2v2 = glm::dot(axis, tri2vert2);
    int t2v3 = glm::dot(axis, tri2vert3);

    int t1min = glm::min(t1v1, glm::min(t1v2, t1v3));
    int t1max = glm::max(t1v1, glm::max(t1v2, t1v3));
    int t2min = glm::min(t2v1, glm::min(t2v2, t2v3));
    int t2max = glm::max(t2v1, glm::max(t2v2, t2v3));


    if ((t1min < t2max && t1min > t2min) || (t1max < t2max && t1max > t2min))
            return true;
    if ((t2min < t1max && t2min > t1min) || (t2max < t1max && t2max > t1min))
            return true;

    return false;
}

bool CollisionHelper::isTriangleIntersectingTriangle(glm::vec3 tri1, glm::vec3 tri2, glm::vec3 tri3, glm::vec3 otherTri1, glm::vec3 otherTri2, glm::vec3 otherTri3)
{
    //Triangle surface normals, 2 axes to test
    glm::vec3 tri1FaceNrml = CalcSurfaceNormal(tri1, tri2, tri3);
    glm::vec3 tri2FaceNrml = CalcSurfaceNormal(otherTri1, otherTri2, otherTri3);

    glm::vec3 tri1Edge1 = tri2 - tri1;
    glm::vec3 tri1Edge2 = tri3 - tri1;
    glm::vec3 tri1Edge3 = tri3 - tri2;
    glm::vec3 tri2Edge1 = otherTri2 - otherTri1;
    glm::vec3 tri2Edge2 = otherTri3 - otherTri1;
    glm::vec3 tri2Edge3 = otherTri3 - otherTri2;

    //axes
    //TODO: may need to (un)normalize the cross products
    glm::vec3 axis1 = tri1FaceNrml;
    glm::vec3 axis2 = tri2FaceNrml;
    glm::vec3 axis3 = glm::normalize(glm::cross(tri1Edge1, tri2Edge1));
    glm::vec3 axis4 = glm::normalize(glm::cross(tri1Edge1, tri2Edge2));
    glm::vec3 axis5 = glm::normalize(glm::cross(tri1Edge1, tri2Edge3));
    glm::vec3 axis6 = glm::normalize(glm::cross(tri1Edge2, tri2Edge1));
    glm::vec3 axis7 = glm::normalize(glm::cross(tri1Edge2, tri2Edge2));
    glm::vec3 axis8 = glm::normalize(glm::cross(tri1Edge2, tri2Edge3));
    glm::vec3 axis9 = glm::normalize(glm::cross(tri1Edge3, tri2Edge1));
    glm::vec3 axis10 = glm::normalize(glm::cross(tri1Edge3, tri2Edge2));
    glm::vec3 axis11 = glm::normalize(glm::cross(tri1Edge3, tri2Edge3));

    //Perform SAT
    if (SATTriangleCheck(axis1, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis2, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis3, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis4, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis5, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis6, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis7, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis8, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis9, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis10, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;
    if (SATTriangleCheck(axis11, tri1, tri2, tri3, otherTri1, otherTri2, otherTri3)) return true;

    return false;
}