I came across a little issue with JS in my project.  Basically I use this type of for loop for most arrays:  for (var item in array) {     // Do something with each "item" }   Now that is working fine and dandy for the most part, but when I use it like this:  for (var element in someDOMelements) {     element.AddEventListener(...); }   It is going to throw me an error, saying AddEventListener is not working However if I adjust the code to something like:  for (var i = 0; i &lt; someDOMelements.length; i++) {     someDOMelements[i].AddEventListener(...); }   It's working as it should. And just to rule it out I logged the array that the DOM elements are in before the loop and it correclty gave me a list (HTML Collection) of all the objects..  Is there anything specific going on here, that prevents me from manipulating DOM elements with these kind of for loops?  Cheers!
I've been told not to use for...in with arrays in JavaScript. Why not?
Can I run a second wordpress site as a subdomain without using multisite? What material fills the synaptic cleft? Is it water? The synaptic cleft is the gap between the pre-synaptic and post-synaptic neurons, and neurotransmitters are transferred between the neurons within this region. What substance exits in this space, is it water? If so, what force makes the neurotransmitters move toward the receptors despite colliding with water molecules? This is the proof, which I mostly understand except for one bit:  You have $h_1 \in H_1$ and $h_2 \in H_2$.   We also have $h_1^{-1}(h_2^{-1}h_1h_2) \in H_1$, because $h_2^{-1}h_1h_2 \in h_2^{-1}H_1h_2 = H_1$. Similarly, we have $(h_1^{-1}h_2^{-1}h_1)h_2 \in H_2$. Therefore  $$ h_1^{-1}h_2^{-1}h_1h_2 \in H_1 \cap H_2 = \{1_G\} $$  and so $h_1^{-1}h_2^{-1}h_1h_2 = \{1_G\}$. Let's first multiply everything on the left by $h_1$  $$h_1^{-1}h_2^{-1}h_1h_2 = \{1_G\}$$ $$ h_1 h_1^{-1}h_2^{-1}h_1h_2 = h_1 \{1_G\}$$ $$ h_2^{-1}h_1h_2 = h_1 \{1_G\}$$   Multiply both sides on the left by $h_2$ giving us  $$ h_1h_2 = h_2 h_1 $$  The bit I don't get is right at the beginning. Why is this correct: "We also have $h_1^{-1}(h_2^{-1}h_1h_2) \in H_1$, because $h_2^{-1}h_1h_2 \in h_2^{-1}H_1h_2 = H_1$." is it safe to keep database connections open for long time I have a .net client application which is connected to a remote database. Is it safe to keep a single connection open for the lifetime of the client (hours)? Does the answer hold if I have multiple (10 or 100) clients running? How can I mitigate edge halo when darkening skies in post-processing? If $p$ is a prime and $p \mid ab$, then $p \mid a$ or $p \mid b$. The proof is already given in the textbook but I tried other way around.   Proof by contradiction: Let's assume that $p$ doesn't divide $a$ and $p$ doesn't divide $b$, but $p$ divides $ab$. So $\gcd(p,a)=1$ and $\gcd(p,b)=1$. Given that we can construct linear combinations   $sp+ta=1$ together with $up+wb=1$. Multiplying the left and the right sides of the equations we get  $spup+spwb+taup+tawb=1$ or $p(sup+swb+tau)+ab(tw)=1 \implies \gcd(p,ab)=1$. This is a contradiction.   Is it rigorous and sound proof? How to use both binary and continuous variables together in clustering? I need to use binary variables (values 0 &amp; 1) in k-means. But k-means only works with continuous variables. I know some people still use these binary variables in k-means ignoring the fact that k-means is only designed for continuous variables. This is unacceptable to me.  Questions:     So what is the statistically / mathematically correct way of using binary variables in k-means / hierarchical clustering? How to implement the solution in SAS / R? Python metaheuristic packages Allow sound file uploads in questions and answers? Should Stack Exchange introduce the ability to upload embedded sounds (maybe via HTML5/Flash, whichever the user has) as part of questions and answers to Stack Exchange?  It could require a certain amount of rep to stop new users from doing it frivolously.  My rationale behind this is the new language &amp; usage sites.  I often find myself thinking that it might be helpful, when discussing a regional dialect or something, for the person answering to just pronounce what they're trying to describe in words. I have seen this construction quite often:      Online ads have been around since the dawn of the Web, but only in   recent years have they become the rapturous life dream of Silicon   Valley.   What is the rule there?. When your sentence doesn't start with pronoun + verb, invert them as verb + pronoun?. I know it sounds awkward but is it possible (grammatically correct) to use something similar to:      Online ads have been around since the dawn of the Web, but only in   recent years they have become...   And in any case, does this only work with have (or has)? Maybe it works fine with 'had' but I can't think of an example right now. A characterisation of quadratic extensions contained in cyclic extensions of degree 4 Let $D$ be a squarefree integer. I am trying to prove that $\mathbb Q[\sqrt D]$ is contained in a Galois extension of $\mathbb Q$ with Galois group $\mathbb Z/4$ if and only if $D$ is the sum of two squares, $D = a^2 + b^2$ with $a,b\in \mathbb Q$.   The hint in the exercise in Dummit and Foote suggests considering the extension $\mathbb Q[\sqrt{s + s\sqrt D}]$ for the forward direction. However, I am unsure how to show that this extension is Galois, much less that its Galois group is cyclic of order 4.   For the reverse direction, I expressed the given Galois extension as $\mathbb Q[\sqrt{a+b\sqrt D}]$ for some $a,b\in \mathbb Q$. I showed that this extension has $\mathbb Q[\sqrt{c^2 - d^2 D}]$ as a subfield for some $c,d \in \mathbb Q$. From this, I deduced that the $\sqrt D$ and $\sqrt{c^2 - d^2 D}$ generate the same extension, so $\sqrt D = x \sqrt{c^2 - d^2 D}$ for some $x$, and hence that $D = \frac{x^2 c^2}{1 + x^2 d^2} $. It seems that there should be a way to decompose this as a sum of two squares, but I did not see how.   I did not tag this as homework as I am studying it independently. I hope somebody has already figured this one out. I just installed Geoserver 2.9 on a vanilla Ubuntu 16.04 distro. The Geoserver 2.8 method of enabling CORS with the shanbe.hezoun class does no longer work with Jetty 9.2.13.  There are mentions that CORS support is already packaged with Jetty 9.2.13 in the jetty-servlets.jar.  The Jetty lib which is compiled with Geoserver contains a jetty-servlet-9.2.13.v20150730.jar in geoserver/lib but not jetty-servlets.9.2.13.v20150730.jar. Are these supposed to be the same jar with a different name?  It should be possible to enable CORS either in geoserver/etc/webdefault.xml or in geoserver/webapps/geoserver/WEB-INF/web.xml.  My understanding is that the webdefault.xml is applied first and the web.xml thereafter.  I have tried following filter in both xml. I haven't got as far as adding a filter mapping. Adding the filter alone will cause the Geoserver/Jetty service to not start proper.  &lt;filter&gt;     &lt;filter-name&gt;cross-origin&lt;/filter-name&gt;     &lt;filter-class&gt;org.eclipse.jetty.servlets.CrossOriginFilter&lt;/filter-class&gt; &lt;/filter&gt; OpenLayers and OSGB 1936 (CRS 27700) I've been working with loads of shapefiles projected according to OSGB 1936 (CRS 27700). The project CRS is set to EPSG:27700 and "On the fly reprojection" to EPSG:27700 is set (I keep this as a default as I work with OSGB 1936 95% of my time).  I decided to download OSM layers from the OpenLayers plugin. When I load this, the EPSG in the bottom right of the screen goes from EPSG:27700 to EPSG:3857   Question 1: should this be happening anyway as it would suggest that the whole project has been re-projected to EPSG:3857?   As soon as the OSM layer is loaded it's way out of alignment but a quick pan seems to bring it altogether quiet nicely.   What I have noted is that (Question 2), if I try to re-specify the CRS to 27700, then the shapefiles "move" by a few tens of meters with respect to the OSM. Does this suggest that QGIS is doing a second re-projection (from what to what?)?   Also (Question 3), does it mean that if I import another shapefile that would be originally a dataset digitised with EPSG:27700 it would be re-projected to EPSG:3857 because the CRS in the bottom right of the screen was set to EPSG:3857 after the OSM import. This is all a bit confusing and logic would suggest that the import of a non-ESPG:27700 (project default CRS) should not go and change the EPSG setting in the bottom right of the screen. Anita Graser's book says on page 34 "Your project CRS will automatically be changed to Pseudo Mercator when you load a background map using the OpenLayers plugin option".   Does that mean there is no way of keeping ESPG:27700 active in the project when importing basemaps from OpenLayers? If so, what alternatives are there?  What I am trying to bottom out is to understand the correct way of importing basemaps (usually Google, Bing or OSM through the OpenLayers plugin) into my projects (always EPSG:27700) without losing alignment and getting layers to correctly re-project. I'm trying to support greater use of QGIS in my company but don't want to lose credibility by promoting the use of a tool that is misaligning datasets. Don't get me wrong. QGIS is a great tool and I am very fond of it but importing layers with different CRS's is quite common these days and getting this right from the start is half the job done.  I did quite an extensive Google search before posting and didn't come up with a recent, clear cut answer to my questions above. There is a bit of content out there on problems with older versions of QGIS, PROJ4, etc. but nothing recent for QGIS 2.0 so worth an update. How to interpret autocorrelation plot in MCMC I am getting familiar with Bayesian statistics by reading the book Doing Bayesian Data Analysis, by John K. Kruschke also known as the "puppy book". In chapter 9, hierarchical models are introduced with this simple example: \begin{align} y_{ji}   &amp;\sim {\rm Bernoulli}(\theta_j)  \\ \theta_j &amp;\sim {\rm Beta}(\mu\kappa, (1-\mu)\kappa)  \\ \mu      &amp;\sim {\rm Beta}(A_\mu, B_\mu)   \\ \kappa   &amp;\sim {\rm Gamma}(S_\kappa, R_\kappa) \end{align} and the Bernoulli observations are 3 coins, each 10 flips. One shows 9 heads, the other 5 heads and the other 1 head.  I have used pymc to infer the hyperparamteres.  with pm.Model() as model: # define the          mu = pm.Beta('mu', 2, 2)     kappa = pm.Gamma('kappa', 1, 0.1)     # define the prior     theta = pm.Beta('theta', mu * kappa, (1 - mu) * kappa, shape=len(N))     # define the likelihood     y = pm.Bernoulli('y', p=theta[coin], observed=y)      # Generate a MCMC chain     step = pm.Metropolis()     trace = pm.sample(5000, step, progressbar=True)     trace = pm.sample(5000, step, progressbar=True)   burnin = 2000  # posterior samples to discard thin = 10  # thinning  pm.autocorrplot(trace[burnin::thin], vars =[mu, kappa])   My question is regarding the autocorrelation. How shall I interpret autocorrelation? Could you please help me to interpret the autocorrelation plot?    It says as the samples gets further from each other the correlation between them reduces. right? Can we use this to plot to find the optimum thinning? Does the thinning affect the posterior samples? after all, what is the use of this plot? Why doesn't backpropagation work when you initialize the weights the same value? Why doesn't backpropagation work when you initialize all the weight the same value (say 0.5), but works fine when given random numbers?   Shouldn't the algorithm calculate the error and work from there, despite the fact that the weights are initially the same? Is it logically correct to assert that the expectation of the momentum $$\langle \hat p \rangle=0$$ for any bound state because it is bound to some finite region? What is the physical interpretation of the fact that $$\langle \hat p \rangle=0$$ in an energy eigenstate $\psi_n(x,t)$  but $$\langle \hat p \rangle\neq0$$ in some superposition state $$\psi(x,t)=c_m\psi_m(x,t)+c_n\psi_n(x,t)~?$$ Here $\psi_n(x,t)$ the eigenstates of the Hamiltonian, for example, in the problem of particle in a box (say). Conditional Expectation of Bernoulli R.V. Let $X_1, X_2,\ldots, X_n$ be iid bernoulli r.v. with parameter $p$. Let $S=X_1+\cdots+X_n$ and $Y=X_1X_2$. Compute $\mathbb{E}(Y\mid S)$.  I know that $\mathbb{E}(X_1\mid S) = S/n$. So If I could split $\mathbb{E}(Y\mid S)$ into two then I would be done. But I don't think that is allowed. How to proceed? Select an area in rep graph not working on Chrome The "select an area by dragging across the lower chart" thing is not working on Chrome.  Tested with Chrome 13.0.782.220 m, works with Firefox 6.0.1 and IE 8  Quirk: For some reason, if I open an incognito window, it works. Tried clearing the cache and cookies, still not working. We know the escape velocity from the Earth is 11.2km/s. Isn't it the velocity required to escape from earth if we go normal to the surface of earth? i.e while we derive the formula for the escape velocity from earth we never consider the slanted motion of the object. So when we launch a rocket we need to use very less value of velocity compare to escape velocity to escape from earth because rocket follows a slanted path so curvature of earth has an effect?  If what I said above is right, then how we can say escape velocity is 11.2 km/s? What is the most efficient way to deep clone an object in JavaScript?