Implicit integral equation involving square root

Question: I have the following integral equation stemming from a physical problem (connected with BCS theory):
$$
1 = \frac{2}{\pi}u \int_0^1 dx \sqrt{\frac{1-x^2}{u^2\phi^2 + x^2}},
$$
where $u$ is a positive parameter and I have to solve the equation for the variable $\phi$, which is acceptable only within the range $-1/2 < \phi < 1/2$.
I guess that asking for an analytic expression $\phi(u)$ is probably too much, but at least I would like an approximated solution when $u\ll 1$.
From physical considerations and numerical analysis I know that the solution should be something like $\phi \sim e^{-1/u}$, however I have no clue about how to prove it.
Can anyone point me to the right direction?
I am not able to transform this integral into elliptic functions, and Wolfram Mathematica can't solve it either. Moreover, I am not sure how to expand for small values of $u$... I am thinking that there's no way out, except numerics.
Comment: ... and you can manually evaluate the result at $0$ and $1$ (I ran a definite `Integrate` input but it never completed for me). It's given in terms of an *incomplete* elliptic integral (second kind). OTOH, if I'm not mistaken, differentiating both sides w.r.t. $\phi$, then computing the integral gives a somewhat simpler result in terms of two *complete* EIs (first and second), and since the right side vanishes one ends up with having to solve$$E\left(\frac i{u\phi}\right) = K\left(\frac i{u\phi}\right)$$(using Wikipedia's convention for the elliptic modulus, not the WL's). But what now?
Comment: *Mathematica* can do it if you include more conditions. This should work in v.13.1+:
`Integrate[Sqrt[1 - x^2] / Sqrt[u^2 f^2 + x^2], x, Assumptions -> u < 1 && -1/2 < f < 1/2]`
Comment: what is this notation ?
Answer: Too long for a comment
Denoting $a=|u\phi|$ and considering the case $a\ll1$
$$I(a)=\int_0^1\sqrt{\frac{1-x^2}{a^2 + x^2}}dx\overset{IBP}{=}\ln(x+\sqrt{a^2+x^2})\sqrt{1-x^2}\,\bigg|_0^1+\int_0^1\frac {\ln(x+\sqrt{a^2+x^2})xdx}{\sqrt{1-x^2}}$$
The remaining integral is regular at $a=0$; therefore
$$I(a)=-\ln a+\int_0^1\frac{\ln(2x)\,x}{\sqrt{1-x^2}}dx+o(a)=-\ln a+2\ln2-1+o(a)$$
and your equation becomes
$$\boxed{\,\,1=\frac2\pi u\big(-\ln|u\phi|+2\ln2-1+o(|u\phi|));\,\,|u\phi|\ll1\,\,}$$
You should exclude the case of $\phi=0$ from consideration: in this case the integral diverges at any $u$.
Comment: I checked numerically the initial integral: the asymptotics of $I(a)$ is correct. Moreover, the integral $\int_0^1\frac{\ln(2x)\,x}{\sqrt{1-x^2}}dx$ appears directly (in one line) and is equal $2\ln2-1$ (I checked with WolframAlpha). I'm not good at special functions, so I cannot explain why there is a difference in the answers. One of the explanation could be that the function $e^{-1/u}$ is not analytical at $u\to0$, and we have to know how Mathematica treat it in this limit...
Comment: There is one point : when $u$ is small, $\phi$ is much smaller. Is there a way to take into account ? As I wrote, I have the strange feeling that we are not very far from a solution in terms of the generalized Lambert function. Do you agree ? Thanks & cheers :-)
Comment: I found Lambert function (once more)
Comment: Wow! Beautiful solution, thanks a lot. There's one detail I still don't get: if I take @Claude Leibovici 's solution and blindly expand it with Mathematica for $a \to 0$,  I get the equation $1=(2u/\pi) [\log{2} - \log{(u\phi)}]$, which is slightly different. How is that possible?
Comment: Numeric check with WolframAlpha for $a=0.1:\,\, I(0.1)=2.698...$, approximation $=-\ln(0.1)+2\ln2-1=2.689$    ( https://www.wolframalpha.com/input?i=%5Cint_0%5E1++%5Csqrt%7B%5Cfrac%7B1-x%5E2%7D%7B0.01+%2B+x%5E2%7D%7Ddx  and    https://www.wolframalpha.com/input?i=-%5Cln%280.1%29%2B2%5Cln2-1)
Comment: @Claude Leibovici, you are right about $\phi$. The asymptotics ($I(a)$) is also correct. I don't think there the is reason to evaluate higher terms ($o|u\phi|$). In fact, even correction $2\ln2-1$ does not work at $u\ll1$ - only one term is needed in fact. BTW, superconductivity was explained so late because of this non-analytic behavior: people struggled to apply the perturbation theory, which is not applicable for such function...
Comment: Glad to see that, once more, we fully agree.
Answer: Assuming $a>0$ and $x>0$, using the elliptic integral of the second kind
$$I=\int \sqrt{\frac{1-x^2}{a^2+x^2}}\,dx=-i E\left(i \sinh ^{-1}\left(\frac{x}{a}\right)|-a^2\right)$$
$$J=\int_0^1 \sqrt{\frac{1-x^2}{a^2+x^2}}\,dx=-i E\left(i \sinh ^{-1}\left(\frac{1}{a}\right)|-a^2\right)$$ So, with $a=u\phi$, the equation to be solved for $\phi$ is
$$1+\frac{2 i }{\pi }\, u\, E\left(i \sinh ^{-1}\left(\frac{1}{u \phi
   }\right)|-u^2 \phi ^2\right) =0$$
This equation cannot be inversed but any numerical method (such as Newton) should work as a charm $\cdots$ provided a reasonable estimate.
I had no problem using $\phi_0=e^{-1/u}$
But, as usual, @Svyatoslav's estimate
$$\phi_0=\frac 4 u  \exp\left( -\left(\frac{\pi }{2 u}+1\right)\right)$$ is extremely good.
Edit
Doing what @user170231 suggested in comments (sorry fot not having paid a sufficient attention), we have somthing simpler (even if there is one hypergeometric function). But, it can be simplified as
$$J=\frac{\left(a^2+1\right) }{a}K\left(-\frac{1}{a^2}\right)-a   E\left(-\frac{1}{a^2}\right)$$
The equation is then
$$1-\frac{2 \left(u^2 \phi ^2+1\right) K\left(-\frac{1}{u^2 \phi
   ^2}\right)}{\pi  \phi }+\frac{2 u^2 \phi  E\left(-\frac{1}{u^2   \phi ^2}\right)}{\pi }=0$$ which can be expanded as a series
$$1+\sum_{n=0}^\infty A_n\, u^{2n+1}=0$$ where
$$A_0=-\frac{2 \left(\log \left(\frac{u}{4}\right)+\log (\phi)+1\right)}{\pi }$$
$$A_1=\frac{\phi ^2 \left(\log \left(\frac{u}{4}\right)+\log (\phi)\right)}{2 \pi }$$
$A_0$ is the term given by @Svyatoslav.
I suppose that we are not very far from a solution in terms of the generalized Lambert function.
Using $$\phi_0=\frac 4 u  \exp\left( -\left(\frac{\pi }{2 u}+1\right)\right)$$ use Newton method
$$\phi_{n+1}=\phi_n-\frac {f(\phi_n)}{f'(\phi_n)}$$ with
$$f'(\phi)=\frac{2 u^2 }{\pi }\left(E\left(-\frac{1}{u^2 \phi
   ^2}\right)-K\left(-\frac{1}{u^2 \phi ^2}\right)\right)$$
Update
Let $\phi=\frac{1}{u \sqrt{x}}$ and we look for the inverse of
$$\frac 2 \pi u=\frac{  \sqrt{x}}{ (x+1) K(-x)- E(-x)}\tag 1$$ where the rhs is a nice function (its reciprocal looks like a Lambert function).
Expand for large $x$ to $O\left(\frac{1}{x^{3/2}}\right)$ and let $x=e^t$ to obtain
$$e^{-t}=4\, \frac {t+2 (2 \log (2)-1) }{t+ \left(\frac{u}{\pi }+4 \log (2)\right) }$$
and the solution is given in terms  of the generalized Lambert function (have a look at equation $(4)$).
Expanding the rhs of $(1)$ as a series, we have  avery good asymptotics
$$\frac 2 \pi u=\frac 1 t \sum_{n=0}^\infty (-1)^{n}\, {P_n(t)}\,\left(\frac{x}{t}\right)^n \quad \text{where} \quad x=\frac{1}{16} e^{2( t+1)}$$ the first polynomials being
$$\left(
\begin{array}{cc}
n & P_n(t) \\
 0 & 1 \\
 1 & \frac{t+1}{4} \\
 2 & \frac{14 t^2+17 t+8}{128} \\
 3 & \frac{90 t^3+113 t^2+78 t+24}{1536} \\
 4 & \frac{6948 t^4+8551 t^3+6860 t^2+3360 t+768}{196608} \\
 5 & \frac{90900 t^5+107183 t^4+91810 t^3+55380 t^2+21120
   t+3840}{3932160}\\
\end{array}
\right)$$
Comment: This is beautiful! I could not imagine that I could go this far, thanks! However, if I expand this with Mathematica, I get a slightly different equation w.r.t @Svyatoslav's estimate, but I don't see why (unless Mathematica is giving me wrong results for some reasons)
Comment: @Matteo. Could you show the syntax you used ? In any manner, I always try to get first the antiderivative.
Comment: Sure (I replace $\phi$ with f)!  Assuming[{u > 0, 0 < f < 1/2}, FullSimplify[(2/Pi)*Series[-I*u*EllipticE[I*ArcSinh[1/(u*f)], -(u*f)^2], {u, 0, 1}]]]
Comment: The output is $(2u/\pi)[\log{2}- \log{(u\phi)}]$


Building a simple app for Windows Mobile 6.5. Where to start?

Question: I'm trying to build a small application for Windows Mobile 6.5 that has a simple menu interface with options. Based on the option the user selects the application goes ahead and overwrites a configuration file stored somewhere in the device. It seems very simple to build for other platforms but I've never actually done any development for Windows Mobile 6.5. I know C++.
I'm looking for pointers on where to look to get started. What are some good resources to learn about windows mobile development that are not too tedious (since my app is so simple)? Are there any other apps/code examples that I can look at to get a head start? Does anyone have any idea how this could be coded?
Thank you!
Comment: Sure. At my workplace they have these scan guns to do inventory, and there are 4 separate configuration files that are used based on what the person is trying to scan. This tool would allow the user to overwrite configuration files and make sure everything is set up before using it.
Comment: May I ask the purpose of this effort?
Comment: So you seems to be supporting an existing application, so why write a new one? Also why not use the code of the existing application as an example to start?
Comment: which existing application? This would be a separate application that sets up the configuration for the other one. I haven't found anything like it.
Answer: Before you can start to develop for Windows Mobile in C++ you need a programming environment and the Windows Mobile 6.5 DTK (Device Tool Kit).
For development you normally need a Windows PC and a non-Express version of Visual Studio 2005 or 2008. You may go with the free Microsoft Embedded Visual C++ 4.0 and Windows Mobile SDK (ARM processor). If you do not have access to VS2005 or VS2008 (even VS2003 will work), it will be expensive or hard to get as MS now sells VS2015, but only VS2003/2005/2008 are designed to compile Windows Mobile 6.x code.
There is also a free GNU Windows CE toolkit usable for Windows Mobile programming. Depends on your skills.
A good starting point is to know about general Windows Programming (Charles Petzold's Programming Windows book is a good base).
The Windows Mobile SDKs/DTK come with samples for C++ SmartDevice programming too. These are good starting points.
There are other options, for example Mono Develop with workarounds to get Compact Framework compatible IL code. But this is .NET programming and not C++.


SignalR takes a long time to respond to a heartbeat

Question: I created a very simple ASP.NET Core app with SignalR with Visual Studio using a Web App MVC application template with the following customization:

added a reference to @microsoft/signalr library via libman,
referenced  in _Layout.cshtml,
added the required SignalR services in Startup.cs and created an empty Hub, exposed in the following way:

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub<MyHub>("hub/remote");
                // ... MVC router definitions
            }

created the SignalR connection in JS:

const connection =
    new signalR.HubConnectionBuilder()
        .withUrl("/hub/remote")
        .configureLogging(signalR.LogLevel.Trace)
        .withAutomaticReconnect()
        .build();

connection.start().then(() => console.log("Connected."));

Then I launched the MVC app and everything started without an error.
However, I took a closer look at SignalR log messages:

I believe this is the SignalR's internal heartbeat that keeps the connection alive.
I wonder why does it take 4-5s between sending the message and receiving the response?
I also tried using SignalR in a more complex application and from time to time I even started receiving "Reconnecting" events, as the load was significantly larger there.
That makes me feel that I do something wrong while configuring the connection, but no idea what exactly.
Comment: "Connection Slow" isn't an event in ASP.NET Core SignalR. And the heartbeats are not directly related to each other, so the gaps are normal.
Comment: Re: Connection Slow - you're right. I got used too much to non-Core SignalR :).
Re: gaps, ok, thanks for confirming that.
Comment: @Brennan looks like there are no other comments. Can you turn your comment into an answer so that I can accept it?
Answer: "Connection Slow" isn't an event in ASP.NET Core SignalR.
The heartbeats are not directly related to each other, so the gaps between client and server pings are normal.


Visual SVN 2.0 and IIS

Question: How can I set up Visual SVN Server to run on port 443 and also have IIS set up to handle other website access on port 443?  The URL usually points to /svn/ for the svn server anyway and the other websites point to /fogbugz/ for example.
Or is it possible to have Visual SVN Server just use IIS instead of Apache?
Answer: Duplicated question: Is it possible to bind domain names to VisualSVN server and IIS on the one box without using a port?
Option 1: Run VisualSVN Server and IIS on different IP address
You can run VisualSVN Server and IIS side-by-side on the same port using multiple IP address on network interfaces: http://www.itsyourip.com/networking/how-to-add-multiple-ip-address-in-windows-2000xp2003/
To configure VisualSVN Server bind to only specific interfaces use the following steps:

Run VisualSVN Server Manager
Right click on root element and choose Properties
Switch to Network tab
Select "These IP addresses" radio button
Click Add Enter IP address of interface to listen
Click OK to close Add interface dialog
Click OK to close Properties window

To configure IIS listen on specific interface use the following steps:
1. Start elevated command prompt
2. Execute following command: netsh http add iplisten ipaddress=IPADDRESS
Option 2: Use use reverse proxy for IIS
Use SvnReverseProxy to redirect traffic from IIS to VisualSVN Server. See following links for details:
http://gstoolkit.codeplex.com/wikipage?title=SvnReverseProxy&ProjectName=gstoolkit
Comment: If I use option 2, will the URL look like https://svnserver.home/svn/repo or will it redirect me to https://svnserver.home:8443/svn/repo?  The redirection won't work.
Comment: URL of your IIS server will be used.
Answer: I asked an almost identical question here. I also have a blog post which contains information on an (admittedly basic) workaround here: http://www.troyhunt.com/2009/10/creating-your-own-custom-subversion.html

Visual SVN 2.0 and IIS


Mathematically finding a threshold for deciding on rare word

Question: I am implementing spell-correction facility as a preprocessing step of for a text classification project. For this reason I have to make a knowledge-base where I shall be putting all the words along with their frequencies. During test time, if any misspelled word is found, then the program will be replacing that word with most appropriate word from that knowledge-base.
But here is a problem. As I consider all the tokens along with there frequencies, then there will be some rare words as well which are not too much helpful. Even in worse cases, they may prevent a word from being corrected with another more preferable option. Following is an example:
Token    Frequency
========================
quick      122
brown       99
fox         80
dog         79
.
.
.
quik         1

Here we can see that, the knowledge-base contains both quick and quik, so if the input contains the term quik then it will not be corrected as it is already present in the knowledge-base. But leaving it as it is (just because it is an in-domain token) is not a good idea either. As, it is obvious that, it would be better if there was no quik in the knowledge-base such that the term got a chance to be corrected with quick. As quick is more familiar to the text classifier.
So, the obvious way is to remove the tokens with low frequencies. But I am facing problem to choose a threshold value of this frequency (i.e, choosing a threshold value such that if some token has lower or equal frequency than that, then we will call them as rare words and remove from the knowledge-base). Deciding this value is problematic, as it can vary a lot based on the data-set we are using. For instance, for a large data-set we might have chosen this value to be 3 which is reasonable. But for small data-set this value will be too much and many important tokens will be removed.
Following is another view of the same problem: In this plot I have plotted the first 1000 most frequent tokens along with there frequencies (the total number of tokens is around 40,000). So, basically, I need a threshold for the frequency, under or equal of which I shall discard all the tokens, assuming them as rare words. Please note that, the data-set I have used to collect tokens is large (around 70,000 sentences). For smaller data-sets we may have different types of frequency distributions. So, I am suspecting that, the presupposition on the distribution might not be appropriate for all the cases, therefore, we might need to use rank-statistics.

So, the question is is there any statistical / mathematical approach to find this threshold dynamically?
Answer: I'll give my two cents, though it's far from a "perfect" solution (if one exists).
First, as for the issue of varying dataset sizes, you can normalize the token frequencies by the document count, and choose a threshold over the normalized frequency rather than the absolute one.
Second, as you noticed, using a threshold in such cases is problematic, and will always create false positives and/or false negatives. One thing you could do is sample rare words across various frequencies, manually label them as typos or legit rare words, choose a metric for weighing between false positives and false negatives, and use all that to find a threshold that optimizes that metric. This will still not be perfect, 1) because frequency alone probably can't perfectly discriminate typos from legitimately rare words, and 2) because it will be based on manual labeling of samples (and not all the data).
Looking outside the dataset, you can perhaps intersect your knowledge base with existing language databases, e.g. wordnet or others in different languages.
Lastly, if you're up to some more sophisticated cleaning work, notice that you can use more information than just frequency to try determine if a word is a typo or not: say we have two words with identical low frequencies, e.g. quik and Cthulu. quik is very similar (e.g. using edit distance) to an existing, popular word in the dataset (quick), which increases its likelihood of being a typo; while Cthulu is probably distant from most other words in the dataset. This way you can use heuristics to assign a "typo probability" to each word, and use a cutoff on that score.
Comment: It's not needed to be perfect. Again, for my use case, it is not possible to check the words manually, as it is just a preprocessing step and the program will be trained on user data after it goes to production. And the user of this service can upload data which may vary in sizes. I want a solution which will help me to get rid of this manual supervision. And also I am giving more importance on reducing false positive, than false negative.
Comment: In that case I would start with just normalizing by document count / max token count and choose some reasonable threshold. If the datasets change and there's no labelling then I doubt frequency statistics alone will provide enough information to find an optimal threshold. I do think the "typo probability" score will give better results, but it requires more work to implement.


Features View, directory browsing hide and seek

Question: In Microsoft Windows 7, IIS, features view tab, I don't see "directory browsing".
How do I make this view visible?
Answer: Install the feature from Control Panel.
Go to Control Panel, Programs and Features, Turn Windows Features On or Off, and check Internet Information Services / World Wide Web Services / Common HTTP Features  /Directory Browsing


how to convert a very large string to QR code?

Question: I am going to write a program to convert a Json String to QR Code using Zxing library but my Json is too long sometimes , so what is the best approach to handle long Json string to make Qr Code?
Comment: create a link for json file and make qr code for that URL
Comment: shortURL kind of thing is better
Comment: something like http://qr.w69b.com/g/o4zEQ4sb6
Answer: One QR code can contain up to 4296 aplpha-numerical characters with the lowest error correction level. If your json is larger you can try some kind of compression algorithm. But there is no standard definition for data compression inside of qr codes. So normally no barcode scanner can uncompress your data.
Another feature of QR codes is structured append which means that you can split your data across separate QR codes. But it is similar to compression, it is not guaranteed that every barcode scanner supports structured append.
So it is better not to store large amounts of data inside the QR code. Perhaps you can find a way to store the data elsewhere and only encode an URL inside the QR code which points to the data (like mentioned by mastermind).


Is it safe to change INT to BIGINT or DECIMAL in database?

Question: I need to change a field from INT to BIGINT or DECIMAL. I tested changing it directly in the database on field_data and field_revision tables and apparently all is working fine, but I have my doubts and I don't want to do that on production until I'm entirely sure it's safe. It's enough to change the data type on database or I have to do something else like the solutions listed in the links below? If it's not safe to just change it in database, I'd like to know why.

change field from int to big int in drupal
How to change a field type from Integer to Decimal?
field is Integer and I am getting PDOException error thrown
Comment: It really depends on how you are using it. If you don't mind to [possibly lose precision](http://php.net/manual/en/language.types.integer.php#language.types.integer.overflow), you are good to go.
Answer: Usually, when you make a change of this type it is recommended to make it in a development environment, so you can make some test to check your site is working correctly.
In the case you decide to make it in a production environment, be sure you make a backup of your database, in order to restore your system in case of problems.
Comment: Thanks for your answer, but that's not what I'm asking. I currently do that on a testing environment, probably my redaction was not good (english is not my native language). I'm not asking for best practices when doing changes, I'm asking if it's enough  to do that change directly on database or I must do it differently to avoid any issues later.
Comment: @Camilo I think that in this case you can find the answer in the 3 references that you have in the question
Comment: That's my suspicion, but what I do work fine (for now). If my solution is not safe, I'd like a reason why it is not safe. (I edited my question)
Answer: If you want to be safe, here is what I would do.
If you can view your Drupal database with phpmyadmin or some other package/program/tool.
Export the field in question DB table that you want to change as a CSV file.
Add your new field, then edit 1 node and add a value to that field. Export the new field (which has 1 value) as a CSV file.
Open both CSV files in excel. Copy the node id (nid) column and the field value column from the field in question CSV to the New CSV and save changes.
Import New CSV to the New Field DB Table.
Do the above again for the _revision version of the table.
Flush the Drupal Cache.
Delete the field in question.


Como pegar de volta uma data formatada no formato MMM/yyyy para o formato yyyy-MM com date-fns

Question: Eu quero pegar o valor de uma date string formatada como MMM/yyyy para  o formato yyyy-MM.
Por exemplo, para abr/2017, quero retornar 2017-04.
Eu escrevi o seguinte código com a biblioteca date-fns, porém não está funcionando:
import format from 'date-fns/format';
import ptBR from 'date-fns/locale/pt-BR';

format(new Date('abr/2017'),'yyyy-MM', { locale: ptBR })

Comment: O primeiro argumento de format() não tem de ser uma data, em vez de string? Talvez com a função toDate()?
Comment: Eu corrigi lá... Esse é o código que eu estou tentando rodar, @epx
Answer: Primeiramente, new Date('abr/2017') não funciona da maneira que você espera:

// cada browser dá um resultado (Chrome: 01/01/2017 - Firefox: null/invalid date)
console.log(new Date('abr/2017'));

Testando no Node e no Chrome, o resultado foi uma data em 1 de janeiro de 2017, mas no Firefox deu "invalid date".
Isso porque o construtor de Date não aceita qualquer string em qualquer formato. Apenas os formatos indicados na especifição são garantidos que funcionem em todos os browsers/ambientes. Qualquer outro formato é dependente da implementação e não há garantia nenhuma que funcione (sobre isso e muito mais, leia mais aqui, aqui, aqui, aqui, aqui e aqui).

Enfim, se você tem a string "abr/2017" e quer convertê-la para outro formato, então primeiro você precisa converter esta string para uma data (ou seja, fazer um parsing) e depois converter esta data para o outro formato (ou seja, fazer uma formatação). Ou seja, você também vai precisar da função parse:
import format from 'date-fns/format';
import ptBR from 'date-fns/locale/pt-BR';
import parse from 'date-fns/parse';

// converter "abr/2017" para data
var data = parse('abr/2017', 'MMM/yyyy', new Date(), { locale: ptBR });
// converte a data para o outro formato
console.log(format(data, 'yyyy-MM', { locale: ptBR })); // 2017-04

Repare que no parse eu preciso informar o formato em que a string está (no caso, MMM/yyyy), para que ele interprete corretamente. No terceiro argumento passei new Date(), que ele usa como referência para preencher os campos restantes (pois a string só tem mês e ano, então ele precisa saber o que colocar nos outros campos - neste caso não faz tanta diferença porque só estou usando a data para formatar os mesmos campos). E por fim, informo o locale para que ele saiba interpretar corretamente o nome do mês.
Já na formatação, como só estou colocando os valores numéricos, nem precisava do locale (poderia ser apenas format(data, 'yyyy-MM') que já seria o suficiente).


Different formulas for matrix transformations

Question: I am a bit confused about how to get a matrix in a new basis.
On the one hand, we always use the multiplication by transformation matrix when we want to receive a matrix in a new basis:

$A' = CA$, where $A'$ is a matrix in a new basis; $C$ is a transformation matrix; $A$ is a matrix in the standard basis.

However, when we speak about getting the matrix in its eigenbasis, we use the other formula.

$A = C^{-1}A'C$, where $A$ is a matrix in a standard basis; $A'$ is a matrix in the eigenbasis; $C$ is the transformation matrix.

Why do we have different formulas while doing the same thing (matrix transformations) or do I get something wrong?
Answer: Any transformation of a matrix in a new basis has the form $A=C^{-1}A'C$. This is a consequence of the fact that a matrix represents a linear transformation that is the same in any basis.
So, for a vector $x$, whose components are expressed in the standard basis, we have the transformation $x \rightarrow Ax$.  In the new basis we have $x \rightarrow x'=Cx$ and the new matrix $A'$ acts on $x'$ in such a way that if we return to the standard basis, by menas of  $C^{-1}$,  the result is the same $Ax$.
This means that we must have
$ A x= (C^{-1}A' C )x \quad \forall x $.


Get Error When Compile Source (.C) file Using Microsoft Visual C/C++ compiler via GnuWin32 in Windows 7

Question: I will show you step as below ....
First You Download GNUWIN32.
Then Install on windows 7 and Set Environment Path.

I will make a.C Source file shown as below
#include <stdio.h>
int main()
{
    //FileName: a.C
    printf("Hello World !!! Its works");
    return 0;
}

I will to make Makefile. shown as below
#MakeFile Source Code... FileName: Makefile
OBJS: a

#add path visual c/c++ compiler
PATH=C:/Program Files\ (x86)\Microsoft\ Visual\ Studio\ 9.0/VC

CC: $(PATH)/bin/cl.exe

all: a

a:
    $(CC) -c a.C

clean:
    rm -rf $(OBJS)

I compile Source code. it get error.
Input: C:\Users\*****\Desktop\Test>make

output:
cc -c a.C
process_begin: CreateProcess(NULL, cc -c a.C, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [a] Error 2

Please Let Me help, How to build this code using visual c++ compiler.
Comment: why do you need to overcomplicate with GnuWin32 when you clearly have a Visual Studio installed?
Comment: You need to use the vsvars.bat file that comes with Visual Studio to set up the command line environment.
Comment: Hello, fritzone thanks for your replay. i build sqlcrypt source file with latest sqlite version but that follows this procedure...
Comment: Hello, Paul R Thanks for your replay but that procedure already follows.
Answer: PATH is the wrong name to use for a variable in your Makefile, because it is also the name of the variable that lists the paths to be searched when looking for other programs.  Change it to something else.
Comment: Hello Tom Thanks for your replay. Path Name was change and recompile again it get same error
Answer: There's a semantic error in your makefile. You are defining CC as a target, not a variable. Fix it thus:
CC=$(PATH)/bin/cl.exe

The clue is in the error message process_begin: CreateProcess(NULL, cc -c a.C, ...) failed.. You can see that it's trying to execute cc not cl.exe
Comment: Hello andy brown thanks for replay but i will change from CC to cc but it get same error. but you give me example build a.C file using Visual C++ compiler via Make command.
Answer: If you have a look at vcvars32.bat, provided by μSoft to set up your environment for the compiler, you will see that it adds several folders to your %PATH% environment variable.
You can express this %PATH% minging in make if you want to. Something like
export PATH := /cygdrive/c/Program Files/Microsoft Visual Studio 9.0/Common7/IDE:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC/BIN:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/Common7/Tools:/cygdrive/c/Program Files/Microsoft Visual Studio 9.0/VC/VCPackages:/cygdrive/c/Program Files/Microsoft SDKs/Windows/v6.0A/bin:${PATH}:/cygdrive/C/PROGRA~1/MICROS~2.0/VC/redist/DEBUG_~1/x86/MICROS~1.DEB

Yes, this is make syntax. It augments any existing %PATH% with a prefix and a suffix (see that ${PATH} right in the middle?).
Note though that this is in a format ready for cygwin make. You may need a few adjustments. Oh, and don't forget that cl.exe needs decent settings for %INCLUDE%, %LIB% and %LIBPATH% too.


A criterion for checking if a set of measurable functions satisfy a certain property.

Question: I have recently become interested in analysis, and while checking an old set of notes of mine, I discovered this "theorem" stated without proof in them:
Let $X$ be a compact metric space equipped with the Borel $\sigma$-algbera. Let $C_+(X)$ be the set of all the non-negative real-valued continuous functions on $X$. Let $BM_+(X)$ be the set of all the non-negative bounded measurable functions on $X$.

Theorem. Let $S\subseteq BM_+(X)$ be such that
$1)$ Whenever $f_1, f_2, f_3, \ldots\in S$, we have $\sum_if_i\in S$.
$2)$ Whenever $f, g\in S$ with $f\geq g$, we have $f-g\in S$.
$3)$ $C_+(X)\subseteq S$.
  Then $BM_+(X)\subseteq S$.

The problem with the above statement is that the first condition on $S$ cannot be satisfied. For if $f\in S$ is such that $f(x)>0$ for some $x$, then setting $f_i=f$ for each $i\geq 1$ implies by (1) that a non-bounded function is in $F$, contrary to the fact that $F\subseteq BM_+(X)$.
So the theorem is not true (or rather vacuously true) as stated.
What is the modification that one needs to make in order to make this statement true?
I am interested in this because in some situations it may be easier to see that continuous functions satisfy a certain property. A theorem of the above type will help us conclude that all bounded measurable functions also satisfy that property, provided some reasonable conditions are satisfied.
If you happen to know the correct statement, then can you also please provide a reference?
Comment: Maybe the sum was intended to be finite? (I don't actually know, though.)
Comment: The intention may be that the $f_i$ are all distinct. So, for example, they could be supported on pairwise disjoint sets. This would not require $S$ to be finite.
Answer: $\newcommand{\set}[1]{\{#1\}}$
$\newcommand{\mc}{\mathcal}$
$\newcommand{\R}{\mathbf R}$
The correct formulation and the proof is presented as Lemma 2 below.
Let $X$ be a set and $\mc D$ be a collection of subsets of $X$.
We say that $\mc D$ is a Dynkin system (or $\lambda$-system) if
$\bullet$ $X\in \mc D$.
$\bullet$ If $A\in \mc D$ then $X\setminus A\in \mc D$.
$\bullet$ If $A_1, A_2, A_3, \ldots \mc D$ such that $A_i\cap A_j=\emptyset$ whenever $i\neq j$, then we have $\bigcup_{i=1}^\infty A_i\in \mc D$.
Also, we way that a non-empty collection of subsets $\mc P$ of $X$ is a $\pi$-system if $\mc P$ is closed under finite intersections.

Theorem 1.
Dynkin's $\pi$-$\lambda$ Theorem.
  Let $\mc P$ be a $\pi$-system and $\mc D$ be a $\lambda$-system on $X$ such that $\mc P\subseteq \mc D$.
  Then $\sigma(\mc P)\subseteq \mc D$, where $\sigma(\mc P)$ denotes the $\sigma$-algebra generated by $\mc P$.

Let $M_{\geq 0}(X)$ denote the set of all the non-negative measurable functions on $X$ and $C_{\geq 0}(X)$ denotes the set of all the non-negative continuous function on $X$.

Lemma 2.
  Let $S\subseteq M_{\geq 0}(X)$ be such that
  1) $C_{\geq 0}(X)\subseteq S$.
  2) If $f, g\in F$ with $g\geq f$, then $g-f\in S$.
  3) If $f_1, f_2, f_3 , \ldots\in F$, then we have $\sum_{i=1}^\infty \in S$.
  Then $S=M_{\geq 0}(X)$.

Proof.
It is enough to show that the indicator functions of Borel sets in $X$ are in $S$.
Let $\mc C=\set{A\in \mc X:\ \chi_A\in S}$.
It is easy to see that $\mc C$ is a $\lambda$-system.
We show that each open set is in $\mc C$.
Let $U$ be an arbitrary open set in $X$.
For each $n\geq 1$, define
$$K_n=\set{x\in X:\ d(x, X\setminus U) \geq 1/n}$$
Then each $K_n$ is compact and is contained in $U$.
By Urysohn's lemma, we can find a continuous function $g_n:X\to [0, 1]$ supported in $U$ and which takes the value $1$ on all of $K_n$.
For each $k\geq 1$, define
$$
h_k=\max\set{g_1 , \ldots, g_k}
$$
Then note that
$\bullet$ Each $h_k$ vanishes outside of $U$.
$\bullet$ $h_k(x)\uparrow 1$ if $x\in U$.
$\bullet$ $h_1\leq h_2\leq h_3\leq \cdots $
Finally define $q_1=h_1$, and $q_i=h_i-h_{i-1}$ for each $i\geq 2$.
Then $\sum_{i}q_i=\chi_U$.
But since each $q_i$ is in $S$, we have that $\chi_U$ is also in $S$.
So the collection of all open sets, which is a $\pi$-system, is contained in $\mc C$.
But then by Theorem 1 we have that $\mc C$ contains the $\sigma$-algebra generated by the open sets, and we are done.
$\blacksquare$


BootStrap: With 5 Modal Forms on a page. How to check with JavaScript/jQuery which one is open

Question: I have 5 modal forms in a page. And I want to get the Id of the currently opened one.
I know I can check with $('#myModal').hasClass('in');. If I have 5 modal forms I have to write this 5 times. Which I don't want to.
Is there some way I can determine which modal the user has open currently open and then I will get the id of that.
Answer: You can use the shown.bs.modal event to get the current open modal.
Modal Events

shown.bs.modal
This event is fired when the modal has been made visible to the user (will wait for CSS transitions to complete). If caused by a click, the clicked element is available as the relatedTarget property of the event.

Here is an example

$('.modal').on('shown.bs.modal', function (e) {
  var crntModalId = "current modal id is: " + $(this).attr('id');
  $('.output').text('');
  $('.output').text(crntModalId);
})
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal-One">
  Launch modal one
</button>

        <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>

Modal title

        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>

<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal-Two">
  Launch modal two
</button>

        <button type="button" class="close" data-dismiss="modal" aria-label="Close">×</button>

Modal title

        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>

Answer: It's very simple, with bootstrap modal event's
To get any attribute value from the modal trigger button you can use $(e.relatedTarget)
To get the modal attribute value you can use $(e.currentTarget)
In your case, you can get the Opened modal id with
$('.modal').on('shown.bs.modal', function(e) {
    var modalid = $(e.currentTarget).attr('id');
});

Fiddle
Answer: A bootstrap modal gets automatically the class 'shown.bs.modal' when is open, so you can use this to track which one is open.


There's possible to pass PHP Post using Jquery to a Constructor Class In a Simple MVC Structure?

Question: Here is my JS code I'm trying to pass the data like a post to the class, I want to keep the integrity of the class. I want to get the form data, and via Jquery Ajax pass it as a post, and by different action it receives data values to be passed to the model and rendered by the view.
//Pass a POST to the PHP controller class via Ajax Jquery.
(I know my $.ajax is empty, this is just a example...)
$.ajax({
               url: 'php/Sys/Controllers/ControllerUsuario.php',
               type: 'POST',
               data: { },
               error: function() {

               },
               success: function(data) {

               }
            });
        });

Here is my PHP Class
class ControllerUsuario
{
   private $modelUsuario;
    private $action;

    /*public function actionUsuario(  ){
        //$codigo = $_POST[codigo];
        $this->modelUsuario = new ModelUsuario();
        $this->modelUsuario->setCodigo($codigo);
        return (new ViewUsuario($this->modelUsuario->selecionarUsuario()))->renderUsuario();
    }*/

    public function __construct($action) {
        $this->action = $action;

        switch ($this->action) {
            case 'actionUsuario':
                //$codigo = $_POST["codigo"];
                $this->modelUsuario = new ModelUsuario();
                $this->modelUsuario->setCodigo(1);
                return (new ViewUsuario($this->modelUsuario->selecionarUsuario()))->renderUsuario();
                break;

            default:
                # code...
                break;
        }
    }
}

Someone can help-me? please?
Comment: Your ajax call looks syntatically correct, though your data object is empty.  I'm not sure I understand your question.
Answer: Please clarify your question
as i understand from your question that you need to send data from ajax to you controller
You need to create object of your data
Ex. Ajax call
     $.ajax({
           url: 'php/Sys/Controllers/ControllerUsuario.php',
           type: 'POST',
           data: {action: "actionUsuario", codigo: "Test"},
           error: function() {

           },
           success: function(data) {

           }
        });
    });

and add this to end of your your controller
if(isset($_POST['action']) && $_POST['action']){
 return new ControllerUsuario($_POST['action']);
}

Answer: I made a Handler to get all data and after that I pass the values to the class, because my problem was with the $_POST inside the constructor class. It was giving me a problem. Error. I solved this. Thank you guys for Helping.


one application registered with two ICON on IPhone?

Question: Our customer has a particular request for my project.
how to use short-cut to launch our application?
what I am trying to do is create an standalone application does nothing except to launch my main application to skip some step go to more depth level?
maybe one application is registered with two icons, one is for main process, one is to do short-cut process.
is that possible?
I have searched this site, someone mentioned to create an application to launch another application? is there an example or a piece of code?
Thanks in advanced.
Answer: This is probably technically feasible with a custom url schemes, but I doubt that Apple would approve the "shortcut" app for release in the App store.


Java netty io/netty/channel/EventLoopGroup not found

Question: I get an exception

Caused by: java.lang.ClassNotFoundException: io.netty.channel.EventLoopGroup

when trying to start my server from runnable jar file, it works fine in IDE, but not in jar version. I don't understand why this is happening. What is missing here ? I use intellij and maven.
<?xml version="1.0" encoding="UTF-8"?>

http://maven.apache.org/xsd/maven-4.0.0.xsd">
    4.0.0
<groupId>Tcp-Server-listener-application</groupId>
<artifactId>TCPSLA</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Listener</name>

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
    <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-all</artifactId>
        <version>4.1.29.Final</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>de.saxsys</groupId>
        <artifactId>mvvmfx</artifactId>
        <version>1.7.0</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.4</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.12</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.7</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cassandra</groupId>
        <artifactId>cassandra-all</artifactId>
        <version>0.8.1</version>

        <exclusions>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
            <exclusion>
                <groupId>log4j</groupId>
                <artifactId>log4j</artifactId>
            </exclusion>
        </exclusions>

    </dependency>

</dependencies>

<build>
    <plugins>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>Source.Main</mainClass>
                    </manifest>
                </archive>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>2.18</version>
            <executions>
                <execution>
                    <id>integration-tests</id>
                    <goals>
                        <goal>integration-test</goal>
                        <goal>verify</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

Comment: @MINIKAS there is some problem with your pom.xml. Please share.
Comment: are you trying to run a spring boot project ?
Comment: No, I'm trying to run a simple JavaFX project.
Comment: Are you running the jar version from command line ?
Comment: @MINIKAS and where do you use netty?
Comment: @Gauntam To see the exception yes, then I can see whats going on.
Comment: @Srini I'm initializing Netty server as soon as I press "Start" button, it simply trying to create a server `TCPServer = new TCPServer(viewModel,Integer.parseInt(PortField.getText()));`
Comment: I guess you are not packaging the netty jar along with your project? can you unjar your project and see if you included it?
Comment: @MINIKAS  can you share the pom.xml
Comment: @Srini if it should be on \META-INF\maven then no, can't see netty.
Answer: While I can offer no explanation as to why it compiles, as did mine, but fails at runtime, I can offer a solution that worked for me:
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>5.0.0.Alpha2</version>
</dependency>

Apparently, '4.1.29.Final' does not include EventLoopGroup


Given $f(x)=ax-1$ and $g(x)=(x+1)/3$, if $f \circ g$ is identity then what is $a$?

Question:
The function $f$ is given as $f(x)=ax-1$ and the function $g$ as $g(x)=(x+1)/3$.
If $(f \circ g)(x)$ is an identity function, what is the value of $a$?
Comment: Welcome to MSE. For some basic information about writing mathematics at this site see, *e.g.*, [basic help on mathjax notation](/help/notation), [mathjax tutorial and quick reference](//math.meta.stackexchange.com/q/5020), [main meta site math tutorial](//meta.stackexchange.com/a/70559) and [equation editing how-to](//math.meta.stackexchange.com/q/1773).
Comment: I think $f(g(x)) = f((x+1)/3) = (ax+a)/3+1$, not $-1$, right ??
Comment: I think the question should be $f(x) = ax-1$. It was this way originally in the body. The title has always wrong. I believe the body has now been incorrectly edited to be consistent with the (incorrect) title.
Comment: Ah good, that's been fixed.
Comment: Both the printer and the OP may want to check signs.
Answer: I'm unsure about what your question is supposed to be, because I remember seeing a minus sign in there before the latest edit, i.e. $f(x) = ax-1$.
If your question is indeed that (i.e. $f(x) = ax-1$) with all else being unchanged, then it has a solution. $fg(x) = a\frac{x+1}{3} -1 = x\frac a3 + \frac{a-3}{3}$, and this is identically equal to $x$, so by comparing coefficients, $\frac a3 = 1$ and $\frac{a-3}{3} = 0$ which both have the consistent solution $a=3$. This is crucial.
If, on the other hand, your question has $f(x) = ax+1$, then $fg(x) = a\frac{x+1}{3}+1 = x\frac a3 + \frac{a+3}{3}$. If this is identically set equal to $x$, we get $\frac a3 = 1$ and $\frac{a+3}{3} = 0$ which have no consistent common solution. So there is no answer in this case.
Answer: There was a misunderstanding.
Edit:
$$fog(x)= a\dfrac{x+1}{3}-1$$
Let,$$y(x)=fog(x)$$
So,now,for to be identity function,
$$y(x)=x$$
$$fog(x)=x$$
$$\implies a\dfrac{x+1}{3}-1= x$$
$$a=3$$
Comment: The identity function is $x$.
Comment: $f(x)=x \implies f(g(x))=g(x)$
Comment: No, the composition $fg$ is the identity. So $fg(x) = x$.
Comment: Yes,I agree, the composite function is identity.,so $fog(x)=f(g(x))$ has to be identity. that is what i have written.
Comment: How is this what you have written? You've written $fg(x) = g(x)$, whereas what you should have written is $fg(x) = x$.
Comment: Thanks,I was thinking from a wrong corner.it is fixed now.
Comment: I've reversed my downvote.
Comment: Thanks.you are upvoted too.
Answer: Since $$f(g(x))=x$$ for all $x$, it is true also for $x=0$:  $${1\over 3}a-1=f({1\over 3})=f(g(0))=0$$
So $a=3$.
Comment: Your solution before the edit gave a solution to a question that had no solution (due to the typo in the question). Your method of simply substituting a convenient numerical value failed to reveal the error in the question (which meant your original solution was also wrong). Right now (post-edit), your solution is correct, but it is not ideal because it remains susceptible to the same issue (not being able to pick up on when the question itself is wrong and no solution exists).
Comment: should' it be f(g(x))=g(x)?
Comment: No, it si $x$ !
Comment: why? thats not an identity function.
Comment: Then which is it?
Comment: f((x+1)/3)=x this is what f(g(x))=x means
Comment: Yes, that is true.
Comment: how is that an identity?
Comment: Then what is it?
Comment: @greedoid I think the question has been incorrectly edited. It should be $f(x) = ax-1$. See my answer please.
Comment: The incorrect solution here is fairly instructive - it's always better to solve it algebraically by comparing coefficients rather than substituting single values.
Comment: @Deepak Why is that better?
Comment: I would hardly say thatsome method is better than other. I simply haven't finish the task i.e. I didin't made a check for that value.


Executar Ajax primeiro

Question: A última linha do código a baixo é a primeira a ser executada, e eu preciso que a função contendo esse ajax retorne true ou false, porém quando coloco para retornar dentro do success,error ou complete ele não funciona.
<code>error: function (response) {
        if (((response.responseText.split("{")[1]).split("}")[0]).split(":")[1]) {
            confirmationValue = true;

        } else {
            confirmationValue = false;
        }
    },
    complete: function () {
        console.log(confirmationValue);
        return confirmationValue;
    }
});
console.log(confirmationValue);
</code>
Obrigado!
Comment: Ajax, como diz o próprio nome é assíncrono, logo dessa forma o return não fará sentido. Pode tentar usando async/await, exemplo [click aqui](https://stackoverflow.com/questions/48506445/javascript-await-async-return-ajax-result)
Answer: Você pode utilizar o sync e await do ES6, desta forma você faz com que o restante do seu código aguarde o resultado da sua função ajax para continuar o código, no seu caso aguarda o retorno booleano para dar sequ
<code>    async  function executar(){
    return $.ajax({
    'url': 'https://swapi.co/api/people/1',
    'metod': 'GET',
    success: async function(data){
        return data
    }
  })
}

async function chamaFuncao(){
  await executar()
  .then((res) =>{
        alert(res.name)
  })

  alert('Continua a execução')

}

chamaFuncao();
</code>
Veja o exemplo no JSFiddle

Executar Ajax primeiro


Counting number of messages sent by sendmail

Question: Does anyone know of a utility of that would give me the total number of email messages sent by sendmail, using old maillogs ?
Someone suggested the use of the mailstats utility, however this program seems to give the statistical information for all mail log file entries. Though this is beneficial, it's not helpful on this case since a single mail message sent by sendmail can log anywhere to 5 different log entries.
Answer: You can use grep -c to count the number of matching lines instead of pipe grep to wc -l:
grep -c "Message accepted for delivery" /var/log/maillog

Comment: Neat trick! It's much faster than piping! On a 2GB file it ran in 1/3 the time.
Answer: Does grep 'Message accepted for delivery' /var/log/maillog| wc -l provide the number you need?
Comment: Is the string 'Message accepted for delivery' the standard sendmail log entry for successful messages? If so then this is what I was looking for. -Tony


Trying to understand the function $y = x^x$

Question: I am trying to understand the function $y=x^x$:
1) Why is $0^0$ not defined? Why isn't it defined as $0^0=1$? The limit of the function for $x\to0$ also goes to $1$
2) Why is it only defined for $x>0$ and not for $x\le0$? For example $(-2)^{(-2)}=\frac{1}{4}$ which is defined.
Comment: Hint: What about $(-\tfrac 12)^{-\tfrac 12}$ ?
Comment: Among many papers about $0^0$ : https://fr.scribd.com/doc/14709220/Zero-puissance-zero-Zero-to-the-Zero-th-Power .
Answer: $0^0$ is not defined since the limits of $x^0$ and $0^x$ differ as $x\to 0^+$. Just as with $\frac00$, $0^0$ is not the limit of $x^x$, it is the limit of $x^y$ as $(x,y)\to (0,0)$.
And yes, $x^x$ is defined on the negative integers, but not on any other negative numbers.
Answer: The first answer gives a good explanation for why $0^0$ is not defined. Here's a more in-depth look at why you can't define $x^x$ on the negative real numbers:
Firstly, the function is defined on all the negative integers $(-m)^{(-m)}=1/(-m)^m$. But once you start trying to extend the domain of $x^x$ to arbitrary negative fractions, you'll get stuff like $(-1/2)^{(-1/2)}$, which in fact is a complex number.
The problem, of course, is that this depends on the choice of representation of the rational number $x$. For example, $x=-1/3=-2/6$ are both the same number, but when you take $x^x$ the odd denominator of $-1/3$ gives you back a real number, whilst the even denominator of $-2/6$ gives you back a complex number. Thus the function isn't well-defined on the negative rationals (all this depending, I guess, on the "multi-valued" branching of the complex square root/$n$th root function).
Answer: Another way of looking at this function is to rewrite it as
$$y=e^{\ln x^x}=e^{x\ln x}.$$ The answers to your questions then follow easily:
1) $\lim_{x\to 0}e^{x\ln x}=e^{\lim_{x\to0}x\ln x}$. This limit does not exist since $\lim_{x\to 0^+}\ne\lim_{x\to0^-}$.
Note that $\lim_{x\to0^+}x\ln x = 1$, but $\lim_{x\to0^-}x\ln x$ does not exist.
2) Using complex logarithm $(-2)^{-2}=e^{-2\ln(-2)}=e^{-2(\ln|2|+in\pi)}=e^{-2\ln|2|}e^{-2in\pi}=|2|^{-2}\cdot 1=\frac{1}{4}$. Like this you can compute $y=x^x$ for any $x\in\mathbb{C}$ (thus also any negative real numbers).
As mentioned, in the case of negative real numbers (and for that matter any complex numbers) we obtain complex solutions, e.g. $(-\frac{1}{2})^{-1/2}=e^{-1/2\ln(-1/2)}=e^{-1/2(\ln|1/2|+in\pi)}=(\frac{1}{2})^{-1/2}e^{-in\frac{\pi}{2}}=\{\pm\sqrt{2}, \pm\sqrt{2}i\}$, depending on $n\in\mathbb{Z}$.


What does it mean for a map to factorize over something?

Question: In lectures about ring theory my professor says that a map factorizes over a ring and then draws commutative diagrams. I have never heard this expression before.
What exactly does it mean for a map to factorize? Is it equivalent to the diagram commuting or is it stronger? Why this name?
Answer: When you have a commutative diagram (triangle) that captures $h = g \circ f$, it has the same appearance as factoring an integer such as $12 = 3 \cdot 4$, hence the terminology:  the integer $12$ has been decomposed into constituent components, and the same is true for $h$.  The most fundamental appearance of this that you should master is the first isomorphism theorem:  a surjective ring hom $h: R \to T$ factors through a quotient of the kernel, the factors being the quotient map $R \to R/\mathrm{ker}(h)$ and the resulting induced map $R/\mathrm{ker}(h) \to T$ (an iso!).


Working with FebricJs and outputting toDataURL

Question: I found a code on your site that loads an image using FebricJs into the browser. Then you can twist it and resize it and pass it base64 to the output. Loading goes fine, I edit its size and when I click on the output in , the original image is displayed without changes.
https://jsfiddle.net/sujitkm/p51zwL50/
I have not worked with this script, help me understand why this is happening? I want to get the modified image in canvas.toDataURL (). Thanks.
 var canvas = new fabric.Canvas('canvas');
            document.getElementById('file').addEventListener("change", function (e) {
                var file = e.target.files[0];
                var reader = new FileReader();
                reader.onload = function (f) {
                    var data = f.target.result;
                    fabric.Image.fromURL(data, function (img) {
                        var oImg = img.set({left: 50, top: 100, angle: 00}).scale(0.9);
                        canvas.add(oImg).renderAll();
                        var a = canvas.setActiveObject(oImg);
                         oImg.setCoords();
                    var dataURL = canvas.toDataURL({ format: 'jpeg', quality: 0.8 });
                                                canvas.renderAll();
     console.log("Canvas Image " + dataURL);
                document.getElementById('txt').href=dataURL;
});
                 };
                reader.readAsDataURL(file);

            });

Answer: There is old url in href, which was set only when you add the object to canvas and didn't change after the object transformation. This is the reason why there is the old image. You need to use fires from doc for it. I prepared code, it works:
const canvas = new fabric.Canvas('canvas');
document.getElementById('file').addEventListener('change', function(e) {
  const file = e.target.files[0];
  const reader = new FileReader();
  reader.onload = function(f) {
    const data = f.target.result;
    fabric.Image.fromURL(data, function(img) {
      const oImg = img.set({ left: 50, top: 100, angle: 00 }).scale(0.9);
      canvas.add(oImg).renderAll();
      const a = canvas.setActiveObject(oImg);
    });
  };
  reader.readAsDataURL(file);
});

canvas.on('object:modified', () => {
  const dataURL = canvas.toDataURL({ format: 'jpeg', quality: 0.8 });

  console.log('Canvas Image ' + dataURL);
  document.getElementById('txt').href = dataURL;
});


Is Git now the only way to install Drush?

Question: Going in circles trying to figure out the right way to install Drush on a Linux CentOS system.  I have Git set up, but as I'm not planning to contribute to Drush code at the moment, it's not unambiguously clear that I should be using Git.
Some directions say to use PEAR, but when I go to the Drush project page, the directions say to get Drush 6 from Git.  Tutorials I have found demo wget and PEAR, not Git.  And the Git project page View says, "Use our Github project for contributing code, or reporting bugs, or requesting features," none of which applies.
Could an experienced Drupalista please answer the following?

Is Git now the only method of obtaining Drush?  Someone asked a
similar question more than a year ago when PEAR was still
recommended.
If Git is the way to go, I have read that drush should not be installed within the website directories, so which directory is it recommended to be in when I invoke the following?
git clone --branch 7.x-5.x http://git.drupal.org/project/drush.git

I'm looking forward to using Drush.  Thanks!
Answer: Drush moved to GitHub a few weeks ago.  The official home is now: https://github.com/drush-ops/drush
The current preferred method is to install with composer:
composer global require drush/drush:6.*

If you are working with Drupal 8, or need a patch that hasn't been backported, then you can work with the latest version:
composer global require drush/drush:dev-master

You can also use composer to install a particular version.
You can install it manually; and normal GitHub retrievals apply.  You can download the master (link is on the main page), or clone the repo locally.  When you clone locally, you can checkout any tag you want.
I have it installed in my home directory, eg
cd ~
git clone https://github.com/drush-ops/drush.git drush

After, you need to run composer
cd ~/drush
composer install

I then put ~/drush/ in my $PATH:
export PS1=$PATH:~/drush/

Everything should work as normal.
Sidenote.  Even if you don't want to contribute back, tracking your whole site with git is a great way to handle dev/live, and for backing out oopsies.
Comment: This didn't seem to work for me.  My understanding is you must use composer now
Comment: @User composer is the recommended method right now, but you can `git clone`, but you need to do a `composer install` after. I don't recall when this became a requirement, but it happened sometime after this answer.
Answer: (1). Yes, you can still install Drush using pear.  See the section "Installing - Pear" in the README.md, which is displayed on the project page: https://github.com/drush-ops/drush
To whit:
pear channel-discover pear.drush.org
pear install drush/drush

(2). If installing Drush from git, the best branch is 6.x, and the most recent tag is 6.0.0.
If you install from Pear as shown above, and you do -not- get Drush 6.0, please post a bug on the GitHub project.  (Sorry, don't have time to fire up a VM and test the pear install right now, but it is presumed to work.)
Update: I missed the second question in (2).  You can put it where you want. A lot of people put it in /usr/local/drush when doing a system-wide install.  I usually install it per-user, in ~/local/drupal/drush.  Just make sure that you also add the folder you use to your PATH.  Like chrisjlee, I have an install script you may examine if you wish: https://github.com/greg-1-anderson/utiliscripts/blob/master/move-in
Comment: The pear install works fine for 6.0.0, I upgraded a legacy server to it the other day
Comment: It seems that the channel pear.drush.org is not working any more.
Answer: You can try out my project. It install's drush automatically for you:
https://github.com/chrisjlee/uamp-files/blob/master/drush/setup.sh
It's rather simple. It assumes you have git installed though.
Comment: I had to replace `git co` with `git checkout`
Comment: ya I got this as well when trying to install 'git: 'co' is not a git command. See 'git --help'.

Did you mean one of these?
 commit
 clone
 log'
Answer: The package repo versions of Drush are outdated, and there were major improvements to Drush that make it a better idea to install it from the git repo. If you're keeping Drupal up to date, you should be keeping Drush up to date with it as things can break when the two are not updated together.
Drush should be installed to /usr/local/bin or /opt on most *nix systems. /opt may be better if you want to be able to backup and restore the installation and save your settings.
Answer: Since Version 9, Drush is installed by Composer when listed as dependency of Drupal 8. See also at docs.drush.org.

Instructions to install or upgrade a global Drush 8 (without using Git):

# Browse to https://github.com/drush-ops/drush/releases and download the drush.phar attached to the latest 8.x release.

# Test your install.
php drush.phar core-status

# Rename to `drush` instead of `php drush.phar`. Destination can be anywhere on $PATH.
chmod +x drush.phar
sudo mv drush.phar /usr/local/bin/drush

# Optional. Enrich the bash startup file with completion and aliases.
drush init

More detailed information can be found at docs.drush.org. There is also an instruction for a site-local installation.
Comment: This is how I installed it on my computer.
Answer: On OS X/macOS I always installed it with Homebrew. It's just brew install drush. End of story.
Only recently since D8 was released and Composer got the state of the art I also always have it installed site-locally via composer require drush/drush to make use of it in Docker containers etc. for example.

Drush 9 (D8.3+)
Actually since version 9 installing Drush with Composer is the one and only recommended way to install Drush:

Drush 9 only supports one install method. It requires that your Drupal
  8 site be built with Composer and Drush be listed as a dependency.

@see http://docs.drush.org/en/master/install/

No Composer
What else you can do if you have no Composer on prod for example but at least have access to the command line, is to install Drush with Composer on a different machine, then upload the vendor/ directory and then access the Drush binary like that for example:
$ vendor/drush/drush/drush -y updb

Answer: Following is from https://www.drupal.org/node/2009426 :

Below is how I install Drush on CentOS systems that have H-Sphere installed as a control panel
1 - Grab a copy of Drush and untar it in your shared folder
sudo wget --quiet -O - http://ftp.drupal.org/files/projects/drush-7.x-5.9.tar.gz | sudo tar -zxf - -C /usr/local/share
(Note, change the link above you the link to the latest version of drush on Drupal.org.)
2 - Create a symbolic link to where Drush can be found on your server
sudo ln -s /usr/local/share/drush/drush /usr/local/bin/drush
3 - Get Drush to auto download the required "stuff"
sudo drush
Drush won't work yet as it won't know where to find php, so
4 - Open your bash_profile file and edit the PATH line from something like this
bash_profile: PATH=/hsphere/shared/bin:/hsphere/shared/sbin:/hsphere/local/var/vpopmail/bin:/usr/local/bin:/usr/local/sbin:$PATH:$HOME/bin
to something like this (note the php path in this version):
PATH=/hsphere/shared/bin:/hsphere/shared/sbin:/hsphere/local/var/vpopmail/bin:/usr/local/bin:/usr/local/sbin:/hsphere/shared/php53/bin:$PATH:$HOME/bin
5 - Reboot your server and YEE HAW!

With this instructions from the offical drupal site, there is absolut no need for git or any other 3rd party tools. Im perfectly fine with installing drush on my multi side vm that way.
Answer: Drush 9, which at the moment I am writing this answer is the master branch, only supports a single installation method: The Drupal 8 site must be built with Composer, and Drush be listed as dependency. Installing it globally is not supported anymore. Moshe Weitzman says it clearly in a comment at Drush 8.x doesn't install Drupal 8.4.x and Drush master doesn't install Drupal 8.3.x.

Global install of Drush is no longer supported because you get errors exactly like the one described here. The install docs already don't mention it anymore. Each project needs to name Drush as a dependency. Its fine if Drush8 sites stick with the global install and Drupal 8.3-. For Drupal 8.4, they are going to need to use Drush9 as a dependency.

The documentation for the master branch also says it in a short note.

Drush 9 (coming soon!) only supports one install method. It requires that your Drupal 8 site be built with Composer and Drush be listed as a dependency.

The note is referring to Drupal 8 because the minimum requirement for Drush 9 (which is the master branch, at this moment) is Drupal 8.3+. The Drush 8 documentation, reports the following commands as method to globally install it.
# Download latest stable release using the code below or browse to github.com/drush-ops/drush/releases.
wget http://files.drush.org/drush.phar

# Test your install.
php drush.phar core-status

# Rename to `drush` instead of `php drush.phar`. Destination can be anywhere on $PATH.
chmod +x drush.phar
sudo mv drush.phar /usr/local/bin/drush

# Optional. Enrich the bash startup file with completion and aliases.
drush init


File permissions are not being preserved while after unarchive tar.gz

Question: I'm trying to unarchive tar.gz file using Apache Compress library under Linux with Java.
How can I preserve files permissions using Apache Compress library when unarchiving tar.gz?
public void run(ByteTransferCallback callback) throws IOException
{
    this.entries = new HashSet<>();

    try (TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(
            new GzipCompressorInputStream(new BufferedInputStream(new FileInputStream(this.tarGZipFile)))))
    {
        TarArchiveEntry entry = null;

        while ((entry = tarArchiveInputStream.getNextTarEntry()) != null)
        {
            if (entry.getName().startsWith(this.tarGZipPath))
            {
                boolean cancelled = !unarchiveEntry(tarArchiveInputStream, entry, callback);
                if (cancelled) break;
            }
        }

    }

}

protected boolean unarchiveEntry(TarArchiveInputStream tar, TarArchiveEntry
     entry, ByteTransferCallback callback) throws IOException
{
    File entryDestination = new File(this.destination,
    entry.getName().replaceFirst(this.tarGZipPath, ""));

    entryDestination.getParentFile().mkdirs();

    this.entries.add(entryDestination);

    boolean result = false;

    if (entry.isDirectory())
    {
        entryDestination.mkdirs();
        result = true;
    }
    else
    {
        result = unarchiveFileEntry(tar, entry, entryDestination, callback);
    }

    return result;
}

protected boolean unarchiveFileEntry(TarArchiveInputStream tar,
TarArchiveEntry entry, File destination, ByteTransferCallback callback)
throws IOException
{
        try(OutputStream out = new FileOutputStream(destination))
        {
            return copy(tar, out, callback);
        }
}

protected boolean copy(InputStream in, OutputStream out,
ByteTransferCallback callback) throws IOException
{
    int numBytes = 0;
    byte[] buffer = new byte[DEFAULT_BUFFER_SIZE];

    boolean cancelled = false;

    while (EOF != (numBytes = in.read(buffer)) && !cancelled)
    {
        out.write(buffer, 0, numBytes);
        cancelled = !callback.onBytesTransferred(numBytes);
    }

    return !cancelled;
}

From each entry, I can get permission in Unix format using TarArchiveEntry.getMode(), but how I can set it to each unarchived file?
Comment: how are you coding it?
Comment: Possible duplicate of [why doesn't tar preserve file permissions?](https://stackoverflow.com/questions/20338215/why-doesnt-tar-preserve-file-permissions)
Comment: My question is different from  [why doesn't tar preserve file permissions?](https://stackoverflow.com/questions/20338215/why-doesnt-tar-preserve-file-permissions)
Answer: Under Linux/Unix there's no way for a normal user to transfer the ownership of a file system object to another user. Only root (UID 0) can.
In this case your program needs to be run as root and you need to use the system call chown() and related (see man 2 chown).
For the file permissions and time and date you need to use the system call utime() and related ones (see man 2 utime).
You can do this from Java with the methods available in java.io.File like setExecutable, setReadable, and setWritable.
Please refer to the official documentation for the details.
Comment: This means I have to read and parse each file unix permission via getMode() and set it to all files with setExecutable(boolean) and etc.. ? This is error prone!
Comment: This is what the `tar` tool does under Unix/Linux. This is what's needed!


How do I remove the author textfield from the comment form?

Question: How do I remove the Author textfield from the Comments form. I added a couple new fields:

First Name
Last Name

But now in addition to asking for First Name and Last Name, there is a 'Your Name' field which is confusing.
So it looks like this:

Add New Comments
First Name (text box)
Last Name (text box)
Your name (text box)
Subject (text box)
Comment (text box)

I'd like to remove the 'Your name (text box) from all comments since it is a repeating field.
This is the code I am using.
function onviasupport_preprocess_page(&$vars) {
    //modify taxonomy pages breadcrumbs
    if (!empty($vars['template_files'][0]['page-taxonomy'])){
            //pull term id from variable templates list
            foreach($vars['template_files'] as $key => $value){
                if(substr_count($value, 'page-taxonomy-term-') > 0){
                    $tid = explode('-', $value);
                    $tid = $tid[3];
                }
            }
            if (!empty($tid)){
                //We're on a taxonomy term page.
                $term = taxonomy_get_term($tid);
                $link = getLinkByPath();
                $bc = '
Home  › '.$link;
                $vars['breadcrumb'] = $bc. ' › '. $term->name .'
';
            }
    }

    //var_dump($vars['page']['content']['system_main']['nodes']);

    if (!empty($vars['node'])){
        // If the node type is "blog" the template suggestion will be "page--blog.tpl.php".
        $vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type;
        $vars['theme_hook_suggestions'][] = 'page__'. $vars['node']->type.'__'.$vars['node']->nid;

        //modify resource page & article breadcrumbs..
        //$lnk = getLinkByType($vars['node']->type);
        $lnk = getLinkByPath();

        $bc = '
Home';
        if ($lnk) { $bc .= ' › '.$lnk;}

        //add the first taxonomy term associated with this node
        $tid = _get_node_taxonomy_tid($vars['node']);
        $term = taxonomy_term_load($tid);
        if(!empty($term)) {
            $bc .= ' › '.l($term->name, drupal_get_path_alias('taxonomy/term/'.$tid));
        }

        $vars['breadcrumb'] = $bc . ' › '.$vars['node']->title .'
';

        //insert the title emphasis
        //$vars['head_title'] = cleanTitle($vars['head_title']);
        $vars['title'] = lowerG(insertEmTrig($vars['node']->title));
        //$vars['node']->title = insertEmTrig($vars['head_title']);

        if ($vars['node']->type == 'primary_landing' || $vars['node']->type == 'resource_landing'){
            $vars['title'] = lowerG(insertEmTrig($vars['node']->title, '
'));
        }
    }
}

//given a node, return the first taxonomy tid assigned
function _get_node_taxonomy_tid($node) {
    $tkeys = array();
    foreach($node as $key => $val) {
        if(substr_count($key, 'taxonomy')) {
            $tkeys[] = $key;
        }
    }
    foreach($tkeys as $tvoc){
        if(!empty($node->$tvoc)) {
            $tx = $node->$tvoc;
            return $tx['und'][0]['tid'];
        }
    }
}

//create a list of clickable letters to glossary pages.
function glossary_letters($term = array(), $nodeTx = array()){
    $output = '';
    /*
    //if we're on a node, grab the term id
    if(!empty($nodeTx)){
        foreach($nodeTx as $nt){
            if($nt->vid == "5"){  //the glossary
                $tid = $nt->tid;
                break;
            }
        }
    }
    */

    //make sure this is a term in the glossary vocabulary
    if ($term->vid == "5") {
        //search through the nodes assigned to this term, and strip off the letter from their title.
        //$sql = taxonomy_select_nodes(array($tid),'or', 0, false, 'n.title DESC');
        // - not working well due to it's running db_query_range(), fine for a limited range but not this.

        $result = db_query('SELECT DISTINCT(n.nid), n.title, n.created FROM {node} n
            INNER JOIN taxonomy_index tn ON n.nid = tn.nid
            WHERE tn.tid = :tid AND n.status = 1', array(':tid' => $term->tid));

        $nodes = array();
        foreach ($result as $node){
            $ltr = explode(' - ', $node->title);
            $ltr = strtoupper($ltr[1]);
            $nodes[$ltr] = $node->nid;  //letter is now matched to the nid
        }
        if(!empty($nodes)) {
            $output .= '
';
            foreach(range('A','Z') as $letter){
                if(array_key_exists($letter, $nodes)){
                    $path = url('node/'.$nodes[$letter]);
                    $output .= ''.$letter.'  ';
                } else {
                    $output .= $letter.'  ';
                }
            }
            $output .= '
';
        }
    }
    return $output;
}

//given a vocabulary object, return the link to the correct primary page
function getVocabLink($voc){
    $link = '';
    if(is_array($voc->nodes)){
        foreach($voc->nodes as $key => $val){
            if (empty($link)) {
                $link = getLinkByType($key);
            }
        }
    }
    return $link;
}
function getLinkByPath() {
    $link = '';
    $pth = drupal_get_path_alias();
    if (substr_count($pth, 'product-guide') > 0){
        $link = l('Product Guide','product-guide');
    }
    if (substr_count($pth, 'resources') > 0){
        $link = l('Resources','resources');
    }
    if (substr_count($pth, 'your-account') > 0){
        $link = l('Your Account','your-account');
    }
    return $link;
}
function getLinkByType($type){
    if ($type == 'product_guide_page'){
        $link = l('Product Guide','product-guide');
    }
    if ($type == 'resource_page'){
        $link = l('Resources','resources');
    }
    if ($type == 'your_account_page'){
        $link = l('Your Account','your-account');
    }
    if ($type == 'user_guide'){
        $link = l('Product Guide','user-guides');
    }
    return $link;
}

function swapTitle($title){
    //now change the default Drupal page title, put brand at beginning
    $t = str_replace(' | Onvia', '',$title);
    return 'ONVIA | '.$t;
}

/* function to force lowercase "g" on gBusiness  */
function lowerG($gtext){
    //Don't lowercase the content, as that could be bad for IDs and classes, so I test for all variances.
    $gtext = str_replace('GBUSINESS','gBUSINESS', $gtext);
    $gtext = str_replace('GBusiness','gBusiness', $gtext);
    $gtext = str_replace('gBusiness','gBusiness', $gtext);
    $gtext = str_replace('gBUSINESS','gBUSINESS', $gtext);
    return $gtext;
}

function onviasupport_breadcrumb($vars){
    if (!empty($vars)) {
        $crumbs = '
'.implode(' › ', $vars['breadcrumb']).'
';
        $crumbs = str_replace('^','', $crumbs);
        return $crumbs;
  }
}

/**
*  insert the  tag into title using trigger ^
*/
function insertEmTrig($title, $tag=''){
    $title = explode('^',$title);
    if(count($title) > 1) {
        return $title[0].$tag.' '.$title[1].'';
    } else {
        return $title[0];
    }
}

/**
*  clear the trigger ^ for head title
*/
function cleanTitle($title){
    $title = str_replace('^','', $title);
    return $title;
}

/**
*  insert the  tag half-way through the title, auto = no trigger
*/
function insertEmAuto($title, $tag = ''){
        $title = explode(' ',$title);
        $half = (floor(count($title) / 2));
        array_splice($title, $half, 0, $tag.'');
        $title = implode(' ',$title). '';
        return $title;
    }

//return a list of node titles as links from array of nodes. Used in articles.
function get_title_list($rel_nodes){
    if (empty($rel_nodes[0]['nid'])){
        return '';
    } else {
        $filter = '';
        foreach($rel_nodes as $item){
            if (strpos($filter, 'AND') > 0){
                $filter .= ' OR nid = '.$item['nid'];
            } else {
                $filter .= ' AND nid = '.$item['nid'];
            }
        }
        $query = db_query('SELECT nid, title FROM {node} WHERE status = 1 '.$filter.' ORDER BY created DESC');
        $list = '';
        while ($result = db_fetch_object($query)){
            $itemtitle =  cleanTitle($result->title);
            $list .= '
'.l($itemtitle, 'node/'.$result->nid).'
';
        }
        return $list;
    }
}

/**
* This is a theme override of the theme_table function from Drupal's  theme.inc file.
* Only thing I'm doing here is stripping out any ^ symbols
*/
function onviasupport_table($variables) {
  $header = $variables['header'];
  $rows = $variables['rows'];
  $attributes = $variables['attributes'];
  $caption = $variables['caption'];
  $colgroups = $variables['colgroups'];
  $sticky = $variables['sticky'];
  $empty = $variables['empty'];

  // Add sticky headers, if applicable.
  if (count($header) && $sticky) {
    drupal_add_js('misc/tableheader.js');
    // Add 'sticky-enabled' class to the table to identify it for JS.
    // This is needed to target tables constructed by this function.
    $attributes['class'][] = 'sticky-enabled';
  }

  $output = '
\n";

  if (isset($caption)) {
    $output .= '
' . $caption . "
\n";
  }

  // Format the table columns:
  if (count($colgroups)) {
    foreach ($colgroups as $number => $colgroup) {
      $attributes = array();

      // Check if we're dealing with a simple or complex column
      if (isset($colgroup['data'])) {
        foreach ($colgroup as $key => $value) {
          if ($key == 'data') {
            $cols = $value;
          }
          else {
            $attributes[$key] = $value;
          }
        }
      }
      else {
        $cols = $colgroup;
      }

      // Build colgroup
      if (is_array($cols) && count($cols)) {
        $output .= ' <colgroup' . drupal_attributes($attributes) . '>';
        $i = 0;
        foreach ($cols as $col) {
          $output .= ' <col' . drupal_attributes($col) . ' />';
        }
        $output .= " </colgroup>\n";
      }
      else {
        $output .= ' <colgroup' . drupal_attributes($attributes) . " />\n";
      }
    }
  }

  // Add the 'empty' row message if available.
  if (!count($rows) && $empty) {
    $header_count = 0;
    foreach ($header as $header_cell) {
      if (is_array($header_cell)) {
        $header_count += isset($header_cell['colspan']) ? $header_cell['colspan'] : 1;
      }
      else {
        $header_count++;
      }
    }
    $rows[] = array(array('data' => $empty, 'colspan' => $header_count, 'class' => array('empty', 'message')));
  }

  // Format the table header:
  if (count($header)) {
    $ts = tablesort_init($header);
    // HTML requires that the thead tag has tr tags in it followed by tbody
    // tags. Using ternary operator to check and see if we have any rows.
    $output .= (count($rows) ? '

' : '
');
    foreach ($header as $cell) {
      $cell = tablesort_header($cell, $header, $ts);
      $output .= _theme_table_cell($cell, TRUE);
    }
    // Using ternary operator to close the tags based on whether or not there are rows
    $output .= (count($rows) ? "

\n" : "
\n");
  }
  else {
    $ts = array();
  }

  // Format the table rows:
  if (count($rows)) {
    $output .= "
\n";
    $flip = array('even' => 'odd', 'odd' => 'even');
    $class = 'even';
    foreach ($rows as $number => $row) {
      // Check if we're dealing with a simple or complex row
      if (isset($row['data'])) {
        $cells = $row['data'];
        $no_striping = isset($row['no_striping']) ? $row['no_striping'] : FALSE;

        // Set the attributes array and exclude 'data' and 'no_striping'.
        $attributes = $row;
        unset($attributes['data']);
        unset($attributes['no_striping']);
      }
      else {
        $cells = $row;
        $attributes = array();
        $no_striping = FALSE;
      }
      if (count($cells)) {
        // Add odd/even class
        if (!$no_striping) {
          $class = $flip[$class];
          $attributes['class'][] = $class;
        }

        // Build row
        $output .= '
';
        $i = 0;
        foreach ($cells as $cell) {
          $cell = tablesort_cell($cell, $header, $ts, $i++);
          $output .= _theme_table_cell(cleanTitle($cell));
        }
        $output .= "
\n";
      }
    }
    $output .= "
\n";
  }

  $output .= "
\n";
  return $output;
}

Comment: In the shown code I don't see any part that is relevant for the question, nor do I see any code trying to remove the field as the question asks. Since the question is about code to write, we expect to see a tentative to do as reported in the question. In that case, we can point out what is wrong. Differently, the question is too broad. We are not here to tell you the _best way_ of doing something, but to answer a well defined question with a definitive answer. The answer could also change over the time, but at least there is one.
Answer: You could do use a hook_form_alter(), eg, something like this:
function YOURMODULE_form_comment_form_alter(&$form, &$form_state) {
  global $user;

  if (!$user->uid) {
    unset($form['author']['name']);
  }

}

to remove that field for anonymous users.  If you want that field gone for everyone, then just remove the if :)
Note:  you could also unset() the whole $form['author'] but then you would not be able to allow other contact information, eg, the homepage and email address, when you use:
Answer: You have several options. One is to simply hide the field by using CSS. As the author field is not required it should work like this without problems.
The other is to do some form altering. You can do this in template.php on the theme level or in a custom module.
There is a pretty good description here: http://planken.org/2013/10/drupal-remove-your-name-elements-comment-form
It boils down to this in template.php:
function YOURTHEME_form_comment_form_alter(&$form, &$form_state) {
  $form['author']['#access'] = FALSE;
}

or to this in a custom module:
function YOURMODULE_form_comment_form_alter(&$form, &$form_state) {
  $form['author']['#access'] = FALSE;
}

Comment: It would be along the lines of `#comment-form .form-item-name { display: none; }` but the alter is the right way to go.
Comment: How would I hide the field using CSS?
Comment: @user3075987 You open the site in a browser, open the developer tools available to you to inspect the element, look for the wrapper div of the form element and use it's ID or class to selectively set `display: none;` on that element. This would have to be done in one of the CSS files of your theme. The proper solution is the form altering though ;)
Comment: I put this into the template.php file and it broke my site:
Comment: @user3075987 How did it break your site?
Comment: The site doesn't come up when I put this code into the template.php file
Comment: @user3075987 Can you post your complete code in a pastebin please? General remark: you have to replace the string `MYTHEME` with the actual name of your theme.
Comment: I paste the code in my original post.
Comment: Yes, I will replace 'MYTHEME' with the name of my theme
Comment: @user3075987 Please correct the code formatting in your original post. Currently it is unreadable.
Comment: I included the jfiddle link
Comment: let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/13175/discussion-between-berliner-and-user3075987)
Comment: @user3075987 There is no THEMENAME_comment_form_alter function in there.


Brownian brigde, brownian motion and independence.

Question: Let $\{W(t)\}_{0 \le t \le 1}$ a Brownian motion. Then $\{B(t)\}_{0 \le t \le 1}$ with $B(t)=W(t)-tW(1)$ is a Brownian brigde. My goal is to prove that $B(t)$ and $W(1)$ are independent. Since their joint distribution is Gaussian, it is enough to see that their covariance is 0. I realize that
$$Cov(B(t),W(1))=E(B(t)W(1))$$
but I'm no sure about how to continue.
Comment: replace $B_t$ by $W_t -tW_1$, then make direct computation. Notice that $EW_tW_s = s\wedge t$
Comment: Thank you, with that property the problem is done.
Comment: @ted Why not write it as an answer?
Comment: @saz I followed your suggestion. I didn't know it was ok to answer your own question using the hints provided by other user with comments.
Answer: We have that
$$E(B(t)W(1))=E \left( (W(t)-tW(1))W(1) \right) =E(W(t)W(1)-tW(1)W(1)) $$
Using the linearity of the expectation we also have that this expression is equal to
$$ E(W(t)W(1))-E(tW(1)W(1))=E(W(t)W(1))-tE(W(1)W(1))$$
As @PetiteEtincelle said, $E(W(t)W(s))=\min(t,s)$, so finally we conclude that
$$ E(B(t)W(1))= \min (t,1)-t\min(1,1)=t-t=0$$


Can the goalkeeper play the ball again after missing a drop-kick release?

Question: If the goalkeeper tries to release the ball using a bad drop-kick, but misses the kick and the ball lands outside the penalty area, can they run up and kick it?
Answer: There's nothing in the rule book that forbids it: law 12 -- fouls and misconduct -- Indirect Free Kick.
Fouls commited by the goalkeeper are:

When the ball has been deliberately kicked back to them by another player on their team.
When they receive the ball directly from a throw-in by another player on their team.
When they have held the ball continuously for 6 seconds.
When they have already held the ball for 6 seconds and released it and it has not been touched by another player.

These situations are where he can't use his hands. But he can release the ball (him being inside the box, ball thrown outside the box), then control it with his feet, and kick it.
If you put a ball back into play by dropping or rolling the ball on the ground in front of you, it's considered distributing the ball. Then you can't pick it up again using your hands (even thought you are within your own 18 yard box). What you did was to set the ball in play by putting it on the ground and then you can kick it away from you.
I can't see a situation where a failed attempt at dropping/kicking the ball would be seen as a foul/misconduct, and the referee to blow the whistle. A step-by-step action would be: 1. I handle the ball 2. I release the ball 3. I kick the ball with my foot. At no stage there's handling back the ball (that would be a foul).


On numbers with small $\varphi(n)/n$

Question: Let $\Phi(n) = \varphi(n)/n = \prod_{p|n}(p-1)/p$ be the "normalized totient" of $n$.
Some facts:

$\Phi(p) = (p-1)/p < 1$ for prime numbers with $\lim_{p\rightarrow \infty}\Phi(p) = 1$
$\Phi(n) = 1/2$ iff $n$ is a power of $2$
$\Phi(n) < 1/2$ for all even $n$ that are not powers of $2$ and some odd $n$
if $\Phi(n) > 1/2$ then $n$ is odd

I have some questions concerning numbers with $\Phi(n) < 1/2$:

Are there numbers with arbitrary small $\Phi(n)$? Or is there a lower bound $\Phi_{\text{min}} > 0$?
Are there odd numbers with arbitrary small $\Phi(n)$?
How can this astonishing regularity been explained when displaying in a square spiral only those numbers with $\Phi(n) < 1/3$ – a regular pattern of triples pointing right, down, left, up clockwise (with some irregularily distributed defects of course):

Note that the regular background pattern vanishes when choosing values other than 1/3, e.g. 0.3 (left) or 0.4 (right):

Since the cases $\Phi(n) < 1/2$ and $\Phi(n) < 1/3$ display regular patterns, one might suspect that also $\Phi(n) < 1/5$ gives rise to some regularity. But the numbers envolved in creating that pattern are too big, so I cannot visualize it.

Supposed one would visualize $\Phi(n) < 1/5$ which regular pattern would emerge (if any)?
Comment: Perhaps you should change the symbol for that normalization, as it is easy, I think, to confuse with Euler's function. Perhaps something like $\;\Phi(n)\;$ or perhaps even $\;\Psi(n)\;$ .
Comment: Done, thanks for the hint.
Comment: Sorry, you are right. We have $$\prod_{p\ prime, p\le x} \frac{p-1}{p}\approx \frac{e^{-\gamma}}{\ln(x)}$$ where $\gamma$ is the Euler-Mascheroni-constant.
Comment: Even for odd $n$, the value can get arbitary small since the product $$\prod_{p\ prime} \frac{p-1}{p}$$ diverges to $0$
Comment: What might help for a deeper analyze is that we can replace $n$ by its radical (the product of the primes dividing $n$)
Comment: @Peter: Why do you say "diverges to $0$"? Don't you mean "converges"?
Comment: In the case of a product, "convergence" means that the value is non-zero. Important is that the product becomes arbitary small , if we consider more and more primes.
Comment: @Peter: Ah, I didn't know that (one calls convergence to zero "divergence"), now I know. But the product gets smaller very, very slowly, doesn't it? $\prod_{p \leq 739} (p-1)/p$ which corresponds to the number $\prod_{p \leq 739} p \approx 4\cdot 10^{306}$ is still $\approx 0.081$
Comment: @Peter: Which product?
Comment: For more details, google Mertens' theorems.
Comment: @Peter: On the left side $p$ is a bound variable. What does it mean on the right side?
Answer: The answer seems simple: Having a closer look at the numbers in the spiral reveals that most of them are - not surprisingly - multiples of $6 = 2\cdot 3$:

And the spiral forces the multiples of $6$ to arrange in triples (except along the lower right diagonal):

But not all multiples of $6$ have $\Phi(n) < 1/3$, e.g. $n = 2^k\cdot 3$, and not all $n$ with $\Phi(n) < 1/3$ are multiples of $6$, the smallest one being $770 = 2\cdot 5\cdot 7 \cdot 11$.
To answer partly the last of my questions: This is how the integers divisible by 8 and 10 are distributed (the second picture giving the blueprint for the case $\Phi(n) < 1/5$):

Note that in the right picture the "arrows" (5-tuples) go counter-clockwise.

On numbers with small $\varphi(n)/n$


DoCmd.FindRecord isn't finding the record in Access VBA code

Question: I am not sure if there is another post like this but i think my question is a little different.
I am currently designing a database to track employee training given by employer. My current error I find is adding an employee by using a bound form (frmAddEmployee) to my employees table (tblEmployees).
What I have at the moment that works is VBA code that shows a notification when you enter a value into a textbox for the employee number and it finds a duplicate record in the table. The VBA will also show the record in the same form that corresponds with the value you have entered when you clear the notification.
Here's the code I use for the txtEmpNumber after update:
Private Sub txtEmpNumber_AfterUpdate()
Dim EmpNum As String
Dim stLinkCriteria As String
Dim EmpNr As Integer

'Assign the entered employee number to a variable
EmpNum = Me.txtEmpNumber.Value
stLinkCriteria = "[EmpNumber] = " & "'" & EmpNum & "'"
If Me.txtEmpNumber = DLookup("[EmpNumber]", "tblEmployees", stLinkCriteria) Then
    MsgBox "This employee number, " & EmpNum & ", has already been entered in database." _
           & vbCr & vbCr & "Please check the number.", vbExclamation, "Duplicate information"
    Me.Undo
    'show the record of matched employee number from the employees table
    EmpNr = DLookup("[EmpID]", "tblEmployees", stLinkCriteria)
    Me.DataEntry = False
    DoCmd.FindRecord EmpNum, , , , , acCurrent
    Me.cmdSave.Enabled = False
    Me.cmdNew.Enabled = True
Else
    Me.txtIDNumber.Enabled = True
End If
End Sub

The notification shows there is a duplicate value, for example 1234 and shows the record in the table for 1234 but when I try a different value like 5678 then it shows the value again for 1234 and not 5678.
Any ideas how to fix this problem?
Comment: Use BeforeUpdate events to validate input.
Comment: This may not be the problem, but I notice that after the `Me.Undo`, you look up the `Id`, `EmpNr`, but then use `FindRecord` to search on `EmpNum`. Perhaps you meant to use `FindRecord` with `EmpNr`?
Comment: Or, when you say "it shows the value again", are you talking about the popup notification, or the search for the matching record in the table?
Comment: is it possible to send you an example of the database and you can have a look?
Comment: @AnnL. yes its the matching record
Comment: @Vanzie Was I on the right track with my first comment? Because I notice that you look up `EmpNr`, but don't do anything with it. Were you intending to use it with `FindRecord`?
Comment: @Vanzie Unfortunately, the laptop I'm using doesn't have Office installed, so it wouldn't do any good for you to send me the database.
Comment: @Vanzie (Also, your employer would probably object to you sending data outside the company!)
Comment: still shows same problem
Comment: @AnnL. there will be no information within the tables as you can enter your own xyz  to test
Comment: @Vanzie Can you post a screen shot of your form? I just have some questions about how you set it up, and the easiest way for me to get answers is to see what the form looks like.
Comment: @AnnL. i removed the EmpNr lookup and DIM but it still gives me the same problem. Like for example i add person A to the database and continue to add person B. Now i add person C but accidentally use the same employee number as person B for person C. Now after clearing the notification it should find the record of the employee with that employee number and display that information which should be person B's information but it keeps displaying person A's details (no matter how many persons you add it keeps displaying info for A)
Comment: @AnnL. i have added a link in the body of the question
Comment: This is a wild guess, but try changing `acCurrent` to `acAll`.  See if that makes a difference.
Comment: seems to have worked!
Comment: yay!  I will write this up as a solution, then. It would be nice if you could mark it as accepted when I'm done.
Comment: Here's a link to a quick demo of how StackOverflow works. It should demonstrate someone marking an answer as accepted.
Comment: @Vanzie Never provided the link!  [Demo of marking an answer as accepted](https://stackoverflow.com/tour)
Answer: I think the problem you are having is that this command:
 DoCmd.FindRecord EmpNum, , , , , acCurrent

...searches in the current field.  But if there isn't a current field (because the form doesn't have the focus), or if the current field is some other field (such as ID), the "find" won't find a match, and the record you're looking at won't change.
The simplest fix would be to change your code to this:
 DoCmd.FindRecord EmpNum, , , , , acAll

That will search for the value of EmpNum in ALL the fields.
But, if there's a chance that the value for EmpNum might also appear in other fields than txtEmpNumber (for example, if someone has EmpNum = 12 and someone else is ID = 12), this will eventually start "finding" the wrong record.
So I think the best thing to do would be to make sure your current field is txtEmpNumber before you execute the FindRecord.
Me.txtEmpNumber.SetFocus
DoCmd.FindRecord EmpNum, , , , , acCurrent

That will ensure it only looks in txtEmpNumber when it's trying to find the record.
Comment: This will definitely be the answer but I doubt I will run into this problem with other ID fields as each table as it's own unique ID fields. But thank you for you help. I'm still new so I have no idea how to mark as the answer
Comment: @Vanzie You see, by the answer, where there's a number and an up-triangle and a down-triangle?  You should see a checkmark below it. If you click on that, it should mark this answer as "Accepted".  And I believe you'll even get points for accepting an answer!
Answer: Dim K As String
K = Me!b
a.SetFocus
DoCmd.FindRecord FindWhat:=K, Match:=acStart, MatchCase:=True, Search:=acSearchCurrent, SearchAsFormatted:=True, OnlyCurrentField:=acCurrent, FindFirst:=True

Comment: As it's currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer).


Handling wcf services from nodejs

Question: I am trying to access soap URL,I came across different file types i.e. .asmx and .svc. I used the node-soap module for handling .asmx services. For .svc I came across wcf.js below is the code
var BasicHttpBinding = require('wcf.js').BasicHttpBinding
, Proxy = require('wcf.js').Proxy
, binding = new BasicHttpBinding()
, proxy = new Proxy(binding, "https://webservice.kareo.com/services/soap/2.1/")
, message = '<Envelope xmlns=' +
        '"http://schemas.xmlsoap.org/soap/envelope/">' +
             '' +
               '' +
                 '<GetData xmlns="http://tempuri.org/">' +
                   '<value>GetAppointments</value>' +
                 '</GetData>' +
                '' +
           '</Envelope>'

proxy.send(message, "http://www.kareo.com/api/schemas/KareoServices/GetAppointments",       function(response, ctx) {
console.log(response)
});

I could not understand what has to be passed as message as an input for wcf web service.
Can Anyone provide me some idea regarding this? It will be really helpful.
Advance Thanks
Answer: The message should contain the raw soap wcf expects. You can get it by using WCF logging or Fiddler on an existing working c# client.
Comment: you have pasted above a working example... you just need to change the message per your needs, you can ask the service vendor for an exmaple

Handling wcf services from nodejs