Proving that $e^{\pi}-{\pi}^e\lt 1$ without using a calculator

Question:
Prove that $e^{\pi}-{\pi}^e\lt 1$ without using a calculator.

I did in the following way. Are there other ways?
Proof : Let $f(x)=e\pi\frac{\ln x}{x}$. Then,
$$e^{\pi}-{\pi}^e=e^{f(e)}-{e}^{f(\pi)}\tag1$$
Now,
$$f'(x)=\frac{e\pi(1-\ln x)}{x^2},\quad f''(x)=\frac{e\pi (2\ln x-3)}{x^3},\quad f'''(x)=\frac{e\pi (11-6\ln x)}{x^4}.$$
Since $f'(x)\lt 0$ for $e\lt x\lt\pi$, one has $f(e)\gt f(\pi)$. By Taylor's theorem, there exists a point $c$ in $(e,\pi)$ such that
$$\begin{align}f(\pi)&=f(e)+(\pi-e)f'(e)+\frac{(\pi-e)^2}{2}f''(c)\\&\gt f(e)+(\pi-e)\cdot 0+\frac{(\pi-e)^2}{2}\cdot \frac{e\pi(2\ln e-3)}{e^3}\\&=f(e)-\frac{\pi(\pi-e)^2}{2e^2}\tag2\end{align}$$
because $f'''(x)\gt 0\ (e\lt x\lt \pi)$ implies $f''(c)\gt f''(e)$.
By the mean value theorem and $(2)$,
$$e^{f(e)}-e^{f(\pi)}\lt (f(e)-f(\pi))e^{f(e)}\lt \frac{\pi (\pi-e)^2}{2e^2}\cdot e^{\pi}=\frac{e\pi(\pi-e)^2}{2}\cdot e^{\pi-3}\tag3$$
Since $e^x\lt \frac{1}{1-x}\ (0\lt x\lt 1)$ and $0\lt \pi-3\lt 1$,
$$e^{\pi-3}\lt\frac{1}{4-\pi}\tag4$$
From $(1)(3)(4)$,
$$e^{\pi}-{\pi}^e\lt \frac{e\pi(\pi-e)^2}{2}\cdot\frac{1}{4-\pi}\lt\frac{3\times\frac{22}{7}\left(\frac{22}{7}-2.718\right)^2}{2}\cdot\frac{1}{4-\frac{22}{7}}\lt 0.993\lt 1$$
Comment: $$ \frac{1}{2} \ \cdot \ \frac{20}{7} \ \cdot \ \frac{22}{7} \ \cdot \ ( \frac{22}{7} - \frac{19}{7})^2 \ \cdot \left(\frac{1}{4 - \frac{22}{7}} \right) \ = \ \frac{20 \cdot 22 \cdot 9 \cdot 7}{2 \cdot 7 \cdot 7 \cdot 49 \cdot 6} \ = \ \frac{330}{343} \ < \ 1 \ \ . $$  The factors cancel in a way that makes simplification possible without a calculator. [This is an omission-typo in the previous comment: the inequality was meant to read $ \ \frac{19}{7} \ < \ e \ < \ \frac{20}{7} \ $ . ]
Comment: Fantastic method of proof!
Comment: @mathlove If I may make a suggestion, I have been bothered by the last line, since it uses a decimal approximation for  $ \ e \ $ , leading to a difference squared which would seem to require a calculator to demonstrate that the value is less than 0.993 .  You also use $ \ 3 \ $ as a bound on $ \ e \ $ which makes this coarser than necessary.  Since $ \ \frac{19}{7} \ < \ e \ \frac{20}{7} \ $ , you can use $ \ \frac{20}{7} \ $ as the first factor and $ \ \frac{19}{7} \ $ in the difference-squared.  This leads to (continued)
Comment: I deleted an answer involving numerical approximations, but thought I should mention something of the difficulty involved there.  Since the actual difference between the two numbers is already $ \ \approx \ 0.68 \ $ , each of the two values (about 23) must be estimated to a precision of order 1% so that the estimate of the difference remains less than  1  .  This turns out to be extremely difficult to arrange for transcendental powers of transcendental numbers if one is using rational numbers to represent sums of series when one must obtain convincing results _without_ a calculator.
Comment: There is a way called ceilings and floor technique where only integral parts are taken into consideration so $2^3-3^2=-1( approx). Hence the inequality is true ie $-1<1$.
Comment: Consider $f(x)= x^{\pi + e - x } + \frac {x}{\pi - e}$ and show it is increasing on the interval $[e,\pi]$.
Answer: I looked at a couple of ways of examining this using series expansions.  A difficulty that I noted in a comment to mathlove's answer is that this requires rather careful selection of estimators, since the permissible "error budget" is very limited if we are to show that the difference is less than 1 , when its actual value is about 0.682.  Another issue is that we would like to use rational approximations in a way that makes these computations look credibly like ones that can be managed without a calculator.  I use some "number facts" here that are either generally familiar or can be found readily enough (while these can be obtained using a calculator, that can be avoided if one is acquainted with approximate values); it proves to be very important to use values that closely approximate the needed numbers.
We can attempt to estimate an upper limit the difference $ \ e^{\pi} \ - \ \pi^e \ $ by setting up an inquality in which $ \ e^{\pi} \ $ is overestimated and $ \ \pi^e \ $ is underestimated.  In this first one, we will start from
$$ \left( \frac{68}{25} \right)^{22/7} \ > \ e^{\pi} \ > \ \pi^{e} \ > \ \left( \frac{157}{50} \right)^{19/7} \ \ $$
$$ \Rightarrow \ \ \left( 3 \ - \ \frac{7}{25} \right)^{3 + \frac{1}{7}} \ > \ e^{\pi} \ > \ \pi^{e} \ > \ \left( 3 \ + \ \frac{7}{50}  \right)^{3 - \frac{2}{7}} \ \ $$
$$ \Rightarrow \ \ 3^3 \ \cdot \ 3^{1/7} \ \cdot \left( 1 \ - \ \frac{7}{75} \right)^3 \ \left( 1 \ - \ \frac{7}{75} \right)^{\frac{1}{7}} \ > \ e^{\pi} \ > \ \pi^{e} \quad > \ 3^3 \ \cdot \ 3^{-2/7} \ \cdot \left( 1 \ + \ \frac{7}{150}  \right)^3 \ \left( 1 \ + \ \frac{7}{150}  \right)^{-\frac{2}{7}} \ \ .  $$
We can construct Taylor polynomials for the powers of $ \ 3 \ $ based on the function $ \ 3^x \ $ [using $ \ \ln 3 \ \approx \ 1.1 \ $ ], and can apply the (generalized) binomial series for the other factors:
$$  3^3 \ \cdot \ 3^{1/7} \ \cdot \left( 1 \ - \ \frac{7}{75} \right)^3 \ \left( 1 \ - \ \frac{7}{75} \right)^{\frac{1}{7}} $$ $$ \approx \ 27 \   \left( 1 \ + \ \ln 3 \cdot \frac{1}{7} \ + \ \frac{(\ln 3)^2}{2} \cdot \frac{1}{7^2} \right) \   \left( 1 \ - \ 3 \cdot \frac{7}{75}\ + \ 3 \cdot \frac{7^2}{75^2} \right)  $$ $$ \cdot   \left( 1 \ - \ \frac{1}{7} \cdot \frac{7}{75} \ + \ \frac{\frac{1}{7} \cdot  \frac{-6}{7}}{2} \cdot \frac{7^2}{75^2} \right)  \ $$
$$ \approx \ 27 \   \left( 1 \ + \ \frac{11}{10} \cdot \frac{1}{7} \ + \  \frac{6}{10} \cdot \frac{1}{7^2} \right) \   \left( 1 \ - \  \frac{7}{25}\ + \ 3 \cdot \frac{7^2}{75^2} \right)  \  \left( 1 \ - \  \frac{1}{75} \ - \  \frac{3}{75^2} \right)  \ \ , $$
and similarly,
$$  3^3 \ \cdot \ 3^{-2/7} \ \cdot \left( 1 \ + \ \frac{7}{150} \right)^3 \ \left( 1 \ + \ \frac{7}{150} \right)^{-\frac{2}{7}} $$ $$ \approx \ 27 \   \left( 1 \ - \ \ln 3 \cdot \frac{2}{7} \ + \ \frac{(\ln 3)^2}{2} \cdot \frac{4}{7^2} \ - \ \frac{(\ln 3)^3}{6} \cdot \frac{8}{7^3} \right) \   \left( 1 \ + \ 3 \cdot \frac{7}{150}\ + \ 3 \cdot \frac{7^2}{150^2} \right)  $$ $$ \cdot   \left( 1 \ - \ \frac{2}{7} \cdot \frac{7}{150} \ + \ \frac{\frac{-2}{7} \cdot  \frac{-9}{7}}{2} \cdot \frac{7^2}{150^2} \right)  \ $$
$$ \approx \ 27 \   \left( 1 \ - \ \frac{11}{10} \cdot \frac{2}{7} \ + \  \frac{6}{10} \cdot \frac{4}{7^2} \ - \ \frac{4 \cdot 4}{3 \cdot 3} \cdot \ \frac{1}{7^3}  \right) \   \left( 1 \ + \  \frac{7}{50}\ + \ 3 \cdot \frac{7^2}{150^2} \right) $$ $$ \cdot \ \left( 1 \ - \  \frac{1}{75} \ + \  \frac{9}{150^2} \right)  \ \ . $$
In order for the series for $  \ 3^{-2/7} \ $ to remain an underestimate, it is necessary to extend the Taylor polynomial to third-degree.  Simple linearizations give far too "coarse" approximations to resolve the inequality we desire clearly enough; we are also unable to obtain sufficient precision by only keeping the "linear" terms in the product.  There isn't much for it other than to arrange each factor to have a single denominator, which gives us
$$ 27 \ \left[ \ \left(  \frac{573}{490}  \right) \   \left( \frac{4197}{5625} \right)  \  \left(  \frac{5547}{5625} \right) \  -  \  \left(  \frac{11260}{15435}  \right) \ \left( \frac{25797}{22500} \right)  \  \left(  \frac{22209}{22500} \right) \right] \ > \ e^{\pi} \ - \ \pi^e \ \ . $$
From this point, it becomes a question of how much calculation one has the patience to do without the aid of a device; it would likely be easiest to divide out each ratio, multiply the three factors in each term, take the difference between terms, and multiply the result by $ \ 27 \ $ .  In the pre-calculator era, this would not have been considered unreasonable: after all, the Ludolphine number $ ( \pi ) $ was computed to 35 decimal places over 400   years ago using polygon-approximations over the course of some years. If we avail ourselves of a calculator at this point, we see that we have
$$ 27 \ \left( \ 1.16939 \cdot   0.74613  \cdot  0.98613 \  -  \  0.72951 \cdot 1.14653  \cdot  0.98707 \right) \ \approx \ 0.9403 \ > \ e^{\pi} \ - \ \pi^e \ \ . $$
This may be compared with the first inequality we wrote, for which our result is an intended overestimate,
$$ \left( \frac{68}{25} \right)^{22/7} \ - \ \left( \frac{157}{50} \right)^{19/7} \ \approx \ 0.8901  > \ e^{\pi} \ - \ \pi^{e} \  \ . $$
$$ \ \ $$
We might well wish for something more tractable, which can be obtained by making the estimate a bit differently.  If we're permitted the "number facts" $ \ e^3 \ \approx \ 20.1 \ \ , \ \ \pi^3 \ \approx \ 31 \ \ , \ \pi \ < \ \frac{22}{7} \ $ and $ \ e \ > \ \frac{19}{7}  \ $ , we can proceed from
$$ \frac{201}{10} \ \cdot \ e^{1/7} \ > \  e^{3 \ + \ \frac{1}{7}} \ > \ e^{\pi} \ > \ \pi^{e} \ > \ \pi^{3 \ - \ \frac{7}{25}} \ > \ 31 \ \cdot \ \pi^{-7/25} \ > \ 31 \ \cdot \ \left( \frac{\pi}{e} \right)^{-7/25} \ \cdot \  e^{-7/25} \ \ . $$
We would like the factor $ \ \left( \frac{\pi}{e} \right)^{-7/25} \ $ to be underestimated, so we will use the overestimate
$$ \ \left( \frac{\pi}{e} \right) \ < \ \frac{22/7}{19/7} \ = \ \frac{22}{19} \ \ . $$
As above, we will use Taylor polynomials for the powers of $ \ e \ $ and the generalized binomial series to produce
$$ \frac{201}{10} \ \cdot \ \left( 1 \ + \ \frac{1}{7} \ + \ \frac{1}{2 \cdot 7^2} \right) \ >  \ e^{\pi} \ > \ \pi^{e} \ > \  31 \ \cdot \ \left( 1 \ + \ \frac{3}{19} \right)^{-7/25} \ \cdot \  \left( 1 \ - \ \frac{7}{25} \ + \ \frac{7^2}{2 \cdot 25^2} \right)  $$
$$ \Rightarrow \ \ \frac{201}{10} \ \cdot \ \left( 1 \ + \ \frac{1}{7} \ + \ \frac{1}{98} \right) \ >  \ e^{\pi} \ > \ \pi^{e} \ > \  31 \ \cdot \ \left( 1 \ - \ \frac{7}{25} \cdot \frac{3}{19} \right) \ \cdot \  \left( 1 \ - \ \frac{7}{25} \ + \ \frac{49}{1250} \right)  $$
$$ \Rightarrow \ \ \frac{201}{10} \ \cdot \  \frac{113}{98}  \ >  \ e^{\pi} \ > \ \pi^{e} \ > \  31 \ \cdot \ \frac{454}{475}   \ \cdot \   \frac{949}{1250}  \ \ , $$
these ratios being obtainable by reasonably simple hand-calculation.  We can make the work we face in the right-hand term of this inequality a bit less onerous by using
$$ 31 \ \cdot \ \frac{454}{475}   \ \cdot \   \frac{949}{1250}  \ > \ 31 \ \cdot \ \frac{450}{475}   \ \cdot \   \frac{945}{1250}  \ = \ 31 \ \cdot \ \frac{18}{19}   \ \cdot \   \frac{189}{250} \ \ . $$
Re-arranging the inequality gives us
$$  \frac{201}{10} \ \cdot \  \frac{113}{98} \ - \ 31 \ \cdot \ \frac{18}{19}   \ \cdot \   \frac{189}{250} \ = \ \frac{201 \cdot  113 \cdot  19 \cdot 25 \ - \ 31 \cdot 18 \cdot 189 \cdot 98}{980 \cdot 19 \cdot 25}  \ >  \ e^{\pi} \ - \ \pi^{e}   \ \ . $$
While this looks a bit daunting, it is considerably easier to compute by hand than the earlier estimate:  a little work with binomials simplifies some of the multiplicaton and the rest is not too bad to work out "long-hand".  Hence,
$$ \frac{10,788,675 \ - \ 10,335,276}{465,500} \ = \ \frac{453,399}{465,500}  \ >  \ e^{\pi} \ - \ \pi^{e}   \ \ . $$
So we again establish the desired inequality, this time with more handiwork.  We can make use of the calculator (or divide long-hand if we really want to remain "pure") to find that this ratio is about 0.9740 .
I will admit to a bit of guidance from a calculator to make adequate selections for the rational approximations in the interests of saving some time.  It would take rather longer than  to refine the numbers used in this investigation if one had to work entirely without "machine assistance".
Comment: But $\approx$ is not rigorous enough, I think.
Comment: I found myself drawn back to this problem more than once in the past months and hope I have now answered certain earlier objections.  I offer this answer largely to give some sense of the trouble one must go to in order to obtain an estimate of the difference in question that is less than $ \ 1 \ $ .  (It is considerably less work to show that it is less than $ \ 1.5 \ $ .)  It also makes one thankful for the availability of high-precision calculating devices in the current era, as they save a great deal of time in looking for ways to refine the estimates used.
Answer: Let $x>0$. Consider $e^{e+x}-(e+x)^e=e^e(e^x-(1+\frac xe)^e)=e^e(A-B)$.
Now $z\ge \log(1+z)\ge z-\frac{z^2}2$, so $0\le A-B=A(1-\frac BA)\le A\log(A/B)\le A\frac{x^2}{2e}$. Hence, for $x=\pi-e$, we get
$$
0\le e^{\pi}-\pi^e\le e^{\pi-1}(\pi-e)^2/2\,.
$$
Now we use the trivial inequality $e\ge 2+\frac 12+\frac 16+\frac 1{24}=2+\frac{17}{24}>2.7$ ($170>168$ if you want to check it mentally) and the much less trivial inequality $\pi<3.15$, for which I have no paper-free proof, to get $(\pi-e)^2\le 0.45^2=0.2025<\frac 29$ (the two-digit numbers ending in $5$ can be squared without paper). So, all we need to show now is that $\log 9=2\log 3\ge 2.15$ or $-\log \frac 13>1.075$. However, writing the first 6 terms of the Taylor series, we see that this logarithm is at least
$$
\frac 23+\frac 29+\frac 8{81}+\frac 4{81}+\frac{32}{5\cdot 3\cdot 81}
+\frac{64}{6\cdot 9\cdot 81}
\ge 1+\frac 3{81}+\frac 2{81}+\frac{2}{15\cdot 81}+\frac 1{81}
\\
>1+\frac 6{81}+\frac 1{8\cdot 81}>1+\frac 6{81}+\frac 6{80\cdot 81}=1+\frac 6{80}=1.075
$$
So, if we define $\pi$ to be a number between $e$ and $3.15$, the whole computation (assuming decent memory) requires no pen and paper, not to mention calculators. However, $\pi$ is not defined that way, so the inequality $\pi<3.15$ is a gaping flaw in this argument :-(.
Comment: $\frac{22}{7}-\pi = \int_{0}^{1} \frac{(x-x^{2})^{4}}{1+x^{2}}dx >0$
Answer: Consider $f(x,y) = x^y - y^x$ where $x, y \approx 3$.  Increasing $x$ should bring $f$ down and increasing $y$ should bring $f$ up.  In general, without any real knowledge of $f$:
$$ 1 > f(x+ \epsilon_1, y + \epsilon_2) \approx
 f(x, y ) + \epsilon_1 \frac{\partial f}{\partial x}  + \epsilon_2 \frac{\partial f}{\partial y}
 $$
where the first inequality is something we are trying to prove for $x = e \approx 2.718$ and $y = \pi \approx 3.141$.

Let's try $x = \frac{11}{4}$ and $y = \frac{13}{4}$.   Then we have taken off too much slack:
$$ \left( \frac{11}{4} \right)^{\frac{13}{4}} - \left( \frac{13}{4} \right)^{\frac{11}{4}} \approx 1.214$$
Using the continued fractions of $e$ and $\pi  $ does give less than one and check with a calculator:
$$ \left( \frac{8}{3} \right)^{\frac{22}{7}} - \left( \frac{22}{7} \right)^{\frac{8}{3}} \approx 0.621$$
Even your proof requires a calculator in the last step... but we did not use the exact values of $\pi, e$.

How good is this approximation?  Somehow we should compute how quickly $f$ changes with $x$ and $y$:
$$ \frac{\partial f}{\partial x} = y \, x^{y-1} - (\ln y ) y^x \approx 3 \times 3^{3-1} - (\ln 3) 3^3 \approx -27(\ln \frac{e}{3}) \approx -2.7 $$
The $y$ partial derivative is similar, except it is positive instead of negative.

It can be proven, the continued fraction error of $e$ and $\pi$ are inversely proportional to the denominators:
$$ \left| e - \frac{8}{3} \right| < \frac{1}{3^2} \text{ and }  \left| \pi - \frac{22}{7} \right| < \frac{1}{7^2}$$
These would be our estimates of $\epsilon_1$ and $\epsilon_2$.  Then using  a tiny bit of multivariable calculus:
$$ \epsilon_1 \frac{\partial f}{\partial x}  + \epsilon_2 \frac{\partial f}{\partial y}
\approx \frac{1}{3^2} \times 2.7 + \frac{1}{7^2} \times (-2.7) < 0.355 $$
This should be enough to establish $|f(\pi,e)| < 1$.

This used a calculator in many places but not the exact value of the constants $\pi$ and $e$.
Answer: Take the roots against $\pi e$, to get $e^{1/e}$ v $\pi^{1/\pi}$.  These are instances if $x^{1/x}$ for $x=e$ and $x=\pi$.
For integers, we see that 9>8 and 2^4=4^2=16 imply that $\sqrt[3]{3} > \sqrt[4]{4} = \sqrt{2}$, from the sixth and eighth roots respectively.
Put $y=\sqrt[x]{x}$, whence $x = y^x$. We note that for values greater than 1, there are two solutions, the second is $z=y^z$.  We now suppose z>x, and consider the case w>z.  Where w>z, then $w<y^w$, which means that the value of y for w is less than that for z.
In the region where 1 < w < x  we note that $y^x > y^w$, still, and that $\sqrt[w]{w} < \sqrt[x]{x} < L$
If now we note that $\pi > 3 > e$, and if we find a corresponding value for 3, then the range from 3 to 3' will contain either pi or e.
We now seek a value r for which $r^3 = 3^r$.  Put r=2.5, gives r^3 = 125/8 = 15.625, and $9\sqrt{3}=1.732*9$, at 15.588.  This tells us that r<2.5, and we get $r=3'< 2.5 < e < 3 < \pi$.
Since this is a convergence of $x$ and $z$ converge on some limit $L$, we can use brackets of the form of ( and ) to show this convergance, viz
$ 3' (2.5  ( e )) 3 ) \pi$, and thus from $3' ( e ) 3 ) \pi$, $e^\pi > \pi ^e$.


onPrimary deprecation -> migration fail on Flutter 3.3.0

Question: In Flutter 3.3.0 primary should never used because of deprecation... by right clicking on primary I get a migration hint to change primary -> foregroundColor...
But the onPrimary property is also deprecated. The migration guide says: change onPrimary to foregroundColor (there is no onForegroundColor)... but there is the problem. onPrimary should be in high contrast to primary.
What is to do here?
Code Example:
ElevatedButtonThemeData getElevatedButtonTheme(ColorScheme colorScheme, TextTheme textTheme) => ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(32)),
        elevation: 1,
        primary: colorScheme.secondary,
        onPrimary: colorScheme.onSecondary,
        textStyle: textTheme.button,
      ),
    );

update:
by clicking in the flutter code I found a comment "..use disabledForegroundColor..."
Comment: Instead of editing your question that you found the solution it's better to write your solution as an answer. [It's allowed and even encouraged to answer your own questions](https://stackoverflow.com/help/self-answer)
Answer: Ok, it seems the comment was wrong...
primary is backgroundColor and
onPrimary is foreground
But only for ElevatedButtonThemeData
ElevatedButtonThemeData getElevatedButtonTheme(ColorScheme colorScheme, TextTheme textTheme) => ElevatedButtonThemeData(
      style: ElevatedButton.styleFrom(
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(32)),
        elevation: 1,
        backgroundColor: colorScheme.secondary,
        foregroundColor: colorScheme.onSecondary,
        textStyle: textTheme.button,
      ),
    );


Closed form for $\sum_{n=1}^\infty\frac{(-1)^n n^4 H_n}{2^n}$

Question: Please help me to find a closed form for the sum $$\sum_{n=1}^\infty\frac{(-1)^n n^4 H_n}{2^n},$$ where $H_n$ are harmonic numbers: $$H_n=\sum_{k=1}^n\frac{1}{k}=\frac{\Gamma'(n+1)}{n!}+\gamma.$$
Comment: Is it possible to generalize it to `n^a` instead of `n^4`? http://math.stackexchange.com/questions/385094/closed-form-for-sum-n-1-infty-frac-1n-na-h-n2n
Answer: $$\sum_{n=1}^\infty\frac{(-1)^n n^4 H_n}{2^n}=\frac{28}{243}+\frac{10}{81} \log \left(\frac{2}{3}\right).$$
Hint: Change the order of summation:
$$\sum_{n=1}^\infty\frac{(-1)^n n^4 H_n}{2^n}=\sum_{n=1}^\infty\sum_{k=1}^n\frac{(-1)^n n^4}{2^n k}=\sum_{k=1}^\infty\sum_{n=k}^\infty\frac{(-1)^n n^4}{2^n k}.$$
Comment: How is this a hint?
Answer: A related problem. Here is another approach. Recalling the generating function of the harmonic numbers
$$ \sum_{n=1}^{\infty} H_n x^n = \frac{\ln(1-x)}{x-1} \implies (xD)^4\sum_{n=1}^{\infty} H_n x^n=(xD)^4 \frac{\ln(1-x)}{x-1}, $$
$$ \implies \sum_{n=1}^{\infty} H_n n^4 x^n = {\frac {x \left( 1+11\,x+11\,{x}^{2}+{x}^{3} \right) \ln  \left( 1-x
 \right) }{ \left( -1+x \right) ^{5}}}+{\frac {x \left( -1-27\,{x}^{2}
-18\,x-4\,{x}^{3} \right) }{ \left( -1+x \right) ^{5}}}.$$
Substituting $x=-\frac{1}{2}$ in the above identity gives the desired result
$$ \sum_{n=1}^\infty\frac{(-1)^n n^4 H_n}{2^n}={\frac {28}{243}}-{\frac {10}{81}}\,\ln  \left( \frac{3}{2} \right).  $$
Comment: Pretty nifty (+1).
Comment: @RonGordon: Thanks for the comment.
Comment: @FelixMarin: Thanks for the comment. I really appreciate it.
Answer: Hint: Set $f_k=H_k$ and find a function $g_k$ such that  $g_{k+1}-g_k=\frac{(-1)^kk^4}{2^k}$ and use summation by parts to get:
$$\sum_{k=1}^nf_k(g_{k+1}-g_k)=f_{n+1}g_{n+1}-f_1g_1-\sum_{k=1}^n(f_{k+1}-f_k)g_{k+1}$$
$$\sum_{k=1}^nH_k(\frac{(-1)^kk^4}{2^k})=f_{n+1}g_{n+1}-f_1g_1-\sum_{k=1}^n(\frac{1}{k+1})g_{k+1}$$
Find the limit as $n\rightarrow \infty$. $g_k$ will be a function of the form $(\frac{-1}{2})^kp(k)+C$ for some polynomial $p$ and constant $C$. Thus, I believe the RHS will be a sum of the form:
$$\sum_{k=1}^{\infty}[(\frac{-1}{2})^kp(k)+C]\frac{1}{k+1}$$
which will be just tedious to evaluate.


Como usar 'while' em uma 'isNaN()'?

Question: Eu estou fazendo um teste de "questionário" e para funcionar o usuário tem que digitar apenas números, caso não digite, será emitido uma mensagem de erro para ele repetir o processo.
Consegui resolver isso com o seguinte:
if (isNaN(variavel1))
{
    Variavel1 = Prompt("Só são permitido numeros, tente novamente ");
}

Mas o problema é que isso só funciona uma vez. Se o usuário na segunda tentativa continuar escrevendo letras, o programa não manda ele digitar novamente.
Tentei usar o while mas não estou sabendo como usar para esse caso especifico.
Se puderem me ajudar, agradeço.
Comment: Sim, mas esqueci de informar, estou aprendendo Javascript. Por isso
Comment: Por que nao validar com HTML5? Só colocar input type number e pronto....
Answer: É possível validar no evento keyup... mas não recomendo mostrar um popup e sim algo mais sutil como alterar a cor do texto. Veja o exemplo:

var tb = document.getElementById("num");
tb.addEventListener("keyup", function(e){
  tb.className = isNaN(tb.value) ? "invalid" : "valid";
});
.invalid {
  color: red;
  }
<input id="num" type="textbox" />

Como usar 'while' em uma 'isNaN()'?


Nginx: maintenance mode with "is a developer" check

Question: It's much variants described in Internet how to display maintenance page with nginx. But I didn't find the solution to check if user is a developer and not to display maintenance page for developers.
I use try_files, which does't works as I need after any IF-section was entered. So I made my own solution, which I want to share. It works in any configuration with try_files, proxy and so on.
Answer:
In http section (out of any server section) check the user if he is a developer:
map $http_cookie $isDevHack {
    default "";
    ~DEVELOPER_SECRET=1010 "/non-existed-location";
}

User is a developer if he had DEVELOPER_SECRET with 1010 value in this case. This map is shared for all servers in config.
Append server section with 503-error handler:
error_page 503 @maintenance;
location @maintenance {
     rewrite ^(.*)$ /maintenance-mode.html break;
}

maintenane-mode.html is a page to display for non-developer users in maintenance mode. File path is relative to document_root of current server.
In location sections, which must be protected in maintenance mode, add before any normal-mode rules:
if (-f "$isDevHack/home/site-home/maintenance") {
    return 503;
}

If current user is a developer, checked file name will be prepended with /non-existed-location prefix and if will never be entered.
Answer: I have a fairly simple server setup for which the configuration at the end of the answer will do the following:

If a file named MAINTENANCE exists one level above the root, then the server will be in maintenance mode. (This is the -f test).
Except that if there exist a cookie named foo_dev with the value secret!, the check described above will be bypassed and nginx will serve the data as if the server were not in maintenance mode. (This is the $cookie_foo_dev = "secret!" test.)

I've tried with some try_files settings and did not run into any issue.
Here is the configuration.
server {
    # ... omitted stuff that does not pertain to the solution ...

    root <some path>;

    if ($cookie_foo_dev = "secret!") {
        break;
    }

    if ( -f $document_root/../MAINTENANCE) {
       return 503;
    }

    error_page 503 @maintenance;
    location @maintenance {
        rewrite ^(.*)$ /maintenance.html break;
    }

    location / {
        proxy_pass http://localhost:8000;
    }
}

All incoming connections are required to use HTTPS so the cookie never goes in plain text over the Internet.
I've also set the server to which nginx forwards the requests to display a big fat warning if the cookie foo_dev is set so that I don't mistakenly forget that the site is in maintenance mode.


How to make getTree works?

Question: I want to expose a vocabulary to an external server using services module. I have followed this question How to create test_endpoint, and checked every checkbox, and enabled the `REST Server Module.
The only endpoint that I interest is getTree. But I don't know how to compose the URL. I can't find any document describing the detail (please tell me if you know).

Which HTTP method should I use? GET or POST? I think it should be a GET, but I got nothing
how to specify the vid? /taxonomy_vocabulary/[vid]/getTree ? /taxonomy_vocabulary/getTree/[vid] ? or /taxonomy_vocabulary/getTree?vid=[vid]? any other params?

I have try some URL,
GET  [endpoint]/taxonomy_vocabulary/getTree will response [false] (what is this mean?)
POST [endpoint]/taxonomy_vocabulary/getTree will response 401 Unauthorized, but whatever I disable or enable the Session Authorization, I got the same response.
Answer: you must add {"vid":"1234"} in the body of HTTP POST request and add Content-Type in the header request with "application/json"

How to make getTree works?


Response.End terminating page events within a sharepoint page

Question: article
This article explains how to fix a bug in Sharepoint where the page would go dead after a save dialog is prompted. It states to add in my case where the link button is under the page where the link button resides
<code>exportButton.OnClientClick = "document.getElementsByTagName(\'form\')[0].onsubmit = function() {return true;}";
</code>
Ive tried this the error it produces is "server tag not well formed". My form name is aspnetForm and my link button name is TestLinkButton. Any ideas what im doing wrong from the article?
Answer: I'm curious what this is really solving, but I'll put that curiosity aside for now and just answer your question.
Get rid of those backslashes:
<code>   document.getElementsByTagName('form')[0].onsubmit = function() {return true;};
</code>
If that doesn't work, can you explain how you are injecting this line into the page? Maybe I can help out more then.


convergence series geometric test

Question: Prove if this converges:
$$\sum_{n=1}^\infty \frac{2^n+3}{3^n-1}$$
pf: using geometric
$$0 < \frac{2^n+3}{3^n-1} \leq \frac{2^n + 2 \times 2^n}{3^n-\frac{3^n}{2}} = \cdots $$ and so on
I know how to do the rest but my question is that where in the world did my teacher get
$$\frac{2^n + 2 \times 2^n}{3^n-\frac{3^n}{2}}$$
Comment: The ratio test does it.
Answer: A slightly better bound would be
$$\frac{2^n+3}{3^n-1}=\frac{2^n(1+3\cdot 2^{-n})}{3^n(1-3^{-n})}\leq \frac{5/2}{2/3}\frac{2^n}{3^n}$$
Comment: OP's bound gives convergence ($\frac{2^n+2\cdot 2^n}{3^n-3^n/2}= \frac{6\cdot 2^n}{3^n}$).
Comment: @Milly You're right. Let me edit.
Answer: You teacher increased the numerator (from $2^n+3$ to $2^n+ 2\cdot 2^n$, since $3\leq 2\cdot 2^n$), and decreased the denominator (from $3^n-1$ to $3^n-3^n/2$, since $1<3^n/2$), thus obtains a fraction (i.e. $\frac{2^n+2\cdot 2^n}{3^n-3^n/2}$) which is bigger than the original (i.e. $\frac{2^n+3}{3^n-1}$).
Answer: Ratio test:
$$
\frac{\left(\dfrac{2^{n+1}+3}{3^{n+1}-1}\right)}{\left(\dfrac{2^n+3}{3^n-1}\right)} \to \frac 2 3 \text{ as }n\to\infty,
$$
so the series converges.

convergence series geometric test


TomEE plus 1.7.1 in Linux hangs during server startup on myfaces-impl-2.1.15.jar

Question: Tomee plus 1.7.1 server was hanging on server startup and we debugged it found that myfaces-impl-2.1.15.jar is causing the problem. If we remove this jar from the server lib, server starts fine.
Same distribution works fine on windows environment but we see this problem on linux server. Appreciate your inputs.
Answer: Downloaded myfaces-api-2.2.7.jar and myfaces-impl-2.2.7.jar from https://myfaces.apache.org/ and replaced older version of myfaces jars.
I don't see the server hanging after replacing jars with latest jar files.


ERROR: Failed to build PhantomJS! Building Qt Base failed

Question: I have Debian Linux(64-bit) in VirtualBox.
Ram: 8Gb (for Debian 4Gb)

CPU: i5-3470

If any other details are needed please tell me.
I have followed instructions written here, and here you can see the console log.
For some reason I am unable to to build phantomjs and I can't understand why its not working... Have searched a lot, but couldn't find any thread which would be about this error.
--- EDIT ---
When I executed this command:
./configure --with-openssl-includes=/usr/include/openssl-1.0/ --with-openssl-libraries=/usr/lib/openssl-1.0/

Output was this:
--with-openssl-includes=/usr/include/openssl-1.0/: invalid command-line switch
--with-openssl-libraries=/usr/lib/openssl-1.0/: invalid command-line switch

The output of the console has changed but I still get errors: https://pastebin.com/wbgi8syg
Answer: Looks like you are on stretch (or later) and that you are already aware of the libssl vs libssl1.0 case.
Therefore, if you don't have libssl-dev installed, this line will get you further:
python build.py --qt-config "-I /usr/include/openssl-1.0/ -L /usr/lib/openssl-1.0/"

If you already have it installed and my suggestion doesn't work, you can uninstall libssl-dev for the time to build phantomjs which will likely avoid having to play further with configuration related variables.
Comment: Did you do add the --git-clean-qtbase option before trying ? Otherwise the tests are likely cached thus it's not a full re-build and you'll continue with the same errors..
Comment: Even with that still cant build: https://pastebin.com/4R3dpHeL   what I really don't understand is why it wouldn't build.. I mean it's fresh install of Debian, had followed all the steps and I still can't build it... Is this issue with phantomjs so everyone experiences same problem?
Comment: Build tested with an newly installed stretch (9.1) without desktop environment, with the same dependencies as mentionned in the guide with only libssl1.0-dev in place of libssl-dev. One thing you can do is to call "git submodule foreach git clean -ddfx" to ensure there's nothing left hanging from a prior build try.
Comment: I have uninstalled openssl-dev and installed openssl-1.0-dev, then ran: "git submodule foreach git clean -ddfx" and after that: "python build.py --qt-config "-I /usr/include/openssl-1.0/ -L /usr/lib/openssl-1.0/" --git-clean-qtbase".  still can't build :/
Comment: With the same error ? Do you still have something in /usr/include that concerns OpenSSL ?
Comment: I could build it after creating debian virtual machine again and tried everything one more time from the beginning. At first it didn't build but then I ran this command "sudo apt-get install libssl1.0-dev". I don't know why it worked, but it did(even though I tried it before). Thank you for help :)


How to test the equality of coefficients in a quantile regression?

Question: I run this model on the 95th percentile (Stata 14)

β(2012) 1 : 1 is a dummy variable when Y is observed in 2012
β(2013) 1 : 1 is a dummy variable when Y is observed in 2013
β(2014) 1 : 1 is a dummy variable when Y is observed in 2014

I want to test the equality of  β(2012) and  β(2013).
Does quantile regression assumes the normality of the distribution? In other words, can I simply run a T-test for this coefficients equality test?
Comment: [A similar question was asked here.](https://stats.stackexchange.com/q/124796/1352) A potential reference was given in a [comment](https://stats.stackexchange.com/questions/124796/testing-for-statistical-differences-of-quantile-regression-line-slopes#comment237867_124796), but since there is no upvoted or accepted answer, we can't close this question as a duplicate of that one.
Answer: You can just do a Wald test on the coefficients directly or via margins:
. sysuse auto
(1978 Automobile Data)

. qreg price i.rep78, quantile(0.5) nolog

Median regression                                   Number of obs =         69
  Raw sum of deviations    65163 (about 5079)
  Min sum of deviations    63340                    Pseudo R2     =     0.0280

------------------------------------------------------------------------------
       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
       rep78 |
          2  |        170   1745.715     0.10   0.923    -3317.467    3657.467
          3  |       -185   1612.622    -0.11   0.909    -3406.584    3036.584
          4  |        864   1645.876     0.52   0.601    -2424.015    4152.015
          5  |        463   1697.437     0.27   0.786     -2928.02     3854.02
             |
       _cons |       4934   1561.415     3.16   0.002     1814.715    8053.285
------------------------------------------------------------------------------

. test _b[5.rep78] = _b[3.rep78]

 ( 1)  - 3.rep78 + 5.rep78 = 0

       F(  1,    64) =    0.69
            Prob > F =    0.4082

. margins rep78, pwcompare(pveffects)
Warning: cannot perform check for estimable functions.

Pairwise comparisons of adjusted predictions
Model VCE    : IID

Expression   : Linear prediction, predict()

-----------------------------------------------------
             |            Delta-method    Unadjusted
             |   Contrast   Std. Err.      z    P>|z|
-------------+---------------------------------------
       rep78 |
     2 vs 1  |        170   1745.715     0.10   0.922
     3 vs 1  |       -185   1612.622    -0.11   0.909
     4 vs 1  |        864   1645.876     0.52   0.600
     5 vs 1  |        463   1697.437     0.27   0.785
     3 vs 2  |       -355   878.6573    -0.40   0.686
     4 vs 2  |        694   938.2936     0.74   0.460
     5 vs 2  |        293   1026.051     0.29   0.775
     4 vs 3  |       1049   658.3504     1.59   0.111
     5 vs 3  |        648   778.3381     0.83   0.405
     5 vs 4  |       -401   845.0837    -0.47   0.635
-----------------------------------------------------

Edit:
You can do a one-sided test like this:
qreg price i.rep78, quantile(0.5) nolog
local sign_diff = sign(_b[5.rep78] - _b[3.rep78])
testnl _b[5.rep78] - _b[3.rep78] = 0
display "H_0: _b[5.rep78] >= _b[3.rep78] p-value = " normal(`sign_diff'*sqrt(r(chi2)))

or perhaps like this:
qreg price i.rep78, quantile(0.5) nolog
local sign_diff = sign(_b[5.rep78] -_b[3.rep78])
test _b[5.rep78] = _b[3.rep78]
display "H_0: _b[5.rep78] >= _b[3.rep78] p-value = " 1-ttail(r(df_r),`sign_diff'*sqrt(r(F)))

Comment: If I want to test  : `test _b[5.rep78] >= _b[3.rep78]`,
how does this change the critical value of the Wald Test?
Comment: There was a thread about this on SO yesterday: https://stackoverflow.com/q/51734678/1187671
Comment: This is what I am wondering though, since the post (link) is a test  related to a scalar `test _b[_cons] = 10`. Is it the exact same process when we compare 2 coefficients `test _b[5.rep78] >= _b[3.rep78]` ?
Comment: No, read the post carefully.
Comment: e.g.  `local sign_rep = sign(_b[5.rep78] - _b[3.rep78])`

`display "H_0: 5.rep coef >= 3. rep coef. p-value="  ttail(r(df_r),`sign_rep'**sqrt(r(F)))
Comment: It's testing a less than or equal to hypothesis, which uses an equality hypothesis test as an ingredient.
Comment: @user399035 See the edit above.


Python - pyinstaller - executable project by pyinstaller has error Failed to execute script pyi_rth_pkges

Question: I try to executable project by pyinstaller but has error Failed to execute script pyi_rth_pkges , after run program.
Hello Guys this is project structure: tree /F app-1.0.1
│   LICENSE
│   main.py      # this module to run GUI build by tkinter
│   MANIFEST.in
│   PKG-INFO
│   README.md
│   setup.cfg
│   setup.py      # this is the module to package all application
│
├───app.egg-info
│       dependency_links.txt
│       entry_points.txt
│       PKG-INFO
│       requires.txt
│       SOURCES.txt
│       top_level.txt
│
├───components
│       frame.py
│       menu.py
│       vie.py
│       __init__.py
│
├───lib
│       functions.py
│       variable.py
│       __init__.py
│
├───pages
│       winAbout.py
│       win_star.py
│       __init__.py
│
├───data
    │   __init__.py
    │
    └───image
            logo.ico
            home.jpg
            __init__.py

This is The setup.py code :
from setuptools import setup , find_packages

setup(
    name="app",
    version="1.0.1",
    description="A Python package to get Auto reports for any Site.",
    author="john",
    author_email="firstname.lastname@example.com",
    license="MIT",
    classifiers=[
        "License :: OSI Approved :: MIT License",
        "Programming Language :: Python :: 3",
        "Programming Language :: Python :: 3.7",
    ],
    packages=find_packages(),
    package_data={
        'data': ['image/*.ico', 'image/*.jpg'],
    },
    install_requires= ['Pillow'],
    entry_points={
        'console_scripts': [
            'napp=main:App'
        ]
    }
)

After using code: pyinstaller --onefile -w setup.py I see the message in Shell.
1699 INFO: PyInstaller: 3.6
1699 INFO: Python: 3.8.2
1715 INFO: Platform: Windows-10-10.0.18362-SP0
1715 INFO: wrote C:\Users\JOHN\Desktop\app\setup.spec
1730 INFO: UPX is not available.
1768 INFO: Extending PYTHONPATH with paths
['C:\\Users\\JOHN\\Desktop\\app', 'C:\\Users\\JOHN\\Desktop\\app']
1768 INFO: checking Analysis
1768 INFO: Building Analysis because Analysis-00.toc is non existent
1768 INFO: Initializing module dependency graph...
1784 INFO: Caching module graph hooks...
1815 INFO: Analyzing base_library.zip ...
11684 INFO: Processing pre-find module path hook   distutils
11690 INFO: distutils: retargeting to non-venv dir 'c:\\python\\lib'
24084 INFO: Caching module dependency graph...
24348 INFO: running Analysis Analysis-00.toc
24448 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\python\python.exe
24702 INFO: Analyzing C:\Users\JOHN\Desktop\Amazon\setup.py
25809 INFO: Processing pre-find module path hook   site
25840 INFO: site: retargeting to fake-dir 'c:\\python\\lib\\site-packages\\PyInstaller\\fake-modules'
32617 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
34642 INFO: Processing module hooks...
34642 INFO: Loading module hook "hook-distutils.py"...
34695 INFO: Loading module hook "hook-encodings.py"...
34858 INFO: Loading module hook "hook-lib2to3.py"...
34958 INFO: Loading module hook "hook-pkg_resources.py"...
36349 INFO: Processing pre-safe import module hook   win32com
36581 INFO: Excluding import '__main__'
36581 INFO:   Removing import of __main__ from module pkg_resources
36581 INFO: Loading module hook "hook-pycparser.py"...
36618 INFO: Loading module hook "hook-pydoc.py"...
36618 INFO: Loading module hook "hook-pythoncom.py"...
37182 INFO: Loading module hook "hook-pywintypes.py"...
37745 INFO: Loading module hook "hook-setuptools.py"...
39108 INFO: Loading module hook "hook-sysconfig.py"...
39126 INFO: Loading module hook "hook-win32com.py"...
c:\python\lib\site-packages\win32com\client\makepy.py:369: SyntaxWarning: "is not" with a literal. Did you mean "!="?
  if path is not '' and not os.path.exists(path):
40488 INFO: Loading module hook "hook-xml.dom.domreg.py"...
40519 INFO: Loading module hook "hook-xml.etree.cElementTree.py"...
40519 INFO: Loading module hook "hook-xml.py"...
40519 INFO: Loading module hook "hook-_tkinter.py"...
41461 INFO: checking Tree
41461 INFO: Building Tree because Tree-00.toc is non existent
41461 INFO: Building Tree Tree-00.toc
41923 INFO: checking Tree
41923 INFO: Building Tree because Tree-01.toc is non existent
41923 INFO: Building Tree Tree-01.toc
42005 INFO: Looking for ctypes DLLs
42121 INFO: Analyzing run-time hooks ...
42121 INFO: Including run-time hook 'pyi_rth__tkinter.py'
42158 INFO: Including run-time hook 'pyi_rth_multiprocessing.py'
42205 INFO: Including run-time hook 'pyi_rth_pkgres.py'
42220 INFO: Including run-time hook 'pyi_rth_win32comgenpy.py'
42289 INFO: Looking for dynamic libraries
44434 INFO: Looking for eggs
44434 INFO: Using Python library c:\python\python38.dll
44434 INFO: Found binding redirects:
[]
44465 INFO: Warnings written to C:\Users\JOHN\Desktop\app\build\setup\warn-setup.txt
44614 INFO: Graph cross-reference written to C:\Users\JOHN\Desktop\app\build\setup\xref-setup.html
44773 INFO: checking PYZ
44773 INFO: Building PYZ because PYZ-00.toc is non existent
44773 INFO: Building PYZ (ZlibArchive) C:\Users\JOHN\Desktop\app\build\setup\PYZ-00.pyz
46679 INFO: Building PYZ (ZlibArchive) C:\Users\JOHN\Desktop\app\build\setup\PYZ-00.pyz completed successfully.
46759 INFO: checking PKG
46759 INFO: Building PKG because PKG-00.toc is non existent
46759 INFO: Building PKG (CArchive) PKG-00.pkg
66169 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully.
66215 INFO: Bootloader c:\python\lib\site-packages\PyInstaller\bootloader\Windows-32bit\runw.exe
66215 INFO: checking EXE
66215 INFO: Building EXE because EXE-00.toc is non existent
66231 INFO: Building EXE from EXE-00.toc
66247 INFO: Appending archive to EXE C:\Users\JOHN\Desktop\app\dist\setup.exe
66331 INFO: Building EXE from EXE-00.toc completed successfully.

I get 'dist' folder has the Setup.exe but after run it from sheel I see this error.
PS C:\Users\JOHN\Desktop\app\dist> Setup.exe
Setup.exe : The term 'Setup.exe' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the
spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Setup.exe
+ ~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Setup.exe:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Suggestion [3,General]: The command Setup.exe was not found, but does exist in the current location. Windows PowerShell does not load commands from the current location by default. If you trust this command, instead type: ".\Setup.exe". See "get-help about_Command_Precedence" for more details.

And After run from Setup.exe from folder I see this Message error:
Comment: Compiling a setup.py is pointless. It won't affect your python installation. PyInstaller has its own isolated internal environment which is where it would be installed. And when you're running in one file mode, the package that had been installed would get deleted. You can't edit a onefile executable.
Comment: I need to build program, like FileZilla.but run and use it without installing
Comment: Oh I don't know why python has all this problems in  executable application but if build it in Microsoft Visual Studio it easy to executable your application. I have this tree of my application build by tkinter and script selenium how can I build executable application?? . if is possible to move this project selenium in Visual Studio and build GUI by it and executable application without any problem?
Comment: you're going about this wrong. Do you want to build a library like something from pypi, or a program, like FileZilla?
Comment: that's easy. Which is the main python file which you run to run your app?
Comment: Run main.py module to launch application interface and after click start run script selenium from this module AllTests.py
Comment: Does this answer your question? [Pyinstaller "Failed to execute script pyi\_rth\_pkgres" and missing packages](https://stackoverflow.com/questions/37815371/pyinstaller-failed-to-execute-script-pyi-rth-pkgres-and-missing-packages)
Comment: @john try `pyinstaller main.py -w`. That should work.
Comment: same problem look in this sample https://github.com/Jtonna/Processes-Killer
Answer: you should add this import in your main file code
import pkg_resources.py2_warn
also, you can type this for trying solve problem

pip uninstall pyinstaller
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip
Comment: I add this line in main.py but same problem, I think this way setuptools iby pyinstaller is wrong
Comment: pkg_resources isn't the issue here. (Well it is, but @john is compiling incorrectly)
Comment: Thanks AhmedHaies all work fine after add import pkg_resources.py2_warn in main.py and remove setup.py


Fundamental Theorem of Arithmetic for Positive Rational Numbers and not just Integers?

Question:
I'm using a picture because I want to reflect the book. I'm flustered. Why not introduce the Fundamental Theorem of Arithmetic  as Exercise 2.19,
for $\{$ positive rational numbers $\} \supseteq \mathbb{Z}>1$?  Why just $\mathbb{Z}>1$ first — and then make an exercise about it for $\{$ positive rational numbers $\}$ ?
Wikipedia — Allowing negative exponents provides a canonical form for positive rational numbers.
Comment: a nonzero rational number is defined in terms of two integers with no common factors. a rational integer just means an integer
Comment: @DavidHolden Thanks. i fixed title
Answer: $\newcommand{\ord}{\operatorname{ord}}$
Let $r$ be a non-zero rational number. Then, by definition, there exist integers $a,b \in \mathbb Z$, non-zero, such that $r = a/b$. By the fundamental theorem of arithmetic in $\mathbb Z$, we can write $$a = \pm\prod_{i=1}^\infty p_i^{\ord_{p_i}(a)},$$
and
$$b = \pm \prod_{i=1}^\infty p_i^{\ord_{p_i}(b)},$$
where $\{p_i\}$ is the set of all prime numbers in $\mathbb Z$ and $\ord_{p_i}(a),\ord_{p_i}(b) \in \mathbb N$ are zero for almost all indexes $i$ (except by a finite number). This decomposition is unique. So, if you define $\ord_{p_i}(r)=\ord_{p_i}(a)-\ord_{p_i}(b)$, then, since $r = a/b$, we have
$$ r = {\left(\pm\prod_{i=1}^\infty p_i^{\ord_{p_i}(a)}\right) \over \left(\pm \prod_{i=1}^\infty p_i^{\ord_{p_i}(b)}\right)} = \pm\prod_{i=1}^\infty p_i^{\ord_{p_i}(r)},$$
where, now, $\ord_{p_i}(r) \in \mathbb Z$ is zero for almost all indexes. This shows the existence of prime factorization in $\mathbb Q$. If you are interested, verify this factorization is unique.
Comment: Thanks. Your answer is too hard. What's $ord(p_i)$? Can you simplify please?
Comment: $\operatorname{ord}_{p_i}(a)$ is the exponent of $p_i$ that appears in the prime factorization of $a$.
Comment: thanks. and why is $ord_{p_i} = 0$  for almost all indexes i (except by a finite number) ? Can you please answer in your answer (not in comments)? Can you please move your comment overhead into your answer?


A question in Proof of Theorem 10.27 of Apostol Mathematical Analysis

Question: While self studying Lebesgue integration from Tom M Apostol I am unable to think about an how to deduce a line in the proof whose image I am adding( line is highlited.

I am not able to deduce the line that the sequence { $G_n(x) $ } decreases almost everywhere and hence converges everywhere.

I am unable to get how the author wrote that {$ G_n (x) $ } is decreasing? and how that implies that it's convergent.
Kindly help.
Comment: The fact $G_n(x) $ is decreasing is already explained in "since $A\subseteq B$ implies $\sup A \leq \sup B$".
Comment: The convergence of $G_n(x) $ is explained afterwards by showing that if $f_n(x) \to f(x) $ then $G_n(x) \to f(x) $. The details are in next page of the book.
Answer: $\{G_n (x)\}$ is decreasing because it's defined as supremum of $\{f_n(x), f_{n+1}(x),...\}$. $G_1 (x)=\sup\{f_1(x),f_2(x),f_3(x),...\}$ and $G_2(x)=\sup\{f_2(x), f_3(x),...\}$, so, depending on $f_1(x)$, $G_2(x)\leq G_1(x)$ and so on.
And this is why $\{G_n (x)\}$ converges a.e.: $\{f_n(x)\}$ converges a.e. and for fixed $x_0$, such that number sequence $\{f_n(x_0)\}$ converges, we have $$\lim_{n\to \infty}f_n(x_0) = \lim_{n\to \infty}\left( \sup_{m\geq n}f_n(x_0)\right) = \lim_{n\to \infty}\left( \inf_{m\geq n}f_n(x_0)\right)$$
So, $$\lim_{n\to \infty}f_n(x_0) = \lim_{n\to \infty}G_n(x_0)$$ hence $\{G_n (x)\}$ converges in points, where $\{f_n (x)\}$ also converges.


How to check whether a username already exists?

Question: I had created a controller where I can create a new user programmitically by the following code.
<code>$user = User::create();

      //Mandatory settings
      $user->setPassword($password);
      $user->enforceIsNew();
      $user->setEmail($email);

      //This username must be unique and accept only a-Z,0-9, - _ @ .
      $user->setUsername($username);

      //Optional settings
      $language = 'en';
      $user->set("init", 'email');
      $user->set("langcode", $language);
      $user->set("preferred_langcode", $language);
      $user->set("preferred_admin_langcode", $language);
      $user->activate();

      //Save user
      $user->save();
      drupal_set_message("User with uid " . $user->id() . " saved!\n");

      $uid = $user->id();
</code>
I am passing all variables via postman by POST method. I am using email as the username. But I want to check a condition (whether the username is already exist ) before the user creation. How can I write the if condition?
Comment: It's easy to end up with a race condition leading to unexpected results - can you give more details on exactly what you're trying to do? It might make more sense to try and create a user and detect a constraint violation (duplicate usernames aren't allowed) than to explicitly make a call trying to check ahead-of-time.
Answer: I guess you can use a simple EntityQuery.
<code>  $ids = \Drupal::entityQuery('user')
        ->condition('name', 'USERNAME_TO_CHECK')
        ->range(0, 1)
        ->execute();
    if(!empty($ids)){
      //then this name already exists
    }
</code>
Comment: Much shorter version: `$account = User::loadByProperties(['name' => 'foo']);`. Then just test `$account` for `NULL`.
Comment: you can do $user_id = reset($ids) and then $existing_user = User::load($user_id);
don't forget to call use Drupal\user\Entity\User; in your file or php class.
Comment: Thank you that works... ! How can i just print that id inside that $ids array...? When i try to print_r($ids) I got Array ( [28] => 28 ) ............. 28 is the uid... but how can i fetch that from $ids. I need to use this uid.
Answer: Instead of custom one-off checks, you should use the validation API.
Before saving, call $user->validate(). That tells you if anything with the values isn't OK, there is also a limit on what characters are allowed for the username/email and so on.
See https://www.drupal.org/docs/8/api/entity-validation-api/entity-validation-api-overview.


On Zeta function zeros in the critical strip

Question: I have been reading about Riemann Zeta function and have been thinking about it for some time.
Has anything been published regarding upper bound for the real part of zeta function zeros as the imaginary part of the zeros tend to infinity?
Thanks
Comment: Well, the *conjecture* is that all the real parts of critical strip zeroes are equal to 1/2. anyway, have a look at (sadly now nearing its end) [ZetaGrid](http://www.zetagrid.net/).
Comment: I feel bad about ZetaGrid too... :(
Answer: The term in analytic number theory is "zero-free regions".  Any proof of the prime number theorem will produce such a region, and the region is equivalent to the error term in bounds for $\pi(x)$ and to the lower bounds in nonvanishing theorems $|\zeta (1+it)|> 0$. At present, the known zero-free regions are asymptotic to the line $Re(s)=1$: at height $h$ all zeros are at least at distance $d(h)$ from the line with $\lim_{|h| \to \infty} d(h) = 0$.
(Added: on the subject of later improvements, if any region not asymptotic to $Re(s)=1$ were demonstrated it would be a giant advance in number theory, comparable to Wiles' proof of the modularity conjecture and Fermat's Last Theorem. In the analogous function field case there is an algebraic technique for boosting Beta < 1 to Beta < (1/2)+epsilon, and the latter is the Riemann hypothesis.  You can be sure that if a zero free region were proven that had finite distance from the boundary of the critical strip, we would all have heard about it.  Some known bounds are listed at http://www.math.uiuc.edu/~ford/wwwpapers/zeros.pdf )
Comment: Great answer... I wanted to know exactly this... "At present, the known zero-free regions are asymptotic to the line Re(s)=1"
Comment: Im sorry but there are better bounds known then asymptotic to Re(s) = 1 ? See the wiki pages on zeta , RH and PNT.
Answer: I would suggest you read the book "Riemann's Zeta Function" by H.M.Edwards.
As to your question, this is one theorem (from the above book)

De La Vallee Poussin's Theorem (1899) : There exist constants $c > 0, K > 1$ such that
$$ \beta < 1 - \frac{c}{\log \gamma}$$
for all roots $\rho = \beta + i \gamma$, in the range $\gamma > K$.

I am pretty sure there will be more such theorems (the book itself mentions that the above theorem has been improved upon). The book also mentions that (as of 1974) that the bound $\beta < 1$ (real part of the root) has not been improved!
Hope that helps.
Comment: I second the recommendation of Edwards's book.
Comment: Thanks for the recommendation!!! I have the Edwards book. I'll look into it.
Answer: De La Vallee-Pousin's theorem has been improved by Korobov and Vinogradov in the 50's and I believe their result is the strongest known asymptotic zero free region, cf. The Riemann zeta-function: Theory and applications by Alexandar Ivic. One can find more recent papers but my impression is that they don't touch the main exponents and so relatively tractable problems seem to be improving the constants, or giving explicit bounds on the constants etc.
Comment: What is the title of Ivic's book, if you don't mind?
Comment: J.M., the book title is *The Riemann zeta-function: Theory and applications* by Alexandar Ivic. (Actually the c in Ivic has an accent over it).


Dimension of a vector space of sequences and if it is complete?

Question: Consider the vector space V of all real sequences such that $\sum_{n=1}^{\infty}2^n|a_n|$ converges. Consider the norm as $||(a_n)||= \sum_{n=1}^{\infty}2^n|a_n|$

Is this vector space complete?
Is the dimension countable?

For part 1. I considered the sequence of sequences with finitely many positions = $(1/2)^n$ from 1st to nth position and rest 0. I "believe" under this norm this sequence converges to the sequence with nth element = $(1/2)^n$ and then the sum will not converge. Am I right?
For part 2. I am stumped. But I do see that it is at least not finite dimensional.
Comment: 1. Wrong: the vector space is isometric to $\ell^1$ so it is complete. For 2., use the Baire Category Theorem to show that no complete vector space is a countable union of proper closed subspaces (eg finite-dimensional), and in particular cannot be of countable dimension.
Answer: The sequence that you created does not converge in that norm.
The answer has been presented by @Mindlack in the comment. But I would like to point out a way to see the completeness of $V$.
Actually $V$ is $L^{1}(\mu)$, where $d\mu(x)=\omega(x)d\nu(x)$, here the variable $x$ is discrete, it is just $n$, and $\omega(x)=2^{x}$, $\nu$ being the counting measure, and that
\begin{align*}
\sum_{n}2^{n}|a_{n}|=\int_{\mathbb{N}}|f(x)|\omega(x)d\nu(x)=\int_{\mathbb{N}}|f(x)|d\mu(x),
\end{align*}
where $f(x)=a_{x}$. And we know that $L^{1}(\mu)$ is complete for every measure $\mu$.


How to read WhatsApp media path

Question: I am creating a chat application in which I am uploading images and videos from the gallery like WhatsApp, but when I trying select image which is already downloaded by WhatsApp folder then I get this path
/storage/emulated/0/WhatsApp/Media/WhatsAppImages/IMG-20180717-WA0024.jpg

but when I read this to get real path to show image then I am getting this exception:

java.io.FileNotFoundException: open failed: ENOENT (No such file or directory)

This is my provider
<provider
        android:name="android.support.v4.content.FileProvider"
        android:authorities="${applicationId}"
        android:exported="false"
        android:grantUriPermissions="true">
        <meta-data
            android:name="android.support.FILE_PROVIDER_PATHS"
            android:resource="@xml/file_paths" />
    </provider>

Below are the file path
<resources>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path name="/storage/emulated/0" path="."/>
</paths>

This happens only with WhatsApp media anyone please tell me the solution.
Thanks in advance
Comment: can you please add your java file code?? and did you add provider to code?
Comment: @LearningAlways yes i add this in menifest
Comment: Please edit your ans with manifest file and some java code. which may produce error. instead of adding code in comment.
Comment: @LearningAlways edited please check now
Comment: did you change your android:authorities="${applicationId}" to like android:authorities="com.ex.example.fileprovider". try this for more reference see ans below
Comment: you can also  find about your issue https://stackoverflow.com/questions/30896130/fileprovider-crash-npe-attempting-to-invoke-xmlresourceparser-on-a-null-string here
Answer: android:authorities="${applicationId}" here application id contains your project package name.
which are define in you app gradle file
 defaultConfig {
        applicationId "<your app Id>"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 25
        versionName '5.8'
        multiDexEnabled true
    }

/////
<provider
            android:name="android.support.v4.content.FileProvider"
            android:authorities="<package name>.fileprovider" // which are defined in app gradle application id
            android:exported="false"
            android:grantUriPermissions="true">
            <meta-data
                android:name="android.support.FILE_PROVIDER_PATHS"
                android:resource="@xml/file_paths_public" />
        </provider>

and your xml file should like
<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <external-path
        name="external_files"
        path="." />
</paths>

and your java code are like.
here file is your filepath which you are trying to access
Uri uri = null;
     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
                    uri = FileProvider.getUriForFile(this, getApplicationContext().getPackageName() +
                            ".provider", file);
                } else {
                    uri = Uri.fromFile(file);
                }

after getting path in uri do whatever you want with this.
and for getting real path try this It may work.
public String getRealPathFromURI(Uri contentURI) {
        String result;
        Cursor cursor = context.getContentResolver().query(contentURI, null,
                null, null, null);

        if (cursor == null) { // Source is Dropbox or other similar local file
            // path
            result = contentURI.getPath();
        } else {
            cursor.moveToFirst();
            try {
                int idx = cursor
                        .getColumnIndex(MediaStore.Images.ImageColumns.DATA);
                result = cursor.getString(idx);
            } catch (Exception e) {
                AppLog.handleException(ImageHelper.class.getName(), e);
                Toast.makeText(context, context.getResources().getString(
                        R.string.error_get_image), Toast.LENGTH_SHORT).show();

                result = "";
            }
            cursor.close();
        }
        return result;
    }

Comment: Permission Denial: opening provider com.whatsapp.MediaProvider
Comment: did you change your  android:authorities="${applicationId}" to like
android:authorities="com.ex.example.fileprovider". try this
Comment: i get this uri

content://com.example.myapp/external_files/WhatsApp/Media/WhatsAppImages/IMG-20180717-WA0024.jpg

but still cannot get real path
Comment: this is your real path above marshmellow device.. you can access this file with that uri.. and you can also convert uri to string if you want .
Comment: If you don't mind send your java code block where you get any error or exception
Comment: Thanks but i want path like this

/storage/emulated/0/Download/abc.jpg

I want uri to give me this type of path... i am using Oreo version...  will you tell me how can i get this type of path or should i store to another folder?
Comment: Error is resolved as per your provided help link thanks but i want real path as i mentioned above
Comment: In that case replace this uri mannualy "content://com.example.myapp/external_files" with your /storage/emulated/0
Comment: according to this .... it can again lead me to my question

/storage/emulated/0/WhatsApp/Media/WhatsAppImages/IMG-20180717-WA0024.jpg
Comment: android.database.CursorIndexOutOfBoundsException: Requested column: -1, # of columns: 2

getting this exception now :(
Comment: Check ans from this https://stackoverflow.com/questions/19985286/convert-content-uri-to-actual-path-in-android-4-4/27271131#27271131
Comment: Ok. may be you got your solution :)
Answer: Error throw column '_data' does not exist when i share video from whatsapp to my app
java.lang.IllegalArgumentException: column '_data' does not exist
Comment: i also use this method.this methos was working in file manager.But i have share video from whatsapp or hike to my app throws exception column_data does not exist and illegalArgumentException Please Help me...

How to read WhatsApp media path


why does ggplot show outliers but no whiskers?

Question: I created the following plot in R (ggplot2). But I don't know how to interpret the third boxplot. From the documentation: 'The upper whisker extends from the hinge to the largest value no further than 1.5 * IQR from the hinge (where IQR is the inter-quartile range, or distance between the first and third quartiles)'. However, the plot does not show any whisker up to the largest value or 1.5 * the IQR. Why not?
Answer: Note that the middle boxplot does show upper and lower whiskers.
Note that whiskers extend from the box to specific values, namely, for the upper whisker, "the largest value no further than 1.5 * IQR from the hinge", and analogously for the lower whisker. It is implicit in this definition that values that fall inside the box are not considered.
For instance, the boxplot on the right seems to describe only five data points. The box extends from the second-smallest (the first quartile) to the second-largest one (the third quartile). This only leaves the largest and the smallest value as potential candidates to extend the whiskers to. But apparently, they are both farther than 1.5 IQR away from the hinge, so they are considered outliers. Thus, there are no values to extend the whiskers to. Consequently, no whiskers are drawn.
The boxplot on the left apparently has identical first and the third quartiles, so the IQR is zero. In such a situation, no value will be outside the box and less than 1.5 IQR away from the hinge (because 1.5 IQR is also zero), so again, no value qualifies as the endpoint of a whisker, and no whisker is drawn.


How to pass variables between theme functions

Question: I often use functions that contain variables in the following files:

Template.php
Custom Panels Style Plugins
node.tpl.php files
field.tpl.php files
views.tpl.php files

I often needed to pass variables between these functions.
At the moment, I do this by declaring my variable as a global Using PHP's global command. However, I have read that is not best practice. Is there a better way?
I know that Drupal has variable_set() and  variable_get(). However, apparently these have similar problems to using Globals for lots of little variables.
Comment: What is the source of your global variables. Did you retrieve these data from database on every page request?
Comment: @Xio I create them in the theme layer
Answer: I am newish to Drupal, but will give this a shot (I'm sure someone will tell me if I am wrong).
You can set variables that exist in different contexts by using the template.php file of your theme by adding stuff to the $variables array with preprocessor functions. So you could maybe add your variables to the YOURTHEME_preprocess_html() function, which should make them available everywhere.
function YOURTHEME_preprocess_html(&$variables, $hook) {
  $variables['sample_variable'] = t('Lorem ipsum.');
}

Answer: What about hook_preprocess? This hook called for all templates.
Answer: You probably need some settings, so using variable_set is a normal practice I think.


How to import state created on another server?

Question: I setup my Kubernetes cluster using kops, and I did so from local machine.  So my .kube directory is stored on my local machine, but I setup kops for state storage in s3.
I'm in the process of setting up my CI server now, and I want to run my kubectl commands from that box. How do I go about importing the existing state to that server?
Answer: To run kubectl command, you will need the cluster's apiServer URL and related credentials for authentication. Those data are by convention stored in ~/.kube/config file. You may also view it via kubectl config view command.
In order to run kubectl on your CI server, you need to make sure the ~/.kube/config file contains all the information that kubectl client needs.
With kops, a simple naive solution is to:
1) install kops, kubectl on your CI server
2) config the AWS access credential on your CI server (either via IAM Role or simply env vars), make sure it has access to your s3 state store path
3) set env var for kops to access your cluster:
  export NAME=${YOUR_CLUSTER_NAME}
  export KOPS_STATE_STORE=s3://${YOUR_CLUSTER_KOPS_STATE_STORE}

4) Use kops export command to get the kubecfg needed for running kubectl
  kops export kubecfg ${YOUR_CLUSTER_NAME}

see https://github.com/kubernetes/kops/blob/master/docs/cli/kops_export.md
Now the ~/.kube/config file on your CI server should contain all the information kubectl needs to access your cluster.
Note that this will use the default admin account on your CI server. To implement a more secure CI/CD environment, you should create a service account bind to a required permission scope (a namespace or type or resources for example), and place its credential on your CI server machine.
Comment: when I do this, I get `cannot find CA certificate`. I tried looking in the state store but I don't see it there. Any advice on whether I missed a step, or if something else is set up incorrectly? `~/.kube/config` does not seem to know about my cluster, but kops does.
Comment: @szeitlin did you run the kops export step? if it exports successfully then you should expect the `~/.kube/config` file to contain information of your cluster
Comment: Yes, I tried to run it, and I get that error saying that it can't find the certificate.
Answer: .kube/config is hardly a "state", it's just a client configuration, so it is possible to just take the content of it (or its part if you have more contexts localy) and use on another machine. That is unless you want to create a dedicated user (key/cert) for CI, in which case you need to create a separate credentials and if you use key/cert they'd need to be for a different certificate "subject" so the users can be recognised as different ones


When is an accumulation point not the limit of some sequence in a topological space?

Question: In a general topological space $(X,\tau)$ we define an accumulation point $x_0$ of a set $A$ to be a point such that any open neighbourhood about $x_0$ intersects $A$.
Now it is certainly true that if a sequence $x_n\in A$ tends to some limit $x \in X$, $x$ must be an accumulation point of $A$ since $x_n$ lies in any open neighbourhood of $x$ for all $n$ sufficiently large, and so lies in the intersection of this open neighbourhood and $A$.
What I would like to know is: Are there any (preferably elementary) examples of a topological space with a subset $A$ that has an accumulation point which is not the limit of any sequence in $A$. I would also appreciate information on any conditions on a space which imply that any accumulation point of $A$ is the limit of some sequence in $A$.
For example, if $X$ is first countable (e.g. any metric space) then it is easy to show that any accumulation point of $A$ must be the limit of some sequence of points in $A$. Intuitively this is because for a given point $x$, we can find a nested sequence of open sets that "get smaller" and can eventually be contained in any open neighbourhood of $x$, so these nested open sets "contract around $x$, allowing us to find such a sequence.
Answer: Here are two examples:

The closed ordinal space $\omega_1 + 1 = [ 0 , \omega_1 ]$ consisting of all countable ordinals as well as the least uncountable ordinal $\omega_1$.  It is easy to see that $\omega_1 \in \overline{[ 0 , \omega_1 )}$, but since any sequence in $[0 , \omega_1 )$ is countable, it has an upper bound $\beta$ which is a countable ordinal, and $( \beta , \omega_1 ]$ is an open neighbourhood of $\omega_1$ disjoint from the sequence.
The Stone–Čech compactification $\beta \mathbb{N}$ of the discrete space $\mathbb{N}$.  This space has the property that there are no non-trivial (i.e., not eventually constant) convergent sequences.  (For quite a bit of basic information about this space see Dan Ma's Topology Blog.)  We have that $\mathbb{N}$ is a dense subset of $\beta \mathbb{N}$, but no sequence in $\mathbb{N}$ can converge outside of $\mathbb{N}$.

(Consider also this previous answer of mine, and possibly also this question and its answers.)

For the interested:
One may be lead to believe that the problem is that sequences are "too short", and that things would change if only we were allowed to use "longer" sequences.  This is almost true.
Definition. A topological space $X$ is called radial if for any $A \subseteq X$ and any $x \in \overline{A}$ there is a transfinite sequence $\langle x_\xi \rangle_{\xi < \alpha}$ (where $\alpha$ is an ordinal) in $A$ which converges to $x$.  (The definition of convergence in this sense is the natural extension of sequential convergence.)
It is not too difficult to show that $\omega_1 +1$ is radial (in fact, we only need to allow sequences of length $\omega_1$ to capture this property).
However $\beta \mathbb{N}$ is not even radial!
Comment: Thank you very much for the (very thorough) answer!
Comment: Hi Arthur, I give another example, which you may be interested in.
Answer:
Another example: An uncountable space $X$ with countable complement (co-countable) topology.

Proof: Pick any point $x\in X$. It is the accumulation point of $A=X\setminus \{x\}$, however it is not the limit point of $A$. Since for any countable subset $S$ of $A$, $U=X\setminus S$ is an open set of $x$, which satisfies that $U \cap S=\emptyset$.
Comment: Help clarify the proof: any sequence in $A$ can be regarded as a countable subset $S$ of $A$. The proof actually says for any countable set $S$ of $A$, there exits an open set $U$ containing $x$ that does not contain any points in  $S$. So no sequence in $A$ converges to $x$.
Answer: Here is a compact Hausdorff example you might consider more friendly.

Let $X$ be the "cube" $[0,1]^{[0,1]}$. That is, the space of all functions $[0,1] \to [0,1]$ in the topology of pointwise convergence. Let $A = \{ f \in X : f \text{ is  continuous, and  } \int_0^1 f(t) \ dt \geq 1/2\}$. Then, the zero function is an accumulation point of $A$ (for every finite set $x_1,\ldots,x_n \in [0,1]$, there is an $f \in A$ which vanishes at all of them). But, there can be no sequence $f_n \in A$ converging pointwise to zero (hint: use the Lebesgue dominated convergence theorem).

One can also cut $[0,1]^{[0,1]}$ down to the subspace of polynomial functions with rational coefficients to get an example where the space $X$

has countably many points
is a Tychonoff space (being a subspace of $[0,1]^{[0,1]}$)
is zero-dimensional in the sense that, whenever $f,g \in X$ are distinct, there is a parition of $X$ into open sets $U,V$ so that $f \in U, g \in V$.

I took this example from a little "mock paper" I wrote for a course once. See Example 4 in http://arxiv.org/abs/1210.1008.
Comment: @JSempliner: OK, I've removed my comment about pointwise convergence, as it was apparently unnecessary. Anyway, I don't understand what you don't like about the example. Do you agree with the following claim? Given any $\epsilon > 0$ and any finite set $\{ x_1, \ldots, x_n\} \subset [0,1]$, there is a polynomial $p(x)$ with rational coefficients such that (1) $0 \leq p(x)\leq 1$ when $x \in [0,1]$, (2) $\int_0^1 p(x) \ dx \geq 1/2$, and (3) $p(x_i) < \epsilon$ for $i=1,\ldots,n$.
Comment: No sorry to give that impression! I was unaware that there were countable spaces that were not Frechet-Urysohn, so it was quite enlightening! It just clashed with my intuition late last night so I wanted to ask about it.
Comment: @JSempliner: I don't mind, I was glad to be reminded of this example. I quite like it.
Answer:
Now it is certainly true that if a sequence $x_n∈A$ tends to some limit $x∈X$, $x$ must be an accumulation point of $A$

Unless the sequence is constant, right?

For example, if X is first countable (e.g. any metric space)

Metric spaces don't need countable space?
Comment: No, my definition of accumulation point allows for (eventually) constant sequences, which would provide a counter-example to the same statement made for limit points. I'm also not sure what you mean by the question "Metric spaces don't need countable space?". Are you saying that metric spaces aren't necessarily countable? I agree with that, but that's not implied by being first countable (which all metric spaces are), so I'm not sure what you're saying...
Comment: @TomOldfield An eventually constant sequence is not evidence for an accumulation point
Comment: I don't understand what you mean. From the definition I gave, any element of $A$ is an accumulation point. So even if the sequence is constant, the limit is still an accumulation point.


Is my Bayesian analysis correct?

Question: This is my first time doing a Bayesian analysis, so I'm not sure whether what I did makes perfect sense. I'm trying to tell if two samples come from the same distribution, more specifically, if they have the same mean.
I have very few samples, and no subjective beliefs about them. I am modelling the observed distribution as a Gaussian. Using pyMC:
import pymc as pm

sample1 = [8.254828927, 8.485694524,10.58058423,5.221356325]
sample2 = [7.921107724, 9.744301571, 5.750874082,8.421883012,11.09813068]

sample_mean = sum(sample1+sample2)

#Empirical prior for the mean
normal_mean_prior = pm.Normal("mean_prior", mu = sample_mean, tau = 1)

#Uninformative prior for the precision
normal_precision_prior = pm.Uniform("precision_prior", lower = 0, upper = 100)

#Normal observation
normal_observation_sample1 = pm.Normal("normal1", mu = normal_mean_prior, tau = normal_precision_prior, observed = True, value = sample1)
normal_observation_sample2 = pm.Normal("normal2", mu = normal_mean_prior, tau = normal_precision_prior, observed = True, value = sample2)

With this model, I would sample it using MCMC and check if the posterior distribution of the means are different or the same.
Is my analysis correct? Have I made any significant blunder? Thank you.
Comment: This line: `sample_mean = sum(sample1+sample2)`. Did you want to divide by sample size?
Comment: Yes, that is what I wanted. Interestingly, the posterior mean was reasonable, close to a frequentist answer, so I couldn't realize there was a mistake until you saw it. (p.s. I love your book, it's what motivated me to start exploring pyMC. Thank you!)
Answer: Your prior on the mean is too narrow.  Also, you don't just want samples for the two means, you want samples of the difference between the means.  The posterior distribution of the difference is what you want to look at.  For more details, see the paper Bayesian estimation supersedes the t test.
Comment: You said that you had no subjective beliefs, which I interpret to mean that you don't want the prior to influence the results.  Choosing tau=1 will definitely influence the results, since the likelihood function for the mean has precision around 1 for both datasets.
Comment: How can I know whether the prior is too narrow or too wide? This was the part I had most difficulty with, so I ended up choosing the precision rather arbitrarily. I'm gonna read Kruschke's paper to understand what I'm doing better, thanks for the link.
Comment: The method BEST discussed in detail in the paper is also one of the exampes for PyMC. Almost as easy as plug in your data and interpret the results. https://pymc-devs.github.io/pymc3/BEST/
Answer: I would say that you have an good start, but your analysis is incomplete.  How did you pick your hyper-parameters?  How will you check if the posterior distribution of the means are the same?  The devil is in the details.
@TomMinka has answered with a reference to a paper by Kruschke that proceeds in the general direction you have been going and fills in the details.  Here is the PyMC implementation of something along those lines (but using the normal instead of t for the likelihood to keep it simple):
def model():
    sample_0 = [8.254828927, 8.485694524, 10.58058423, 5.221356325]
    sample_1 = [7.921107724, 9.744301571, 5.750874082, 8.421883012, 11.09813068]
    pooled_data = np.hstack((sample_0, sample_1))

    # hyper-parameters
    S = 1000 * np.std(pooled_data)
    M = np.mean(pooled_data)

    L = .001 * np.std(pooled_data)
    H = 1000 * np.std(pooled_data)

    # prior
    mu = pm.Normal('mu_1', M, S**-2, value=[M,M])
    sigma = pm.Uniform('sigma_1', L, H, value=[np.std(pooled_data), np.std(pooled_data)])

    # likelihood
    obs_1 = pm.Normal('obs_1', mu=mu[0], tau=sigma[0]**-2, value=sample_0, observed=True)
    obs_2 = pm.Normal('obs_2', mu=mu[1], tau=sigma[1]**-2, value=sample_1, observed=True)

    # derived quantities of interest
    d_mu = mu[0] - mu[1]
    d_sigma = sigma[0] - sigma[1]
    @pm.deterministic
    def effect_size(d_mu=d_mu, sigma=sigma):
        return d_mu / np.sqrt(.5*(sigma[0]**2 + sigma[1]**2))
    @pm.deterministic
    def outside_rope(effect_size=effect_size):
        return -.1 < effect_size < .1

    return locals()

And here is an IPython Notebook to sample from the approximation posterior distribution with MCMC to see that the probability that the two distributions have different means is 0.1.
Comment: @PedroTabacof: I see.  For non-observed stochastics, the `value` parameter is used only as the initial point for MCMC.  It is not necessary to provide it, and if you do not, PyMC will choose an initial value randomly from the stochastic's prior distribution.  Well-chosen initial values can speed convergence.
Comment: I noticed a weird thing about this Kruschke approach, in the absence of data, the posterior probability of `outside_rope` is 2%.  Maybe I made a mistake in my implementation, but if not... is that low?
Comment: In the absence of data, Kruschke's rule for setting the hyperparameters doesn't apply.   So you must have done something different.
Comment: Good point.  I used 0 instead of the mean and 1e-6 instead of the standard deviation.  Here is [the notebook for it](http://nbviewer.ipython.org/gist/aflaxman/ef63d29171b038510187).
Comment: I see a small mistake on the code: "pooled_data = np.hstack((sample_0, sample_0))" is doubling sample_0 and ignoring sample_1. In any case, I don't understand something about your code: Why do you set the values of the prior distributions? Does it influence the posterior sampling? Thank you.
Comment: @PedroTabacof: I've used these values for the prior distribution based on the suggestions of Kruschke from the paper linked above.  I think it influences the posterior a lot when there is little data, but only a little when there is a lot of data.  Thanks for catching that mistake!
Comment: @AbrahamDFlaxman Sorry, I didn't make myself clear. I wasn't talking about the hyper-priors, but about the way you defined the priors using "value=[M,M]" and "value=[np.std(pooled_data), np.std(pooled_data)]". I thought setting the value of a distribution only mattered when it was observed. Could you please explain the reason for this?

Is my Bayesian analysis correct?


What is the meaning of "foo(...arg)" (three dots in a function call)?

Question: Can someone tell what is "..." in the below code in the "Intro to Angular" example?
getHeroes() {
    this.backend.getAll(Hero).then( (heroes: Hero[]) => {
      this.logger.log(`Fetched ${heroes.length} heroes.`);
      this.heroes.push(...heroes); // fill cache
    });

Comment: https://developer.mozilla.org/nl/docs/Web/JavaScript/Reference/Operators/Spread_operator
Answer: This has nothing to do with jQuery or Angular. It's a feature that was introduced in ES2015.
This particular use of ... doesn't actually have an official name. A name that is in line with other uses would be "spread argument" (a generic term would be "spread syntax"). It "explodes" (spreads) an iterable and passes each value as argument to the function. Your example is equivalent to:
this.heroes.push.apply(this.heroes, Array.from(heroes));

Besides being more concise, another advantage of ... here is that it can be more easily used with other concrete arguments:
func(first, second, ...theRest);

// as opposed to the following or something similar:
 func.apply(null, [first, second].concat(Array.from(heroes)));

Answer: It is a JavaScript feature called  Rest Parameters.
By using it your function can take any number of arguments.
You put the three dots just before the argument (without a whitespace character) and the mechanism spreads it for you as if it was a list of several arguments.
In Eloquent Javascript you have a good example of it.
let numbers = [5, 1, 7];
console.log(max(...numbers));
// -> 7

Answer: It's a copy of the original array
let args = [7, 3, 8];
var [h] = args.reverse(); // args is now 8, 3, 7

whereas
var [h] = [...args].reverse(); // args is still 7, 3, 8

It can also be used to specify the remaining values of an array
var [first, ...rest] = args; // first = 7, rest = [3, 8]

Answer: As per the title of the question, the use of ... in a function declaration (within parenthesis) is that of a rest operator or rest parameter,In order to help us create more flexible functions, ES6 introduces the rest parameter for function parameters.
With the rest parameter, you can create functions that take a variable number of arguments. These arguments are stored in an array that can be accessed later from inside the function.
Example: 1
function foo(...args) {
  return "You have passed " + args.length + " arguments.";
}

console.log(foo(0, 1, 2,4)); // You have passed 4 arguments.
console.log(foo("hello", null, [1, 2], { })); // You have passed 4 arguments.

Example 2:
function foo(...args){
     args.forEach(function(arg){
        console.log(arg);
     })
   }

   foo(2,3,4,5,6);

The rest parameter eliminates the need to check the args array and allows us to apply map(), filter(), reduce() and other array Higher Order functions on the parameters array.
OTHER USE CASES OF ... operator :

Used as spread operator which is the reverse of rest operator.
const arr = [6, 89, 3, 45];
const maximum= Math.max(...arr);
console.log(maximum);
... operator is used to copy the array or an object pretty easily and is quite helpful in javascript frameworks and libraries like angular and react respectively.
const arr1 = [1,2,3,4];
const arr2 = [...arr1];
console.log(arr2);//  [1,2,3,4];

const obj1 = {
  name:'john',
  age:25
}

const obj2 = {...obj1};
console.log(obj2); // Now obj2 is new object and is copy of obj1 (non-mutated
way)


java spring boot Entity constructor with arguments does not execute

Question: i do not understand why an Entity no argument constructor is being called when providing a request body? if i delete it and the only constructor that exist is the one that receive arguments, i get the expected output print, but i must implement a no argument constructor in order to save the Entity in the database.
this is the request body:
<code>{
"str": "stringgg",
"intt": 2,
"doublee": 1.003
}
</code>
this is the route: when commenting out the empty constructor, the values of the new instance match the request json body
<code>@PostMapping("/save")
public List<Modell> obj(@RequestBody Modell model) {
    modelRepository.save(model);
    System.out.println(model.toString());
    return modelRepository.findAll();
}
</code>
this is the entity class:
<code>@Table(name = "modelltbl")
@Entity
public class Modell {

    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE)
    @Column(name = "id", nullable = false)
    private long id;

    @Column(name = "str", nullable = true)
    private String str;

    @Column(name = "intt", nullable = true)
    private int intt;

    @Column(name = "doublee", nullable = true)
    private double doublee;

    public Modell(String str, int intt, double doublee)
    {
        this.str = str;
        this.intt = intt;
        this.doublee = doublee;
    }
    public Modell(){}

    @Override
    public String toString()
    {
        return String.format("model class,params: %s , %o , %f ", str , intt, doublee);
    }
}
</code>
Comment: Do not use entities iat controller level. It is bad application Design
Comment: @Jens can you please explain more?
Comment: read about 3tier architecture. The explanation is to long for SO
Answer: First of all: Do not use entities iat controller level. It is bad application Design.
The json will be converted throug jackson library which creates the object by calling the default constructor and the setter of the properties. If you do not want this behavior you can use the <code>@JsonCreator</code> annotation.
<code>@JsonCreator
public Modell(@JsonProperty("str")String str, @JsonProperty("intt")int intt, @JsonProperty("doublee")double doublee)
{
    this.str = str;
    this.intt = intt;
    this.doublee = doublee;
}
</code>


Change Text of Create an Account in Login Block

Question: I want to change text of Create an account to

something>
Click here

When I print the form I got these values
[links] => Array
        (
            [#markup] =>

Create new account

Forgot your password?

        )

Also, I gave a try in settings.php like
$conf['locale_custom_strings_en'][''] = array(
  '"Create a new user account' => '
somethifn>
Click here',
);

But this prints as a text.
Anybody can help?
Comment: why you dont try achieve it with jquery ?
Comment: Can you give the debug code of the form? (how you debug it? you say that the code is in settings.php??)
Comment: As I understand you don't try to edit the login form, but the tab-menu of the login form.
Comment: Hint: The string you are trying to replace is `"Create a new user account`, but Drupal uses `Create a new user account`.
Answer: The above mentioned problem can be easily solved by using hook_form_alter hook_form_alterhook_form_alter(&$form, &$form_state, $form_id) . You can use that function in our template.php of your custom theme .
In template.php write..
function custom_theme_form_alter(&$form, &$form_state, $form_id){
  if( $form['form_id']['#value'] === 'user_register_form'){// For registration form on 'user/register' page
    $form['actions']['submit']['#prefix'] = '
';
    $form['actions']['submit']['#value'] = '--your text--';
    $form['actions']['submit']['#suffix'] = '
';
  }
  if( $form['#id'] === 'user-login-form' ){  // For login block that comes with drupal core blocks and can be assigned to any region.
    $form['links']['#markup'] = '

--your text--

Request new password

';
  }
}

This will change your text from 'Create a new account' to your custom text. And don't forget to clear the cache :).
Reply on this thread if you still find some problem.
Answer: So lets assume you want to alter the tab-menu of the /user page.
First the dpm() doesn't work because you are logged out.
Then you must create a module, but if you are too lazy paste the code on the template.php of your theme and rename module with your theme's name.
Then debug the menu:
function module_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  debug($data);
}

After you find the title you want to edit your function:
function module_menu_local_tasks_alter(&$data, $router_item, $root_path) {
  // The path of the array
  debug($data['tabs'][0]['output'][0]['#link']['title']);
  // Edit the actual array value
  $data['tabs'][0]['output'][0]['#link']['title'] = "My new title";
}

If you want to edit something in the login form:
function module_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'user_login') {
    debug($form);
  }
}

Answer: I have solved the same problem with just two lines at the top in my page.tpl.php file,
<?php if($title == 'Create an account'):$title='whatever title you want';endif;  ?>

You can also include html tags to modify the title.
Thank you.
Comment: The user doesn't want to change any page title, but the text shown for a link.
Comment: Then it will be better to use l().
As mentioned here :
https://api.drupal.org/comment/13259#comment-13259


Mysql - Get average of time diff between 2 tables

Question: I have these 2 tables :
customer
  id
  name
  created_at

and :
action
  id
  customer_id
  type
  created_at

I want to have the average time difference between customer.created_at and action.created_at, where action.type = "call0" and action is the first entry (action may have many type = "call0")
For now, I have this query :
SELECT AVG(TIME_TO_SEC(timediff(action.created_at, customer.created_at)) / 60) AS diff
    FROM action
     WHERE action.type = "call0"
    JOIN customer ON action.customer_id = customer.id
    GROUP BY customer.id
    ORDER BY action.created_at ASC

Dunno why, this query returns me several rows - each for action entry.
How can I return the whole average calculation ?
Answer: if you want the total result  then don't group by for   customer.id
  SELECT AVG(TIME_TO_SEC(timediff(action.created_at, customer.created_at)) / 60) AS diff
    FROM action
    JOIN customer ON action.customer_id = customer.id
    WHERE action.type = "call0"

otherwise  if you want the avg for each customer.id the  try show also the corresponding customer.id
SELECT customer.id, AVG(TIME_TO_SEC(timediff(action.created_at, customer.created_at)) /60) AS diff
  FROM action
 JOIN customer ON action.customer_id = customer.id
  WHERE action.type = "call0"
  GROUP BY customer.id
  ORDER BY action.created_at ASC


Como fazer o Filter após apertar alguma tecla do teclado, o ENTER por exemplo

Question: Existe alguma forma de fazer o filtro do registro a partir do enter, não em tempo de execução como é de costume do Angular?
Answer: Você pode implementar uma diretiva:
angular.module('meuApp').directive('ngEnter', function () {
    return function (scope, element, attrs) {
        element.bind("keydown keypress", function (event) {
            if (event.which === 13) {
                scope.$apply(function () {
                    scope.$eval(attrs.ngEnter);
                });

                event.preventDefault();
            }
        });
    };
});

Você pode então utilizar o adereço ng-enter em um controle:
<input type="text" name="Procura" placeholder="Procura" ng-model="Termos" ng-enter="Procura()">

Comment: agradeço muito, me ajudou bastante. obrigado mesmo


Sort array and return an array of indicies that indicates the position of the sorted elements with respect to the original elements (new)

Question: I have this array
test = [3, 2, 2, 1];

I want to be able to get this array
result = [3, 1, 2, 0]

The idea is the same as: Javascript: Sort array and return an array of indicies that indicates the position of the sorted elements with respect to the original elements
but incrementing the position value every time there is two elements on "test" with the same value.
Comment: What have you tried so far? Please post your code and explain what didn't work, with a live demo if possible to reproduce the problem.
Comment: I didn't try nothing but the solution proposed by @Dave Aaron Smith on the linked post. From that I get an array: [1,2,2,3]...
Answer: You can pass a comparison function to sort:
var test = [3, 2, 2, 1];

var result = [];
for(var i = 0; i != test.length; ++i) result[i] = i;
result = result.sort(function(u,v) { return test[u] - test[v]; })
console.log(result) // [ 3, 1, 2, 0 ]

Comment: just perfect! Well done!
Comment: Well... there is a problem with this solution... http://jsfiddle.net/WQYKd/


eliminate cache in iframes

Question: I have a financial system where I create pdf forms for tax forms, receipts and etc
I have a printing page where I open the document for the client in an iframe
which suits dynamically the src to the client's pdf -
curUser = usrSrv.getUserFromCookie(cookie);
string formSrc = "UserForms/" + curUser.Id + ".pdf";
ifPdf.Attributes.Add("src", formSrc);

iI my code behind I've inserted the clear cache properties as such:
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();

but still - in several cases (when the user goes back from the print page for ex') - the pdf file is being saved in the cache and the system is losing its purpose.
I've figured out there might be a way with - server.Mappath() - but when I use it - the location seems fine and the file exists but the browser never finds the actual file or simply don't show it.
Answer: If you add a querystring parameter to the end of the frame's URL you will get the result you need, as long as the parameter is generated fresh and unique every time. A common way of doing that is to add something like a timestamp:
url += "?ts=" + DateTime.Ticks;

or:
url += "?ts=" + Date.getTime();

Comment: i was actually realy sorpriesd cause i never figuerd out i can add this stamps on files ( i was allways sure it changes the file mark ) any how - works like a charm tnks!

eliminate cache in iframes