Show that $\int_0^\infty \frac{x\log(1+x^2)}{e^{2\pi x}+1}dx=\frac{19}{24} - \frac{23}{24}\log 2 - \frac12\log A$

Question: Any idea on how to prove the following integral
$$\int_{0}^{\infty} {x\log(1+x^2)\over e^{2\pi x}+1}dx =\require{cancel} \cancel{\frac{17}{24} - \frac{23}{24}\log 2 + \frac{1}{2}\log A}={\frac{19}{24} - \frac{23}{24}\log 2 - \frac{1}{2}\log A }$$
Where $A$ is the Glaisher–Kinkelin constant.
We define
$$A= \lim_{n \to \infty}\frac{H(n)}{n^{n^2/2+n/2+1/12}e^{-n^2/4}}$$
Where $$H(n) = \prod^{n}_{k=1} k^k $$
I would start by
$$F(z) = \int^\infty_0 \frac{2xz}{(x^2+z^2)(e^{2\pi x}+1)} \, dx$$
I know that
$$\frac{2t}{e^{2\pi t}-1} =\frac{1}{\pi}-t+\frac{2t^2}{\pi}\sum_{k=1}^\infty\frac{1}{k^2+t^2} $$
But I can't find a similar one for
$$\frac{1}{e^{2\pi t}+1}$$
Comment: Do you know complex function theory with the method of integration by residues ?
Comment: @JeanMarie, Yes.
Comment: Thus, what is the function $f(z)$ you choose, which contour do you take ? Then its poles are... its residues in these poles are, etc.
Comment: @JeanMarie, not sure what function and contour to choose.
Comment: @ZaidAlyafeai: If Claude Leibovici's comment is correct, it seems that you also have to change a sign in your post (in front of $\frac 1 2 \ln A$).
Comment: @AlexM,  I checked it in W|A. It should be positive.
Comment: What are the usual integration contours when you have these bounds ?
Comment: @JeanMarie, The function $\log(1+x^2)$ has a branch cut on the imaginary axis. So I am not sure usual contours will work.
Comment: Good answer for the branch cut (which can be brought back on the real axis by changing $z$ into $iz$, i.e., integrating $f(z)=log(1-z^2)/(1+e^{i \pi z})$ Besides, you know you must enclose poles. It is clear that you have an infinite number of poles. Maybe their residues sum up into a series involved in the result...
Comment: the simple algebraic identity $\frac{1}{e^x+1}=\frac{1}{e^x-1}-\frac{2}{e^{2x}-1}$ might be of some help here
Comment: why on earth we have $4$ close votes here?
Comment: @tired, please read the comments under M.N.C.E. answer.
Comment: Woow it got closed, Thanks .
Comment: problem solved...
Comment: maybe i can add a proof using abel plana later on...let's see
Answer: Contour Integration
Integrate $\frac{z\log{z}}{e^{2\pi z}+1}$ along a rectangular contour with a quarter-circle indent around $0$ and with vertices $0$, $R$, $R+i$ and $i$. Taking limits, one can check that the contributions from the line segment $[R,R+i]$ and the indent tend to zero. By the Residue Theorem,
$$\operatorname{Re}\pi i \operatorname*{Res}_{z=\frac{i}{2}}\frac{z\log{z}}{e^{2\pi i z}+1}=\operatorname{Re}\left\{\int^\infty_0\frac{x\log{x}-(x+i)\log(x+i)}{e^{2\pi x}+1}\ dx+PV\int^1_0\frac{y\log(iy)e^{-\pi iy}}{2\cos(\pi y)}dy\right\}$$
Simplifying this,
\begin{align}
-\frac{\log{2}}{4}
&=\color{red}{\int^\infty_0\frac{x\log{x}}{e^{2\pi x}+1}\ dx}-\frac{1}{2}\int^\infty_0\frac{x\log(1+x^2)}{e^{2\pi x}+1}\ dx+\color{blue}{\int^\infty_0\frac{\arctan\left(\frac{1}{x}\right)}{e^{2\pi x}+1}\ dx}\\
&\ \ \ \ \ +\color{green}{\frac{1}{2}\int^1_0x\log{x}\ dx}+\color{purple}{\frac{\pi}{4}PV\int^1_0x\tan(\pi x)\ dx}
\end{align}
Let us evaluate these integrals individually.

The Red Integral
We have
\begin{align}
\int^\infty_0\frac{x\log{x}}{e^{2\pi x}+1}\ dx
&=\int^\infty_0\frac{x\log{x}}{e^{2\pi x}-1}\ dx-2\int^\infty_0\frac{x\log{x}}{e^{4\pi x}-1}\ dx\\
&=\frac{1}{4}\int^\infty_0\frac{x\log\left(\frac{x}{2}\right)}{e^{\pi x}-1}\ dx-\frac{1}{8}\int^\infty_0\frac{x\log\left(\frac{x}{4}\right)}{e^{\pi x}-1}\ dx\\
&=\frac{1}{8}\int^\infty_0\frac{x\log{x}}{e^{\pi x}-1}\ dx\\
&=\frac{1}{8}\left.\frac{d}{ds}\int^\infty_0\frac{x^{s-1}}{e^{\pi x}-1}\ dx\right|_{s=2}\\
&=\frac{1}{8}\left.\frac{d}{ds}\sum^\infty_{n=0}\int^\infty_0 x^{s-1}e^{-\pi(n+1)x}\ dx\right|_{s=2}\\
&=\frac{1}{8}\left.\frac{d}{ds}\sum^\infty_{n=0}\frac{\Gamma(s)}{\pi^{s}(n+1)^{s}}\right|_{s=2}\\
&=\frac{1}{8}\left.\frac{d}{ds}\pi^{-s}\Gamma(s)\zeta(s)\right|_{s=2}\\
&=\left.\frac{d}{ds}\frac{2^{s-4}\zeta(1-s)}{\cos\left(\frac{\pi s}{2}\right)}\right|_{s=2}\\
&=\left.\frac{2^{s-4}\left[-\zeta'(1-s)+\zeta(1-s)\left(\log{2}+\frac{\pi}{2}\tan\left(\frac{\pi s}{2}\right)\right)\right]}{\cos\left(\frac{\pi s}{2}\right)}\right|_{s=2}\\
&=\color{red}{\frac{\zeta'(-1)}{4}+\frac{\log{2}}{48}}
\end{align}

The Blue Integral
Integrate $\frac{\log{z}}{e^{2\pi z}+1}$ along the same contour as we did for the integral in question. This yields
$$\operatorname{Im}\pi i \operatorname*{Res}_{z=\frac{i}{2}}\frac{\log{z}}{e^{2\pi z}+1}=\operatorname{Im}\left\{\int^\infty_0\frac{\log{x}-\log(x+i)}{e^{2\pi x}+1}\ dx-i\ PV\int^1_0\frac{\log(iy)e^{-\pi iy}}{2\cos(\pi y)}dy\right\}$$
Simplifying,
\begin{align}
\int^\infty_0\frac{\arctan\left(\frac1x\right)}{e^{2\pi x}+1}\ dx
&=-\frac{\log 2}{2}-\frac{1}{2}\int^1_0\log x\ dx-\frac{\pi}{4}PV\int^1_0\tan(\pi x)\ dx\\
&=-\frac{\log 2}{2}-\frac{1}{2}\left[x\log{x}-x\right]^1_0-\frac{\pi}{4}(0)\\
&=\color{blue}{-\frac{\log 2}{2}+\frac{1}{2}}
\end{align}

The Green Integral
This is elementary. Integrate by parts once to get
$$\frac{1}{2}\int^1_0x\log{x}\ dx=\frac{1}{2}\left[\frac{x^2}{2}\log{x}-\frac{x^2}{4}\right]^1_0=\color{green}{-\frac{1}{8}}$$

The Purple Integral
Splitting the limits of integration,
\begin{align}
\frac{\pi}{4}PV\int^1_0x\tan(\pi x)\ dx
&=\frac{\pi}{4}\lim_{\epsilon\to0}\left[\left(\int^{\frac{1}{2}-\epsilon}_0+\int^1_{\frac{1}{2}+\epsilon}\right)x\tan(\pi x)\ dx\right]\\
&=\frac{\pi}{4}\lim_{\epsilon\to0}\left[\int^{\frac{1}{2}-\epsilon}_0x\tan(\pi x)\ dx-\int^{\frac{1}{2}-\epsilon}_0(1-x)\tan(\pi x)\ dx\right]\\
&=\frac{\pi}{4}\int^\frac{1}{2}_0(2x-1)\tan(\pi x)\ dx\\
&=\frac{1}{2}\int^\frac{1}{2}_0\ln(\cos(\pi x))\ dx\\
&=\color{purple}{-\frac{\log{2}}{4}}
\end{align}
where the last step follows from a classic result.

The Final Result
Therefore, we conclude that
\begin{align}
\int^\infty_0\frac{x\log(1+x^2)}{e^{2\pi x}+1}\ dx
&=2\left(\frac{\log{2}}{4}+\color{red}{\frac{\zeta'(-1)}{4}+\frac{\log 2}{48}}\color{blue}{-\frac{\log{2}}{2}+\frac12}\color{green}{-\frac{1}{8}}\color{purple}{-\frac{\log{2}}{4}}\right)\\
&=\frac{\zeta'(-1)}{2}-\frac{23}{24}\log{2}+\frac{3}{4}\approx0.00302338011316028053\cdots
\end{align}

$\textbf{Note:}$ As pointed out by @Sangchul Lee, there was originally a discrepancy between the value in my answer and that provided in the question due to a computational fault in WolframAlpha / Mathematica. The value given in the question has now been corrected.
Comment: @ZaidAlyafeai, I have no idea why the symbolic computation failed in Mathematica (which presumably uses the same kernel as in WolframAlpha). Probably the programmers in Wolfram Research know the reason. My guess is that they made a sign mistake when they punched the integral table into the software. At least numerical computation matches M.N.C.E.'s answer.
Comment: (+1) Wonderful solution. A little remark: the blue integral can be computed from Binet's second log-Gamma formula, too.
Comment: Your answer equals $\frac{19}{24} - \frac{23}{24}\log 2 - \frac{1}{2}\log A$, which also matched the numerical result up to 100 digits using Mathematica 11. Since Mathematica 11 shares the same symbolic computation issue you pointed out, I will going to report this error. I guess that this is a sign mistake since the erroneous answer given by Mathematica is exactly the same as $$\frac{17}{24} - \frac{23}{24}\log 2 + \frac{1}{2}\log A = \text{[correct answer]} - \zeta'(-1).$$
Comment: @M.N.C.E. I edited my question to indicate the answer given by SangchulLee.
Comment: @SangchulLee, I initially put the answer you suggested in the question but I got 3 downvotes and 4 reports to close the question because someone (who deleted his comment by now) said it was wrong. Then I had to change the result to that of W|A.
Comment: @Sangchul Lee Thanks for your confirmation!
Comment: @ZaidAlyafeai, That is too bad since I see nothing wrong with your question. I upvoted your question. I am also writing down my real-analysis solution. I hope this also improves this situation.
Comment: @SangchulLee, I hope you explain in more details what went wrong in numeric solution of the integral in your coming answer. Or you can add a separate answer for that.
Comment: I have a question, the contour will pass through the pole at $i/2$ ?
Comment: @ZaidAlyafeai Yes it will. The contribution from that pole is $\pi i$ multiplied by the residue at $z=i/2$.
Comment: To be more precise the segment of the contour connecting $i$ to $0$ is actually the limit of
$$\color{red}{[i,\tfrac{i}{2}+i\epsilon]}\cup \tfrac{i}{2}+\epsilon e^{i[\pi/2, -\pi/2]}\cup \color{red}{[\tfrac{i}{2}-i\epsilon,0]}$$
As $\epsilon\to 0$ the red parts contribute the principal-value integral while the middle one contributes as $\pi i \times \text{residue at } i/2$.
Comment: @M.N.C.E. Yeah I forgot about that theorem.
Answer: The following approach uses the Abel-Plana formula, which was mentioned in a comment by the user tired.
By applying the Abel-Plana formula to $f(\frac{x}{2})$ and then subtracting the result from the Abel-Plana formula applied to $f(x)$, we get $$\begin{align} &\sum_{n=0}^{\infty} f(n) - \sum_{n=0}^{\infty} f \left(\frac{n}{2} \right) \\ &= \int_{0}^{\infty} f(x) \, dx - \int_{0}^{\infty} f \left(\frac{x}{2} \right) \, dx + i \int_{0}^{\infty} \frac{f(ix) - f(-ix)}{e^{2 \pi x}-1} \, dx -  i \int_{0}^{\infty} \frac{f\left(i \frac{x}{2}\right) - f\left(-i\frac{x}{2}\right)}{e^{2 \pi x}-1} \, dx \\ &= \int_{0}^{\infty} f(x) \, dx - 2 \int_{0}^{\infty} f(u) \, du + i \int_{0}^{\infty} \frac{f(ix) - f(-ix)}{e^{2 \pi x}-1} \, dx - 2 i \int_{0}^{\infty} \frac{f(iu) - f(-iu)}{e^{4 \pi u}-1} \, du  \\ &= -\int_{0}^{\infty} f(x) \,  dx + i \int_{0}^{\infty} \frac{f(ix) - f(-ix)}{e^{2 \pi x}+1} \, dx. \end{align} $$
Let's apply the above formula to the function $$ f(x)= \frac{1}{(1+x)^{s}}  , \quad \text{Re}(s) >1.$$
Doing so, we get $$\sum_{n=0}^{\infty} \frac{1}{(1+n)^{s}} - 2^{s} \sum_{n=0}^{\infty}\frac{1}{(2+n)^{s}} = \frac{1}{1-s} + 2 \int_{0}^{\infty} \frac{\sin \left(s \arctan x \right)}{(1+x^{2})^{s/2}(e^{2 \pi x}+1)} \, dx,$$ which implies that
$$2 \int_{0}^{\infty} \frac{\sin \left(s \arctan x \right)}{(1+x^{2})^{s/2}(e^{2 \pi x}+1)} \, dx =  (1-2^{s}) \zeta(s) + 2^{s} + \frac{1}{s-1}. \tag{1}$$
By analytic continuation, $(1)$ should hold for all complex values of $s$. (For $s=1$, the right side of the equation should be treated as a limit.)
Now if we differentiate under the integral sign and then let $s=-1$, we get
$$\int_{0}^{\infty} \frac{x \log(1+x^{2})}{e^{2 \pi x}+1} \, dx + 2 \int_{0}^{\infty} \frac{\arctan x}{e^{2 \pi x}+1} \, dx = - \frac{\log 2}{2} \underbrace{\zeta(-1)}_{- \frac{1}{12}}+\frac{\zeta'(-1)}{2} + \frac{\log 2}{2}-\frac{1}{4}. $$
But using Binet's second formula for the log gamma function, we have $$ \begin{align} 2 \int_{0}^{\infty} \frac{\arctan x}{e^{2 \pi x}+1} \, dx &= 2 \int_{0}^{\infty} \frac{\arctan x}{e^{2 \pi x}-1} \, dx - 4 \int_{0}^{\infty} \frac{\arctan x}{e^{4 \pi x}-1} \, dx \\ &=2 \int_{0}^{\infty} \frac{\arctan x}{e^{2 \pi x}-1} \, dx -2 \int_{0}^{\infty} \frac{\arctan \left(\frac{u}{2}\right)}{e^{2 \pi u}-1} \, du \\ &= 1- \frac{\log (2 \pi)}{2} + \frac{3}{2} \log 2 -2 + \frac{\log(2 \pi)}{2}  \\ &= \frac{3 \log 2}{2} -1 .\end{align}$$
Therefore, $$ \begin{align}\int_{0}^{\infty} \frac{x \log(1+x^{2})}{e^{2 \pi x}+1} \, dx &= \frac{\log 2}{24} + \frac{\zeta'(-1)}{2} + \frac{\log 2}{2} - \frac{1}{4} + 1 - \frac{3 \log 2}{2} \\ &= \frac{\zeta'(-1)}{2} - \frac{23}{24} \log 2 + \frac{3}{4}. \end{align}$$
Comment: @tired Thanks for the upvote.
Comment: Very nice, this is what i had in mind (+1)
Comment: @FShrike $$\begin{align} \frac{2}{e^{2 \pi x}-1} - \frac{4}{e^{4 \pi x}-1} &= \frac{2}{e^{2 \pi x}-1}- \frac{4}{(e^{2 \pi x}-1)(e^{2 \pi x}+1)} \\ &= \frac{2 e^{2 \pi x}-2}{(e^{2 \pi x}-1)(e^{2 \pi x}+1)} \\ &= \frac{2}{e^{2 \pi x}+1} \end{align}$$
Comment: Hey RV , I should've thought of that.
Comment: In the post I recently "answered", where you left the link to this answer, I struggled with that arctangent integral greatly. I knew it was very close to the Binet formula but I couldn't apply it; I'm reading your answer now, and I don't understand your decomposition of the $e^{2\pi x}+1$ into $e^{2\pi x}-1,e^{4\pi x}-1$. What's the presumably simple substitution in missing?
Answer: Here is another method which is a mixture of both real-analysis technique and complex-analysis technique (without contour integration). The main idea is similar to my previous answer.
Let $I$ denote the integral and we write
$$ I = \sum_{n=1}^{\infty} (-1)^{n-1} \int_{0}^{\infty} x \log(1+x^2) e^{-2\pi n x} \, dx. $$
In order to proceed, we claim the following:
$$ \int_{0}^{\infty} x \log(1+x^2)e^{-sx} \, dx
= \frac{2}{s^2} - \frac{2}{s} \int_{0}^{\infty} \frac{\sin(st)}{t+1} \, dt + \frac{2}{s^2} \int_{0}^{\infty} \frac{\cos(st)}{t+1} \, dt. \tag{1} $$
We postpone the proof to the end and discuss the consequence of $\text{(1)}$. Substituting $s = 2\pi n$ and plugging back, $I$ can be simplified as
\begin{align*}
I
&= \sum_{n=1}^{\infty} (-1)^{n-1} \left( \frac{1}{2\pi^2 n^2} - \frac{1}{\pi n} \int_{0}^{\infty} \frac{\sin(2\pi n t)}{t+1} \, dt + \frac{1}{2\pi^2 n^2} \int_{0}^{\infty} \frac{\cos(2\pi n t)}{t+1} \, dt \right) \\
&= \frac{1}{24} - \int_{0}^{\infty} \left( \sum_{n=1}^{\infty} (-1)^{n-1} \frac{\sin(2\pi n t)}{\pi n} \right) \, \frac{dt}{t+1} + \int_{0}^{\infty} \left( \sum_{n=1}^{\infty}(-1)^{n-1} \frac{\cos(2\pi n t)}{2\pi^2 n^2} \right) \, \frac{dt}{t+1}
\end{align*}
Then utilizing the Fourier series of the periodic Bernoulli polynomials $\tilde{B}_n$
$$ \sum_{n=1}^{\infty} \frac{\sin(2\pi n x)}{\pi n} = -\tilde{B}_1(x), \qquad
\sum_{n=1}^{\infty} \frac{\cos(2\pi n x)}{\pi^2 n^2} = \tilde{B}_2(x), $$
it follows that

$$ I = \frac{1}{24} - \int_{0}^{\infty} \frac{\tilde{B}_1(t + \frac{1}{2})}{t+1} \, dt - \frac{1}{2}\int_{0}^{\infty} \frac{\tilde{B}_2(t + \frac{1}{2})}{t+1} \, dt. $$

Next, we introduce the following function
$$f(s) = 2^s - (2^s - 1)\zeta(s) + \frac{1}{s-1}.$$
This is an entire function on $\Bbb{C}$ since all the poles are cancelled out. Then we claim that for $\Re(s) > 0$,
\begin{align*}
\int_{0}^{\infty} \frac{\tilde{B}_1(t + \frac{1}{2})}{(t+1)^s} \, dt
&= \frac{f(s-1)}{s-1}, \tag{2} \\
\int_{0}^{\infty} \frac{\tilde{B}_2(t + \frac{1}{2})}{(t+1)^s} \, dt
&= \frac{2f(s-2)}{(s-1)(s-2)} - \frac{1}{12}\frac{1}{s-1}. \tag{3}
\end{align*}
We also postpone the proof to the end. Assuming this, we have
\begin{align*}
\int_{0}^{\infty} \frac{\tilde{B}_1(t + \frac{1}{2})}{t+1} \, dt
&= \lim_{s\to 1} \frac{f(s-1)}{s-1} = \frac{3}{2}\log 2 - 1, \\
\int_{0}^{\infty} \frac{\tilde{B}_2(t + \frac{1}{2})}{t+1} \, dt
&= \lim_{s\to 1} \left(\frac{2f(s-2)}{(s-1)(s-2)} - \frac{1}{12}\frac{1}{s-1}\right) = \frac{7}{12} - \frac{13}{12}\log 2 - \zeta'(-1).
\end{align*}
Plugging this back yields the same answer as M.N.C.E.'s:

$$ I = \frac{3}{4} - \frac{23}{24}\log 2 + \frac{1}{2}\zeta'(-1). $$

Proof of $\text{(1)}$. By the integration by parts, for $s > 0$ we have
\begin{align*}
\int_{0}^{\infty} x \log(1+x^2)e^{-sx} \, dx
&= \int_{0}^{\infty} \frac{2x(sx+1)}{s^2(x^2+1)} e^{-sx} \, dx \\
&= \int_{0}^{\infty} \frac{2u(u+1)}{s^2(u^2 + s^2)}e^{-u} \, du \qquad (u = sx) \\
&= \int_{0}^{\infty} \left( \frac{2}{s^2} - \frac{2}{u^2+s^2} + \frac{2u}{s^2(u^2 + s^2)} \right) e^{-u} \, du.
\end{align*}
In order to compute the last integral, we notice that
$$ \int_{0}^{\infty} \frac{e^{-u}}{u - is} \, du
= \int_{0}^{\infty}\int_{0}^{\infty} e^{ist} e^{-ut} e^{-u} \, dt du
= \int_{0}^{\infty} \frac{e^{ist}}{t+1} \, dt. $$
In fact, this is more of a heuristics than a rigorous computation, since the Fubini's theorem does not apply directly. One can regularize both sides by replacing $s$ by $s - i\epsilon$ for $\epsilon > 0$, applying Fubini's theorem to prove the corresponding equailty, and then letting $\epsilon \to 0^+$ to establish this. (Alternatively, this can be also thought as a $\frac{\pi}{2}$-rotation of the contour.) Then the claim follows by utilizing this equality. ////

Proof of $\text{(2)}$ and $\text{(3)}$. We first prove the following identity
$$ \int_{0}^{\infty} \frac{1}{(t+1)^s} \, d\tilde{B}_1(t+\tfrac{1}{2}) = f(s), \qquad \Re(s) > 0. $$
By integration by parts, it is not hard to check that the left-hand side defines a holomorphic function for $\Re(s) > 0$. In view of the principle of analytic continuation, it suffices to prove the identity for $\Re(s) > 1$. Then
\begin{align*}
\int_{0}^{\infty} \frac{1}{(t+1)^s} \, d\tilde{B}_1(t+\tfrac{1}{2})
&= \int_{0}^{\infty} \frac{1}{(t+1)^s} \, d(t - \lfloor t+\tfrac{1}{2}\rfloor) \\
&= \frac{1}{s-1} - \sum_{k=0}^{\infty} \frac{1}{(k+\frac{3}{2})^s}.
\end{align*}
It is easy to check that this coincides with $f(s)$. Now both $\text{(2)}$ and $\text{(3)}$ follows easily. Again, both define holomorphic functions on $\Re(s) > 0$ and the principle of analytic continuation allows us to prove both identities only when $\Re(s)$ is large. Then the claim follows from the following identity:
\begin{align*}
\int_{0}^{\infty} \frac{\tilde{B}_n(t + \frac{1}{2})}{(t+1)^s} \, dt
&= \frac{B_n(\frac{1}{2})}{s-1} + \frac{1}{s-1} \int_{0}^{\infty} \frac{1}{(t+1)^{s-1}} \, d\tilde{B}_n(t + \tfrac{1}{2}) \tag{$n \geq 1$} \\
&= \frac{B_n(\frac{1}{2})}{s-1} + \frac{n}{s-1} \int_{0}^{\infty} \frac{\tilde{B}_{n-1}(t + \frac{1}{2})}{(t+1)^{s-1}} \, dt \tag{$n \geq 2$}
\end{align*}
Comment: Don't tell me you have changed ur username ?
Comment: @ZaidAlyafeai Who changed their username?


How can I read line by line an HTML file and return document.write() for each line with Javascript?

Question: I have 3 files: index.html, header.js and footer.js.
I wonder if I can use just one JS script to read line by line the HTML files header.html and footer.html (files instead of header.js and footer.js) and return for each line of the file the document.write('line content');?
Instead of having header.js and footer.js I want to have header.html and footer.html and one JS file for transforming the HTML into JS file: header.html transformed into header.js.
index.html
<!DOCTYPE html>

    <link rel="stylesheet" type="text/css" href="style.css">

Title

Substitle

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

header.js
document.write('');
document.write('
HEADER
');
document.write('');

footer.js
document.write('');
document.write('
FOOTER
');
document.write('');

At the end the index.html will look like this:
index.html
<!DOCTYPE html>

    <link rel="stylesheet" type="text/css" href="style.css">

Title

Substitle

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

The rest of the files will look like this:
header.html

HEADER

footer.html

FOOTER

Comment: Please explain WHY - what is the actual reason for this? jQuery can easily grab content and insert on a page if the content comes from the same site as the page you want to assemble it on
Answer: Please explain WHY youneed document.write - what is the actual reason for this? jQuery can easily grab content and insert on a page if the content comes from the same site as the page you want to assemble it on
For example
$(function() {
  var $body = $("body");
  $.get("header.html",function(data) {
    $body.prepend(data);
  });
  $.get("footer.html",function(data) {
    $body.append(data);
  });
});

that would make your page look like this
<!DOCTYPE html>

    <link rel="stylesheet" type="text/css" href="style.css">

Title

Substitle

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

where include.js looks like what I posted above

If you do NOT want to use jQuery, you will need to ajax the pages in, convert your pages on the server using for example PHP or use iFrames to hold them

Example without frameworks:
DEMO
<!DOCTYPE HTML>

<title>Test header footer insertion without jQuery</title>

Here is some content

Comment: There is another method instead of using jQuery? I know it is stupid, but there is no reason not to use jQuery, this is very powerful tool, but the specification of the application exclude any form of framework. :(
Comment: I found this answer:

var txtFile=new XMLHttpRequest();
txtFile.open("GET", "http://localhost/header.txt", true);
txtFile.onreadystatechange = function()
{
  if (txtFile.readyState === 4) {  // document is ready to parse.
    if (txtFile.status === 200) {  // file is found
      allText = txtFile.responseText;
      lines = txtFile.responseText.split("\n");
    } else alert('File is NOT found!');
  } else alert('Document is NOT ready to parse!');
}
txtFile.send(null);
document.write(txtFile.readyState);

, but it return the msg. "Doc..." and the value 1 for readyState.
Comment: readyState=1 means uninitialized
http://www.w3schools.com/jsref/prop_doc_readystate.asp
Comment: I recommend not to pay too much attention to w3schools. viz http://w3fools.com/ the example you found is simila to what I gave you at the end of my question - difference is that you do NOT need to read line by line, just insert the resulting html


Using Json Schema Validator sample code from NewtonSoft and getting a 400 Bad Request

Question: So I'm trying to wrap my head around writing an API for work and one portion of it is validating incoming JSON against a schema. I have created a simple schema as POC in order to get this API up and running. I am using NewtonSoft.Json.Schema as this seems to be the best way to achieve what I'm after, and I can't stress this enough, there is free sample code!
This is my sample schema, with sample json, showing that it validates.
https://www.jsonschemavalidator.net/s/jldyV4ng
In the sample code, a class ValidRequest is used and this contains the text of the schema and json, so I've attempted to leverage that code as-is.
Invoke-RestMethod -Method Post -Uri https://localhost:44392/api/jsonschema/validate -Body ('{"Schema":"https://gist.githubusercontent.com/jeffpatton1971/c2d3ee98a37766a2784ccd626b9b8ca2/raw/edee46a24c1439e09490e415fa27943a08b353dd/schema.json","Json":"{}"}') -ContentType application/json

valid errors
----- ------
False {@{message=Required properties are missing from object: checked, dimensions, id, name, price, tags.; lineNumber=1; linePosition=1; path=; value=System.Object[]; schema=; schemaId=http://example.com/root.json; schemaBaseUri=; er...

This appears to work as advertised, the validator is telling me that my empty json string is missing stuff. What I'm struggling with is when I attempt to pass in the correct json that works on the link above.
Invoke-RestMethod -Method Post -Uri https://localhost:44392/api/jsonschema/validate -Body ('{"Schema":"https://gist.githubusercontent.com/jeffpatton1971/c2d3ee98a37766a2784ccd626b9b8ca2/raw/edee46a24c1439e09490e415fa27943a08b353dd/schema.json","Json":{"checked":true,"dimensions":{"width":7,"height":8},"id":1,"name":"thing","price":1,"tags":[]}}') -ContentType application/json
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At line:1 char:1
+ Invoke-RestMethod -Method Post -Uri https://localhost:44392/api/jsons ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

I feel that perhaps I've got the json string wrong in some fashion but I'm not clear. Below is the code from my POC. In my example I use the request.schema as a url and then I grab it from the URL passed in via WebClient. It parses the schema as you would expect, and for the null json string, it parsed that json as you would expect. When I pass in an actual json payload I get the error above. I have placed a breakpoint at the top of the ValidateResponse code, but I never get that far, so that error is thrown before I get to any code that I can trace.
Any help would be appreciated, I feel I'm doing something silly, the project is the asp.net core web api project, and I've followed the defaults and added an read/write api controller named JsonSchemaController. My startup.cs is below the JsonSchemaController.cs.
JsonSchemaController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema;
using System.Net;

// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860

namespace SchemaValidator.Properties
{
    [Route("api/[controller]")]
    [ApiController]
    public class JsonSchemaController : ControllerBase
    {
        public class ValidateRequest
        {
            public string Json { get; set; }
            public string Schema { get; set; }
        }

        public class ValidateResponse
        {
            public bool Valid { get; set; }
            public IList<ValidationError> Errors { get; set; }
        }

        // GET: api/<JsonSchemaController>
        [HttpGet]
        public IEnumerable<string> Get()
        {
            return new string[] { "value1", "value2" };
        }

        // GET api/<JsonSchemaController>/5
        [HttpGet("{id}")]
        public string Get(int id)
        {
            return "value";
        }

        [HttpPost]
        [Route("validate")]
        public ValidateResponse Valiate(ValidateRequest request)
        {
            WebClient wget = new System.Net.WebClient();
            var jsonSchema = wget.DownloadString(request.Schema);

            // load schema
            JSchema schema = JSchema.Parse(jsonSchema);
            JToken json = JToken.Parse(request.Json);

            // validate json
            IList<ValidationError> errors;
            bool valid = json.IsValid(schema, out errors);

            // return error messages and line info to the browser
            return new ValidateResponse
            {
                Valid = valid,
                Errors = errors
            };
        }

    }
}

Startup.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

namespace SchemaValidator
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
                endpoints.MapControllerRoute(
                    "default", "{controller=Home}/{action=Index}/{id?}"
                    );
            });
        }
    }
}

Package Manager Output
PM> Install-Package newtonsoft.json
Restoring packages for C:\Users\JeffreyPatton\source\repos\SchemaValidator\SchemaValidator\SchemaValidator.csproj...
Installing NuGet package newtonsoft.json 13.0.1.
Committing restore...
Writing assets file to disk. Path: C:\Users\JeffreyPatton\source\repos\SchemaValidator\SchemaValidator\obj\project.assets.json
Restored C:\Users\JeffreyPatton\source\repos\SchemaValidator\SchemaValidator\SchemaValidator.csproj (in 22 ms).
Successfully installed 'Newtonsoft.Json 13.0.1' to SchemaValidator
Executing nuget actions took 1.1 sec
Time Elapsed: 00:00:01.6936888
PM> Install-Package newtonsoft.json.schema
Restoring packages for C:\Users\JeffreyPatton\source\repos\SchemaValidator\SchemaValidator\SchemaValidator.csproj...
Installing NuGet package newtonsoft.json.schema 3.0.14.
Committing restore...
Writing assets file to disk. Path: C:\Users\JeffreyPatton\source\repos\SchemaValidator\SchemaValidator\obj\project.assets.json
Restored C:\Users\JeffreyPatton\source\repos\SchemaValidator\SchemaValidator\SchemaValidator.csproj (in 9 ms).
Successfully installed 'Newtonsoft.Json.Schema 3.0.14' to SchemaValidator
Executing nuget actions took 1.01 sec
Time Elapsed: 00:00:01.4802313

Comment: Pretty sure I used two seperate packages, let me add the package manager output to the post
Comment: Thanks.  I pasted your JSON and schema into a fiddle, however I'm not getting any validation errors.  See https://dotnetfiddle.net/4aY3uE.  Are you sure that `request.Json` and `request.Schema` are what you think they are?
Comment: Then you might tag your question with the frameworks and tools you are using to get the attention of someone who can help you, edit the title to be reflect where you think your your difficulty is, and try to narrow your problem down into a [mcve].  It was just tagged Json.NET which is why I weighed in but if your real problem is e.g. how to use `Invoke-RestMethod` in PowerShell I'm not going to be of much help.
Comment: Are you using the separate package [Json.NET Schema](https://www.newtonsoft.com/jsonschema) or the obsolete, deprecated [JSON Schema support built into Newtonsoft](https://www.newtonsoft.com/json/help/html/JsonSchema.htm)? ... Hmm [`JSchema`](https://www.newtonsoft.com/jsonschema/help/html/T_Newtonsoft_Json_Schema_JSchema.htm) is indeed from [Json.NET schema](https://www.newtonsoft.com/jsonschema/help/html/T_Newtonsoft_Json_Schema_JSchema.htm) so it looks like you are using that.
Comment: In my jsonsschemacontroller.cs above you can see that I'm using Newtonsoft.Json.Schema;
Comment: They both use the same namespace -- [`Newtonsoft.Json.Schema` in Json.NET schema](https://www.newtonsoft.com/jsonschema/help/html/N_Newtonsoft_Json_Schema.htm) and [`Newtonsoft.Json.Schema` in pure Json.NET](https://www.newtonsoft.com/json/help/html/N_Newtonsoft_Json_Schema.htm).  However, Json.NET schema is a [separate NuGet](https://www.nuget.org/packages/Newtonsoft.Json.Schema/) and a separate DLL that is separately licensed so I ask to make sure which is being used.  If you simply do `using Newtonsoft.Json.Schema` without the extra NuGet you may be using the obsolete schema code.
Comment: Yea so in the link I posted from newtonsoft you can see that the schema and json check out just fine. I think the problem is in how i'm passing in the json in the request, and everything ive' tried is failing.
Comment: Thanks I don't think it's an issue with powershell...but I see what you're saying let me see if I can get the same problem using postman.
Answer: The problem I'm seeing has to do with how the JSON is being constructed outside of the API. @dbc's post above with fiddler put me on the right track. Then working with postman helped me out even more.
{
    "Schema":"https://gist.githubusercontent.com/jeffpatton1971/c2d3ee98a37766a2784ccd626b9b8ca2/raw/edee46a24c1439e09490e415fa27943a08b353dd/schema.json",
    "Json": "{\"checked\":true,\"dimensions\":{\"width\":7,\"height\":8},\"id\":1,\"name\":\"thing\",\"price\":1,\"tags\":[]}"
}

This escaped json works as expected, I appreciate all the feedback.


How to properly add .NET assemblies to Powershell session?

Question: I have a .NET assembly (a dll) which is an API to backup software we use here. It contains some properties and methods I would like to take advantage of in my Powershell script(s). However, I am running into a lot of issues with first loading the assembly, then using any of the types once the assembly is loaded.
The complete file path is:
C:\rnd\CloudBerry.Backup.API.dll

In Powershell I use:
$dllpath = "C:\rnd\CloudBerry.Backup.API.dll"
Add-Type -Path $dllpath

I get the error below:
Add-Type : Unable to load one or more of the requested types. Retrieve the
LoaderExceptions property for more information.
At line:1 char:9
+ Add-Type <<<<  -Path $dllpath
+ CategoryInfo          : NotSpecified: (:) [Add-Type], ReflectionTypeLoadException
+ FullyQualifiedErrorId : System.Reflection.ReflectionTypeLoadException,Microsoft.PowerShell.Commands.AddTypeComma
ndAdd-Type : Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Using the same cmdlet on another .NET assembly, DotNetZip, which has examples of using the same functionality on the site also does not work for me.
I eventually find that I am seemingly able to load the assembly using reflection:
[System.Reflection.Assembly]::LoadFrom($dllpath)

Although I don't understand the difference between the methods Load, LoadFrom, or LoadFile that last method seems to work.
However, I still seem to be unable to create instances or use objects. Each time I try, I get errors that describe that Powershell is unable to find any of the public types.
I know the classes are there:
$asm = [System.Reflection.Assembly]::LoadFrom($dllpath)
$cbbtypes = $asm.GetExportedTypes()
$cbbtypes | Get-Member -Static

---- start of excerpt ----
   TypeName: CloudBerryLab.Backup.API.BackupProvider

Name                MemberType Definition
----                ---------- ----------
PlanChanged         Event          System.EventHandler`1[CloudBerryLab.Backup.API.Utils.ChangedEventArgs] PlanChanged(Sy...
PlanRemoved         Event          System.EventHandler`1[CloudBerryLab.Backup.API.Utils.PlanRemoveEventArgs] PlanRemoved...
CalculateFolderSize Method     static long CalculateFolderSize()
Equals              Method     static bool Equals(System.Object objA, System.Object objB)
GetAccounts         Method     static CloudBerryLab.Backup.API.Account[],     CloudBerry.Backup.API, Version=126.96.36.199, Cu...
GetBackupPlans      Method     static CloudBerryLab.Backup.API.BackupPlan[], CloudBerry.Backup.API, Version=220.127.116.11,...
ReferenceEquals     Method     static bool ReferenceEquals(System.Object objA, System.Object objB)
SetProfilePath      Method     static System.Void SetProfilePath(string profilePath)

----end of excerpt----
Trying to use static methods fail, I don't know why!!!
[CloudBerryLab.Backup.API.BackupProvider]::GetAccounts()
Unable to find type [CloudBerryLab.Backup.API.BackupProvider]: make sure that the     assembly containing this type is load
ed.
At line:1 char:42
+ [CloudBerryLab.Backup.API.BackupProvider] <<<< ::GetAccounts()
    + CategoryInfo          : InvalidOperation:     (CloudBerryLab.Backup.API.BackupProvider:String) [], RuntimeException
    + FullyQualifiedErrorId : TypeNotFound

Any guidance appreciated!!
Answer: Could you surround the Add-Type with a try catch and print the LoaderExceptions property, as the error is stating to do. It may provide an exception with a more detailed error message.
try
{
    Add-Type -Path "C:\rnd\CloudBerry.Backup.API.dll"
}
catch
{
    $_.Exception.LoaderExceptions | %
    {
        Write-Error $_.Message
    }
}

Comment: isn't there a way to use relative path?
Comment: The opening curly bracket must be on the same line as the percent sign:
 `$_.Exception.LoaderExceptions | % {`
Comment: At the time of posting, which was I believe PS2.0? That was valid syntax. Has this changed in 6+? Asking for my own curiosity.
Answer: Some of the methods above either did not work for me or were unclear.
Here's what I use to wrap -AddPath calls and catch LoaderExceptions:
try
{
   Add-Type -Path "C:\path\to.dll"
}
catch [System.Reflection.ReflectionTypeLoadException]
{
   Write-Host "Message: $($_.Exception.Message)"
   Write-Host "StackTrace: $($_.Exception.StackTrace)"
   Write-Host "LoaderExceptions: $($_.Exception.LoaderExceptions)"
}

Reference
https://social.technet.microsoft.com/Forums/sharepoint/en-US/dff8487f-69af-4b64-ab83-13d58a55c523/addtype-inheritance-loaderexceptions
Answer: I found this link:
http://www.madwithpowershell.com/2013/10/add-type-vs-reflectionassembly-in.html
He says, ".LoadWithPartialName" has been deprecated.  Therefore, instead of continuing to implement Add-Type with that method, it uses a static, internal table to translate the "partial name" to a "full name".  In the example given in the question, CloudBerry.Backup.API.dll does not have an entry in PowerShell's internal table, which is why [System.Reflection.Assembly]::LoadFrom($dllpath) works.  It is not using the table to look up a partial name.
Answer: The LoaderExceptions are hidden inside the error record. If the add-type error was the last one in the error list, use $Error[0].InnerException.LoaderExceptions to show the errors. Most likely, your library is dependent on another that has not been loaded. You can either Add-Type each one, or just make a list and use the -ReferencedAssemblies argument to Add-Type.
Comment: Try $Error[0].Exception.LoaderExceptions and following Eris's advise.
Answer: I used the following setup to load a custom csharp control in powershell. It allows the control to be customized and utilized from within powershell.
here is the blog link
http://justcode.ca/wp/?p=435
and here is the codeproject link with source
http://www.codeproject.com/Articles/311705/Custom-CSharp-Control-for-Powershell
Comment: Welcome to Server Fault! We really do prefer that answers contain content not pointers to content. Whilst this may theoretically answer the question, [it would be preferable](http://meta.stackexchange.com/q/8259) to include the essential parts of the answer here, and provide the link for reference.
Answer: I guess by now you MIGHT have found an answer to this phenomena.
I ran upon this post after encountering the same problem...I could load the assembly, and view the types contained in the assembly, but was unable to instanciate a instance of it from a static class.  Was it EFTIDY. Tidy, EFTidyNet.TidyNet.Options or what?  Ooooo Weeee...Problems...problems...it could be anything.  And looking through the static methods and types of the DLL didn't reveal anything promising.  Now I was getting depressed.  I had it working in a compiled C# program, but for my use I wanted to have it running in a interpeted language...powershell.
My solution I found, and it's still being proven, but I'm elated and wanted to share this.  Build a small console.exe app exercising the func that I was interested in and then view it in something that would decompile it or show the IL code.  I used Red-Gate's reflector and the powershell language generator add-in and Wallah!  it showed what the proper constructor string was!  :-)    Try it. and I hope it works for whomever is faced with this problem.
Comment: And... what was the proper constructor string? This doesn't really answer the question the way it's written. Also, welcome to ServerFault!


Valores com tipos diferentes Gson - Java

Question: Eu gostaria de saber, se existe uma forma com Gson de obter valores de diferentes tipos em um array de "chave-valor" em Json.  Segue o exemplo:
{
"events":[
            {"event":"comprou-produto",
             "timestamp":"2016-09-22T13:57:32.2311892-03:00",
             "custom_data":[
                    {"key":"product_name","value":"Camisa Azul"},
                    {"key":"transaction_id","value":"3029384"},
                    {"key":"product_price","value":100}]} ... outros elementos]}

Neste exemplo acima temos o array "custom_data" com os campos de chave-valor, e repare que "product_price" é um campo e o seu valor é um double (ou int se preferir), sendo que os demais são Strings.  Como eu posso obter esses valores com Gson.  Eu fiz uma classe para tentar ler esse conjunto de dados.  Segue:
public class Event {

private final String event;
private final String timestamp;
private final double revenue;
private final List<CustomData> custom_data;

//Constructor.
public Event(String event, String timestamp, double revenue, List<CustomData> custom_data) {
    this.event = event;
    this.timestamp = timestamp;
    this.revenue = revenue;
    this.custom_data = custom_data;
}

//nested class.
public static class CustomData{

    private final String key;
    private final String value;

    public CustomData(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}

Obs: O campo revenue, refere-se a uma informação extra do conjunto de eventos que o array mais externo possuí, em alguns casos como o do exemplo eu simplesmente o ignoro.
Obrigado.
Answer: Você pode utilizar um Map pra isso.
public class Event {
    ...
    private final List<Map<String, Object>> custom_data;
    ...
}

Parse:
EventWrapper events = new Gson().fromJson(jsonData,EventWrapper.class);

EventWrapper.java
public class EventWrapper {
    private Event[] events;

    public Event[] getEvents() {
        return events;
    }
}

Acesso:
for (Map<String, Object> customData : event.getCustom_data()) {
    String chave = (String) customData.get("key");
    String valor = String.valueOf(customData.get("value"));
    System.out.println(String.format("%s => %s", chave, valor));
}

Resultado:

Parse:
EventWrapper events = new Gson().fromJson(jsonData,EventWrapper.class);
Comment: Você utilizou a API Gson pra poder obter esses dados ?  Eu estou com dúvida justamente em como fazer essa ação com o Gson.
Comment: Editei a resposta com como fiz a conversão


(Not) Downloading Patches?

Question: I have just upgraded from VC 2.5 U4 to vSphere Server 4 U1. I have upgraded the Upgrade Manager extension also.
My patch repositry shows what looks to be a full repositry, it contains ESX 3.5 patches and ESX 4 patches, BUT, if I look at the actual directory structure of downloaded patches then there are no ESX 4 patches downloaded??
Why hasnt it downloaded all the patches? Running the scheduled task doesnt do it and there are no error's when it runs. There is also no email confirmation anymore after running - presumably as nothing has been downloaded.
Cheers,
Rich
Answer: Try completely uninstalling and delete VCUM, clear down all directories etc, reboot then reinstall.
Comment: I've never realized how dirty VCUM could be ...

(Not) Downloading Patches?


Why do I feel like I sound really bad when I'm playing Guitar?

Question: I'm going to try and articulate what I feel about myself when I play guitar, whether it be in front of people or by myself. I'm not sure if its a common thing for musicians to feel or if its just me.
So I've been playing guitar for about 6 years, on and off for the first 4 and have been playing a lot for the past 2 years. I'm in the school band where we play these pretty lame songs, the usual stuff that you'd expect. But whenever I'm playing, its feels like I'm really bad at playing the guitar, whether it be in front of others or just by myself. It's this deep sinking feeling that I sound so bad.
It doesn't seem like I sound bad when I'm actually playing but I still don't believe that I sound decent at all. When I listen to a recording of myself i get the same feeling, but I'm always unimpressed with how I sound. I really don't know if its low self-esteem, a warped perception of how I sound or if I really am just utter trash at playing.
I ask my friends and people I play with if I sound bad and they always say 'no', I ask them to be specific, asking them to explain how they feel, ask them to tell the truth and tell them that I just want to know, you can be as brutal, mean and nasty as you want just tell me if I sound bad or not. But they always just reassure me, going you sound fine. I'm not sure if they just want to spare my feelings or they think I actually sound alright, but this is driving me crazy. I've got a performance coming up soon and I really need to know if I sound awful before hand so I can try and figure out whats wrong.
I don't want to continue playing and having people shudder every time i play. I understand that music is subjective, but I just don't feel like I sound any good and I don't even think all the affirmation in the world would convince me otherwise. I don't know what I should do.
Is there anyway I can really know if I sound alright?
Comment: You won't know for sure until you start trying out for bands and/or playing gigs. I think most musicians are better than they think they are, except the ones who think they are great. Also, it's more important to find your own sound and expression than to sound "great". Focus on sounding like you and see if people want to hear it and play with you.
Comment: Even the best friends may not give a true opinion if they don't want to upset you: upload the clip to Soundcloud or Youtube and post it on Reddit or similar and you're likely to get a more neutral opinion: especially if you specifically ask for it along with some constructive criticism and feedback
Comment: It may be related to low self-esteem and/or perfectionism, or maybe another thing -I am not psychologist or anything-. Listen your own recordings to see how it really sounds and try to fix what you see wrong with them. Also you should accept that you may not be as good as people whose profession is playing guitar several hours a day. Keep that in mind if you compare your playing with the studio recordings of the original song that you cover.
Comment: Re: comparing to recordings. The best thing to do is look for live recordings/videos of some of your favorite guitar players. Quite a few of the greats often miff notes and wrench chords live. Most audiences are not there to heckle, so not a big deal. If you miff Mary Had a Little Lamb, errors are mystifying. If you are decent and playing at the edge of your ability, they can be breathtaking. And if you incorporate them, they are not even errors anymore.
Comment: Do you have decent foldback so you can actually _hear_ what you sound like?
Comment: I'd say recording yourself is a very good tip, if when you hear these recordings you think you are out of time, then use a metronome, if you think that you are missing notes in a part then play through that part. It is true that your self esteem is a big thing in music. I have so many people that say I can sing but I'm not confident so I think I sound bad.
Comment: Put a recording on here. I'll be honest!
Comment: i felt this about my bass when I first played publicly. However the sound guy, himself  a music teacher told me it sounded amazing out-front. He turned a speaker round for me and he was right.  Its just nerves making you worry.
Comment: I'd suggest _not_ asking people what they _thought_ of your playing; instead, ask them whether they _enjoyed_ it. Even non-musicians can tell you that in detail! And perhaps it's a more worthy goal. (It works the other way around, too: if you've listened to a performance whose quality you can't honestly praise, you might still be able to tell them in all sincerity "I really enjoyed that!")
Answer: Most musicians constantly fuss over how they sound.  It is understandable, given the way we communicate using sound; we want our sound to be the best sound we can create. So, you are not alone here.
It is important for you to learn to separate the sound from your self-worth as a human being.  You ask your friends to be specific, but you need to be specific: what exactly are you asking about? Are we talking about timbre? If so, some quick adjustments to your guitar / strings / amp can easily change that. Are we discussing performance confidence? Stage presence? Understanding everything that the music entails and practicing those techniques regularly will mitigate ignorance of the music, thus mitigating performance anxiety.
What is it about your sound you want to change? Timbre? Performance Anxiety? Is it a technique problem? Sloppy playing? Is it a gear / setup issue?
Notice that none of those questions focus on you as a person.
One other thought: don't ask your friends - ask people you don't know; they don't have anything to lose by being honest with you, even if their answers aren't as articulate as you might want them to be.
Comment: On the final point: I was going to emphasize asking other musicians (who aren't your friends); I believe that some people will say generic positive things because they do not listen as closely and/or cannot find the words to describe what they are hearing.
Comment: @Dave Yes I agree. I didn't say as much in my answer, but as a composer I find that generally other composers will provide much more specific, insightful comments than other types of musicians. That being said, I have some friends who are instrumentalists with *excellent* ears for nuance and articulate themselves extremely well; though they can't write a note of music themselves.
Answer: Well, you're six years into playing.  Your discrimination develops faster than your playing skills and your imagination.  Chances are that indeed your playing leaves something to be desired -- to you.  If Picasso had shopped around for opinions at age 20, everybody would have told him he was doing great and that his pictures were fine.
Now to quote Shakespeare: "'So so' is good, very good, very excellent good; and yet it is not; it is but so so."
There is a whole lot you can do with reasonable skills.  At the same time, you should work on being able to better put a finger on what is disturbing you with regard to your playing and work on getting better.
At some point in that process, it might be a good idea looking for a teacher who either understands your problem with your playing and work targeted on it, or (and of course that's the more tedious options) who can solidify your basics and perspectives to a degree where you have a better chance yourself to move forward.
This does not need to mean weekly lessons: some people derive a lot of inspiration from an occasional master class or (depending on their skills level) more generic courses and session work.
Developing a plan and trying to make progress on it, preferably under supervision of more experiences players, may end up less frustrating than just screwing around without aim, but even screwing around without aim is better than doing nothing.
Answer: First, ask yourself what you do well when you play. When you are listening to yourself, it's very easy to get caught up in what you are doing wrong. You missed a chord in the third measure, or you lost the rhythm for a moment somewhere. But if you only pay attention to those things, you miss everything else. You missed a chord or two, but you played 30 or 40 chords correctly. You lost the rhythm for a full second, but if the song is 3 minutes, that means you held the rhythm for 179 seconds. Every time you play a song, make a point of noting to yourself one thing you did right for every thing you do wrong. It not only helps you feel better, but it helps you see what you are honestly doing well.
If you feel like you sound terrible, but other people say you don't, you need to learn to hear yourself like others do. An easy way to do this is to record yourself, then don't listen to the recording for at least a week or two. A month is even better. By giving yourself time before you listen, you'll forget exactly what you did wrong, and it feels more like it isn't your own. Then when you do listen, make an effort to listen like it's a stranger playing. Listen to the overall sound, like you would if it was another person. Maybe try humming along, just paying attention to the overall melody and rhythm. Don't try to pick out the mistakes.
And finally, you are going to make mistakes. I've listened to concerts by professionals whose musicianship I'll never match, and heard them screw up badly. They still sounded great. If you want to become a good musician, you need to be able to recover from mistakes, and part of that is learning to move on quickly when you make them. If you consider yourself trash, you'll never get any better.
Comment: This dovetails with a maxim of my own: **When recording, you want to have as few wrong notes as possible; but when playing live, have as many _good_ notes as possible.** In a live situation, any minor mistakes are over, gone, and forgotten almost immediately. Remember that your audience aren't following the score; they probably won't even notice minor mistakes, and any who do won't worry about them, so neither should you. Concentrate on what you're playing _now_, make that as good as you can, and enjoy it — and people will enjoy listening to it.
Answer: I picked up on one thing that doesn't appear to be mentioned and I think plays into the "Flow" post made above as well.
Your second paragraph, second sentence starts "I'm in the school band where we play these pretty lame songs...." and I think part of the problem is right there.
Music has energy, pulse, a life of it's own, if you don't like what you are playing, and are just going through the motions trying to get to the end of the song then your lack of energy and drive can translate into the music sounding flat and boring (not flat as in b just flat as in no dynamic).
I realize this is a sort of intangible thing I am describing but I think that if you can find something inside these "lame" songs to grab onto and use to push yourself you will find some energy and enthusiasm slipping back into your playing.
Maybe it's pushing yourself to be perfectly in time every time on every beat 4 to a bar, maybe it's pushing yourself to be able to accent the "and of 2" every bar. If you are allowed to make artistic choices maybe it is trying to find and use a different voicing for one of the boring chords you have to play over and over.
Make it a game to try and take every last bit of knowledge a song can offer and stretch it as far as it can go.
Odds are good that in band in school you are learning some good old Jazz standards. Look up players that have come before you and see what they did with it, find inspiration in the small things!
Maybe that is useful, maybe it isn't, but I really think if you can find a way to stop thinking of the songs as "lame" and find something interesting about them to focus on, you can find something you feel like you are missing!
Thanks!
Steve
Answer: First of all, if you've been actively working on it and playing for six years, I doubt you're really bad. The worst case is that you're mediocre.
These are the top three torments of the amateur musician:

You're so used to hearing yourself and micro-analyzing your playing that your ears go numb and it's almost impossible to judge your own skill.
You can't ask your friends because everyone is going to tell you that you're good no matter what.
Even if you're actually pretty good, you'll never sound anywhere near as good as your heroes, or even necessarily good enough that you'd listen to your own stuff for fun.

And these are the top three consolations:

If you're even halfway decent, you still get lots of the perks that come with being a musician. Playing music is seen as an almost magical power by a lot of people. It automatically makes you more interesting and--yes--a bit more attractive.
It's not a job. If you're not enjoying yourself or can't get out of your own head about whether you're any good or not, you can put it down whenever you want and return to music when it feels right.
Playing music is really fun, especially with friends, even if you're just so-so. There was a time when music was a major pastime, when  families would gather after dinner and play music the way we now watch TV and play games. People had a great time. Were most of them all that good? Probably not, but who cares?
Answer: I know the feeling. As a violinist, I used to have an over-inflated opinion of my sound. The violin is right up against your chin, and vibrates your skull which makes the instrument sound much better to the one who's playing it... (much like how people's voices sound better to themselves than to others or on a recording.)
If you've been playing for that long, then you probably sound just as good as you could be expected to. I record myself practicing so that I can get a better idea of how I really sound, and of course it horrifies me. But it's important (me being a violinist... violinists have big heads...) to have an adequate idea of how I sound. What I discovered is that when I compare how I sound now to how I sounded when I first started, I sound like I've improved. You never stop learning. You never sound perfect, but you always improve.
To most people who never stuck with an instrument, you probably sound like something incredible. Don't think that people give out praise for nothing. It's not that you sound as good as a guitar legend, it's that you sound better than you used to, and better than people who haven't played as long as you have. Being able to play at all takes dedication. That's what people notice. Not the perfection.
You sound like a rather young person. How usual is it to have a person your age who's stuck with any instrument for as long as you have? Most people your age don't know the first thing about guitar.
So what can you do? Practice. Record yourself. Don't beat yourself up when you don't sound like a master. Remember that you've improved.
When you can't seem to move forward, remember where you've been.
Answer: Playing a musical instrument is basically about "performance". Whether it is in front of an audience or the audience is just yourself alone, it is still about performance.
At a young age (you play in a school band) it can be very easy to develop a negative outlook of ones own musical ability (or any other ability for that matter).
Moving from a negative to a positive mindset is no easy matter.
This short article may help ...The psychology of performance:
"A lot of people get really scared just getting up in front of a school and addressing an assembly. Times that by a million and put an instrument in your hands, and [add] the abstracted nature of music, and then you've got a taste of what it's like standing in front of an audience".
http://www.abc.net.au/radionational/programs/musicshow/richard-tognetti-and-the-psychology-of-performance/6838670
Answer: Having played instruments for over 30 years, having been in a band with real gigs, and having a visual arts degree, I will say: you are not alone.
However, aside from the basic self-loathing and impostor syndrome that all artists suffer from, there is a concept in psychology called flow. Which is similar to but different from "hyperfocus."
In my experience, when I become conscious of my playing in an analytic sort of way that you seem to describe in your question, especially when I think of how cool I ought to look and how much everyone must be enjoying my obvious genius (/sarcasm), my playing suffers for it.
Some people speak about right-brain/left-brain duality and it seems like there is some science to it. I always thought of flow as that state where my left brain just shuts the hell up and lets me work.
There is no easy way to get into a flow except to "feel it" and no easy way to get back in it once you "break it." You just need to know what to do, how to hear, and where to go (even when you stumble). These come from practice and positive attitude towards imperfection.
Flow is (from Flow (phychology)):

Intense and focused concentration on the present moment
Merging of action and awareness
A loss of reflective self-consciousness
A sense of personal control or agency over the situation or activity
A distortion of temporal experience, one's subjective experience of time is altered
Experience of the activity as intrinsically rewarding, also referred to as autotelic experience

and

Some of the challenges to staying in flow include states of apathy,
  boredom, and anxiety.

Oddly enough, mundane practice and self-critiques which are both critical long-term for creativity are also counterindicated for flow.
Answer: You are describing the internal state that leads musicians to seek guidance from a really good teacher.
You will be amazed how much more satisfaction you can get from playing your instrument if you are being guided to make improvements in your playing.
Assemble a list of candidate teachers.  Ask to observe a lesson.  Cross off your list anyone who is uncomfortable with this request.  Keep looking until you find the right fit.
Answer: I think it may be a good thing what's happening to you. You are aware that you're not sounding like you would like.
From my experience I get that too. When I hear great musicians, and experience what they make me feel; I see how amazing they are, and wonder how can I, or would I even be able to be great at music.
When I play, I find weak points, or things I would like to improve. And I even hear how I want it to sound, but there's a gap. And sometimes, a big one, between how I know it should sound, or how I want it to sound, and how I sound when I'm playing.
And it's no easy task. It's not easy to play countless times to get a little closer to how I want to sound. And sometimes it feels like I'm going nowhere, like it doesn't get better.
But hard work it's worth it. One day you are playing yet another time the same piece, and it magically comes together.
One of the things that made me get in this journey of music deeper, was the teacher I have. He is teaching me how to build my own sound, how to think about music, how to interpret. How to give each single note you play a meaning. All notes make music. And that's the difficult part, every single note you play has a meaning, it's all part of a big speech. And that's part of what makes great musicians, able to give life to every note they play.
One of the important things he taught me is to have some solid base. Things that you can reliably depend on when you are stuck. This elements, technique elements, make up the ground where you build up music. How you position your body to play, how do you move your muscles to produce sound. What do you need to do to make some sound, be it a legato, or a staccato for example, how is it played, and how do you play it with your body.
The point is, the foundations you build make up for the music you'll make. If you can build a solid ground, you can make great music. It's a tough path. But I'm working on the tools that allow me to paint the music, it's like preparing a color palette to use later. You can play 'easy' / 'beginner' music, and still make it sound amazing if you have the tools.
Answer: As a budding musician, I am aware of every mistake I make.  But I find that my audience rarely notices them unless I stop or do something that breaks the rythme.  So just keep rockin, and nobody else is likely to notice.  Another thing is that school music is all about following the notes as written.  Do your self a favor an focus more on the message and less about the content.  Listen to the music.  Jazz it up.  Make it sound the way you want it to sound.  Improve upon it so that it sounds better to you.  Just as long as you stay in key and don't go off the rails, you will be fine.
But my main point is that a musician hears his every mistake.  As a result, you need to learn from them, but you also need to be able to forgive and forget.  Make sure you spend plenty of time playing the things you want to play.  We don't get paid to worry, so why should we?  We get paid to rock!


How to configure ldap to resolve host names?

Question: I'm new to LDAP and I already configured accounts with LDAP so I can login on few computers with LDAP.
Now I would like to add some host names to LDAP. In /etc/nsswitch.conf I changed:
hosts:          files dns ldap

But I have no idea how to add anything to LDAP database so it could resolve some names. I tried google but I couldn't find anything helpful.
On example, how to add this:
192.168.1.1    node1

Answer: I already figured it out with help of migrationtools (ubuntu package).
First, create file add_hosts.ldif:
dn: ou=Hosts,dc=example,dc=net
objectClass: organizationalUnit
ou: Hosts

Load it with:
ldapadd -D cn=admin,dc=example,dc=net -W -f add_hosts.ldif

Above steps should be done only once.
Then create file node1_host.ldif:
dn: cn=node1,ou=Hosts,dc=example,dc=net
objectClass: top
objectClass: ipHost
objectClass: device
ipHostNumber: 192.168.1.1
cn: node1
cn: n1

I added second cn so it can resolve both node1 and n1.
If you want to add another host, just create another file node2_host.ldif and load it into LDAP.


Namespace alias for subnamespaces in local scopes

Question: Consider that I want to call boost::algorithm::join as boost::join, but I don't want to import the subnamespace in the global namespace as:
namespace boost {
   using algorithm::boost;
};

Because I want to call boost::join with that syntax only in a local scope of an specific function:
void my_fun()
{
    namespace boost { // Doesn't allowed syntax in local scope
        using algorithm::join;
    }

    auto ret = boost::join(something...);
}

A different approach would be:
void my_fun()
{
   using boost::algorithm::join;
   auto ret = join(something...);
}

But this would provoke a ADL lookup, and I don't want to do such a lookup, because I know what method I'm calling: boost::algorithm::join.
Only, I'm trying to find the shorter boost::join way of calling it. What will be the correct syntax or idiom to create a "subnamespace" alias?
Comment: Sounds like you could use a [namespace alias](http://en.cppreference.com/w/cpp/language/namespace_alias)
Comment: Don't mess with other people's namespaces. You can make your own `namespace boost_misc` or whatever you want to call it, but don't add names to `namespace boost`.
Comment: I don't understand what you have against ADL? It's not something that happens at run-time anyway, only at compilation-time. It's a very simple solution to the problem you have.
Comment: @Someprogrammerdude Implicit conversions and other possible overloads.
Comment: Are you worried someone else will modify your code, and call the `join` function (in the scope where you have the `using` directive) with arguments that won't be correct? Do you have your own `join` function that might clash with the Boost one? That is active in the same scope as the `using` directive?
Comment: Please improve your question's title, such that it describes the question and has no tags in it.
Answer: You can't do this without polluting the Boost namespace, which is not yours to pollute.
Perhaps the following compromise can work for you?
namespace balgo = boost::algorithm;

Then use balgo::join.
So it's not a very descriptive name, but you're trying to make a short alias in a confined scope, right?
Otherwise, the affected region should be small enough that a simple join is clear and unambiguous (i.e. using namespace boost::algorithm); otherwise, just stick with the fully qualified name. Your team will thank you for it.


Enable CORS at Visual Studio Code

Question: I´m unable to start debugger on Visual Studio Code and also CORS extension on chrome, it simply does not appears as when I console yarn start.
Is it any way to specify that I want CORS extension enabled on Chrome when debugging?
This is my launch.json:
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Chrome",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceRoot}/src"
        }
    ]
}

Answer: You can instruct the Chrome instance to allow CORS by starting it with the argument --disable-web-security. To do this from VS Code, use the runtimeArgs config option, i.e.
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Chrome",
            "type": "chrome",
            "request": "launch",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceRoot}/src",
            "runtimeArgs": ["--disable-web-security"]
        }
    ]
}

Enable CORS at Visual Studio Code


How Do You Rewrite 6/8 Time To 3/4 Time?

Question: In the sheet I'm doing, it asks to rewrite a measure from the song. The original song is in 6/8 time and I chose to revert to 3/4 time. How do I do that?
Comment: 6/8 and 3/4 are equivalent in time, just not in feel/rhythm.  You shouldn't need to do anything, unless your goal is to preserve something of the feel.  See http://music.stackexchange.com/q/25035/28
Comment: @NeilMeyer - actually, that would be a far better question in a test !
Comment: You cannot *revert* to 3/4, as it never was that anyway.
Comment: We're not going to get far until you ask a clearer question!
Comment: You could convert it to 2/4 time but that is not really the question
Comment: Unless the question specifically asked for that to happen - which is doubtful - answering in 3/4 time will get it marked down. Please show the question.
Comment: It's very rare that 6/8 is a 3-beat metric, so I would deny the question posed.
Answer: Whilst there are the same number of quavers in both time signatures, you need to preserve the feel as far as possible.
To do this, you're going to end up with two 3/4 bars for every 6/8 bar. Firstly, divide the 6/8 bar into two 3/8 bars. You just need to stick a bar line in the middle of the bar. Easy.
Then, you want to convert the 3/8 into 3/4. To do this, you need to double the length of every note and rest. This should be straightforward, depending on the complexity of the music.
Finally, double the tempo, if there is one. It may now be quite fast.
The end result is probably the best conversion you are going to get. It's better than simply changing the quaver beaming because it largely preserves the beat emphasis. I also suspect it will be harder to read, but that's a matter of opinion.
Comment: Well that finally explains the existence of 6/8. I always had a hard time reading it but some others could easily have it hard the other way around.
Comment: But - bear in mind that in 3/4 time, every '1' is emphasised the same, theoretically. Whereas, in 6/8, '1' is emphasised most, with '4' being emphasised as well, but not so much as '1'. So the feel won't be exactly the same. That's probably why both time sigs exist, as they can't be exactly morphed into each other.
Answer: It depends on the focus of what your worksheet is having you work on.
If it is a transcription exercise working on musical notation then the convention is in 6/8 time to have eighth notes beamed in triplets (three notes per beam).
In 3/4 time the eighth notes will be beamed in pairs.
This follows the strong count of the measures, so eighth notes in 6/8 follow 1 2 3  4 5 6, and in 3/4 follow 1 + 2 + 3 + .  Otherwise the measures will look the same, but the feel will be different.


gracenote c++ wrapper error: gnsdk_taste.h is missed

Question: I'm trying to write simple app based on GNSDK, which will be using c++ wrapper. And I have error - after I including "gnsdk.hpp" compiler could not find gnsdk_taste.h. I was trying to find it in GNSDK folder, but could not. Could someone please help me to solve issue?
Comment: Can you try removing gnsdk_taste.h from gnsdk.hpp? You are not going to use gnsdk_taste anyway as the corresponding lib is not included.
Comment: Thanks, It work for me. But it was a little bit strange - I have downloaded GNSDK from official site, and it contains such little bug.
Comment: Can you accept a comment as and answer? Also would you be so kind and let me know the exact version or name of the package you downloaded? I'll get it corrected.
Answer: Remove gnsdk_taste.h from gnsdk.hpp. You are not going to use gnsdk_taste anyway as the corresponding lib is not included.


Create tpl file for webform

Question: I have created a form using webform module. Is there any way to create tpl file for this form?
webform-form-node_id.tpl.php is working fine. Here my problem is node_id will deffer on dev,qa and production etc server.
Please suggest so that a single tpl file can used for all instance.
Comment: If using path alias for template suggestion is an option for you - [check this post](http://drupal.stackexchange.com/a/202780/49935)
Answer: You can use 'node--webform.tpl.php' template for all webform nodes.

Create tpl file for webform


What are those blue stripes or patches on Balotelli's back?

Question: I've seen a lot of players with those blue stripes or patches like Balotelli wore in the Italy - Germany Euro 2012 semi-final:

What are those stripes / patches/ tapes?
Comment: **Welcome** to those of you who are here for the first time! Please note that while anyone may freely answer, answers like "Neat!" or "I had the same question, thanks for this!" **are subject to immediate deletion.** This is what keeps our quality high. If you're curious and want to know more, have a look at our [faq].
Comment: The BBC have ran an article on this tape: http://www.bbc.co.uk/news/health-18672458
Comment: @Ste We were first!
Answer: It is Kinesio Tape, which is an adhesive-tape that is applied to problematic muscles.
Problematic as in, the muscles are weak after returning from injury (you can support them using Kinesio tape), or you can apply it to aching muscles to sooth the pain. It's application can also increase blood flow to the muscles, and speed up the recovery process.
Specifically to Mario, no-one knows the exact reason he's using it.
Here's an article which explains the science behind it (beyond me :P).


Ansible: prevent interpreting variable's content as JSON/YAML

Question: I'm trying to use Ansible to tweak an ini-style configuration file, where one value is formatted as JSON data.
I tried the following task:
- name: Update configuration
  ini_file:
    dest: "{{ service_root }}/etc/production.ini"
    create: no
    section: app:main
    option: "{{ item.option }}"
    value: "{{ item.value }}"
    mode: '0640'
  notify: Reload Apache configuration
  with_list:
    - option: repoze.who.auth_tkt.secret
      value: "{{ secrets.auth_tkt }}"
    - option: oidc.client_config
      value: "{{ oidc_client_config | to_json }}"
  loop_control:
    label: "{{ item.option }}"

Unfortunately, when I try it, the oidc.client_config is not formatted as expected: the strings are between single-quote symbols instead of double-quote, and the false value shows up as False instead of false…
As I understand it, when I use the item.value variable, Ansible sees it looks like JSON and decodes it, and then converts it to string, using Python's str() function.
I tried a single-option task:
- name: Update configuration
  ini_file:
    dest: "{{ service_root }}/etc/production.ini"
    create: no
    section: app:main
    option: oidc.client_config
    value: "{{ oidc_client_config | to_json }}"
    mode: '0640'
  notify: Reload Apache configuration

This one works fine, I get the value formatted as expected in my configuration file. Hence, I can split split my initial task and then it works fine, but I'm unhappy with this solution.
Is there a way to prevent interpretation of the item.value variable as JSON/YAML?
For what it's worth, I'm currently using (the quite ancient) Ansible 2.2.
Answer: In the advanced syntax section of the manual (https://docs.ansible.com/ansible/latest/user_guide/playbooks_advanced_syntax.html) there is a section on unsafe or raw strings.
My understanding is you can just mark your value as unsafe and it will not be interpreted:
value: !unsafe "{{ oidc_client_config | to_json }}"

Comment: Thanks for pointing that section of the manual; it seems that I missed it (and the part about anchors and aliases is something I needed). Unfortunately, it does not work as expected: doing as suggested, I get the raw string "`{{ oidc_client_config | to_json }}`" in my configuration, rather than the jsonified content of the `oidc_client_config` variable.
Comment: Thanks for pointing that section of the manual; it seems that I missed it.
Comment: Is there a way to do something like this in an ad-hoc command?

Ansible: prevent interpreting variable’s content as JSON/YAML


Plain C++ objects in code accessed by JNI

Question: My Android application has a native C++ layer and a Java layer. The Java layer accesses the native layer via JNI calls.
Can the C++ layer safely create C++ objects for its own internal use, and store them in C++ member variables? I'm talking about C++ objects that don't need to be accessed by Java code in any way, i.e. they are managed and deleted completely in the C++ layer. In other words, the same object (via a member variable) is accessed throughout multiple JNI calls, but only the C++ layer needs to access it.
I need confirmation in this matter, because I know that there are special JNI methods for handling objects (relevant terms: local reference, global reference, etc.). If I'm correct, these apply only for objects that are visible by (or created for) Java code as well.
Therefore, I suppose that native-only C++ objects can be created and deleted in the usual ways (such as new and delete), and Java doesn't need to know anything about them. No special interoperability considerations are necessary, as long as the objects and any references to them reside exclusively in the C++ layer. Is this correct? Can I define C++ classes and methods in this layer in the same way as if it was a usual C++ application without any JNI/Java interoperability? To be general, is it allowed to instantiate and store plain C++ objects, i.e. objects that are out of the authority of Dalvik/JVM?
Comment: Yes, of course. Look at this code, for example: http://stylishtoupee.blogspot.fr/2011/07/jni-example-with-class-instantiation-c.html
Comment: Thanks. I suppose that your solution provides a "root" for the stateful C++ layer. I mean, we have to keep track about the "root" C++ object, and this is why you store its pointer in Java level. In "deeper" level, i.e. *inside* this C++ class, there can be further member variables (and additional C++ objects). References to those "further" objects don't need to be stored in Java level (we store them in the C++ class), but the "root" object must be, because this is how you can access the stateful C++ layer from Java code.
Comment: This sample just shows that there are no restrictions on creating C++ objects inside C++ library exposing API for Java. C++ instances may be passed to JNI client, or kept inside the library, making some internal work.
Answer: Indeed, the JNI methods for handling objects are for the Java objects.
You can create C/C++ objects in any way you can imagine (malloc/new), but: how will you preserve them across JNI calls? (If you need that, of course.) Two options:

Convert the pointer into an integer and pass that integer to Java. (You will have to care about pointers stored in garbage-collected Java objects, you see, the integers do not imply freeing the native memory.)
Have some C/C++ data structure with all the necessary references.

Thread-safety deserves separate consideration; if you try to store pointers in thread-local variables, you probably will never debug the code (you see, there's a life cycle mismatch).
Good results may be achieved with static global variables accessed from just one thread.
And keep in mind that Android may kill and restart your application's process, thus destroying everything stored in static variables, as well as your native data structures.
Comment: I was thinking about a combination of 1) and 2): the "root" C++ object is managed according to 1), and this C++ class can handle the rest of internal C++ stuff in itself (i.e. instantiate additional C++ objects and store them in member variables, this is how it would save the state across JNI calls). Does this sound correct? (Assuming that Android lifecycle/thread safety is handled properly.)
Comment: Yes, it does. Just remember that activities are killed and recreated each time the screen turns, and in some other less evident circumstances. I'd keep that pointer in the `Application` instance. And it's better to avoid pointers to native memory in objects that may be garbage-collected (just because it's easier to avoid it than to do it right).


Measuring 'total bytes written' under Linux

Question: We're quite interested in exploring the possibility of using SSD drives in a server environment. However, one thing that we need to establish is expected drive longevity. According to this article manufacturer's are reporting drive endurance in terms of 'total bytes written' (TBW). E.g. from that article a Crucial C400 SSD is rated at 72TB TBW. Do any scripts/tools exist under the Linux ecosystem to help us measure TBW? (and then make a more educated decision on the feasibility of using SSD drives)
Comment: Take a look at https://serverfault.com/q/995084/34560, I am trying to figure out the same thing.
Answer: Another possibility is to look at /proc/diskstats. It's not persistent across reboots, but it has data for every block device. Probably most interesting to you is field 10, which contains the total number of sectors written. On a system with scsi disks with a sector size of 512 bytes, you could run
awk '/sd/ {print $3"\t"$10 / 2 / 1024}' /proc/diskstats
to see how many megabytes were written to each device. The output will look like

sda   728.759
  sda1    79.0908
  sda2    649.668
Comment: Sector size could be found by running command #cat /sys/block/sda/queue/hw_sector_size
Comment: @Antonio thanks! I'm not sure when that was added. It looks like it is in 3.2 but not 2.6.18.
Comment: @sciurus could you explain the math behind your calculations please ? You're talking about the size of the sector = 512 but your calculations are dividing the read value with 2/1024
Comment: @gyre Field 10 contains the number of 0.5 kilobyte sectors written. I divide that by 2 to get the number of kilobytes written. I then divide that by 1024 to convert to megabytes.
Comment: @antonio That *does* show the sector size being used with the underlying hardware, but afaict from the kernel source, iostat source, and empirical tests, the "sectors" number in /proc/diskstats *always* refers to 512 bytes, even when `hw_sector_size` is different (at least since the 2.4 series). See `block/cfq-iosched.c`, particularly `cfqg_stats_update_dispatch()`.
Answer: I was struggling with the same problem on my notebook, but as I reboot it pretty much on a daily basis, the accepted answer wasn't helpful.
I have a Samsung mSATA SSD, which happens to have the SMART attribute #241 Total_LBAs_Written. According to the official documentation,

To calculate the total size (in Bytes), multiply the raw value of this attribute by 512B.

So the following command gives me the total TB written on my SSD disk (sdb)
sudo smartctl -A /dev/sdb | awk '/^241/ { print "TBW: "($10 * 512) * 1.0e-12, "TB" } '

As it also works on my HDD, I assume that it should work on pretty much every modern hard disk.
Comment: No, this only exists on certain models of SSD drives. It is not universal.
Comment: I wanted to point out that your equation actually produces a number that is off it would be more accurate as: `sudo smartctl -A /dev/sda1 |  awk '/^241/ { print "TBW: "($10 * 512) * 1.0e-12, "TB"  }'`.
Comment: My Intel SSD has the same attribute but it's called `Host_Writes_32MiB`. Also there is Attribute 249 `NAND_Writes_1GiB`. So be aware that on each SSD this seems to be different (e.g. a mSATA Intel SSD of mine does not have those attributes)
Comment: On my Intel SSD Pro 5400s (SATA) the `Total_LBAs_Written` is specified in GBs!
Couldn't make any sense of the low `4714` smart was showing. But looking in the Intel SSD Toolbox in Windows showed it was in GB.
Answer: You can see how much data has been written to an ext4 filesystem by looking in /sys/fs/ext4/$DEVICE/lifetime_write_kbytes.
Comment: @symcbean - with present-day flash devices, this is largely a non-issue. They all have wear-leveling routines built into their on board controllers.
Comment: @symcbean - There are two kinds of flash devices. Memory Technology Devices (or MTDs) present a direct interface to the flash memory. These are typically found in embedded devices and are what filesystem like JFFS2 are designed for. The other kind of flash device hides the flash memory behind a Flash Translation Later (FTL) so that it looks like a regular block device. This is how consumer technology like SSDs, usb sticks, and memory cards are implemented. Filesystems like JFFS2 aren't appropriate for these; instead, you have to use filesystems like ext4 that are designed for block devices.
Comment: BEWARE: The ext4 lifetime_write_kbytes and session_write_kbytes are not representative of SSD memory cell writes. I've seen one system report 15TB for ext4 lifetime_write_kbytes, while the SSD itself reported only 1TB via SMART attribute 241.

I suspect ext4 might be adding the entire size of the filesystem's free space to those statistics every time fstrim runs, even though the SSD controller obviously wouldn't repeatedly erase all those available blocks if they hadn't been touched since the last erase. tune2fs -l output appears to be similarly misleading.
Comment: That's a cool feature I didn't know about! A shame most of our systems are running ext3 and also some raw LVM partitions for VMs :)
Comment: ext3 (and to a slightly lesser extent) ext4 are not designed for writing to flash. The failure will occur depending on the number of times a location is written - and with conventional filesystems, hotspots develop very rapidly. The figures cited by manufacturers are very misleading since they assume an even spread of writes. There are filesystems - such as JFFS2 - specifically designed to extend the life of your SSDs.
Comment: @ErikA - I assumed the same. The flash controller should perform wear-levelling which would make the "total bytes written" metric a useful guideline :) (or so I hope!)
Comment: Is there any equivalent of this for Btrfs?
Answer: For my KINGSTON SEDC400S37480G, under Ubuntu Server 14.04, I use the following script to monitor TBW. I run it from cron once every day.
The script outputs to a log file.
You need calc for it to work.
Install calc using:
apt-get install apcalc

Script content:
echo "*** $(date -R) ***" >> /scripts/tbw/log.txt
tbw=$(cat /sys/fs/ext4/sda1/lifetime_write_kbytes)
TB=1000000000
echo TB written to sda1: >> /scripts/tbw/log.txt | calc $tbw / $TB >> /scripts/tbw/log.txt

Will output:
*** Thu, 20 Jul 2017 03:02:51 +0300 ***
TB written to sda1:
    3.062138442

Comment: Instead of calc, one could use [GNU bc](https://www.gnu.org/software/bc/)
Answer: You can try iostat. It gives you statistics related to IO and CPU usage. Have a look at the manual man iostat.
Comment: I suppose that could work but I was hoping there was something higher-level available that could provide cumulative byte totals :)
Answer: Try this:
# sg_logs -a /dev/sdX
...
Write error counter page  [0x2]
  Errors corrected without substantial delay = 0
  Errors corrected with possible delays = 0
  Total rewrites or rereads = 0
  Total errors corrected = 0
  Total times correction algorithm processed = 539240
  Total bytes processed = 240417511616512  <<<<<< THIS IS WHAT YOU WANT
  Total uncorrected errors = 0

And it provides lots of other great info, including some vendor-specific bits:
...

HGST/WDC miscellaneous page [0x37]
  Power on hours = 58696
  Total Bytes Read = 2147606791815168
  Total Bytes Written = 240417511616512
  Max Drive Temp (Celsius) = 47
  GList Size = 0
  Number of Information Exceptions = 0
  MED EXC = 0
  HDW EXC = 0
  Total Read Commands = 10282573568
  Total Write Commands = 658305184
  Flash Correction Count = 0


Relationship properties in 'Oracle SQL Developer Data Modeler'

Question: I have four questions regarding to 'SQL Language' and 'Oracle SQL Developer Data Modeler':

What is the meaning of source optional or target optional in 'Oracle SQL Developer Data Modeler' relationships?

I it something related to'Ordinality' of the relationship?
Actually I make two different logical models. In the first one the source is optional, while in the second one the source is NOT optional.
But the Generated DDL files for both of them are them same. Why?

Why when we make a 1:N relationship, 'Identifying' in logical models, then the 'target optional' check box becomes DISABLED??
Why an M:N relationship can not be 'identifying' e.g. in M:N relationships the identifying check box is disabled?
What does 'in Arc' check box means in relation properties window?
Answer:
In 1:N relationship, the meaning of 'target optional' is that the corresponding attribute can be NULL (for example, a user exists without any subscriptions). I can't understand what the 'source optional' is in a 1:N relationship, in a relational model. However, in a ER-model, a source can be optional. Why not? Why can't you forbid a citizen to exist without a passport, for example? But I'm sure it can't be implemented in (forward engineered into) a pure relational model. However, it may be forward-engineered into some constraints (triggers, for example). I haven't ever tried that.
'Identifying' actually means the foreign key (in the target) is a part of the primary key, so it can't be NULL. However, anyone decide to use surrogate keys instead, I think.
In a ER-model, the term 'Identifying relationship' isn't applicable for M:N relationships. At the worst, an M:N relationship can be treated as always-identifying. It may be confusing, because, in the corresponding relational model, an M:N will always be a table with two foreign keys, and if you imagine them like that then an M:N is always identifying for both foreign keys, but, of course, in a relational model, neither 'identifying' nor 'relationship' exist.
You can declare a super type for an entity (so it appears in a super type's rectangle and as well can or can not inherit its attributes). When you create a relationship from a super type to another entity, if the 'subtree generation' is set to 'table per child' for the source entity, the relation is forward-engineered into an arc. The arc means creation of foreign keys on the target table (one per the source's child type) and a constraint for each of the keys allowing non-null for only one of them.


Add default_value to a name field in a .yml file

Question: I am using the migrate source CSV module. I have a few records that do not have the Contact field set or its value is null; the migration fails for this reason. I tried using the default_value plugin that ships with core, but I keep getting the following error.

A colon cannot be used in an unquoted mapping value at line 42 (near default_value: 'Full Name').

process:
  uid: EIN
  field_contractor_name: CONTACT
  name: CONTACT
  -
  plugin: default_value
  default_value: 'Full Name'

How do I get a default value added to that field when a value is not present in the record?
Answer: The correct YAML to use is the following one.
process:
  uid: EIN
  field_contractor_name:
    -
      plugin: get
      source: CONTACT
    -
      plugin: default_value
      default_value: 'Full Name'


Installling fails with no error messages

Question: I installed Drupal 7 on linuxMint 17.1 localhost using the install wizard. Submitting the database configuration page leads to a white screen and nothing else happens.
Looking at the database I could see some data though.
Can anyone help me to fix it?
Answer: This is a typical white screen of death issue, ways to debug it are described here on drupal.org
Answer: Try deleting the Drupal folder and download it again. Don't forget to drop and create or truncate the DB.
Comment: You're welcome! Hope everything's going fine.


angular config block not being called

Question: The code inside my angularjs config block is not getting executed. I have already checked the similar questions on stackoverflow and nothing helped me. I have already checked the 2 possible errors.
1)Missing ng-app in html.
2)Overriding of module.
I am not sure what's going wrong. I can see that the breakpoint is going to this line but it doesn't go inside this block. I also don't see any error on the console. It just silently ignores it. Even if I change $locationProvider to $locationProvider1 , it doesn't give any error.
myLittleApp .config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {

index.html

app.js
'use strict';
var angular = require('angular');

require('angular-ui-router');

require('angular-ui-bootstrap');

var myLittleApp = angular.module('littleapp', [
    'ui.router',
    'ui.bootstrap',
   require('./modules/firm').name
]);

myLittleApp .config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
console.log('test');
}]);

Comment: Just a thought, Are you sure `require('./modules/firm').name` is working correctly? Not sure, but I'd expect .config blocks to evaluate in the order of their dependencies (so that the config block for `littleapp` wouldn't run before the block for `./modules/firm`). What happens if you remove that require?
Comment: I tried that too. no luck. I can see that it's excecuting this code from angularjs library.
Comment: if (isUndefined(event.immediatePropagationStopped)) {
      var originalStopImmediatePropagation = event.stopImmediatePropagation;
      event.stopImmediatePropagation = function() {
        event.immediatePropagationStopped = true;

        if (event.stopPropagation) {
          event.stopPropagation();
        }

        if (originalStopImmediatePropagation) {
          originalStopImmediatePropagation.call(event);
        }
      };
Answer: I was able to resolve this issue on my own. The issue was with ng-app in html file. It should be an attribute of body tag instead of html tag.
wrong

Correct

Comment: not true, you can use ng-app in the html element too.  Check out this plunkr to see https://plnkr.co/edit/tpl:CR2TtS1zz9wFGgsl5z2c?p=preview. Just to know, what is "no-js"?
Answer: As per the code you provided, Your code seems to have a space between your application variable name and the config function. I removed it. Try it again. I also moved the firmModule outside the app module. One more thing, try following John Papas Style Guide.
Also can you share the .modules/firm code to see how you are exporting the module?
var angular = require('angular');

require('angular-ui-router');

require('angular-ui-bootstrap');

var firmModule = require('./modules/firm').name;

var myLittleApp = angular.module('littleapp', [
    'ui.router',
    'ui.bootstrap',
    firmModule
]);

myLittleApp.config(['$routeProvider', '$locationProvider',  function($routeProvider, $locationProvider) {
    console.log('test');
}]);

Comment: btinoco - that space got added while copying code here. It doesn't exist in my environment. I have also commented the .modules/firm code. It still doesn't work. Thanks for the pointer to papas style guide.

angular config block not being called


Finite solvable subgroup in $GL_2(\mathbb{C})$ which is not contained in Borel subgroup

Question: What is the example of finite solvable subgroup in $GL_2(\mathbb{C})$ which is not contained in any Borel subgroup?
Comment: Any thoughts you might like to add to the question?
Comment: Any irreducible finite solvable subgroup of ${\rm GL}(2,\mathbb{C})$ will do. These include all finite dihedral groups with $6$ or more elements.
Answer: You have the standard embedding of $Q_8\to GL_2(\mathbb{C})$ given by the action of the standard basis on $\mathbb{H}=\mathbb{C}^2$. More expliticly, these are given by the Pauli matrices. These cannot be put into an upper triangular form. This is exactly what you want, since all Borel groups are conjugate, and the cannonical one is the upper triangular matrices, so we are asking if we can put all the Quaterions in diagonal form. I recall the presentation $\langle l, n_i; i\le 3|n_i^2=n_1n_2n_3=l, l^2=1\rangle$. The condition $l^2=1$, and $l\neq 1$, implies that $l=-I$ or $l_{11}=-l_{22}$, and $l_{ii}^2=1$. Regardless, this means that either $l_{11}=-1$ or $l_{22}=-1$, denoted $h$. The relations $n_i^2=l$ them implies $n_{i, h,h}^2=-1$. But $n_{1, h,h}n_{2, h,h}n_{3, h,h}=(n_1n_2n_3)_{h,h}=l_{h,h}=-1$. This is impossible, since $n_{i,h,h}=\pm i$. There is probably a better way to do this. Oh, and this is solvable by Burnside lemma or $0\to \mathbb{Z}/(2)\to Q_{8}\to \mathbb{Z}/(4)\to 0$.
Comment: Thank you a lot. I have thought a little bit and now it seems that the simplest example is just $A_4$.