$(p-2)!-1 \neq p^k$ for any $k\in \mathbb{N}$, $p$ is a prime.

Question: $(p-2)!-1 \neq p^k$ for any $k\in \mathbb{N}$, $p>5$, $p$ is a prime.
How to solve this?
Comment: If this is from an analytic number theory course, please tag it as such. calculus is not the tag. Also I changed number-theory to elementary-number-theory. Feel free to change it back, if it is an advanced course.
Answer: If $p > 5$ is prime, then  at least one of the following is true:

$p-1$ is divisible by $q = 4 \le p-2$.
$p-1$ is divisible by an odd prime $q \le p-2$.

In either case, we have $(p-2)! \equiv 0 \mod q$ as well as $p \equiv 1 \mod q$.
This implies that
$$0 \equiv (p-2)! = p^k + 1 \equiv 1^k + 1 \equiv 1 + 1 \equiv 2 \mod q,$$
which is a contradiction.
Comment: Nice one here ! What's with this name though ? ...
Answer: I removed my previous answer because there was a mistake in it and it made it become useless, but still I guess you could try it by assuming the "opposite" of your proposition:
$$\exists k\in\Bbb{N},\space (p-2)!-1=p^k$$
If you arrive at something impossible, this will mean the beginning assumption was wrong.
Thus you get your result (which is the opposite of your (wrong) assumption):
$$\forall k\in\Bbb{N},\space (p-2)!-1\neq p^k$$ (for prime $p>5$)
This comes from the fact that if proposition $\urcorner A$ leads to something wrong using valid reasoning, then $\urcorner A$ is itself wrong and thus $A$ is true.
Comment: I believe you have erred in multiplying by $p(p-1)$.  It seems you forgot to distribute it through to the $-1$ as well.
Comment: @FrankMcGovern Oh yes, cr** ...
Comment: I think that's the right way to go about it, though.
Comment: @FrankMcGovern Still works ovrall though, I'm going to change this (and the summation is not necessary either ... poor proof :))
Comment: @FrankMcGovern No it doesn't work anymore: it's now an odd number equal to another odd number ... too bad, liked this proof :(


How would I move a standalone Ubuntu Server to an virtual server (ESXi)

Question: I need to move an ubuntu server to a virtual server and everything on it with users, etc. The most logical way would be to move the entire HDD to an virtual disk on VMWare ESXi but how would I do that? Exporting all data, all userdata, configurations, etc seems like an unnecessary hassle. Could anyone guide me in the right direction?
Answer: You need the VMWare Converter Standalone (i.e. free) version.
Comment: Seems like what I'm looking for, I'm going to have to test that out. Thanks for the help so far.
Comment: I've tried to use VMWare Converter Standalone using this guide: http://www.vladan.fr/how-to-p2v-linux-into-vmware-esx-server/ but I'm stuck at step 10, first it complains about a certificate then I've tried both installing and ignoring the certificate but I just get a connection error and can't proceed. Any suggestions?
Comment: Ignoring is the right option, are you sure you've put in the right IP for the host and the local root account and password? I'm no expert at this sorry as I have the 'full' licenced version - perhaps someone else will be able to help.
Comment: Yes I'm sure it's the right IP, I get some sort of connection error. It's probably RICOH who've blocked the traffic even tho they say that they've allowed it on the network, problem is I can't have any downtime on the server so I can't take it out of the network temporarily, hopefully it will be fixed next week, otherwise I'll have to try to fix it somehow.


.htaccess doesn't rewrite /something to index.php?menu=something. It shows something.htm instead

Question: I want my site to treat URI as part of a query string.
When accessing properly with sub.domain.cz/something it works okay.
If I don't use neither www nor sub, it rewrites URL and works.
But when I use www, it rewrites www.domain.cz to sub.domain.cz, but it shows sub.domain.cz/something.htm instead of threating 'something' like parameter.
I thought there is the problem with multiple use, but adding Options -MultiViews didn't change anything (and removing !-f makes it lose connection to styles).
RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.cz$ [NC]
RewriteRule ^(.*)$ http://sub.domain.cz/$1 [L,R=301]

RewriteBase /

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=style.css
RewriteRule ^(.*)$ index.php?menu=$1 [L,QSA]

I'm not any expert. Mostly I'm just trying a bunch of stuff I find on Internet and simultaneously trying to understand them for future use. But now I have no idea of what's wrong. I've tried changing order and flags. Maybe all of that changed something but it was not visible to me. Do you have any nice idea, please?
Answer: RewriteEngine on

RewriteCond %{HTTP_HOST} ^(www\.)?domain\.cz$ [NC]
RewriteRule ^(.*)$ http://sub.domain.cz/$1 [L,R=301]

RewriteBase /something/

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteCond %{REQUEST_URI} !=style.css
RewriteRule ^(.*)$ index.php?menu=$1 [L,QSA]

Comment: Now I'm wondering if my English is that bad and I couldn't tell what I really want or that solution is not sutable for me. There is a bunch of stuff that can be placed after sub.domain.cz like intro/price/about-us/offer, so 'something' isn't the only parameter I'm having troubles with. And I can't make RewriteBase for everyone of them (or can I?).
I may be a rookie, but how is that supposed to help the problem exactly? I don't have a folder /something/, so there are no rules for it need.


Como atribuir uma class css nos formulários do django

Question: Fala galera, tudo bem?
Então a bucha de hoje é a seguinte, desejo adicionar por padrão um css nos meu formulários gerados no django, dei uma pesquisada achei algumas coisas mas nada resolvia o meu "problema".
Queria saber se tem alguma forma de adicionar uma class css?
Segue a baixo meu código atual do form.py e minha models.py respectivativamente
#form.py

from django.forms import ModelForm
from .models import Transacao

class TransacaoForm(ModelForm):
  class Meta:
    model = Transacao
    fields = ['dt_transaco','descricao','valor','categoria','observacoes']

#models.py
class Transacao(models.Model):
    dt_transaco = models.DateTimeField()
    descricao = models.CharField(max_length=300)
    valor = models.DecimalField(max_digits=7,decimal_places=2)
    categoria = models.ForeignKey(Categoria, on_delete=models.CASCADE)
    observacoes = models.TextField(null=True, blank=True)

    class Meta:
       verbose_name_plural = 'Transações'

Answer: Bom, você não colocou nenhum código de seus templates aí - se quer uma classe CSS no form de HTML, é nos templates que precisa por, manualmente - as classes do django.forms até tem métodos de renderização para HTML, mas a tag Form vem sempre no template - os objetos em Python são renderizados para os textos, ajuda, e widgets que vão dentro do form.
Já se quiser adicionar atributos class customizados nos controles (widgets) gerados por Django form, aí é outra conversa -
Você pode associar classes de html a cada controle de um form passando o parâmetro attrs ao criar o campo - a documentação está aqui:
https://docs.djangoproject.com/en/2.2/ref/forms/widgets/#styling-widget-instances

Claro que, como nesse caso, você está usando um modelform, isso implicaria em que você teria que declarar os fields manualmente na classe que herda de ModelForm, para passar o parâmetro attrs  para o widget.
Se quiser manter tudo automático e alterar só o attrs, dá pra fazer isso logo depois de declarar a classe, e manipular o obejto Field manualmente - a criaçao de classes de form do Django tem uma customização que faz com que sejam diferentes de classes normais de Python  - os Fields  de uma classe  django.forms.Form ficam em dicionários dentro da classe, e não direto como atributos da classe - todos são listados dentro de um dicionário chamado base_fields. Num objeto do tipo Field, você pode acessar diretamente o atributo widget e customizar o atributo attrs do mesmo (que é um dicionário Python)- esses  attrs serão renderizados para html:
class TransacaoForm(ModelForm):
  class Meta:
    model = Transacao
    fields = ['dt_transaco','descricao','valor','categoria','observacoes']

field_descricao = TransacaoForm.base_fields["descricao"]
descricao.widget.attrs["class"] = "minha_classe_CSS"]

E pronto, ao usar um dos métodos para renderizar esse formulário, o campo
"descricao" vai ver com `class="minha_classe_CSS" em seu elemento Input.
Se quiser mudar a classe do Label e HTML do que vem em volta do Input também, nesse caso, vai ter que criar sua própria classe de widget, e customizar tudo.
Comment: Valeu cara realmente funcionou!


Measures of residuals heteroscedasticity

Question: This wikipedia link lists a number of techniques to detect OLS residuals heteroscedasticity. I would like to learn which hands-on technique is more efficient in detecting regions affected by heteroscedasticity.
For example, here the central region in the OLS 'Residuals vs Fitted' plot seen to have higher variance than the sides of the plot (I am not entirely sure in facts, but let's assume it's the case for the sake of the question). To confirm, looking at the error labels in the QQ plot we can see that they match the error labels in the center of the Residuals plot.
But how can we quantify the residuals region that has significantly higher variance?

Comment: I'm not sure you're right that there is higher variance in the middle.  The fact that the outliers are in the central region looks to me likely to be a result of the fact that that is where most of the data is.  Of course, this doesn't invalidate your question.
Comment: The qqplot is intended to identify nonnormality of the distribution and not inhomogeneous variances directly.
Comment: @PeterEllis Yes, I specified in the question that I'm not sure the variance is different, but I had this diagnostics picture handy and there might actually be some heteroscedasticity in the example.
Comment: @MichaelChernick I only mentioned the qqplot to illustrate how the highest errors seem to concentrate in the middle of the residuals plot, hence potentially indicating higher variance in that area.
Answer: This problem has an exploratory feel to it.  John Tukey describes many procedures for exploring heteroscedasticity in his classic, Exploratory Data Analysis (Addison-Wesley 1977).  Perhaps the most directly useful is a variant of his "wandering schematic plot."  This slices one variable (such as the predicted value) into bins and uses m-letter summaries (generalizations of boxplots) to show the location, spread, and shape of the other variable for each bin.  The m-letter statistics are further smoothed in order to emphasize overall patterns rather than chance deviations.
A quick version can be cooked up by exploiting the boxplot procedure in R.  We illustrate with simulated strongly heteroscedastic data:
    set.seed(17)
    n <- 500
    x <- rgamma(n, shape=6, scale=1/2)
    e <- rnorm(length(x), sd=abs(sin(x)))
    y <- x + e

Let's obtain the predicted values and residuals from the OLS regression:
    fit <- lm(y ~ x)
    res <- residuals(fit)
    pred <- predict(fit)

Here, then, is the wandering schematic plot using equal-count bins for the predicted values.  I use lowess for a quick-and-dirty smooth.
    n.bins <- 17
    bins <- cut(pred, quantile(pred,
                      probs = seq(0, 1, 1/n.bins)))
    b <- boxplot(res ~ bins, boxwex=1/2,
                 main="Residuals vs. Predicted",
                 xlab="Predicted", ylab="Residual")
    colors <- hsv(seq(2/6, 1, 1/6))
    temp <- sapply(1:5, function(i) lines(lowess(1:n.bins,
                         b$stats[i,], f=.25),
            col=colors[i], lwd=2))

The blue curve smooths the medians.  Its horizontal tendency indicates the regression is generally a good fit.  The other curves smooth the box ends (quartiles) and fences (which are typically extreme values).  Their strong convergence and subsequent separation testify to the heteroscedasticity--and help us characterize and quantify it.
(Notice the nonlinear scale on the horizontal axis, reflecting the distribution of predicted values.  With a bit more work this axis could be linearized, which sometimes is useful.)
Comment: Nice example, I would have thought some implementation of running quantiles was available in R (to avoid the problem with bins alltogether). Kind of reminds me of [bag-plots](http://rgm2.lab.nig.ac.jp/RGM2/func.php?rd_id=aplpack:bagplot). Also see Rob Hyndman's [extension](http://robjhyndman.com/papers/Rainbow5.pdf) in his Rainbow package.
Answer: Typically, heteroskedasticity is modeled using a Breusch-Pagan approach. The residuals from your linear regression are then squared and regressed onto the variables in your original linear model. The latter regression is called an auxiliary regression.
$nR^2_a$, where $n$ is the number of observations and $R^2_a$ is the $R^2$ from the auxiliary regression serves as a test statistic for the null hypothesis of homoskedasticity.
For your purposes, you could focus on the individual coefficients from this model to see which variables are most predictive of high or low variance outcomes.
Comment: +1 But please notice that such tests are limited in the forms of heteroscedasticity they can detect.  Examples like the one shown in my answer can slip right through, even though the heteroscedasticity is extremely strong.


Como fechar uma session em PHP

Question: Estou tendo problema ao tentar destruir as sessões, tentei o código abaixo, existe alguma forma além dessa?
<?php
    session_start();
    session_destroy();
    header('Location: index.php');
?>

O que ocorre é que as váriaveis de sessão não são destruídas, dessa forma conseguindo resgatar os valores contidos nela.
Comment: O que você entende por "finalizar sessões"?
Comment: Estou tentando fazer que o usuário realize o "logoff"
Comment: Já leu a [documentação da função `session_destroy()`](http://php.net/manual/pt_BR/function.session-destroy.php)?
Comment: Infelizmente não sei o que houve de errado. Quando eu faço o Logoff ele realiza o redirecionamento para a página "Index.php" mas quando eu forço o acesso para uma outra página como "Home.php", Ele entra na página normalmente como se eu estivesse logado.

Esse é o meu código para "logoff"
Comment: A pergunta ficou mais clara?
Comment: Não, qual foi o "problema" que está tendo?
Comment: A pergunta já foi respondida, estou tentando deixa-lá mais clara com os padrões do site. vou edita-lá novamente.
Answer: Para encerrar sessão você deve usar isso em seu código PHP.
session_destroy();

Caso queira criar uma sessão pode fazer dessa forma em seu codigo PHP:
session_start();

$_SESSION['usuario'] = "User1";

Caso queira obter algum valor da sessão em seu codigo PHP:
echo $_SESSION['usuario'];

Comment: Quando eu faço o Logoff ele realiza o redirecionamento para a página "Index.php" mas quando eu forço o acesso para uma outra página como "Home.php", Ele entra na página normalmente como se eu estivesse logado.

Esse é o meu código para "logoff"
Comment: Tente fazer algumas alterações: vou colar como resposta.
Answer: Faça a seguinte alteração em Home.php na primeira linha de código:
<?php
    session_start();
    /* Aqui você está verificando se a sessão está setada,
     * quando ele fizer logoff, seu session_destroy fará com que ele não entre na página
     */
    if(!isset($_SESSION['logged_in'])){
        header('Location: index.php');
    }
?>

Então, modifique o login também. Adicione este código se o login foi feito com sucesso:
...
$_SESSION['logged_in'] = true;
...

Answer: Tente fazer umas alterações:
Na tua pagina "App Help Desk" retire o trecho:
session_destroy();

header('Location: index.php');

Crie uma uma página com o nome:
logoff.php
e cole o código abaixo em logoff.php
session_destroy();

header('Location: index.php');

Como fechar uma session em PHP


Separating a CSV file contents into an array

Question: My CSV file is formatted like this
Object,Value,Attribute
Object,Value,Attribute
Object,Value,Attribute

etc.
Would I need 3 separate arrays? (I think that's the best way of doing this..) One for object which I can then feed into my chart.. one for value and the attribute. I don't know much about arrays yet.
Answer: You should create your own class that holds Object, Value and Attribute and store this in a list.
class SomeClass {
 public string MyObject { get; set; }
 public string MyValue { get; set; }
 public string MyAttribute { get; set; }
}

private List<SomeClass> myList = new List<SomeClass>();

public void ReadCsv(){
 using (var sr = new StreamReader("PathToCsvFile")) {
  string currentLine;

  while ((currentLine = sr.ReadLine()) != null) {
   var elements = currentLine.Split(',');

   myList.add(new SomeClass {
    MyObject = elements[0],
    MyValue = elements[1],
    MyAttribute = elements[2]
   });
  }
 }
}

Comment: String.Split may not be the best answer; won't work so well if any of the columns contain a comma that is not a delimiter.
Comment: A comma as part of a value will always be a tricky situation in CSV files and should indeed be treated appropriately. That's beyond the scope of this question though. You've already provided a good link for that so OP should look there if he encounters this issue.
Answer: I'd recommend one array of a class that holds object, value, and attribute, because then you don't need to worry about the complications of missing data, and changing all your arrays if you add more columns.
Answer: What you do with the fields depends on how you're going to use the data.  You probably need an array of structs or objects, where each element in the array is a row and each member of the object/struct is a column.
Here's a very simple example of a struct, where you can hold your data:
struct MyStruct
{
    string Column1;
    string Column2;
    //etc
}

And here's some code to populate it from the file:
List<MyStruct> rows = new List<MyStruct>;

s = reader.ReadLine();
while (s != null)
{
    string s[] columns = SplitLine(s);
    MyStruct row = new MyStruct();
    row.Column1 = s[0];
    row.Column2 = s[1];
    rows.Add(row);
    s = reader.ReadLine();
}

Notice the ambiguous function "SplitLine."  Lots of ways to split a string up .  Look here for the best ways to split the string into fields.
Answer: It really depends on what you want to do with the data. It seems you want to chart the data per category. If that is the case then the simplest way is to put each col in the same list.
1) read the csv file, per line
2) split the line based on comma
3) put data (in the same column) to the same list


If $\hat{A}$ commutes with $\hat{r}^2$, does $\hat{A}$ commute with $\hat{r}$?

Question: Let $\hat{x}, \hat{y}, \hat{z}$ be the position operators in 3D space and $\hat{r}^2=\hat{x}^2+\hat{y}^2+\hat{z}^2$ as usual.
If one operator $\hat{A}$, commutes with $\hat{r}^2$, i.e.
$$\Big[\hat{A}, \hat{r}^2\Big] = 0$$
Does this imply that it also commutes with $\hat{r}$, $[\hat{A}, \hat{r}]=0$.
If the answer is no in general, what happens if we restrict $\hat{A}$ to some combination of $\hat{r}$ and $\hat{p}$ operators (with $\big[\hat{r}_i, \hat{p}_j\big] = i\delta_{ij}$)?
Before this comes up as a comment, I know that in general $\Big[\hat{A},\hat{B}^2\Big]=0$ does not imply $[\hat{A},\hat{B}]=0$, but I wonder if there is some property of the position operator to allow this.
The origin of my question is because in Quantum Physics sometimes one uses the argument that an operator (for example $\hat{L}$) commutes with $\hat{r}^2$, to justify that this operator commutes with any operator $V(\hat{r})$ in the Hamiltonian (for example, the Coulomb potential). And I want to know if this is really a good argument.
Thank you
Comment: Is $\hat r$ a unit vector? Because they have norm 1 which means $\hat r^2 = 1 \neq \hat x^2 + \hat y^2 + \hat z^2$. I think your confusion comes from using $r$ interchangeably from a variety of contexts.
Comment: No, $\hat{r}$ is the radial position operator. The one that acts as $\hat{r}\psi(x,y,z) = r\psi(x,y,z)$.
Comment: The radial position vector should be denoted $\vec{r}$ to prevent this confusion, but in any case its mapping $\psi$ to $r\psi$ makes no sense if $r$ is a scalar, so you may need to clarify that symbol too.
Comment: No, I don't mean a vector. Why the mapping $\psi \to r\psi$ is meaningless? It is the same as the $\hat{x}$ operator, but instead of the mapping $\psi \to x\psi$ we define the radial operator by $\psi \to r\psi$, I don't see why this doesn't make sense. $\psi(x,y,z)$ is the usual wave function. It is a scalar map, that given a position $(x,y,z)$, returns a complex number, which can be multiplied by $r=\sqrt{x^2+y^2+z^2}$.
Comment: @Gaussian97 The other users don't get notified if you don't start with @...
Comment: @J.G. Sorry, I did not mention you in my previous response. Thanks Filippo for the advice.
Comment: What I said was it doesn't make sense that a vector operator would scale by a scalar. ("Radial position" sounds like a vector to me.) Did you actually mean to say your operator quantizes the scalar-valued radius?
Comment: @J.G. Sorry for the confusion, I indeed meant my operator to multiply the wave function by a scalar. Probably "radial distance operator" might have been a better name.
Comment: With a non-central potential, angular momentum isn't classically conserved so $\hat{L}^2$ isn't a good quantum number, so isn't simultaneously diagonalizable with the Hamiltonian. By contrast, a central potential is a function of $r^2$.
Comment: @J.G. Why does a central potential need to be a function of $r^2$? The Coulomb potential is a function of $r$. Of course, you can say that $r$ is a function of $r^2$. But still, I don't see why commuting with $r^2$ implies commutation with $r$.
Comment: Any function of $r^2$ is a function of $r$ because $r\ge0\implies r=\sqrt{r^2}$.
Answer: The point is that $\hat r$ is a positive operator and hence one has that $\hat r=\sqrt{\hat r^2}$.
Therefore, any operator commuting with $\hat r^2$ will also commute with $\hat r$.
The situation is entirely different with respect to a general self-adjoint operator, e.g. any $2\times 2$ matrix commutes with the square of $$A=\pmatrix{1&0\cr0&-1},$$
a.k.a. the identity matrix, but of course not all matrices commute with $A$!

EDIT:  Upon request let us show that, given two unbounded self-adjoint operators $A$ and $B$, if $B$ is positive and $A$
commutes with $B^2$, then $A$ also commutes with $B$.
First of all, recall that two unbounded self-adjoint operators $A$ and $B$ are said to "strongly commute" if all the projections in their associated projection-valued measures commute.  This is equivalent to saying that $e^{itA}$ commutes with
$e^{isB}$, for all $s, t\in {\mathbb R}$.
By contrast, simply saying that $[A, B]=0$ on the common domain is not a very useful condition and, in particular, this doesn't imply that $e^{iA}$ commutes with $e^{iB}$.
See the book by Reed and Simon, "Methods of mathematical physics" vol.1, chapter 8,  for a counter-example.
I am therefore referring to strong commutativity throughout.
This said, if $A$ and $B$ are self-adjoint operators, $B$ is positive (my term for positive semi-definite), and $A$
commutes (strongly of course) with $B^2$, then yes, it is true that $A$ commutes with $B$.
To prove it, denote the spectra of $B$ and $B^2$, respectively by $\Sigma _1$ and    $\Sigma _2$, and
consider the projection-valued measures
$P_1$ and $P_2$ for $B$ and $B^2$, respectively.
Thus $P_1$
(resp. $P_2$)
is defined on the Borel $\sigma $-algebra of  $\Sigma _1$
(resp. $\Sigma _2$), and
$$
B=\int _{\Sigma _1}\lambda \,dP_1(\lambda )$$$$
\Big (\text {resp}, \ B^2=\int _{\Sigma _2}\lambda \,dP_2 (\lambda )\Big ).
$$
Considering the "square" function
$$
  s:\lambda \in \Sigma _1\mapsto \lambda ^2\in \Sigma _2=\Sigma _1^2,
  $$
let $Q=s_*(P_1)$ be the push-forward measure of $P_1$ under $s$, namely  the projection-valued measure defined on $\Sigma _2$ by
$$
  Q(E) = P_1(s^{-1}(E)),
  $$
for every Borel subset $E\subseteq \Sigma _2$.  We then have that
$$
  \int _{\Sigma _2}\lambda \,dQ(\lambda ) =   \int _{\Sigma _2}\lambda \,ds_*(P_1)(\lambda ) =   \int _{\Sigma _1}s(\lambda )\,dP_1(\lambda ) = $$$$=
  \int _{\Sigma _1}\lambda ^2\,dP_1(\lambda ) =   \Big (\int _{\Sigma _1}\lambda \,dP_1(\lambda )\Big )^2 = B^2 = \int _{\Sigma _2}\lambda \,dP_2 (\lambda ).
  $$
By the uniqueness of the spectral decomposition we have that $Q=P_2$, meaning that
$$
  P_2(E) = P_1(s^{-1}(E)), \qquad (*)
  $$
for every Borel subset $E\subseteq \Sigma _2$.
The key hypothesis that $B$ is positive implies that $\Sigma _1\subseteq {\mathbb R}_+$, and hence that $s$ is a bijective function from $\Sigma _1$ to
$\Sigma _2$.  Plugging $E=s(F)$ in $(*)$, where $F$ is any Borel subset of $\Sigma _1$, we get
$$
  P_2(F^2) = P_1(F).
  $$
This says that all spectral projections for  $B$ (namely the $P_1(F)$) are found among the spectral projections of $B^2$.  Consequently, if a
spectral projection of $A$ commutes with all spectral projections of $B^2$, then it obviously commutes with all spectral
projections of $B$.
Comment: thank you. So is it true that $[A,B^2]=0 \Longrightarrow [A,B]=0$ if $B$ is positive semi-definite? Could you please point me to a proof of this fact? Thank you :D
Comment: The answer is a bit long, so I included it in the main answer  above.
Comment: Thank you, I didn't understand all the details, but I think I understand the main ideas :D
Comment: @Gaussian97.  Feel free to ask for clarifications and I'll be happy to answer if I can!


Wicket 1.5 - page serialization - how it works?

Question: My application is filling up disk space with serialized pages. The are not being cleaned up at all - not even after session expiration.
I order to find out the reason for it I need to understand how the serialization is working.
1) Does Wicket have hooks on HTTP Session which clan up page history when Session is terminated or times out?
2) What are the configuration options for page history?
3) Is is possible to configure page serialization to use HTTP Session and not temp dir?
4) Is is possible to configure page serialization to use in memory cache?
Answer: OK.... so I've checked the code
1) yes
2) only folder path (javax.servlet.context.tempdir) can be configured over properties. DiskDataStore can be used to configure few additional things pragmatically: limit serialization size (default is 10 mb) and in memory page cache size.
3) yes - by registering HttpSessionDataStore
4) partly - it's possible to increment StoreSettings#inmemoryCacheSize, when it's full, wicket will start serialization to file - this makes sense.
Comment: Did you ever find out why the sessions were not being cleaned up, even after session expiration?
Comment: no, not yet, currently we have corn job that removes old folders.


What is the intuition behind Euler's proof of the value of the Riemann Zeta Function at 2?

Question: I just read the idea of Euler's proof that $\zeta(2) = \frac{\pi^2}{6}$. He studied the Taylor series of the function $\frac{\sin \pi x}{x}$.
Does someone know if he by chance was studying this function and found the connection with the Riemann Zeta Function? Or did he have some intuition that this was the right function to work with?
Comment: The "intuition" is that $f(z)=\frac{\pi^2}{\sin^2(\pi z)}-\frac1{z^2} = \sum_{n\ne 0} \frac1{(z-n)^2}$  so that $f^{(2k)}(0)=(2k+2)!\zeta(2k+2)$
Comment: @reuns, it is my (naive) impression that this idea came only some decades later, after Euler's epiphany that maybe $\sin(x)$ had an infinite-product expansion... Is there tangible evidence that Euler had contemplated the partial fraction expansion instead? I'd be interested to hear...
Comment: @paulgarrett Isn't his late rigorous proof equivalent to the partial fraction of $\tan(x)$ ?
Comment: @reuns, yes, I have that impression, but/and the earlier epiphany has always struck me as an exemplar of inspiration and methodological optimism. My other example is (perhaps "of course") Riemann's paper on zeta, which I've come to appreciate as astonishingly "courageous", methodologically... I do think that earlier inspirations deserve notice... apart from later justifications. Of course I do like proofs, but especially of provocative things. :)
Comment: I believe this is covered in Mathologer's video on ["Euler's crazy pi formula generator"](https://www.youtube.com/watch?v=WL_Yzbo1ha4&ab_channel=Mathologer)
Comment: If you know the roots of a polynomial, you can immediately factor the polynomial. It is a typical Eulerian leap to think of $\sin(x)$ as an "infinite degree polynomial" for which we know the roots, and to write down the factorization. What a wonderful idea.
Answer: Obligatory "not a full answer, but too long for comments". That being said, this will get you 90% of the way there.
As mentioned in my comment, the idea of the proof is essentially covered in Mathologer's video on "Euler's crazy pi formula generator". The difference is we start by looking at Euler's product formula for $\sin x$, which can be manipulated or derived to/from many other series', such as a Taylor series for $\sin(\frac{\pi x}{x})$.
$$\sin x = x\left(1-\frac{x}{\pi}\right)\left(1+\frac{x}{\pi}\right)\left(1-\frac{x}{2\pi}\right)\left(1+\frac{x}{2\pi}\right)\left(1-\frac{x}{3\pi}\right)(\dots)$$
This is the foundation for exploring it's relationship to the zeta function. We begin by looking at pairs of terms, and notice they can be simplified as they bare the of the form of the difference of two squares:
$$\sin x = x\left(1-\frac{x^2}{\pi^2}\right)\left(1-\frac{x^2}{(2\pi)^2}\right)\left(1-\frac{x^2}{(3\pi)^2}\right)(\dots)$$
The next step is a bit tricky, and I must admit I don't entirely grasp it (again, better described by Mathologer). The gist of it is that we now essentially get clever with our choices in expanding and grouping specific terms, which yields:
$$\sin x = x+\left(-\frac{1}{\pi^2}-\frac{1}{(2\pi)^2}-\frac{1}{(3\pi)^2}-\dots\right)x^3+(\dots)x^5+(\dots)$$
Now, after differentiating thrice, we're left with a series preceded by a very useful $\color{red}{\text{constant}}$.
$$-\cos x = \color{red}{\left(-\frac{1}{\pi^2}-\frac{1}{(2\pi)^2}-\frac{1}{(3\pi)^2}-\dots\right)6}+(\dots)60x^2+(\dots)$$
Evaluating this at $x=0$ gets rid of all the terms proceeding the constant.
$$\cos 0 =1= \left(\frac{1}{\pi^2}+\frac{1}{(2\pi)^2}+\frac{1}{(3\pi)^2}+\dots\right)6$$
Which can trivially be rearranged to find a formula for $\frac{\pi^2}{6}$, which just-so-happens to be of the same form as $\zeta(2)$.
$$\frac{\pi^2}{6}=\frac{1}{1^2}+\frac{1}{2^2}+\frac{1}{3^2}+\dots=\zeta(2)$$
QED
As for if Euler knew beforehand that this process would result in a zeta-function-like form, is unclear. As with all long term mathematicians, both inexplicable intuition (as with the case of a lot of Euler's work) and stumbling-upon-by-chance is inevitable.
Note: I imagine it to be very difficult to algebraically manipulate these formulas for other values of the zeta function. Hence, I don't believe studying this series for sole the intention of it's general relationship to the zeta function was his intention. Clearly, it's very much related to $\zeta(2)$ and, as I imagine, also consequently related to $\zeta(2k)$ (as those are the values for which $\zeta$ yields multiples of powers of $\pi$).
Comment: Thank you very much for your answer! As I think more and more about it I think that Euler probably started with the product formula and eventually realized that it was related to the zeta function. But as you said, what really happened is unclear.


Entity Framework Core .Net 6.0 many-to-many. Do not understand how this should work

Question: We are currently working on a project where we migrate from NHibernate to the Entity Framework Core with .Net 6.0. I've scaffolded the existing database to create a new Code First model and most of the entities I use are just working fine with some tweaking of the code and model context. Now I've come accross a situation that I just don't fully understand. I've read the documentation on the subject and searched the net for answers but is just iludes me totally. It is about a many-to-many construction that was scaffolded like this in the model context:
        modelBuilder.Entity<PersonToScheduledTimeSlot>(entity =>
        {
            entity.HasNoKey();

            entity.Property(e => e.PersonId)
                .IsRequired()
                .HasColumnName("Person_id")
                .HasMaxLength(255);

            entity.Property(e => e.ScheduledTimeSlotId).HasColumnName("ScheduledTimeSlot_id");

            entity.HasOne(d => d.Person)
                .WithMany()
                .HasForeignKey(d => d.PersonId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKFECEB8CB4EF068");

            entity.HasOne(d => d.ScheduledTimeSlot)
                .WithMany()
                .HasForeignKey(d => d.ScheduledTimeSlotId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKFECEB84E36D0C1");
        });

Below is a description of how the many-to-many should work
                ScheduledTimeSlot <=    PersonToScheduledTimeSlot                => Person
            |                       |                                           |                       |
Database    |   id                  |   Person_id                               |   id                  |
            |                       |   ScheduledTimeSlot_id                    |                       |
            |                       |                                           |                       |
Code        |                       |   PersonId                                |                       |
            |                       |   ScheduledTimeSlotId                     |                       |
            |                       |                                           |                       |
Context     |                       |   HasColumnName("Person_id")              |                       |
            |                       |   HasColumnName("ScheduledTimeSlot_id")   |                       |

I have this LINQ query that should resolve but it does not work.
        var slots = _UnitOfWork.Query<ScheduledTimeSlot>()
            .AsNoTracking() // <= No tracking needed for these entities
            .Include(sts => sts.RecordingRequest)
            .Include(sts => sts.Lecturers)
            .Include(sts => sts.Device)
            .ThenInclude(dev => dev.DeviceLocations)
            .Where(sts => sts.Start.Date == date) // Get only items for today
            .ToList()
            .Where(sts => sts.IsRecordingPermitted);

The problem is with the .Include(sts => sts.Lecturers), If I leave that out the code works but then the IsRecordingPermitted in the last Where clause does not produce expected results for it tests for the count of Lecturers in the query.
The entities involved are these (leaving out non interesting code):
The table to couple the the Person and ScheduledTimeSlot entities:
namespace Wur.WurScheduler.Blazor.Core.Models.Database
{
    public partial class PersonToScheduledTimeSlot
    {
        public int ScheduledTimeSlotId { get; set; }
        public string PersonId { get; set; }

        public virtual Person Person { get; set; }
        public virtual ScheduledTimeSlot ScheduledTimeSlot { get; set; }
    }
}

The Person Entity:
namespace Wur.WurScheduler.Blazor.Core.Models.Database
{
    public partial class Person : EntityWithId
    {
        public ICollection<ScheduledTimeSlot> ScheduledTimeSlots { get; set; }

        .....
    }
}

The ScheduledTimeSlot entity:
namespace Wur.WurScheduler.Blazor.Core.Models.Database
{
    public partial class ScheduledTimeSlot : EntityWithId, IAuditable, IValidatableObject
    {
        public ICollection<Person> Lecturers { get; set; }

        ...
    }
}

I've tried several scenarios with ForeignKey Attributes and Column attribute but something is wrong and I can't put my finger on it. According to the documentation I should be able to do this (changed the .WithMany():
        modelBuilder.Entity<PersonToScheduledTimeSlot>(entity =>
        {
            entity.HasNoKey();

            entity.Property(e => e.PersonId)
                .IsRequired()
                .HasColumnName("Person_id")
                .HasMaxLength(255);

            entity.Property(e => e.ScheduledTimeSlotId).HasColumnName("ScheduledTimeSlot_id");

            entity.HasOne(d => d.Person)
                .WithMany(person => person.ScheduledTimeSlots)
                .HasForeignKey(d => d.PersonId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKFECEB8CB4EF068");

            entity.HasOne(d => d.ScheduledTimeSlot)
                .WithMany(timeslot => timeslot.Lecturers)
                .HasForeignKey(d => d.ScheduledTimeSlotId)
                .OnDelete(DeleteBehavior.ClientSetNull)
                .HasConstraintName("FKFECEB84E36D0C1");
        });

But the compiler complains with the following (removed bloated info):
Error   CS0266  Cannot implicitly convert type 'ICollection<Wur.WurScheduler.Blazor.Core.Models.Database.ScheduledTimeSlot>' to 'IEnumerable<Wur.WurScheduler.Blazor.Core.Models.Database.PersonToScheduledTimeSlot>'.

Error   CS0266  Cannot implicitly convert type 'ICollection<Wur.WurScheduler.Blazor.Core.Models.Database.Person>' to 'IEnumerable<Wur.WurScheduler.Blazor.Core.Models.Database.PersonToScheduledTimeSlot>'.

which to me is not intuitive. I was expecting this to work but for some reason is does not.
Comment: As for EF, you only have two 1:n association. Therefore, both `Person` and `ScheduledTimeSlot` should have collections `public ICollection`.
Comment: Hi @GertArnold Thanks for responding. Can you elaborate? Do I need to add some code to the context to achieve this or is just adding the 2 collections enough?
Comment: I would just replace (not add) the collections.
Comment: See here for more info and other options in the surrounding text. https://learn.microsoft.com/en-us/ef/core/modeling/relationships?tabs=fluent-api%2Cfluent-api-simple-key%2Csimple-key#indirect-many-to-many-relationships
Comment: @GertArnold But that is just exactly where my code fails. If I add the `.WithMany(person => person.ScheduledTimeSlots)` the compiler complain as described in my post and I can not put my finger on the problem with that. I'm missing something here.
Comment: Yes, please read carefully, the collections should be `PersonToScheduledTimeSlots`, not `ScheduledTimeSlots`.
Comment: @GertArnold Ah, but I didn't mention something here. The solution is a work in progress meaning that the 'fase1' still uses NHibernate while 'fase2' uses EF Core 6.0. I cannot change anything in the database right now because it would make 'fase1' fail.
Comment: @GertArnold `Yes, please read carefully, the collections should be PersonToScheduledTimeSlots, not ScheduledTimeSlots` Do you mean that both the `Lecturers` and `ScheduledTimeSlots` should be collections of the type `PersonToScheduledTimeSlot`?
Comment: @GertArnold Just tried it but now a lot of other code fails to compile because it expects a list of Persons and ScheduledTimeSlots instead of a list of PersonToScheduledTimeSlots.
Comment: You *can* have [many to many associations with so-called *skip navigations*](https://learn.microsoft.com/en-us/ef/core/modeling/relationships?tabs=fluent-api%2Cfluent-api-simple-key%2Csimple-key#many-to-many) which would mean you have collections of `ScheduledTimeSlot` and no `PersonToScheduledTimeSlot` class. You can even have both. It's all described in the docs.
Comment: @GertArnold I know, I've read that documentation. I understand the concept of that but somewhere it just doesn't make my mind switch so I can implement it. I'm missing something and I can't grasp it somehow. I have a lot of knowledgeable colleagues that looked into this problem but none of them came up with a solution. It just needs that little push to get it right.
Comment: @GertArnold I'll look into it tomorrow once more. Thanks so far Gert.
Answer: For anyone who want to know how to do this. Here's a description of my solution.
namespace Wur.WurScheduler.Blazor.Core.Models.Database
{
    public partial class Person : EntityWithId
    {
        public ICollection<ScheduledTimeSlot> ScheduledTimeSlots { get; set; }
        // Define a list to the couple table on your entity.
        public List<PersonToScheduledTimeSlot> PersonScheduledTimeSlots { get; set; }

        .....
    }
}

namespace Wur.WurScheduler.Blazor.Core.Models.Database
{
    public partial class ScheduledTimeSlot : EntityWithId, IAuditable, IValidatableObject
    {
        public ICollection<Person> Lecturers { get; set; }
        // Do the same on the other entity
        public List<PersonToScheduledTimeSlot> ScheduledTimeSlotPersons { get; set; }

        ...
    }
}

In the ModelContext add the following to one of the entities involved. In this case I put it on the ScheduledTimeSlot entity.
entity.HasMany(sts => sts.Lecturers)
    .WithMany(lec => lec.ScheduledTimeSlots)
    .UsingEntity<PersonToScheduledTimeSlot>(
        j => j
            .HasOne(ptsts => ptsts.Person)
            .WithMany(t => t.PersonScheduledTimeSlots)
            .HasForeignKey(ptsts => ptsts.PersonId),
        j => j
            .HasOne(ptsts => ptsts.ScheduledTimeSlot)
            .WithMany(p => p.ScheduledTimeSlotPersons)
            .HasForeignKey(ptsts => ptsts.ScheduledTimeSlotId),
        j =>
        {
            j.HasKey(t => new { t.PersonId, t.ScheduledTimeSlotId });
        });

And remove the entity.HasNoKey(); from the PersonToScheduledTimeslot model description. Couple tables need a key.


Can I take as a value iframe .php from from external .php?

Question: I have a php page that calls a php iframe, the iframe php executes a series of actions that return a response or value.
As I can take that answer from the external php page (which calls the iframe)?
Answer: There are several solutions, the easiest is that from the iframe php save the value in a session variable (_SESSION) and from the external php, ajax make a constantly read that session variable (_SESSION).
This way you take any value that does or calculate the iframe.


Increase session timeout

Question: So I have a requirement that I'm getting close to stumped on how to complete in Drupal 8.
I'm going to attempt to simplify the requirements. I have two roles. They are essentially mutually exclusive. Let's call them "Internal" and "Client".
The request is to have Clients logged in for an indefinite period of time... let's call it years. Internal users need to be logged in for a short period of time, say 1 day, or even just the session.
(Note: I didn't make these requirements, just coding them... haha)
My understanding of the Drupal login is that there are really two things controlling this... there is the cookie lifetime of a user, and the session lifetime (on the server). If I set the cookie lifetime to 1 week, but the session lifetime is 1 day, the user will essentially be logged out after 1 day, b/c their cookie will match a session that doesn't exist after a day... is that right?
So, I think I have to start with the upper limit. If I want my user to be logged in for 1 year, I need my server session to be 1 year. One of my questions is: what are the risks/downsides/etc to setting my server session to 1 year? Let's say my server gets 50k visits a month. What if it's not 1 year, and I want it at 2 years? I can't seem to find a definitive guide to what the upper limit of server session should be? It seems like there's a lot of factors that could clear out that session as well...
Ok, so the above is one question... assuming I can set the server session, how can I have the cookie lifetime visit based on user role? I'm getting to the point where it seems like it just might not be possible to vary this setting, and I might have to do some kind of route subscriber and custom cookies and whanot to detect the internal users, and log them out when I see they've been logged in too long...
Any help would be much appreciated...
Answer: I have achieved this goal in the past for Drupal 7 using a bit of custom code.

Set the cookie lifetime and server session timeout to the larger of the 2 numbers, in your case I guess that's 2 years.
Write a custom script (e.g. in drush) that will find stale sessions and delete them.

For item #2 for you that means it has to find the Internal users with a short lifetime and delete their session if the sessions.timestamp is beyond a limit. According to system.install, that column contains The Unix timestamp when this session last requested a page.
The limit of your sessions table depends on database server hardware, but my experience on a fairly large site is that you can have millions of sessions records and it's not a huge problem for performance. That said, I also found that user interaction followed a power-curve. 90% of users who committed and got engaged did so within the first day. 95% were within the first week and going out to 3 months got up to 98%. Saving the cookie data beyond that for what amounts to a rounding error is generally not super useful.
I found that trying to do a sql delete directly does not scale well. Instead, I wrote a loop that would find records to delete and then run individual delete queries with a condition WHERE sid = :sid so it was using a primary key. This had the greatest performance while having minimal impact. You can even run the select against a read-replica database to reduce the performance impact further. For my scenario, 1 class of users who had not been active in the last hour were logged out so that job ran every hour. The other class of users who got deleted after 3 months would be deleted in a job that ran overnight as it performed more operations and had more impact on server resources.
If you truly need to store session data for 2 years that's fine. However, you might consider if you can instead store the data in the cookie instead of in the session. That way your sessions table stays lightweight and you can still do tracking of the user inside the cookie. For example, if your goal is to track a channel that brought the user to the site you could simply store that channel information in their cookie instead of the $_SESSION. If you can avoid generating/keeping a session then the scalability problem goes away.
Beware that many spiders and bots generate significant traffic and are poorly behaved a it relates to sessions: they may discard cookies, effectively generating a new session for every page request if your app does that. You can either place a bot-blocking/caching network in front (like Cloudflare) or just plan to periodically analyze the sessions table and delete sessions from these bots based on something like IP address.
I would not suggest memcache for this purpose, but instead a sql database (perhaps a dedicated database instance) or Redis. Memcache is optimize as a temporary data store. You purposefully want a persistent data store, which sql or redis do provide.
Answer: Approach one,

Increase the session and cookie lifetime as required.
Move session from file-based sessions to Memcached. This can be done in php.ini.

So basically you give the longest session for all users. And then maybe you can write a rule or cronjob for invalidating sessions of the users of the roles you need shorter span.
Approach two, I guess better
https://www.drupal.org/project/persistent_login
See: http://www.jaspan.com/improved_persistent_login_cookie_best_practice
Comment: jaspan.com returns a white screen. Remember to always include a summary when linking blog articles. As they can go 404 any time, what value has this link then?

Increase session timeout


What is an example use of Auto differentiation such as implemented in Tensorflow and why is it important?

Question: I have a decent grasp of neural networks, back propagation and chain rule however I am struggling to understand auto differentiation.
The below refer to auto differentiation outside the context of back propagation:

How does auto differentiation compute the gradient from a matrix?
What are the requirements to compute a gradient? Does a function need to be specified?
What are some use cases for this (other then back propagation)?
Why is it important and what are the alternatives?

Am I missing something?
Comment: Automatic differentiation, also known as algorithmic differentiation, is an automated way of numerically calculating derivatives of a function(s) specified by a computer program, but the functions can be indirectly defined by the computer program. It is useful for computing gradients, Jacobians, and Hessians for use in numerical optimization, among other things.  Backpropagation is an implementation of the reverse mode of automatic differentiation for computing the gradient of a neural network optimization problem  See  https://en.wikipedia.org/wiki/Automatic_differentiation .
Comment: Alternatives are symbolic differentiation and finite differences, both of which are usually slower, and finite differences might be less accurate. Hand-coded derivatives can be used if the human can figure out the derivative, but are prone to human mistakes in many cases.
Comment: See list of automatic differentiation software and tools at Wikipedia link, and also links which include example usage. Another alternative to automatic differentiation is complex step differentiation (derivative) http://aero-comlab.stanford.edu/Papers/martins.aiaa.01-0921.pdf , which winds up being almost the same thing as the forward mode of automatic differentiation.
Comment: Where can I find simple examples to see how it is implemented? Is it the `tf.gradient` method I should be looking at?
Answer: In auto differentiation systems mostly an operator (e.g. addition, subtraction) is defined together with its differentiation.
So after you write a function by stacking a series of operators, the system can figure out by itself how the corresponding derivatives should be computed, usually by using computation graphs and the chain rule.
Auto differentiation is beneficial for gradient based optimization (e.g. training a neural network using gradient descent), as it saves us from working out the math, implementing the code and verifying the derivatives numerically case by case.
Here's how to define an operator (op) in Theano and Tensorflow.


Migrate data from dynamics crm to salesforce

Question: I want to know some best practice for migrating data from microsoft crm to salesforce crm.
Should you use migration tools?
If so what good migration tools are there out there?
Should I migrate it the data first to microsoft excel and then migration it from excel to salesforce?
I read that you can import data to salesforce crm by .csv files. Can you for example export data från dynamics crm to .csv files and then import the files with salesforce. Is this an alternativ solution?
What practice leaves you with less functionality loss?
Answer: I just recently went through an evaluation of the tools available and found that Scribe Insight is still the best tool for connecting to Dynamics CRM.  Their 60-day license option is great for one-time data migrations.
Comment: What other tools did you evaluate?
Comment: I looked at [Boomi](http://www.boomi.com/) and [Pervasive](http://www.pervasive.com/).  I didn't consider [Informatica](http://www.informatica.com/us/company/news-and-events-calendar/press-releases/03192012-microsoft-dynamics-crm-cloud.aspx) because their price was too high for my implementation


passing parameters into a linear search function on python

Question: I have this linear search where there is a list of words and a single word. the search checks whether the word is in the list or not. I keep on trying to pass my parameters to test the function but when i run the program nothing comes up. it would be great if you could look at this code and tell me where im going wrong.
def isin(alist, word):
    found = False
    length = len(alist)
    pos = 0
    while found == False and pos < length:
        if alist[pos] == word:
            found == True
        else:
            pos = pos + 1
    return found

words = ["child","adult","cat","dog","whale"]

if isin(words, "dog"):
    print("yes")
else:
    print("no")

Comment: `found = True` not `==`
Answer: You have a problem with line found == True. It should be found = True.
def isin(alist, word):
    found = False
    length = len(alist)
    pos = 0
    while found == False and pos < length:
        if alist[pos] == word:
            found = True
        else:
            pos = pos + 1
    return found

You could simplify the method to do the same task in one line as:
def isin(alist, word):
    return True if word in alist else False

Comment: What is wrong with incrementing conditionally in this context? (btw, your second version can be simplified to just `return word in alist`)
Comment: Thanks for pointing. I found the `==` missing part later after executing locally and forgot to edit the answer. I have edited it.
Answer: You are doing a lot extra works. Do it like this:
def isin(alist, word):
    if word in alist:
        return True
    else:
        return False

words = ["child","adult","cat","dog","whale"]

if isin(words, "dog"):
    print("yes")
else:
    print("no")

Comment: yh we werent allowed to use 'in' in the algorithm but cheers


Dust.js multi level array data

Question: My JSON data looks something like this:
{
    data:[
        [
            {"title": "Text1"},
            {"title": "Text2"},
            {"title": "Text3"}
        ],
        [
            {"title": "Text4"},
            {"title": "Text5"},
            {"title": "Text6"}
        ]
    ]
}

I want to use the data to generate a table. So far, I only manage to get it generate rows.
{#data}

      {title}

{/data}

How can I get it generate columns? Thanks.
Answer: You need to add an extra loop as each value in the first array is also an array:
{#data}

        {#.}
            {.title}
        {/.}

{/data}

Dust.js multi level array data


hang analysis - lock on xls OleDbConnection?

Question: Admins told us that there is some prolem in production. They noticed big jump in memory usage and in requests waiting.
I received one crash dump.  I need help analysing it.
Using Debug Diagnostic Tool I found this:

Detected possible blocking or leaked critical section at 0x1e5bd320 owned by thread 141 in dllhst3g.exe__Metastorm Process Engine__PID__7444__Date__10_25_2011__Time_01_19_15PM__686__Manual Dump.dmp

Impact of this lock

11,59% of threads blocked

(Threads 97 137 142 143 144 147 207 208 211 212 213 214 215 216 217 218 219 221 222 223 224 225 226 227 228 229 230)

The following functions are trying to enter this critical section
ACECORE+20eb

The following module(s) are involved with this critical section
C:\Program Files\Common Files\Microsoft Shared\OFFICE12\ACECORE.DLL from Microsoft Corporation

From the listed threads only thread 142 is waiting for thread 141. All others are waiting for thread 142.
~141
 141  Id: 1d14.1b38 Suspend: 0 Teb: 7fee4000 Unfrozen
  Start: msvcrt!_endthreadex+0x2f (77bcb4bc)
  Priority: 0  Priority class: 32  Affinity: ff

~141s : Edit: new stacktrace after fixing symbols
kb

2a2efdcc 7c827b89 77e6202c 00000003 2a2efe1c ntdll!KiFastSystemCallRet
2a2efdd0 77e6202c 00000003 2a2efe1c 00000001 ntdll!NtWaitForMultipleObjects+0xc
2a2efe78 7739bbd1 00000003 2a2efea0 00000000 kernel32!WaitForMultipleObjectsEx+0x11a
2a2efed4 7739ce36 00000002 2a2eff74 ffffffff user32!RealMsgWaitForMultipleObjectsEx+0x141
2a2efef0 4a77cb28 00000002 2a2eff74 00000000 user32!MsgWaitForMultipleObjects+0x1f
2a2eff84 77bcb530 33c23fe8 00000000 00000000 comsvcs!CSTAThread::WorkerLoop+0x1f9
2a2effb8 77e6482f 37e3b7e8 00000000 00000000 msvcrt!_endthreadex+0xa3
2a2effec 00000000 77bcb4bc 37e3b7e8 00000000 kernel32!BaseThreadStart+0x34

~142
 142  Id: 1d14.1128 Suspend: 0 Teb: 7feb9000 Unfrozen
  Start: msvcrt!_endthreadex+0x2f (77bcb4bc)
  Priority: 0  Priority class: 32  Affinity: ff

~142s : Edit: new stacktrace after fixing symbols
kb

31b5aa88 7c827b99 7c83d09c 00006c44 00000000 ntdll!KiFastSystemCallRet
31b5aa8c 7c83d09c 00006c44 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc
31b5aac8 7c83d0e7 00006c44 00000004 00000000 ntdll!RtlpWaitOnCriticalSection+0x1a3
*** ERROR: Module load completed but symbols could not be loaded for ACECORE.DLL
31b5aae8 3c9e20eb 1e5bd320 31b5ab3c 2ae13a61 ntdll!RtlEnterCriticalSection+0xa8
WARNING: Stack unwind information not available. Following frames may be wrong.
00000000 00000000 00000000 00000000 00000000 ACECORE+0x20eb

!clrstack
Shows call to System.Data.OleDb.OleDbConnection.Open()
I found it connects to xls
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\temp\somefile.xls;Extended Properties="Excel 8.0;HDR=Yes;"

~97
  97  Id: 1d14.730 Suspend: 0 Teb: 7fee5000 Unfrozen
  Start: mscorwks!CorExitProcess+0x21ef9 (79f756cf)
  Priority: 0  Priority class: 32  Affinity: ff

Edit: new stacktrace after fixing symbols
~97s
kb
27e1ca10 7c827b99 77e61d1e 000018e4 00000000 ntdll!KiFastSystemCallRet
27e1ca14 77e61d1e 000018e4 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc
27e1ca84 77e61c8d 000018e4 ffffffff 00000000 kernel32!WaitForSingleObjectEx+0xac
27e1ca98 7769c7ad 000018e4 ffffffff 2386d3a8 kernel32!WaitForSingleObject+0x12
27e1cab4 7778b5cb 24a1c758 2386d3a8 00000000 ole32!GetToSTA+0x7c
27e1cad4 7778c38b 27e1cb9c 27e1cc9c 22d3e674 ole32!CRpcChannelBuffer::SwitchAptAndDispatchCall+0xcb
27e1cbb4 776c0585 22d3e674 27e1ccac 27e1cc9c ole32!CRpcChannelBuffer::SendReceive2+0xd3
27e1cc20 776c051a 22d3e674 27e1ccac 27e1cc9c ole32!CAptRpcChnl::SendReceive+0xab
27e1cc74 77ce347f 22d3e674 27e1ccac 27e1cc9c ole32!CCtxComChnl::SendReceive+0x1a9
27e1cc90 77ce352f 45e02be4 27e1ccd8 0600016e rpcrt4!NdrProxySendReceive+0x43
27e1d080 77ce35a6 776762b8 776794ba 27e1d0b8 rpcrt4!NdrClientCall2+0x206
27e1d0a0 77c65037 00000014 00000004 27e1d0d0 rpcrt4!ObjectStublessClient+0x8b
27e1d0b0 776ad951 45e02be4 00000000 27e1d89c rpcrt4!ObjectStubless+0xf
27e1d0d0 776acb4b 77794960 00000001 00000000 ole32!CProcessActivator::CCICallback+0x6d
27e1d0f0 776acafc 77794960 27e1d6f8 00000000 ole32!CProcessActivator::AttemptActivation+0x2c
27e1d12c 776ada3b 77794960 27e1d6f8 00000000 ole32!CProcessActivator::ActivateByContext+0x4f
27e1d154 776aaf9e 77794960 00000000 27e1d89c ole32!CProcessActivator::CreateInstance+0x49
27e1d194 4a777108 27e1d89c 00000000 27e1d5d8 ole32!ActivationPropertiesIn::DelegateCreateInstance+0xf7
27e1d210 776aaf9e 443dd8f8 00000000 27e1d89c comsvcs!CSTAPoolActivator::CreateInstance+0x5a9
27e1d250 4a766303 27e1d89c 00000000 27e1d5d8 ole32!ActivationPropertiesIn::DelegateCreateInstance+0xf7
27e1d2a0 776aaf9e 341d3168 00000000 27e1d89c comsvcs!CStdContextActivator::CreateInstance+0x221
27e1d2e0 77727f8a 27e1d89c 00000000 27e1d5d8 ole32!ActivationPropertiesIn::DelegateCreateInstance+0xf7
27e1d310 776f5c55 0009a0f8 00000000 27e1d89c ole32!CSurrogateProcessActivator::CreateInstance+0xf7
27e1d344 776aaf9e 7779487c 00000000 27e1d89c ole32!CClientContextActivator::CreateInstance+0xc9
27e1d384 776ab12f 27e1d89c 00000000 27e1d5d8 ole32!ActivationPropertiesIn::DelegateCreateInstance+0xf7
27e1d68c 776a67ba 361f8c54 00000000 00000015 ole32!ICoCreateInstanceEx+0x3f8
27e1d6c0 7769b9b3 361f8c54 00000000 00000000 ole32!CComActivator::DoCreateInstance+0x6a
27e1ddc8 4a7516d8 45bfeb58 361f8c54 00000000 ole32!CComActivator::StandardCreateInstance+0x7c
27e1de3c 4a751fc6 00000000 361f8c40 00000000 comsvcs!CClassFactoryWrapper::ActivateOnMachine+0xaf
27e1de74 7a078d9b 361f8c40 00000000 79edda70 comsvcs!CClassFactoryWrapper::CreateInstance+0x80
27e1e118 7a07a1e6 361f8c40 00000000 00000000 mscorwks!ComClassFactory::CreateInstanceFromClassFactory+0x102
27e1e174 7a0bf10a 1e772994 00000000 27e1e1b4 mscorwks!ComClassFactory::CreateInstance+0x91
27e1e184 7a0c870b 1e772994 1e772994 79faa672 mscorwks!AllocateComObject_ForManaged+0x1e
27e1e1b4 79e9c82b 1e772994 234b20e8 79faa737 mscorwks!AllocateObject+0x38
27e1e1c0 79faa737 05ff2627 00000001 072336fc mscorwks!MethodTable::Allocate+0x35
27e1e260 792c25c3 1e772994 27e1e278 792c257c mscorwks!CRemotingServices::AllocateUninitializedObject+0xdf
27e1e278 792c1951 0f5b1b50 27e1e2d0 03100120 mscorlib_ni+0x2025c3
27e1e290 792c143e 44194464 00000000 00000016 mscorlib_ni+0x201951
27e1e2ac 79e71e04 00000001 27e1e334 79faa569 mscorlib_ni+0x20143e
27e1e2b8 79faa569 792c1400 072336fc 00000000 mscorwks!CTPMethodTable__CallTargetHelper3+0xf
27e1e334 79faa5d8 072336fc 00000000 00000001 mscorwks!CTPMethodTable::CallTarget+0xdd
27e1e348 79faa614 790fd65c 072336fc 00000000 mscorwks!CTPMethodTable::CallTarget+0x14
27e1e368 7a04b578 1e772994 00000000 00000001 mscorwks!CRemotingServices::CreateProxyOrObject+0x38
27e1e414 1e923c99 0f5b1a58 0f5b1b1c 27e1e464 mscorwks!JIT_NewCrossContextHelper+0xa9
WARNING: Frame IP not in any known module. Following frames may be wrong.
27e1e430 776e2fae 00000000 00000064 00000001 0x1e923c99
27e1e464 79e71b4c 27e1ef70 00000064 00000001 ole32!CoGetContextToken+0x29
27e1e494 79e821b9 27e1ee70 00000008 27e1ee20 mscorwks!CallDescrWorker+0x33
27e1e514 7a0f851b 27e1ee70 00000008 27e1ee20 mscorwks!CallDescrWorkerWithHandler+0xa3
27e1e5e4 79270454 00000001 00000000 00000000 mscorwks!CMessage::Dispatch+0x162
27e1e63c 7977c16e 00000001 00000000 075d788c mscorlib_ni+0x1b0454
27e1e658 6744d146 0752309c 0f5b19d8 0752304c mscorlib_ni+0x6bc16e
27e1e690 197cb7c7 0d0e3640 79e7a6b8 27e1ea80 System_EnterpriseServices_ni+0x5d146
27e1e70c 197f3d04 27e1eae4 0071f13b 36c6b460 System_EnterpriseServices_Wrapper!__dyn_tls_init_callback  (System_EnterpriseServices_Wrapper+0x2b7c7)
27e1e74c 77720df0 27e1eae4 35ccbed0 00000000 System_EnterpriseServices_Wrapper_197f0000!System::EnterpriseServices::Thunk::FilteringCallbackFunction+0x44
27e1e798 7772189c 00000000 35ccbed0 197f3cc0 ole32!EnterForCallback+0xc4
27e1e8f8 776f0418 27e1e7d0 197f3cc0 27e1eae4 ole32!SwitchForCallback+0x1a3
27e1e924 7769c194 35ccbed0 197f3cc0 27e1eae4 ole32!PerformCallback+0x54
27e1e9bc 776e316c 36c6b460 197f3cc0 27e1eae4 ole32!CObjectContext::InternalContextCallback+0x159
27e1ea0c 79e71d8b 36c6b470 197f3cc0 27e1eae4 ole32!CObjectContext::ContextCallback+0x85
27e1ea68 197cbc82 776e30e7 0f5b1a28 072323f0 mscorwks!PInvokeCalliReturnFromCall
27e1ea88 197cbc82 0010c8f0 00000000 00000008 System_EnterpriseServices_Wrapper!__dyn_tls_init_callback  (System_EnterpriseServices_Wrapper+0x2bc82)
27e1eab4 197cbb51 07231a74 27e1eb2c 79282f85 System_EnterpriseServices_Wrapper!__dyn_tls_init_callback  (System_EnterpriseServices_Wrapper+0x2bc82)
27e1eac0 79282f85 27e1eb44 00000000 00000000 System_EnterpriseServices_Wrapper!__dyn_tls_init_callback  (System_EnterpriseServices_Wrapper+0x2bb51)
27e1eb2c 797f5a0d 03100788 072323f0 075d7830 mscorlib_ni+0x1c2f85
00000000 00000000 00000000 00000000 00000000 mscorlib_ni+0x735a0d

And all other threads waiting for thread 142 have same stack trace.
I don't know what thread 141 is doing. Thread 142 cannot open connection to xls file. And not sure why other threads wait for thread 142.
Maybe you have any ideas?
EDIT:

    analyze -v -hang
GetPageUrlData failed, server returned HTTP status 404
URL requested: http://watson.microsoft.com/StageOne/dllhst3g_exe/5_2_3790_3959/unknown/0_0_0_0/00000000.htm?Retriage=1
FAULTING_IP:
+1e02faf0157df58
00000000 ??              ???
EXCEPTION_RECORD:  ffffffff -- (.exr 0xffffffffffffffff)
ExceptionAddress: 00000000
   ExceptionCode: 80000003 (Break instruction exception)
  ExceptionFlags: 00000000
NumberParameters: 0
FAULTING_THREAD:  0000008d
BUGCHECK_STR:  HANG
PROCESS_NAME:  dllhst3g.exe
ERROR_CODE: (NTSTATUS) 0xcfffffff -
EXCEPTION_CODE: (NTSTATUS) 0xcfffffff -
MOD_LIST:
NTGLOBALFLAG:  0
APPLICATION_VERIFIER_FLAGS:  0
MANAGED_STACK: !dumpstack -EE
OS Thread Id: 0xc2c (17)
Current frame:
ChildEBP RetAddr  Caller,Callee
1974f450 655f1110 (MethodDesc 0x651b7efc +0x30 System.Data.ProviderBase.WrappedIUnknown.ReleaseHandle())
1974f93c 792e5e4f (MethodDesc 0x79107064 +0xf System.Runtime.InteropServices.SafeHandle.Dispose(Boolean))
1974f944 792e5d6b (MethodDesc 0x79107030 +0x1b System.Runtime.InteropServices.SafeHandle.Finalize())
DERIVED_WAIT_CHAIN:
Dl Eid Cid     WaitType

0   1d14.71c Speculated (Triage)    -->
   17  1d14.c2c Critical Section       -->
   141 1d14.1b38 Event
WAIT_CHAIN_COMMAND:  ~0s;k;;~17s;k;;~141s;k;;
BLOCKING_THREAD:  00001b38
DEFAULT_BUCKET_ID:  APPLICATION_HANG_WRONG_SYMBOLS
PRIMARY_PROBLEM_CLASS:  APPLICATION_HANG_WRONG_SYMBOLS
LAST_CONTROL_TRANSFER:  from 7c827b89 to 7c82847c
STACK_TEXT:
2a2efdcc 7c827b89 77e6202c 00000003 2a2efe1c ntdll!KiFastSystemCallRet
2a2efdd0 77e6202c 00000003 2a2efe1c 00000001 ntdll!NtWaitForMultipleObjects+0xc
2a2efe78 7739bbd1 00000003 2a2efea0 00000000 kernel32!WaitForMultipleObjectsEx+0x11a
2a2efed4 7739ce36 00000002 2a2eff74 ffffffff user32!RealMsgWaitForMultipleObjectsEx+0x141
2a2efef0 4a77cb28 00000002 2a2eff74 00000000 user32!MsgWaitForMultipleObjects+0x1f
2a2eff84 77bcb530 33c23fe8 00000000 00000000 comsvcs!CSTAThread::WorkerLoop+0x1f9
2a2effb8 77e6482f 37e3b7e8 00000000 00000000 msvcrt!_endthreadex+0xa3
2a2effec 00000000 77bcb4bc 37e3b7e8 00000000 kernel32!BaseThreadStart+0x34
FOLLOWUP_IP:
ntdll!KiFastSystemCallRet+0
7c82847c c3              ret
SYMBOL_STACK_INDEX:  0
SYMBOL_NAME:  ntdll!KiFastSystemCallRet+0
FOLLOWUP_NAME:  MachineOwner
MODULE_NAME: ntdll
IMAGE_NAME:  ntdll.dll
DEBUG_FLR_IMAGE_TIMESTAMP:  4cc18322
STACK_COMMAND:  ~141s ; kb
BUCKET_ID:  HANG_ntdll!KiFastSystemCallRet+0
FAILURE_BUCKET_ID:  APPLICATION_HANG_WRONG_SYMBOLS_cfffffff_ntdll.dll!KiFastSystemCallRet
WATSON_STAGEONE_URL:  http://watson.microsoft.com/StageOne/dllhst3g_exe/5_2_3790_3959/45d69678/unknown/0_0_0_0/bbbbbbb4/cfffffff/00000000.htm?Retriage=1
Followup: MachineOwner

Not sure I understand it. But thread 17 is finalizer thread. So looks like it is blocked? And I thinkg it as again some kind of access to xls?

    ~17s
    kb
ChildEBP RetAddr  Args to Child
1974f08c 7c827b99 7c83d09c 00003a98 00000000 ntdll!KiFastSystemCallRet
1974f090 7c83d09c 00003a98 00000000 00000000 ntdll!ZwWaitForSingleObject+0xc
1974f0cc 7c83d0e7 00003a98 00000004 00000001 ntdll!RtlpWaitOnCriticalSection+0x1a3
1974f0ec 2ae1fa94 29202124 32787727 00000000 ntdll!RtlEnterCriticalSection+0xa8
WARNING: Stack unwind information not available. Following frames may be wrong.
1974f160 4c856487 2263eff4 00000000 00000005 ACEOLEDB!DllGetClassObject+0xdc2d
1974f174 4c862d06 2263eff4 4c8633c4 2263efe8 oledb32!CACMDynamic::CmFinalRelease+0x50
1974f17c 4c8633c4 2263efe8 2263efe8 1974f1e4 oledb32!CDCM::FinalRelease+0x1b
1974f198 4c8633f6 00000000 2263efe8 1974f1b8 oledb32!ATL::CComPolyObject::~CComPolyObject+0x2a
1974f1a8 4c88d5ad 2263efe8 2370a39c 1974f1f4 oledb32!ATL::CComPolyObject::Release+0x25
1974f1b8 4a757681 1a271fa0 2263efe8 2370a39c oledb32!CDCMCreator::DestroyResource+0xf
1974f1f4 4a75793e 2370a39c 2263efe8 00000000 comsvcs!CHolder::SafeDispenserDriver::DestroyResource+0x20
1974f20c 4a758a35 23151cd0 00000000 2fa44808 comsvcs!CHolder::ProcessDestroyList+0x2e
1974f238 4c88d30e 23151cd0 2263efe8 2263efe8 comsvcs!CHolder::FreeResource+0x7f
1974f268 4c878a3a 2263efe8 00000000 271aa824 oledb32!CDCMCreator::ReleaseResource+0x31
1974f288 4c8545e7 271aa824 00000000 4c85456a oledb32!CDPO::ReturnDCMToPool+0x89
1974f294 4c85456a 271aa818 271aa818 1974f320 oledb32!CDPO::FinalRelease+0xb
1974f2b0 4c88e78a 271aa818 1974f2d0 4c85218c oledb32!ATL::CComPolyObject::~CComPolyObject+0x2a
1974f2bc 4c85218c 00000001 00000000 000eaaf8 oledb32!ATL::CComPolyObject::`scalar deleting destructor'+0xd
1974f2d0 4c8521aa 271aa818 1974f330 79f63ff9 oledb32!ATL::CComPolyObject::Release+0x27
1974f2dc 79f63ff9 271aa824 3b6a3777 000eaaf8 oledb32!ATL::CComContainedObject::Release+0x11
1974f330 79f640ac 271aa828 3b6a3733 000eaaf8 mscorwks!ReleaseTransitionHelper+0x5f
1974f374 79f64110 271aa828 00000000 3b6a37ef mscorwks!SafeReleaseHelper+0x8c
1974f3a8 79f53b5d 271aa828 00000000 3b6a3017 mscorwks!SafeRelease+0x2f
1974f450 655f1110 000eaaf8 00000000 1974f470 mscorwks!MarshalNative::Release+0xb0
1974f460 79e71b4c 1974f4dc 000c5958 1974f4f0 System_Data_ni!_bidW103  (System_Data_ni+0x4a1110)
1974f470 79e821b9 1974f540 00000000 1974f510 mscorwks!CallDescrWorker+0x33
1974f4f0 79e96531 1974f540 00000000 1974f510 mscorwks!CallDescrWorkerWithHandler+0xa3
1974f634 79e96564 655f10e0 1974f6bc 1974f6a4 mscorwks!MethodDesc::CallDescr+0x19c
1974f650 79e96c4c 655f10e0 1974f6bc 1974f6a4 mscorwks!MethodDesc::CallTargetWorker+0x1f
1974f670 79eccd2a 1974f6a4 0b402780 00000004 mscorwks!MethodDescCallSite::Call_RetObjPtr+0x1c
1974f770 79eccd5e 0b402780 000eaaf8 000eaaf8 mscorwks!SafeHandle::RunReleaseMethod+0x89
1974f870 79eccbf4 00000001 0d0e3640 79e7a1c8 mscorwks!SafeHandle::Release+0x11b
1974f89c 79f83999 3b6a3d7b 00000000 000eaaf8 mscorwks!SafeHandle::Dispose+0x23
1974f93c 792e5e4f 1974f970 792e5d6b 0b3ac100 mscorwks!SafeHandle::Finalize+0xab
1974f944 792e5d6b 0b3ac100 ffffffff 00000000 mscorlib_ni+0x225e4f
1974f970 79f7169a 1974f9c4 79ef465c 1974fc1c mscorlib_ni+0x225d6b
1974f9d4 79f7175b 0b402780 792e5d50 08000000 mscorwks!MethodTable::GetObjCreateDelegate+0xaf
1974f9f4 79f71609 0b402780 0b402780 00000000 mscorwks!MethodTable::CallFinalizer+0xa0
1974fa08 79fd46a6 0b402780 3b6a3e1f 00000000 mscorwks!SVR::CallFinalizer+0xa6
1974fa58 79fd45d7 000eaaf8 00000415 1974fadf mscorwks!SVR::GCHeap::TraceGCSegments+0x1b0
1974fae0 79f5832f 0740eeb4 00000000 1974feb0 mscorwks!SVR::GCHeap::TraceGCSegments+0x2f6
1974faf4 79e9848f 1974fd04 000eaaf8 00000000 mscorwks!SVR::ProfScanRootsHelper+0x69
1974fb08 79e9842b 1974feb0 1974fb90 79fa6a6b mscorwks!Thread::DoADCallBack+0x32a
1974fb9c 79e98351 1974feb0 3b6a3f9f 000eaaf8 mscorwks!Thread::ShouldChangeAbortToUnload+0xe3
1974fbd8 79ec4322 1974feb0 00000000 1974fc98 mscorwks!Thread::ShouldChangeAbortToUnload+0x30a
1974fbe8 79f581f3 1974feb0 1974fc8c 79fa6a6b mscorwks!Thread::RaiseCrossContextException+0x434
1974fc98 79f58279 1a9cb678 79ec430e 1974feb0 mscorwks!Thread::DoADCallBack+0xcd
1974fcb8 79f58265 1974feb0 1974fd20 79f582e4 mscorwks!Thread::DoADCallBack+0x322
1974fcc4 79f582e4 1a9cb678 79f58316 1974fd04 mscorwks!ManagedThreadBase::FinalizerAppDomain+0x25
1974fd20 79fd45d7 000eaaf8 00000000 1974fda7 mscorwks!SVR::GCHeap::TraceGCSegments+0x251
1974fda8 79fd48a8 00000000 00000000 1974feb0 mscorwks!SVR::GCHeap::TraceGCSegments+0x2f6
1974fdc0 79e9848f 1974feb0 00000000 00000000 mscorwks!SVR::GCHeap::FinalizerThreadWorker+0xb7
1974fdd4 79e9842b 1974feb0 1974fe5c 79fa6a6b mscorwks!Thread::DoADCallBack+0x32a
1974fe68 79e98351 1974feb0 3b6a3ae3 00000000 mscorwks!Thread::ShouldChangeAbortToUnload+0xe3
1974fea4 79f074d4 1974feb0 00000000 1a9cb678 mscorwks!Thread::ShouldChangeAbortToUnload+0x30a
1974fecc 79f074e5 79fd4809 00000008 1974ff14 mscorwks!ManagedThreadBase_NoADTransition+0x32
1974fedc 79f090b3 79fd4809 3b6a3b53 00000000 mscorwks!ManagedThreadBase::FinalizerBase+0xd
1974ff14 79f75715 00000000 00000007 ffffffff mscorwks!SVR::GCHeap::FinalizerThreadStart+0xbb
1974ffb8 77e6482f 000eb528 00000000 00000000 mscorwks!Thread::intermediateThreadProc+0x49
1974ffec 00000000 79f756cf 000eb528 00000000 kernel32!BaseThreadStart+0x34

Comment: I would try db 77bcb4bc to see what file GetModuleHandleA was trying to open. That might give you some clues.
Comment: Thanks. I added output from db.
Comment: Thread 141 is some sort of COM thread. However it is hard to tell what it is doing without symbols. Can you try fixing up symbols for comsvcs.dll? Fixing all other symbols wouldn't hurt either.
Comment: How do I recognize that there are no symbols? I thought that if I see stacktrace with function names it is ok. I thought I had symbols set up correctly. I debug on XP applications from win 2003. I downloaded symbol files from microsoft.
Comment: Ok I think i fixed symbols using .sympath SRV*d:\websymbols*d:\websymbols\win2003*http://msdl.microsoft.com/download/symbols - added microsoft server to this list. Look at another kb from thread 141.
Comment: I edited my post and entered new stacktraces for all the threads after fixing symbols.
Comment: Unless you are so familiar with dump analysis (which is not as you don't even use !CLRStack or !threads or !threadpool or psscor2). In this case, you should open a support case via http://support.microsoft.com and share the dump with Microsoft support guys.
Comment: I use all of those. How did you come up with this!? Those are not relevant here. And to open a case with support you have to pay and wait weeks. Good luck when you need to fix it now. And for your information the bug was fixed.
Answer: You need to find who owns the following critical section that your thread is waiting on:
1974f0ec 2ae1fa94 29202124 32787727 00000000 ntdll!RtlEnterCriticalSection+0xa8

You can do an automated critical section analysis with call stacks:
!locks -v

This will dump all critical section locks that are in a locked state and the call stacks of the threads, you then need to scan each call stack for each lock to see if say Thread A is waiting on lock 1 which is owned by Thread B, Thread B is waiting on lock 2 which is owned by Thread A.
Hope this helps


What is the $\lVert v\rVert$ sign mean in the context of vectors?

Question: Suppose $V$ a inner product space, $u, v \in V$.
I need to prove this identity:
$$\lVert u+v\rVert^2 +\lVert u-v\rVert^2 = 2\left(\lVert u\rVert^2 +\lVert v\rVert^2\right) $$
what is the $\lVert v\rVert$ ("two lines") sign mean? thanks.
Answer: It is the norm. In this case,
$$
\|u\| = \sqrt{\langle u, u \rangle}
$$
Comment: $|| u + v||$ is $\sqrt()$ or $\sqrt()$?
Comment: It is $\sqrt{\langle u+v,u+v\rangle}.$


Commerce account pane email change

Question: I am using Drupal 7 with commerce module. In the commerce shipping pane I have created a new email filed through admin -> store -> Customer profiles -> Shipping Information and it is displaying in the shipping section that's all fine.
Now what I have to do here is use this email while creating the account for anonymous users instead of using email from the account pane and also I need to hide the email filed in account pane.  Can anyone guide me how to implement this? Thanks in advance.
Ratheesh
Comment: Anonymous users will be asked to enter an email address anyway when checking out, what is wrong with using the default email field? You seem to be making things harder for yourself.
Answer: I have resolved the issue like adding a submit handler function when click on continue button click. Code is provided below
your-module_form_alter(&$form, $form_state, $form_id) {
   global $user;
   if(!$user->name){
      $form['account']['login']['mail']['#required'] = 0;
      $form['account']['login']['mail']['#prefix'] = '
';
      $form['account']['login']['mail']['#suffix'] = '
';
      array_unshift($form['buttons']['continue']['#validate'], 'your-module_submit_handler');
    }
}

your-module_submit_handler(&$form, &$form_state){
    $form_state['values']['account']['login']['mail'] = $form['customer_profile_shipping']['field_email']['und'][0]['value']['#value'];
}

Commerce account pane email change


How to deselect a text box in javascript

Question: For any help thanks in advance and
Here my code is:
<code><input type="text" id="hoEndDate" name="endDate" class="endDatePicker" required/>
</code>
js code is:
<code>$('#hoEndDate').setAttribute("disabled", true);
</code>
Comment: Do you mean deselect (remove focus) or do you mean disable (make it read only)
Comment: `$("#duration").prop("disabled",true)`
Comment: Just to be sure, are you talking about _deselecting_ the text in a textbox, or making a textbox _disabled_?
Comment: There is no setAttribute in jQuery. I am sure your developer console has an error message that states that.
Answer: You can set disabled attribute like this:
<code>$("#duration").attr("disabled","disabled")
</code>
OR
<code>$("#duration").prop("disabled",true)
</code>
Comment: `disabled` is a property, use `.prop` instead.
Comment: i want to deselect the text in a textbox.
Answer: by deselect if you mean to remove focus,
<code>$("#duration").blur()
</code>
or to disable
<code>$("#duration").attr("disabled","disabled")
</code>
Comment: @sireeshaj there is not any way to deselect value in text box you have to blank the text field by using these $("#duration").val("");
Comment: for select box i wrote like this           $('select#endTimeMins option').removeAttr("selected");
but for text box how to remove the selected value?
Comment: please give me solution.
Answer: You can do it by
<code>$("#duration").attr("disabled","disabled")
</code>


Tukey's fences for outlier removal

Question: I'm in a biomedical research field, and I see a lot of researchers conducting low N studies that use Tukey's fences for outlier removal. For anyone who doesn't know, Tukey's fences works as such:

Calculate quartiles 1 and 3 of your data
Add 1.5xInterquartile Range to Q3 (upper fence), subtract 1.5xIQR from Q1 (lower fence)
Anything above the upper fence or below the lower fence is an outlier and can be excluded

This doesn't feel right to me, especially in the context of low N experiments, though it seems common. The odd thing is, in scientific papers where this is mentioned, the reference given is John Tukey's 1977 textbook, "Exploratory Data Analysis." You can find the PDF online, but nowhere in the book does he talk about using this strategy for data removal, only for highlighting data points in an exploratory manner.
I was wondering if anyone knew of any references or papers about when this strategy began to be used for outlier removal, or if this is a valid strategy.
Answer: As you suspect, this is not a valid strategy for data removal. The
"outliers" falling outside Tukey's fences are worth a second look. They may or may not have arisen through legitimate random sampling from the population of an experiment.
Some datasets may contain observations arising from data entry errors, equipment failure, sampling from the wrong population, etc. Perhaps one can check with original sources to see
if these values are correct; perhaps 129 was input as 921, perhaps there is a lab note about an unusual occurrence.
In some cases (such as: a negative height, a human age of 1078) a value may be obviously wrong. Perhaps more commonly, outliers are correct, but unexpectedly low or high values.
Also, the boxplot outlier detection rules work better for data that are approximately normally distributed (e.g., scores on certain kinds of tests) than for highly skewed data, such as exponential or Pareto data (e.g., waiting times, bank balances).
Using R software, it is easy to count the outliers in
a randomly generated sample. For example, in one sample of size $n=50$ from an exponential distribution with rate $1/5$ (mean $5),$ there were $3$ outliers of the kind you mention.
set.seed(2021)
length(boxplot.stats(rexp(50, 1/5))$out)
[1] 3

set.seed(2021); x = rexp(50, 1/5)
boxplot(x, horizontal=T)

Then we can look at 100,000 such samples to get a good idea
how many outliers to expect among such exponential samples.
It seems that the average number is around 2.45 outliers
per sample. These outliers are characteristic of the
distribution, and deleting them would give a false
impression of the actual population.
set.seed(1010)
nr.out = replicate(10^5,
          length(boxplot.stats(rexp(50,1/5))$out))
summary(nr.out)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   0.00    1.00    2.00    2.45    3.00   10.00

With the huge datasets in common use nowadays, I don't know
what you mean by "small" sample size--10, 100, or 1000.
In a normal dataset of size 100 one should not be surprised
to see an outlier. [I used standard normal samples, but the result would be the same sampling from a normal population with any $\mu$ amd $\sigma.]$
set.seed(1234)
nr.out = replicate(10^5,
          length(boxplot.stats(rnorm(100))$out))
summary(nr.out)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
  0.000   0.000   1.000   0.923   1.000  15.000

Note: I have tried to give a direct answer to your specific question.
But you may find some useful additional information by looking
at the links in the margin of this page to "Related" Q&A's
Comment: Thank you for the detail. Yeah, I'm seeing this "outlier" removal method used in experiments with rodents where the sample sizes per group are less than 20, sometimes less than 10.
Comment: it's a pity that this does not really answer the question "references or papers about when this strategy began to be used for outlier removal". It might not always be good method for outlier detection but it is obviously widely used for that and the question asked about references and how this started.

Tukey's fences for outlier removal


What is the best solution for PCI-DSS compliance?

Question: I'm comparing different solutions for PCI-DSS compliance, reading a lot of white papers and brochures regarding RSA enVision, Splunk, LogRhythm, SenSage, ArcSight and OSSEC.
Unfortunately, comparison have been difficult because the lack of details provided by the companies/organizations. So, what are your experiences using these systems? Any advice? Criticism?
Some details:

My PCI system will be a small segmented network with 5 hosts, protected by firewalls
All machines will be running Linux
I decided to write this question after reading this astonishing critic to enVision. Do you agree with those guys?!?
Answer: Whenever I see the term "CMDB" thrown about, my bs detector activates.
According the RSA use case video, the enVision solution will:

Magically "discover" your IT environment by drawing upon your CMDB. Sure.
Magically get messages from your vulnerability scanner what exploits your server is vulnerable to
Process your IDS logs and magically correlate attacks with the vulnerabilities mapped in steps 1 and 2

Not knowing anything about enVision outside of what that video presented, I'm concluding that it's bogus enterprise software that typically gets sold to CIOs who are in the middle of ITIL projects, and that remains on the shelf in 90% of the time. Why?

CMDB is the great white whale of the ITIL high priests. Whatever database you have to track things, I'm sure that it isn't a CMDB.
After you spend a few years figuring out what RSA defines as a CMDB, how is this tool actually going to find anything? (A: You're going to write lots of scripts and do lots of work. Or hire lots of RSA consultants)
How do you correlate whatever your vulnerability scanner is reporting with the crap from you CMDB? (A: You're going to write lots of scripts and do lots of work. Or hire lots of RSA consultants)
How do you then automatically correlate attacks against vulnerabilities that were in turn associated with crap from your CMDB? (A: You give up before this stage.)

There's too many moving parts... assuming that the product could work, the resources required to make that happen probably exceed the cost of having someone sit at a desk at stare at syslog output 24x7.
Answer: Unfortunately, the best solution for PCI-DSS compliance is simply not to process card data yourself.


Chord lick, looking for others similar and maybe a bit of the theory behind how it works...

Question: Here's a nice little chord lick that I picked up from Little Charlie of Little Charlie and the Nightcats.  Charlie uses it as a turnaround in a few Swing Blues tunes he does.
<code>$4.9.$3.8.$2.9.$1.7   /   $4.6.$3.7.$2.6.$1.7   /    $4.6.$3.7.$2.5.$1.7   /   $4.6.$3.7.$2.6.$1.7   /
</code>
A great place to play the lick is here, in T-Bone Shuffle, in the turnaround spot right before the first solo.  By the way, that song is off one of the best blues albums ever.  Showdown with Albert Collins, Robert Cray and Johnny Copeland.
T-Bone shuffle is in B, making the chords in this case B add 6, Bdim and an inverted Edom7.
Can anyone explain the theory behind that lick?  I'd like to be able to figure out some of those on my own.  Flailing around for the last 10 years or so, I've found a few that are OK, but none that work as well as that one.
Comment: It would be cool to be able to hear this instead of just looking. Tab plugin with audio play-back. Songster does this nicely.
Answer: You can analyze it a number of ways but the key features are the B "pedal" in the melody, the voice leading, and the strong to weak harmonic accents.
Since this is all over a B7 chord all these are B chords.
These are all B13b5#9 chords with the 6th and #9's emphasized. At least that is the sound that you ultimately hear. Depending on how the chords are voiced in the other instrument and such it may or may not work well and the effect you are liking is going to depend on a lot of factors.
You can think of it as simply emphasizing the blue notes of the blues scale.
If you want to be able to play around with such things learn different ways to voice the B13b5#9 chord(there are hundreds of ways) and learn to move between them using smooth voice leading(or not, it's up to you).
Remember, you don't have to play every note in the chord but makes sure the background harmony is a B13 chord or you won't get the effect. e.g., if you just play that harmony by itself you do not get a B13 sound or at least it starts to sound like a progression(e.g., G#m to E9 instead of a coloring of B13).
e.g., the progression can be thought of a G#m E9 E7 E9  (E9 from the minor mode)
Which, if you wanted, you can simply say this is all an E13 chord!! Which means when you learn all your B13 chords they will work over(more or less) the E13 chords and vice versa(among a few others).
So, you can look at the lick as a continuation of the IV7 chord into the I7 chord(a sort of polychord) for the turn around or simply colorations of a B7 chord.
In any case(how ever you look at it) the B pedal, the voice leading, and the Strong/weak stress is what is important. If you copy those properties and change other things you'll be able to get as many variations as you want.
=-=-=-=-=-=-
Ok, realize that you can play "shell" voicings of the chord because they tend to be played by other instruments. Suppose you want the harmony to sound a B13b5#9 and the other instruments are playing a B7 chord. Well B7 = B D# F# A and B13b5#9 = B C# D D# E F F# G# A.
Since we can't play all those notes(and probably don't want to) we can leave out at least the unimportant ones or the ones that clash too much. The notes we need to play because the other instruments are not are the C# D E F and G#. The C#, the maj9th of chord, going to sound a bit dissonant with the D so we'll leave that out. Essentially we are changing the maj9th into a augmented 9th(D to D# or 9th to #9th). This leaves us with the notes D E F G#. Add in the B and you get a complete E9 chord. E9 is the IVth of the key.
So effectively he is playing E9(from the minor mode) over the B7 chord giving a B13b5#9 sonority. He doesn't play the E but on the weak beat because the it and the F(the b5) form a min2nd dissonance which gives that sort of B7sus sound.
The best way to think about it though, IMO, is that he is simply playing the IV chord over the I chord with a pedal on the tonic(which sort of ties it all together). By playing by playing E9 rather than E one gets the two blues notes that are missing from the B7 chord(usually played melodically).
That is, if you play the E9 from the minor mode(add the min9 rather than the maj9) over a B7 chord you'll get the tonality of a B13b5#9 chord(it won't have the maj9th in it, the C#, but if you followed we replaced that with the aug9th).
All you really have to think about is simply to continue the harmony from the previous chord over into that of the I chord and you'll get a similar effect. Flatten the 9th of that IV chord though which will give you the b5th of the I chord which will make it sound more bluesy.
Now, if you get that, that is, we can use the E(b9) chord over the I chord then it becomes much easier to play those sounds. Now, We can leave any chord tone out that we wish to make it easier to play. If you are only playing 4 notes in the chord then you'll have to leave out one. In this case he is simply playing different 4 note voicings of the 5 note chord all with a B in the soprano which helps tie them all to a B tonality(so it doesn't sound too jazzy/polytonal probably).
You'll never find a B13b5#9 fully voiced because it requires too many notes. It is simply the mashup of two chords played simultaneously(a polychord) that can either be intentional or not.
For example, playing the V chord over the I chord in blues gives
B D# F# A + F# A# C# E
This gives something that is not used in the blues idiom and has many min2nd dissonances
But the biii chord over the I chord gives
B D# F# A + D F A
which contains exactly the blues notes(min3rd, b5, and b7) and gives us a B7#9b5 chord.
It is much easier to think of just playing the Dm chord over a B7 chord to get the blues sound than(of course it alone is not enough). Adding the root B to Dm gives B D F A = Bdim. So playing a Bdim chord also gives the blues sound and has the same effect ad the Dm chord but with the added B helps tie it together(makes it sound more "Bish" than "Dish").
So try a Dm chord over the B7 chord in blues then try an E(7 and/or 9). Try other chords. See how they all sound. Note that some will work better than others. Some will sound cool but will not be blues.
The only thing new you should be learning is that you can play some chords over other chords that do not change them but that expresses a certain color that is appropriate.
What is more important than anything I have said is HOW YOU PLAY IT. If you can't play it in the proper blues idom then it doesn't matter what your playing. A great blues player can just about make anything work cause they know when to use it(although they might not "know" what they are using and how to use it).
BB King, for example, likes to throw in the b2nd note in some of his licks. I really like that sound as it gives a more sophisticated feel. The b2nd tends to be a bad note use in general but works well in certain cases in blues(not emphasized but used as a non-harmonic tone to add just the right color to a line). The same holds for the b6th.
Comment: AD, would you mind giving a few examples of B13b5#9 in context, playable by mortals?  I've been playing around with this for 15 minutes or so and ... - I think they key in your answer is the motion on the second string against the 1st string B pedal note.  Did I at least get that right? :)
Comment: Many jazz based blues songs use those types of chords because they contain the blues notes. Just remember that you don't have to play all the notes. I amended my reply. Try playing around with simple chords that you know over a static B7 chord and see which ones work well for what you want. Try adding or leaving off notes. Try keeping a pedal on the root to tie it all together(sometimes you can get away with a lot of stuff by using pedals).
Comment: The voice leading effect gives you the sense of progression of the individual lines(They don't jump around but move to the next closest chord tone). This gives the effect of coherent movement and makes it seem natural. e.g., melodies tend to move by steps and not skips and you are doing the same thing in your chords kinda treating each individual line as a melody.
Comment: Thank AD, that made it more clear.  There's a good example of what you talk about in your last paragraph about BB King in the SRV cover of Honey Bee.  The opening like is made by the hammer on/pull off on the b2.  Took me forever to get that lick right...
Comment: This is why it's very important to use your ears. Music is dynamical and theory isn't a theory about how to create good music. It can help you make sense of some things a little but will never tell you how to create good music. Why? Because context is the most important thing. You can learn a lick that will suck over the same progression but sound awesome in another simply because of the voicing's other instruments are using or how the sonority is distributed through the various instruments.
Comment: By hearing the music internally you won't go wrong expressing yourself. This is why some people are good at music and others are not. Your subconscious never chooses wrong notes. It's your conscious that gets you into trouble. You say things like "I'm going to play this lick I've learned over this chord cause I practiced it for 3 hours yesterday and it sounded good". You do that when you get up on stage and do it and it doesn't always work. Why? Because the context/situation changed. Maybe they are playing the same harmony maybe it isn't exactly the same? or maybe the feel has changed?
Comment: Knowing what are the right notes and when to play them can only come from the subconscious. You can use things like scales to narrow down the choices but then what tells you when to play notes not in the scale? What tells you that the b2nd will sound good there? You can't use theory about it because theory cannot describe such organic things(maybe one day but chances are it won't).
Comment: It's cause they their subconscious is playing those notes and it doesn't have to "think" about it. Of course one can argue that it won't always sound good too but it will always sound good to the performer because they are playing what they feel. Basically you want to reach the point where the instrument is simply expressing what you feel inside. When that happens there are no wrong notes, scales, or chords. Of course we have to start somewhere.
Comment: My point here is that if your not satisfied with things you are trying to create you should work on trying to get something to hear in your subconscious then getting it out of the instrument. Can you hear cool blues licks in your head? If not then you should put down the guitar and work on hearing music in your head. Else you have nothing to say. Once you can heard stuff in your head you then need to work on getting it out. This is started by simply hearing the "lick" and then working on playing it. It takes years to get even ok at this(of course some people are naturals).
Comment: Usually when I hear good musicians I come away hearing all kinds of music in my head and I can create solo's quite easily that I feel sound awesome. My goal is instead of just hearing them in my head is, as I'm hearing it, to be able to play it simultaneously(and not think about what I'm hearing). Obviously if I can do that then if what I'm hearing is really that awesome then what comes out will be just as awesome(or close at least). If I have to stop and think "What scale am I in" or "what note is that I'm hearing", "What is the chord", etc... then it's too late.
Comment: BTW, I'm talking about improvising/soloing. You can have a decent career doing things that don't require such abilities. Usually blues is the epitome of expression through "feeling"(maybe thats why most blues players don't know much about theory? ;)
Comment: Ha. That's probably true about blues players. One of the reasons I've always loved the blues is that there are so few notes (5) and you've got a set 12 bar progression. You have to really make it "sing" or it's just boring. There's no hiding behind theory or complex instrumentation. If there's no soul or passion in the music, it just doesn't work. Period. I find that awfully appealing.
Comment: I guess you can count me as a blues player then.  I know a little theory (I can figure out what a chord is from the notes, usually...)  I also know a little about harmonizing the major scale but that's about it.  So, are you saying the dumber about theory the better you are as a blues player? :)
Comment: As I have mentioned countless times, "Music theory" is just a language for communicating ideas. It ultimately should be useless because if everyone has amazing ears then there would be no need for it.  Of course we don't all have perfect "ears" so we do need a way to communicate with each other. But when you are trying to express your emotions the last thing you want is your logical side getting in the way telling you "You can't do that cause it doesn't make any sense(theory wise)".
Comment: @yossarian: 5 notes?  You're missing the best one that way.  The b5 is good stuff, especially with the microbends I've heard some people use. :)
Comment: @jimr, I know. There's all the minor / Dorian stuff too. Just didn't think that was really necessary for my point.