Levi Civita and Kronecker Delta identity

Question: One of the popular Kronecker delta and Levi-Civita identities reads
$$\epsilon_{ijk}\epsilon_{ilm}=\delta_{jl}\delta_{km}-\delta_{kl}\delta_{jm}.$$
Now, is there an intuition or mnemonic that you use, that can help one learn these or similar mathematical identities more easily?
Also, what is the motivation for expressing Levi-Civita symbol in terms of Kronecker Delta in the first place?
Comment: Intuition and mnemonics are not the same...
Comment: @JeanMarie If intuition isn't available, I will settle for mnemonics.
Comment: I appreciate the humor...
Comment: @JeanMarie Please answer if you can :)
Comment: Crossposted from http://physics.stackexchange.com/q/270410/2451
Comment: The indexes must be all different to obtain something that is not zero. If the ordering of the indexes is the same ($j=l$ and $k=m$), you have 1, if it is not the same (up to cyclic permutations, i.e. $j=m$ and $k=l$) you have -1, see e.g.  https://math.stackexchange.com/a/3659638/532409
Answer: I think it's helpful to see how you can actually derive this identity, using a different definition of $\epsilon_{ijk}$. I hope you are a friend of matrices and  determinants, since I am going to use that a lot in what follows now. (I will not be using the Einstein summing convention in the proof, but then again in the other parts of this answer)
$\newcommand{\vek}[1]{\boldsymbol{#1}}$
The most common definition of $\epsilon_{ijk}$ is
$$
\epsilon_{ijk}
=
\begin{cases}
1  & \text{if $\space (ijk) \space$ is an even permutation of (123) } \\
-1 & \text{if $\space (ijk) \space$ is an odd permutation of (123) } \\
0 & \text{else} \end{cases}
$$
Simply comparing the following two expressions, you can observe that

$$
\det (\vek{e}_i ~\vek{e}_j ~\vek{e}_k) = \epsilon_{ijk} ~~~~\text{for all}~~~ (ijk)
$$

Armed with this, and some linear algebra, lets tackle the identity you are interested in:
$$
\sum_{i=1}^3 \epsilon_{ijk}\epsilon_{ilm}
= \delta_{lj} \delta_{mk} - \delta_{lk} \delta_{mj}
$$

Proof
$\color{blue}{\text{If } j=k}$ then no matter the value of $i$ , every summand will be $0$ and thus the sum as a whole. So we have
$$
\delta_{lj} \delta_{mk} - \delta_{lk} \delta_{mj}
= \delta_{lk} \delta_{mk} - \delta_{lk} \delta_{mk} = 0 = \sum_{i=1}^3 \epsilon_{ijk}\epsilon_{ilm}
$$
$\color{blue}{\text{If } j \neq k}$ then there is one value of $i \in \{1,2,3\}$ , such that $i,j,k$ are all different. For this value of $i$, we have
\begin{align*}
\epsilon_{ijk}\epsilon_{ilm}
&= \det( \vek{e}_i ~\vek{e}_j ~\vek{e}_k)
\det
\begin{pmatrix}
\vek{e}_i^T \\
\vek{e}_l^T \\
\vek{e}_m^T \\
\end{pmatrix}
= \det
\begin{pmatrix}
\vek{e}_i^T \vek{e}_i & \vek{e}_i^T \vek{e}_j & \vek{e}_i^T \vek{e}_k \\
\vek{e}_l^T \vek{e}_i & \vek{e}_l^T \vek{e}_j & \vek{e}_l^T \vek{e}_k \\
\vek{e}_m^T \vek{e}_i & \vek{e}_m^T \vek{e}_j & \vek{e}_m^T \vek{e}_k \\
\end{pmatrix}
\\&=
\det
\begin{pmatrix}
\delta_{ii} & \delta_{ij} & \delta_{ik} \\
\delta_{li} & \delta_{lj} & \delta_{lk} \\
\delta_{mi} & \delta_{mj} & \delta_{mk} \\
\end{pmatrix}
=
\det
\begin{pmatrix}
1 & 0 & 0 \\
\delta_{li} & \delta_{lj} & \delta_{lk} \\
\delta_{mi} & \delta_{mj} & \delta_{mk} \\
\end{pmatrix}
\\&=
\det
\begin{pmatrix}
 \delta_{lj} & \delta_{lk} \\
 \delta_{mj} & \delta_{mk} \\
\end{pmatrix}
=
\delta_{lj} \delta_{mk} - \delta_{lk} \delta_{mj}
\end{align*}
For the other values of $i$, we either have $i=j$ or $i = k$ and thus $\epsilon_{ijk}=0$ . Thus, summing over all values of $i$, we get
$$
\sum_{i=1}^3 \epsilon_{ijk}\epsilon_{ilm}
= \delta_{lj} \delta_{mk} - \delta_{lk} \delta_{mj}
$$
Which completes the proof.

Mnemonic
\begin{align}
\require{cancel}
\epsilon_{ijk}\epsilon_{ilm}
&= \det(\vek{e}_i ~\vek{e}_j ~\vek{e}_k) ~\det(\vek{e}_i ~\vek{e}_l ~\vek{e}_m)
\\ &= \color{blue}{\det(\cancel{\vek{e}_i} ~\vek{e}_j ~\vek{e}_k) ~\det(\cancel{\vek{e}_i} ~\vek{e}_l ~\vek{e}_m)
 = \det(\vek{e}_j ~\vek{e}_k) ~\det(\vek{e}_l ~\vek{e}_m) }
\\ &= \det(\vek{e}_j ~\vek{e}_k) ~\det
\begin{pmatrix}
\vek{e}_l^T \\ \vek{e}_m^T
\end{pmatrix}
\\ &= \det
\begin{pmatrix}
 \vek{e}_l^T \vek{e}_j & \vek{e}_l^T \vek{e}_k \\
 \vek{e}_m^T \vek{e}_j & \vek{e}_m^T \vek{e}_k \\
\end{pmatrix}
\\ &= \det
\begin{pmatrix}
 \delta_{lj} & \delta_{lk} \\
 \delta_{mj} & \delta_{mk} \\
\end{pmatrix}
=
\delta_{lj} \delta_{mk} - \delta_{lk} \delta_{mj}
\end{align}
You could just remember what is marked in blue; the $\color{blue}{\text{formal canceling of } \vek{e}_i}$ . The calculation after that is pretty straight forward, and you get the correct result.

Usage of the identity
Where would you use this identity? For example if you want to prove
$$
\vek{a} \times (\vek{b} \times \vek{c} ) = \vek{b} (\vek{a} \cdot \vek{c} ) - \vek{c} ( \vek{a} \cdot \vek{b} )
$$
Because you can start at the left side of the equation (here, using Einstein summation!)
\begin{align}
\vek{a} \times (\vek{b} \times \vek{c})
&= \epsilon_{ijk} a_k (\vek{b} \times \vek{c})_i ~\vek{e}_j
\\ &= \epsilon_{ijk} a_k \left( \epsilon_{ilm} b_l c_m \right) ~\vek{e}_j
\\ &= (\epsilon_{ijk}\epsilon_{ilm}) ~a_k  b_l c_m  ~\vek{e}_j
\end{align}
where you can now use the identity to continue.
Comment: In terms of abstract orthogonal vectors, what would $\det (\vec{e}_i ~\vec{e}_j ~\vec{e}_k) $ mean? Or can this only make sense in terms of components?
Comment: Just asking because tensor analysis can be coordinate free, right?
Comment: @IonSme Yes, tensor analysis and the concept of a determinant in particular can be done in a coordinate free way. This will lead you to the topic of exterior algebras: https://en.wikipedia.org/wiki/Determinant#Exterior_algebra
Answer: Here is a new reference
Another reference explaining how one can generalize Levi Civita symbol.
Comment: If you read both questions carefully, you'll notice there is an extra line of text present in this question
Comment: Nevertheless, you should mention your previous question.
Comment: Alright, that also has been linked now
Comment: Very well. I modify my answer accordingly.
Comment: I'd like to ask you something, that when you deal with indicical notation. Is it still like a compressed form of the rules have been given to you and you basically have to evaluate the final result component by component only in the end?
Comment: And you have certain set of algebraic rules called "Tensor Algebra" which are proved in general, for all the components and you can do these manipulations on your expression given in indicical notation, to shorten it so that the number of calculations per component reduces, but still in usual scenarios, but ultimately you've to evaluate each component separately and carefully, one by one?
Comment: I'm sorry, I'm new to this notation, so it's kind of troubling me to apply it in calcuations
Comment: Do you know the  **Einstein contraction rule** which governs this notation : whenever 2 identical indices are found in a product, one upper and the other lower, it means that there is an (omitted) summation. For example $f_q^n=g^{np}h_{pq}$ means $f_q^n=\sum_{p=1}^{p=n}g^{np}h_{pq}$ (in this case it is the definition of a matrix product). But in some cases (your notations) all indices are... as indices.
Comment: Yes, I know. May be I need to some solved examples for this. Thanks for your help :)
Comment: Broken first link @JeanMarie


Como selecionar somente a classe sem a classe filha em javascript puro

Question: Boa tarde, estou desenvolvendo um modal em javascript puro.
O que ocorre é o seguinte... o script detecta que existem tag com a classe "modal"
, e quando encontra uma ou mais ele insere as tags com as classes já definidas.
O que ocorre... uma das funções insere uma div dentro dessa div com a seguinte classe

 e dessa forma ele entra como mais um item dentro do laço do javascript.Existe alguma forma de selecionar somente o modal que não tenha outra classe dentro? Eu estou usando essa chamada no meu javascript
var modal = document.getElementsByClassName('modal');
modal[i].innerHTML = "

"

Meu CSS está dessa forma.
    .modal>.loading {
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 10%;
    background: url(loader.gif) center no-repeat;
}

Answer: Você pode detectar usando querySelector, que retornará falso se não houver a div com a classe que você procura.

A vantagem de usar querySelectorAll em vez de
  getElementsByClassName é que o primeiro permite seletores CSS
  completos.

// aqui selecione apenas as divs com .modal sem .loading
var modal = document.querySelectorAll('div.modal:not(.loading)');

for(var item of modal){
   if(!item.querySelector("div.loading")){ // verifica se a div com a classe .loading existe dentro da modal
      console.log('A '+item.innerText+' não possui ".loading"');
   }
}
/* Estilos apenas para ilustração */
div.modal:not(.loading){
   display: block;
   width: 100px;
   margin: 10px 0;
   background: red;
}

Loading

   modal 1

   modal 2

   modal 3

Loading

   modal 4

Comment: A resposta esta quase perfeita, só uma dúvida referente, existe alguma maneira no querySelectorAll de selecionar exatamente aquela uma classe ao invés de passar o parametro do :not()?
Comment: @김무진 Selecionando só .modal?
Comment: Perdão fui implementar o código adaptando a coisa esqueci de inibir o anterior, isso resolveu meu problema
Answer: Você pode utilizar o pseudo selector :not(), no seu caso, para não selecionar a classe .loading você pode usar esse seletor:
.modal:not(.loading){

}

Comment: Meu problema é a seleção no javascript não no CSS


Volume of a parallelepiped, given 8 vertices

Question: Given the eight vertices $(0,0,0)$, $(3,0,0)$, $(0,5,1)$, $(3,5,1)$, $(2,0,5)$, $(5,0,5)$, $(2,5,6)$, and $(5,5,6)$, find the volume of the parallelepiped.
I'm having trouble finding the 1 vertex and 3 vectors needed to find the volume. The closest four vertexes I found so far are $(0,0,0), (3,0,0), (0,5,1), (3,5,1)$...is using those four vertexes correct? Any starting hints to point me in the right direction?
Comment: No. Notice that your 4th equals the sum of the 2nd and 3rd: $$(3,5,1) = (3,0,0) + (0,5,1)$$ So you want a different 4th; you can identify it as some of the subsequent vertices are equal to a sum involving it.
Comment: @SimonS: Is the volume of the parallelepiped the absolute value of the determinant of the matrix: $\begin{pmatrix} 3 & 0 & 0 \\ 0 & 5 & 1 \\ 2 & 0 & 5 \end{pmatrix}$?
Comment: But note that by adding constant vector $ (2,0,5)$  to first 4 points you get next 4 points; and that there is no change of y-coordinate, and so it is like a shear deformation from rectangle to parallelogram.Sketching by hand in 3D projection helps.
Comment: In theory it can, but that would a degenerate parallelepiped in the sense that it has zero and lie entirely in a plane. Your parallelepiped is not degenerate.
Comment: It is natural to focus on the vertex at $(0,0,0)$. What are the three other vertices whose squared distances from $(0,0,0)$ are smallest? Like @SimonS says, your fourth point has $3^2+5^2+1^2$ which is not on the "top-3" of smallest squared distances. *Addition:* Wait, for some very long and slim parallelepipeds it may happen that the surface diagonal on the tiny side on the end is shorter than the long edge.
Comment: You can confirm that by making sure the four other vertices are simple sums of the first three (excluding (0,0,0)), in the sense that the coefficients in the sum are 1 or 0. That way you know we're dealing with a volume which has parallel sides and that the first three you have found give the three directions of the 12 sides.
Comment: Ok. What's your final answer?
Comment: @SimonS: The vertex is $(0,0,0)$ and the three vectors are...$(3,0,0), (0,5,1), (2,0,5)$?
Comment: And the volume?
Comment: Yes ............ my work is done ;-)
Comment: @SimonS: Thanks so much for the help! :) If you would like to write an answer for it, I will upvote & select it.
Answer: Hint:
If the origo is among them, the set of vertices of a parallelepiped is of the form
$$\{0,\ a,\ b,\ c,\ a+b,\ a+c,\ b+c,\ a+b+c\}$$
for some vectors $a,b,c$.
Then write the coordinates of these $a,b,c$ in a matrix and calculate its determinant.


faulting module msvcrt.dll, what is msvcrt.dll?

Question: I have Apache version 126.96.36.199 running locally serving a PHP application that connects to a Firebird database.  Recently, I have been having problems with Apache crashing, as best as I can tell, randomly.  I get the following error message:
<code>Faulting application Apache.exe, version 126.96.36.199, faulting module msvcrt.dll, version 7.0.2600.5512, fault address 0x00036137.

0000: 41 70 70 6c 69 63 61 74   Applicat
0008: 69 6f 6e 20 46 61 69 6c   ion Fail
0010: 75 72 65 20 20 41 70 61   ure  Apa
0018: 63 68 65 2e 65 78 65 20   che.exe
0020: 32 2e 30 2e 35 39 2e 32   184.108.40.206
0028: 30 30 20 69 6e 20 6d 73   00 in ms
0030: 76 63 72 74 2e 64 6c 6c   vcrt.dll
0038: 20 37 2e 30 2e 32 36 30    7.0.260
0040: 30 2e 35 35 31 32 20 61   0.5512 a
0048: 74 20 6f 66 66 73 65 74   t offset
0050: 20 30 30 30 33 36 31 33    0003613
0058: 37

                 7
</code>
I'm not sure what msvcrt.dll does, or why it would be crashing randomly.  Here is a screenshot of the event in the Application Event Viewer.
https://i.stack.imgur.com/Jrq2Z.jpg
If anyone has experience with similar crashes or knows what msvcrt.dll does, I would love the help.
Answer: MicroSoft Visual C RunTime.  This is essentially the C standard library, which is used in most C/C++ programs --- or in other words, most programs.  Don't assume that msvcrt is what's causing the crash; it's much more likely to be the program giving the wrong information to the standard library, and making it crash.
Basically, same procedure as any other bug in software: go get the latest (unmodified) version of the software, and see if that works.  If it doesn't, check you're using it right.  If it still doesn't, then look at the bugs for the program you're using, and if you can't find such a bug report the problem to them.  They should get a fix made, or at least show that the problem is not theirs, and that you should bug microsoft about msvcrt.
Chances are, it's something wrong with your configuration of apache and/or PHP, or it's a fault with Apache on windows (since that's a relatively unstable version compared to apache on unix).
Answer: Micro s oft Visual C++ Run t ime provides standard C++ library routines.
The first thing I would try is refreshing a copy of that file.


Oracle 10g install on Windows 7 where to go the 10.2.0.5 Patch?

Question: Hi i'm trying to get a couple of clients up and running, these are Windows 7 based machines 1 is 32bit the other 64. I have the install files for 10.2.0.3 and 10.2.0.4 for these environments but they require a patch file to update them to 10.2.0.5. This patch is only available to Support level Oracle logins, which I dont have, does anyone know where else I can get these patch files from?
files I curently have are
10203_vista_w2k8_x86_production_client.zip
10204_vista_w2k8_x64_production_client.zip
p8202632_10205_MSWIN-x86-64.zip
The last one is the Patch but only for 64 bit windows 7, I now require the 32bit version...
Answer: If you don't have a login to metalink, this suggests to me that perhaps you don't have an Oracle licence?
In which case wouldn't be entitled to software patches/updates.
Comment: thanks cowboy, but Oracle Licences are server based so for installing a client there shouldn't be any restriction. I dont know why Oracle hide the patch behind this requirement all of their client software is available using a normal logon.  the Patch is heavyWeight and I think it may contains DB stuff! So as far as I'm concerened my question still stands.
Comment: PurpleMonkey - Cagcowboy is correct.  The Oracle Support provides different options.  You can get access to support, patches and upgrades, etc based on the levels of support you "pay" for.  We are a development shop that supports both SQL and Oracle and we have to buy an oracle support so we can get these for testing.  I suggest you get with the DBA's managing the servers you are connecting the clients to to get the patches you require.
Comment: Thanks for the details, that makes sense in a way. Shame as I will have to wait for my DBA's to come though. cheers.


Use of prime symbol in proof writing

Question: Questions:
So I looked through my course notes and saw this proof. I understand the content, but I'm confused about the use of the prime symbol. If we say that there is some $j'$ such that it is a natural number, and $n = 2j' + 1$, what is the purpose of declaring $j$ on the following line?
Here is the proof of if n is odd, n$^2$ is also odd, from my notes:

Assume $n \in \mathbb{N}$.

Assume n is odd.

Then, $\exists j' \in \mathbb{N}, n = 2j' + 1$. # by definition of n
odd

Let $j \in \mathbb{N}$ be such that $n = 2j + 1$. # name it j
Then $n^2 = 4j^2 + 4j + 1 = 2(2j^2 + 2j) + 1$. # definition of $n^2$
Then $\exists k \in \mathbb{N}; n^2 = 2k + 1.$ # $2j^2 + 2j \in \mathbb{N}$, since N closed under +;
Then $n^2$ is odd. # by denition of $n^2$ odd

Then n is odd $\implies$ n$^2$ is odd.

Then $\forall n \in \mathbb{N}, $n odd$ \implies n^2$ odd.

A few more questions:
If done this way, could I simply just continue using $j'$ rather than declaring $j$? As in, could I just write $n^2 = 4j'^2 + 4j' + 1$ and skipped the let statement instead?
Is there a reason that $k$ is used instead of something like $j''$?
Thanks for your time. Apologies for the formatting.
Comment: Need to use $j$, not $j'$, which was just a "dummy" variable for the existential quantification.
Comment: But note that the writer is being rather more precise than many people would feel it necessary to be.
Comment: A serious problem that is peculiar to the letters I and J is that the lowercase form's dot can crash with the prime symbol: compare $a$ and $a\prime$ to $i$ and $i\prime$.
Comment: Interesting. I just realized you used the apostrophe whereas I used the TeX command. So, for the sake of comparison: $a$ and $a'$, $i$ and $i'$, and also $j$, $j\prime$ and $j'$.
Answer: Statements $\exists a, \Phi(a)$ and $\exists b, \Phi(b)$ are equivalent and interchangeable (apart from technical details that the variables may not occur "hidden" in $\Phi$; for example $\exists a,a+3b=5$ is not equivalent to $\exists b,b+3b=5$). The same holds for $\forall a,\Phi(a)$ and $\forall b,\Phi(b)$.
Now regarding the rulkes of inference used: If we know $\exists a,\Phi(a)$, we are allowed to pick and work with an object, $b$ say, that makes this true, i.e. a $b$ such that $\Phi(b)$. It may be clearer to name this specific $b$ different from the $a$ used inthe quantifier. Then again, as we might have just as well started from $\exists b,\Phi(b)$ it seems that nothing forbids us to use the same variable name. The author chose to not keep the variable name and in order to end up with the desired $j$, he started with something different, namely $j'$.
Likewise at the end: If we derive $\Phi(x)$ for some expression $x$, then we may conclude $\exists a,\Phi(a)$ (with similar caveats about the variable $a$) and again the specific quantifier variable used doesn't matter. It should of course not be the same as some variable already defined in the current "scope" as one would say in programming. So $j''$ instead of $k$ would indeed be fine, but would that look nicer?
Comment: If you started with $\exist j$, your instructor would likely want you to use a different symbol for an (in this case the) actual object $w$ such that $2w+1=n$.
Comment: Just to make sure I understand correctly, j' (or whatever prime) is often used as a dummy variable (from previous comment), so I should use j instead, but if I start out by just writing \exists j in N, there would be no reason to declare another variable to takes its place? Thanks again

Use of prime symbol in proof writing


Chinese remainder theorem as sheaf condition?

Question: The chinese remainder theorem in its usual version says that for a finite set of pairwise comaximal ideals $R/\bigcap _jI_j\cong \prod _j R/I_j$.
In the binary case, the following general statement holds without conditions on the ideals $R/(I\cap J)\cong R/I\times _{R/I+J}R/J$. In this question I wanted to generalize the more general version to several ideals, but got stuck and only contrived an ad hoc justification for pairwise comaximality.
A few weeks ago I finally thought of $R/(I\cap J)\cong R/I\times _{R/I+J}R/J$ as a sheaf condition for a cover by two elements. Then I told myself the diagram below must be an equalizer, because pairwise comaximality pops out of it so naturally.
$$R/\bigcap _jI_j\rightarrow \prod _j R/I_j \rightrightarrows \prod _{i,j}R/(I_i+I_j)$$
Several satisfied days later I stumbled upon this comment which to my dismay says the diagram above fails to be an equalizer for more than three ideals. But it just seems so perfect...
Can anyone give some counterexamples which show why the diagram above is not an equalizer and explain why things fail geometrically?
Comment: It would be weird for that diagram to be an equalizer since the first map is already an isomorphism! And the geometric way of thinking about this is that the vanishing sets of comaximal ideals are disjoint in Spec R, and disconnected Spec's are the Spec of the products of the coordinate rings of the components.
Comment: @DylanWilson I'm asking about the general case, in which the ideals are not assumed comaximal.
Answer: Each ideal $I\subset R$ corresponds to a closed subscheme of $\mathrm{Spec}(R)$, intersection of ideals corresponds to union of subschemes, and sum of ideals corresponds to intersection of subschemes. If a finite collection of closed subschemes is an open cover of their union (which is the case if and only if the union is disjoint), then indeed your diagram is an equalizer, precisely because of the sheaf condition. But in general the sheaf condition won't hold for coverings by closed sets.
A counterexample: let $k$ be a field, $R=k[x,y]$, $I_1=(x)$, $I_2=(y)$, $I_3=(x-y)$. Then $\mathrm{Spec}(R)$ is the affine plane and the ideals $I_1$, $I_2$, and $I_3$ correspond to the lines $L_1:x=0$, $L_2:y=0$, and $L_3:x=y$. The statement that your diagram is an equalizer is equivalent to the statement

the data of a regular function on $L_1\cup L_2\cup L_3$ is the same as the data of a triple of regular function $f_1$, $f_2$ , $f_3$ on $L_1$, $L_2$, $L_3$ resp., such that all three functions take the same value at the origin.

This is false because we need an extra condition on the functions $f_1$, $f_2$, $f_3$, namely for these functions to determine a function on $L_1\cup L_2\cup L_3$, the derivative of $f_3$ in the direction $(1,1)$ needs to equal the sum of the derivative of $f_1$ in the direction $(0,1)$ and the derivative of $f_2$ in the direction $(1,0)$.

The data of $\prod R/I_j$ and the maps to $\prod R/(I_i+I_j)$ corresponds to data of a bunch of closed subschemes and their pairwise intersections. This is not enough to determine a scheme. For instance, the union $L_1\cup L_2\cup L_3$ is not isomorphic to the union of the coordinate axes in $\mathbb{A}^3$, because the tangent space to the former at the singular point is $2$-dimensional, while the tangent space to the latter is $3$-dimensional. But both schemes are the union of three lines, such that the pairwise intersection is a single point. For the example $I_1,I_2,I_3\subset R$ above, the equalizer of your diagram is the coordinate ring of the union of the coordinate axes in $\mathbb{A}^3$, rather than of $L_1\cup L_2\cup L_3$.
Comment: Thanks for the instructive answer! I have asked about the equalizer of $\prod _j R/I_j \rightrightarrows \prod _{i,j}R/(I_i+I_j)$ [here](http://math.stackexchange.com/questions/1602201/description-of-the-equalizer-of-prod-j-r-i-j-rightrightarrows-prod-i-jr) - perhaps you could answer that question as well :)


Setup FreeRADIUS on windows

Question: Can any one suggest where to download "FreeRADIUS" server (2.2.3) .exe for windows?

I tried downloading 1.1.7 from Downloads | FreeRADIUS. It works fine but it doesn't work for TLS security.
The WIFI module provider suggested that download 2.2.3 version and it will work.
I tried searching internet through out but could not get the .exe of setup.
Comment: Are you using Windows Server? Because if so, just deploy NDES and a local PKI from the AD CS service.
Answer: FreeRADIUS is not distributed for Windows. I did find WinRADIUS which looks like it's a Windows port of FreeRADIUS.

Setup FreeRADIUS on windows


How do I find the $\sup\{s_{n+1}-s_n|n\geq 1\}$?

Question: Let $\{s_n\}$ be a sequence in $[0,1]$. Assume that $2s_n\leq s_{n-1}+s_{n+1}, n\geq 1.$ Then

$\lim_{n\to \infty}s_{n+1}-s_n=\text{doesn't exist}$
$\lim_{n\to \infty}s_{n+1}-s_n=0$
$\lim_{n\to \infty}s_{n+1}-s_n=\frac{1}{2}$
$\lim_{n\to \infty}s_{n+1}-s_n=1$

My attempt:-
$$2s_n\leq s_{n-1}+s_{n+1}$$
$$\implies s_n-s_{n-1}\leq s_{n+1}-s_n$$
$$\implies (s_2-s_1)  \leq...(s_{n-1}-s_{n-2})\leq (s_n- s_{n-1}) \leq ( s_{n+1}-s_{n}) $$
Hence the sequence $\{s_{n+1}-s_n \}$ increasing and bounded above. Hence $\lim_{n\to \infty}s_{n+1}-s_n=\sup\{s_{n+1}-s_n|n\geq 1\}$
So, option(1) is wrong.
How do I find the supremum of $\sup\{s_{n+1}-s_n|n\geq 1\}$?
Answer:
is true. Here is a hint; If $l=\lim (s_{n+1}-s_n) >0$ then $s_{n+1} >s_n+\frac l 2$ for $n$ sufficiently large. Iterate this to get the contradiction that $s_n >1$ for $n$ large enough. Similarly, $l <0$ would give $s_n <0$ for $n$ large enough.
Comment: can you please elaborate on how did you arrive at the contradiction that $s_n > 1$ ?


Using boto3/MQ to list queues on a MQ broker

Question: I've tested the methods listed here: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/mq.html, but none return the actual queues running on the broker.
Is there a way to list the queues running on a broker using Boto3?
I'd like to get the queues so I can programmatically create dashboards e.g.
Region ap-southeast-2
Namespace AWS/AmazonMQ
Metric name MessageUnacknowledgedCount
Broker mybroker
VirtualHost /
Queue default

Comment: Probably you have to use MQ native API for that. Not boto3.
Answer: I'm not recommending this but it works in this situation.  So there was no direct access to MQ so it wasn't possible to query it directly.  Instead, I queried the Cloudwatch API to obtain the queue names e.g.
client = conn.client('cloudwatch')
response = client.list_metrics(
        MetricName = "MessageUnacknowledgedCount",
        Namespace='AWS/AmazonMQ',
        Dimensions=[
            {"Name": "Broker", "Value": "my-mq-instance"},
        ],
    )

#Don't include queue names that match this pattern.
pattern = re.compile(r'celery@.*\.celery\.pidbox$')

queue_names = [
        dimension['Value']
        for metric in response['Metrics']
        for dimension in metric['Dimensions']
        if dimension['Name'] == 'Queue' and not pattern.match(dimension['Value'])
        and not dimension['Value'].endswith('dead_letter')
        and not dimension['Value'].startswith('celeryev')
    ]


C++ pointers runtime error - setting a variable with pointers then retrieving

Question: I'm setting up a prototype c++ console application.
The program contains some virtual classes and pointers etc.
When the program reaches the lines of code below in the main function it crashes. I believe it is something to do with accessing the memory at that pointer.
main()
...
Player _player();  //new player object created
Actor *player = &_player;  //pointer to player created

...
//note player and get_inventory() are/return a pointer
{
 Inventory* a =  player->get_Inventory();
 a->set_testMe("testedMe");
 string result = a->get_testMe();
 cout << result << endl;
}

{
 Inventory* a =  player->get_Inventory();
 string result = a->get_testMe();  //This causes error
 cout << result << endl;
}
...

Actor.cpp //get_Inventory()
...
Inventory* Actor::get_Inventory()
{
    Inventory mInventory = this->actorInventory;
    Inventory * pInventory = &mInventory;
    return pInventory;
}
...

Inventory.cpp
...
Inventory::Inventory()
{
this->testMe = "initial test";
}

void Inventory::set_testMe(string input)
{
    this->testMe = input;
}
string Inventory::get_testMe()
{
    return this->testMe;
}
...

Any ideas?
Thanks
Comment: If you split that statement into several steps, like saving the return of `player->get_Inventory()` in a variable, you can more easily check if it's a `nullptr`. Also, can you please show the declaration of the `testMe` variable?
Comment: What does the `get_Inventory()` function do/return
Comment: Show us your testcase.
Comment: are you sure player is not NULL and get_Inventory() is not NULL.  you are not showing enough code to guarantee the pointers are valid.  the Inventory snippets look fine.
Comment: Ok I have split up the first statement in two as suggested. This seemed to work but when trying to retrieve the testMe string again from another block it crashed at runtime again.
I have edited the above code to match.
Give me a min and I will add the other functions too.
Thanks for the help!
Comment: Have you tried debugging and inspecting the pointers used and returned?
Comment: `Player _player();` declares a function `_player` that returns a `Player` - either change this to `Player _player{};` or simply `Player _player;` to define a variable `_player`
Comment: @melak47 In my original code this is - Player _player(a) where 'a'is a string passed to the constructor. Could this be causing the problem?
Answer: This returns a pointer to a local variable:
Inventory* Actor::get_Inventory()
{
    Inventory mInventory = this->actorInventory;
    Inventory * pInventory = &mInventory;
    return pInventory;
}

The first statement copies this->actorInventory into a local variable (as in, local to the method get_Inventory), and then returns a pointer to that local variable.  Once you return from get_Inventory(), that variable goes out of scope and no longer exists.
You may want to try returning a pointer to this->actorInventory directly:
Inventory *Actor::get_Inventory()
{
    return &actorInventory;
}

Or, if you don't want the caller modifying actorInventory, return a const qualified pointer:
const Inventory *Actor::get_Inventory() const
{
    return &actorInventory;
}

Comment: Brilliant! Thanks that was exactly it. I thought that seemed like a lot of code to just return a pointer. I initially tried 'return &this->actorInventory; which clearly didnt work.


How to check if jQuery is already in cache?

Question: Is there anyway to check on a client if jQuery was loaded before from a CDN? I mean to have code like this:
if (jQuery.isLoadedFromCDN)
//DoNothing
else
//load from internal resource

NOTE that I don't want to check that jQuery is loaded, but specifically if it was loaded from a CDN.
The context is that I have an internal LAN web app that uses jQuery, loading jQuery from the LAN is definitely faster but if it already was downloaded before from a CDN (which is probably the case) then I just want to use that otherwise I want to get it from our internal resource not the cdn. The bandwidth saving is definitely not huge, but I am more curious to know if that's technically possible.
Answer: I'm guessing you're checking to see if jQuery was loaded from the Google Libraries API?
Your browser will cache jQuery whether it's from the CDN or from your LAN. If it's already in the cache from a previous retrieval from the CDN, it'll load faster than from your LAN. If it's not already in your cache from either a previous visit to your site, or another site using the same CDN, it'll only need to load once: subsequent visits will load from the cache.
Splitting the URL for jQuery between the CDN and your LAN will just cause two copies to get cached. Let the browser cache do what it was meant to do. :)
Answer: This should do it:

You need to adapt the path for the fallback, which should be located at your domain.
Comment: @lonesomeday: just fixed that, I copied those lines from an older source.
Comment: @jAndy unescape is deprecated! can you suggest a better alternative?
Answer: to my knowledge, that's not really possible.
2 things jump to mind however that can help you:

Use Etags: Identify your resources on the webserver side. This way, your browser does that work for you: identify if a resource is already loaded, regardless from the domain it was loaded from
If you really want to know which domain jQuery was loaded from, you can do dummy AJAX requests. You can only do AJAX requests from the same domain your library was loaded from (except ofcourse when doing a JSONP request). So if your jQuery was loaded from your LAN resource, you will get trplies to AJAX requests to your LAN webserver, and that rules out the CDN.

Hope it helps,
Bart


How to start with halfpipe snowboarding?

Question: For somebody that is a little experienced with regular snowboarding (around 10 years of basic snowboarding), what would be the ideal way to starting halfpipe snowboarding?

I have done some research and saw that there are some basic tips on the halfpipe snowboarding   out there. This source suggests just delving right to it, the only precursor is having to buy a helmet. Similarly, this one suggests:

When riding the Halfpipe for the first time, it is important that you practice first. You can do this by simply traversing the transitions of the Halfpipe[…]

I am not entirely sure if jumping right to it (without any schooling) is the best idea there is (judging from my experiences with jumping the bumps on my own and causing many issues).
In your experience, having clocked some snowboarding time, what would be the best way to start the halfpipe?
Comment: Have you tried halfpipe/quarterpipe skating?  I was into skating a few years back and was told that the best way is just to do it - seems like the advice between the two sports is the same.  I don't know how the skills between skating and snowboarding compare, but I expect they're reasonably similar in terms of balance and mental attitude :)
Comment: @LordScree Unfortunately I haven't.. I understand that the advice might be just to get the gist of it, but I want to avoid any potential injuries. Or limit them as much as I can :)
Answer: If you want to avoid injury, take it slow. I would suggest traversing the transitions as the second link suggests. Start at the bottom of the transition on one side and practice cutting back to the transition on the other side. With each run, you will feel more confident. You should be able to climb higher into the transitions with each run, until you eventually catch the vertical. The first few times you catch the vertical, focus on safely landing. After that, work on simple tricks. Once you've mastered those, work on tricks that are a little more difficult. If you still have difficulty performing tricks over jumps in a board park, I would suggest a little more practice there before you try any tricks on a halfpipe. The halfpipe is a lot more dangerous than a board park because you can easily accelerate faster than intended, which means you can accidentally catch a lot of air. If you don't know how to safely land, you may end up landing in the transition and go for a nasty spill. If you are confident you can safely land (even in the transition), I'd say you are well prepared to try halfpipe. Accidents are to be expected when learning, but please do review safe landing techniques before trying the halfpipe. You might do this by watching halfpipe videos on youtube. Even videos where people crash will be of great help as they will teach you what not to do. Best of luck!
Answer: Everyone will have his/her own opinion on the matter. One way might work well for one person and another way will work better for another. The important thing is to stay safe and know your limits. I've been snowboarding for six years and this is what I found to work well for me:
It was my third season and one of the lift operators suggested that I try out the halfpipe. The snow was very soft that day, so the conditions were ideal for learning. She was right; the snow cushioned my (numerous) falls, but I eventually started pulling off some jumps. Traversing can definitely be helpful, but so can linking the turns and carving. I learned by carving on a 45 degree angle (not 90 degrees), making a jump as I turned my body, and landing.
Some people have claimed that starting out in the park first is better. In all honesty, I started in the halfpipe first and I was fine. I think it depends on what kind of riding you'd like to do because the type of board you use for the halfpipe should be different from the board you use for the terrain park. This is because you need excellent stability and edgehold when tackling the halfpipe, which requires a stiffer board. The terrain park, on the other hand, has rails, boxes, and many other obstacles that require a board that can take punishment. A flexible board is good for absorbing impact. Also, you don't want to have sharp edges in the terrain park because sharp edges will catch on rails and such (however,you want to have sharp edges for the halfpipe).
It is important to land properly, but you don't have to practice in the terrain park to do it. You can easily find a wall on a regular slope to practice going up on and can even try springing up over small lumps of snow. Again, when the snow is soft, you can practice jumping on the halfpipe. If you're concerned about falling, you can purchase some body armour, but I can honestly say that I've never worn any and I was fine practising (I have never seriously injured myself when snowboarding). It's your call.
A couple of tips: be sure to bend your knees to absorb impact, watch some videos online and read some literature on the subject, and (if you want) get an advanced lesson. First and foremost, stay safe.


jQuery disable and clear values of a (Select2) field

Question: I have a field that works with Select2 called location, where a user can enter one or more locations. Then I have a checkbox noCity which can be checked by the user if there is no location.
What I try to archieve: when noCity is checked, location is disabled, the placeholder removed, and all values cleared.
What I have archieved: when noCity is checked, location is disabled, when unchecked, enabled and when the form is loaded and noCity was checked, disabling is done correctly as well.
My issue: I cannot seem to remove the values of the field location, nor the placeholder. .attr("placeholder", '', this) and  .val('', this) do not seem to work and other tryouts have failed.
My code so far:
$('#location').select2({
placeholder: 'Enter a city'
});

$("#noCity").click(function () {
    if (jQuery(this).prop("checked")) {
        jQuery("#location")
            .prop("disabled", this)
            .attr("placeholder", '', this)
            .val('', this)
        ;
    } else {
        jQuery("#location")
            .prop("disabled", false)
            .attr("placeholder", 'Enter the name of the city')
            .val('')
        ;
    }
});

if ($('#noCity').is(':checked')) {
    jQuery('#location')
        .prop('disabled', this)
        .attr('placeholder', '')
        .val('');
}

and html:
Location: <select id="location" multiple="multiple" style="width: 300px">
<option>New York</option>
<option>Hong Kong</option>
<option>Amsterdam</option>
</select>

No city:<input id="noCity" type="checkbox">

Here is a JSFiddle
My question: how can I make sure that when noCity is checked, location is disabled, the placeholder removed, and all values cleared (while also when noCity is unchecked the field location is enabled again and the placeholder back)?
Edit: my question is similar to this one, however I try to implement this when a checkbox is unchecked (which still not works) and I use Select2 version 4 which works differently.
Comment: You want when noCity is checked, location's value will be empty, right?
Comment: Yes, emty and without a placeholder.
Answer: You just add the following code into noCity is checked event. I run test and it's OK :))
$("#location").select2().val("0").trigger("change");

Comment: Thank you for your suggestion. I did what you said as `if ($('#noCity').is(':checked')) {
$("#location").select2().val("0").trigger("change");`, but nothing really changes. Could you tell me what I do wrong?
Comment: Wait, I got it, it was in the wrong event. It's all working now, thank you!


Solaris 10 zone network configuration

Question: I am testing out zones on Solaris 10, release 10/09 (s10x_u8wos_08a) with Generic_142901-04 kernel.
The host server has two physical NIC's (bnx0 and bnx1), and since I am intending to run several (three or more) zones, dedicating a NIC to a zone is out of the question. Presently, I do not have any "dedicated" IP-addresses assigned to these zones, so I'm obtaining leases from DHCP.
My questions, which we'll get back to once I've shown you my current setup, revolve mainly around this network configuration.
Here are the steps (with some additional information) I took to set up the zone:
erikn@global:~ $ zpool status zpool1
  pool: zpool1
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        zpool1      ONLINE       0     0     0
          c1t1d0    ONLINE       0     0     0

errors: No known data errors

erikn@global:~ $ zfs list zpool1
NAME     USED  AVAIL  REFER  MOUNTPOINT
zpool1  84.1G   183G  6.14G  /zpool1

erikn@global:~ $ pfexec zfs create zpool1/zones

erikn@global:~ $ pfexec zfs set mountpoint=/zones zpool1/zones

erikn@global:~ $ pfexec zonecfg -z test \
> 'create -b ;
> set zonepath=/zones/test ;
> verify ;
> commit'

erikn@global:~ $ zoneadm list -vic
  ID NAME             STATUS     PATH                           BRAND    IP
   0 global           running    /                              native   shared
   - test             configured /zones/test                    native   shared

I proceeded to install the zone
erikn@global:~ $ pfexec zoneadm -z test install
A ZFS file system has been created for this zone.
Preparing to install zone <test>.
Creating list of files to copy from the global zone.
Copying <196614> files to the zone.
Initializing zone product registry.
Determining zone package initialization order.
Preparing to initialize <1595> packages on the zone.
Initialized <1595> packages on zone.
Zone <test> is initialized.
Installation of these packages generated errors: <SUNWvbox SUNWpostgr-83-server-data-root CSWcacertificates CSKmysql32 SUNWpostgr-82-libs SUNWpostgr-82-server SUNWpostgr-82-client SUNWpostgr-82-devel CSKphp5 SUNWpostgr-82-contrib CSKapache2 SUNWpostgr-82-server-data-root>
Installation of <1> packages was skipped.
The file </zones/test/root/var/sadm/system/logs/install_log> contains a log of the zone installation.

So some packages generated errors, but that doesn't concern me much since I do not need them inside this zone anyway.
The install exited with zero anyway.
erikn@global:~ $ echo $?
0

I booted up the zone
erikn@global:~ $ pfexec zoneadm -z test boot

And connected to the "console".
erikn@global:~ $ pfexec zlogin -C test

I followed the installation; selecting a language (English), setting the locale (U.S.A. (en_US.ISO8859-1)), terminal type (DEC VT100), giving it a hostname (test), setting time zone (Europe/Oslo), setting a root password ("password123" - no, just kidding).
Changed the root shell to bash:
# usermod -s /usr/bin/bash root
UX: usermod: root is currently logged in, some changes may not take effect until next login.

Logged out and in again.
Since there were a lot of enabled services (including telnet and finger), I figured it'd be easier to disable everything and then re-enable services untill I had a working system.
-bash-3.00# svcs | grep " svc:" | sed "s/ \{1,\}/ /g" | cut -d' ' -f3 | \
> xargs svcadm disable

Doing this resulted, as expected, in the zone entering System Maintenance Mode.
I re-enabled all the milstone services:
-bash-3.00# svcs -a | grep " svc:/milestone/" | sed "s/ \{1,\}/ /g" | \
> cut -d' ' -f3 | xargs svcadm enable

Enabled sshd and syslogd.
-bash-3.00# svcadm enable svc:/network/ssh:default
-bash-3.00# svcadm enable svc:/system/system-log:default

Looped over dependency services, enabling them:
-bash-3.00# while [ $( svcs -xv | wc -l ) -gt 0 ] ; do
> svcs -xv | grep "^svc" | cut -d' ' -f1 | xargs svcadm enable
> done
Hostname: test
Reading ZFS config: done.

Enabled console-login and checked the status.
-bash-3.00# svcadm enable svc:/system/console-login:default

-bash-3.00# svcs -xv
svc:/system/console-login:default (Console login)
 State: offline since August 27, 2012 11:38:04 AM CEST
Reason: Unknown.
   See: http://sun.com/msg/SMF-8000-AR
   See: man -M /usr/share/man -s 1M ttymon
Impact: This service is not running.

Rebooted the zone.
-bash-3.00# reboot

Was greeted by the console login prompt. Logged in. Checked service status:
-bash-3.00# svcs -xv

No output is good output.
Halted the zone and took a snapshot from the global zone for good measure.
-bash-3.00# halt
Aug 27 12:10:08 test halt: halted by root
Aug 27 12:10:09 test syslogd: going down on signal 15

[NOTICE: Zone halted]
~.
[Connection to zone 'test' console closed]

erikn@global:~ $ pfexec zfs snapshot zpool1/zones/test@neat

After this, I booted up the zone again, figured out the dependency order of the packages which were installed (using this the "pkgdep" script found here), and removed some of the stuff that I didn't need.
Next, it was time to configure the network, which is what this question is about.
From the global zone, I created a logical interface and assigned it to the zone "test".
erikn@global:~ $ pfexec ifconfig bnx1:1 plumb zone test

We can verify that this was assigned to the zone:
-bash-3.00# ifconfig bnx1:1
bnx1:1: flags=1100842<BROADCAST,RUNNING,MULTICAST,ROUTER,IPv4> mtu 1500 index 5
        inet 0.0.0.0 netmask 0

Now, since the zone is configured with IP-type "shared", it won't be able to send DHCP requests on the interface. Therefore, we do it from the global zone:
erikn@global:~ $ pfexec ifconfig bnx1:1 dhcp start
ifconfig: bnx1:1: wait timed out, operation still pending...

That didn't go too well, now did it?
erikn@global:~ $ echo $?
4

Back to the zone.
-bash-3.00# ifconfig bnx1:1
bnx1:1: flags=1104843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,ROUTER,IPv4> mtu 1500 index 5
        inet 10.0.6.92 netmask fffffc00 broadcast 10.0.7.255

Well, we have an IP-address... (Here, I have replaced the network with 10.0.4.0/22, but the netmask is the same).
We modify our /etc/nsswitch.conf and /etc/resolv.conf to use our name servers.
Since we are using a HTTP proxy on our network, we must remember to export that (i usually put it in ~/.bash_profile)
-bash-3.00# export http_proxy=http://proxy.example.com:8080

-bash-3.00# /usr/sfw/bin/wget http://www.google.com
--2012-08-27 13:03:30--  http://www.google.com/
Resolving proxy.example.com... 10.0.7.17
Connecting to proxy.example.com|10.0.7.17|:8080... connected.
Proxy request sent, awaiting response... 302 Found
Location: http://www.google.no/ [following]
--2012-08-27 13:03:40--  http://www.google.no/
Connecting to proxy.example.com|10.0.7.17|:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `index.html'

    [ <=>                                   ] 11,343      --.-K/s   in 0s

2012-08-27 13:03:40 (65.3 MB/s) - `index.html' saved [11343]

Although things appear to be working, it's not perfect. Let's go back to the global zone.
First we have the real bnx1 interface, which is also using DHCP.
erikn@global:~ $ ifconfig bnx1 dhcp status
Interface  State         Sent  Recv  Declined  Flags
bnx1       BOUND         2357  1558       778
(Began, Expires, Renew) = (08/27/2012 12:09, 08/31/2012 12:09, 08/29/2012 12:09)

Then we have our logical interface:
erikn@global:~ $ ifconfig bnx1:1 dhcp status
Interface  State         Sent  Recv  Declined  Flags
bnx1:1     PRE_BOUND       20    14         6

Let's create another logical interface, but we'll not give this one to any zone, so it'll belong to the global zone:
erikn@global:~ $ pfexec ifconfig bnx1:2 plumb

erikn@global:~ $ pfexec ifconfig bnx1:2 dhcp start

erikn@global:~ $ echo $?
0

erikn@global:~ $ ifconfig bnx1:2
bnx1:2: flags=1104843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,ROUTER,IPv4> mtu 1500 index 5
        inet 10.0.6.123 netmask fffffc00 broadcast 10.0.7.255

erikn@global:~ $ ifconfig bnx1:2 dhcp status
Interface  State         Sent  Recv  Declined  Flags
bnx1:2     BOUND            5     4         1
(Began, Expires, Renew) = (08/27/2012 13:11, 08/31/2012 13:11, 08/29/2012 13:11)

So that worked pretty flawlessly. Alas, it doesn't help us much.
I attempted to hand that interface over to the zone "test":
erikn@global:~ $ pfexec ifconfig bnx1:2 zone test
erikn@global:~ $ echo $?
0

It wasn't too happy about that:
erikn@global:~ $ ifconfig bnx1:2 dhcp status
Interface  State         Sent  Recv  Declined  Flags
bnx1:2     DECLINING        6     4         2

And releasing and starting DHCP client anew on the interface leads to the same result as that which we saw last time:
erikn@global:~ $ pfexec ifconfig bnx1:2 dhcp release

erikn@global:~ $ pfexec ifconfig bnx1:2 dhcp start
ifconfig: bnx1:2: wait timed out, operation still pending...

As a last, desperate attempt, I tried:
erikn@global:~ $ pfexec ifconfig bnx1:2 plumb \
> netmask 0xfffffc00 \
> broadcast 10.0.7.255 \
> zone test \
> up

No such luck.
erikn@global:~ $ pfexec ifconfig bnx1:2 dhcp start
ifconfig: bnx1:2: wait timed out, operation still pending...

My questions are basically:

Is it at all possible to have DHCP assigned IP's for a Solaris 10/09 zone without giving it a physical NIC of its own?
Am I going about this the wrong way? Should I instead have private IP's for the zones and let the host computer do NAT? Is that possible?

The end goal for me, is to have different network-connected services running in each their zone.

There will be some network communication accross the zones, and
they are also going to be running network accessible services which will be used by other hosts on our network.
Answer: Zone virtual interface has some features limited... some states can't be setup, packet filter doesn't work in zone too. If I remember right, zone interface can't send ethernet broadcasts, so then no DHCP.
Btw why you doing that bloat about setting up zone interface? What about this?
pfexec zonecfg -z test
> 'create -b ;
> set zonepath=/zones/test ;
> add net ;
> set physica=bnx1 ;
> set address=10.0.6.92 ;
> end ;
> verify ;
> commit'

It will inherit netmask from global zone interface. Of course you can setup more interfaces, or put zone only on 'internal' interface (no public IP) and the let ipf provide NAT.
Comment: I set up the interface using `ifconfig` because I didn't want to set a static IP for the interface yet. I suppose I'll have to go the NAT route with `ipf` as you suggested until I can get some static IP's.

Solaris 10 zone network configuration


Mocking a Jersey REST Api running on Grizzly using Mockito

Question: I am having a play with testing a RESTful api which I have set up using Jersey.  I want to test it using JUnit while running it with Grizzly to provide the Http container.
General testing using the server works ok, i.e. sending requests and receiving responses etc.
The api is called CMSApi and it has a dependency called skyService which I would like to mock out so I'm testing just the api.
So the question is how can I inject the CMSApi with a mockSkyService object created using Mockito?  The relevant code is below:
Grizzly Server start up:
public static HttpServer startServer() {
    final ResourceConfig rc = new ResourceConfig().packages("com.sky");
    rc.property(ServerProperties.BV_SEND_ERROR_IN_RESPONSE, true);
    return GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI), rc);

}
My JUnit calls the above start method:
@Before
public void setUpServer() throws Exception {

    // start the server and create the client
    server = Main.startServer();

    Client client = ClientBuilder.newClient();
    target = client.target(Main.BASE_URI);
}

I run the test using the @RunWith(MockitoJUnitRunner.class).
Here are the relevant objects in the test:
//System Under Test
private CMSApi cmsApi;

//Mock
@Mock private static SkyService mockSkyService;

Here is the test method calling:
  @Test
public void testSaveTile() {

    //given
    final Invocation.Builder invocationBuilder = target.path(PATH_TILE).request(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON);

    Tile tile = new Tile(8, "LABEL", clientId, new Date(), null);

    //when
    Response response = invocationBuilder.post(Entity.entity(tile, MediaType.APPLICATION_JSON_TYPE));

    //then
    assertEquals(Status.OK.getStatusCode(), response.getStatus());

}

Maven dependencies
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<groupId>com.sky</groupId>
<artifactId>sky-service</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>sky-service</name>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey</groupId>
            <artifactId>jersey-bom</artifactId>
            <version>${jersey.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

 <dependencies>
     <dependency>
        <groupId>org.glassfish.jersey.media</groupId>
        <artifactId>jersey-media-json-jackson</artifactId>
        </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.test-framework.providers</groupId>
        <artifactId>jersey-test-framework-provider-bundle</artifactId>
        <type>pom</type>
        <scope>test</scope>

    <dependency>
        <groupId>org.glassfish.jersey.ext</groupId>
        <artifactId>jersey-bean-validation</artifactId>
        </dependency>
    <dependency>
        <groupId>org.glassfish.jersey.test-framework.providers</groupId>
        <artifactId>jersey-test-framework-provider-grizzly2</artifactId>
    </dependency>
    <dependency>
        <groupId>com.sun.jersey</groupId>
        <artifactId>jersey-json</artifactId>
        <version>1.16</version>
    </dependency>

    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.10</version>
        <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>1.9.5</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <inherited>true</inherited>
            <configuration>
                <source>1.7</source>
                <target>1.7</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <executions>
                <execution>
                    <goals>
                        <goal>java</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <mainClass>com.sky.Main</mainClass>
            </configuration>
        </plugin>
    </plugins>
</build>

<properties>
    <jersey.version>2.15</jersey.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Answer: You're going to need to tap into the ResourceConfig, as you will need to explicitly register the CMSApi, so that you can inject it with the mocked SkyService prior to registering. It would basically look something like
// Sample interface
public interface SkyService {
    public String getMessage();
}

@Path("...")
public class CMSApi {
    private SkyService service;
    public void setSkyService( SkyService service ) { this.service = service; }
}

// Somewhere in test code
CMSApi api = new CMSApi();
SkyServicer service = Mockito.mock(SkyService.class);
Mockito.when(server.getMessage()).thenReturn("Hello World");
api.setSkyService(service);
resourceConfig.register(api);

The key is to have your resource class set up for injection of its dependency. Easier testing is one of the benefits of dependency injection. You can inject through constructor, or through a setter as I have done, or through an injection framework with the @Inject annotation.
You can see a more complete example here, which uses the Jersey DI framework HK2. You can also see more about Jersey and HK2 here. Then example also uses the Jersey Test Framework, which I see you already have as a dependency, so you might want to leverage that. Here is another example which uses Jersey 1, but the concept is the same, and you might be able to get some ideas from it.
As an aside, it looks like you're using the Jersey archetype, which I am familiar with. So the code for the config you are showing is in a different class. You may not want to mess with the current app configuration, so maybe your best bet is to use the test framework and create a new config as seen in the example I linked to. Or else you would need some other way to access the resource config from the test class. Or you could set up a new server in the test class instead of starting the server in the Main class.
Comment: Thanks @peeskillet for your response.  I was able to get what I wanted working as per your examples.

In the end I was able to:
- Inject the dependency using HK2.
- I extended the JerseyTest class
- I created a Factory for the Mocked Service and registered it with the ResourceConfig by overriding the configure() method.

The only slight difference was that I created the Mock using the Mockito annotation and wrote the stubbing code in my test case so I could make it return what was needed for the test.
Comment: Thanks for your response I was able to get what I wanted.


.net framework client profile-- What if the Dll I Need is Not There?

Question: I am thinking about going into .net framework client profile, but currently I am depending on System.Design.dll, which is not inside the profile.
I can, of course, manually distribute them in my application folder directory, but is there a better strategy?
Answer: I don't think you are legally permitted to distribute individual .NET Framework DLLs. If you depend on a DLL that's not part of the client profile, either get rid of the dependency somehow or don't target the client profile; consider requiring the full .NET Framework.
Answer: You have two options:

target the full desktop framework
refactor your code to remove the System.Design.dll dependency

See also this blog post.
Answer: The problem with manually distributting your local System.Design.dll is that if that dll gets patched in the framework later on, your app will keep using an older version of the dll. Of course you can put code in your program to load dynamically the local DLL only if the full framework is not present.. but that becomes more involved.
What about making two versions of the app.. one not dependent on System.Design.dll (and only requiring the client profile) and one dependent on System.Design.dll that requires the full framework.. and let the user choose the trade off?
Answer: Lets start with the fact that you cannot legally redistribute a single .Net DLL with your application.
Next lets make sure you understand the purpose of the Client Profile; and it is to provide a smaller footprint for distribution and/or a faster deployment experience for you users. It does this by providing a streamlined subset of Windows Presentation Foundation (WPF), Windows Forms, Windows Communication Foundation (WCF), and ClickOnce features.
Based on this you need to decided if the Client Profile meets your goals for your application.

If it does, you will need
to refactor your project to not be
dependent on any libraries that are
not part of that profile.
If it does not then you really shouldn't
be using the Client Profile.

As I see it you only have those two options.


Prove the dominated convergence for $f_n(x)=\frac{x^n}{x^2+3x+2}$

Question: Suppose that we have $f_n:[0,1]\rightarrow\mathbb{R},f_n(x)=\frac{x^n}{x^2+3x+2}$.

$f_n$ don't have uniform convergence because the pointwise isn't continuous:  $$\lim_{n\to\infty}f_n(x)\neq\lim_{n\to\infty}f_n(1)$$
To prove that $\{f_n\}$ has dominated convergence we need an integrable function $g$ such that $|f_n|\leq g$ and $f_n\rightarrow f$ pointwise as $n\rightarrow\infty$.

But if the pointwise isn't continuous for every $x\in[0,1]$, how we can show the dominated convergence? Or for dominated convergence isn't necessary to have a continuous pointwise limit for every $x\in[0,1]$ ?

By the way, how can I prove that $f_n\leq g$ where $g$ is integrable ? I suppose $g$ can be $1$ which is integrable on the interval but how can I prove inequality such that $f_n\leq 1$ ? or something else, not necessarily $1$...
Comment: If $x\in[0,1]$, $$f_n(x)=\frac{x^n}{(x+1)(x+2)}\leq \frac{1}{1\cdot 2}.$$
Comment: Moreover, since $f_{n+1}(x)\leq f_{n}(x)$, the most natural candidate for a dominating function is just $f_1(x)$.
Comment: hi Jack, can you give me some explanations for yellow box ? as I said the pointwise convergence isn't continous, but in dominated convergence isn't neccessary this condition ?
Answer: Note that
\begin{align*}
\frac{x^{n}}{x^{2}+3x+2}\leq \frac{1}{0+0+2}=\frac{1}{2}
\end{align*}
for all $n\in\mathbb{N}$, and the constant function $\frac{1}{2}$ is integrable on $[0,1]$.
To answer the part in the yellow box: the dominated convergence theorem does not require that the point-wise limit is a continuous function.
Comment: Thomas can you ask at the yellow box?
Comment: @Lucas: I edited the answer and included that part too. For further reference for dominated convergence theorem, the wikipedia article has a lot of information: http://en.wikipedia.org/wiki/Dominated_convergence_theorem
Comment: Thomas, so we can say that $f_n$ is pointwise convergent to $0$, $\forall x\in[0,1]$ or $x\in[0,1)$ ? I mean in dominated convergence not uniform
Comment: @lucas: The point wise convergence to zero happens for all $x\in [0,1)$. At $x=1$ the limit is not zero, but the single point $x=1$ has measure zero and thus does not contribute to the value of the integral.
Comment: Thomas for $x=1\Rightarrow\lim_{n\to\infty}f_n(x)$ will be $\frac{1}{6}$ I don't understand what you want to say by "$x=1$ has measure zero.."
Comment: @lucas: Yes that's true. You can ignore the comment about measure zero: I thought you we're dealing with integration through measure theory, but you can also view the integral as a Riemann integral. That's fine too.
Comment: but Thomas when you say "thus does not contribute to the value of the integral" is what I want to sound, because $\int_0^1 f_n(x)=\int_0^1 f(pointwise)dx$ and this is what I don't understand if our integral is defined on $[0,1]$ which is the pointwise convergent: $0$ or $\frac {1}{6}$ ?
Comment: @Lucas: The conclusion is that $\lim_{n\to\infty}\int_{0}^{1}f_{n}(x)=\int_{0}^{1}f(x)$. And $f(x)=0$ if $x\in [0,1)$ and $f(1)=\frac{1}{6}$. This limit function is defined on the whole interval $[0,1]$ and is discontinuous. The reason why $\int_{0}^{1}f(x)=0$ requires measure theory: the set $\{1\}$ has measure zero and thus its contribution to the integral $\int_{0}^{1}f(x)$ is negligible. To fully understand this, a good place to start is to google "Lebesgue measure" and "Lebesgue integral".


lldb frame variable command no return when debugging apps in iPhone

Question: when i enter the frame variable of lldb command ,there is no output in the terminal  ,i can not see the variables of current frame,what the problem ,tell me why.
there is no output  in the  terminal  when  i  enter  "frame variable" command
Comment: Please post the code in the question itself.
Answer: Usually more details would help
With that said, in your case the issue is pretty obviously that you're stopped in mach_msg_trap
You are highly unlikely to have debug information for the kernel - and since you don't, LLDB doesn't know which variables exist in that function, so it doesn't show any
Comment: Process 49612 stopped
* thread #1: tid = 0xc1cc, 0x0000000100426af0 JuMei`___lldb_unnamed_function24595$$JuMei, queue = 'com.apple.main-thread, stop reason = breakpoint 1.1
    frame #0: 0x0000000100426af0 JuMei`___lldb_unnamed_function24595$$JuMei
JuMei`___lldb_unnamed_function24595$$JuMei:
-> 0x100426af0:  stp    x20, x19, [sp, #-32]!
   0x100426af4:  stp    fp, lr, [sp, #16]
   0x100426af8:  add    fp, sp, 16
   0x100426afc:  sub    sp, sp, #16
(lldb) frame info
frame #0: 0x0000000100426af0 JuMei`___lldb_unnamed_function24595$$JuMei
(lldb) frame variable
(lldb) thread backtrace
Comment: I'm sorry ,the problem is that the command of  "frame variable " return nothing.It did not stop in mach_msg_trap.It stop at a breakpoint.
Comment: I agree with @zhmeifu I see the same /Users/dyl/Desktop/Screen Shot 2016-06-05 at 7.09.06 PM.png
Comment: Same for me ---> (lldb) frame info
frame #0: 0x0000000194012ea4 UIKit`-[UIViewController viewDidAppear:] ---> but no info for frame variable


Cannot detect row in gridview while update data

Question: I want to update the AResult with click approve or reject button.
In my aspx page, here my code,
<asp:ButtonField ButtonType="Button" CommandName="Approve" Text="Approve" runat="server" />
<asp:ButtonField ButtonType="Button" CommandName="Reject" Text="Reject" runat="server" />

My aspx.vb code,
Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As GridViewCommandEventArgs) Handles GridView1.RowCommand

    Dim con As New SqlConnection(ConfigurationManager.ConnectionStrings("dbconnection").ConnectionString)

    con.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True"
    con.Open()

    If e.CommandName.CompareTo("Approve") = 0 OrElse _
       e.CommandName.CompareTo("Reject") = 0 Then
        ' The Approve or Reject Button has been clicked
        ' Determine the ID of the appointment whose result was adjusted

        Dim AID As Integer = Convert.ToInt32(_GridView1.DataKeys(Convert.ToInt32(e.CommandArgument)).Value)

        Dim cmd As New SqlCommand

        cmd.Connection = con
        If e.CommandName.CompareTo("Approve") = 0 Then
            cmd = New SqlCommand("UPDATE [Appointment] SET AResulT  = N'Approve'", con)

        ElseIf e.CommandName.CompareTo("Reject") = 0 Then
            cmd = New SqlCommand("UPDATE [Appointment] SET AResult = N'Reject'", con)

        End If

        cmd.ExecuteNonQuery()

        Response.Redirect("Waiting List")

        con.Close()

    End If
End Sub

When i click on approve button, it will update my whole appointment's result with approve. Can someone teach me how to detect the row when i click the button?
Comment: Maybe this can help you: http://stackoverflow.com/questions/2818203/get-datakey-values-in-gridview-rowcommand/6672463#6672463
Answer: In your update statement you are not updating only one row, you are updating the whole table
  cmd = New SqlCommand("UPDATE [Appointment] SET AResulT  = N'Approve'", con)

You need to change this query to
  cmd = New SqlCommand("UPDATE [Appointment] SET AResulT  = N'Approve' WHERE [KeyColumnName]=" & AID, con)


Customise Title Mark Up from template.php

Question: On my site, I have several content types. They all use the same node--content_type.tpl.php file. However, the mark up applied to the node title has to change depending on the content type.
How can I modifying the title according to the content type from template.php?
(I don't want to use too many IF statements in my node.tpl.php file as you are supposed to keep those files clean, so I want the code to go in my template.php file).
(This question is for Drupal 7).
Answer: I found the solution to this

Create a field called Title
Your users use this new field to
    enter a title
Use Auto Node Title  to automatically title
    the node based on this field.

You can ow hide the original title in your theme and use the new title filed instead. The new title field can be customised like a regular field.
Answer: You could use Display Suite to control the layout of your content type including how to visualize each field which includes the title, you will need to activate Display Suite Extras so you can control how to output each field. I think the field template could be your answer for this. You can find a demo and extra information in the following links:

Field template display suite
Configuring and using Display Suite Xtras

This could be a good alternative if you don't want to use many if's statements in your tpl.
Comment: Thanks for taking the time to reply! I think Display Suite would be overkill. I only want to change the mark up for the title, ideally from template.php.


In this algorithm what is "b"?

Question: I'm trying to take an algorithm from this page: Link and convert it to working code. The step-by-step is as follows:
The following algorithm uses a similar (but slightly different) idea.
It uses two internal integer variables, m and r, which are not reset
at the beginning of the algorithm (in C, you would declare them
as "static").  Initially, m = 1 and r = 0.  We also have a parameter
N, which is a large integer such that 2N can still be represented
exactly in the computer.  As said before, n is the modulus of the
numbers you want to produce (they will be between 0 and (n - 1)), we
must have n < N, and we have a function NextBit() that returns a
truly random bit.
1. WHILE m < N DO r : = 2*r + NextBit(); m = 2*m; (r is a random
   variable of modulus m)
2. Divide m by n : m = n*q + b
3. IF r >= n*q, let m : = m - n*q, r : = r - n*q (r is still a random
   variable of modulus m), and go to step 1.
4. Otherwise, let x : = r mod n, r : = [r/n], and m : = q, and return
   x.

However, I can't find any indication of what "b" is. Math expert, I am not.
Comment: It seems to be just the remainder of $m/n$. For example if $m=13$ and $n=3$, then $q=4$ and $b=1$.
Answer: As noted by David Mitra in the comments. $b$ denotes the remainder. The Division Algorithm theorem states that the division of integers produces a quotient and a remainder. That is, given a numerator $m$, and a denominator $n$, the division $m / n$ results in a quotient $q$ and a remainder $b$. Or, $$ m = qn + b. $$ In a programming setting, you can obtain $b$ using rem operation on $(m,n)$ if your language has one. Otherwise, you can always divide $m/n$, round down the results to get $q$, then $b$ is given by $b = m-qn$.

In this algorithm what is "b"?


Domain for a complex function

Question: For which $z$ values is the complex function below undefined?
$$\frac{1}{e^z-1}$$
Am I under thinking this problem, or shouldn't the domain be all complex values except for $z=0$?
Comment: Are you saying that $e^z$ never equals one unless $z=0$?
Answer: HINT: The complex exponential is periodic. Consider the trigonometric definition of $\exp(z)$ or more clearly $\exp(ix)$.
Answer: It's undefined when $e^z=1,$ and notice that $e^{\pm2\pi i} = 1$ and $e^{\pm4\pi i} = 1,$ etc.
The slightly more involved question is how do we know there are no other points where it's undefined? And there you need to observe that $e^z$ is defined for all values of $z.$ And also ask yourself how you know that there are no other values of $z$ for which $z=1$ than the ones included in the "etc." of the first paragraph above.
Comment: I can easily state all the values of $z$ for which $z = 1$... I think.

Domain for a complex function


divergence of a vector field on a manifold

Question: I've been asked to show the following: For a vector field $V$ on a semi-Riemannian manifold with metric $g$ that $$Div \cdot V = \frac{1}{\sqrt{\det(g)}}\partial_i\left(\sqrt{\det(g)}V^i\right)$$ I know we're supposed to use Christoffel symbols as well as a few matrix formulas, but I'm not sure how to proceed. In particular, we were given that for a (invertible) matrix $M$ with some parameter $s$, that $$\frac{d}{ds}\det M(s)=\det M(s) \cdot tr\left(M(s)^{-1}\frac{d}{ds}M(s)\right)$$ and $$\frac{d}{ds}(M(s)^{-1})=-M(s)^{-1}M'(s)M(s)^{-1}$$ Any help would be greatly appreciated.
The definition of divergence that we were given was $$Div \cdot V = \nabla_{\partial_i}V^i = \partial_iV^i+\Gamma_{ij}^iV^i$$
Answer: Let's work backwards.
The product rule gives
$$\begin{align*}
\frac{1}{\sqrt{\det g}}\partial_i\left(\sqrt{\det g}\,V^i \right) & = \frac{1}{\sqrt{\det g}}\left[ \sqrt{\det g}\ \partial_iV^i + \partial_i\left(\sqrt{\det g}\right)V^i \right] \\
& = \partial_iV^i + \frac{1}{\sqrt{\det g}}\partial_i\left(\sqrt{\det g}\right)V^i \\
& = \partial_iV^i + \frac{1}{\sqrt{\det g}} \frac{1}{2\sqrt{\det g}}\partial_i\left(\det g\right)V^i
\end{align*}$$
We can now apply the formula for the derivative of a determinant to get:
$$\begin{align*}
\frac{1}{\sqrt{\det g}}\partial_i\left(\sqrt{\det g}\,V^i \right) & = \partial_iV^i + \frac{1}{2} \text{tr}(g^{-1}\partial_ig)\,V^i \\
& = \partial_iV^i + \frac{1}{2} \text{tr}(g^{jk}\partial_ig_{kl})\,V^i \\
& = \partial_iV^i + \frac{1}{2} g^{jk} \partial_i g_{kj}\,V^i
\end{align*}$$
Now, it is a general fact that for the Levi-Civita connection, the Christoffel symbols satisfy
$$\partial_ig_{kj} = \Gamma^l_{ik}g_{lj} + \Gamma^l_{ij}g_{kl}.$$
Therefore,
$$\begin{align*}
\frac{1}{\sqrt{\det g}}\partial_i\left(\sqrt{\det g}\,V^i \right) & = \partial_iV^i + \frac{1}{2} g^{jk} \left(\Gamma^l_{ik}g_{lj} + \Gamma^l_{ij}g_{kl} \right)\,V^i \\
& = \partial_iV^i + \frac{1}{2}\left(\Gamma^l_{ik}\delta^k_l + \Gamma^l_{ij}\delta^j_l \right)\,V^i \\
& = \partial_iV^i + \Gamma^l_{il}\,V^i \\
& = Div \cdot V
\end{align*}$$
as was to be shown.
Comment: Actually, I think the formula $\partial_i g_{kj} = \Gamma^l_{ik}g_{lj} + \Gamma^l_{ij}g_{kl}$ is true more generally for any connection compatible with the metric, but don't quote me on that.
Comment: This (the formula for the derivative of the metric tensor) seems to be a direct consequence of corrollary 7 in chapter 6 of the second volume of Spivak's comprehensive introduction to differential geometry.
Comment: I just know it as a consequence of the Koszul formula, a.k.a. one of the [Christoffel identities](http://en.wikipedia.org/wiki/Fundamental_theorem_of_Riemannian_geometry).  (I don't own any of Spivak's diff geo books besides Calculus on Manifolds.)
Answer: $\def\div[0]{\operatorname{div}}$
My favourite reason this formula is true: let $\phi$ be an arbitrary smooth function with compact support contained in a single chart $(U,x)$. Then integrating by parts we get
$$ \int_U \phi \div V d\mu_g= -\int_U V^i \partial_i \phi\, d\mu_g = -\int_U V^i \partial_i \phi \sqrt {\det g}\, dx.$$
Now integrate by parts again, but this time in the chart geometry (i.e. use the product rule for partial derivatives instead of the one for Riemannian divergence, and the measure $dx$ instead of $d \mu_g$):
$$ -\int_U \partial_i \phi\,  V^i \sqrt {\det g}\, dx= \int_U \phi\, \partial_i (\sqrt{\det g}\, V^i) dx = \int_U \phi\, \frac 1{\sqrt{\det g}} \partial_i(\sqrt{\det g}\, V^i)\ d\mu_g.$$
Since this is true for every $\phi$ we get the desired formula for $\div V$.
In some sense this is just a weak version of Giuseppe's answer, but seeing it was the first time this formula really clicked for me, so I figured I'd write it down.
Comment: This is nice, but I have two questions: 1) Isn't it true that the "integration by parts formula" for the divergence is proved via its coordinate formula (you need to know in advance that $\operatorname{div}(fX)=f\operatorname{div}(X)+\langle \operatorname{grad f}, X\rangle$). The only way I know how to do this is via coordinates, which of course would make your argument circular (but I guess it is just my ignorance).  2) I am not sure what happend in your last equality.
Comment: 1) I did my whole first course in Riemannian geometry without even seeing this formula for the divergence - you can do everything with its Christoffel-style coordinate form $\rm{div} X = \partial_i X^i + \Gamma_{ij}^i X^j$ if you need a coordinate expression for some reason. 2) Thanks, fixed a typo there.
Answer: The metric volume form is $\omega=\sqrt{|\det(g)|}dx^1\wedge\ldots\wedge dx^n.$
The divergence of $V=V^i\partial_i$ is determined by $(\text{div}V)\omega=d(V\lrcorner\omega)\equiv V(\omega),$ hence we get: $$(\text{div}V)\omega=\left[V^i\partial_i(\sqrt{|\det(g)|})+\sqrt{|\det(g)|}\partial_iV^i\right]dx^1\wedge\ldots\wedge dx^n,$$
Where we used the obvious formula $V(dx^1\wedge\ldots\wedge dx^n)=(\partial_iV^i)dx^1\wedge\ldots\wedge dx^n.$
Therefore $$\text{div}V=\frac{1}{\sqrt{|\det(g)|}}\frac{\partial}{\partial x_i}\left[\sqrt{|\det(g)|}V^i\right]$$

Edit added in reply to Asaf Shachar's comment
Probably, in the original version of my answer, I should have spent a few words justifying the following formula $$V(dx^1\wedge\ldots\wedge dx^n)=(\partial_iV^i)dx^1\wedge\ldots\wedge dx^n.\tag{$\star$}$$
Here, on the left-hand side, as elsewhere in my answer, I am using the expression $V(\eta)$ to denote the Lie derivative, along the vector field $V$, of a differential form $\eta$.
Recall that the vector field $V$ is locally given by $V=V^i\partial_i$ in terms of the holonomic frame $\partial_1,\ldots,\partial_n$ corresponding to the local coordinate system $x^1,\ldots,x^n$, so that $$V(x^i)=V^i\tag{1}.$$
Moreover, since the Lie derivative $V(-)$ is a (degree $0$) derivation of the differential graded algebra $(\Omega^\bullet(X),\wedge,d_{dR})$, we get immediately that $$V(dx^1\wedge\ldots\wedge dx^n)=\sum_{i=1}^n dx^1\wedge\ldots\wedge d(V(x^i))\wedge\ldots\wedge dx^n.\tag{2}$$
Now, from $(1)$ and $(2)$, it follows $(\star)$, as we needed.
Comment: Can you please explain the "obvious formula"?
Comment: Thanks! this really helped.  I now see your derivation uses indeed the fact that the Lie derivative is a derivation, together with its commutation with the exterior derivative (The latter is required in order to prove $\mathcal{L}_V(dx^i)=dV^i$).
Comment: By the way, this answer here (http://math.stackexchange.com/a/1758100/104576) contains alternative proof which is based on evaluations of the relevant differential forms on $n$-vectors. Interestingly, it does not use the  commutation of the Lie derivative with the exterior derivative.
Comment: Dear @AsafShachar I have edited my answer according with your request. Let me know it is now ok for you.


Non-exported activities: launched on emulators; SecurityException on phones

Question: I have a non-exported activity in my project.
If I try to launch it on my phone using adb:
adb shell am start -n "packagename/activityname"

I get the error:
java.lang.SecurityException:
Permission Denial: starting Intent { ... } from null (...) not exported from uid ...

But, if I run the same command on an emulator, then everything works Okay. How comes?
Comment: The user account that `adb shell` run as has greater rights on an emulator, AFAIK.
Answer:
But, if I run the same command on an emulator, then everything works Okay. How comes?

An emulator instance runs as root by default, meaning that more system processes has root rights compared to a non-rooted device.
Consider the ps command output grep-ed with adbd and sh (i.e. adb shell ps | grep 'adbd' and adb shell ps | grep 'sh', respectively). You might see the following (with different PID and PPID on your device/emulator, of course):

Non-rooted device
USER     PID   PPID  NAME
shell    166   1     /sbin/adbd
...
shell    15721 166   /system/bin/sh

Emulator
USER     PID   PPID  NAME
root     1183  1     /sbin/adbd
...
root     2884  1183  /system/bin/sh

sh process, so is its parent process adbd, is owned by root on an emulator, in contrast to the shell owner on a non-rooted device. And a root user has a "permission" to access your app's sandbox, despite the android:exported attribute set to false.


a simple question

Question: I have an inequality:
$$2ax^2+by^2\geq0$$that $x^2\geq y^2$.  Actually $x^2$ is $c.c$ that is $(\sum c_{ij}^2)$ and $y^2$ is  $(tr(c))^2$, where $c$ is $2\times 2$ matrix.
Now, I want to show that $a$ and $a+b$ are  positive.
Maybe it is so simple, but it got alot of time of me.
Please help me,
Thanks.
Answer: let $x=2,y=1 a=.5 b=-1$ then $(.5)2^2-1=2 \geq 0$ but $a+b=-.5 < 0$ so its not true.
Comment: @Martin No, as stated in the question, $x$ and $y$ are numbers, not matrices. When $c=\pmatrix{1&\sqrt{3/2}\\ \sqrt{3/2}&0}$, we have $x^2:=\sum c_{ij}^2=4$ and $y^2=1$, so that baharampuri's example applies.
Comment: @user1551: right. Thanks.
Answer: May be not. If $c$ is $(0)$, then $a$ and $b$ are equal to 0. They are not positive.
Comment: $c$ is not $\bf 0$
Comment: Why? From your question, $c$ may be is a 0 matrix.
Comment: @Hakhak It doesn't matter whether $c$ is the zero matrix or not. If $a=b=0$, the inequality $2ax^2+by^2\ge0$ always holds. In other words, you cannot infer that $a>0$ or $a+b>0$ from the inequality.
Comment: Sorry,I should say it that $c$,$a$ and $b$ are physics concepts that are not zero, but I do not know any more about them.

a simple question


How can the ukulele D7 chord have different fingerings with different sounds?

Question: Just learning the ukulele, and trying the D7 chord. I'm confused because there seems to be two accepted fingerings for the D7: a barre on the second fret and a single finger on the first string of the third fret, or a finger on the second and fourth strings of the second fret.
These are both D7, apparently, but they sound substantially different to my ear; the first (barre + finger) higher in tone than the second (strings 2 and 4 on the second fret).
Is there a "superior" D7 in terms of what a D7 should sound like? Is it worth forcing myself to learn the slightly more difficult barre + finger version for a "better" D7?
Answer: A D7 chord consists of:

D - the root note - if you leave it out the chord is ambiguous, but you might fix that by having another instrument, your voice, or the listener's imagination, fill it in. When you're the only accompaniment, however, you typically want the tonic as one of the lowest notes in your chord, as an anchor (this is why bass guitars often play root notes)
A - D's 5th - this reinforces the root (which is why the next step from root-note-only bass parts, is root-and-fifth bass parts), but leaving it out doesn't weaken the chord too much
F# - D's major 3rd. This is what makes it a major chord. An F natural would make it a minor chord. Leaving out the third altogether makes it ambiguous (known as a "power chord")
C - D's dominant 7th. This is what makes it a dominant 7th chord (in pop/rock/folk we generally use "7th" as shorthand for "dominant 7th" when talking about chords) If you leave it out, it's just a major chord, not a 7th chord.

Now, these four notes occur in multiple places on the fretboard:

You can play any of them and get a note that fits in a D7 chord. You can play any combination of them and get at least a partial D7 chord. To get a full D7 chord you need at least one of each.
So, there are lots of fingerings that would get some or all of those notes, in various octaves and in various orders. These are known as inversions of a chord. Here are three:

The top letters are the string names, the bottom letters are the fretted note names.
The first chord is missing the D, but uses two open strings, so is easy to play. It would sound OK, especially if (for example) a bass instrument is taking care of root notes.
One reason this shape might be in your source, is that some people reach ukulele chords by starting with Guitar chords. The top four strings of a guitar have the same relative tuning as a uke (if the uke has a low G), a fifth out. So a uke D7 is the same shape as a guitar A7, but two strings are missing. On the guitar, the root note is the 5th string. On the uke, the root note is missing.
The second chord has all four notes, with the D on the third string.
The third chord barres the 5th fret and also has all the notes, although the D is on the top string, so doesn't anchor the chord so firmly. It is higher up the fretboard, so you get a different tone out of your instrument. You could sometimes play this chord, and other times play one of the other forms, to add variety to an accompaniment.
This is very common on lots of instruments. When I want to play a C chord on guitar, I choose between the shape beginners learn early on, with open strings; a barred shape on the third fret; a different barred shape on the 8th fret; or lots of other choices.
I'd suggest:

Play these three chords, and notice (especially if you hum the D to remind yourself of the tonic, and to fill in the missing D in the first form) that although the sound changes, the harmonic content stays the same.
Try making up more D7 shapes, using more of the positions on the fretboard diagram.
Try mapping out the notes of a different chord on the fretboard, and working out the shapes and inversions for that chord from first-principles too.
Comment: Great, comprehensive answer - especially taking the time to to diagrams.
Comment: Thank you for putting the fret number next to the fret, instead of between frets (yes, people do that.  I never know which fret they're numbering).
Answer: The D7 chord is D (root), F♯ (major 3rd), A (perfect 5th), C (minor 7th). Any voicing that includes all four of those is correct. For example, the barre fingering is A–D–F♯–C, which is correct. Furthermore, the chord is in root position on a soprano or concert ukulele – meaning that the root is the lowest-pitched note – which is ideal for playing unaccompanied.
A chord voicing can omit some notes and still be correct, and it's often necessary on four-stringed instruments like ukuleles and bass guitars. It's usually safe to omit the perfect 5th and double up on the root, for example, as the root note's harmonics will imply it. In contrast, you can't usually omit the 3rd or 7th as their sound is essential to chord quality.
The root note is a special case, as it's essential to harmony, but only in the bass. Therefore, if you are accompanying a bass instrument, you can safely omit the root note, but if you are playing unaccompanied, the root note is essential. Your alternate fingering, A–C–F♯–A, lacks the D root note, so it's unsuitable if you're playing alone, but OK if you're playing with other musicians, as the ukulele is not usually the bass instrument.
Answer: There are two common ukulele chords called D7.  The traditional D7 chord is the barre chord:

This chord has all four of the D7 notes: D, F♯, A, C
The other D7 chord is a common alternative on the ukulele:

This form of the D7 chord is often called the Hawaiian D7, perhaps because it is popular in Hawaii.  As others have noted, it is missing the D note.  But because it is a little easier for beginners to play than a barre chord, you'll often see this Hawaiian D7 chord shown in ukulele chord charts as D7.
In many songs, either chord can be used.  I use both chords: when I encounter a song with D7, I'll try them both and figure out which works best in the song.  Without the high C, the Hawaiian chord sounds lower and more mellow.
Answer: You can easily check what 4 notes are played in each chord if you know your musical alphabet. If you have the same notes in both, but in different orders, they are just different voicings of the same chord and it comes down really to choice or how they sound in each song you use them in.
Assuming your uke is tuned A-E-C-G then your first version has notes C-F#-D-A while the second has A-F#-C-A
D7 has notes D, F#, A & C so your second variant is not right to me - it's not horrible as you have no wrong notes, but you don't have all 4 notes played. In fact you don't have the D, which is kind of important :)
Comment: As an aside, the uke is a pretty easy instrument to barre on compared to guitar so I'd bite the bullet and practice the technique anyway, it will be very handy not to think of barre chords as 'dreaded'!
Comment: Sure -- I'm not sure what's most correct, but my understanding of "1st string" would be like here (https://ukuguides.com/how-to/how-to-properly-tune-your-ukulele/) where the first string is the furthest away from my face, or the A string.
(EDIT) And thanks for the encouragement -- I'm going to try to learn both, I was just confused as to why they sound different but are the "same" chord.
Comment: That got me confused but I think I have it right now and edited accordingly... I don't think your easy one can really be called a D7 (if I didn't make an error) even though it will not sound awful
Answer: Essentially, the more traditional (especially in Hawaii) form of D7 is not really a D7; it's an F♯ diminished triad. It is usually written as D7 in notation for ukulele because it almost always serves the same function as a D7 (strong transitions to a G chord), and it is also the upper three notes of a real D7 chord and therefore sounds similar. If a piece of music ever asks for an F♯ diminished or an f♯ diminished seventh, you can play this with no problem. The barre D7 chord contains all the notes of a D7 and can only be used as such. The easier D7 is learned usually because it's easier, but the barre D7 is useful because one can slide it up and down the neck, prodicing more dominant seventh chords.
Answer: Stringed instruments have several different places where you can play the same note.
If you look at some guitar chord charts (as an example) you can see there are many different fingerings for a given chord.  Different inversions, different mixtures of open and fretted notes, different octaves involved, etc.
None of these fingerings is necessarily superior, they just give different flavors.  Some can sound better in some contexts, so it's worth it to learn several different fingerings for each chord.


Iptables / What is the difference between connmark and mark?

Question: While adding iptables rules, I couldn't understand what is the difference between connmark and mark? If anyone explains it with detailed explanations, I will be appreciated.
Answer: MARK associates "marks" with packets. CONNMARK associates "marks" with connections. The second one is useful because you can mark all the packets of a connection or related to a connection with the same mark (for example, FTP). Another usefull use of CONNMARK is that you can mark packets using the criteria that only matches with the first packet.
Comment: Agreed. You almost *always* want to use CONNMARK, unless you know why you don't. If in doubt, use CONNMARK.


Could a content type be corrupt?

Question: I just update a site from Drupal 7.14 to Drupal 7.15 and made some other modules updates.
One of the content I have created in the site is Inmuebles
The site have around 200 nodes of the Inmueble type. All of them are shown fine. But if I tried to edit them I get a blank page (nothing at all).
I tried to Edit the content type Inmueble itself and I get a blank page.
I tried to Manage the Fields and I get a blank page.
I have no problems with other content types, just with this one.
I guess this content type has a mis-configuration but I see no way to fix it if I can't access to modify it.
If I delete the content type because I will delete the nodes as well, then I can't do that.
What can I do? I have Drush installed, just in case it helps to fix this.
UPDATE
Found the problem (but not the source of the problem)
It was a problem of memory size. I had to set the memory size to 512 to get the content type loaded. But this is not normal anyway. The page takes 1 minute to load... and why does this content type need this much memory to work fine. How can I fix this?
I enabled  Display query log , Display memory usage and Display memory usage
Now if I edit a node I get this summary report:

Executed 731 queries in 555.96 ms. Queries exceeding 5 ms are
  highlighted. Page execution time was 3058.65 ms. Memory used at:
  devel_boot()=2.08 MB, devel_shutdown()=135.13 MB, PHP peak=137.25 MB.
Comment: Enable error reporting using http://drupal.org/node/158043 and post the errors you see in blank page here... That will help to find the problem...
Comment: Drupal 14 to 15 ? Guess I overslept again. Time to go back to the past.
Comment: Actually 7.14 to 7.15 i guess :-) Edited !
Comment: yeah I meant 7.14.
Comment: found the source of the problem. please see my update at the bottom of the question.
Comment: I am having a similar problem. were you able to get figure out the solution for the same?
Answer: You can export all the nodes of content type "Inmuebles" with the drush command
drush -u 1 ne-export --type=inmuebles

Then maybe try deleting the content type and creating it again.
Although it doesnt make sense for a content type to just get corrupt, maybe if you check your error reports or apache log you will get a better look.
Comment: Importing is again a pain and if any references to that content will be lost like comments and node references...So deleting a content type or nodes is not an option !!
Comment: If you have any custom theme installed, try switching to Drupal "Bartick" theme and check if its working.
Comment: Node export should preserve noderefs and comments if you have the proper sub-modules enabled.  You can always take a backup, try this method, and restore the backup if it doesn't work.
Comment: I have Bartik enabled, I found what is the problem but not the source of the problem. Pls see my updates at the bottom of the question

Could a content type be corrupt?


Control Design Problem with continue and discrete signals;

Question: I met a real application problem within my research.
The control signal will be three dimension, $u_1$,$u_2$,and $u_3$.
$u_1$ and $u_2$ are continous. Unfortuately, $u_3$ is disrete with the 6 selections with {1,2,3,4,5,6}. I have to design this control from optimal perspective.
Is there anyone who has done this situation before? Could you give me a hint.
thanks
Jie
Answer: Model predictive control is a general framework for optimization-based control, and having discrete control inputs does not make the control structure any more complicated conceptually, although the actual computation of control inputs might become prohibitively expensive as it will lead to mixed-integer optimization problems.
Comment: Johan, thank you for your comments. Yes, you are definitely right. It will lead to the mixed integer nonlinear programming problem. Typically,  it is addressed by traditional Brand-and-Bound searching technique.  Sir, Do you know other technique to tackle this challenge other than Brand-and-Bound searching?
Comment: Nothing I know of


A random variable with a step function CDF is discrete?

Question: Consider the step function
$$
\Delta(x;\lambda,\mu)\equiv \sum_{j=1}^J \lambda_j\times 1\{\mu_j\leq x\}
$$
where

$\lambda_j\geq 0$ $\forall j$; $\sum_{j=1}^J \lambda_j=1$
$\mu_j\in \mathbb{R}$ $\forall j$; $\mu_1<...<\mu_J$
$1\{\cdot\}$ is an indicator function taking value $1$ if the condition inside is satisfied and zero otherwise
$\lambda\equiv (\lambda_1,...,\lambda_J)$
$\mu\equiv (\mu_1,...,\mu_J)$

Take a random variable $Y$ with CDF given by $\Delta(\cdot; \lambda,\mu)$. Is it correct to say that $Y$ should be necessarily a discrete random variables with support $\{\mu_1,...,\mu_J\}$ and with probabilities masses equal to $\{\lambda_1,...,\lambda_J\}$?
Comment: There exist a theoretical problematic case which is a counter-example https://en.wikipedia.org/wiki/Cantor_distribution
Comment: Thanks. Is that the only counter example?
Comment: https://stats.stackexchange.com/search?q=%22singular+distribution%22
Comment: $J$ seems to be finite here.
Answer: Let's write each of the possibilities (let $a^-$ be number arbitrarily close to $a$, but smaller than $a$):
$P(Y=\mu_1)=P(Y\leq\mu_1)-P(Y<\mu_1)=\Delta(\mu_1)-\Delta(\mu_1^-)=\lambda_1$
$P(Y=\mu_2)=P(Y\leq\mu_2)-P(Y<\mu_2)=\Delta(\mu_2)-\Delta(\mu_2^-)=\lambda_1+\lambda_2-\lambda_1=\lambda_2$
continuing this way ...
$P(Y=\mu_k)=P(Y\leq\mu_J)-P(Y<\mu_J)=\Delta(\mu_J)-\Delta(\mu_J^-)=\sum_{i=1}^{K}\lambda_i-\sum_{i=1}^{K-1}\lambda_i=\lambda_K$
So, yes. You have a discrete RV with support $\mu$, and masses $\lambda$.