Square root inequality revisited

Question: This is a follow-up question of this one:
Proof of the square root inequality $2\sqrt{n+1}-2\sqrt{n}<\frac{1}{\sqrt{n}}<2\sqrt{n}-2\sqrt{n-1}$
I am interested in the following generalizations of the square root inequality.
Let $\varepsilon,\delta>0.$ Then
$$\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}<\frac{\delta}{2\sqrt{\varepsilon}}.$$
If additionally $\delta<\varepsilon$, then
$$\frac{\delta}{2\sqrt{\varepsilon}}<\sqrt{\varepsilon}-\sqrt{\varepsilon-\delta}.$$ The proof is similar as answered in my previous question.
Moreover, if $\varepsilon,\delta\in\mathbb{C}$ are any complex numbers and $\sqrt{\cdot}$ is a complex root, then
$$\min(|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|,|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|)\leq\min(\frac{|\delta|}{\sqrt{|\varepsilon|}},\sqrt{|\delta|}).$$
I have trouble to prove this one, but it should hold (it is not from me). What I have yet is the following: first suppose
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|\leq|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|.$$
Then
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|^2\leq|\delta|,$$
so that
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|\leq\sqrt{|\delta|}.$$
Similarly, when
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|\geq|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|,$$
then
$$|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|\leq\sqrt{|\delta|},$$
so that
$$\min(|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|,|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|)\leq\sqrt{|\delta|}.$$
Moreover,
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|=\frac{|\delta|}{|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|}\leq\ldots$$
and I don't know how to continue. Any help for solving this?
Comment: Are you looking for a demonstration only of the complex claim?
Comment: Yes. I already have LHS $\leq \sqrt{|\delta|}.$ I will add details.
Comment: I just wrote the others as a follow-up but I have the proof.
Answer: I think I have found a proof. Any comments, remarks are welcome.
We use the notation $x\wedge y=\min(x,y).$ Let $f:\mathbb{C}^2\to\mathbb{R}$ be the function defined by
$$
f(\varepsilon,\delta) = \left\{
    \begin{array}{ll}
        \frac{|\delta|}{\sqrt{|\varepsilon|}}\wedge \sqrt{|\delta|} & \mbox{when } \varepsilon\neq0, \\
        \sqrt{|\delta|} & \mbox{otherwise.}
    \end{array}
\right.
$$
$f$ is continuous since $\lim\limits_{\varepsilon\to 0}\frac{|\delta|}{\sqrt{|\varepsilon|}}\wedge \sqrt{|\delta|}= \sqrt{|\delta|}$ and the $\min,|\cdot|,\sqrt{\cdot}$ are continuous functions. Considering $f$ instead of the original RHS allows us to avoid undetermined forms.
Claim: For all $\varepsilon,\delta\in\mathbb{C}$ and any complex square root $\sqrt{\cdot},$
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|\wedge|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|\leq f(\varepsilon,\delta).$$
Proof:
Throughout the proof, we use the fact that for any $z\in\mathbb{C},$ $|\sqrt{z}|=\sqrt{|z|}.$
Step 1)  Suppose $\varepsilon=0.$ Then the inequality becomes
$$\sqrt{|\delta|}\leq\sqrt{|\delta|},$$
which is satisfied for any $\delta\in\mathbb{C}.$
Step 2) Suppose $\varepsilon\neq 0.$ For all non-negative reals $a,b\geq 0,$
$$\sqrt{ab}\geq a\wedge b,$$
so that
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|\wedge|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|\leq\sqrt{|\varepsilon+\delta-\varepsilon|}=\sqrt{|\delta}|.$$
This yields the first part of the inequality.
Note that
$$2\sqrt{|\varepsilon|}=|\sqrt{\varepsilon}-\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}+\sqrt{\varepsilon+\delta}|\leq|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|+|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|$$
by the triangle inequality. Suppose now
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|+|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|=0.$$
In turn, this implies
$$\varepsilon =0,$$
which contradicts our assumptions. So suppose
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|+|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|>0.$$
Now for real numbers $a,b\geq 0$ such that $a+b\neq 0,$
$$\frac{2ab}{a+b}\geq\frac{ab}{a\vee b}=a\wedge b.$$
This finally yields
$$|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|\wedge|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|\leq \frac{2|\delta|}{|\sqrt{\varepsilon+\delta}-\sqrt{\varepsilon}|+|\sqrt{\varepsilon+\delta}+\sqrt{\varepsilon}|}\leq\frac{|\delta|}{\sqrt{|\varepsilon|}},$$
and concludes the proof.

Square root inequality revisited


Language missing from node field arrays

Question: For some fields, not all, the language index is missing from the field array. For example, here is the body field of the packaged blog content type (using print_r):
[body] => Array
    (
        [0] => Array
            (
                [value] =>
Shirley Temple[...]
                [summary] =>
Shirley Temple[...]
                [format] => html_raw
                [safe_value] =>
Shirley Temple[...]
                [safe_summary] =>
Shirley Temple[...]
            )
    )

Expected structure:
[body] => Array
        (
            [und] => Array
                (
                    [0] => Array
                        (
                            [value] =>
Shirley Temple[...]
                            [summary] =>
Shirley Temple[...]
                            [format] => html_raw
                            [safe_value] =>
Shirley Temple[...]
                            [safe_summary] =>
Shirley Temple[...]
                        )
                )
        )

I have only ever seen this happen on two fields (the one above and another field from a different content type). Other fields on the blog content type are fine. It looks like it is only happening on my development environment, production seems to be fine. If I set $reset to true when calling node_load() then the structure is fine.
field_get_items() returns false and wrapping the node using the Entity API's entity_metadata_wrapper() and calling $wrapped_node->body->value() I gives the following PHP error:

EntityMetadataWrapperException: Missing data values. in EntityMetadataWrapper->value() (line 83 of /vagrant/web/sites/all/modules/entity/includes/entity.wrapper.inc).

Setup:

Drupal 7.28
  PHP 5.3.10
  MySQL 5.5.34
  Apache 2.2.22
  memcached 1.4.13
Answer: I haven't run into this issue again. I think a Drupal update resolved the problem.

Language missing from node field arrays


How to find $\phi$ for triple integral spherical coordinates

Question: Having trouble calculating bounds and how to do it generally for other terms.
I've been asked to find the volume of the solid bounded by the sphere
$x^2 + y^2 + z^2 = 4$
and the cones
$z = \sqrt{x^2 + y^2}$
$z = -\sqrt{3x^2 + 3y^2}$
I assume that $0 <= \rho <= 2$ and $0 <= \theta <= 2\pi$, but I don't know how to find $\phi$ for either cones.
Comment: You can do it geometrically, by drawing right triangles (for the first cone, you have a $z=r$, so it's an isosceles right triangle, and $\phi=\pi/4$. Alternatively, put spherical coordinates into the equation and you'll get  $\rho\cos\phi = \rho\sin\phi$, so $\cos\phi = \sin\phi$, so $\phi = \pi/4$. You can work on the other one.
Answer: Using cylindrical coordinates, we have the equations $$\begin{align}
z^2&=4-r^2,\\
z&=r\\
z&=-\sqrt 3 r
\end{align}.$$
The first equation gives $4-r^2\ge 0,$ or $0\le r\le 2.$ Then the last two give $-\sqrt 3 r\le z\le r.$ Finally, we have $0\le \phi\le 2π,$ since all the equations are independent of $\phi.$
So you want to calculate the $$\int_0^{2π}\int_0^2\int_{-\sqrt 3 r}^r{r\mathrm dz \mathrm dr\mathrm d\phi.}$$
Comment: In the title I specified spherical coordinates, not cylindrical.
Comment: First, you're using European/physics $\phi$, when the OP wanted $\phi$ to be the angle from the positive $z$-axis. Second, the OP specifically asked for help in spherical coordinates. Third, your $dV$ is wrong.  Fourth, where are you using the region between the sphere and the cones? I didn't check the rest.
Comment: @Jack That's right. I thought it wasn't necessary. This gives you what you want eventually with as little work (perhaps littler).
Comment: @TedShifrin I don't understand your quibble. The ones one notation I ignore. But what do you mean about the differential of volume of the specified region not being correct in cylindrical coordinates? What is it supposed to be, then? Thank you.
Comment: $dV = r\,dz\,d\phi$ in cylindrical coordinates. But the serious complaint is that you're ignoring the sphere. You're finding the volume between the two cones inside a cylinder of radius $2$, nothing to do with the sphere.
Comment: @TedShifrin Oh, well yes, that's true. I forgot the scaling jacobian $r.$ Thanks for that.


Docker can't load config file, but container works fine

Question: I'm using docker-machine with generic driver to deploy containers on an existing remote host. But when I switch to the remote host and try to run a container, this happens:
$ docker-machine create --driver generic --generic-ip-address=$REMOTEIP \
--generic-ssh-key ~/.ssh/id_rsa --generic-ssh-user $REMOTEUSER vm
[works fine]

$ eval $(docker-machine env vm) #switch to remote host
[works fine]

$ docker run -it busybox sh
WARNING: Error loading config file:/home/user/.docker/config.json - open /home/user/.docker/config.json: permission denied
[Even with the warning, runs fine]

The container runs fine anyway, but I want to solve that warning message.
Given that user doesn't exist in the remote host, I guess that this file doesn't exist. But ..
1) why does the engine search for it in the first place? shouldn't it search for the config.json of $REMOTEUSER instead of that?
2) and why the container runs properly on the remote host anyway?
Answer: Docker is not searching for that file in the remote host but in the local host. Turns out that file exists and it's owned by root.
$ ls -lsa ~/.docker/config.json  4 -rw------- 1 root root \
95 dic 29 15:29 /home/user/.docker/config.json

That's why it says permission denied.
A simple chown fixes the issue:
$ sudo chown user:user /home/user/.docker -R


Serialize Flutter Widget

Question: Is there any way to serialize the Build layout of a stateless flutter widget and save it to a database?
I would like to design many simple Badge widgets and don't want to update the App each Time I have a new one.
I would like to save new widgets to a db instead.
Answer: Remote flutter widgets - may be the direction. It has mechanism for rendering widgets based on declarative UI descriptions that can be obtained & rendered at runtime.

Serialize Flutter Widget


Find explicit formula for $y_{n}=\frac{1}{n (\sqrt 2)^n}+\frac{n-1}{n} y_{n-2}$

Question: Is it possible to find a explicit formula here ?
This is the reduction formula of$$\int_{0}^{\frac{\pi}{4}} (\cos x)^n dx$$.
If the limits are from $0$ to $\frac{\pi}{2}$ then the nice walli's formula can be obtained,however i have no idea regarding solving this kind of recurrences. Any help will be appreciated.
Answer: Starting with
$$
y_n=\frac1{n\,2^{n/2}}+\frac{n-1}{n} y_{n-2}\tag1
$$
Multiply $(1)$ by $\frac{\Gamma\left(\frac{n+2}2\right)}{\Gamma\left(\frac{n+1}2\right)}=\frac{n}2\frac{\Gamma\!\left(\frac{n}2\right)}{\Gamma\!\left(\frac{n+1}2\right)}=\frac{n}{n-1}\frac{\Gamma\left(\frac{n}2\right)}{\Gamma\left(\frac{n-1}2\right)}$:
$$
\frac{\Gamma\!\left(\frac{n+2}2\right)}{\Gamma\!\left(\frac{n+1}2\right)}y_n
=\frac1{2^{\frac{n}2+1}}\frac{\Gamma\!\left(\frac{n}2\right)}{\Gamma\!\left(\frac{n+1}2\right)}+\frac{\Gamma\!\left(\frac{n}2\right)}{\Gamma\!\left(\frac{n-1}2\right)} y_{n-2}\tag2
$$
Thus, we get
$$
\overbrace{\frac{\Gamma\!\left(n+1\right)}{\Gamma\!\left(n+\frac12\right)}y_{2n}}^{\large\alpha_n}
=\frac1{2^{n+1}}\frac{\Gamma\!\left(n\right)}{\Gamma\!\left(n+\frac12\right)}+\overbrace{\frac{\Gamma\!\left(n\right)}{\Gamma\!\left(n-\frac12\right)}y_{2n-2}}^{\large\alpha_{n-1}}\tag3
$$
and
$$
\overbrace{\frac{\Gamma\!\left(n+\frac32\right)}{\Gamma\!\left(n+1\right)}y_{2n+1}}^{\large\beta_n}
=\frac1{2^{n+\frac32}}\frac{\Gamma\!\left(n+\frac12\right)}{\Gamma\!\left(n+1\right)}+\overbrace{\frac{\Gamma\!\left(n+\frac12\right)}{\Gamma\!\left(n\right)}y_{2n-1}}^{\large\beta_{n-1}}\tag4
$$
Therefore, noting that $\alpha_n=\alpha_0+\sum\limits_{k=1}^n(\alpha_k-\alpha_{k-1})$,
$$
y_{2n}=\frac{\Gamma\!\left(n+\frac12\right)}{\Gamma\!\left(n+1\right)}\left[\frac{y_0}{\sqrt\pi}+\sum_{k=1}^n\frac1{2^{k+1}}\frac{\Gamma\!\left(k\right)}{\Gamma\!\left(k+\frac12\right)}\right]\tag5
$$
and noting that $\beta_n=\beta_0+\sum\limits_{k=1}^n(\beta_k-\beta_{k-1})$,
$$
y_{2n+1}=\frac{\Gamma\!\left(n+1\right)}{\Gamma\!\left(n+\frac32\right)}\left[\frac{y_1\sqrt\pi}2+\sum_{k=1}^n\frac1{2^{k+\frac32}}\frac{\Gamma\!\left(k+\frac12\right)}{\Gamma\!\left(k+1\right)}\right]\tag6
$$
It might be useful to recall that $\Gamma(n+1)=n!$ and $\Gamma\!\left(n+\tfrac12\right)=n!\frac{\sqrt\pi}{4^n}\binom{2n}{n}$.
Unfortunately, I am not aware of closed forms for the sums in $(5)$ and $(6)$.
Comment: @clathratus: if the sum has a fixed number of terms, yes. However, if the number of terms grows with $n$, I don't think it would.
Comment: @MDesmond: I have added more connection between $(3)$ and $(5)$ and between $(4)$ and $(6)$. I hope that helps.
Comment: @NewBornMATH: if you have a recursion like $y_n=a_n+\frac{n-1}ny_{n-2}$, multiply by $b_n$ to get $b_ny_n=a_nb_n+b_n\frac{n-1}ny_{n-2}$. Now, we would like to find $b_n$ so that $b_{n-2}=b_n\frac{n-1}n$. Since the indices skip $2$, it is easier to substitute $n\mapsto2n$ to get $b_{2n}=b_{2n-2}\frac{n}{n-\frac12}$ which has a solution $b_{2n}=\frac{\Gamma(n+1)}{\Gamma\left(n+\frac12\right)}$, which says $b_n=\frac{\Gamma\left(\frac{n+2}2\right)}{\Gamma\left(\frac{n+1}2\right)}$
Comment: Wouldn't a sum with a finite number of terms qualify as a closed form?
Comment: @robjohn after (3) and (4)  how you obtained (5) and (6) , is it by the same method as clathratus has mentioned ?
Comment: As far as I'm concerned, if one can calculate something in a finite number of steps, that qualifies as a closed form $\Rightarrow$ +1
Comment: ■(1)using $$f_n=f_0\prod_{i=1}^{n}\beta_i+\sum_{k=0}^{n-1}\alpha_{n-k}\prod_{j=1}^{k}\beta_{n-j+1}$$ one can obtain 5,6 from 3,4 then why you have mentioned that $$\beta_n=\beta_0+\sum\limits_{k=1}^n(\beta_k-\beta_{k-1})$$ and $$\alpha_n=\alpha_0+\sum\limits_{k=1}^n(\alpha_k-\alpha_{k-1})$$ , in fact from your assumption $\alpha_{n}$ and $\beta_{n}$ are variable. How can you get that formula by not using the first mentioned fact and using two of your mentioned facts ? ■(2) How do you perfectly guess what gamma function to multiply?
Comment: @NewBornMATH: I was answering M Desmond's question about how I got $(5)$ and $(6)$ from $(3)$ and $(4)$. I did not use clathratus' formula, I simply used $\alpha_n=\frac{\Gamma\left(n+1\right)}{\Gamma\left(n+\frac12\right)}y_{2n}$ and $\alpha_k-\alpha_{k-1}=\frac1{2^{n+1}}\frac{\Gamma\left(n\right)}{\Gamma\left(n+\frac12\right)}$ from $(3)$ to get $(5)$. Similarly, I used $\beta_n=\frac{\Gamma\left(n+\frac32\right)}{\Gamma\left(n+1\right)}y_{2n+1}$ and $\beta_k-\beta_{k-1}=\frac1{2^{n+\frac32}}\frac{\Gamma\left(n+\frac12\right)}{\Gamma\left(n+1\right)}$ from $(4)$ to get $(6)$.
Comment: @NewBornMATH: I am not sure what you mean by $\alpha_n$ and $\beta_n$ are variable. They are functions of $y_{2n}$ and $y_{2n+1}$.
Answer: We can find an explicit formula for $y_n$ when $n$ is even. Here's how. Define
$$D_n=y_{2n}$$
Hence we have
$$D_n=\frac1{2n\cdot (\sqrt2)^{2n}}+\frac{2n-1}{2n}D_{n-1}$$
$$D_n=\frac1{2^{n+1}n}+\frac{2n-1}{2n}D_{n-1}$$
And we have the base case $D_0=\int_0^{\pi/4}dx=\pi/4$.
Then we note that, given the general recurrence $$f_n=\alpha_n+\beta_nf_{n-1}$$
Where $\alpha, \beta$ are explicit functions of $n$ and the base case $f_0$ is known. We have
$$f_n=f_0\prod_{i=1}^{n}\beta_i+\sum_{k=0}^{n-1}\alpha_{n-k}\prod_{j=1}^{k}\beta_{n-j+1}$$
Which is an explicit function of $n$. Choosing $\alpha_n=\frac1{2^{n+1}n}$ and $\beta_n=\frac{2n-1}{2n}$ We have
$$D_n=\frac\pi4\prod_{i=1}^{n}\frac{2i-1}{2i}+\sum_{k=0}^{n-1}\frac{2^{k-n-1}}{n-k}\prod_{j=1}^{k}\frac{2n-2j+1}{2n-2j+2}$$
$$D_n=\frac\pi{4^{n+1}}{2n\choose n}+\frac1{2^{n+1}}\sum_{k=0}^{n-1}\frac{1}{n-k}\prod_{j=1}^{k}\frac{2n-2j+1}{n-j+1}$$
I do not know how to simplify the final product anymore though. Note that this formula for $D_n$ works for integer $n\geq0$ because $\sum_{k=0}^{-1}:=0$ and $\prod_{j=1}^{0}:=1$
I hope this helped :)
Answer: But why not use the following relationship
$$\cos^nx=\frac{1}{2^n}\sum_{k=0}^{n}\binom{n}{k}\cos(n-2k)x$$
Then
$$y_{n}=\int_{0}^{\frac{\pi}{4}}\cos^nx \ dx=\frac{1}{2^n}\sum_{k=0}^{n}\binom{n}{k}\frac{\sin\frac{(n-2k)\pi}{4}}{n-2k}$$
The last formula works for $n=2m+1$
For $n=2m$ we get
$$y_{n}=\int_{0}^{\frac{\pi}{4}}\cos^nx \ dx=\frac{\pi}{4}\frac{\binom{n}{\frac{n}{2}}}{2^n}+\frac{1}{2^{n-1}}\sum_{k=0}^{\frac{n}{2}-1}\binom{n}{k}\frac{\sin\frac{(n-2k)\pi}{4}}{n-2k}$$
Comment: @MDesmond $\cos x=\frac{e^{ix}+e^{-ix}}{2}$, then raise to the n-th power and use Newton's Binomial Theorem. Finally,separate real and imaginary parts.
Comment: Can you please tell me where i can find the proof of that identity?


Relation between Morse number and Heegaard number

Question: Given a closed 3-manifold $M$, a self-indexing Morse function $f:M\to[0,3]$ produces a Heegaard splitting by : $$M=f^{-1}([0,3/2])\cup f^{-1}([3/2,3]).$$
(This question discussed a bit on the topic.)
Now, we define :
Definition : Let $M$ be a closed 3-manifold. The Morse number $\mathfrak{m}(M)$ of $M$ is the minimal number of critical points of Morse functions. The Heegard number $\mathfrak{h}(M)$ of $M$ is the smallest genus of any Heegard splitting of $M$.
We have a theorem that Milnor used to create exotic spheres :
Theorem : (Reeb) Let $M$ be a closed $n$-manifold such that $\mathfrak{m}(M)=2$. Then $M$ is a topological $n$-sphere.
Moreover, by a result from Alexander, we have that $\mathbb{S}^3$ is the only manifold whose Heegaard number is $0$, that is we have, for a closed 3-manifold : $$\mathfrak{h}(M)=0\iff\mathfrak{m}(M)=2\iff M\cong\mathbb{S}^3.$$
This suggests that the two may be related. My questions are the following :

Are $\mathfrak{m}(M)$ and $\mathfrak{h}(M)$ related ?

Given a self-indexing Morse function $f:M\to[0,3]$, is the genus of the associated Heegaard splitting related to the number of critical points of $f$ ?

About the first question, I am wondering whether there is a somewhat-nice formula, like a linear relation $\mathfrak{m}(M)=A\mathfrak{h}(M)+B$ ? About the second question, I found no literature about this construction for a Heegaard splitting, the one I knew about was using Moise's triangulation theorem.

As a side note, about the first question, if a linear relation existed, taking $M=\mathbb{S}^3$ or $\mathbb{S}^1\times\mathbb{S}^2$ would yield (unless I made mistakes in my computations) $\mathfrak{m}(M)=2[\mathfrak{h}(M)+1]$. However, I didn't manage to compute the two numbers for a 3-torus $\mathbb{T}^3$ to check whether there is a contradiction. In any case, a polynomial relation $\mathfrak{m}(M)=P(\mathfrak{h}(M))$ would be respectable !

Edit :
I've been reading some stuff here and there, and I have noticed :

Given a self-indexing Morse function $f:M\to[0,3]$, assuming that there are only one index zero and one index three critical points, then the genus of the associated Heegaard splitting is $g=\# f^{-1}(1)$ the number of index one critical points.

It is always possible to construct a Morse function satisfying the hypotheses of the previous bullet.

However, my concern is that the function constructed this way is not necessarily minimal (in the sense that its number of critical points is not necessarily the Morse number of the manifold). Moreover, this construction is certainly not natural. At last, I am not sure that given a self-indexing Morse function $f:M\to[0,3]$, the construction of the new Morse function $\tilde{f}:M\to[0,3]$ with $\# f^{-1}(0)=\# f^{-1}(3)=1$ preserves the total number of critical points -- I haven't yet looked at the very details of this construction (see Milnor, Lectures on the h-cobordism theorem).
In any case, this partially answers my second question, at least in that special setting where we assume only one index zero/three critical point.
It would be interesting to see what you think about this !
Answer: Here is a somewhat sketchy answer, based on the creed that Morse functions and (smooth) handles should be thought about interchangeably (and that Heegaard splittings are a form of handle decomposition).
Suppose $M$ is a closed, connected, orientable 3-manifold and $f:M\rightarrow [0,3]$ is a self-indexing Morse function. For $k=0,1,2,3$, let $c_k$ be the number of critical points of $f$ having index $k$. We can see that $c_1-c_0=c_2-c_3$, because $$0=\chi(M)=c_0-c_1+c_2-c_3.$$
Since $f^{-1}[0,1.5]$ is formed from $c_0$ zero-handles and $c_1$ one-handles, we can see that it is a handlebody of genus $c_1-c_0+1$ (this uses the assumption that $M$ is connected and orientable). Considering the upside-down Morse function $-f$, we can similarly observe that $f^{-1}[1.5,3]$ is a handlebody of genus $c_2-c_3+1$. So the genus of this particular Heegaard splitting is $c_1-c_0+1=c_2-c_3+1.$ If $c_0=c_3=1$, then the genus of this particular Heegaard splitting is $c_1=c_2.$
Suppose that our Morse function is minimal, i.e. it has $\mathfrak m(M)$ critical points. If we have $c_0>1$, then there are multiple zero-handles, which need to be glued together by 1-handles in order for $M$ to be connected. Hence, there is an index-one critical point $q$ whose two descending flow lines limit to two different critical points $p$ and $p'$ of index zero. Since there is exactly one flow line from $q$ to $p$, we can cancel these critical points, which contradicts the minimality of $f$. Thus, we must have had $c_0=1$ to begin with. We can see that $c_3=1$ by applying the same argument to $-f$. This proves that $$\mathfrak h(M)\leq c_1=\frac{2c_1+2}{2}-1=\frac{c_0+c_1+c_2+c_3}{2}-1=\frac{\mathfrak m (M)}{2}-1.$$ To see the reverse inequality, we need to prove that a genus $g$ Heegaard splitting gives rise to a Morse function $f:M\rightarrow [0,3]$ with $c_0=c_3=1$ and $c_1=c_2=g$. Letting $H_g$ denote a handlebody of genus $g$, we can define a self-indexing Morse function $h:H_g\rightarrow[0,1.5]$ having one index-zero critical point and $g$ index-one critical points, and satisfying $h^{-1}(1.5)=\partial H_g$ (because $H_g$ can be formed from a single zero-handle and $g$ one-handles). Then $3-h:H_g\rightarrow[1.5,3]$ is also a self-indexing Morse function having one index-three critical point and $g$ index-two critical points, and satisfying $(3-h)^{-1}(1.5)=\partial H_g$. Being careful to preserve smoothness, we can glue these two functions along the splitting surface of the Heegaard splitting to define the desired Morse function $f:M\rightarrow [0,3].$
Comment: Thank you for resurrecting this long-forgotten question!


Formula to inscribe nested polygons tilted by $x^\circ$?

Question: I created these images way back in 2019 before I learned programming:

Now I am trying to programmatically generate images like them using Python.
Basically, I want to make something like this:

In short, you start off with a regular polygon with n sides, then you create new regular polygon of the same number of sides such that the vertices of the new polygon are on the sides of the original polygon, and each of the sides of the new polygon and the corresponding side in the original polygon form an angle of x degrees.
Then you create a new regular polygon with n sides whose vertices are on the second polygon and the pairs of corresponding sides also form an angle of x degrees. And then you recursively do this until a certain number of iterations is reached.
I want to know given the number of sides of the polygon, and the angle of rotation, how to calculate the corresponding distance the vertices need to be displaced along its sides.
For example, I have calculated the cases of squares and equilateral triangles:

For the square, let its side be s, the angle be a, it is easy to see the two legs of the right triangle formed by the rotated side and the original sides add together to s.
let x be the distance needed, let y be s - x.
It is easy to see y = x / tan(a)
x+y=s
y=x/tan(a)
x+x/tan(a)=s
x = s*tan(a)/(tan(a)+1)

So the vertices need to be displaced along the sides by s*tan(a)/(tan(a)+1)

For the equilateral triangle it is harder to calculate the distance needed, but if you draw a line from one of the rotated vertices perpendicular to its corresponding side in the original triangle, the right triangle formed by the operation will always contain a 30° angle.
Let x be the amount of displacement needed, and let y be s - x, x can be calculated with the following:
x + y = s
y = x/2 + x*cos(30°)/tan(a)
x + x/2 + x*cos(30°)/tan(a) = s
3x/2 + x*cos(30°)/tan(a) = s
x*(3/2+cos(30°)/tan(a))=s
x=s/(3/2+cos(30°)/tan(a))

Unfortunately my knowledge of geometry stops here, I can't calculate the amount of displacement of the vertices along the sides needed for regular polygons with more sides.
I know how to calculate the coordinates of vertices of regular polygon of given number of sides, I just don't know the amount of displacement corresponding to angles. Can anyone generalize the calculations I used?

Fixed logical reasoning errors in the question body, I was busy with other things so I didn't notice the error until now.

I did it!

Code
Comment: Isn't [MathJax](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) the norm here (the body)?
Comment: @user21820 - Aren't questions with MathJax in the title not allowed on the HNQ list? This was on the list a few minutes ago.
Comment: @mr_e_man: As per Math SE guidelines, [we should use descriptive titles using MathJax as appropriate](https://math.meta.stackexchange.com/a/10144). Whether MathJax is allowed on the HNQ or not should never be a reason to degrade the quality of question titles on Math SE.
Comment: @user21820 - Yes, but I don't think it's necessary for quality in this case. "tilted by a given angle" would be just as descriptive.
Comment: @mr_e_man: Feel free to ask a moderator about this.
Comment: @mr_e_man: It would be, and I think more descriptive of the problem to boot, but in this case, the difference in intelligibility is small, and so is the difference in searchability. It would be different if the MathJax portion were not quite so small.
Comment: @user21820 - Another problem with $x$ in the title is that $x$ is also used as the desired length, and the given angle is changed to $a$.
Comment: How the heck did this post get downvoted five days after it was last modified? I don't think this post is displayed in the front pages, so the downvoter knows this post and views this post specifically just to downvote it, why would anyone do that? They must have no better things to do.
Answer: If one iterates over the sides of a regular polygon with side length 1, let $\lambda$ be the constant value such that one must go a distance of $\lambda$ along each side of the polygon to find the vertices of the polygon in the next iteration (going in an anti-clockwise direction).
We find using trigonometry this constant value of $\lambda$ for any given angle $\alpha$ and $n$ being the number of sides of the polygon we wish to iterate on. An interior angle $\beta$ of the polygon will be $180\cdot\frac{n-2}{n}$ degrees. By the law of $\sin$es,
$\frac{\sin^2 \alpha}{\lambda^2} = \frac{\sin^2 \beta}{c^2}$, where $c^2 = 2\lambda^2 - 2\lambda + 1 + 2\lambda(\lambda-1)\cos\beta$ (by the law of cosines), and so therefore $\frac{c^2}{\lambda^2} = \frac{\sin^2\beta}{\sin^2\alpha}$.
This is a quadratic in $\mu = \frac{1}{\lambda}$, which can be written
$\mu^2 - 2(1+\cos\beta)\mu + 2(1 + \cos\beta) = \frac{\sin^2\beta}{\sin^2\alpha}$. Solving for $\mu$, we get:
$$\mu = 1+\cos\beta \pm \sqrt{(1+\cos\beta)^2-(2+2\cos\beta-\frac{\sin^2\beta}{\sin^2\alpha})} = 1 + \cos\beta \pm \sqrt{\frac{\sin^2 \beta}{\sin^2 \alpha} - \sin^2\beta}$$
$$= 1 + \cos\beta \pm \sin\beta\sqrt{\csc^2\alpha - 1} = 1 + \cos\beta \pm \sin\beta\cot\alpha$$ from which we choose the value of $\mu$ such that $0 \leq \lambda \leq 1$ ($\mu \geq 1$). So $\mu = 1 + \cos\beta + \sin\beta\cot\alpha$. And therefore
$$\lambda = \frac{1}{1 + \cos\beta + \sin\beta\cot\alpha}$$
If your regular polygon has side length $s$, then multiply the $\lambda$ value by $s$. It is easiest however to let $\lambda$ be between $0$ and $1$ and always move in relation to the side you are currently calculating with.
From here, the rest is quite simple. Create an array which stores lists of vertices. Iterate on the last member of this array, finding the new vertices by moving $\lambda$ along each side of the regular polygon and then append this set of new vertices to the end of the array.
Here is a sample, with $n = 7$ and $\alpha = 15$, $100$ iterations having been done.

$n = 4$, $\alpha = 4$, $100$ iterations


Can we display region label from Layouts?

Question: We have a MYTHEME.layouts.yml file which defines regions...
<code>layout
  label: 'Layout Name'
  path: templates/panels
  template: layout-template
  default_region: theregion
  regions:
    theregion:
      label: 'This is The Region'
</code>
In the template we display fields added to the region with
<code>{{ content.theregion }}
</code>
Can we display the label that we defined?
Answer: The labels are for administration purposes and should not be used in templates as they are hard coded and can't be changed in the UI. A better option would likely be to use a Text field where you want to display the label as that can easily be changed.
That said, you can output the region name in the twig template like this:
<code>{{ layout.regions.theregion.label }}
</code>
Comment: Thanks!  We prefer to have the labels be not easily changed.


Add scrolling effect to hidden node title

Question: Here:
http://jsfiddle.net/sdleihssirhc/AYYQe/3/
There is a nice JavaScript code to ellipsize text when it's too long. On hover, the text  slide to the left,  and show the hidden part.
I'm struggling to make this script work in a view, to ellipsize and show hidden part from node titles.
This is my  View  structure.

[picture]

[title]

this is the CSS I'm using:
#tweet, #tweet_js { border:1px solid red; width:25em; padding:.5em; }
#tweet_js { overflow:hidden; white-space:nowrap; }
.hiding { text-overflow:ellipsis; }

and this is the code:
var tweet = document.getElementById('tweet');
tweet.id = 'tweet_js';
tweet.className = 'hiding';

var slide_timer,
max = tweet.scrollWidth,
slide = function () {
    tweet.scrollLeft += 1;
    if (tweet.scrollLeft < max) {
        slide_timer = setTimeout(slide, 40);
    }
    };

tweet.onmouseover = tweet.onmouseout = function (e) {
e = e || window.event;
e = e.type === 'mouseover';
clearTimeout(slide_timer);
tweet.className = e ? '' : 'hiding';
if (e) {
    slide();
} else {
    tweet.scrollLeft = 0;
}
};

I added the JavaScript file in in the module's .info file using this :
scripts[] = script.js

but nothing is working, I have tested  this JavaScript code in HTML page, and its working  only when placed before  the ending body tag.

(JavaScript and CSS are not mine, they were posted by sdleihssirhc as an answer to this question: https://stackoverflow.com/questions/4755593/css-jquery-powered-sideways-scrolling-text-on-hover )
Answer: There should be no direct errors if you got it working on a HTML page. I would suggest checking from the html source that your js file is actually loaded (if not clear the caches). Additionally try wrapping the javascript code inside
jQuery(document).ready(function() {
  //code here
});

or a possibly better option with Drupal 7:
Drupal.behaviors.exampleModule = {
  attach: function (context, settings) {
    // code here
  }
};

You might find additonal useful info about managing javaScript in Drupal 7 here.
Comment: Thank you Dooshta, It's not that the file is not loaded, I can see it in the html source, but It seems  that :
1- the slide effect doesn't work in RTL.
2- In LEFT TO RIGHT mode. The effect is only working with one title. I have a View with more than 20 posts, all titles has the "tweet ID" but the (.hidden) class only apply to the first one.
Comment: @Nizarnav The 'id' attribute must be unique on a given page so if you have 20 titles with the same 'id' on the same page it isn't working like you can see. You would have to use the 'class' attribute instead, but the script should then also be modified accordingly.


When would one use a hard margin SVM?

Question: Is there ever a good case to use a hard margin SVM? It seems far more likely to overfit and doesn't seem computationally faster than a soft margin SVM, so there doesn't seem to be any reason to ever use it.
Answer: This is analogous to "why use linear regression if ridge regression is available" - if your primary goal is predictive accuracy, you wouldn't.
Since SVMs are only used for predictive modeling, I don't think there is much real world use for hard margin.  The soft margin problem includes the hard margin as a special case, so if you're doing everything properly, your hyperparameter tuning of the soft margin will find the hard margin solution if that maximizes the predictive power of the model.
That said, hard margin SVMs are useful to understand as a stepping stone to the soft margin case.  So there is pedagogical and mental mapping use for them.
Answer: The real world problems aren't linearly separable usually, thus you can't use hard margin. However if you find a mapping corresponding to a kernel that make transformed data linearly separable in the Hilbert space you can use hard margin. This is equal to extract features from training set according to mentioned mapping and using feature data as new training set. If the mapping make feature data linearly separable you can use hard margin
Comment: One can make the data linearly separable in feature space as you mention. And, it's then *possible* to fit a hard margin SVM. But, that doesn't mean it's a good idea. Doing this can lead to overfitting. Soft margin SVMs reduce overfitting, and will probably give better generalization performance on real data, including in the kernelized case.

When would one use a hard margin SVM?


data.table summary by group for multiple columns

Question: dt = data.table(a = rep(x = c(1, 2, 3), 3), y = as.numeric(1:9), z = as.numeric(2:10))

I know this summarizes the value by group for one column:
dt = data.table(a = rep(x = c(1, 2, 3), 3), y = as.numeric(1:9), z = as.numeric(2:10))

But if I try for multiple columns:
dt[, .(c('y', 'z') = list(mean(y) mean(z)), by = a]

I get the error

Error: unexpected '=' in "dt[, .(c('y', 'z') ="

What I'm looking for:
## data.table equivalent to
dt %>% group_by(a) %>% summarise(y = mean(y), z = mean(z))
#  a     y     z
#  <dbl> <dbl> <dbl>
#1     1     4     5
#2     2     5     6
#3     3     6     7

Answer: dt <- dt[, .(y = mean(y), z = mean(z)), by=.(a)]


Theorems similar to Baire Category theorem

Question: A variant of Baire Category Theorem states that if a complete metric space is a countable union of closed sets then at least one of the sets has a non-empty interior.
In my study I have a Banach space which is a countable union of closed sets $F_n$, with the property that for every $x \in F_n$, if $\lambda \in \Bbb{K}$ with $| \lambda| \geq 1$ then $\lambda x \in F_n$. I would need to find a set out of these  which contains a circle(not necessarily a disk) around the origin(not necessarily centered in the origin), but containing the origin in its interior. I know this is almost impossible using only these conditions, but maybe I can find more properties of the sets $F_n$ before leaving this lead.
My question is like this:

Are there any theorems similar to Baire Category theorem which can prove something like this? Even if there is no theorem that directly solves the problem above, I am interested in any exotic variant of Baire Category theorem, in which maybe the sets $F_n$ have additional properties.

References are welcome. Thank you.
Answer: Not even true for $\mathbb{R}^n$ for $n>1$.  Let $v$ be a non-zero vector with rational co-ordinates, and let $F_v = \{w: |w \cdot v| \geq |v|^2\}$.  Let $F_0 = \{0\}$.
Then $\{F_v\}$ covers $\mathbb{R}^n$, but there is no sphere containing $0$ in any $F_v$, since no vectors perpendicular to $v$ are in $F_v$.
Additional comments: I think it's wrong to consider your goal as being somehow related to the Baire Category Theorem.  BCT is inherently purely topological, while what you are looking for is something geometrical, including your desire for a circle.
If you have circle in $F_n$ that contains $0$ in the interior, you can find a circle in $F_n$ which is centered on $0$.
Obviously, for $F$ to contain a circle around $0$, you need, at minimum, for each $v$, a $\lambda > 0$ such that $\lambda v \in F$.  That's not sufficient, however.
Comment: I know it isn't true like this. I asked if there exists another variant of Baire Theorem, which might have a result similar to this.


Logic without the three traditional laws of thought

Question: The wikipedia page on the laws of thought mentions the The three traditional laws: The Law of the Excluded Middle, Law of Non-contradiction and The Law of the Identity. These laws are embedded in a vast majority of logic systems, but not all.
In intuitionistic logics, the The Law of the Excluded Middle does not hold. In paraconsistent logics, the Law of Non-contradiction does not hold. As pointed out in this answer, in Schrodinger logics, the The Law of the Identity does not hold.
One interesting thing about these logics is that the removal of the laws has a larger ramification, it affects other inference rules. For example, in intuitionistic logic the law of double negation doesn't hold, and reduction ad absudum may only prove negative statements. Another example, as stated in stanford's entry on paraconsistent logic: "One feature of LP which requires some attention is that in LP modus ponens comes out to be invalid". The removal of these laws makes the system restrictive in more ways than just not being able to use that specific law.
So that raises the quesion, what about a system where none of them hold? Can such a system make any deductions at all?
Note that this question is mostly for exploration/amusement/curiosity. It does not require an example of an actual formal system where these laws don't apply, as a formal system without any of these would hardly be of any use, and therefore, it has probably never been developed. However, it still feels like an interesting question.
Is it a requirement for at least one of these to hold for a system to be logical, or is it possible to build some system, even if very restrictive, in which none of these laws hold, but that is still capable of producing sound arguments?
Comment: "[Minimal Logic](https://en.wikipedia.org/wiki/Minimal_logic) is a symbolic logic system originally developed by Ingebrigt Johansson. It is an intuitionistic and paraconsistent logic, that rejects both the law of the excluded middle as well as the principle of explosion." The propositional calculus has no equality axioms either.
Answer: There are plenty of inference rules in classical logic which do not rely on any of those three laws. Some examples include:

Modus ponens: $A, A\rightarrow B\vdash B$.

Left and right conjunction elimination: $A\wedge B\vdash A$ and $A\wedge B\vdash B$.

Absorption: if $A, A\vdash B$ is a valid sequent, then $A\vdash B$ is a valid sequent. (Actually this is just a special case of absorption, but oh well.)

These are simply unrelated to LEM/noncontradiction (negation doesn't appear) or to identity (they make sense in propositional logic which has no notion of equality in the first place).
So we can drop all three "laws of thought" and still have a nontrivial deductive system. Of course, this raises the question of whether such a system still counts as a "logic," and there is no accepted notion of what exactly a logic is. But I believe the current stance is a very pluralistic one, according to which even such weak systems still count as logics. (FWIW I hold such a pluralistic view.)
Answer: Lukasiewicz 3-valued logic rejects both the law of noncontradition and the law of the excluded middle as general laws applicable to all propositions, although they do still apply in special cases. As a propositional logic, it does not make specific use of the law of identity.
This does impose certain restrictions on deduction. In particular, the presence of doubtful conditionals imposes limitations on the free use of common methods of deductive inference such as modus ponens and modus tollens. Proof by contradiction becomes much more difficult.  However,these methods do hold in modified or restricted form. With due attention to the necessary restrictions and requirements, it is possible to conduct valid and sound deductive reasoning in this system.


I'm having trouble finding the volume of a parallelepipid

Question: I'm having trouble resolving an issue involving the volume of a rectangular parallelepiped.
I know that to find the volume, just multiply the factors, that is the length, width, and height. However, none of the alternatives match the multiplication product.
I believe this has to do with "thickness", but I don't quite understand what it means and what I should do to solve the problem.
So I would like to know if anyone can help me with this problem.
Question
A factory sells chocolates in a wooden box, as shown.

The wooden box is shaped like a straight-rectangle parallelepiped whose external dimensions, in centimeters, are indicated in the figure. It is also known that the thickness of the wood, on all its sides, is $0.5\mathrm{cm}$.
What is the volume of wood used, in cubic centimeters, in the construction of a wooden box like the one described to pack chocolates?
a) $654$
b) $666$
c) $673$
d) $681$
e) $693$
What I tried:
$$\text{volume} = \text{length}\cdot x\cdot\text{width}\cdot x\cdot \text{height}$$
$$\text{volume} = 20\mathrm{cm}\cdot x\cdot 8\mathrm{cm}\cdot x\cdot 20\mathrm{cm}$$
$$\text{volume} = 3200 \mathrm{cm}^2$$
In the alternatives, there isn't any that match the value I got, and I believe that's because of that part of the question that talks about the thickness of the wood on each side, but since I'm not aware of that, I don't know what to do. I tried to divide the value found by $6$ since a parallelepipid has $6$ faces, but I didn't come up with a coherent answer.
Comment: Hint: from the volume of the "full" parallelipiped subtract the volume of the empty space inside.
Answer: Volume of Wood = External volume - Internal Volume
External Volume = $ 20 \times 8 \times 20 = 3200$
Internal Volume = $ 19 \times 7 \times 19 =2527$
Therefore,
Volume of Wood = $3200 - 2527 = 673$
Answer: The volume of wood used will be (Volume of "full" box)-(Volume of empty space left ) .
As the thickness of wood is $0.5 cm$ , a length of $0.5 cm+0.5 cm=1 cm$ will be reduced from each dimension to get the dimensions of the "empty" space left . Therefore , dimensions of "empty" space are $(19cm)$$(19cm)$$(7cm)$ . Therefore volume of empty space=$(19*19*7) cm^3$ , or $2527 cm^3$ .
Therefore ,volume of wood used = $(3200- 2527)cm^3$ or $673 cm^3$.


Listen to AJAX complete event from a behavior

Question: I have a form that has an AJAX button.  When I click it, it updates a bunch of stuff as expected which is fine.
I was wondering if there is a way to create a listener in behavior that gets called when the AJAX call is complete?
Thanks
Answer: Yes, there is :
Drupal.behaviors.YourBehaviour = {
attach: function(context, settings) {
  $('#yourform').ajaxComplete(function(event, xhr, settings) {
    if ($(event.target.id) == 'the-id-of-your-item') {
      // Your code here
    }
  });
 }
}

Comment: +1, but for Drupal 7 it would be `Drupal.behaviors.YourBehaviour = { attach: function() { $('#yourform').ajaxComplete...`
Comment: you don't need this $() just event.target.id you are't referencing an object
Comment: Because it's considered best practice and prevents namespaces collisions, among other things.
Comment: You're right : forgot a line while pasting !
Comment: Why wrap it in Drupal behaviours?
Answer: For versions of jQuery 1.8+, it seems you now must attach the .ajaxComplete function to the document, not the form or the view itself (see http://api.jquery.com/ajaxcomplete/)
The following worked for me on D7 with Jquery 1.10 and Views 7.x-3.8, where "your_view_id" is the machine name of the view set in the view's "Other" settings panel. There is a lot of other info in event, xhr and settings to key off of to determine if the ajax result is for the view you want, but this worked for my situation:
jQuery(document).ajaxComplete(function(event, xhr, settings) {
    if(typeof settings.extraData != 'undefined' && typeof settings.extraData.view_display_id != 'undefined') {

        switch(settings.extraData.view_display_id){

            case "your_view_id":

                console.log('your_view_id ajax results!');

                break;

            default:

                console.log('some other ajax result...');

                break;

        }
    }

});

Answer: None of the given solutions worked for me with Drupal 7.24, jQuery 1.11 and Views 7.x-3.8.
What user1193694 suggested was not bad, but the settings object that I received didn't have the extraData parameter.
When parsing the settings object i saw that the settings.data propertiy contains 'view_name=' and your view's machine name, so thats what i am filtering for:
jQuery(document).ajaxComplete(function(event, xhr, settings) {

    // see if it is from our view
    if (settings.data.indexOf( "view_name=your_views_name") != -1) {

            console.log('your_view_id ajax results!');

    }
});

Replace 'your_views_name' with the machine name of your view.


cPanel to LAMP FTP woes, how to configure/use ProFTPD like cPanel does?

Question: so yesterday I made the move to stop using cPanel on my CentOS 6 server and learn how to use it using a LAMP sertup.
My basic requirement was to just have a web server with ftp access for me and my registered users, I use atmail for my mailing and another server running mysql server on it.
cPanel was just over the top in that aspect, so I moved to LAMP. Now my issue is that I want to be able to make FTP users and lock them into their "home" directory such as /var/www/html/users/<user>
these are the steps I have taken:

1) wget proftpd-1.3.3e.tar.gz (from ftp repo)
2) tar zxvf proftpd-1.3.3e.tar.gz
3) cd /proftpd-1.3.3e.tar.gz
4) ./configure
5) make
6) make install
I edited /etc/proftpd.conf to this
  7) vi /etc/proftpd.conf
8) DefaultRoot ~
9) User     nobody
Group    nobody

thats as far as I have gotten, I attemped to make a user with this command

10) groupadd test
11) useradd -g test1 -p test1 -d /var/www/html/users/ -s
  /sbin/false test

i tried to login, but Filezilla throws a login incorrect error.
I have looked at maybe 20 guides on how to set up ProFTPD but I am still confused and has been nothing but a learning experience for me.
Can someone perhaps tell me the exact steps needed to get a successful FTP server running much like cPanel sets up when adding FTP accounts.
Edit: this is my proftpd.conf
# This is a basic ProFTPD configuration file (rename it to
# 'proftpd.conf' for actual use.  It establishes a single server
# and a single anonymous login.  It assumes that you have a user/group
# "nobody" and "ftp" for normal operation and anon.

ServerName                      "ProFTPD Default Installation"
ServerType                      standalone
DefaultServer                   on

# Port 21 is the standard FTP port.
Port                            21

# Don't use IPv6 support by default.
UseIPv6                         off

# Umask 022 is a good standard umask to prevent new dirs and files
# from being group and world writable.
Umask                           022

# To prevent DoS attacks, set the maximum number of child processes
# to 30.  If you need to allow more than 30 concurrent connections
# at once, simply increase this value.  Note that this ONLY works
# in standalone mode, in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd).
MaxInstances                    30

# Set the user and group under which the server will run.
User                            nobody
Group                           nobody

# To cause every FTP user to be "jailed" (chrooted) into their home
# directory, uncomment this line.
DefaultRoot ~

# Normally, we want files to be overwriteable.
AllowOverwrite          on

# Bar use of SITE CHMOD by default
<Limit SITE_CHMOD>
  DenyAll
</Limit>

# A basic anonymous configuration, no upload directories.  If you do not
# want anonymous users, simply delete this entire <Anonymous> section.
#<Anonymous ~ftp>
#  User                         ftp
#  Group                                ftp

  # We want clients to be able to login with "anonymous" as well as "ftp"
#  UserAlias                    anonymous ftp

  # Limit the maximum number of anonymous logins
#  MaxClients                   10

  # We want 'welcome.msg' displayed at login, and '.message' displayed
  # in each newly chdired directory.
#  DisplayLogin                 welcome.msg
#  DisplayChdir                 .message

  # Limit WRITE everywhere in the anonymous chroot
#  <Limit WRITE>
#    DenyAll
#  </Limit>
#</Anonymous>

Answer: Did you set AuthOrder to mod_auth_pam.c* mod_auth_unix.c in proftpd.conf?
You can also setup virtual users with ftpasswd.

If you still cannot login, enable the log:
# Define the log formats
LogFormat           default "%h %l %u %t \"%r\" %s %b"
LogFormat           auth    "%v [%P] %h %t \"%r\" %s"

# Define log-files to use
TransferLog /var/log/proftpd/xferlog
ExtendedLog /var/log/proftpd/access_log WRITE,READ write
ExtendedLog /var/log/proftpd/auth_log AUTH auth
ExtendedLog /var/log/proftpd/paranoid_log ALL default

to see what happens.
Comment: Add `AuthOrder` directive as I suggested above, restart `proftpd` and try again.
Comment: didn't work, how can i add a group and assign a ew user to that group?
Comment: _"didn't work"_ is not good reply. You should give us the error you get. Anyway, you can add a group with `groupadd` and add an user to that group by `useradd -g  `.
Comment: hehe, ya well there isn't much to say. I am unable to connect using Filezilla, how would i abel able to check what users exists? i added a few users with `useradd` but im starting to think that its not adding them correctly. i used `groupadd`  to add a "test" group but when i include the group in the useradd it returns and error saying that user 'test' doesn't exist
Comment: `useradd` creates a new user. There is no reason for that error _"user 'test' doesn't exist"_. Please give us the exactly command you use and output you get?
Comment: @s2xi let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/1069/discussion-between-quanta-and-s2xi)


Linear regression estimates

Question: For the simple linear regression model
$$y_i=\beta_0 +\beta_1 x_i$$
I have derived the estimates of $\beta_0=\bar y -\beta_1\bar x$ and $\beta_1=\frac{\Sigma (y_i-\bar y)(x_i-\bar x)}{\Sigma (x_i-\bar x)^2}$ but my book says that it is possible to express $\beta_0=\Sigma a_i Y_i$ and $\beta_1 =\Sigma c_i Y_i$.
How ever I can't seem to factor out $Y_i$ from either expression.
For $\beta_0$ all I can get is $\beta_0=\Sigma \frac{y_i}{n}-\beta_1\bar x$ but this has constant term $\beta_1 \bar x$.
For $\beta_1$ I get $\beta_1=\Sigma y_i\frac{x_i-\bar x}{\Sigma (x_i-\bar x)^2}-\frac{\bar y(x_i-\bar x)}{\Sigma(x_i- \bar x)^2}$ again with constant term that I can't get rid of. Does anyone know how to solve it, why these constants should go or how to get rid of them?
Comment: What is $\bar{x}_0$ in the expression of $\beta_1$?
Comment: Should be written $\hat{\beta}_0$ and $\hat{\beta}_1$ instead of just $\beta_0$ and $\beta_1$ while writing the estimates.
Answer: Hint:
\begin{align}
\hat{\beta}_0 &= \bar{y} - \hat{\beta}_1 .\bar{x}\\
& = \left(\frac{1}{n} \sum \limits_{i=1}^n y_i\right) - \frac{\sum \limits_{i=1}^n (y_i-\bar y)(x_i-\bar x)}{\sum \limits_{i=1}^n (x_i-\bar x)^2} \bar{x}\\
&= \left(\frac{1}{n} \sum \limits_{i=1}^n y_i\right) - \frac{\sum \limits_{i=1}^n (y_i-\bar y)x_i}{\sum \limits_{i=1}^n (x_i-\bar x)^2} \bar{x}\\
&= \left(\frac{1}{n} \sum \limits_{i=1}^n y_i\right) - \sum \limits_{i=1}^n \left(\frac{x_i\cdot \bar{x}}{\sum \limits_{i=1}^n (x_i-\bar x)^2}\right)y_i + \bar{y} \frac{\bar{x}\sum\limits _{i=1}^n x_i}{\sum \limits_{i=1}^n (x_i-\bar x)^2}\\
&=  \sum \limits_{i=1}^n \left(\frac{1}{n}\right) y_i - \sum \limits_{i=1}^n \left(\frac{x_i\cdot \bar{x}}{\sum \limits_{i=1}^n (x_i-\bar x)^2}\right)y_i + \sum \limits_{i=1}^n \left(\frac{\bar{x}\sum\limits _{i=1}^n x_i}{n\sum \limits_{i=1}^n (x_i-\bar x)^2}\right)y_i
\end{align}
Now the rest should be done easily.

Linear regression estimates


Transformar função em String com Javascript

Question: Supondo que tenho o seguinte objeto abaixo
const teste  = {
  onload:  ()=> {
    console.log('a')
  }
}

Onde o atributo onload é uma função, e preciso que seja transformado em uma string para que eu possa utilizar em outro local passando novamente para objeto, porém, se faço:
console.log(JSON.stringify(teste))

Tenho como resultado {}
Teria alguma forma de converter todo objeto incluindo as funções que nele se encontra, em uma string?
Comment: Por que você precisa converte-lo em uma string? Não seria mais fácil enviar a referencia da função?
Answer: Você pode utilizar o segundo argumento do JSON.stringify, para passar uma função de replace, que te permite modificar a forma como os dados são "serializados":

const obj = {
  onload: () => console.log("Foo")
};

const json = JSON.stringify(
  obj,
  (name, val) => typeof val === 'function'
    ? val.toString()
    : val
);

console.log(json);

Estamos também usando o método Function.prototype.toString.
Mas fazer isso não me parece uma boa ideia, ainda mais se esse tipo de dado for passar nas mãos de um usuário. Além disso, você estará utilizando JSON para transferir dados que ele não foi feito para trabalhar  – funções. Provavelmente há outras formas melhores de fazer o que você precisa.
Comment: E como passar novamente para Json em outro local? , tentei JSON.parse e me retorna {onload: "() => console.log("Foo")"}
Comment: Testei aqui e `json` é válido. Só que a função será convertida para string, e não função. Você terá que utilizar `eval` ou `new Function` para transformar de novo em uma função. Por isso essa abordagem é de fato insegura e talvez seja melhor reconsiderar utilizá-la.
Comment: Blz, muito obrigado pela explicação


How to do 'naked domain aliasing' like DNS hosts that support it?

Question: My goal is to use GitHub Pages and also benefit from their CDN, without having to use a third-party DNS host that supports DNS ALIAS record types (or ANAME - neither are accepted standards). I want to know how they do it, can anyone explain please?
We have many questions here about DNS aliasing with CNAME records, but in this particular situation I can't CNAME the naked domain to username.github.io.
If I do this with Apache or Nginx to get www.example.com working as a GitHub Page, does it work and do I break anything like email?
Apache
<VirtualHost *:80>
        ServerName example.com
        Redirect 301 / http://username.github.io/
</VirtualHost>

Nginx
server {
    server_name example.com;
    return 301 http://username.github.io/;
}

The above assumes a CNAME for www => username.github.io and an A Record for the naked domain => one of my servers with the above configuration.
Comment: http://wwwizer.com/
Comment: So... Instead of breaking the standards (by using ANAME/ALIAS) you want to break the standards (by using an apex CNAME)?
Comment: @MathiasR.Jessen Possibly...yes! If all I'm doing is breaking a standard (but achieving the functionality I want) then that's okay for now. If I'm actually breaking any functionality with the domain then no. It's not like I'm proposing to drive on the wrong side of the road or tear the warning tags off of mattresses.
Comment: @MichaelHampton interesting, that might be the simplest.
Answer:
without having to use a third-party DNS host that supports DNS ALIAS record types (or ANAME - neither are accepted standards)

This sentence is meaningless. In both the mentioned cases, the ALIAS and ANAME custom DNS types are internally resolved into a pool of A records. Thus, from an end-user perspective, you are not breaking any standard. Any client trying to connect to a hostname you configured with an ALIAS (I can speak for DNSimple given I'm work for them) will return the same list of A record that would return the target hostname.

but in this particular situation I can't CNAME the naked domain to username.github.io.

Theoretically you can, practically you don't want to. Per RFC, the CNAME can't co-exist with any additional record type. This means that if you CNAME the root domain you will shadow any other record associated to the root domain basically breaking your root domain capability to resolve.

If I do this with Apache or Nginx to get www.example.com working as a GitHub Page, does it work and do I break anything like email?

You can configure www.example.com as CNAME as long as you don't need any other DNS record attached to that hostname. This is normally ok.
From a web server configuration there is nothing you need to do. If you configure www.example.com as a CNAME of username.github.io, any request to www.example.com will resolve to the IP(s) associated with username.github.io and GitHub web servers will handle the request.
Still, in this case you haven't solved the problem of what you want to do with the root domain. At this point, the only think you can do is to HTTP redirect the root domain to the www.example.com hostname.
The configuration snippets you mentioned will work in that way.


Error while installing Android Studio in Ubuntu 16.04

Question: I am trying to install android studio in ubuntu 16.04 LTS.
I downloaded the latest release and installed  jdk using
sudo apt install openjdk-9-jre-headless

After the above step I am trying to run ./studio.sh after extracting Android studio zip file but It is giving me the following error. Please help.
com.intellij.ide.plugins.PluginManager$StartupAbortedException: java.lang.reflect.InvocationTargetException
    at com.intellij.ide.plugins.PluginManager$2.run(PluginManager.java:96)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.ide.plugins.PluginManager$2.run(PluginManager.java:93)
    ... 1 more
Caused by: java.lang.ExceptionInInitializerError
    at com.intellij.openapi.application.ApplicationNamesInfo.getInstance(ApplicationNamesInfo.java:49)
    at com.intellij.ui.AppUIUtil.getFrameClass(AppUIUtil.java:127)
    at com.intellij.ui.AppUIUtil.updateFrameClass(AppUIUtil.java:120)
    at com.intellij.idea.StartupUtil.prepareAndStart(StartupUtil.java:114)
    at com.intellij.idea.MainImpl.start(MainImpl.java:34)
    ... 6 more
Caused by: java.lang.RuntimeException: Cannot load resource: /idea/AndroidStudioApplicationInfo.xml
    at com.intellij.openapi.application.ApplicationNamesInfo.<init>(ApplicationNamesInfo.java:59)
    at com.intellij.openapi.application.ApplicationNamesInfo.<init>(ApplicationNamesInfo.java:30)
    at com.intellij.openapi.application.ApplicationNamesInfo$ApplicationNamesInfoHolder.<clinit>(ApplicationNamesInfo.java:43)
    ... 11 more
Caused by: java.io.FileNotFoundException: /idea/AndroidStudioApplicationInfo.xml
    at com.intellij.openapi.util.JDOMUtil.loadDocument(JDOMUtil.java:351)
    at com.intellij.openapi.application.ApplicationNamesInfo.<init>(ApplicationNamesInfo.java:55)
    ... 13 more

Answer: I saw similar problem on StackOverflow. Please, do not install Java 9 before previous would be officially deprecated. This version is still in sdevelopment process and might be highly unstable
Unistall openJdk-9 and install Oracle-jdk-8 following this post:
http://www.webupd8.org/2012/09/install-oracle-java-8-in-ubuntu-via-ppa.html


How many images needed to create JavaScript 360 degree image spin effect?

Question: I was looking at some demos over at Apple showcasing some cool HTML5, CSS3 and JavaScript demos and I got intrigued by this one, a 360 degree product viewer of sorts.
I was wondering out many photos you think I would need to try and replicate this.  Apple themselves say several on the page, but that isn't very descriptive.
It seems like it would be a very arduous task to try and accomplish so I may not do it, but I'm just wondering.
Thanks.
Answer: They don't specify because there is no real answer. If you want it to be super-smooth, 360 images would be nice. Apple used 72. You can use any number from 2 to 72 to 360 to infinity to technically get the effect, so it's your call just how much work is worth just how smooth an effect.
Sorry.
Comment: @BOSS: Well, ya know, sorry there's no easy answer. I don't like making decisions like that much myself xD But I'm sure you've got it down :)
Answer: The demo uses 72 images.
Incidentally, the demo seems to just update the image src attribute.
Comment: I inspected the DOM with Chrome's Developer Tools.
Comment: @BOSS: Well, I took a quick look at their source code, and decided that I'd find a faster answer by plugging high numbers into their template path until I found the upper bound :P `/safaridemos/showcase/threesixty/images/optimized/Seq_v04_640x378_##.jpg`
Comment: And yeah, I liked just how little of this demo really had to do with HTML5 and CSS3 xD
Comment: I just left the DOM inspector open while rotating the image.  The `src` attribute on the image restarted after 72.
Comment: How did you find out how many?  I realized after I posted that if I scroll very slowly, you can count of course! :)
Comment: @Matchu well, that's why I didn't tag the question with them, they have some other cool HTML5 and CSS3 effects though
Answer: Depends on the precision of the rotation you want.
There is no fixed number.
In that specific example they are using 72.
the images can be found at http://developer.apple.com/safaridemos/showcase/threesixty/images/optimized/Seq_v04_640x378_72.jpg
replace the last 72 part of the url with 01 to 72 to get all images.
Answer: You need several, that's as descriptive as it gets.
But note one thing. If you load them in a specific order, you can get a progressive effect.
For example, load first "north" and "south". Then "east" and "west". Then "northwest", "southwest", "northeast" and "southeast" and so on, that way you can have more than 72 images but the user won't have to wait to get a progressively smooth experience.
Note that in this case you'd be loading them in powers of two.
1st load (after one image is already there): 1 image (the opposite)
2nd load: 2 images (the sides)
3rd load: 4 images
4th load: 8 images
...
8th load: 128 images.
Note that you wouldn't use degrees as easily. (they just had to divide by 5, 360/5=72)
For calculating which image is on a given degree you'd use interpolation.
So first  you'd interpolate 360 degrees down to 2 (images), then to 4, then 8... to know which image to pick based on which you have
An easy explanation of interpolation is here.
Answer: From the visual not the technical... The Smoothness of the rotation is the factor that you want to look at on how many images you need. The size if the object and the level of detail help in the answer, you then have the bandwidth. 20 images is a minimum, 40 is a good recommendation, but 72 looks great. Remember that if it is photography, each image adds more work and difficulty.
Here is a chart the helps showcase the amount of images.
http://www.photospherix.com/matrix.html
Answer: You can download the demo from here
Have a play around with it I reckon 24 is a good number but it depends how many rotating view you plan on creating.
http://lukedurrant.com/2011/08/apples-360-rotating-ipod-html-5-source-code-download/


Proper statistical analysis to compare means from three groups with two treatment each

Question: any help to solve this is greatly appreciated:
The research question is to assess the superiority of Treatment A for estimulate bone growth in comparison with Treatment B, the current standard.
I'm planning to compare two treatments to estimulate bone growth in maxilary sinuses. For that, I will treat each patient with treatment A in one sinus and treatment B in the other.
Hence, my design is
To randomize X patients to three groups with

Group 1: one sinus with Treatment A vs the other sinus with nothing
Group 2: one sinus with Treatment A vs the other sinus with Treatment B
Group 3: one sinus with Treatment B vs the other sinus with nothing

My first tought was to compare within each group with a paired T-test. Then I considered to compare the means with an one-eay ANOVA of repeated measures, with two measures for each patient. Is the ANOVA use right?
Which is the better way to compare means between treatments with repeated patients?
Any comment, answer or criticism is welcome.
Answer: My thought is to approach this with a mixed effects regression model with a random intercept for each person.  I image the data set up as follows:
<code>
id  condition   outcome
1     A           3.2
1     C           1.2
...
30    A            4.2
30    B            6.2
...
</code>
with two rows per person and a variable indicating whether that sinus received treatment A, B, or the control (C).
You could then model this in R with the nlme package as:
lme(outcome ~ condition, random = ~ 1|id)
Comment: Thanks, your solution is a better approach to handle this data.


What can I do with content types that I can't with taxonomies?

Question: I'm starting with Drupal and comparing taxonomies and content types and from what I see, they both:

offer a URL via the Name/Title field
have the same list of field types (images, double-field, text...)
can refer each other (with node/term reference)
have translation (with the proper translation modules enabled)

Therefore I seem able to create the same content via taxonomies as with content types.
However, taxonomies seem tightly integrated with views, offering categorization and filtering, unlike content types, which brings me to the following question:
What's the point of using content types at all, is there anything we can do with content types that we can't do with taxonomies?
Answer: Taxonomies allow hierarchical nesting of items in vocabularies, and each term can only be in one position and one vocabulary at a time.
Nodes, however, can be tagged with any number of terms from any number of vocabularies.
Tagging taxonomy terms with other terms from other taxonomies, or with other terms from within the same taxonomy could potentially have very different results than maintaining a separation between terms (descriptors) and nodes (content that can be described), especially when it comes to using something like Views to sort and separate content based on descriptors.
So it's not so much that content types can do things that terms can't, as it is that content types cannot do as many things that nodes ought not do.
Comment: Understood your whole answer except for the last bit (`"as it is that content types cannot do as many things that nodes ought not do."`) which got me confused. We were talking about `taxonomies/content types`: what do `nodes` refer to in that context? Also, not sure I see where you're headed to with `"ought not do"` (as if not doing as much were a good thing): could you please rephrase?
Comment: A node, in Drupalspeak, is a single piece of content made with a content type. "Ought not do" means in this case that behaviors like hierarchical nesting doesn't make sense for nodes like it does for more abstract things like terms, so it's good that nodes don't do that directly.


how to make an automatic download button?

Question: I have a Content type with a file field. I want to add another field (download button) which when users click on that, they would be able to download the file (uploaded in file field), and show file field as a simple preview image or even hidden it.
Is there any module to do this(1:create a button with custom css through cck and 2: automatically link the file path to download button), or any other ways?
Answer: The generic file output of the file field is pretty close to what you are asking. It creates a link with a icon showing the file type and links to the file (download, unless the browser understands the file, like an image would be displayed in the browser instead of being downloaded)
You could with theming/css alter the appearance if you so please.
If you want force download, you have to modify the headers sent to the browser. You can use the File Force Download if this is your goal (Thanks for the tip @nicoz). It seems to be using field formatters, which functions much like the generic file display possible with file fields.
Comment: You can force file download using http://drupal.org/project/file_force


How to set multi-value hidden field from javascript?

Question: I have a multi-value text field, the values should be set from javascript on the browser.
For a single value text field, I can just set the value of the hidden field. But for multi-value text field, drupal will only take the first value and omit following values even the browser post more than one value.
I insert some input tag with same name (nearly, see below) under the form using jquery:
<input type="hidden" name="field_subscription_id[und][0][value]" value="52e1c1d99c29ec6fd84698b6" />
<input type="hidden" name="field_subscription_id[und][1][value]" value="52e1c1d99c29ec6fd84698b6" />
...

data is POST like this (inspect using dev tool of chrome):
field_subscription_id[und][0][value]=52e1c1d99c29ec6fd84698b6
field_subscription_id[und][1][value]=52e3de349c29ec6fd84698d4
...

After node created, the field field_subscription_id will only have the first value.
So, any idea to make this work? ~thx
EDIT
I define the form from UI, just a normal content type and a text field. I make a ajax request to external site from page, let user select something (from the ajax response), then fill a field of add-node form with the selected ids.
Using the AJAX response, I build a list of
, each
 has a checkbox, the form attribute (HTML5) of the checkbox has been set to the value of form-id of drupal add-node form on this page.
Comment: Please provide more informations eg. what did you on drupal-side, are you using the form_api, how is your form defined etc.?
Comment: I define the form from UI, just a normal content type and a  text field. I make a ajax request to external site from page, let user select something (from the ajax response), then fill a field of add-node form with the selected ids.
Answer: Fields will only appear in the $field_state array if they were there when the form was built. (If you inspect the $_POST array directly you should see your values there.)
The solution: When creating the form add enough fields so you don't need to add any more with js.
If you didn't create the form yourself then use hook_form_alter to add more fields.
If you need to be able to add more fields on the fly then you will have to look into the #ajax property. The examples module has some good examples on that.
Also make sure to use the #default_value, not #value property if you need to set a default value for any of the hidden fields as using #value will lock the value to that and stop the client from being able to make any changes.
Comment: I will checkout that module. BTW, if I want to inspect the $_POST array, which function should I look?
Comment: If you have devel installed then dmp($_POST) will do the trick. If not then print_r($_POST) will also do it.


Which type(s) of pedals should a beginner get?

Question: I have been teaching myself guitar for about 6 months now. I can play simple riffs and parts of solos, working on scales and chords. I can play Smells Like Teen Spirit's riff and solo and Sweet Child O' Mine's intro and first two solos.
I live in India and you can't find a lot of stores with pedals even in big cities. However, I have an opportunity to get pedals and possibly other gear from US in a month and it'll also be much cheaper.
I know product recommendations aren't allowed on this forum. But I would like advice on what types of pedals to get that would be useful. I use a Blackstar ID Core 10W amplifier which has a good built-in tuner and effects like Chorus, Flanger, Tremolo, Reverb and Delay. These effects are pretty decent though I can't turn them on and off easily while playing. Overdrive channels along with the ISF on the amp are great. To modify EQ however, I need to connect the amp to a computer which isn't easy.
Link to Amp's specs: https://www.blackstaramps.com/uk/products/idcore-stereo-10
I'm assuming most entry level pedals won't sound much better than the built-in effects on the amp, not to mention I will be upgrading to a better amp in another 6-7 months. Is it worth getting a distortion/OD pedal? Will it help me get better hard rock, blues and metal tones? Is it fine if I get a Wah pedal at this stage? I have read that a looper pedal is useful so that's on my list.
Thanks a lot in advance for any advice.
Answer: Even though your amp provides built-in effects, it is very convenient to have the same effects as pedals so you can turn them on and off. Another reason is that you can change the order of the effects. For example, distortion into delay is very different from delay into distortion.
Some basic types to consider include the ones you've already mentioned, like distortion/OD, chorus, wah-wah. Some others you might want are fuzz, compression, and volume. I haven't used a looper yet myself, but it's high on my list of things to get next. If you have a riff playing in a loop, you can put down the guitar and dial in the controls on the other effects and immediately hear what's happening. Be sure to check out our Glossary of Guitar Effects.
If/when you get a chance to go to a store, ask to try a few using a similar amp and guitar that you have.
We have a chatroom for this site where we often talk about pedals and setting them up.
I've been very pleased with the quality of very inexpensive pedals from Behringer and Danelectro. For wah-wah, my personal recommendation is Morley since it's the only kind I know of that lets you switch it on and off while leaving it in the same position. This lets it work almost like a Parametric Equalizer.
FWIW my first pedal purchases were: volume, wah-wah, amp   simulator. Some years later I expanded this by getting: octave, OD, envelope filter. And after that, it kind of exploded.
Comment: Playing in rock bands in the '60s, I never saw AC15s. Plenty of AC30s and AC50s.
Comment: In my opinion, the amp you have is just fine. All the great rock bands from the 60s were using Vox AC15's, just 15 watts. I mostly play in musicals in a small theatre and my Vox VT120 (10 watts) is plenty loud. I have a bigger one for bass, but for guitar you don't really need tons of power unless you're playing in really large rooms without a P/A system. I haven't used a Crybaby myself, but if that's the sound you really like, then go for it! For me, I don't the way most wahs have the switch under the toe. It just feels awkward to me.
Comment: I am not worried about loudness but more about tone. I like the tone out of a few amps but unless I find a way to try them out I think I'll stick with this amp and get pedals. Also is it a better idea to get used pedals from better brands like Boss than Behringer or Danelectro? And where do you recommend looking for used guitar pedals in US? Also do you have a good recommendation for a overdrive/ distortion pedal that can do most types of rock and metal well?
Comment: Used pedals are a great idea. If your area has a major guitar chain retailer, you should absolutely try out as many as you can. Even if you have to drive, say, an hour, you can try out a ton in one afternoon. Make notes and look for what you like on a popular used gear site. For what you describe you want in a single distortion pedal, a Rat or clone might be a good bet. Search YouTube for videos that compare the most well-known types of distortion pedals (overdrive vs distortion, TS-types vs Rat-types) and see if one strikes you as versatile enough.
Comment: Thanks @mistercoffee66. It took me visiting over 20 stores in two cities to find three stores that had about 10-15 guitars each. And none of them had any mid range guitars that were well priced or any collection of pedals. I'll see if there are any other stores though. The prices are already pretty expensive on pedals and when you add import taxes it's not cheap. The used market is virtually non-existent for all gear and you might find 20 budget guitars with poor setups that have been lying around in a beginner's house for a few years.
Comment: @Tarun I think Reverb.com is probably better than any single store in the US because it has listings from hundreds of stores. It's a lot like the Amazon Marketplace for used books but for gear.
Comment: I sort of understand what different pedals do thanks to YouTube videos but I can't try them out in person. Even the best shops only have one or two cheap multi effects processors. Are any of them good enough for me to use for a year or so for a bunch of common effects? Behringer is available cheaply online but every other brand is over 100-400$ and way overpriced, I still can't find any stores with a good enough variety of gear in two major cities here. Should I go for an amp like the Katana or pedals? Also I love the sound of the Dunlop Crybaby, is it as good as people claim?
Comment: I do know someone coming from the US back to India so I could ask them to get me gear. Where could I expect them to find used pedals online or in a store??
Answer: To be quite honest, I think a metronome would serve most beginners better than pedals. Being able to press a button and get a different sound is fun but doesn't do much to help you grow musically. And note that some exceptional, world class guitarists (for example Derek Trucks) eschew the use of pedals altogether.
Nothing wrong with doing stuff to make playing fun, but playing around with gear (for guitarists it's amps/guitars/pedals, for sax players it's always mouthpieces and reeds) often distracts from the hard work of learning to play good musical phrases in time.
Do you play acoustic guitar by the way?
Comment: I don't contest that music is hard. It requires patience and dedication and you either have those or develop them. Personally I've found that facing that and trying (!) to address my weaknesses has been what has given me most real encouragement, and that's why I give this answer. I don't think that buying gear makes you sound better, provided what you already have is workable, because the reasons you sound bad are likely to be with timing and musicianship, not the sound. But I don't want to get drawn into a pointless debate about it, and I accept that others may have other viewpoints.
Comment: I have played my friend's acoustics and I can play stuff on it but not fingerstyle. I understand that rhythm is very important and I've already learned South Indian Classical for over 10 years where rhythm plays a very crucial role. I play keyboard so I have a metronome on that and also a tap tempo on my amp. I know that you don't need pedals to sound great. Angus also doesn't use any pedals but a slight boost to compensate for his wireless. I don't want to go overboard and I can't with the prices here luckily. I probably just need an OD, looper and maybe a wah-wah.
Comment: well you sound like a bit more than a beginner musician Tarun, I know rhythm is very sophisticated in Indian traditional music. I think acoustic is useful because you tend to focus a lot more on the guitar itself - some great electric players are great acoustic players first. But in the end it's all tools for the job, and only you can decide what you want. There are great players with huge pedal boards and equally great ones that hate them. Do your thing ...
Comment: Acoustic is a nice idea and it's way easier to pickup and play without disturbing a lot of people. The acoustics I tried out had really high action and at the time I thought that was just how it was. My friend's acoustic has nearly a cm of action at the twelfth fret and you can barely play it. I learn fingerstyle on an acoustic later. Thanks for the help.
Comment: no, they vary a lot. You might like to look for a nice nylon-string, they are great to just learn all the basic stuff on and you can get a decent one for quite a modest price. And as you say, it is great to just pick up and play with no overhead
Comment: For many people, it's a problem if they don't get good vibes from their own playing. If you can't produce any sound that you might play in front of others without feeling embarrassed. Where do you get the motivation to continue? Use a metronome ... right. Then at least you'll know for sure that you suck. ;) There has to be someone or something that keeps you going even while knowing that you really suck. An effect pedal can provide some encouragement. At least there's some part of your music that doesn't _totally_ suck?
Comment: But does the tone change a lot between nylon and steel strings? I really like the sound of even some 300$ acoustics.
Comment: yes, it is a different sound. Both can be great. Sometimes I have trouble figuring which I like more for a given song.
Answer: Get a compression pedal.  You'll be amazed how much better it will make your guitar sound.  And I like a good distortion type pedal to play blues soloes.  I just bought the Keeley DDR and it is my favorite for that kind of thing.  I've tried dozens of pedals in my lifetime and they're all fun but a Boss Compressor is the only ones I've kept.  I have the Boss CS-1, CS-2, and CS-3.  The CS-1 is the oldest, but my favorite.  It just makes a guitar sound so good!  Ever wonder why guitars on records sound so much better than your guitar?  It's the compression!


How to solve the optimization problem?

Question: The original problem is to find nonnegative $\mathbf{w}=(w_1, w_2, w_3)$ that maximizes $$\pi_{\mathbf{w}}=\frac14(p_1-w_1)+\frac14(p_2-w_2)+\frac12(p_3-w_3)$$ subject to $$\frac14\sqrt{w_1}+\frac14\sqrt{w_2}+\frac12\sqrt{w_3}-600 \ge 400$$ and
$$\frac14\sqrt{w_1}+\frac14\sqrt{w_2}+\frac12\sqrt{w_3}-600 \ge \frac12\sqrt{w_1}+\frac14\sqrt{w_2}+\frac14\sqrt{w_3}-0,$$
where $p_1$, $p_2$, and $p_3$ are given as $1$ million, $4$ million, and $9$ million dollars, respectively.
My professor solved this problem very easily.
he said when $w_1=0$ and $w_3=5760000$, the second inequality is satisfied. So is the first inequality. Hence, $(w_1, w_2, w_3)=(0,0,5.76 \text{ million})$ and the total utility becomes $2.87$ million dollars.

First, I remove $p_i$'s in the objective function because it does not affect the optimal $w_i$'s.
Then, I normalize constant values.
Finally, I substitute $\sqrt{w_i}$'s with $x_i$'s in order to remove root terms.
Hence, I obtained a problem that finds nonnegative $\mathbf{x}=(x_1, x_2, x_3)$ that maximizes $$f(\mathbf{x})=x_1^2 + x_2^2+ 2x_3^2$$ subject to $$x_1+x_2+2x_3 \ge 4000$$ and $$-x_1 + x_3 \ge 2400.$$

I tried to solve the problem with five inequality constraints (additional $x_1\ge0$, $x_2\ge0$, and $x_3\ge0$) using KKT condition.
However, it is so complicated because there are three equality equations from $\nabla L$, where $L$ is a Laplacian equation, five original ineqaulities, five Lagrangian multiplier $\lambda_i$'s inequalities, and five complementary slackness equalities.
Is there any method to solve the problem easily?
Comment: You have to minimize $f(\mathbf{x})$ in order to maximize $\pi_{\mathbf{w}}$.
Answer: I have used Lagragian Multiplier's method to find the minimum of $f(x_1,x_2,x_3)$.
$f(x_1,x_2,x_3)) =x_1^2+x_2^2+2x_3^2$
$g_1(x,y) = x_1+x_2+x_3\ge{4000}$
$g_2(x,y) = x_3-x_1\ge{2400}$
$\nabla f = \lambda \nabla g_1 + \mu \nabla g_2$
$<2x_1, 2x_2,4x_3> = \lambda<1,1,1> + \mu<-1,0,1>$
$\lambda - \mu = 2x_1$
$\lambda = 2x_2$
$\lambda + \mu = 4x_3$
When you substitute the values of $ x_1, x_2, x_3$ in $g_1$ and $g_2$
you solve for $\lambda$ and $\mu$
I get $\lambda = \frac{28800}{7}$ and $\mu = \frac{32000}{7}$
Find $x_1, x_2, x_3$
Finally plug the values of $x_i$'s in the minimization problem and you will find $\pi_w$
I get $x_1 = -\frac{2000}{7}$, $x_2 = \frac{14400}{7}$, $x_2 = \frac{15200}{7}$
And I get  $\pi_w = 2321428.57\approx 2.32$ million
Comment: Lagragian multipliers can stil work but it is just to be dealt with matrices
Comment: $f(x_1,x_2,x_3)$ is not $(x_1^2 + x_2^2 + x_3^2)$ but $(x_1^2 + x_2^2 + 2x_3^2)$.
Comment: OMG, but the principle remains the same.  Let me rework while you try at your end too.
Comment: Is there any method without defining $g_3(x_1, x_2, x_3)=x_1 \ge 0$, $g_4(x_1, x_2, x_3)=x_1 \ge 0$, and $g_5(x_1, x_2, x_3)=x_1 \ge 0$? It is too hard to solve with five multipliers.
Answer: First, note that your attempt contains a small mistake - the function you maximize should be
$$
\hat{f}(\mathbf{x}) = -x_1^2 - x_2^2 -2x_3^2,
$$
or, equivalently, minimize
$$
f(\mathbf{x}) = -\hat{f}(\mathbf{x}) = x_1^2 + x_2^2 + 2x_3^2
$$
Now, the problem is the following QP:
$$
\begin{aligned}
\underset{\mathbf{x} \in \mathbb{R}^3}{\text{minimize}} &\quad x_1^2 + x_2^2 + 2x_3^2 \\
\text{s.t.} &\quad -x_1-x_2-2x_3\leq -4000 \\
&\quad x_1 - x_3 \leq 2400 \\
&\quad \mathbf{x} \geq \mathbf{0}
\end{aligned}
$$
I do not know how to solve it analytically, but I will solve it graphically using duality. Writing the Lagrangian $L(\mathbf{x}, \mathbf{y})$ with Lagrange multipliers $y_1, y_2$ for the first two constraints, and finding the dual objective, results in:
$$
\begin{aligned}
q(\mathbf{y}) &= \min_{\mathbf{x} \geq 0} L(\mathbf{x}, \mathbf{y}) \\
 &= \min_{x_1 \geq 0} \{ x_1^2 - (y_1 - y_2) x_1 \}
+ \min_{x_2 \geq 0} \{ x_2^2 - y_1 x_2 \} + \min_{x_3 \geq 0} \{ 2x_3^2 - (2y_1 + y_2) x_3 \} + 4000 y_1 - 2400 y_2 \\
 &= -\tfrac{1}{4} \max(0, y_1 - y_2)^2 - \tfrac{1}{4}\max(0, y_1)^2 - \tfrac{1}{8} \max(0, 2y_1 - y_2)^2 + 4000 y_1 - 2400 y_2
\end{aligned}
$$
with
$$
x_1 = \tfrac{1}{2} \max(y_1 - y_2, 0), \quad
x_2 = \tfrac{1}{2} \max(y_1, 0), \quad
x_3 = \tfrac{1}{4} \max(2y_1 + y_2, 0)
$$
being the minimizers. Thus, can recover the optimal $\mathbf{x}$ using the formulas above after having solved the following dual:
$$
\max~q(\mathbf{y}) \quad \text{s.t.  } \mathbf{y} \geq 0
$$
Plotting the contours of $q(\mathbf{y})$ on the positive orthant and zooming into the maximizer using e.g. MATLAB results in $y_1 = 2000, y_2 = 0$ being the optimal solution. Recovering the optimal $\mathbf{x}$ results in
$$
x_1 = x_2 = x_3 = 1000
$$
Now, you can prove that the above is the minimizer by noting that both are primal and dual feasible, and both objective values are equal.
Comment: Sorry I was wrong to convert $x$ to $w$, i.e., second inequality constraint is wrong. (not 2400 but -2400.) However, I saw your solution process, thank you
Comment: Was it helpful?

How to solve the optimization problem?


Mixing of localhost (default for [NDBD]HostName) with other hostname(X.X.X.X) is illegal

Question: I'm trying to create a mysql cluster configuration between two servers has mysql server 5.5 installed.
on the main server I execute the ndb management server using the following command:
ndb_mgmd -f conf/config.ini --initial --configdir=/storage-mysql/mysql_cluster/conf

my config.ini in the main server is: (changed my ip to X.X.X.X)
[computer]
id=db02
hostname=X.X.X.X

[ndb_mgmd]
 hostname=localhost
 datadir=/storage-mysql/mysql_cluster/ndb_data
 nodeid=1
[ndbd default]
 noofreplicas=2
 datadir=/storage-mysql/mysql_cluster/ndb_data
[ndbd]
   hostname=localhost
   nodeid=3
[ndbd]
    ExecuteOnComputer=db02
    hostname=localhost
    nodeid=4
[mysqld]
   nodeid=50

when I execute the sndb_mgmd server i get the following error:
2011-10-02 14:09:47 [MgmtSrvr] ERROR    -- at line 9: Mixing of localhost (default for [NDBD]HostName) with other hostname(X.X.X.X) is illegal
2011-10-02 14:09:47 [MgmtSrvr] ERROR    -- at line 9: Could not store previous default section of configuration file.
2011-10-02 14:09:47 [MgmtSrvr] ERROR    -- Could not load configuration from 'conf/config.ini'
2011-10-02 14:09:47 [MgmtSrvr] ERROR    -- Could not determine which nodeid to use for this node. Specify it with --ndb-nodeid=<nodeid> on command line

what am I doing wrong?
using MySQL Cluster Management Server mysql-5.1.56 ndb-7.1.15a
thank you!
kfir
Comment: As it says: Don't put localhost in your configuration file.
Comment: i thought that I can't mix two ip address on the same config file. thanks :) please add it as answer so i'll be able to accept it.
Answer: As it says: Don't put localhost in your configuration file.


How to properly fall FORWARD while ice skating and prevent wrist fractures?

Question: I've looked this up everywhere and cannot find a good answer.
In ice skating, they teach us to fall to the side or on our bottoms to prevent injury. However, what do you do when you're about to fall forward? e.g. tripping over your ice pick for figure skaters. My instinct would be to extend my arms to break the fall. This will likely hurt my wrists, if not fracture it. Is there a proper technique?
Comment: They teach you to fall to your side, because that's the proper technique to fall.  When your ice pick catches, you still can rotate your body some so you fall on your side rather than on your front, no?
Answer: You will almost always have a slight rotation one direction or the other, and even if you don't, you can use whichever foot has best contact with the ice to start a twist as you fall.
Then rotate your shoulders, wrapping your arms in to speed the spin as needed, so you can take the fall sideways, rolling rather than impacting.
Answer: Use your underarms, not your hands to break your fall. Turn away your head so you don't crash facefirst into the ice if your arms slide away to the sides.


does ParseImageView cache ParseFile

Question: Does ParseImageView cache ParseFile's in Android. If it caches parseFile, How can i find the path of those files in my android device.
<code>ParseImageView imageView = (ParseImageView) findViewById(android.R.id.icon);
 // The placeholder will be used before and during the fetch, to be replaced by the fetched image
 // data.
 imageView.setPlaceholder(getResources().getDrawable(R.drawable.placeholder));
 imageView.setParseFile(file);
 imageView.loadInBackground(new GetDataCallback() {
   @Override
   public void done(byte[] data, ParseException e) {
     Log.i("ParseImageView",
         "Fetched! Data length: " + data.length + ", or exception: " + e.getMessage());
   }
 });
</code>
Comment: Picasso is the only way to go here.
Answer: Looks like @suresh kumar is dead right, so this question is settled with "no", but having run into this trouble I wanted to drop some code in here to get around it.
I use Universal Image Loader for URL image loading, and it supports a lot of configuration options for caching and display. Set it up in your Application class with (at time of writing):
<code>    //Create image options.
    DisplayImageOptions options = new DisplayImageOptions.Builder()
        .showImageOnLoading(R.drawable.button_default)
        .cacheInMemory(true)
        .cacheOnDisc(true)
        .build();

    //Create a config with those options.
    ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
        .defaultDisplayImageOptions(options)
        .build();

    ImageLoader.getInstance().init(config);
</code>
And then use it with Parse where you'd like to load and cache your image:
<code>        ParseImageView itemImage = (ParseImageView) v.findViewById(R.id.iv_item);
        ParseFile photoFile = item.getParseFile("picture");
        if (photoFile != null) {
            //Get singleton instance of ImageLoader
            ImageLoader imageLoader = ImageLoader.getInstance();
            //Load the image from the url into the ImageView.
            imageLoader.displayImage(photoFile.getUrl(), itemImage);
        }
</code>
Hope that helps.
Comment: Glad to help! (Interesting how much competition there is amongst iOS images loaders too. I've used SDWebImage out of habit.)
Comment: An incredible tip, thanks ..  Just FTR the iOS equivalent is DLImageLoader (eg, http://stackoverflow.com/a/19115912/294884 ) ... that may help any "Mac to Android" devs googling in the future.  Thanks again so much.  Bounty en route!
Comment: **footnote** cacheOnDisc would seem to be now cacheOnDisk ("k").
Comment: **footnote** this incredibly helpful answer will with android studio: http://stackoverflow.com/a/17521288/294884
Comment: However!  I've since experimented with Picasso.  I do think it's even better.  With a long ListView (about 100 full-screen images) I was getting a lot of stutter with UIL which I could not resolve.  I changed to Picasso -- and it's done.  So, Picasso worked for me!
Comment: ParseFile is limited in this respect. your solution is brilliant, thanks.
Answer: ParseImageView doesn't cache ParseFile, It is only used to display the image file stored in Parse.com. See this
and this

does ParseImageView cache ParseFile


'SwaggerGenOptions' does not contain a definition for 'SerializeAsV2'

Question: I'm trying to use swaggergen tools, so I configure my services:
        services.AddSwaggerGen(c =>
        {
            c.SerializeAsV2 = true;
            c.CustomOperationIds(apiDescription => {
                return apiDescription.TryGetMethodInfo(out MethodInfo methodInfo) ? methodInfo.Name : null;
            });

I have Swashbuckle.AspNetCore and Swashbuckle.AspNetCore.Newtonsoft installed in my nuget package manager
Why does the c.SerializeAsV2 has a red squiggly: "'SwaggerGenOptions' does not contain a definition for 'SerializeAsV2'" I can't find anything on this at all in google.
Answer: Move it to the Configure method:
app.UseSwagger(c =>
{
    c.SerializeAsV2 = true;
});

Reference: Serialize Swagger in the 2.0 format
Comment: Even after adding this to the Configure method, it still generates a json document in version 3.0.  Any pointers as to why this might be happening?


React leaflet too much refresh map with context update value

Question: I have a map and a list filtered in another component that displays the markers present. When I execute map.on ('moveend') to have the list of markers present I have a refreshing problem.
I have a context which contains 2 array. A filtered array and an array containing my markers. When I execute the function to update my filtered list I have several hundred data refreshed and the page crashes.
In my component which creates the map it only retrieves the default list of markers. It is in another component that I display my filtered markers.
I would like not to resume my map because the data inside does not change, my marker list is still present even if the map moves I only want to update an array of my context to display the list in another component
filteredListComp the array where is the datas is display in an other components
map.on('moveend', function(e){
  if(e.target.getBounds().contains(obj)) {
     filtered.push(m)
     setListCompContext(prevState => ({...prevState, filteredListComp: filtered }))
  }
})

my initial context at root project:
const [listDefaultCompContext, setListDefaultCompContext] = useState({
   defaultListComp: [],
   filteredListComp: []
})

<ContextApp.Provider value={[listDefaultCompContext, setListDefaultCompContext]}>
    <DefaultLayout>
        <Component {...pageProps} />
    </DefaultLayout>
</ContextApp.Provider>

Comment: What exactly is `setListCompContext` - did you mean `setListDefaultCompContext` or are these indeed 2 separate functions?  Where are these markers being rendered?  What version of react-leaflet are you using?
Comment: setListCompContext is a function for update my context, setListDefaultCompContext is the initial state of my context. I have edit the post. The problem is resolv
Comment: If you solved your problem then please post the solution as an answer so that others who come across it know that it has been solved.
Answer: The problem comes from the dynamic import of next.js which made a mount of my component. When I moove the map the component is always mount.
The first thing I did was create an anonymous function at the level of my page's imports.
In my component of the page I have a useEffect which does a require () of my component in order to avoid the windows is not defined.
And in my mapLeaflet component I have a useEffect which handles the map.on ('moveend') event so that it avoids having too many refreshes
Component of my page at the level of import:
import xxxx from 'xxxx';
...
let MapLeaflet = () => {
    return <Spin />
}
....
import xxxx from 'xxxx';

/***************/
Inside my functional component of my page

const myFunctionalComponent = () => {

     useEffect(() => {
        MapLeaflet = require('components/s/MapLeaflet').default

        return () => {
            /* Destroy */
        }
    }, [])

}

/***************/
And in my leafletComponent inside my MapContainer

const MapLeaflet = (props) => {
   <MapContainer
   center={mapCenter}
   zoom={12}
   scrollWheelZoom={true}
   style={{ height: props.size, width: '100%', zIndex: '0' }}
   >

      <LMapContent />

   </MapContainer>
}

const LMapContent = () => {

    useEffect(() => {
        // Mount

        // Map events
        map.on('moveend', (ev) => {
          ...code
        })

        return () => {
            /* Destroy */
        }
    }, [])

}