Stop Attachment image names from taking top level permalink

Question: I don't know why but images uploaded to my site in posts are getting a top level permalink. So if I upload an image into a post called "Apple" then it gets an attachment page at mysite.com/apple and that is a big problem for me. How can add a path between my top level and image attachment page name?
Comment: The question is more like: Why does this happen? Please write a quick plugin for that and update your post, so we can try to debug this in our own installations.
Answer: Don't link to attachment pages anywhere on your site and it won't matter what permalink they have. Search engines only see what you make public.
BTW another thing you can try is to upload only from within the post/page edit screen. That way attachments take up the parent post/page permalink. Sort of like
example.com/post-name/attachment-name.
Comment: what's happenig is Im using a front end post form so user can submit but if they submit a image with a name of someone it takes up that top level url. So when I want to go and make wiki style pages about people they are taken by these images.


What kind of larvae are these. Lots of them in the basement in the summer, crawling around on the floor and the walls

Question: larvae crawl on basement floor.  Some are also found on the first floor of the house.  Lots of legs--I also thought they became "rolly polys"  but never knew for sure what they were either.
Comment: Welcome to Biology.SE! For identification questions please [edit](https://biology.stackexchange.com/posts/86502/edit) your post to: 1) include the location (e.g. country and region — the more specific the better), and 2) an estimate of the size of the creature. The location and size can be essential clues for identification. ——— If possible clear, closeup photos of the creature would be helpful. ——— Thank you for taking the tour — please also take the time to go through the help pages starting with [Ask] questions effectively on this site. Thanks!
Comment: "Lots of them in the basement in the summer, crawling around on the floor and the walls" Quick! get some head & shoulders :)
Answer: Those are not larvae, but adult millipedes. Myriopoda, Diplopoda. https://en.wikipedia.org/wiki/Millipede
Here is a good link from the U of Minnesota on common arthropods in the basement.
https://extension.umn.edu/insect-relatives/sowbugs-millipedes-and-centipedes


What makes electrons lose energy?

Question: As far as I know from physics lessons I got at school, electrons go up to higher energy levels when they capture a photon. But, once an electron is at a given level, what makes it go down to a lower level and emit a photon? Is there a constant time during which an electron is able to stick at a level, and then jump to a lower level? I mean, I know electrons tend to reach low energy levels, but can you describe this process? Put in other words, how does an electron "know" there are lower energy levels and when does an electron choose to lose energy?
Comment: Everything that is not forbidden is compulsory. --Quantum Mechanical Totalitarian
Comment: The key processes are *spontaneous emission* and *stimulated emission*.
Comment: @RobJeffries: "... *spontaneous emission* and *stimulated emission*..." which are actually the same thing.
Comment: @DanielSank perhaps, in QED, but from the point of view of "physics lessons I got in school" they are quite different. One can be "explained" in a semi-classical way, the other cannot; so the distinction is quite relevant here, and one usually sees them discussed separately.
Comment: One does indeed see them discussed separately, and that is a major pedagogical failure based on 80 year old history of how the theory was originally developed. Either you learn about stimulated and spontaneous emission before you learn quantum, in which case it doesn't really make sense anyway, or after you learn quantum in which case any distinction between stimulated and spontaneous is completely artificial. You don't need any fancy QED stuff, just really simple Jaynes-Cummings physics which a first year course in QM could easily discuss.
Answer: The electron itself doesn't "know".  The entire system "knows" what its own energy levels are.  That is, the system can make transitions only to states that exist.   Don't think of the electron, think of the entire system that contains the electron.
The system will stay at the excited level for some period of time depending on the strength of the coupling between the system and the electromagnetic field,  and the intensity of the field.  Stronger coupling means shorter lifetime.  And stronger field means shorter lifetime.  This last effect is stimulated emission.
There is never a situation where the field has no intensity.  The ground state of the electromagnetic field has "zero-point fluctuations", required by the uncertainty principle. No energy can be extracted from the field in the ground state, so it behaves like zero intensity.  But the zero-point field can induce transitions in an atom just as in stimulated emission.  This is the origin of spontaneous emission, the process by which an isolated excited system makes transitions to lower energy states.
Comment: *"Don't think of the electron, think of the entire system that contains the electron."* Always an important point.
Comment: Very nice answer!

What makes electrons lose energy?


Local parameters and etale coverings of of elliptic curves

Question: I found some absurd observation which I could not fix by myself. For an elliptic curve $E$ over $\mathbb{Q}$, let $\overline{E}=E\otimes\overline{\mathbb{Q}}$. Every multiplication-by-$n$ map $\overline{E}\to \overline{E}:P\mapsto nP$ defines an étale covering of $E$. It means that for any $n$ and $n$-torsion point $P$, the morphism $\mathcal{O}_{\overline{E},O}\to\mathcal{O}_{\overline{E},P}$ sends a local parameter $\varpi_O$ at $O$ to $u_P\cdot\varpi_P$ where $u_P$ is a unit in $\mathcal{O}_{\overline{E},P}$ and $\varpi_P$ is a local parameter at $P$. Note that, basically, for any $Q\in\overline{E}(\overline{\mathbb{Q}})$, a local parameter at $Q$ is any $f\in K(\overline{E})$ such that $v_Q(f)=1$, which menas $\varpi_O$ is a function on $\overline{E}$ which has order 1 zero at $O$. However, as we have seen in the above, $\varpi_O\mapsto u_P\cdot\varpi_P$ so it also has order 1 zero at $P$. Since we chose $n$ arbitrary, $\varpi_O$ becomes a function having zeros (of order 1) at every torsion points which is definitely absurd. Could anyone point out what I am confusing?
Comment: Firstly, $\varpi_O$ is not a global function on $\bar E$, but only a local one. In fact, there is no global function on an elliptic curve with exactly one zero (this might be fixable, but really you should be thinking about *local* functions). Secondly, it is not $\varpi_O$ that has a zero at every $n$-torsion point, but rather $[n]^* \varpi_O$. This depends on $n$, so you do not get a single function that works for all torsion points. (If this is still confusing, try giving the two copies of $\bar E$ different names, and see on which space $\varpi_O$ and $u_P \varpi_P$ live.)
Comment: @R.vanDobbendeBruyn Thank you very much. I am wondering whether this is known or not: if we take $\varpi_O=x/y$ and $\varpi_P=x-x(P)$ where $x,y$ are variables defining $E$ and $x(P)$ is the $x$-coordinates of $P\in E[n]$. Then can we explicitly write down $\frac{[n]^*\varpi_O}{\varpi_P}$?
Comment: Do you assume a special choice for the local parameter at $\Bbb O$ and at $P$? Surely any relationship between $[n]^*\varpi_{\Bbb O}$ and $\varpi_P$ would depend strongly on such choice, isn't that so? And do you have an answer to your question when $\Bbb O=P$?
Comment: @Lubin I am specifically interested in the case $\varpi_O=x/y$ and $\varpi_P=x-x(P)$. When $P=O$, I think that $\frac{[n]^*\varpi_O}{\varpi_P}$ should be of the form $n+\text{higher terms in }\varpi_P$.
Answer: I can only speak about the case that $p=\Bbb O$, when there's one uniformizer involved. I'll follow you and call $x/y=\varpi$ — now we need no subscripts. If you're satisfied with a formal response to your question, then all is answered by the formal group of the elliptic curve in question. Since you're working over $\Bbb Q$, you're in luck here, due to the existence of the logarithm of the formal group.
You may express the regular differential $\psi$ of your elliptic curve in the form $g(\varpi)d\varpi$ — if you don't see how to do this, I can explain either with an edit, or by e-mail. But once you have $\psi$, you can integrate it and multiply by a suitable element of $\Bbb Q$ to get it in the form $L(\varpi)=\varpi+\sum_ia_i\varpi^i\in\Bbb Q[[\varpi]]$. This is the logarithm of the formal group, and formally, the addition on the elliptic curve is given by a power series $F(x,y)$ which fits in with the logarithm thus: $L\bigl(F(x,y)\bigr)=L(x)+L(y)$. The $[n]$-endomorphism of the elliptic curve has $L([n](x))=nL(x)$, and in particular, $[n]'(0)=n$, which verifies the conjecture expressed in your last comment. If, for a particular elliptic curve, you should need the higher terms of $[n](x)$, you can get them by an easy degree-by-degree computation, or notice that $[n](x)$ is a root of the power-series $L(X)-nL(x)\in R[[X]]$, where $R$ is the complete ring $\Bbb Q[[x]]$.


Ceiling fan capacitor acceptable alternative?

Question: I need to replace the capacitor on my ceiling fan. It's 5 wire 4.5 microfarad 350 volts 6 microfarad 250 volts 6 microfarad 250 volts. The closest 5 wire replacement I can find is 4.5 microfarad 250 volts, not 350, but the rest is the same, 6 microfarad 250 volts 6 microfarad 250 volts.  Is this replacement acceptable? I have 120 volt supply. Thank you.
Answer: The 250v cap will work on a 120v circuit. Many fans used to come with caps rated for 260v and today they have changed to 250. The higher voltage is needed to account for the peak to peak voltage what we measure is RMS or .707 of peak 1.414 of peak to peak.
So the 250v will be fine.


What is an intuitive explanation of a complex slope of a real line?

Question: On thinking about what real slopes and imaginary slopes are I have become a bit confused. We have one coordinate $x$-$y$-$z$ system that we use to specify position. I suppose the coordinates in this system will have only real values. But then again in the argand plane the $x$ axis is real and $y$ axis is imaginary. What is a complex slope of a real line? How do we find it?My book has this sentence: "If $A(z_1)$ and $B(z_2)$ are two points in the argand plane then the complex slope of line $AB$ is $\frac{z_1-z_2}{\bar z_1-\bar z_2}$." Where did they get this from? I'm not very sure whether this formula is correct either.  I do not have extensive knowledge of complex numbers, I have just studied the basics.
Comment: Can't it happen that this sentence is just *defining* the term 'complex slope'?
Comment: Ohhh ok thanks, I think it might be, because there is no further explanation and it just gives one more sentence which is finding if lines are parallel or perpendicular based on whether the complex slopes are equal or opposite it sign. I believe you are right.
Answer: Descartes has taught us how to use a real $(x,y)$-plane ${\mathbb R}^2$ to graphically display functions $x\mapsto y=f(x)$. In particular a linear function $y=ax+b$ has a graph which is a straight line, and this line has  slope $a=\tan\alpha$, whereby $\alpha\in\bigl]-{\pi\over2},{\pi\over2}\bigr[\>$ is the angle between this line and the $x$-axis. The graph of a general function $f$ is a curve with varying tangents. These tangents also have slopes, that can be computed through differentiation of $f$.
Now in complex analysis the $(x,y)$-plane is used for a completely different purpose, namely as a "geometric" representation of the set ${\mathbb C}$ of complex numbers. Each point $(x,y)\in{\mathbb R}^2$ then represents the complex number $z:=x+iy$. Sometimes we do geometry with these complex numbers, and there will be figures with lines $\ell\subset{\mathbb C}$. These lines are ordinary real lines in the plane, and they have a real slope as described above.
When you start to study complex valued functions $z\mapsto w:=f(z)$ then you need a second plane (the $w$-plane) to draw the images of individual points or subsets of the $z$-plane. It is there that something as a "complex slope" arises. The official name is complex derivative. We then have $\Delta w\approx f'(z_0)\Delta z$ in the same way as in the "real world" we have $\Delta y\approx f'(x_0)\Delta x$.
Answering your comment: The quotient $q:=(z_2-z_1)/(\bar z_2-\bar z_1)$  is related to the slope of the segment connecting $A$ with $B$, but I have never seen it called "complex slope". In fact $q=e^{2i\alpha}$, where $\alpha$ is the angle described in the first paragraph. (Note that $z=|z|e^{i\alpha}$ implies ${z\over\bar z}=e^{2i\alpha}$.)
Comment: My book has this sentence: "If A(z1) and B(z2) are two points in the argand plane then the complex slope of line AB is (z1-z2)/(z1¯-z2¯)." Where did they get this from? I'm not very sure whether this formula is correct either. Please give an explanation.
Comment: I'm sorry to ask such a silly question but how is q = e^(2iα)?
Answer: The Argand plane is just a way of visualising complex numbers that is often useful.  It does not have to appear in real life.  Simple graphs involving real numbers, e.g. $y = x^2$ are common in maths and their usefulness is rarely questioned.  Nonetheless, you don't see them while out and about in the real world.
You could ask what is the use of complex numbers in the real world but I am sure that has been asked many times before.  Here are two brief answers.
They don't need to be useful to be interesting.  Mathematicians study many things regardless of their usefulness e.g. uncountable infinities.
Physicists find complex numbers very useful. I won't attempt to answer that as many have done so well already.
I would recommend The Road To Reality by Roger Penrose.  It is a great for a fairly serious amateur.  It will explain the the utility of complex numbers.  It also has a chapter on infinity.  Penrose seems to find it surprising that uncountable infinities are not useful as so much of maths is useful.
I think that the terms "imaginary" and "complex" are unfortunate and unnecessarily scary.  When developing numbers, the step from the rationals to the reals is the most complicated yet few people worry about that.  Comparatively, from the reals to the complex is simple.  I blame calculators which are always happy to tell give you $\sqrt2$ and many will tell you $\pi$ but few will give you $\sqrt{-1}$.
Addition
Electrical engineering is maybe one of the simplest real world uses of complex numbers.  You might know Ohm's Law: $V = IR$.  This works with simple resistors.  Now, consider A/C circuits with capacitors and inductors as well as resistors.  It is possible to assign imaginary resistances to capacitors and inductors.  Combinations of resistors, conductors, and inductors may have more general complex values.  This is normally called "impedance" and represented with $Z$ rather than $R$.  So, $Z$ might indicate a complex slope in a graph of $V$ against $I$.  The real world interpretation of this is that not only might the current have a different amplitude (height of the A/C wave) but also a different phase (the peaks would not be in line).
Comment: But what exactly is a complex slope of a real line?
Comment: What do you mean by a real line?  If a function is from the reals to the reals then the slope could not be complex.  If the function is from the reals to the complex then it could be.  A complex slope would just mean that changing the (real) from value would change the real and imaginary components of to value.  For functions from the complex to the complex, it is a little more complex (sic).  But it would also mean that changing the real part of the from value would change the imaginary part of the result.
Comment: My book has this sentence: "If A(z1) and B(z2) are two points in the argand plane then the complex slope of line AB is (z1-z2)/(z1¯-z2¯)." Where did they get this from? I'm not very sure whether this formula is correct either. Please give an explanation.
Comment: Ohhhhh ok thanks, I think I kind of got an understanding about how it is used, both from your answer and from this comment. No, I do not know any electrical engineering I'm afraid, I'm still in school, but I have learnt Ohm's law.
Comment: Is the complex slope referred to in my book just the ratio of the imaginary (y coordinates) to the real (x coordinates) in the plotting of z1 and z2 in the argand plane?
Comment: Ah, your book might just be referring to the ordinary slope of a line in the Argand diagram.  Rather different from what I was saying about Ohm's law.


Can mixed states be treated in the second quantization formalism?

Question: In the first quantization formalism, mixed states can be handled using density matrices.
When treating many-body quantum systems however, the second quantization formalism often comes handier, allowing for example to automatically take into account the symmetry of the particles.
Is it possible to use density matrices in second quantization? In other words, is there a way to handle mixed states in a sort-of-generalized second quantization framework?

To shed light on what exactly I'm asking, let's consider the Hong-Ou-Mandel effect.
We assume that the two photons are both in the same vertical polarization state (as generated for example by a type I SPDC process).
In the first quantization formalism we can write this state as:
$$
\frac{1}{\sqrt 2} \left( | 0,V,1,V\rangle + | 1,V,0,V\rangle \right), \tag{1}
$$
where for example $|0,V,1,V\rangle$ represents the state with the first photon in the spatial mode 0 and vertical polarization mode, and the second photon in the spatial mode 1 and vertical polarization mode.
Let's now suppose that, due to some noise added to the second spatial channel, the two photons are not completely indistinguishable when they enter the symmetric beam splitter.
As a toy example, we model this noisy channel saying that the photon in the second spatial channel is actually in the mixed state
$$ \rho_2 = \frac{1}{2}\left[p|V\rangle \langle V | + (1-p)|H\rangle\langle H |\right]
= \frac{1}{2} \begin{pmatrix} 1-p&0\\0&p \end{pmatrix}.
$$
Equivalently, I can say that the noisy channel acts on the basis states as:
$$
| 1, H \rangle \rightarrow | 1, H \rangle, \qquad\qquad |1,V\rangle\rightarrow|1,V\rangle \\
|2,H\rangle \rightarrow \sqrt p |2,H\rangle + e^{i \theta} \sqrt{1-p} |2,V\rangle,
\qquad\qquad
|2,V\rangle \rightarrow \sqrt p |2,V\rangle + e^{i \theta} \sqrt{1-p} |2,H\rangle,
$$
where $\theta$ is a randomly changing phase.
Applying this transformations to (1) we get the state (I put this automatically generated image to avoid typos in the latex typesetting):

It is now straightforward (though a lenghty calculation) to write the evolution of this state through the symmetric beam splitter, that is, through the evolution described by the unitary matrix
$$
\mathcal U_{\operatorname{BS}} \otimes \boldsymbol 1 \otimes \mathcal U_{\operatorname{BS}} \otimes \boldsymbol 1,
\qquad \text{where } \qquad
\mathcal U_{\operatorname{BS}} \equiv \frac{1}{\sqrt 2} \begin{pmatrix}1&1\\1&-1\end{pmatrix},\,\,
\boldsymbol 1 \equiv \begin{pmatrix}1&0\\0&1\end{pmatrix}.
$$
The resulting final state is quite aweful, and it is probably not particularly useful to write here. The point is that with this final state we can easily get the corresponding density matrix $\rho_f$. This is the resulting density matrix (I hope it will be readable enough):

Being the phases $\theta$ randomly varying, we can just set to 0 the terms containing phase factors of the form $e^{i \theta}$, obtaining as a result the mixed output state we were looking for:

This density matrix is the result I was looking for, but now you can hopefully better see my point: to get this result I had to pass through the bra-ket formalism to properly symmetrize the (bosonic) states, and then use the "trick" of adding a randomly changing phase $\theta$, which allows me to do the calculations treating all states as pure and only at the last moment set the $e^{i \theta}$ factors to zero, thus properly accounting for the incoherent nature of the considered noise.
If it was possible to somehow treat density matrices in a second-quantization-like formalism, one could (possibly?) do the entire calculation in the density matrix formalism, starting from an initial state that would be written as something like
$$ \left[ \begin{pmatrix}1&0\\0&0\end{pmatrix} \otimes \begin{pmatrix}1&0\\0&1\end{pmatrix} \right] \otimes_S \left[ \begin{pmatrix}0&0\\0&1\end{pmatrix} \otimes \begin{pmatrix}1-p&0\\0&p\end{pmatrix} \right],
$$
where $\otimes_S$ is some sort of "symmetrized tensor product", which automatically allows to take into account the fact that the two photons are indistinguishable (or to be exact, it does not make sense to ask "which of the two photons" went on the second spatial mode and which went in the first spatial mode).
The question is then: how can this be done?

Note: this is not a duplicate of this apparently similar question: my question is specifically with regard to the problem of describing mixed states in second quantization (if that is even possible), which is specifically not covered in the linked question.
Comment: Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/36428/discussion-between-gls-and-mark-mitchison).
Comment: @glS I don't mean to intrude, but came up on this ref., thought it might be useful to you: Quantum optics of the beam-splitter, http://www.quantum.physik.uni-potsdam.de/teaching/ss2013/qo2/script_bsplit.pdf. Pedagogical intro on how to treat a beam splitter in second quantization.
Answer: Yes, it is possible, in a rather trivial way.
We write the state of two indistinguishable photons (bosons) in the modes $0$ and $1$, in the second quantization formalism, as
$$ \lvert \psi \rangle = a_0^\dagger a_1^\dagger \lvert \text{vac} \rangle.
$$
This immediately generalizes to the density matrix formalism, in which this case reads
$$ \rho = a_0^\dagger a_1^\dagger \lvert \text{vac} \rangle \langle \text{vac} \rvert a_0 a_1.$$
Taking the matrix elements of this operator correctly reproduces the density matrix
$$\rho = \frac{1}{2}\begin{pmatrix}0&0&0&0\\0&1&1&0\\0&1&1&0\\0&0&0&0\end{pmatrix}.$$
Applying this to the calculation shown in the question, the density matrix of the initial state becomes
$$ \rho = a_{0,V}^\dagger a_{1,V}^\dagger \lvert \text{vac} \rangle \langle \text{vac} \rvert a_{0,V} a_{1,V}, $$
while the state after the addition of incoherent noise is:
$$ \rho = p \,\, a_{0,V}^\dagger a_{1,V}^\dagger \lvert \text{vac} \rangle \langle \text{vac} \rvert a_{0,V} a_{1,V} + (1-p) \,\, a_{0,V}^\dagger a_{1,H}^\dagger \lvert \text{vac} \rangle \langle \text{vac} \rvert a_{0,V} a_{1,H}. $$
The evolution of this state is now straightforward, as every creation(destruction) operator evolves according to the usual evolution rules.
More generally, a mixed state $\sigma$ with elements $\sigma_{i,j}$ will have in "second quantization" the form:
$$ \hat \sigma = \sum_{i,j} \sigma_{i,j} \,\,\, \hat a_i^\dagger \lvert \text{vac} \rangle\langle \text{vec} \rvert \hat a_j. $$


How to measure UV index?

Question: I am a high school student so please apologise if I say something very dumb or irrelevant. I am conducting an experiment in which I want to find UV index at different points. Such as under shade, inside house, near beach etc. Anything will be greatly appreciated, also even if there is a device thats very expensive please tell me about that as well.
Answer: Finding 'UV index' at a point might be difficult. UV index is an index created by I think was WHO, and is calculated using
 - Thickness of ozone above
 - Cloud density of the area
 - Altitude of location
 - Sun's height
more about it here - https://www.who.int/uv/publications/en/UVIGuide.pdf
So I think you are better off finding the UV light intensity instead, using some measurement tools. There's few different options like photo reactive dyes, and digital scales, but probably the most cheap and quantitative data can be obtained using arduino or other similar development board and creating a small module yourself. Good Luck!
Comment: Hey first of all thanks for your help. Is there a way that I can convert the UV index into UV light intensity, vice-versa. I need to compare my results with the UV index in my city. Thanks
Comment: Sorry I am not aware of conversion of UV index to any physically measurable units. It's more of a guideline of how harmful is the UV at that location at that time, and is multi-component. While light intensity is a physical measurement (But there's multiple ways of measuring, each with different meaning). Moreover, comparing your measurement directly with the city's UV index makes no physical sense, it's like comparing apples and oranges. On the other hand you could decide on how to measure UV and make your own index.
Comment: Thanks again!!! I did some research and I found this could you please tell me if this device is what I think it is. It converts the UV intensity into UV index measurement. - https://www.arpansa.gov.au/user-guide-uv-index-meter
Comment: I guess it works. It could provide you with similar index value to what city announces. That devices seems to use SiliconCarbide photodiode, so do a little research about what's being measured and include that info in your project

How to measure UV index?


Can I use GPU as GPGPU on any system

Question: I wish to use the GPU of a system as GPGPU. The machine is remote, I don't have administrative rights and I don't know anything about its drivers. What I know is that it has has a Matrox VGA card. Can I use as GPGPU with C code and gcc compiler or do I need to have some kind of drivers? Or can I only use OpenGL and twist the logic to suit my purpose?
Answer: There is no easy way to do this using OpenGL. It would be easy to do this if you know the graphics card supports GPGPU functionality. i.e. CUDA, OpenCL, or AMD stream. Then you can use one of these APIs to write a program which uses GPU for computation. For, this you will need corresponding SDKs. But, even using this APIs it is non-trivial to use GPU for complex calculations.
Answer: A few Matrox video cards support OpenGL and/or DirectX, so you might get away with what you want to do through shaders written in OpenGL/GLSL or DirectX/HLSL.
Check the specification of your video card.
Warning: these cards are not known to have particularly good GPUs.
Answer: Using the OpenCL/CUDA/Stream capabilities of a Graphics card requires drivers that expose the functionality. Aside from that, older cards (like say the ATI X800 series) do not have the required hardware to efficiently do what GPGPU requires, and thus are unusable for such purposes.
I doubt Matrox VGA cards have any support for GPGPU whatsoever.

Can I use GPU as GPGPU on any system


Windows Azure VPN Feature

Question: I was wondering if I convinced my manager to deploy Azure in the next project. Would it be possible to access the VPN resources from the Azure cloud Services?
Answer: Yes but you'll need a supported Cisco or Juniper device on-premises. If you don't have such a device, try looking at Windows Azure Connect which can give you an experience similar to VPN.
Comment: Thanks for the link as I am new to Azure and do not know the whole set of features it can offer.
Answer: @Sandrino, depends on what you meant by VPN, just want to point out, Azure Connect is using IPSEC to secure connection end to end.
Answer: Other routers such as fortinet can also support side to side vpn to azure, I myself use a fortinet device to connect to azure, if you need help let me know.

Windows Azure VPN Feature


What is the algorithm behind Rasa NLU?

Question: I see the Rasa NLU use the MITIE and spaCy, but can anyone explain the how they use it and the algorithm behind?
Comment: RASA NLU doesn't use any algorithm as such. It uses [specific pipelines](http://rasa-nlu.readthedocs.io/en/latest/pipeline.html) which you specify in the [configuration JSON file](http://rasa-nlu.readthedocs.io/en/latest/config.html) for NER and intent recognition. One such pipeline is [sPacy](https://spacy.io/usage/examples) and another is [MITIE](https://github.com/mit-nlp/MITIE).
Answer: There is a post by Alan on the Rasa blog here that covers the basic approach used:
https://medium.com/rasa-blog/do-it-yourself-nlp-for-bot-developers-2e2da2817f3d
This should give a good idea of roughly what it's doing but if you are keen to find out more, you can easily look over the actual code used (which is the great advantage of open source solutions!) https://github.com/RasaHQ/rasa_nlu/tree/master/rasa_nlu
Answer: It depends what kind of NER you want to use for your bot.. basically you define a pipeline in your configuration file ... most preferred is spacy since its corpus is being updated regularly and widely used .. mitie is not that good as compare to spacy and also is an older version.

language: "en"
pipeline: "spacy_sklearn"

you can read in more details here :
choosing rasa nlu pipeline

What is the algorithm behind Rasa NLU?


Intersection number of a divisor on a projective bundle over a curve

Question: Let $S$ be a projective smooth curve over an arbitrary field. Let $F$ and $E$ be locally free sheaves on $S$ of rank  1 and 2 making the following sequence exact:
$$ 0\rightarrow \mathcal{O}_S\rightarrow E \rightarrow F \rightarrow 0$$
If we denote $P(E)$ and $P(F)$ the projective bundles over $S$ associated with $E$ and $F$, we know that $P(F)$ is a divisor in $P(E)$ and that $P(F)$ belongs to the linear system of $\mathcal{O}_{P(E)}(1)$. I would like to compute the intersection number
$$(\mathcal{O}_{P(E)}(1) \cdot \mathcal{O}_{P(E)}(1))_{P(E)}$$
or equivalently
$$(P(F) \cdot P(F))_{P(E)}.$$
It should be well-known that it coincides with $\text{deg}(F)$, but I can't see why and I can't find any reference. Any help would be much appreciated, thank you very much.
Answer: First, let us gather some facts:
Let $\pi: P(E) \to S$ be the projective bundle map.
$1)$ We have a graded isomorphism (Hartshorne, II.7.11)
$$\operatorname{Sym}(E) \cong \bigoplus_{d \in \mathbb Z} \pi_* \mathcal O_{P(E)}(d)$$
$2)$ We have $R^i \pi_*\mathcal O_{P(E)}(d)=0$ for all $d>0,i>0$ (Hartshorne, Exercise III.8.4), hence we can compute the cohomology groups $H^i(P(E),\mathcal O_{P(E)}(d))$ after push-forward.
$3)$ Given an exact sequence $0 \to A \to B \to C \to 0$ of sheaves of modules, we have an exact sequence (see http://stacks.math.columbia.edu/tag/01CJ) $$A \otimes \operatorname{Sym}^{n-1} B \to \operatorname{Sym}^{n} B \to \operatorname{Sym}^{n} C \to 0. ~~~~(\star)$$
If $A$ is locally free of rank $1$ and $B,C$ are locally free, we have exactness at the left side, i.e.
$$0 \to A \otimes \operatorname{Sym}^{n-1} B \to \operatorname{Sym}^{n} B \to \operatorname{Sym}^{n} C \to 0$$
is exact. This is easy : The ranks in $(\star)$ are additive in this case, hence the kernel of the first map must be torsion, but it is torsion free as a submodule of a free module.
In our case, we get an exact sequence
$$0 \to \operatorname{Sym}^{n-1}(E) \to \operatorname{Sym}^{n}(E) \to F^n \to 0.$$
$4)$ We have the asymptotic Riemann-Roch formula: If $\mathcal L$ is a line bundle on a $d$-dimensional projective variety, we have
$\chi(\mathcal L^n) = \frac{(\mathcal L^d)}{d!}n^d + \text{lower degree terms...}$
Here $(\mathcal L^d)$ denotes the self-intersection number of $\mathcal L$. You can find this in the book of Lazarsfeld 'Positivity ...' as theorem 1.1.24.

Let us put these together: Let $L=\mathcal O_{P(E)}(1)$.
We have $H^i(P(E),L^n)=H^i(S,\pi_*L^n)=H^i(S,\operatorname{Sym}^n(E))$
, hence $\chi(L^n)=\chi(\operatorname{Sym}^n(E))$.
The exact sequence from $3)$ thus gives us
$$\chi(L^n)-\chi(L^{n-1})=\chi(F^n) ~~~ (\bullet)$$
by the additivity of the euler characteristic.
Together with the asymptotic Riemann-Roch formulas for $L$ and $F$
$$\chi(L^n)=\frac{(L.L)}{2}n^2 + c_1n+c_0,$$
$$\chi(F^n)=\deg(F)n + d_0,$$
this yields $(L.L)=\deg(F)$, since these are the linear coefficients of the left-hand side and the right-hand side of $(\bullet)$ respectively.


Performing semi-automated testing with ruby

Question: I am writing an open source gem that interacts with an sms service. I want to test the interaction, however  it needs account information and a phone number to run. It also needs feedback to determine if sms messages were being sent correctly. This causes two problems:

I can't put the account information in the test file, as the gem is open source and anyone could get to it.
I need the person running the test to give information to the script as it is running (eg checking the phone to see if a message was received).

What techniques or libraries are available that can help with this? I'm currently using rspec and making it prompt for parameters (using gets), however it is pretty cluncky at the moment. I can't be the first person using ruby to have this problem, and I feel that I'm missing a gem or something that solves this problem.
Answer: Use mocks
What are your tests testing, specifically? That a given login/password works? Probably not. Most likely you want to make sure your code reacts to the API properly. Therefore, I'd suggest mocking. Save the output of the API calls and use a mock service to return those responses. Then test. Your tests will be faster and less brittle as a happy side-effect.
More information on mocking with RSpec is here:
http://rspec.info/documentation/mocks/
Comment: The tests are making sure the api is correctly interfacing with the base http api that the service uses. Therefor a mock isn't very useful as I really need to make sure the interface is working correctly.
Comment: Do you need to make sure the service is *up* and functioning correctly at the time of the unit test? I wouldn't recommend this. See also http://martinfowler.com/articles/nonDeterminism.html
Comment: Hmm... re-reading your post, are you trying to use RSpec for something *other* than unit testing? If so, can you be more specific about the type of testing and include when the tests will be run and by whom?
Comment: The library is pretty small (it is at https://github.com/wire2air/wire2air ). It is really an functional/integration test, as I need to make sure that using the library actually connects to the service. Ie I need to make sure that using conn.send_sms("hello", "12345") sends "hello" to the mobile number "12345". If the service's http api changes, then I need the test to fail.

The tests will be run by me, and by the wire2air service developer (who I am developing it for) to make sure that the library actually works.
Answer: Re 1) Why not just save configuration options in a YAML file and load them at the beginning of your tests?
Re 2) Are there maybe any web services for that? E.g. one where you can send a message to and query an API to see if it worked. I know this can be unreliable, but the same is true for a user's phone company network.
Comment: Even if there aren't, it's not a problem to create one running on localhost.
Comment: Sure, but it sounded like OP wanted other people to run the tests, so having to set up a local web service for them might be overkill.
Comment: Certainly. That's why the usual solution is to create mocks.
Comment: 1 could work well, I could try reading from a default file, and if it wasn't found, prompt for additional details.

2 is probably overkill, a command line interface is good enough.
Answer: +1 for Mark Thomas' answer on mocking. Two more alternative mock object libraries for Ruby: FlexMock and Mocha


Matrix operation in dirac matrices

Question: If we define $\alpha_i$  and $\beta$ as Dirac matrices which satisfy all of the conditions of spin $1/2$ particles , and $p$ is the momentum of the particle, then how can we get the matrix form
\begin{equation}
\alpha_i p_i= \begin{pmatrix} p_z & p_x-ip_y  \\ p_x+ip_y & -p_z  \end{pmatrix}.
\end{equation}
Comment: I see... you're breaking the Dirac equation down to 2x2 blocks. This is the standard way of solving it. Where in the argument are you having trouble? Unfortunately the equations in your source aren't numbered, but I can see you mean $\vec{\sigma}\cdot\vec{p}$ rather than $\alpha_i p_i$.
Comment: Dirac matrices in 4 dimensions are 4x4. You've written a 2x2 matrix. Where did you find this equation?
Comment: Dirac matrices can be written as $2*2$ block form . check this link .http://www.nyu.edu/classes/tuckerman/quant.mech/lectures/lecture_7/node1.html
Answer: It's just a matrix manipulation. Let $\sigma_i$ pauli matrices.
\begin{equation}
\alpha_i p_i= \begin{pmatrix} 0& \sigma_i \\ \sigma_i & 0  \end{pmatrix} p_i .
\end{equation}
$ \alpha_i p_i= \begin{pmatrix} 0& p_1 \sigma_1 \\ p_1\sigma_1 & 0  \end{pmatrix}   +  \begin{pmatrix} 0& p_2 \sigma_2 \\ p_i\sigma_2 & 0  \end{pmatrix}  +  \begin{pmatrix} 0& p_3 \sigma_3 \\ p_3\sigma_3 & 0  \end{pmatrix} $
But $ \sigma_1 p_1 = \begin{pmatrix} 0& 1 \\\ 1 & 0  \end{pmatrix}p_1=\begin{pmatrix} 0& p_1 \\\ p_1 & 0  \end{pmatrix}$ ,
$ \sigma_2 p_2= \begin{pmatrix} 0& -i \\\ -i & 0  \end{pmatrix}p_2=\begin{pmatrix} 0& -ip_2 \\\ ip_2 & 0  \end{pmatrix}$
$ \sigma_3 p_3= \begin{pmatrix} 1& 0 \\\ 0 & -1  \end{pmatrix}p_3= \begin{pmatrix} p_3& 0 \\\ 0 & -p_3 \end{pmatrix}$
Now adding these we  get ($1\rightarrow x $, $2\rightarrow y $ ,$3\rightarrow z $)
,
\begin{equation}
\alpha_i p_i= \begin{pmatrix} p_z & p_x-ip_y  \\ p_x+ip_y & -p_z  \end{pmatrix}  .
\end{equation}
Comment: Your final formula is 4x4 on the left and 2x2 on the right. You should have a 4x4 matrix with what you've written as the upper right and lower left blocks, with zeros everywhere else.
Comment: In the right $2\times 2$ makes the matrix $4 \times 4$
Comment: No, the answer you want is $\alpha_i p_i = \left(\begin{matrix} 0 & p_i \sigma_i \\ p_i \sigma_i & 0 \end{matrix}\right)$ which has four 2x2 blocks. Your right hand side is the 2x2 matrix $p_i \sigma_i$, not $\alpha_i p_i$. You had it right until the very last line!
Answer: The equation you wrote only makes one choice that should answer all questions about this context: it chooses a representation of the $\alpha_i$ matrices with
$$ \alpha_i = \sigma_i $$
where $\sigma_i$ are the three Pauli matrices. You may check that if you substitute the Pauli matrices (particular $2\times 2$ matrices listed in the Wikipedia article linked in the previous sentence) for $\alpha_i$ on the left hand side of your equation, you obtain the right hand side.
If your formula had the Greek letter $\sigma$ instead of $\alpha$ on the left hand side, it would be uncontroversial. However, with $\alpha$, it is problematic. The $\alpha_i$ matrices are really $4\times 4$, not $2\times 2$, so all the equations above must be interpreted so that each matrix entry of the Pauli matrices is actually a block
$$ z \to \pmatrix {z&0 \\ 0&-z }. $$
We say that the Pauli matrices were tensor-multiplied by a $2\times 2$ unit matrix (in certain order). This extra tensor factor actually can't be the unit matrix because one couldn't find any matrix $\beta$ that anticommutes with all the $\alpha_i$ matrices. But it may be another $\sigma_z$, for example, in which case $\beta$ may be chosen to be ${\rm diag}(\sigma_x,\sigma_x)$, for example. Alternatively, you should ignore the source and learn some/all of the standard representations of the Dirac matrices.
At any rate, something is sloppy about the notation in which $\alpha_i$ were written as $2\times 2$ matrices and the simplest recipe to get $4\times 4$ matrices (tensor product with the $2\times 2$ unit matrix) doesn't work. So one should first see what $4\times 4$ matrices your source (if it is correct at all) actually means.

Matrix operation in dirac matrices


Block Incoming-Teamviewer Connection

Question: Is it possible to use an open-source tool such as Cisco IPS or Cisco ASA to block incoming Teamviewer connections to specific internal IP blocks, while allowing the outgoing ones? I cannot find a specific answer on other online sources.
Comment: @raz How is that relevant when he wants to block it at the network layer?
Comment: You're running Linux, Windows, a server?
Comment: @Xander he's asking for an open source tool.  I'm simply asking what platform he's working with.
Comment: Most users using Teamviewer use Windows OS
Answer: I don't think you can do this with firewalls, at the networking layer. When you connect someone with TeamViewer, you don't do it directly. TeamViewer users connect each other by using a third party server in the middle.
You can see the answer of kobaltz for the question How exactly does a remote program like Team Viewer work?

When you run TeamViewer, you are assigned an ID on their broker server. You make a connection to a Teamviewer ID, and TeamViewer passes the connection down through the TeamViewer client's established tunnel to the destination and you then you are prompted for password and then the connection establishes afterwards.

To achieve your goal, you should use TeamViewer's way. I think this article from TeamViewer is what are you looking for:  How can I restrict access for TeamViewer connections to my computer?

You can also restrict access to your computer in different ways. Depending on how you want to restrict access and to what extent, choose one of the following options:

To completely prevent any access with ID and password, exit TeamViewer in the taskbar.
  Any incoming or outgoing connections are no longer possible.
To restrict access to ordained devices, use the Black- or Whitelist in the TeamViewer full version. Deny incoming connections for specific TeamViewer IDs or only allow connections for defined TeamViewer-IDs.
To restrict features for incoming connections, use the access control for incoming connections. Choose between Full access, Confirm all, viewing access or deny any incoming remote control connection.
To deny connections from outside your network, only allow incoming LAN connections.
Answer: It's not possible (with a certain amount of time/ressources) to block Teamviewer with a conventional firewall. It would be possible using a proxy and firewall in combination. The easiest solution if you are in a windows environment:

Only allow LAN connection. Create a GPO that sets the following registry-key:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TeamViewer\Version[X]\Security_AcceptIncoming
REG_DWORD= 0
or
HKEY_LOCAL_MACHINE\SOFTWARE\TeamViewer\Version[X]\Security_AcceptIncoming
REG_DWORD = 0

btw: Running Teamviewer is not secure
Comment: I have tried your suggestion but this does not block incoming connection. We are using Teamviewer as a client requirement to support external customers, that's why I cannot reject that request. I believe I can add another layer of security by blocking incoming connection. But I beg your pardon if trying this on my network does not block the incoming connection. Did I miss something? Please advise. Thanks!
Comment: @Dr.U The link you provided, which references http://blog.accuvant.com/bthomasaccuvant/teamviewer-authentication-protocol-part-1-of-3/, implies that TeamViewer is vulnerable due to a 4 digit numeric password.  However the research is a year and a half old; TeamViewer's default is no longer 4 digit numeric pins.  They now provide for two factor authentication.
Comment: @raz It's also vuln to DoS (since everything goes through the TV-Server)
Comment: @confused1027 have you tried it from outside your network? another alternative would be to set up a proxy, forbid the teamviewer connections and a few TCP ports...
Comment: Yes, I am testing it from outside my network (different WAN IPs).
Answer: You can do so with the ASA or any other firewalls if you can use groups. What you would do is create a group that you would want to allow to access/be accessed by Teamviewer. Throw machines with permissions to connect to Teamviewer, then block all the others.
The issue becomes a firewall ACL. When you make connections to and from TeamViewer, you are being proxied through their servers. Here are the listed TeamViewer networks. What you want to do is create an ACL named "TeamViewer Networks" allow to your group, and deny to others.
Comment: This will block the connectivity in both directions, won't it? The OP explicitly asked how to prevent incoming TeamViewer connections ***while still allowing outgoing ones***.
Comment: The `A` record for `teamviewer.com` is 126.96.36.199, so the list of TeamViewer networks is clearly incomplete.
Comment: No WhiteWinterWolf, you can put the ACL only in your desired direction, so you can allow outgoing ones and only deny the incoming.
Answer: There is a couple of ways that you can block / allow Teamviewer specifically through Cisco ASA and the Firepower (IPS/IDS) module. NBAR can be used on routers as well.
NBAR  can also be used at a router level to block traffic for a specific application. Although i'm not 100% sure, you should be able to create some custom ACL's for incoming and outgoing traffic for teamviewer. This will address your issue of teamviewer jumping to different ports as NBAR inspects the traffic and looks for specific markers.
Jumping into Cisco Firepower which is a IPS/IDS module for Cisco ASA firewalls we can set it to block specific applications...
we can set an access control policy specifically for incoming traffic to block the teamviewer application whilst allowing outgoing. updates are received from Cisco daily on signature types for teamviewer apps.
Can be found under Policies -> Access Control -> New Rule -> Application tab
select the remote control applications you want to block in here. this may require a more advanced license so it may pay to check that you're capable of this.
the other way, that doesn't require any additional licensing is through intrusion prevention. however this doesn't resolve your issue of wanting to allow outgoing connections. it will block incoming and outgoing connections completely, but you do have the ability to monitor / alert or block on connections that are established. this may be an alternative to blocking it completely as you are able to view where the connection is originating from and then potentially feed that into your log aggregator or SIEM and take action from there.
Answer: I think the easiest way to block incoming teamviewer connection just edit your TeamViewer configuration.
Go to TeamViewer menu > Extras > Option > Advance > Show Advance Option.
On Access Control section you can change from Full Access to Costum Settings or change to Deny incoming remote control sessions which block all incoming sessions to your pc.
Maybe Costum Settings is the best options which you can allow, confirm or deny some service by click configure....
Comment: This doesn't answer the question. The OP asks about a central, network-wide solution and not one on each client.

Block Incoming-Teamviewer Connection


Integrating Javadoc for Java EE 6 API into Eclipse

Question: I'm using the new JBoss 7.1 which implements the full Java EE 6 standard and Eclipse Indigo.
Is it possible to get all the Javadoc for the EE Api working in Eclipse?
Answer: While the above solution does work, I am personally looking for a smoother solution.
So far I've gathered that for each jboss jar under the build path, I can reference the following url (or as Tiberiu stated, the location where you downloaded the docs):
http://docs.oracle.com/javaee/6/api/
This works fine. But there are approximately 10-15 libraries referenced in a given java ee project. Adding the above url to each library, for every new java ee project seems ridiculous to me.
I should think there is a way to specify where "the javadoc for the entire jboss 7 runtime" is located, not just for the individual libraries. Currently I'm still searching, but if anyone knows how to do this please enlighten me.
It just occured to me, the location i specify for one projects javadoc, might be retained for a new EE project. I'll check and get back with my findings.
UPDATE: Sure enough, it would seem the javadoc specified for one project persists for new ee projects too. So we're good :)
Answer: You could add Javadoc for any of the libraries that you are using in your Eclipse Projects.
Right click on your project -> Build Path -> Configure Build Path.
Now, on your Libraries tab, expand the jar that you are using(look for the Java EE jar). Expand it and you should see 4 sections (Source, Javadoc, Native Library, Access Rules). Click on Javadoc then you can edit (or just double-click Javadoc) and a dialog is brought up.
Not navigate to the locations of the javadoc. It should contain a index.html in the root. Also you can validate it before clicking ok.
Now that you linked the javadoc directory, click ok.
That should work
Comment: Well, I'm using JBoss7.1 and I dont have a single JavaEE.jar. Jboss7 has several jar archives in different directories. I couldn't find any JavaDoc for it. I hoped I could tell Eclipse where it would find the JavaEE javadoc and automatically link it to the classes.


Can the future not be changed in That's So Raven/Raven's Home?

Question: I recently started watching Raven's Home and I have already seen That's So Raven before. One pattern I noticed is Raven and Booker can both get future vision and they always try to change it but end up making things worse many times. However, one thing I notice is consistent is that the vision always comes true.
So is the future fixed in Ravenverse and unchangeable? Are there any instances where she actually succeeded in preventing the vision from happenning?
Answer: I don't remember all the episodes, but Raven and Booker often misinterpret the meaning of their visions, so that the actual events which eventually happen are different from what they expected and either hoped for or dreaded.
I don't think that I remember any episodes where they prevented their visions from happening, and I think that they often cause their visions to happen by trying to prevent them.  So it seems to me that their visions are predestined and inescapable in most or all of the episodes I have seen, though someone more expert than I am might have more to say on the subject.
I also add that That's So Raven and Raven's Home are not in a "Ravenverse" of their own, but are generally considered to be part of the DCLAU, or Disney Channel Live Action Universe.  That includes a number of other shows with science fiction and fantasy elements.  So there should be other DCLAU shows with precognition and time travel.
I believe the Wizards in Wizards of Waverly Place, for example, have some sort of time travel and time rewind spells.
I think the time travelling girls in Best Friends Whenever have sometimes changed history and thus the present, meaning that the future is not immutable and predestined for them, even if it seems to be for Raven & Booker's visions.
Of course, the DCLAU series Girl Meets World was a sequel to Boy Meets World, which was in a universe with other TGIF shows, including Family Matters where Steve Urkel invented a time machine and where the laws of time might be different from those in Raven.
And supporters of the Tommy Westphall Universe theory include the TGIF shows in the Tommy Westphall Universe that contains possibly hundreds of TV series, including some with time travel like, allegedly, Star Trek.  And in Star Trek the laws of time travel, including whether the future is predestined or can be changed, seem to be different in every single time travel episode.
Here is a link to a site with a master list of all the series they consider to be part of the Tommy Westphall Universe, which included 441 television series as of the latest update in August 2016.
According to those sites, Raven's Home is a sequel to That's So Raven, which is linked to the Suite Life of Zack and Cody, which is linked to to the Suite Life on Deck, which is linked to Jessie, which is linked to Live & Maddie, which is linked to Best Friends Whenever, which is linked to Girl Meets World, which is a sequel to Boy Meets World.
Or That's so Raven is linked to The Suite Life of Zack and Cody, which is linked to Jessie, linked to K.C. Undercover and I Didn't Do It, both linked to Austin & Ally, linked to Girl meets World, linked to Boy Meets World, linked to Sabrina the Teenage Witch, linked to Clueless, linked to Moesha, linked to The Parkers, linked to The Hughleys, linked to The Drew Carey Show, linked to Coach, linked to Newhart, linked to The Bob Newhart Show, linked to St. Elsewhere, linked to Cheers, linked to the John Larroquette Show, linked to Star Trek: The Next Generation, which is linked to all the other Star Trek shows with all their time travel stories.  Star Trek is also supposed to be linked to Red Dwarf, which is supposed to be linked to Dr. Who with hundreds of time travel episodes.

Of course opinions vary on how strong a connection two different shows have to have to be considered part of the same fictional universe, so there can be different views on how many shows are int the same fictional universe as Raven and Raven's Home.
I have seen a site that claims that Star Trek is in a fictional universe with only about a dozen other shows, called Group 10, and that St. Elsewhere shares its fictional universe, called Group 2, with "only" about 94 shows instead of over 400 shows.  It puts Dr. Who with all it's time travel stories in a Group 27.  It has a Group 30 that includes Girl Meets World and a bunch of TGIF related shows but doesn't include the DCLAU shows.
That would tend to reduce the other time travel shows to consider when deciding if the future is immutable and preordained in That's So Raven and Raven's Home.
So the question of whether the future is predetermined and unavoidable in That's so Raven and Raven's home can get very complicated if other shows that might be counted by some persons as part of their fictional universe are also considered.
Comment: Related: https://movies.stackexchange.com/questions/91685/why-doesnt-raven-tell-ben-about-dr-sleevemore-et-al
Answer: I know this answer is a little late, but I'm on a binge of random episodes of the original series and in the episode Hook Up My Space (Season 4 Episode 6), Raven has a vision near the start of the episode of Cory making a presentation to their father, and she rushes to intercept him in time to prevent it from happening. She succeeds. I think that's one of the few instances where her vision doesn't actually happen, due to her intervention.
Comment: It's never too late and I will check that episode soon to confirm, for now +1
Answer: In That's So Raven, there have been visions that have changed.
I think the point/theme of the visions in Raven's Home is more of being open to alternative interpretations of the visions or wisdom in knowing that there may be more to the story (presented in any particular vision), rather than fate/determinism vs free will. From what I recall in That's So Raven (and one episode of Cory in the House), this is also the case, but I think That's So Raven had more, but only a little more, fate/determinism vs free will themed episodes than Raven's Home did.
Here's an example where a vision has changed:
For example S02E13 Radio Heads, Raven says at the end:

Guys, just checked out the future. We're going to be friends forever.

This was based on a vision she just had, but earlier the episode, it was shown that Raven had a vision that went like:
Answer: In Season 1 Episode 2, Raven has a vision that Eddie fails a test but it doesn't come true after the teacher changes all the questions at the last minute.


In crystal field theory, why do all the metal electrons enter the d orbitals and not the s orbital?

Question: Suppose we have the complex $\ce{[Fe(H2O)6]}$. Iron has 26 electrons, and its electronic configuration is therefore $[\ce{Ar}]\,\mathrm{4s^2 3d^6}$, but in crystal-field theory, we say that the $\mathrm{3d}$ orbitals have 8 electrons instead of 6. Why?
Comment: $\ce{[Fe(H2O)6]^{\pm 0}}$? I'm pretty sure that doesn't exist; at least due to the 18-electron rule.
Answer: Your example is a little questionable. I would think you are talking about $\ce{[Fe(H2O)6]^2+}$, in which case you are actually supposed to have an $\ce{Fe^2+}$ ion with a $[\ce{Ar}]\mathrm{(3d)^6}$ configuration. There are no $\mathrm{4s}$ electrons in the $\ce{Fe^2+}$ ion.
Nevertheless, it is true that in crystal field theory, electrons are assumed to be entirely in the d-orbitals, even for low-oxidation state complexes. For example, nickel(0) in $\ce{[Ni(CO)4]}$ is assumed to have a "$\mathrm{d^{10}}$" configuration. There is a reason for this, the explanation of which requires a molecular orbital treatment. Consider a generic octahedral complex, $\ce{[MX6]^{n-6}}$, which is formed from a $\ce{M^n+}$ ion and six $\ce{X-}$ ligands. We could construct an MO diagram:

(Source: Miessler & Tarr, Inorganic Chemistry 3rd ed., p 347)
Each $\ce{X-}$ ligand contributes one pair of electrons, which gives rise to a total of six pairs; these six pairs of electrons enter the low-energy bonding MOs $\mathrm{a_{1g} + e_g + t_{1u}}$. These MOs are similar in energy to the ligand AOs, and therefore are likely to be mostly centred on the ligand, which means we can essentially ignore these MOs when we are describing the properties of the complex. (Of course, these MOs are important in the sense that they are responsible for the bonding between metal and ligand. If these bonding MOs did not exist, the complex would not form. However, we are usually much more interested in the higher-energy orbitals.)
The electrons in the $\ce{M^n+}$ ion can be in any of the AOs ($\mathrm{3d}$, $\mathrm{4s}$, or even $\mathrm{4p}$) - it does not matter. The only important thing is that, once the complex is formed, these electrons will enter the lowest-energy MOs according to the aufbau principle. Since those low-energy bonding MOs are already occupied by ligand electrons, the metal electrons will have to go into the $\mathrm{t_{2g}}$ and $\mathrm{e_g^*}$ MOs, which in the simplistic treatment of crystal-field theory are called the "d-orbitals".
The truth is that those two MOs have quite a lot of metal d-orbital character (as you can see from the dotted lines), so crystal-field theory is not entirely wrong. Nevertheless, you can see from the MO diagram why it would be wrong to assume that the metal $\mathrm{4s}$ orbital is filled: what CFT calls the $\mathrm{4s}$ orbital is actually the $\mathrm{a_{1g}^*}$ orbital in the MO scheme. This orbital can only be filled if the $\mathrm{t_{2g}}$ and $\mathrm{e_g^*}$ MOs are already filled, which is not the case unless we are talking about some kind of zinc(0) complex (very unlikely!).
Similar diagrams can be constructed for other geometries (tetrahedral, square planar etc.) and the same point will hold. Therefore, even though $\ce{Ni}$ itself has a $[\ce{Ar}]\mathrm{(3d)^8(4s)^2}$ configuration, the tetrahedral $\ce{[Ni(CO)4]}$ complex will have a $\mathrm{(e)^4(t_2)^6}$ configuration (as you are probably familiar with, in tetrahedral complexes, the d-orbitals are split into $\mathrm{e + t_2}$). Again, in the language of crystal-field theory, both the $\mathrm{e}$ and $\mathrm{t_2}$ orbitals are simply called "d-orbitals", so this is equivalent to having a "$\mathrm{d^{10}}$" configuration.
Comment: After realizing the confusion, I've tried to stick to "valence electrons" for the metal.
Comment: @orthocresol thanks for this answer. However, using just CFT arguments, do you think this could just be explained by arguing that s orbitals are more diffuse and, therefore, experience more repulsion from the ligands and are destabilised more? Moreover, I still don't see why LFT (using MO), which assumes pure covalency, is necessarily better than CFT, especially for hard-hard complexes?


Questions in reported speech from direct speech

Question: Direct speech:

Do you love me?

Reported speech:

She asked if I loved her?

Or

She asked did I love her?

Please let me know, which one is a correct answer? Or both are fine.
Thanks in advance.
Comment: She asked if I loved her. - Without the question mark, is just fine.
Answer: Correct answer is most likely, "She asked me if I love her." but the other one is ok.
I think you missed the important part.  What's the correct answer to say back to her?  The woman talks in code.  The answer to "Do you love me?" is very difficult and advanced.  It all depends on which word is stressed, which indicates uneasiness or doubt.
Her: "Do you love me?" Then she has doubts about the honest of your love.  Maybe your capability.
Correct Answer: "Of course I love you.  If I didn't love you, I would have been gone a long time ago.  I'll always love you."
But they get harder....
Her: "Do you love me?" Then she has doubts about the you loving her.
Correct Answer:  "I love you like I've nover loved anyone in my life.  Yes I love you!"
Her: "Buy why do you love me?"
You: "Because your special.  You're kind.  You love people.  You're the best girl I've ever met.  You're beautiful on the inside and out.  You drive me crazy!"
Her: "Do you love me?" Then she doubt about your love for her.
Correct Answer:  "I always love you.  My heart is yours forever.  I've never stopped and I never will."
Her: "Then why didn't you do X" where "X" is something you never would have thought doing, like stacking her dishes to the left.
You: "Because I wanted to make you mad."
Her: "Whaaat?"
You" "I'm joooking!  I didn't know that was important.  You know I try to be a mindreader.  I'm just not good enough at it yet.  I want more practice.  My energies say you want a shoulder rub right now."
Her: "That's not what I was thinking..."
You: "I know what your mind was thinking, But your body was screaming for a shoulder rub..."
Her:  "Do you love me?  Then she has some doubt or insecurity about herself.
Correct Answer: "Yes I love you.  You're the only one I love.  I love everything about you.  I love your eyes, your smile, your face, you laugh.  But most of all, I - LOVE - YOU!"
Her: "Then what about that girl you were talking to?"
You: "Which one?   I talk to so many..."  She hits you playfully.  "Owww!" you say with more pain and flinching that it really hurt.  "Don't be so jealous/silly/whatever, I was asking her what I should get you for a present."


How to build a case study and portfolio when you have no experience yet?

Question: I am trying to make a good impression and wanted to show everything I've learned from my Google UX certification in a course I took from Coursera. How can I best show it? Is there some websites that I can use to create a case study about without disappointing the recruiter?
Comment: The question is slightly different so I suggest to leave it open. Possibly you will have to figure it out yourself so that other question is definitely something to check out. Ultimately you can post your own answer here yourself and help others with the same question.
Comment: There are no questions like this in UX.SE already? It feels like a really common question to ask. @jazZRo
Comment: Btw, OP, wouldn't you have received a class on how to build such a portfolio within the Google UX Professional Certification itself?
Answer: Making a portfolio website without experience can be a tricky task especially in roles like these (design, UX, etc.).
So, I think it's best you lean into the fact that you are new and are a good learner. Those will be your strengths and your site will have to represent that.
You'll want your site to show what types of things you want to learn and also be an advertisement of what types of experiences you want to help build.
Your best bet to achieve this is to create a blogging site using Wordpress or even ditch the whole idea of making your own site and use other sites like notion or medium. You want to talk about things that you feel passionate about, mainly because it will fuel you to finish articles, which will be your biggest challenge.
Btw, you can check out my site (https://kitanga.dev), or anyone's on this platform really, they all have great sites from what I've seen. Mine though, is primarily designed to show what type of experiences I want to build, it's still a work in progress, but I'm certain it's current state is good enough to make it into this answer.
Comment: Thank you for this, the way you said "lean into the fact that you are new" kinda hit me. I guess it's important to also acknowledge that I am a new and am willing to learn from new experiences.
Comment: @J.Dupo Yea, no problem. Though I'd like to warn you, when you get more experienced you might want to step away from the style of thought. Remembering is the hard part
Answer: Showcasing what you've learned from your Google UX certification can be achieved effectively through creating a well-documented case study or several case studies. Here's how you can go about it:
1. Choose a Project or Topic:

Real-world Projects: Ideally, if you've worked on any real-world projects, you should focus on them. These can be personal projects, freelance work, or even academic projects.
Hypothetical Redesign: If you haven't worked on a real-world project, consider doing a hypothetical redesign of an existing product or website. This can demonstrate your ability to identify UX issues and come up with solutions.
Concept Projects: Create a new app or website concept from scratch, based on a unique idea or a gap in the market.

2. Document the UX Process:

Research: Discuss the initial user research, surveys, interviews, or any other methodologies you used.
Personas & User Flows: Show how you've distilled research into user personas and created user flows based on these personas.
Wireframes & Prototypes: Share your low-fidelity wireframes, moving on to high-fidelity designs and interactive prototypes.
Usability Testing: Detail the testing methods you used, feedback received, and how you iterated based on that feedback.
Final Design & Reflection: Present the finalized design and reflect on the overall process, challenges faced, and learnings.

3. Choose a Platform to Showcase:

Behance
Medium
Personal Website
Dribbble
LinkedIn

4. Tell a Story:
UX is not just about pretty designs; it's about solving problems. Ensure your case study narrates the story of how you addressed a user's problem, the challenges you faced, and how you overcame them.
5. Solicit Feedback:
Before publishing or sharing your case study, get feedback from peers, mentors, or other professionals in the field.
6. Prepare for Discussion:
Be ready to discuss your case study in interviews. The recruiter might ask questions to understand your thought process, the choices you made, or how you handled certain challenges.
7. Consider Ethics and Permissions:

If you're using real-world projects, ensure you have permission to share any proprietary or sensitive information.
If doing a hypothetical redesign, clarify that it's an exercise and not an official project.

Lastly, when showcasing anything, whether it's a real project or a hypothetical redesign, it's the quality, depth, and your process that matter the most, not necessarily the brand or website you chose. Focus on showing how you think, how you approach problems, and how you leverage your UX skills to find solutions
Comment: Thank you for the detailed answer. I will consider this greatly when I build a portfolio. This will serve as an additional item I should consider.


Is there any way to overcome URL length limitation in REST API "GET" Requests?

Question: Is there any way to overcome the 2083 characters limit using REST API GET request itself.
Answer: Technically I HttpGet will have issue if the URL length goes beyond 2000 characters. In that case, it's better to use HttpPost or redesign the URL schema.
Check here for pretty well explanation: https://boutell.com/newfaq/misc/urllength.html
In Summary:
The maximum length of a URL in Internet Explorer is 2,083 characters
Firefox: 65,536 characters
Safari:80,000 characters
opera: 190,000 characters
Comment: Ya Farshid, If length is greater than approx 2k we can go with REST API Post requests or some other client object models. But I'm trying to overcome the limitation for GET requests
Answer: You may require custom service to be written. Other than that I dont see any method. REST is the more capable when quering SharePoint even we think of other methods like CSOM or server side code.


Can a video game potentially detect arduino leonardo?

Question: If I automated an action in a video game through arduino leonardo, can it be detected? Things like autohotkey can be easily detected, however i would expect an arduino would be far more difficult. How easy/difficult would it be detect?
Comment: it all depends on the game, and on the controller that you are emulating ..... for example  if the game is a first person shooter and the arduino is pulling the trigger exactly every 95 ms then the game may be able to determine that you are not pressing the keyboard manually
Comment: It would be little use to only check for Arduino's. You would in some way have to check the player's behaviour and estimate if it's 'human', which works for any type of automation.
Answer: Yes.
First you'll need to define how you plan to inject the new input signal, into the data "packets" as a spoof of controller signals, or just jumping the switches?
In the context of any modern gaming console, it could be detected. Easily. Consoles and controllers use any number of proprietary protocols which sync.commands to improve response and reduce controller lag. If you're just jumping the switches, then no, you could simulate hadouken and probably get away with it just fine.
If you're referencing PC gaming, then that would be hard if not impossible with the variance of input control available.  The best deterrent would be the security of the game software itself and the genre of the gaming. Some games actively encourage Hotkeys.
Answer: Nigh on impossible. True the game could look to see if there is a specific VID/PID combination visible to the computer, but that is probably not going to happen (and anyway you can change it).  As far as the game is concerned, input from a keyboard is input from a keyboard, whether that keyboard has buttons or a piece of code it really can't tell.


What do colors mean in specular maps?

Question: I always thought light pixels correspond to reflective areas and dark pixels correspond to non-reflective areas. so why is this specular map blue?
Comment: Generally, the hue of a specular map is not taken into account, only values. This blue map will work in Blender, but there is no need for it to be bluish, if you turn off its saturation the effect will be the same. It is possible to store in a single RGB image three different BW images (one in   the Red channel, one in  the Green and one in the Blue): maybe that's the reason why you have found this specular map: the creator packed different maps into a single image and then used something like Blender's separate channels node to address every map to the desired input socket.
Comment: [Specular and metallic workflow guide](https://www.allegorithmic.com/pbr-guide) [Similar case study](https://blogs.unity3d.com/2015/02/18/working-with-physically-based-shading-a-practical-approach/) The above Link will help you to clear your Concepts regarding all maps used in PBR texturing.
Answer: Light behaves differently on different materials. So to recreate these behaviours we use Maps and so we have different workflows. Mostly they are Metallic or Specular workflow.
In specular workflow the "Specular" map defines the specular reflectivity of the material. And then the Materials are divided into 2 Categories Metals and Non Metals.
Specular Map in Metals are usually coloured which gives them the Reflective Color and there albedos are usually in greycscale.
Specular map in Non metals are usually in grey scale and the colour is defined by the albedo.
Specular and metallic workflow guide
Similar case study
The above Link will help you to clear your Concepts regarding all maps used in PBR texturing.

What do colors mean in specular maps?


Fubini-Tonelli theorem and absolutely Lebesuge integrable functions

Question: As far as I know, a measurable function is Lebesgue integrable if and only it is absolutely integrable. It is simply because the definition of the integrability requires each of the positive part and the negative part has a finite integral. However, some theorems explicitly state that a function need to be "absolutetly integrable". For example, Fubini-Tonelli theorem says that if one of the iterative integrals or the double integral is absolutely integrable they have the same value. What's the point / importance of the absolute value here? Can I just replace the condition of absolute integrability with just integrability?
Answer: The point in this case is that for
$$
\int \int f(x,y) \, dx \, dy
$$
to be a well-defined integral, we only need (in addition to measurability requirements) that for (almost) all $y$
$$
\int |f(x,y)| \, dx < \infty
$$
and then that
$$
\int \bigg| \int f(x,y) \, dx\bigg| \, dy< \infty.
$$
Note that this is in general a very different condition than
$$
\int \int |f(x,y)| \, dx \, dy<\infty.
$$
Comment: Thank you for the answer. I understand your point. But my main concern is the absolute value in the double integral. The statement in the Wikipedia page requires $\int_{XY} |f(x,y)| d(x,y) < \infty$. I don't get what's the difference between $\int_{XY} |f(x,y)| d(x,y) < \infty$ and $\int_{XY} f(x,y) d(x,y) < \infty$ here.
Comment: In this case, there is no difference (if $f $ is measurable with respect to the product sigma algebra). Only, I would write "$\int f (x,y)d (x,y) $ exists" instead of "$\int f (x,y)d (x,y)<\infty $"


Build / Destroy function design & security checks

Question: I'm working on a browser based strategy game. For the moment I'm working on the build/destroy functions and I have a couple of questions about this. The main question is do you have advice on how I can pass the buildingId and townId to the page where I call the build function? Any advices about the checking I should have in the build / destroy function?
Comment: Morning? It's nearly time to call it a day here... :)
Comment: :-) it's 9:33 am here :-) for me the day started today at 7:30 :-)
Answer: Since this is PHP, you can pass your buildingId and townId as GET data in the URL, i.e.:
build.php?building=39&town=204832

You can then access this with $_GET["building"] and $_GET["town"], which would equal 39 and 204832 respectively in this case.
Your other option is submitting this as POST data (form data) and accessing it using $_POST["building"]. I don't know of a way in PHP to send POST data other than to have form fields on your page and submit that form (<input type="hidden"> would come in handy here). The only advantage here is that your variables aren't exposed in the URL, but it is does not make anything more secure.
I am not a security expert, but don't trust any information your client gives you. There are a lot of security checks you might want to do and only you (as the game's designer) would know which ones need to be asked. Some likely examples:

Does the town exist and belong to the user, or do they have permission to build there?
Does the building they want to build even exist? Can they build it? Can they build it there? If it is a one-of-a-kind building, have they already built it?
Is there already something built there? Is there room for it?

My ultimate advice would also be that you should not use PHP at all, and instead should create this game in anything else: Python webservice, ASP.NET, JavaServer Pages, take your pick. PHP is an incredibly bad language in all the ways a language can be bad. This is not me having a language bias and hating on a language like how some people hate C++ or Java. This is different.  PHP is actually just bad.
Comment: i was looking for new ideeas how to parse the building id and town id so i can go further for inserts, updates, data check and other things like that, and few ideeas about what should i check see if my list is fine or not :) and it is :-D thank you very much for  your reply and for the next replies will come during this day :-)
Comment: i'm using pdo driver for the database work related :-)
Comment: Nevermind then, prepared statements with PDO will do well
Comment: yes i know :-) so far so good yet i'm sad because of all the checkings i need to do some queries to the db :-( and i was hoping to keep it as simple as posible and with a max of three queries :)


How to add time line using normal list in SharePoint

Question: Is it possible to add time line web-part using normal custom list or any other solution to implement through normal list
Answer: If you have a column for Title, Start Date, & End Date (not necessarily with those column names), you could create a Gantt View of the list. This lets you select your start and end date columns, and represents it graphically.
Comment: Are you sure, we can use Gantt view for the time line..because I couldn't get the view while configuring timeline.
Comment: Sorry for the delay. In my list (not the webpart), I clicked 'create new view', then 'Gantt View'. You can configure the settings there. Then, on the page you would the webpart, insert the webpart. Then edit the webpart, and change the view to the Gantt view that you created.
Answer: It's not part of the list, it's a separate webpart. On the page where you want the timeline insert a new web part, and under content rollup you will find the timeline.
** Edit **
You can't bind it to a "custom list" type.  You can however create a task list and then extend it with the columns you need.  This would let you use the timeline with that list.
You can't just add the task content type either - it has to start as a task list to work.
Comment: Yes, But it should be linked to task list..I want a way to use it with normal list.
Comment: How can I extend lsit with column..can you please help me out for this


How do I use Apport on a virtual console to send a bug report?

Question: I am experiencing several bugs in Ubuntu 19.10:

When pasting, often I paste not the newest copied/cut text/image, but the previous one. Very annoying! It is the case in all programs (LibreOffice, Kate, Firefox etc.).
When a program has problems - e.g. because something takes a long time, and it offers to wait or close down, sometimes the whole computer becomes unresponsive - I can move the mouse, but not change to other running programs. In the end, I have to hard reboot.
Sometimes the laptop keyboard becomes somewhat unresponsive. I can move the mouse, change programs etc., but when I type, it takes forever for the letter to turn up - and then a number of the same letter is typed. Even after a restart, it is the case (which makes it impossible to log in). When I close down, wait a few seconds, and restart, it works again.

So I wanted to report these errors - and I guess it has to do with xorg, so I hit Alt+F2, and:
ubuntu-bug xorg

The data is collected, and I hit send. Then nothing happens. According to this page: https://help.ubuntu.com/community/ReportingBugs, I should see a webpage where I should provide more information. But I don't...
Anyone who could help me on how to get these bugs reported?
Answer: example
 apport-bug /var/crash/_usr_bin_lxqt-globalkeysd.1000.crash

If a running program acts wired for you.
pidof programname

get the pid of running Prozess.
apport-bug PID

I'm not good in explaining. Please take also a look in
man apport-collect


What typically is the expiration date of a session cookie?

Question: I need to create a session cookie using JavaScript (for more info see question). I'm wondering what should the expiry date be? I'm guessing it's the browsing session, so if I don't set an expiration date this will be used as the default, right? This session would be used to validate a logged on user. So does it depend on how long I want users to stay logged in before automatically logging them off (if yes what's a good time, or should it stll be the browsing session?)?
Answer:
I'm guessing it's the browsing session, so if I don't set an expiration date this will be used as the default, right?

Yes. Unless you have a particular need for sessions to survive a browser restart, omit the expires parameter so that the cookie is browser-session-only and not persisted to disc.

does it depend on how long I want users to stay logged in before automatically logging them off

That is governed by your actual session expiry time, which should be implemented on the server-side alone. If you do use an expires time you would generally want it to be at least as long as the server-side timeout, but you shouldn't rely on the browser honouring that expires as your method of ensuring old sessions are unreachable.
Generally, session-only (no-expires) cookies are used for session-tracking, with timeout happening on the server side. If a request is made with an unrecognised or missing cookie, then likely the session has expired at the server side, the browser has been closed at the client side, or both, and you should direct the user to start a new session.
Typically there will be a session management tool included in whatever your web framework is on the server-side that will work this out for you by sending the appropriate Set-Cookie headers on an HTTP response (either the initial HTML page, or an XMLHttpRequest response). Whilst you could reimplement session management yourself using only JavaScript, passed parameters and, say, localStorage as an alternative to cookies, there doesn't seem to be that much to win by reinventing that wheel.
Comment: erm, not exactly. Both Firefox and Chrome have the ability to resume an automatically saved state (browser session) at start up which includes session cookies (cookies without an expiration date) - so they can be persisted on non-volatile storage.
Answer: My recommendation would be: "Don't create the authentication cookie using JavaScript."   A cookie identifying an authenticated session should be marked wit the HttpOnly flag to help mitigate XSS attacks, and so must be created by the server and sent with the response, not created on the client.
That bit of advice aside, your assumption is mostly correct.   If there is no expiry set on the cookie, then it is a session cookie and will live as long as the browser is open, and the sessionid is valid.   If the server expires the authenticated sessions periodically, then the cookie will no longer be attached to a session on the server and will therefore be essentially null.
To your second question, if you wish to specify a maximum amount of time a user is logged in before needing to re-authenticate, it's usually done with a rolling expiry, where the expiration time is updated with each request to be x minutes from now, so active user sessions aren't forcibly expired, only idle sessions where a user hasn't made a new request in the last x minutes.   The most secure way to do this is to tie the value of the cookie to a session on the server that expires on time, which can't be interfered with by the user.   The expiry on the cookie is not sufficient, as it can be changed by the client.  If you need to store a session expiration client side, it needs to be encrypted in the value of the cookie, so again needs to be created server-side, not by JavaScript, because the server must be the only place the value can be decrypted in order for it to be secure.
And lastly to your third question, what is an appropriate amount of time before expiring a session?   It depends entirely on your application.   Financial applications often have very short timeouts of five or ten minutes.  Many applications have a more traditional  default time out of 20 or 30 minutes.   If the workflow of your app requires extensive amount of time on a page without refreshing, even longer may be in order.   I don't know that it's terribly important in any case, unless your application has specific security needs.
Comment: @Celeritas The reason is that if the browser has access to the cookies, **any** code running on the page has access to them.  For authentication cookies particularly, This Is A Bad Thing, because if you have any cross-site-scripting (XSS) vulnerabilities on your site, an attacker could inject code that would steal a victim's authentication cookie, which the attacker would then use to impersonate the user.  So, authentication cookies should be marked with the HttpOnly flag and so not accessible to JavaScript on the page.
Comment: An attacker with XSS can already impersonate the user completely inside the compromised browser window. `httponly` doesn't really *prevent* exploitation, it just makes it more annoying for the attacker as they have to do it in-browser instead of stealing the token and doing it locally. There are tools to make that easier though (see eg BeEF); if you have XSS you have effectively already completely lost. `httponly` is worth including if you can drop it in for cheap, but I wouldn't lose any sleep over a client-side app design that couldn't use it.
Comment: Hold on a second. HOLD ON A SECOND! "Don't create the authentication cookie using JavaScript." Why? A user has control over their cookies regardless if it was created by local JavaScript or a client side script (PHP in my case). Note the session itself is created by the server, on the server. I'd really like to be clear on this before I bust my ass off trying to create the cookie with PHP instead of JavaScript =)
Comment: I get it now. If I create the session cookie with JavaScript and set the httponly flag, would that be better or still insecure compared to sending the cookie directly from the server?
Comment: If there's ever a point it can be manipulated on client, it's going to be less secure than creating it on the server and sending it with the HttpOnly flag.  However, if you immediately set the flag, then you've limited the attack surface to the page that creates the cookie.  Personally, I don't care for it, but I can't immediately think of any issues that couldn't be overcome.
Comment: just so you know according to the PHP manual the claim that httponly helps against XSS attacks is disputed http://php.net/manual/en/function.setcookie.php
Comment: @Celeritas That's old (6 or 7 years, likely, as HttpOnly support was added to PHP in 2006) thinking. The use of of HttpOnly is a generally accepted best practice now.
Comment: Its now 2020, and it turned setting the cookie param Httponly to True was/is actually a very good way to slow down and even stop black hats, as black hats are getting lazy these days and move on to another site. In fact it is soo good,  Its now July 2020 Chrome is now giving cookies a MASSIVE security upgrade due to the millions of XSS going on. turn SameSite cookie param to "Strict"(your site only)  or "None"(if you want other sites to read it).
Comment: It turned out this is now soo important that Chrome is trying to flip the default on everyone :) where everything will be set to Strict, and you have to explicitly set to "None"   good luck chrome.. its a good idea.  covid hit, web devs cried, and chrome rolled back their plans.
Answer: I'm not a web developer so this could be wrong but I would expect that you could just use the Set-Cookie: header in the HTTP response to the AJAX query to set the session cookie.
You should not need to pass the session ID inside the AJAX response and then use Javascript to set that cookie.  The standard PHP session_*() functions should handle setting the expiry time correctly for you.

On a security note, HTTPOnly, Secure and SSL.  You should be doing all of these.
You should also be expiring sessions on the server both when the user logs out and after a certain period of inactivity from the user.  The period you choose is a tradeoff between security and usability.  The default in PHP is 1440 minutes (24 hours).
Comment: @barlop nope its because of hackers, that try and guess your session id at 1000 per minute over 24 hours.  and they take over your banking or payment session and take your money.  yes programmers could double their length of cookie to make it hard to guess at all, and extend the cookie till 7 days.
Comment: So it is because of programmers like you that people have to keep logging into sites and get automatically logged out, even when it's their own computer and they are the only person using it. How about giving the user the option
Comment: You have to delete old session storage files from your server at some point or you will run out of disk space. Allowing the user to choose this time period adds complexity to the process which is why no one ever does it. You can implement a "remember me" function on top of session cookies which allows you to stay logged in forever but that's not what this question is about. You still get a new session cookie each time you visit a site with a "remember me" function.