ColdFusion 9's site-wide error handler not working

Question: I have an error page,anyError.cfm, that looks like this
<!DOCTYPE html>

        <title>Error</title>

An error has occurred.

In the CF web admin under Server Settings > Settings > Site-wide Error Handler I enter \anyError.cfm. When I navigate to http://localhost:8500/some-url-that-doesnt-exist I still get the default error page. So my question, how do I get a custom site-wide error page using CF9? It doesn't necessarily have to be through the web admin.
Edit:
Comment: Where are you putting theanyError.cfm page?
Answer: Try using the value "anyError.cfm" instead of "\anyError.cfm" in the site-wide error handler setting.
Update, after seeing your update to your question I see now that you are generating a 404. Which is not for the site-wide error handler, it is for the missing template handler setting right next to it.
Try using a variable that doesn't exist instead to generate an error that will cause the site-wide error handler to display.
Comment: try it with a frontslash then, backslashes are evil
Comment: The web admin won't let me update without the slash. The error I get is `The file specified as the site wide error handler does not exist. The default error handler will be used until a replacement is created.`.
Comment: No dice, I added a screen cap of the error I am seeing (where /s is a non existent directory).
Comment: ahhh yes I see now, thanks, I realize that my question was stated incorrectly. I thought the sitewide error handler would pick up on the 404's, so +1 & A. However if you don't mind answering how I can get anyError.cfm to catch the 404's I would be very grateful, I put the same information, `/anyError.cfm`, in the `Missing Template Handler` box and I still get the 404.
Comment: I believe the missing template handler needs an absolute path. Like c:\coldfusion9\wwwroot\anyError.cfm
Comment: let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/14549/discussion-between-johnthexiii-and-jason-dean)


How to conditionally display field contents in Views

Question: I want to edit my View so that it only displays a certain contents if some field in my content type had been set. I installed the Views PHP plugin, but it's currently not producing the desired results.
This is the current example I have - using the custom php field, where field_link_to_page is a checkbox field in my content type that decides what contents are to be displayed:
<?php
// Field is configured to return "1" if it's checked, or "0" if it's unchecked.
if ($row->field_link_to_page =="1") {
    echo $row->body."
[NID]
<?php
echo "\">more...";
}
else
{
    echo $row->body;
}
?>

Removing this code, and doing a var_dump() on the field, returns something like this:
object(stdClass)#250 (7) { ["field_year"]=> string(3) "113" ["field_month"]=>
string(3) "113" ["field_day"]=> string(3) "113" ["title"]=> string(73)
"Forecast opening day for Talking Rock Golf Course (conditions permitting)"
["body"]=> string(3) "113" ["field_link_to_page"]=> string(3) "113" ["php"]=>
NULL } 113

which is confusing because the contents get rendered nicely by Views but here it only looks like it's handles to something (113). How can I render the contents correctly in php?
Comment: You may be getting `113` because of the way your code snippet is written. You should probably take out the [NID] and see what happens - sort of like I suggest doing in my response. `113` is just probably your node id being printed out on each field - repeatedly.
Answer: I have figured out a way to do what I want without the Views PHP module:
I added the link to my fields as well and rewrite the link token in my checkbox field (field_link_to_page) only if it isn't empty. That seems to have worked out well.
Comment: Hmm. Still doesn't really answer your question - only provide an alternative. Somebody else trying to do what you were doing with the Views plugin might run into this, and become frustrated because they don't really have an answer. It might be good for you to try it out with the Views plugin anyways - or at least improve your answer with links to and examples. Cheers.
Answer: Views has an option to see the value 0 as an empty result. And you can disable rewriting for empty results (thus 0 value too).
Then you can use a simple rewrite like [body]more.
I do think you don't need php here to accomplish what you want.
Answer: The second line of code in your example has a typo, you're missing a semicolon. Also, this number you're doing here feels squishy:
<?php
// code ...
?>[NID]<?php
// code ...
?>

Is that even working? Wouldn't it be better to just var_dump() the whole $row object, find where the node nid for the current row is present, and create a link using l()?
You should always use the Drupal API when creating links, unless for a very specific reason.
Comment: I did a var_dump() but it gives me something like what I've posted above under `This code outputs something like`
Comment: I edited the answer to reflect that, it a little bit unclear before ;)


Em Data science e Programação, o que significa a expressão "Pipeline"?

Question: O que significa a expressão "Pipeline"?
Comment: Um cadeia ordenada de processos cujo a saída de um processo é a entrada do próximo.
Comment: Está correto, vim só complementar: https://en.wikipedia.org/wiki/Pipeline_(computing)
Answer: Um pipeline em ciência de dados é o conjunto de processos que convertem dados brutos em respostas acionáveis a questões relacionadas a negócios.

Automatizam o fluxo de dados da origem ao destino, fornecendo, em última análise, insights para a tomada de decisões dos negócios.
Automatizam os processos de validação de dados; extrair, transformar, carregar (ETL); modelagem e machine learning; revisão; e output para um data warehouse ou plataforma de visualização de dados.
Eliminam muitos processos manuais sujeitos a erros envolvidos no transporte de dados entre locais que podem causar latência de dados e gargalos.


How to switch to cuda7.5 after install tensorflow using .whl file?

Question: I have installed tensorflow using the 1.0.1 whl file.
When I run the command python -c 'import tensorflow' an import error says cannot open shared object file libcublas.so8.0.
However I have only cuda7.5 in my machine.
So how can I change tensorflow to use cuda7.5 in my machine??
Comment: You probably can't
Comment: can I set tensorflow to use cuda7.5 if I re-install it?
Answer: As per the tensorflow website:

The GPU version works best with Cuda Toolkit 8.0 and cuDNN v5.1. Other
  versions are supported (Cuda toolkit >= 7.0 and cuDNN >= v3) only when
  installing from sources. Please see Cuda installation for details. For
  Mac OS X, please see Setup GPU for Mac.

So, tensorflow will not work with cuda 7.5 when installed with the whl file.


Traefik 404 on https://www

Question: I'm using this config:
<code>version: "3.3"
services:
  traefik:
    command:
      # Get Docker as the provider
      - "--providers.docker=true"
      # Avoid that all containers are exposed
      - "--providers.docker.exposedbydefault=false"
      # Settle the ports for the entry points
      - "--entrypoints.web.address=:80"
      - "--entrypoints.web-secure.address=:443"
      # Settle the autentification method to http challenge
      - "--certificatesresolvers.myhttpchallenge.acme.httpchallenge=true"
      - "--certificatesresolvers.myhttpchallenge.acme.httpchallenge.entrypoint=web"
      # Uncomment this to get a fake certificate when testing
      #- "--certificatesresolvers.myhttpchallenge.acme.caserver=https://acme-staging-v02.api.letsencrypt.org/directory"
      # Settle letsencrypt as the certificate provider
      - "--certificatesresolvers.myhttpchallenge.acme.email=___________________
      - "--certificatesresolvers.myhttpchallenge.acme.storage=/letsencrypt/acme.json"
  mysite:
    labels:
      # The labels are usefull for Traefik only
      - "traefik.enable=true"
      - "traefik.docker.network=traefik"
      # Get the routes from http
      - "traefik.http.routers.mysite.rule=Host(mysite.com, www.mysite.com)"
      - "traefik.http.routers.mysite.entrypoints=web"
      # Redirect these routes to https
      - "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https"
      - "traefik.http.routers.mysite.middlewares=redirect-to-https@docker"
      # Get the routes from https
      - "traefik.http.routers.mysite-secured.rule=Host(mysite.com, www.mysite.com)"
      - "traefik.http.routers.mysite-secured.entrypoints=web-secure"
      # Apply autentificiation with http challenge
      - "traefik.http.routers.mysite-secured.tls=true"
      - "traefik.http.routers.mysite-secured.tls.certresolver=myhttpchallenge"
</code>
Everything works except https://www. I get an SSL error, then when I click proceed anyway, I get a error from traefik, 404 page not found. http://, https://, http://www all work, redirect to https://. But https://www does not work.
I tried a lot of suggestions, the regex middleware to no success. It's just the exact same results.
Comment: Clearly the route is not working for https://www. Have you tried running in DEBUG mode or accessing the treafik dashboard ? Where are you running website ?
Answer: I needed to add backticks around the site name in the Host():
<code>- "traefik.http.routers.mysite.rule=Host(`mysite.com`, `www.mysite.com`)"
- "traefik.http.routers.mysite-secured.rule=Host(`mysite.com`, `www.mysite.com`)"
</code>
Also, my deploy was wrong. Sometimes I was uploading the file ad-hoc, then manually running a post-receive hook which overwrites with an old version.

Traefik 404 on https://www


Two variable induction problem

Question: I managed to prove $(1)$ of the following problem, but am completely stuck on $(2)$:

My attempts:
Let $S(k)$ be the statement
$$\sum_{r=1}^{n} r^k = \frac{n^{k + 1}}{k + 1} + E_{k}(n)$$
It is clear that $S(1)$ holds (LHS is sum of a simple arithmetic progression).
Now suppose $S(t)$ holds for some positive integer $t$.
I tried doing several things for the second induction step, two of which seemed to be promising:

Expressing $\sum_{r=1}^{t} r^k$ from $(1)$, which turned out to be a sum of sums and that was beyond my reach.
Multiplying both sides of the equation to obtain
$$t\frac{k+1}{k+2} \sum_{r=1}^{t} r^k = \frac{t^{k + 2}}{k + 2} + E_{k+1}(t)$$
From $(1)$ I deduced

$$\sum_{r=1}^{t} r^{k + 1} + \sum_{r=1}^{t}F_{k}(t) = \frac{t^{k + 2}}{k + 2} + G_{k+1}(t)$$
$$\sum_{r=1}^{t} r^{k + 1} = \frac{t^{k + 2}}{k + 2} + H_{k+1}(t)$$
... and I would really like to say that $S(t)$ implies that (what appears to be $S(t+1)$), but I am not okay with most of the steps I "performed".
Does anyone have any hint or explanation that would help me battle with this second induction?
Comment: To deal with $\sum_{r = 1}^n r^k$, look at $$\sum_{r = 0}^{n} \bigl((r+1)^{k+1} - r^{k+1}\bigr).$$ Use a) telescoping, b) binomial expansion.
Answer: This method requires using complete, or strong induction, but I think it's probably what the question has in mind.
We have
$$ \sum_{r=1}^n r(r+1) \cdots (r+k-1) = \sum_{r=1}^n (r^k + P_1(r)), $$
where $P_1(r)= \sum_{\ell=0}^{k-1}a_{\ell}r^{\ell}$ is a polynomial with degree at most $k-1$. Now notice that the first part gives you
$$ \sum_{r=1}^n r(r+1) \cdots (r+k-1) = \frac{n^{k+1}}{k+1} + P_2(n), $$
where $P_2$ is a polynomial with degree at most $k$.
Now, by the induction hypothesis that $S(\ell)$ holds for $\ell < k $,
$$\sum_{r=1}^n P_1(r) = \sum_{\ell=0}^{k-1} a_{\ell} \left(\sum_{r=1}^n r^{\ell} \right)$$
is a finite sum of polynomials of degree at most $k$, and so is a polynomial $P_3(n)$ of degree at most $k$. Hence
$$ \sum_{r=1}^n r^k = \frac{n^{k+1}}{k+1} + P_2(n)-P_3(n), $$
and $P_2(n)-P_3(n)$ is a polynomial of degree at most $k$, as required.
Comment: Point is, the induction hypothesis $S(\ell)$ tells you that $\sum_{r=1}^n r^{\ell}$ is a polynomial of degree $\ell+1$ (it also tells you the form of the first term, but we don't need this for this part of the proof). Thus the finite linear combination of them in $\sum_{r=1}^n P_1(r) $ is a polynomial of degree $k$, which is what you need for the conclusion.
Comment: Thank you very much for your answer. I have a bit of a problem to see how the induction hypothesis (that $S(ℓ)$ holds for $ℓ<k$) implies the third equation. I mean, since we know that $P_1(r)=\sum^{k−1}_{ℓ=0}a_ℓ r^ℓ$ the sum $\sum^{n}_{r=1}P_1(r)$ can be found without additional information, or? (I assume that $S(k): \sum_{r=1}^{n} r^k = \frac{n^{k + 1}}{k + 1} + E_{k}(n)$). Truth is, I am having difficulties with recognizing the line of thought here.

Two variable induction problem


Timer for ajax requests

Question: I'm running a few ajax requests and I want to time them.
How can I get the number of seconds elapsed since the 1st request?
Comment: Have you done anything? Have you even try? It is not give me the code, you know!
Answer: Create a Date object when you set the first one. Create a new one whenever you want to have a point to compare to that start time. Then compare them.

Timer for ajax requests


double pointers error in C when compiling error when using void as well

Question: I'm new to C and im currently learning about pointers.
I'm  not sure why I am getting an error with the following sections of code in regards to pointers :
char ch;
char** pointer;
pointer = &ch;

and
int function1(void)
{
  return 42.0;
}

void function2(void)
{
  void (*pointer)(int);
  pointer = &function1;
  ...
}

Any help will be appreciated :)
Comment: On the first section, you shouldn't have a double pointer, just a simple pointer
Comment: `void (*pointer)(int);` should be `int (*pointer)(void);`
Comment: Please take a bit time to follow simple rules when asking questions. If there are errors or warnigns, then show us. Show the exact message and the exact code.
Comment: oh yeah the double pointer im very new to that, thank you :) how do i fix the second one
Comment: The second one should be `int(*pointer)(void)`
Comment: sorry @Gerhardh im new to stack overflow :) just getting the hang of it. will do that next time of course :)
Answer: The very first problem is that you are using a double pointer in char** pointer ,as you are not storing the address of some other pointer so you should use char *pointer instead.
Then your function1 has return type as int but you are returning a float value ,although it won't give you any error but it can create some logical issues in your program,so better to properly write the return type in function definition and its prototype.
Then the next problem is in the function2,your function1 returns int but does not take any arguments but your function pointer return void and take int ,so you should better modify this to
int (*pointer)(void);

and then store the address of function1 in pointer ,it will work fine.
Answer: * is a single pointer and ** is a pointer to pointer.
So instead of
char** pointer;

It should be:
char* pointer;

In the second case, the function pointer prototype is not matching the prototype of the function it is pointing to.
So instead of
void (*pointer)(int);

it should be:
int (*pointer)(void);

Answer: you second section have some mistakes
you function1() return int and not take args
but your fucntion ptr return void and take int
so change it to:
int (*pointer)(void);

pointer = &function1;


Existence/Limit of Improper Integral

Question: I got the improper integral:
$$ \int_0^\infty \frac{x^2}{x^4+1} \, dx $$
On one hand one could of course just evaluate the integral and then apply limits.
However, it's not always practical to find an antiderivative.
I got a hint that one can trace back improper integrals to sequences and thus just calculate the limit of a sequence which is way easier, could someone explain to me how this works or link me to some theorems?
Thanks.
Comment: This looks like a standard candidate for evaluation by contour integration.
Comment: Are you actually trying to evaluate it or just trying to show that it has a finite value?
Comment: I just need to show it has a finite value, and i haven't had contour integration sorr :/
Answer: The value of this integral is finite because $f(x):={ \frac { x^ 2 }{ x^ 4+1 }  }$ is continuous in $\mathbb{R}$ and $f(x)\sim 1/x^2$ as $x$ goes to $\pm\infty$.
It can be evaluated by using Residue Theorem:
$$\int _{ 0 }^{ \infty  }f(x)dx=
\frac{1}{2}\int _{ -\infty }^{ \infty  }f(x)dx=
\pi i(\mbox{Res}(f,e^{i\pi/4})+\mbox{Res}(f,e^{i3\pi/4}))\\=
\pi i\left(\frac{1}{4e^{i\pi/4}}+\frac{1}{4ie^{i\pi/4}}\right)=
\frac{\pi}{2\sqrt{2}}.$$
Alternatively, you can integrate $f$ by noting that
$$x^4+1 =(x^2+1)^2 - (\sqrt2x)^2 = (x^2+\sqrt2x+1)(x^2-\sqrt2x+1)$$
Then, by using partial fraction decomposition, we get
$$f(x)=\frac{1}{2\sqrt{2}}\left(\frac{x}{x^2-\sqrt2x+1}
-\frac{x}{x^2+\sqrt2x+1}\right).$$
Comment: Sorry I'm not familiar with complexe Analysis yet
Comment: Then try the second approach
Comment: I have already tried the second approch before but its fairly long, and i think i formulated my question wrong i only need to show the existence :)
Comment: @johnka For the convergence my first two lines suffice.
Answer: Based on the overall nature of your post (and the comment you left that I saw as I finished this), it sounds like you're trying to show this integral actually has a finite value and you're not necessarily trying to find what that value is.
Since the integrand is $\dfrac{x^2}{x^4+1}$, then we know that as $x$ gets really super huge (i.e., as $x \to +\infty$), the integrand "behaves like" $\dfrac{x^2}{x^4} = \dfrac1{x^2}$.  And we know that $\displaystyle \int_1^{+\infty} \dfrac1{x^2} \, dx$ has a finite value.  Actually we can calculate it directly, and it's $1$.  (This does not mean the original integral is also $1$.  We can't conclude anything about the original integral yet!)
So, because our integrand $\dfrac{x^2}{x^4+1}$ "behaves like" an integrand that has a finite integral over $[1,+\infty)$, we expect that our integral of $\dfrac{x^2}{x^4+1}$ over $[0,+\infty)$ is also finite.
To prove it, we can just use the direct comparison test.  On $[1, +\infty)$, we know that $x^4 \le x^4 + 1$.  Divide both sides by $x^2(x^4+1)$ to conclude that $\dfrac{x^2}{x^4+1} \le \dfrac1{x^2}$.  Since $\displaystyle \int_1^{+\infty} \dfrac1{x^2} \, dx$ is finite, then so is $\displaystyle \int_0^{+\infty} \dfrac{x^2}{x^4+1} \, dx$.
Note 1:  Technically the above directly implies that $\displaystyle \int_1^{+\infty} \dfrac{x^2}{x^4+1} \, dx$ is finite, but $\displaystyle \int_0^1 \dfrac{x^2}{x^4+1} \, dx$ is clearly finite and so we conclude $\displaystyle \int_0^1 \dfrac{x^2}{x^4+1} \, dx + \displaystyle \int_1^{+\infty} \dfrac{x^2}{x^4+1} \, dx = \displaystyle \int_0^{+\infty} \dfrac{x^2}{x^4+1} \, dx$ is finite.
Note 2:  For the comparison test for integrals to work, you also need to note that $\dfrac{x^2}{x^4+1} \ge 0$ on $[0,+\infty)$ (technically you just need on $[1,+\infty)$).  This is obviously true, but to be thorough it really should be at least mentioned.
Comment: Thanks, good answer. Could you argue with f is continious on the Intervall (0,1) and therefor you can integrate it Thus watching only the intervall (1,INF) because we know that the statement is true in the other fraction?
Comment: @johnka, yes, since $\dfrac{x^2}{x^4+1}$ is continuous on $[0,1]$, it has a maximum value on $[0,1]$.  Say this maximum value is $M$.  Then $\displaystyle \int_0^1 \dfrac{x^2}{x^4+1} \, dx \le M(1-0) = M$, and so all we really need to worry about is whether or not $\displaystyle \int_1^{+\infty} \dfrac{x^2}{x^4+1} \, dx$ is finite, and it is by the integral comparison test.
Answer: $$I=\int_{0}^{1}\frac{x^2}{x^4+1}\,dx + \int_{1}^{+\infty}\frac{x^2}{x^4+1}\,dx = \int_{0}^{1}\left(\frac{x^2}{x^4+1}+\frac{1}{x^4+1}\right)\,dx \tag{1}$$
leads to:
$$ I = \int_{0}^{1}\frac{1+x^2-x^4-x^6}{1-x^8}\,dx = \sum_{k\geq 0}\left(\frac{1}{8k+1}+\frac{1}{8k+3}-\frac{1}{8k+5}-\frac{1}{8k+7}\right)\tag{2}$$
but due to the digamma reflection formula we have:
$$ \sum_{k\geq 0}\left(\frac{1}{8k+1}-\frac{1}{8k+7}\right)=\frac{\pi}{8}\cot\frac{\pi}{8}, \quad \sum_{k\geq 0}\left(\frac{1}{8k+3}-\frac{1}{8k+5}\right)=\frac{\pi}{8}\cot\frac{3\pi}{8}\tag{3}$$
hence it follows that:
$$ I = \frac{\pi}{8}\left[\cot\frac{\pi}{8}+\cot\frac{3\pi}{8}\right]=\color{red}{\frac{\pi}{2\sqrt{2}}}.\tag{4}$$
The same can be achieved by partial fraction decomposition, since $x^4+1=\Phi_8(x)=(x^2-x\sqrt{2}+1)(x^2+x\sqrt{2}+1)$.
Still another way is to apply Glasser's master theorem:
$$ \int_{0}^{+\infty}\frac{dx}{x^2+\frac{1}{x^2}} = \int_{0}^{+\infty}\frac{dx}{\left(x-\frac{1}{x}\right)^2+2}=\int_{0}^{+\infty}\frac{dx}{x^2+2}.\tag{5} $$
Answer: Note that $$I=\int_{0}^{\infty}\frac{x^{2}}{x^{4}+1}dx\stackrel{x^{4}=u}{=}\frac{1}{4}\int_{0}^{\infty}\frac{u^{-1/4}}{u+1}du$$ and now we can see that this is one of the form of the Beta function. So $$I=\frac{B\left(\frac{3}{4},\frac{1}{4}\right)}{4}=\color{red}{\frac{\pi}{2\sqrt{2}}}.$$
Answer: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$

Lets $\ds{\mc{C}_{R}}$ a quarter circumference in the first quadrant with radius $\ds{R > 1}$ and vertex at the origin. Such contour 'encloses' a single pole $\ds{p \equiv \expo{\ic\pi/4}}$.

\begin{align}
\Re\oint_{\mc{C}_{R}}{z^{2} \over z^{4} + 1}\,\dd z & =
\Re\pars{2\pi\ic\,\lim_{z \to p}{\bracks{z - p}z^{2} \over z^{4} - 1}} =
-2\pi\,\Im\pars{3p^{2} - 2p^{2} \over 4p^{3}}
\\[5mm] & =
-\,{1 \over 2}\,\pi\,\Im\pars{1 \over p} =
-\,{1 \over 2}\,\pi\,\Im\pars{\expo{-\ic\pi/4}} =
{\root{2} \over 4}\,\pi\label{1}\tag{1}
\\[1cm]
\Re\oint_{\mc{C}_{R}}{z^{2} \over z^{4} + 1}\,\dd z & =
\int_{0}^{R}{x^{2} \over x^{4} + 1}\,\dd x
\\[3mm] & +\
\underbrace{\Re\pars{\int_{0}^{\pi/2}{R^{2}\expo{2\ic\theta} \over R^{4}\expo{4\ic\theta} + 1}\,R\expo{\ic\theta}\ic\,\dd\theta}}
_{\ds{\to\ 0\ \mrm{as}\ R\ \to\ \infty}}\ +\
\underbrace{%
\Re\pars{\int_{R}^{0}{-y^{2} \over y^{4} + 1}\,\ic\,\dd y}}_{\ds{=\ 0}}
\label{2}\tag{2}
\end{align}

\eqref{1} and \eqref{2} lead, in the $\ds{R \to \infty}$ limit, to

$$
\bbx{\int_{0}^{\infty}{x^{2} \over x^{4} + 1}\,\dd x = {\root{2} \over 4}\,\pi}
$$

ANOTHER METHOD:
\begin{align}
\int_{0}^{\infty}{x^{2} \over x^{4} + 1}\,\dd x & =
\int_{0}^{\infty}{\dd x \over x^{2} + 1/x^{2}} =
\int_{0}^{\infty}{\dd x \over \pars{x - 1/x}^{2} + 2}
\\[5mm] & =
{1 \over 2}\bracks{%
\int_{0}^{\infty}{\dd x \over \pars{x - 1/x}^{2} + 2} +
\int_{\infty}^{0}{1 \over \pars{1/x - x}^{2} + 2}\pars{-\,{\dd x \over x^{2}}}}
\\[5mm] & =
{1 \over 2}
\int_{0}^{\infty}{1 + 1/x^{2} \over \pars{x - 1/x}^{2} + 2}
\,\dd x \,\,\,\stackrel{t\ =\ x - 1/x}{=}\,\,\,
{1 \over 2}\int_{-\infty}^{\infty}{\dd t \over t^{2} + 2}
\\[5mm] & =
{1 \over \root{2}}\int_{0}^{\infty}{\dd t \over t^{2} + 1} =
{\root{2} \over 2}\,{\pi \over 2} = \bbx{{\root{2} \over 4}\,\pi}
\end{align}

Existence/Limit of Improper Integral


Android set view visibility inside ListAdapter

Question: I have listview with arrayadapter. I want when clicking a button inside list item a specific view in that item (and not in other items) be visibile or invisible.
Heres the code what I'm doing in adapters getView() method:
<code>@Override
public View getView(int position, View convertView, ViewGroup parent) {

    if (convertView == null) {

        convertView = vi.inflate(layoutResourceId, null, false);
        holder = new Holder();
        holder.setShare((ImageView) convertView.findViewById(R.id.share));
        holder.setShareButtons((LinearLayout)convertView.findViewById(R.id.shareButtons));
        convertView.setTag(holder);

    }
    holder = (Holder) convertView.getTag();

    holder.getShare().setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            if(holder.getShareButtons().getVisibility()==View.GONE){
                holder.getShareButtons().setVisibility(View.VISIBLE);

            }
            else{
                holder.getShareButtons().setVisibility(View.GONE);

            }

        }
    });

    return convertView;
}
</code>
But all I'm getting is strange behavior. The onClickListener and setVisibilty methods are called correctly but my view sometimes get visible and sometimes not, and this depend on list scroll positon .
What I'm doing wrong and how should I solve this ?
Answer: WHen a list view is scrolled, the child views are reused and reassigned to new positions.  This is for efficiency, as creating new views is expensive.  However, it puts the burden on the programmer-  on every getView call you must completely reset every value of the view.  So if pressing a button in the child changes the visibility of one of its members, you need to remember what the visibility should be for each numeric position, and in getView you must set the appropriate visibility for every element.
Answer: The holder is meant to keep references to the inner views for performance reasons. It is not related to the data that gets presented in your list - only to the "cells" in your list. You should determine whether stuff is visible or not based on your data.
Answer: Here is a snippet of my custom Adapter which will give you an example on how to react to an item click within the adapter itself:
Functionality: Every row represents a object which can be seen or not seen. Whether it is seen or not, the image is different. Clicking on an item toggles the image on/off.
<code>public class Exampledapter extends ArrayAdapter<CustomObject> {

    private Context mContext;
    private int mLayoutResourceId;
    private ArrayList<CustomObject> mData = null;

    public ExampleAdapter(Context context, int layoutResourceId, ArrayList<CustomObject> data, DataSource datasource) {
        super(context, layoutResourceId, data);
        this.mLayoutResourceId = layoutResourceId;
        this.mContext = context;
        this.mData = data;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        View lRow = convertView;
        ViewHolder holder = null;

        if (lRow == null) {
            LayoutInflater lInflater = ((Activity) mContext).getLayoutInflater();
            lRow = lInflater.inflate(mLayoutResourceId, parent, false);

            holder = new ViewHolder();
            holder.txtTitle = (TextView) lRow.findViewById(R.id.text_);
            holder.imageSeen = (ImageView) lRow.findViewById(R.id.image_toggle);

            lRow.setTag(holder);
        } else {
            holder = (ViewHolder) lRow.getTag();
        }

        holder.imageSeen.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                onListItemClick(position);
            }
        });

        if (mData.get(position).getSeen() == 1) {
            holder.imageSeen.setImageBitmap(mImageSeen);
        } else {
            holder.imageSeen.setImageBitmap(mImageUnseen);
        }

        holder.txtTitle.setText(mData.get(position).getTitle());
        return lRow;
    }

    protected void onListItemClick(int position) {
        if (mData.get(position).isSeen()) {
            mData.get(position).setSeen(0);
        } else {
            mData.get(position).setSeen(1);
        }
        notifyDataSetChanged();
    }

    class ViewHolder {
        TextView txtTitle;
        ImageView imageSeen;
    }
}
</code>


Drush fails "unable to copy" to drush-backups?

Question: When I run $ drush pm-update I receive an "Unable to copy" error.

Unable to copy /mnt/hd0/vhosts/yourwebsite.com/drupal-7.36 to /home/ec2-user/drush-backups/opencall/20150422140414/drupal.               [error]
  Unable to move /mnt/hd0/vhosts/yourwebsite.com/drupal-7.36 to /home/ec2-user/drush-backups/opencall/20150422140414/drupal.               [error]
  Failed to backup project directory /mnt/hd0/vhosts/yourwebsite.com/drupal-7.36 to

Any thoughts? I'm sure it will run if I use sudo but that has other undesirable consequences.
Comment: Drush does run and complete successfully for another site I am running on the same server as another vhost. Permissions on both seem to be the same for both??
Answer: Think I've solved it.
Looks like someone previously ran Drush in the sudo environment and that had the effect of setting permissions to 6226 all over the place.
Updated manually and fixed permissions as I went.
Comment: Check permissions of folders in your Drupal 'sites' directory and subdirectories. Mine were screwed up (set to 6226) everywhere Drush had touched when i stupidly ran is as root. Had to manually fix them all.

It's tricky business so make sure you backup before playing with permissions.
Comment: Where and what did you update manually? I've just set ~/drush-backups to chmod 777 and the error is still happening


how to check if phone exists in firebase auth

Question: hey I try to check if the phone number that the user is insert is exist in my firebase auth
(LoginActivity)
I try this way

String phoneNumber = "+1234567890";

mAuth.fetchSignInMethodsForEmail(phoneNumber)
        .addOnCompleteListener(new OnCompleteListener<SignInMethodQueryResult>() {
            @Override
            public void onComplete(@NonNull Task<SignInMethodQueryResult> task) {
                if (task.isSuccessful()) {
                    SignInMethodQueryResult result = task.getResult();
                    List<String> signInMethods = result.getSignInMethods();
                    if (signInMethods.contains("phone")) {
                        // Phone number is already in use in Firebase Auth
                    } else {
                        // Phone number is not in use in Firebase Auth
                    }
                } else {
                    // An error occurred
                }
            }
        });

and when it comes to this function the debugger jump for it and don't doing anything
.addOnCompleteListener(new OnCompleteListener() {
I try with firebase SDK admin and it also doesn't work
can anyone know how to solve this?
Answer: There are three ways in which you can solve this problem. Two options are on the client, using Java code, and another one using Admin SDK.
Solution 1
When a user signs in for the first time into your app, then save user data in Firestore using a schema that looks like this:
db
|
--- users (collection)
     |
     --- $uid (document)
          |
          --- phoneNumber: "+1234567890"

To check if a user with the +1234567890 already exists, then you have to perform a query that looks like this in Java:
FirebaseFirestore db = FirebaseFirestore.getInstance();
Query queryPhoneNumber = db.collection("users").whereEqualTo("phoneNumber", "+1234567890");
queryPhoneNumber.get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
    @Override
    public void onComplete(@NonNull Task<QuerySnapshot> task) {
        if (task.isSuccessful()) {
            for (QueryDocumentSnapshot document : task.getResult()) {
                if (document.exists()) {
                    Log.d(TAG, "User already exists.");
                } else {
                    Log.d(TAG, "User doesn't exist.");
                }
            }
        } else {
            Log.d(TAG, task.getException().getMessage()); //Never ignore potential errors!
        }
    }
});

Solution 2
Another more elegant and easy solution would be to use Query#count() method:
queryPhoneNumber.count();

If the result is > 0 then it means that the user already exists, otherwise it doesn't exist.
Solution 3
The last solution would be to use a Callable Cloud Function that can be called from your app. Because we use the Admin SDK in Cloud Functions you can call the getUserByPhoneNumber() method. In code it will look like this:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();

exports.checkPhoneNumberExists = functions.https.onCall((data, context) => {
    return admin.auth()
        .getUserByPhoneNumber(data.phoneNumber)
        .then((userRecord) => {
            return { phoneNumber: true }
        })
        .catch((error) => {
            throw new functions.https.HttpsError('invalid-argument', "phoneNumber doesn't exist");
        });

});

Using this approach, there is no need to save user data in Firestore. The Admin SDK will directly query the FirebaseAuth service.
Comment: Hey there. Have you tried one of my solutions above, does one of them work?


topology of normed spaces

Question: Following is a list of problems from an exam for admission into Ph. D program. I have just compiled all previous questions on topological properties of certain subsets of normed linear spaces and i tried to work out . I would be thankful if some one could give a hint on how to proceed in the following problems
1)Consider the space $X = C([0, 1], \mathbb R)$ with its usual 'sup-norm' topology. Let
$S=\{ f \in X:\int_0^1 f(t) \,dt=0 \}$.
Which of the following statements are true?
a. The set $S$ is closed.
b. The set $S$ is connected.
c. The set $S$ is compact.
2)Consider the space $X = C([0, 1], \mathbb R)$ with its usual 'sup-norm' topology. Let
$S = \{f \in X: \int_0^1 f(t) \,dt\neq0 \}$
Which of the following statements  are true?
a. The set $S$ is open.
b. The set $S$ is dense in $X$.
c. The set $S$ is connected.
Comment: The answer to at least one of these depends on whether you're talking about the space of real-valued continuous functions or complex-valued.
Comment: space of real valued continuous functions is considered
Answer: As you asked for hints I will not go into full detail. I assume that $C([0,1])$ refers to the real vector space of the realvalued continuous functions.
Notice that the map $\phi \colon X \to \mathbb{R}$ with $\phi(f) = \int_0^1 f(t) \,\text{d}t$ is linear and continuous, and that for
$$
 S = \{f \in X \mid \phi(f) = 0\}
 \quad\text{and}\quad
 T = \{f \in X \mid \phi(f) \neq 0\}
$$
we have $S = \phi^{-1}(0) = \ker \phi$ and $T = \phi^{-1}(\mathbb{R} \setminus \{0\})$. From this you can answer 1a, 1b and 2a immediately.
For compactness of $S$ pick some $x \in [0,1]$ and notice that the evaluation $e \colon X \to \mathbb{R}$ with $e(f) = f(x)$ is continuous and linear. What do you now about the image of a compact set?
For connectedness of $T$ similarly consider $\phi$ and think about the image of a connected set. (Here we use that we are only considering realvalued functions.)
For the denseness of $T$ notice that $X = T \cup S$. Can you (uniformly) approximate elements of $S$ by elements of $T$? (Hint: How does $\phi$ react to moving functions up and down?)
PS: Some more deatails regarding the compactness of $S$ and connectedness of $T$:
Take some non-zero $f \in S$. Then there exists $x \in [0,1]$ with $f(x) \neq 0$. So for the corresponding evaluation map $e_x \colon X \to \mathbb{R}$, $h \mapsto h(x)$ we have $e_x(f) \neq 0$. Thus $e_x(S)$ is some non-zero linear subspace of $\mathbb{R}$ (which there are not many of). If $S$ was compact then $e_x(S)$ would also be compact, because $e_x$ is continuous.
For the denseness of $T$ notice that for every $f \in S$ and $\varepsilon > 0$ we have
$$
 \phi(f+\varepsilon) = \phi(f) + \phi(\varepsilon) = \varepsilon \neq 0
$$
(here we identify each constant $c \in \mathbb{R}$ with the corresponding constant function on $[0,1]$), where we have $\|f - (f+\varepsilon)\|_\sup = \varepsilon$.
Comment: thanks for the hints,but,i m not able to catch up with your explanation for denseness and compactness.can you elaborate a bit more
Comment: I added some more information about these two points.
Comment: thaks....it was really helpful

topology of normed spaces


Does it matter if the index finger is off the top of the neck playing F barre?

Question: Like pretty much everyone I'm struggling to get good at F barre.  After reading a lot of these answers I couldn't find an answer to this:
I've got a pretty good and more and more consistent F recently, with a lot of practice, but the tip of my index finger is almost completely off the top of the neck?  e.g. The 6th string (E) sits only just above the first finger joint and strings 1 (e) and 2 (B) are between the second joint and base of finger.
I seem to be able to play it pretty well - but worry that the index finger is too high?
(ps. Hope I got the strings right!)
Comment: Post a pic.  That would help
Comment: Please say whether you are playing classical guitar or electric or some other type. I'm guessing classical because you use the term "barre" instead of "bar".   It is important to know however as there are differences in technique (and the width of the neck). P.S. A photo  would be very useful.
Comment: Does you index finger lays flat over 1 st fret?
Comment: @user9339131 - Pretty much flat - it hits all strings but doesn't press the middle ones too hard?
Comment: @chasly-supportsMonica Just a basic acoustic - image added...I normally press a little harder with finger flatter...but trying to take the pic at the same time!
Comment: Not a problem, if hand is comfortable and all strings sounds without buzz then there is no issue. And what's the exact issue?
Comment: @user9339131 Worried that by learning a certain "grip" I'd be heading for trouble further down the line.  Self-teaching (can't afford lessons) so having to make some assumptions.
Comment: No not at all, there is no wrong or right way. I myself is self taught(intermediate/advanced) player and I had major issues with alternate picking(I had to learn it 3 times, seriously), holding guitar(I kept my thumb always over fretboard which contributed in slow progress), and still struggling with my right hand technique(but I am getting better). It is no doubt that it's difficult to be self taught but doing mistake is part of learning. If you are doing something wrong, it will be hurdle in learning and you have to correct it and that is fun(seriously). Hope it motivates you!
Answer: I don't believe there is anything wrong with the tip of the index finger sticking out off the neck when playing barre. Similarly you may find that in some cases when you're supposed to play barre over e.g. two or three strings it is easier to put the finger over more strings. It may depend on specific chord shape as well as on your individual anatomical shape of hand and fingers.
What matters is that the notes sound clear and without the buzz (and also that notes that are not supposed to sound, don't), that you avoid excessive muscle tension and you have freedom in placing the other fingers where they should be and that it doesn't prevent you from switching the chords smoothly.
Comment: "that you avoid excessive muscle tension" this is so important I thought I'd quote it :)
Comment: Thank you - I'll stick with it as its coming out clear.
Comment: @Thomas right. Actually, the more the finger is "sticking out" the closer is the part that is touching the strings to the joint that connects finger with the palm. This reduces the moment of force (which translates into your effort or muscle tension) needed to apply necessary force on the strings.
Answer: Since there is such a discrepancy in the length of fingers between players - and the ratio of finger lengths for individuals - it matters not how much finger covers certain strings. As long as those stringss can be successfully pressed and sound, and other strings can also sound.
Also a large consideration must be the comfort afforded by your positioning. If it hurts, it's not good in the long term. There's also the fact that the majority of guitar players press way too hard, especially when barring chords like this.
Another option, frowned upon by classical guitarists, is to use the thumb over the top to fret that bottom string. With longer thumbs, it can be successful.
It may be worth experimenting to see if your shape hinders changing chords. Sometimes one particular shape makes moving from another shape to that, or that to another shape, not as fluid as it could be.
But if all is well, keep going at it. There cannot be the 'same 'ideal' way for all of us.
Comment: There is a gender aspect that comes into play here as well.  It's not 100% of course, but statistically speaking, women's hands tend to have the index finger longer than the ring finger, while on men's hands it's shorter.  (Middle finger is longer than both regardless.)  This can directly affect how much finger is used in a barre chord.
Comment: @DarrelHoffman Note that length of the finger is not the only factor, but also location and shape of the joints. It's sometimes difficult to press the string properly if it's just under the joint.


Meaning of "actual notes" above staff

Question: I've been studying The Unanswered Question By Charles Ives and found a peculiarity in the trumpet part. When the trumpet comes in, it has the phrase "actual notes" written above as seen below.

I'm pretty sure it means play what's written, but is there anything more to the marking then saying these are the actual notes?
Answer: The 'actual notes' marking appears in two places in the score. The first, as you've flagged, is the first entrance of the trumpet part. The same marking then appears at a section marked specifically for clarinet (where the remainder of the part is clarinet or flute).
As this marking consistently appears at the first entrances of the only parts marked specifically for transposing instruments, and the score in written with all parts in C - I would assume the "actual notes" marking is clarification for the conductor that the notation is written in concert pitch, rather than in Bb, as the instruments would be fingering.
The full score, for anyone interested: Score
Answer: It's the kind of instruction I would expect in "scordatura" situations where an instrument is retuned or modified or stuffed beyond pitch accuracy.
In that case, "actual notes" would mean that the given notes are the sounding notes rather than what one should be fingering on the instrument if it were unmodified.
Another, probably less likely, option would be for a short passage with a different instrument than the preceding passage to indicate that this passage is not written in this instrument's typical transposing notation but in concert pitch.
And, even more unlikely, it might be an English rendition of "loco", meaning that a previously written octave shift is to be abandoned here.
Answer: This sort of question relies so much on context!  Was the trumpet previously playing in some modified transposition?  Was it previously instructed to extemporize?
Fortunately, in this case we can consult the full score.
http://imslp.org/wiki/The_Unanswered_Question_%28Ives,_Charles%29
In this case I think it's clear that Ives is reminding us the score is non-transposed.  We normally perform that part on trumpet, but he offers the choice of trumpet, english horn, oboe or clarinet.  He is also non-specific about the woodwind choir.

Meaning of "actual notes" above staff


How to use breakpoints in Javascript code in .ASPX page of Visual Studio 2008

Question: I have Javascript in my .aspx design source page. How can i set breakpoints and run as i set it for a .cs page. I am using Visual Studio 2008 for my coding.
I have browsed for the use of debugger. But i couldn't get how to use it properly. If debugger; is used, can someone elaborate on how its used.
Comment: Have you tried to set breakpoints in Java script?
Comment: Ya, but it doesn't hit it
Comment: Should I add any process to activate the breakpoint for Java Script ?
Comment: Why don't you use the Debugger of your browser?
Comment: Use Firebug for firefox to debug javascript.
Comment: use this link for help http://stackoverflow.com/questions/2251599/how-to-set-javascript-breakpoints-in-visual-studio-2008-or-visual-studio-2010
Comment: I tried using Debugger of my IE. But it crashes everytime
Comment: Try to erase your cache of your browser.Sometimes you change your javascript but browser get the script from cache.
Answer: If you put a debugger; statement and you're using IE, the browser will throw a "Script Debugging" error and prompt you for a debugging tool, you can select VS 2008 from the list.
Make sure to have the "Disable Script Debugging" options in IE unchecked.
Alternatively, you can use "Debug > Attach To Process" and attach the debugger to your browser processes, after that you can put a regular break point from visual studio on your javascript code and it will work.
Comment: It shows "Breakpoint will not be hit. No symbols have been loaded for this document"
Comment: Its ok, sometimes it does that, but when you refresh your page the break point gets hit.


Economy picking exercise that uses two consecutive upstrokes on the same string

Question: I have started looking into Joseph Alexander's Complete Technique for Modern Guitar where economy picking is recommended. Before starting to practice, I want to understand the logic behind economy picking, and both according to the book as well as to the Wikipedia definition, it seems to be as simple as the following:

When picking multiple notes on a string, alternate picking is used.
When changing to a new string, picking is in the direction of travel.

However, in one of the examples in the book, I see two consecutive upstrokes on the same string. Following is the section where it happens, at the beginning of the 2nd bar:

It seems to be caused by the fact that the 1st note of the 1st bar is played with a downstroke, but when repeating it in the 2nd bar, the same note is played with an upstroke due to economy picking. However I do not understand why the 2nd note is also played as an upstroke. What the rationale behind this pattern with two consecutive upstrokes on the same string? Shouldn't the first 4 notes in the 2nd bar become up-down-up-up according to the way economy picking is defined?
Comment: Going on the assumption that the author and his publishing company did not make an error printing this exercise I have to say that this seems very awkward and counterintuitive to me. I believe @Lazy is right in that the intention is to keep downstrokes on the beats. The final 2 downstrokes in bar 1 create an awkward situation of having to play 2 upstrokes on one string in bar 2 to get back on the beat. I believe altérnate picking for steady 8th notes is much more efficient and easier. The direction of the pick always tells you where you are. What is economized with this system? Beats me.
Answer: I think the intention here is try to keep beats on downstrokes and offbeats on upstrokes. The concept here appears to be avoiding picking in the contrary direction your hand moves to reach the new string. Also playing the penultimate note downstroke might be more economic for moving to the higher string rather than playing an upstroke.
I think in this sense picking style is much like bowing on a violin: It is all about finding a compromise that works for you.
Comment: There's never going to be a perfect solution to picking. As a teenager, I spent many, many hours working out the optimum (for me) picking for every song I played, and some just didn't fit the mould. Compromises just had to be made. Years on, I don't think about it - much.
Comment: @Tim Well, sometimes there **is** a perfect solution. But not always ...


Paypal "Invalid Response"

Question: Im having problems with paypal standard. All of my orders are going into pending in woocommerce, but they are completed from paypal. It was working fine up until yesterday. Have checked paypal notification and nothing seems to be the problem with them posting IPN. Have even called paypal and they suggested it must be a problem with woocommerce.
All I get is a " Received invalid response from PayPal" message. Nothing else.
Very grateful for any help.
Here is the log:
08-03-2014 @ 09:52:33 - Generating payment form for order #3264. Notify URL: http://www.example.com/wc-api/WC_Gateway_Paypal/
08-03-2014 @ 09:52:58 - Checking IPN response is valid via https://www.paypal.com/cgi-bin/webscr...
08-03-2014 @ 09:52:58 - IPN Request: Array
(
    [body] => Array
        (
            [cmd] => _notify-validate
            [mc_gross] => 0.01
            [invoice] => WC-3264
            [protection_eligibility] => Ineligible
            [item_number1] =>
            [payer_id] => 75CDQE99MV6HU
            [tax] => 0.00
            [payment_date] => 02:52:47 Aug 03, 2014 PDT
            [payment_status] => Completed
            [charset] => windows-1252
            [mc_shipping] => 0.00
            [mc_handling] => 0.00
            [first_name] => blah
            [mc_fee] => 0.01
            [notify_version] => 3.8
            [custom] => a:2:{i:0;i:3264;i:1;s:22:"wc_order_53de066107428";}
            [payer_status] => verified
            [business] => email@example.com
            [num_cart_items] => 1
            [mc_handling1] => 0.00
            [verify_sign] => A1K1xiWGhsY-FKnWkd4yY7uiudGNAOARq2ctsv1RwgUf2oeUWPvl8xHQ
            [payer_email] => firstname.lastname@example.com
            [mc_shipping1] => 0.00
            [tax1] => 0.00
            [txn_id] => 0SY73148U75396444
            [payment_type] => instant
            [last_name] => blahblah
            [item_name1] => Test
            [receiver_email] => firstname.lastname@example.com
            [payment_fee] =>
            [quantity1] => 1
            [receiver_id] => 63MGUUP668W7Y
            [txn_type] => cart
            [mc_gross_1] => 0.01
            [mc_currency] => GBP
            [residence_country] => GB
            [transaction_subject] => a:2:{i:0;i:3264;i:1;s:22:"wc_order_53de066107428";}
            [payment_gross] =>
            [ipn_track_id] => 9ac6a002221f7
        )

    [sslverify] =>
    [timeout] => 60
    [httpversion] => 1.1
    [compress] =>
    [decompress] =>
    [user-agent] => WooCommerce/2.1.12
)

08-03-2014 @ 09:52:58 - IPN Response: Array
(
    [headers] => Array
        (
            [server] => Apache
            [x-frame-options] => SAMEORIGIN
            [strict-transport-security] => Array
                (
                    [0] => max-age=14400
                    [1] => max-age=14400
                )

            [content-type] => text/html; charset=UTF-8
            [dc] => slc-a-origin-www-2.paypal.com
            [date] => Sun, 03 Aug 2014 09:52:58 GMT
            [transfer-encoding] => chunked
            [connection] => Array
                (
                    [0] => close
                    [1] => Transfer-Encoding
                )

            [set-cookie] => Array
                (
                    [0] => cwrClyrK4LoCV1fydGbAxiNL6iG=YvFeUiPBnGc9JrBsDcwjbDJQBiP7vJQt0UKZ9_Bzlhtmh2d7UWs2aYg-ENdINNTeQOU_tVg_MLrSb7aedZf4esd8jHXCDRA06es2hAkvXFzT2ImoQc5cEwK6-9bOvt8mxoR4Q1wcqh1q7-Xka84IkDmsLD34Y9kVuh13e6fatgxirOzN4LxgTbJzxGBJBuEJnRcHJ18ofyIq_u5plMzhy6V_Qd7A-QT5gJiEr5ZTgJ5cAAtoX_44lYgXKvSFWIKdag7NORd_AkLYiiZUjnf0A-Xs909CeHcisY0rbeiD_f1iEueyX8-8qHNWCqZi3l2ZCzuUpQ_or1TpGt83eIArYtLtov2y8AdLkHKWd890yalOsG30jwCJseRE3UFxoQiUvqrwSd3bGq35PYHB3XN42ZXdXmHE0RstOuRnPdQQLC3J413su_zQfeiSzfe; domain=.paypal.com; path=/; Secure; HttpOnly
                    [1] => cookie_check=yes; expires=Wed, 31-Jul-2024 09:52:58 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
                    [2] => navcmd=_notify-validate; domain=.paypal.com; path=/; Secure; HttpOnly
                    [3] => navlns=0.0; expires=Tue, 02-Aug-2016 09:52:58 GMT; domain=.paypal.com; path=/; Secure; HttpOnly
                    [4] => Apache=10.73.8.134.1407059578400130; path=/; expires=Tue, 26-Jul-44 09:52:58 GMT
                    [5] => X-PP-SILOVER=name%3DLIVE5.WEB.1%26silo_version%3D880%26app%3Dslingshot%26TIME%3D2047270483; domain=.paypal.com; path=/; Secure; HttpOnly
                    [6] => X-PP-SILOVER=; Expires=Thu, 01 Jan 1970 00:00:01 GMT
                    [7] => Apache=10.73.8.67.1407059578390277; path=/; expires=Tue, 26-Jul-44 09:52:58 GMT
                    [8] => AKDC=slc-a-origin-www-2.paypal.com; expires=Sun, 03-Aug-2014 10:22:58 GMT; path=/; secure
                )

        )

    [body] => 00000008
VERIFIED
00000000

    [response] => Array
        (
            [code] => 200
            [message] => OK
        )

    [cookies] => Array
        (
            [0] => WP_Http_Cookie Object
                (
                    [name] => cwrClyrK4LoCV1fydGbAxiNL6iG
                    [value] => YvFeUiPBnGc9JrBsDcwjbDJQBiP7vJQt0UKZ9_Bzlhtmh2d7UWs2aYg-ENdINNTeQOU_tVg_MLrSb7aedZf4esd8jHXCDRA06es2hAkvXFzT2ImoQc5cEwK6-9bOvt8mxoR4Q1wcqh1q7-Xka84IkDmsLD34Y9kVuh13e6fatgxirOzN4LxgTbJzxGBJBuEJnRcHJ18ofyIq_u5plMzhy6V_Qd7A-QT5gJiEr5ZTgJ5cAAtoX_44lYgXKvSFWIKdag7NORd_AkLYiiZUjnf0A-Xs909CeHcisY0rbeiD_f1iEueyX8-8qHNWCqZi3l2ZCzuUpQ_or1TpGt83eIArYtLtov2y8AdLkHKWd890yalOsG30jwCJseRE3UFxoQiUvqrwSd3bGq35PYHB3XN42ZXdXmHE0RstOuRnPdQQLC3J413su_zQfeiSzfe
                    [expires] =>
                    [path] => /
                    [domain] => .paypal.com
                    [secure] =>
                    [httponly] =>
                )

            [1] => WP_Http_Cookie Object
                (
                    [name] => cookie_check
                    [value] => yes
                    [expires] => 1722419578
                    [path] => /
                    [domain] => .paypal.com
                    [secure] =>
                    [httponly] =>
                )

            [2] => WP_Http_Cookie Object
                (
                    [name] => navcmd
                    [value] => _notify-validate
                    [expires] =>
                    [path] => /
                    [domain] => .paypal.com
                    [secure] =>
                    [httponly] =>
                )

            [3] => WP_Http_Cookie Object
                (
                    [name] => navlns
                    [value] => 0.0
                    [expires] => 1470131578
                    [path] => /
                    [domain] => .paypal.com
                    [secure] =>
                    [httponly] =>
                )

            [4] => WP_Http_Cookie Object
                (
                    [name] => Apache
                    [value] => 10.73.8.134.1407059578400130
                    [expires] =>
                    [path] => /
                    [domain] => www.paypal.com
                )

            [5] => WP_Http_Cookie Object
                (
                    [name] => X-PP-SILOVER
                    [value] => name=LIVE5.WEB.1&silo_version=880&app=slingshot&TIME=2047270483
                    [expires] =>
                    [path] => /
                    [domain] => .paypal.com
                    [secure] =>
                    [httponly] =>
                )

            [6] => WP_Http_Cookie Object
                (
                    [name] => X-PP-SILOVER
                    [value] =>
                    [expires] => 1
                    [path] => /cgi-bin/
                    [domain] => www.paypal.com
                )

            [7] => WP_Http_Cookie Object
                (
                    [name] => Apache
                    [value] => 10.73.8.67.1407059578390277
                    [expires] =>
                    [path] => /
                    [domain] => www.paypal.com
                )

            [8] => WP_Http_Cookie Object
                (
                    [name] => AKDC
                    [value] => slc-a-origin-www-2.paypal.com
                    [expires] => 1407061378
                    [path] => /
                    [domain] => www.paypal.com
                    [secure] =>
                )

        )

    [filename] =>
)

08-03-2014 @ 09:52:58 - Received invalid response from PayPal

Answer: [body] => INVALID

PayPal is returning Invalid, but its still talking to them. Maybe before this:
if ( 'yes' == $this->debug ) $this->log->add( 'paypal', 'IPN Response: ' . print_r( $response, true ) );

Replaced this with:
if ( 'yes' == $this->debug ) $this->log->add( 'paypal', 'IPN Request: ' . print_r( $params, true ) );

Then checked the log - it told the request its making to paypal.

Paypal "Invalid Response"


How many five-digit numbers are there that have exactly two odd digits in their decimal notation?

Question: I thought that in the first place you can choose 9 out of 10 numbers (all but zero) then in the second place choose 4 out of 5.
Or the second option in the first place can be 4 out of 5 odd numbers, in the second and third places we choose odd.
it seems to me that I am confused in these combinations, I don't understand how to calculate, given that zero cannot be the first
Comment: first calculate the number of 5 digit numbers without worrying about leading zeros, subtract from this the number of 4 digit numbers (again without worrying about leading zeros)
Comment: Another option is to consider cases, depending on whether the leading digit is even or odd.
Answer: As suggested in the comments, take the $\binom{5}{2}5^25^3$ numbers with at most five digits, and subtract the numbers with at most four digits, that is $\binom{5}{2}5^5-\binom{4}{2}5^4=44\cdot 5^4=27500$.
Comment: I think that double counting is not an issue here, because I choose to distinct *positions*, not *numbers*. If I would choose $5\cdot 4$, I would count twice, thus the division by $2$ in $\binom{5}{2}$. Having chosen the two positions, I iterate through all combinations with $5^2$. This counts every combination once, also pairs, say $(7,7)$, once.
Comment: This seem to double-count cases when you have repeated odd number (7 and 7) or if you have repeats in even numbers. When you choose $5 \choose 2$ they'd be considered as 2 separate numbers.
Answer: The (moderately) less elegant approach that the OP (i.e. original poster) attempted is also feasible.
If the leftmost digit is odd, then the number of satisfying digits is
$$5 \times \binom{4}{1} \times 5^4. \tag1 $$
If the leftmost digit is even, then the number of satisfying digits is
$$4 \times \binom{4}{2} \times 5^4. \tag2 $$
Adding the expressions in (1) and (2) above gives
$$5^4 \times \left[ ~(5 \times 4) + (4 \times 6) ~\right] = 27500.$$


Can not run EXCEL.EXE with "runas", it says: "1312: A specified logon session does not exist. It may already have been terminated."

Question: I need to run EXCEL.EXE with a user different than current one; previously I have been doing this without any issues using "runas", but after updating the system to Windows 10 Pro version 2004 (19041.508) this method is not working anymore.
This is what I am doing:
C:\Users\forla>runas /profile /user:probanduela "C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE"
Escriba la contraseña para probanduela:
Intentando iniciar C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE como usuario "DESKTOP-PGDBNMB\probanduela" ...
ERROR RUNAS: no se puede ejecutar - C:\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE
1312: Una sesión de inicio especificada no existe. Es posible que haya finalizado.

I am getting all times the error (english version):
1312: A specified logon session does not exist. It may already have been terminated.
Similar issue happens if I try to run it through PowerShell or through win32 API, or through c# API.
This method was working before upgrading to Windows 10 2004 version, I've reproduced this on different computers.
What's the issue? How can I achieve what I want to do ?
-Edit-
Just discovered that using Excel v2002 build 12527.21104 it works; but with Excel v2008 build 13127.20408 it fails.
So apparently is a combination of Windows 10 v2004 + Office 2019 v2008 what causes the issue.
-Edit2-
If I make a copy of EXCEL.EXE and give it another name, like "EXCEL_COPY.EXE" it works. But still not work with WINWORD.EXE.
Comment: +1 I am facing the same problem, but in my case with Access, and I confirm that I could solve it by copying msaccess.exe and starting the copy. However, this is dangerous, and I won't use that solution any more: If there is a security update, the original files will be replaced, but not the copy. That means that you must remember to make the copy again after each Office update. I have thought about solving this problem by making a hardlink instead of a copy, but the hardlink will nearly surely be broken by updates either. So there is still no usable solution for this crap.
Answer: I reported that issue to Microsoft and, after raising up few levels, they have worked on it and fixed. It's fixed on Windows 10 Build 19042.844

Can not run EXCEL.EXE with “runas”, it says: “1312: A specified logon session does not exist. It may already have been terminated.”


Django querying the db uneccessarily for each object

Question: My models.py:
from django.db import models
from django.contrib.auth.models import User

class SkillCategory(models.Model):
    title = models.CharField(max_length=255)

    def __unicode__(self):
        return self.title

    class Meta:
        verbose_name_plural = "Skill Categories"

class Skill(models.Model):
    title = models.CharField(max_length=255)
    category = models.ForeignKey(
        SkillCategory, default=None, null=True, blank=True
    )

    def __unicode__(self):
        return self.title

class UserProfile(models.Model):
    user = models.OneToOneField(User)
    skill = models.ManyToManyField(Skill)
    avatar = models.URLField(
        max_length=400, default=None, null=True, blank=True
    )

    def __unicode__(self):
        return self.user.username

My views.py:
def ShowUserProfile(request, username=None, template_name='user_profile.html'):
    if not username:
         username = request.user.username

    profile = get_object_or_404(
        UserProfile.objects.select_related(), user__username=username
    )
    ...

And in my template I iterate like so:
 ...
 {% if skill.category.title == 'Some Skill' %}
   {% for skill in profile.skill.all %}

{{ skill }}

   {% endfor %}
 {% endif %}
 ...

But if I look at Django Debug Toolbar, I see that for each Skill, Django is querying the db to get the Category. I am using select_related on the UserProfile object but it doesn't affect the number of queries. Surely there must be a better way, whereby Django can get all the Skill and related SkillCategory references in one go?
Edit
Based on the accurate feedback, the correct view looks like this:
def ShowUserProfile(request, username=None, template_name='user_profile.html'):
    if not username:
         username = request.user.username
    profile = get_object_or_404(
        UserProfile.objects.prefetch_related(
            'skill__category'), user__username=username
    )

Answer: select_related doesn't handle ManyToMany relationships.  Look into prefetch_related, which does handle ManyToMany fields by running two queries and joining the results in Python.

select_related works by creating an SQL join and including the fields of the related object in the SELECT statement. For this reason, select_related gets the related objects in the same database query. However, to avoid the much larger result set that would result from joining across a 'many' relationship, select_related is limited to single-valued relationships - foreign key and one-to-one.
prefetch_related, on the other hand, does a separate lookup for each relationship, and does the 'joining' in Python. This allows it to prefetch many-to-many and many-to-one objects, which cannot be done using select_related, in addition to the foreign key and one-to-one relationships that are supported by select_related. It also supports prefetching of GenericRelation and GenericForeignKey.
Comment: Thanks! So the correct query looks like this: `profile = get_object_or_404(UserProfile.objects.prefetch_related('skill__category'), user__username=username)`
Answer: Django's select_related does not work for many-to-many relations.
Check prefetch_related


What's the shortcut to toggle hexadecimal display in Visual Studio?

Question: In Visual Studio (any version), what is the shortcut to toggle hexadecimal display while debugging?
I was not able to find anything for far...
Answer: There isn't one set by default but you can add one in the options menu.
Go to Tools > Options > Environment > Keyboard - (in 2012/2013 you can press ctrl-q to focus the "Quick Launch" box, then type "hotkeys" and press enter).
In the "Show commands containing:" textbox type "hexadecimal".
The first result should be "Debug.HexadecimalDisplay", this is the toggle for turning hexadecimal display on/off so you can then set any shortcut keys you wish - I use ctrl-h, ctrl-x.


What can I say about $x^4 \equiv -4 \mod p$ where $p$ is prime?

Question: What can I say about $x^4 \equiv -4 \mod p$ where $p$ is prime? In general what can I do with powers that are greater than $2$ and where I cannot use reciprocity, legendre/jacobi etc... In general what can I say about a quadratic polynomial modulo $p$: For instance $(x-1)^2 \equiv 1 \mod p$
By 'what can I say' I mean $p \equiv$ something $\mod 4$ or $8$
Comment: Is it $\,x^4=1\,\,\,or\,\,\,x^4=-4\,$? And what do you mean by "what can I say"? The equation $\,x^4=1\,\pmod p$ always has the solutions $\,-1,1\,$, which are different if $\,p\neq 2\,$...
Comment: I mean $-4$. I just fixed my question.
Answer: $$  x^4 + 4 = ((x-1)^2 + 1) ((x+1)^2 + 1)  $$
Comment: By Euclid's Lemma $p|((x-1)^2 + 1)$ or $p|((x+1)^2 +1)$. Then I get $(x-1)^2 \equiv 1 \mod p$ or $(x+1)^2 \equiv 1 \mod p$. I have learned about quadratic residues but not anything more complicated. Could you give me another hint?
Comment: Then you can multiply $-2^2$ to both sides of the congruence and then we have $-4$ is a quadratic residue $\mod p$
Comment: http://artofproblemsolving.com/wiki/index.php/Sophie_Germain_Identity
Comment: @CodeKingPlusPlus .


How to set local alias for a machine?

Question: I would like to set an alias on my local PC for a network machine. I know that it can be done by adding an entry in the hosts file as long as the IP address of the machine is also specified. However, the problem is that IPs are dynamically assigned by a DHCP server so I don't know for sure the IP address. Is there a way to define just an alias based on the machine's network name?
P.S.: I'm running Windows Server 2008 R2.
Answer: Windows only supports IP to Hostname mapping. You cannot set up local aliases using the hosts file.
If you have control over the DNS for the network, you can create a CNAME record that maps one name to another name.
If you do not have control over the network's DNS - you are out of clean options (barring a frankensteined DNS server running on your localhost just for the creation of your own CNAMEs. shudders)
Comment: Ok, so my options are as limited as I thought. Thanks for the confirmation.
Answer: On networks where WINS is enabled/configured, one can refer to another machine by using the network name wherever a hostname is taken, and the OS libraries will map it to the IP address appropriately.
Comment: Unfortunately WINS is not enabled so I cannot use that but thanks for the suggestion.
Answer: This "kinda" works (it depends on your version of windows )
in HOSTS (C:\Windows\System32\drivers\etc\hosts)
Specify:
127.0.0.1 testb
In regedit, create a DWORD as follows:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa
New DWORD
DisableLoopbackCheck
Set to 1
PING works on both Windows Server 2012 and 2019. Specifying the new alias in an explorer window (or opening it with a program) works fine in Windows Server 2012, but fails on Windows 2019 (it gets into credentialing loop and does not accept valid credentials)

How to set local alias for a machine?


Set values in jquery multiselect dropdown

Question: I want to set the multiple ITEMS in jQuery multiselect dropdown depending on the VALUE of that item, which I'm getting from database, separated by ",".
I'm saving this fetched data in hidden field.
Ex.
Hidden field: hdnLots = 64,65
, Items for lot No.: 64 = Lot 1, 65 = Lot2
So when I get the hdnLot=65, then in jQuery Multiselect dropdown only Lot2 needed to be selected. And same for 64,65. i.e. When multiple values are selected than all those values needed to seleted.
I've tried: JQuery multiselect - Set a value as selected in the multiselect dropdown
Code I've wrote for this is:
if ($("#<%= btnUpdateProject.ClientId %>").css('display') == "inline-block")
{
   debugger;
   var dataarray = document.getElementById('<%= hdnLots.ClientId %>').value.split(",");
   $("#<%= ddlNoOfLots.clientid %>").val(dataarray);
}

Comment: $("#<%= ddlNoOfLots.clientid %>").multiselect("refresh");
Comment: Add ` $("#<%= ddlNoOfLots.clientid %>").refresh();`
Comment: add `$("#<%= ddlNoOfLots.clientid %>").multiselect("refresh");`
Comment: @Nouphal.M : Its showing error.
Comment: @user3085495 what error?
Comment: @Dharmang : I've tried it, but its changing `size(height,width)` of multiselect and neither its working.
Comment: @Nouphal.M : `Uncaught type error: Object [object object] has no method refresh`.
Comment: Sorry but $("#<%= ddlNoOfLots.clientid %>").multiselect('refresh'); is the right syntax. Also have you checked what is the value of the `dataarray` var
Comment: Can you reproduce the problem on a demo?
Comment: @Nouphal.M : It's showing only the single data in `dataarray`. i.e. `dataarray = 65` only, even if `hdnLots=64,65`.
Comment: @Dharmang: I'll try for that, but I don't think so I can do that because I'm new to this.
Comment: You need use third party service like jsfiddle to demonstrate your code in js and html language, if you don't know already.
Comment: Try alerting document.getElementById('<%= hdnLots.ClientId %>').value and see what it holds
Comment: @Dharmang: Somehow I managed to reach upto refresh method but its still showing this error: **`Uncaught Error: Cannot call methods on multiselect prior to initialization, attempt to call method 'refresh'`** in console.
Comment: This error means that your multiselect instance is not initialized. first initialize it by calling $("#<%= ddlNoOfLots.clientid %>").multiselect(); provide any options if necessary.
Answer: I hope this will help you:
Demo
$(document).ready(function() {
$("select").multiselect({
   selectedText: "# of # selected"
});
var hidValue = $("#hidSelectedOptions").val();
alert(hidValue);
var selectedOptions = hidValue.split(",");
for(var i in selectedOptions) {
    var optionVal = selectedOptions[i];
    $("select").find("option[value="+optionVal+"]").prop("selected", "selected");
}
$("select").multiselect('reload');
});

EDIT
refresh has been removed from latest jQuery-MultiSelect. Using reload will solve the question now.
Answer: The one thing you would need to ensure is that the values in the array are strings:
<select id='multipleSelect' multiple='multiple'>
  <option value="1">1</option>
  <option value="2">2</option>
  <option value="3">3</option>
</select>

Check my Fiddle: https://jsfiddle.net/luthrayatin/jaLygLzo/
Comment: I'm glad I could help mate!
Answer: var selectedOptions = hidValue.split(",");
typeof (selectedOptions != 'undefined' && $("#hidSelectedOptions").multiselect('select', selectedOptions));

Comment: .multiselect('select', selectedOptions)); this part works great for me.


Should we "feed" our Enterprise Support Tickets here?

Question: I am thinking about making it some kind of habit - after an Magento Enterprise Support ticket was resolved by eBay staff - to post this in QA format here.

Question: Problem description
Answer (not much more than): "We the patch number EE 12345 from support, tested in in our EE 22.214.171.124 and it works" -> Accept answer

Basically I might have asked on stack exchange before, so of course I do not open a new question and just post the answer.
We might not be able to include the patch and code (see Enterprise Edition Code in Examples) and maybe not cite support staff. But technically I then do not see any problem.
Shall we allow / promote this kind of questions here?
Answer: Outside of some agreement-based restriction, I can't see anything wrong with this approach. I like the idea of having public exposure of support requests, including the ability for others to discuss implementing the patches, outcomes, and issues.


Tag merge request: 'usa' and 'united-states'

Question: There are both usa and united-states tags. I'm not sure which one should end up being the primary one, because Tag merge - uk and united-kingdom indicates it should be united-states but that's the lesser used tag at the moment.
Comment: You could potentially create a poll as well for people to decide
Comment: Defs in favor. If we go by Travel SE, there united states is mapped to usa.
Answer: This suggestion was made almost three years ago, and it seems reasonable to me, but there's been no action. Is there any reason to continue to have both tags?
Answer: This looks to have been forgotten back then. I checked, and it looks like people used the usa tag more often (1000 vs 100), so united-states was merged into usa.


not jumping from one activity(layout) to another activity

Question: unable to find issue. all buttons are working properly and jumping properly from one activity to another but "button About" is not working properly. it must jump to "about activity" ... kindly check the code for issue... "About button" having problem has a comment and is in the last... log, xml is also installed thanks and regards
activity having about button
package com.example.routetracker;

import android.media.MediaPlayer;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Select_destination extends Activity implements OnClickListener{
Button close,main,about,texila,aslam_market,royal_son,comsat;
MediaPlayer mPlayer;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_destination);

mPlayer=MediaPlayer.create(this, R.raw.selectdestination);

        mPlayer.start();
        texila=(Button)findViewById(R.id.btn_texila);
        texila.setOnClickListener(this);
        aslam_market=(Button)findViewById(R.id.btn_aslam_market);
        aslam_market.setOnClickListener(this);
        royal_son=(Button)findViewById(R.id.btn_royal_son);
        royal_son.setOnClickListener(this);
        comsat=(Button)findViewById(R.id.btn_comsat_wah);
        comsat.setOnClickListener(this);
        main=(Button)findViewById(R.id.btn_main);
        main.setOnClickListener(this);
        about=(Button)findViewById(R.id.btn_about);
        about.setOnClickListener(this);
        close=(Button)findViewById(R.id.btn_close);
        close.setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.btn_texila:
    mPlayer.stop();

    Intent i=new Intent(Select_destination.this,Start_tracking.class);
    i.putExtra("place", "1");
    startActivity(i);
    break;
case R.id.btn_aslam_market:
    mPlayer.stop();
    Intent j=new Intent(Select_destination.this,Start_tracking.class);
    j.putExtra("place", "2");
    startActivity(j);
    break;
case R.id.btn_royal_son:
    mPlayer.stop();
    Intent k=new Intent(Select_destination.this,Start_tracking.class);
    k.putExtra("place", "3");
    startActivity(k);
    break;
case R.id.btn_comsat_wah:
    mPlayer.stop();
    Intent l=new Intent(Select_destination.this,Start_tracking.class);
    l.putExtra("place", "4");
    startActivity(l);
    break;

case R.id.btn_main:
    mPlayer.stop();
    Intent o=new Intent(Select_destination.this,MainActivity.class);
    startActivity(o);
    break;

case R.id.btn_about:  // for this button i have problem
    mPlayer.stop();
    Intent e=new Intent(Select_destination.this,About.class);
    startActivity(e);
    break;

case R.id.btn_close:
    mPlayer.stop();
    System.exit(1);
}

}

}

About Activity Code
package com.example.routetracker;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class About extends Activity implements OnClickListener{

Button close,main;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);

main=(Button)findViewById(R.id.btn_main);
main.setOnClickListener(this);

close=(Button)findViewById(R.id.btn_close);
close.setOnClickListener(this);
}

@Override
public void onClick(View v) {
switch(v.getId()){
case R.id.btn_main:
    Intent o=new Intent(About.this,MainActivity.class);
    startActivity(o);
    break;

case R.id.btn_close:
    System.exit(1);
    break;

}

}

}

XML code for about button
<Button
android:id="@+id/btn_about"
android:layout_width="97dp"
android:layout_height="90dp"
android:layout_alignBaseline="@+id/btn_main"
android:layout_alignBottom="@+id/btn_main"
android:layout_toRightOf="@+id/btn_main"
android:text="About" />

log file is
08-27 08:28:16.752: I/Choreographer(1000): Skipped 72 frames!  The application may be doing too much work on its main thread.
08-27 08:28:17.133: I/ActivityManager(293): START u0 {cmp=com.example.routetracker/.About} from pid 1000
08-27 08:28:17.173: W/WindowManager(293): Failure taking screenshot for (123x205) to layer 21020
08-27 08:28:17.443: I/Choreographer(1000): Skipped 178 frames!  The application may be doing too much work on its main thread.
08-27 08:28:19.123: I/Choreographer(293): Skipped 31 frames!  The application may be doing too much work on its main thread.
08-27 08:28:20.563: D/dalvikvm(1000): GC_FOR_ALLOC freed 1320K, 28% free 4175K/5772K, paused 287ms, total 327ms
08-27 08:28:20.583: I/dalvikvm-heap(1000): Grow heap (frag case) to 5.468MB for 1319216-byte allocation
08-27 08:28:21.102: D/dalvikvm(1000): GC_CONCURRENT freed 4K, 6% free 5459K/5772K, paused 11ms+25ms, total 499ms
08-27 08:28:21.852: D/AndroidRuntime(1000): Shutting down VM
08-27 08:28:21.902: W/dalvikvm(1000): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
08-27 08:28:22.063: E/AndroidRuntime(1000): FATAL EXCEPTION: main
08-27 08:28:22.063: E/AndroidRuntime(1000): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.routetracker/com.example.routetracker.About}: java.lang.NullPointerException
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.os.Handler.dispatchMessage(Handler.java:99)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.os.Looper.loop(Looper.java:137)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.app.ActivityThread.main(ActivityThread.java:5041)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at java.lang.reflect.Method.invokeNative(Native Method)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at java.lang.reflect.Method.invoke(Method.java:511)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at dalvik.system.NativeStart.main(Native Method)
08-27 08:28:22.063: E/AndroidRuntime(1000): Caused by: java.lang.NullPointerException
08-27 08:28:22.063: E/AndroidRuntime(1000):     at com.example.routetracker.About.onCreate(About.java:24)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at  android.app.Activity.performCreate(Activity.java:5104)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
08-27 08:28:22.063: E/AndroidRuntime(1000):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
08-27 08:28:22.063: E/AndroidRuntime(1000):     ... 11 more
08-27 08:28:22.342: W/ActivityManager(293):   Force finishing activity com.example.routetracker/.About
08-27 08:28:22.382: I/Choreographer(293): Skipped 121 frames!  The application may be doing too much work on its main thread.
08-27 08:28:22.412: W/ActivityManager(293):   Force finishing activity com.example.routetracker/.Select_destination
08-27 08:28:22.482: I/Choreographer(293): Skipped 32 frames!  The application may be doing too much work on its main thread.
08-27 08:28:22.902: W/ActivityManager(293): Activity pause timeout for ActivityRecord{41569f28 u0 com.example.routetracker/.About}
08-27 08:28:23.212: I/Choreographer(293): Skipped 246 frames!  The application may be doing too much work on its main thread.
08-27 08:28:23.232: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
08-27 08:28:23.373: I/Choreographer(293): Skipped 31 frames!  The application may be doing too much work on its main thread.
08-27 08:28:24.403: I/Choreographer(293): Skipped 39 frames!  The application may be doing too much work on its main thread.
08-27 08:28:24.523: I/Choreographer(293): Skipped 44 frames!  The application may be doing too much work on its main thread.
08-27 08:28:27.279: W/ActivityManager(293): Launch timeout has expired, giving up wake lock!
08-27 08:28:27.372: W/ActivityManager(293): Activity idle timeout for ActivityRecord{41569f28 u0 com.example.routetracker/.About}
08-27 08:28:28.053: I/Choreographer(293): Skipped 44 frames!  The application may be doing too much work on its main thread.
08-27 08:28:28.512: I/Choreographer(293): Skipped 32 frames!  The application may be doing too much work on its main thread.

Comment: Seems like your about layout doesn't have close or/and main button.
Comment: paste activity_about.xml here
Comment: what is line 24 about.java? show us `activity_about.xml`
Comment: you about button is working but it is crasing in your about activity in onCreate. Just check and it should be fixed. Its a null pointer exception
Comment: in xml you have button id android:id="@+id/btn_about" and in activity main=(Button)findViewById(R.id.btn_main); both should be same.
Comment: check your About Layout xml and Layout  name . Is it exact as your reference
Answer: Check v.getId() when you click on About button
Log.d("ID ::",v.getId()+"");

Confirm that you are getting btn_about ID
 case R.id.btn_about:  // for this button i have problem

       if(mPlayer != null) {
          mPlayer.stop();
       }

        Intent e=new Intent(Select_destination.this,About.class);
        startActivity(e);
        break;

Comment: Did you check v.getId() in logcat before call About activity


Contraction of a tensor over all indexes?

Question: In Chapter 2.3 of this book, let $F \in T^k_l(V)$ and $\{\omega^i\}_{i=1}^l \in V^*, \{X_i\}_{i=1}^k$, then it is clear that
$$
F \otimes \omega^1 \otimes \cdots \otimes w^l \otimes X_1 \otimes \cdots \otimes X_k \in T^{2k}_{2l}(V)
$$
so the contraction of this tensor over all indexes is
$$
\text{tr}(F \otimes \omega^1 \otimes \cdots \otimes w^l \otimes X_1 \otimes \cdots \otimes X_k) = F(\omega^1,\dotsc,\omega^l,X_1\dotsc,X_k)
$$
...which I don't understand at all. I know that $\text{tr}$ can be viewed as an operation that reduce the rank of the tensor by 2 via
$$
  \text{tr}(F)(\omega^1,\dotsc,\omega^l,X_1,\dotsc,X_k) = \text{tr}(F(\omega^1,\dotsc,\omega^l, \star\ ,X_1,\dotsc,X_k, \star\ ))
  $$
but if we want to sum through all indexes we need to have $l = k $, so how is it possible to take the contraction over all indexes on a general tensor?
Comment: Most likely your product tensor should be of type $T_{k+l}^{k+l}$ and the contraction is really just evaluation of $F$ on the $w$'s and the $X$'s. (you are not contracting $w$'s against the $X$'s). Does that make sense in your context?
Answer: $\newcommand\Tr{\operatorname{Tr}}$The most simple contraction operation is the trace :
$$\Tr : V\otimes V^* \to \mathbb K$$
Given a general tensor product $T^k_l(V) = V^{\otimes k} \otimes (V^*)^{\otimes l}$ (with $k,l\geq 1$), for each $i \in \{1,\ldots, k\}$ and $j\in \{1,\ldots,j\}$, we can define a contraction $C_{ij} : T^k_l(V) \to T^{k-1}_{l-1}(V)$ by contracting the $i$-th factor in $V$ and the $j$-th factor in $V^*$ using $\Tr$.
But we can also iterate this and contract more than one pair of factors. For example by taking the composite :
$$V\otimes V \otimes V^* \otimes V^* \simeq V \otimes (V\otimes V^*)\otimes V \overset{\Tr}\longrightarrow V\otimes V^*\overset\Tr\longrightarrow\mathbb K$$
Now, without using indices like physicists do, the notations quickly become nightmarish. The previous example would be $C_{11}\circ C{21} = C_{11}\circ C_{12}$. Therefore, when everything is clear, we prefer to write any contraction $\Tr$.
In your specific case, with $F \in T^{k}_{l}(V)$, we remark that : $$T = \omega_1\otimes \ldots\otimes \omega_k \otimes V_1\otimes \ldots \otimes V_l \in T_{k}^l(V) = (T^{k}_l(V))^*$$
Therefore, $F\otimes T \in T^k_l(V) \otimes (T^k_l(V))^*$ and we can take the trace over $T^k_l(V)$ instead of $V$, so it makes a lot of sense to write this full contraction as a trace. This can also be written in terms of the trace over $V$ (ie contractions over pairs of factors $(V,V^*)$). In this case, as $F \otimes \omega_1\otimes \ldots\otimes \omega_k \otimes V_1\otimes \ldots \otimes V_l$ belongs to :
$$\underset{k}{\underbrace{V\otimes \ldots \otimes V}}\otimes \underset{l}{\underbrace{V^*\otimes \ldots \otimes V^*}} \otimes \underset{k}{\underbrace{V^*\otimes \ldots \otimes V^*}} \otimes \underset{l}{\underbrace{V\otimes \ldots \otimes V}}$$
it is (implicitly) understood, that the $i$-th of the $k$ factors of $V$ is contracted with the $i$-th of the $k$ factors of $V^*$ and that the $j$-th of the $l$ factors of $V$ is contracted with the $j$-th of the $l$ factors of $V^*$.
Comment: Take trace over $T^k_l(V)$ makes so much more sense. Thanks!
Answer: Each $\omega$ and each $X$ has rank 1. Therefore $\omega^1\otimes\dots\otimes\omega^l\otimes X_1\otimes\dots\otimes X_k$ has rank $l+k$. Furthermore the tensor $F$ has also rank $l+k$. (So the tensor product of everything together has rank $2l+2k$). The "contraction over all indices" that the text talks about contracts each index of $F$ with one of the indices of $\omega^1\otimes\dots\otimes\omega^l\otimes X_1\otimes\dots\otimes X_k$. This works for any value of $k$ and $l$.
You are right, that if $k=l$, then you could also contract each of the $\omega$'s with one of the $X$'s. But thats a different operation with a different result, and probably not what is meant here.
The basic problem is this: Just writing "$\text{tr}(\dots)$" is often ambiguous. It sometimes means contracting exactly two indices (thus reducing the rank by 2), or it can mean contracting everything, thus creating a scalar. And in the second case there can be a myriad of ways how to match all the indices in pairs. Each gives a different result.


How do I compile glucose SAT solver on Mac?

Question: When I compile the glucose SAT solver on Mac, I get the following compile-time errors when compiling glucose 3.0.  How do I avoid these errors?
<code>~/acl2/glucose-3.0/simp$ make
Making dependencies
Compiling: /Users/me/acl2/glucose-3.0/simp/Main.o
In file included from /Users/me/acl2/glucose-3.0/simp/Main.cc:39:
In file included from /Users/me/acl2/glucose-3.0/simp/../core/Dimacs.h:27:
/Users/me/acl2/glucose-3.0/simp/../core/SolverTypes.h:58:16: error:
      friend declaration specifying a default argument must be a definition
    friend Lit mkLit(Var var, bool sign = false);
               ^
<snip>
6 errors generated.
make: *** [/Users/me/acl2/glucose-3.0/simp/Main.o] Error 1
~/acl2/glucose-3.0/simp$
</code>
Answer: Credit goes to Marijn Heule for this solution:
Modify your glucose source code to accommodate the following changes:
<code>bash$ diff SolverTypes.h
~/Downloads/glucose-3.0/core/SolverTypes.h
58c58
<     // friend Lit mkLit(Var var, bool sign = false);
---
>     friend Lit mkLit(Var var, bool sign = false);
66c66
< inline  Lit  mkLit     (Var var, bool sign = false) { Lit p; p.x =
var + var + (int)sign; return p; }
---
> inline  Lit  mkLit     (Var var, bool sign) { Lit p; p.x = var + var + (int)sign; return p; }
</code>
The top (<) is the Mac version, while the bottom (>) is the default source.


Dividir uma data em duas parte

Question: Estou fazendo um calendário usando MySQL, html, JS e PHP.
Esse calendário serve para reservar o salão de festas aqui no prédio.
Pode existir duas reservas no mesmo dia, manhã e tarde que seria "00:00 até 11:59" e "12:00 até 23:59".
Minha questão:
Gostaria de uma sugestão para a melhor forma de fazer isso, já pensei em fazer com dois campos date e o outro hora.
Também imaginei se é possível usar o datatime, timestamp.
Alguma dica ou sugestão?
Answer: Eu armazenaria com 2 campos.

data, campo date mesmo (ou int a contar numero de dias de uma data padrão).
periodo campo int de 1 byte só, ou enum sendo:

1 = manhã
2 = tarde
3 = ambos os períodos

Assim simplifica o problema.
Verificando se a data está livre.
Para testar disponibilidade de data, basta fazer este select:
SELECT periodo WHERE data=$data AND ( periodo=$periodo OR periodo=3 OR $periodo=3 );

periodo=$periodo significa conflito, se pediu manhã e já tem manhâ, ou se pediu tarde e já tem tarde
periodo=3 significa conflito, pois se já tem um ocupando o dia todo, não tem como agendar mais nada nessa data.
$periodo=3 significa conflito, pois se está tentando agendar dia todo, qualquer agendamento existente impede o agendamento.

Se a query acima não retornar nenhum registro, você pode fazer um novo agendamento na data $data para o período $periodo.
Se, por outro lado, retornar registros, não dá para por o novo agendamento, pois terá um conflito.
Comment: Não a estrutura dessa parte ``( periodo=$periodo OR periodo=3 OR $periodo=3 );``
Comment: Sao os 3 testes que eu expliquei acima.  periodo=$periodo elimina tarde com tarde, e manhã com manha. periodo=3 elimina qualquer agendamento se o dia todo está ocupado. $periodo=3 elimina agendamento para o dia todo, se qualquer outra coisa já existir naquele dia.
Answer: A melhor forma seria usar datatime
Para pegar as datas e horas separadamente use:
$datetime = '2010-07-05 12:11:00';

list( $date, $time ) = explode( ' ', $datetime );

echo 'Data: '.$date;

echo 'Hora: '.$time;

Answer: Faça um campo booleano(no MySQL: bit(1)) em que 0 indica a reserva da manhã e 1 indica a reserva da tarde.
Em relação a data:
Se for por questão facilidade, utilize o o tipo DATE, ele armazena datas no seguinte formato: 'YYYY-MM-DD'
Se for por questão de economia de espaço, crie um campo SMALLINT e armazena o número de dias entre o evento e uma data que você definir, por exemplo, entre 01/01/2015 e o dia do evento e deixa o javascript fazer as contas para transformar isso em data bonita.
Você também pode armazenar tudo no tipo DATETIME, mas acho desnecessário.

Dividir uma data em duas parte


is this a part interrupt?

Question: at measure 6 ,
the soprano starts with the G
so shouldn't the alto not go over the G
till the next measure ?
but you could see the alto is getting higher then the G through the measure..
is this a part interrupt ?
Answer: I believe you're discussing what is commonly called a voice overlap. A voice overlap occurs when, from one chord to the next, a voice moves into the register of a neighboring voice. In the example below, a voice overlap occurs on beat 4 because the bass is higher than the tenor was in the previous chord.

Your example would be a voice overlap if the chords moved immediately from beat 1 to beat 3. However, since your example has beat 2 between those two chords, it is no longer a voice overlap. Voice overlap occurs over the span of two chords. Since your example occurs over the span of three chords, it is acceptable.

Voice overlap is not to be confused with a voice crossing, which is when voices move into the register of a neighboring voice in the same chord. In the example below, a voice crossing occurs on beat 4 when the soprano line (the stemmed-up E) moves below the alto (the stemmed-down A).
Answer: What you've written is fine.  All parts have a singable line.   Voice overlaps and crossings should be used with caution, but I don't consider them to be prohibited.

is this a part interrupt?


How to get "User ID From URL" with contextual filter in Pfofile2 page

Question: I'm using Drupal7.
I wanted to display some fields from user account in profile2 page by using Views. I tried to do this by using views block and views_embed_view() coded in profile2--ProfileType.tpl.php for profile2 page.
So, I created a view and set contextual filter like below.
<code>-"USER:UID"
-the default value is "User ID From URL"
</code>
But that doesn't display View in profile2 page even though the URL is "Mydomain.com/profile-My_Profile_Type/User_ID". On the other hand, that View works in the user account page. So, this means that it may be because contextual filter of "User ID From URL" doesn't work in the profile2 page even though its URL has User ID. I changed the contextual filter from "USER:UID" to "(Profile) Profile: User uid", but it doesn't work either...
Can anybody give me the advice how to make it work?
Thank you
Answer: If the url schema is alway the same, you can use the default value "Raw value from url" instead of "User Id from URL" and set the 'path component' in your example to '3' to get the user id.
Comment: thank you for your reply. I tried the way you suggested. But it doesn't work... So doesn't it mean it's impossible to get some value from URL in Profile2 page...?


Concatenar data em PHP para inserir no MySQL

Question: Bom dia, a minha dúvida consiste no método de concatenação e de criação de um Datetime para inserir numa base de dados.
Tendo as variáveis:
$dia = '2018-04-11';
$hora = '09:36';

O formato desejado é: AAAA-MM-DD HH:MM:SS
Como faço para juntar e enviar estes dados para a BD?
Exemplo do que eu pensei:
 INSERT INTO nome_tabela (data_inicio) VALUES concat(data_inicio(Datetime?($dia,$hora))) ??

Têm como ajudar a compor e esclarecer-me como criar o registo com essa data?
Answer: Por exemplo:
$dia = '2018-04-11';
$hora = '09:36';

$datahora = $dia . ' ' . $hora . ':00';
//                  ^              ^--- segundos opcionais no final
//                  '--- espaço entre as partes

$sql = "INSERT INTO nome_tabela (data_inicio) VALUES '$datahora';";

Para aprendizado apenas, se quiser o CONCAT:
$dia = '2018-04-11';
$hora = '09:36';

$sql = "INSERT INTO nome_tabela (data_inicio) VALUES CONCAT('$data', ' ', '$hora', ':00')";

Note que nem precisa do :00 no final, só pus pra ilustrar. O importante é respeitar o formato ISO, YYYY-MM-DD HH:MM:SS, preenchendo da esquerda para a direita.
Isto posto, considere não trabalhar com strings desta forma na aplicação. Tente achar um formato numérico que atenda melhor, para evitar ter que fazer operações muito complexas com os dados.
Por exemplo, datas e horas com precisão de segundos podem ser armazenadas em inteiros, se usar o formato POSIX (até 2038), e se quiser mais tempo, basta usar um offset (por exemplo, tomar por base o número de segundos desde o ano 2010).
Alternativamente, o PHP tem classes para data e hora, mas não justifica o custo adicional para usos simples como esse seu, pois é só mais código e processamento para resultar na mesma coisa:
$dia = '2018-04-11';
$hora = '09:36';

$dateobject = new DateTime( $dia . ' ' . $hora );

// só faz sentido usar isso se for processar a data
// de maneira complexa antes de usar

$datahora = $dateobject->format('Y-m-d H:i:s');

$sql = "INSERT INTO nome_tabela (data_inicio) VALUES '$datahora';";


Prove that X is compact if and only if X is a finite set.

Question: Let X be a set of real numbers such that for each a∈X, a is an isolated point in X. Prove that X is  compact if and only if X is a finite set. (Hint: see the  proof of theBolzano-Weierstrass Theorem)
Comment: The hint seems needless to me. This is an exercise in pushing around definitions. Choose an open set for each point that witnesses the fact that it is isolated. Show that we can only obtain a finite subcover of this cover if the set is finite.
Comment: If $X$ is finite then $X$ is compact (obvious). If $X$ is discrete and compact, extract a finite subcover of $\{\{x\} \mid x \in X \}$.
Answer: Each $a$ is isolated which means that there is a neighborhood $N_{a}$ so that $N_{a}\cap X$ = {a}. If X is compact these $N_{a}$ form a cover of $X$ with no proper subcover, therefore there must be finitely many such $N_{a}$ and hence finitely many $a$, so $X$ is finite. If X is finite the set of distinct sets over X is finite call the totality of such sets J, any open cover of $X$ can find a finite subcover by discarding any repeated sets so that all sets are distinct, then there can be no more than J sets in this subcover, so every open cover has a finite subcover and X is compact.