depth first search – Prove, that DFS produces the correct Topologically ordered sequence

Before I get to the proof, let me just clarify that the algorithm using DFS would be to process edges in decreasing order of finishing times while running DFS on the input graph.

Now to prove that the above algorithm returns a topological sorting, we can use some lemmas about DFS $-$ namely the Parenthesis Theorem as well as the White Path Theorem. I will not get into the proofs of each lemma but we will use the following:

A corollary of the parenthesis theorem, as follows:

Consider vertices $u$ and $v$ in $G$. Then $v$ is a descendant of $u$ in the DFS forest of $G$, if and only if $d(u)<d(v)<f(v)<f(u)$, where $d(x’)$ is the discovery time of vertex $x’$ and $f(x’)$ is its finish time.

Also, we will use the white path theorem which states that

Vertext $v$ is a descendant of vertex $u$ in the DFS forest if and only if at time $d(u),$ there exists a white path from $u$ to $v.$

Now let $e = (u,v)$ be an edge in the input graph. We want to prove that in our output, $u$ comes before $v$. We can show that by proving that in our DFS traversal, $f(u) > f(v).$

CASE I: $d(u) < d(v)$

By the White Path Theorem, $v$ is a descendant of $u$. This is because at time $d(u)$, there is a white path in $G$, which must be from $u$ to $v$ as there exists edge $e = (u,v)$. Hence, we can use the corollary of the parenthesis theorem to show that $f(u) > f(v).$

CASE II: $d(v) < d(u)$

At time $d(v)$, there is no white path from $v$ to $u$, as that would imply that $G$ has a cycle (meaning that it is not a DAG), and hence $u$ cannot be a descendant of $v$ in the DFS forest of $G$. So by the parenthesis theorem, we have $d(v) < f(v) < d(u) < f(u)$. Again, we proved that $f(u) > f(v)$.

Hope that helped 🙂

apache – Docker Image not having correct permissions for www-data in WordPress

So I have a docker container running Apache/WordPress which runs Apache as www-data. I build the image using a Dockerfile and started it. I then copied my local uploads and plugin folders using:

docker cp ../wp-content/uploads esaanz_dev:/var/www/html/wp-content

When I access the machine and I try to install a plugin, always gives me Installation failed: Could not create directory. Furthermore, my backup plugin cannot wrote to wp-content/updraft to create backups.

I have logged into the machine using docker exec and I have run this command:

chown -R www-data:www-data wp-content

The problem persists even though www-data has access to everything:

Permissions for www-data

I am going mad figuring why WordPress is not able to write if it’s running under www-data and this user/group can write to anything in the container.

Any pointers are greatly appreciated.

simplifying expressions – Solving an equation, and verifying that it is correct

I want to solve the equation

 Solve(e == 1/2 (-2 ef + hvk - Sqrt(9 hvk^2 + 4 j^2)), hvk)

I then obtain the solutions

{{hvk ->
    1/4 (-e - ef - Sqrt(9 e^2 + 18 e ef + 9 ef^2 - 8 j^2))}, {hvk -> 
   1/4 (-e - ef + Sqrt(9 e^2 + 18 e ef + 9 ef^2 - 8 j^2))}}

To verify that they are solutions I expect that the command

FullSimplify(
 Refine(1/2 (-2 ef + hvk - Sqrt(9 hvk^2 + 4 j^2)) /. 
   hvk -> 1/4 (-e - ef + Sqrt(9 e^2 + 18 e ef + 9 ef^2 - 8 j^2))))

Should produce the variable $e$. However, I instead obtain

1/8 (-e - 9 ef + Sqrt(9 (e + ef)^2 - 8 j^2) - 
   4 Sqrt(4 j^2 + 9/16 (e + ef - Sqrt(9 (e + ef)^2 - 8 j^2))^2))

which I can not simplify to $e$. What on earth is going on?

I have used the following assumptions in Refine

$Assumptions = {j >=  0, e > 0,
  Element(ef, Reals)}

What is the correct way of listening to events of one viewController from another using combine?

Lets assume I have a ViewControllerA that presents ViewControllerB and I want to subscribe to a button tap. I can do something like this:

public class ViewControllerB {
    public var didTapButton = PassthroughSubject<Void, Never>()
    ...

    func buttonTapped() {
        didTapButton.send(completion: .finished)
    }
}

then subscribe to didTapButton in ViewControllerA with sink.

If I want to do the same with @Published variable, all I can think of is doing this:

public class ViewControllerB {
    public var didTapButton: Void?
    ...

    func buttonTapped() {
        didTapButton = ()
    }
}

Does this make sense? or is there better way to do this?

*Example* Is this the correct use of hreflang & canonical reference

Not to pick on Xero, but I’m wondering if this is a good example of hreflang & canonical use.

https://www.xero.com/uk/resources/small-business-guides/

https://www.xero.com/nz/resources/small-business-guides/

Note: Both pages are identical.

UK Version (note canonical at the bottom):

<link rel="alternate" href="https://www.xero.com/glossary/" hreflang="x-default" />
<link rel="alternate" href="https://www.xero.com/au/glossary/" hreflang="en-au" />
<link rel="alternate" href="https://www.xero.com/ca/glossary/" hreflang="en-ca" />
<link rel="alternate" href="https://www.xero.com/id/glossary/" hreflang="en-id" />
<link rel="alternate" href="https://www.xero.com/ie/glossary/" hreflang="en-ie" />
<link rel="alternate" href="https://www.xero.com/hk/glossary/" hreflang="en-hk" />
<link rel="alternate" href="https://www.xero.com/my/glossary/" hreflang="en-my" />
<link rel="alternate" href="https://www.xero.com/nz/glossary/" hreflang="en-nz" />
<link rel="alternate" href="https://www.xero.com/ph/glossary/" hreflang="en-ph" />
<link rel="alternate" href="https://www.xero.com/sg/glossary/" hreflang="en-sg" />
<link rel="alternate" href="https://www.xero.com/uk/glossary/" hreflang="en-gb" />
<link rel="alternate" href="https://www.xero.com/us/glossary/" hreflang="en-us" />
<link rel="alternate" href="https://www.xero.com/za/glossary/" hreflang="en-za" />
<link rel="canonical" href="https://www.xero.com/uk/glossary/"/>

NZ version (as above):

<link rel="alternate" href="https://www.xero.com/glossary/" hreflang="x-default" />
<link rel="alternate" href="https://www.xero.com/au/glossary/" hreflang="en-au" />
<link rel="alternate" href="https://www.xero.com/ca/glossary/" hreflang="en-ca" />
<link rel="alternate" href="https://www.xero.com/id/glossary/" hreflang="en-id" />
<link rel="alternate" href="https://www.xero.com/ie/glossary/" hreflang="en-ie" />
<link rel="alternate" href="https://www.xero.com/hk/glossary/" hreflang="en-hk" />
<link rel="alternate" href="https://www.xero.com/my/glossary/" hreflang="en-my" />
<link rel="alternate" href="https://www.xero.com/nz/glossary/" hreflang="en-nz" />
<link rel="alternate" href="https://www.xero.com/ph/glossary/" hreflang="en-ph" />
<link rel="alternate" href="https://www.xero.com/sg/glossary/" hreflang="en-sg" />
<link rel="alternate" href="https://www.xero.com/uk/glossary/" hreflang="en-gb" />
<link rel="alternate" href="https://www.xero.com/us/glossary/" hreflang="en-us" />
<link rel="alternate" href="https://www.xero.com/za/glossary/" hreflang="en-za" />
<link rel="canonical" href="https://www.xero.com/nz/glossary/"/>

As both pages are identical, should the hreflang be removed and one is identified as canonical?

I note the local page appears in SERP for each.

What does Google say on the matter? Regarding multi-regional websites:

Websites that provide content for different regions and in different
languages sometimes create content that is the same or similar but
available on different URLs. This is generally not a problem as long
as the content is for different users in different countries. While we
strongly recommend that you provide unique content for each different
group of users, we understand that this may not always be possible for
all pages and variations from the start.

Cite: https://developers.google.com/search/blog/2010/03/working-with-multi-regional-websites

This statement may seem to resolve the matter, but I’ve read a lot to suggest the content cannot be identical. Hreflang does not resolve duplicate content (apparently). Variations such as currency and languages (i.e. en-us vs en-uk) make it “similar” but not the same. Plus, how much should I read into their statement, “This is generally not a problem…”?

Quintessentially, for Xero it should…

  1. Have one page containing the guides that local versions of the site link to with canonical reference.
  2. Alternatively, it could have multiple copies on the local sight but one canonical (remove hreflang).
  3. What they have done is correct.

I’d love to hear your thoughts and commentary.

office web apps – Wopiframe.aspx – SharePoint 2016 – Redirect user to correct location

This issue has been reported many times before but none of the work around works for me.

Scenario : User opens a document in office web apps from a document set. When the user want to go back and click on the link (marked as yellow in picture below) in OWA, they got sent to wrong location.

enter image description here

Following are the articles explaining the problem and possible solutions but non of them worked for me.

Redirect user when document closes in office web apps?

WopiFrame – how to set the URL behind the Exit menu?

https://blogs.technet.microsoft.com/office_web_apps_server_2013_support_blog/2014/01/22/office-web-apps-2013-office-web-apps-redirect-to-incorrect-sharepoint-library/

Any more suggestions?

Thanks

dnd 5e – Why do Warlocks only have spells up to 5th level? What’s the correct progression for their slots?

The book is correct. For the reason why level 6-9 spells exist for the warlock when their Pact Magic slots cap at 5, check the Mystic Arcanum class feature on PHB p.108.

Mystic Arcanum

At 11th level, your patron bestows upon you a magical secret called an arcanum. Choose one 6th level spell from the warlock spell list as this arcanum.

You can cast your arcanum spell once without expending a spell slot. You must finish a long rest before you can do so again.

At higher levels, you gain more warlock spells of your choice that can be cast in this way: one 7th-level spell at 13th level, one 8th-level spell at 15th level, and one 9th-level spell at 17th level. You regain all uses of your Mystic Arcanum when you finish a long rest.

It’s simulating the once-a-day spell slots that other casters get (presumably, they didn’t want you recasting a 9th level spell every time you rested throughout the day), but there are a few minor differences.

  1. It’s not technically a spell slot for anything that cares specifically about spell slots (such as the feature below that in the PHB, Eldritch Master), as mentioned.
  2. Unlike most spellcasters, you only ever “know” (as an arcanum) one spell each of 6th-9th level.
  3. You cannot ‘upcast’ spells to those 6th-9th level ‘slots’, as they aren’t really slots. As an example, if you knew shatter as one of your usual Pact Magic spells, you could only cast it with one of your standard spell slots (likely a 5th level slot by the time you have Mystic Arcanum, barring other spell slot levels being available due to multiclassing or the like); you could not expend a use of Mystic Arcanum instead to cast shatter at spell level 6+.
  4. Similarly to point 3, you always cast the 6th level arcanum at 6th level, the 7th level arcanum as 7th level, etc. You could not, for example, upcast a circle of death chosen as your 6th level arcanum to your 8th level arcanum ‘slot’; that 8th level arcanum can only be used on whatever spell you chose for that level, such as glibness.

unity – How do I correct the turning effects on my car in order for it to turn properly?

In my game, I’m currently working on a Physics-based car driving game in Unity from scratch. My problem is that whenever I press the input controls used for turning, instead of turning, my car does barrel rolls in the air. I’m using a document written about Car Physics by Marco Monster to aid some of my calculations in this post. I’ve looked at my code and suspect that the problem lies within this segment of my code. Please provide any feedback as it would be greatly appreciated.

//This section relates to low-speed cornering, not really useful for drifting
            //This will determine the circle radius related to turning, in effect, calculating how much we turn
            R = L / Mathf.Sin(userRight);

            //Here, we calculate the vehicle's angular velocity in radians per second
            //Omega (fancy w) represents angular velocity
            // v represents velocity
            rb.angularVelocity = rb.velocity / R;

        //This section covers high-speed turning
            //This relates to the car
                //sideSlipAngle = Vector3.Angle(carTransform.forward, rb.velocity);
                sideSlipAngle = Mathf.Atan(rb.velocity.z / rb.velocity.x);

        //This relates to the wheels
        for(int i = 0; i < 4; i++)
        {
            //alpha represents the slip angle for each wheel
            alpha = Vector3.Angle(wheels(i).forward, rb.velocity);

            //this equation is an approxiamtion of values below the peak shown in the graph
            lateralForce = new Vector3(0f, 0f, corneringStiffness * alpha);

            //These values are supposed to represent the magnitudes of these velocities
            longVelocity = Mathf.Cos(alpha) * rb.velocity;
            latVelocity = Mathf.Sin(alpha) * rb.velocity;

            /*
                Remember that these forces are supposed to be acting upon the wheels themselves,
                so add rigidbodies accordingly
             */

            //The lateral velocity causes the cornering force to counteract it
                //This relates to only the front wheels
                frontSlipAngle = Mathf.Atan((latVelocity.magnitude + (rb.angularVelocity.magnitude * b)) / longVelocity.magnitude) - (userRight * Mathf.Sign(longVelocity.magnitude));
                for (i = 0; i < 2; i++)
                {
                    //Calculates the lateral force of the wheels
                    latFrontForce = lateralForce.normalized * (frontWeight.magnitude / 2f);
                    latFrontForce += latFrontForce;

                    corneringForce = latRearForce + Mathf.Cos(userRight) * latFrontForce;
                    lateralForce += latFrontForce;

                    frontTorque = Mathf.Cos(userRight) * latFrontForce * b;
                    //rb_wheels(i).AddForce(lateralForce);
                }

                centripedalForce = corneringForce;
                steeringRadius = centripedalForce.magnitude / (rb.mass * Mathf.Pow(rb.velocity.magnitude, 2f));
                

            //This relates to only the rear wheels
            rearSlipAngle = Mathf.Atan((latVelocity.magnitude - (rb.angularVelocity.magnitude * c)) / longVelocity.magnitude);
            for (i = 2; i < 4; i++)
            {
                //Calculates the lateral force of the wheels
                latRearForce = lateralForce.normalized * (backWeight.magnitude / 2f);

                latRearForce += latRearForce;
                lateralForce += latRearForce;

                rearTorque = -latRearForce * c;
                //rb_wheels(i).AddForce(lateralForce);
            }

        }

        totalTorque = frontTorque + rearTorque;
        rb.AddTorque(totalTorque);
```

workflow – Is it possible to import data from excel into a SharePoint list, and populate a multiple choice column with the correct data?

So I have a SharePoint List that contains an ID, and a multiple choice column. Now I have an excel sheet that I want to import into the SharePoint list. However, is it possible to populate the multiple choice column? Depending on the ID number, that data will be different, and I want the correct data choice to be displayed in the multiple choice column when I import that excel table. Thanks for any help!