Automatically assign members and methods to certain classes

Question: I have many classes that have the following members/methods:
private String name;
public String getName() { return name; }
public void setName(String name) { this.name = name; }
public bool isNamed(String name) { return getName().Equals(name); }

Every time I create a new class that has a member "name", I have to rewrite all these.
Is there a way to write the methods one time and to make them apply to any class I want?
Answer: You'd simply define a base class (you could make it abstract):
public abstract class Named
{
    public string Name { get; set; }
}

and inherit from it:
public class Person : Named
{
}

You don't really need isNamed as in C#, it is perfectly safe to compare strings with ==.

If your class already inherits from another class which is not Named, you'll have to manually add the Name auto property or resort to simulated multiple inheritance.
Alternatively, you could create a specific modification of Named for every base class:
public abstract class NamedLifeForm : LifeForm
{
    public string Name { get; set; }
}

public class Person : NamedLifeForm
{
    // Person inherits both a Name and all relevant members of LifeForm
}

Another alternative would be to create a generic wrapper, Named<T>, that would have two properties: the Name and an instance of T. But that would make construction and access cumbersome, so I don't recommend it.
Comment: @Downvoter: I'd be happy to know if there are any mistakes in my answer so I can improve it.
Comment: What if my class inherits from another class which is not "Named"? As far as I know there is no multiple class inheritance in C#, just multiple interface inheritance, which doesn't help me here, because interfaces have no implementation and I want to implement these methods once.
Comment: @StefanosKargas I've edited my answer in an attempt to provide useful alternatives. There really aren't that many options because auto properties make the problem a lot less relevant as they only take a single line of code.
Answer: Your code can be converted to:
public String Name { get;set;}

Then you can use it as so:
nObject.Name = "Stefan";
if(nObject.Name == "Stefan"){
   // do something
}else{
   // do something else
}

To apply to all the classes automatically you can just make this into an interface:
public interface INameable{
   public String Name {get;set;}
}

Doing this will allow you to inherit from other base classes of importance.
see here for an example
class YourClass : INameable{
  //implementation
}

And now, YourClass has "Name" property automatically inserted.
Comment: I think naming your variable `object` is confusing, especially since it wouldn't compile (`object` is a keyword).
Answer: C# has AutoProperties just for that:
public String Name {get; set; }

This handles both the getName() and the setName() you talked about.
Usage:
To set a value: Name = "MyName;
To get a value: string theName = Name;
Answer: I'd suggest reading up on Object Oriented Programming. You can save yourself a lot of time and effort (and heckling). Here is a good primer http://www.amazon.com/Beginning-Object-Oriented-Programming-Dan-Clark/dp/1430235306
To answer your specific question, you should read about inheritance. It lets you define a "Parent" class with functions. Then you can inherit with "Child" classes and have those same functions.
http://msdn.microsoft.com/en-us/library/ms173149(v=vs.80).aspx
Here is a code example
public class PersonBase
{
     private String name;
     public String getName()
     {
          return this.name;
     }
     public void setName(string name)
     {
          this.name = name;
     }
     public bool isNamed(string name)
     {
           return this.name.Equals(name);
     }
}

public class Employee : PersonBase
{
}

Employee will now have whatever was defined by PersonBase.
As others have pointed out, you can simplify you code with properties. Also you should check for null values before using "this.name".
Here is a link to what properties are:
http://msdn.microsoft.com/en-us/library/x9fsa0sw(v=vs.80).aspx
The simplified code example would be:
public class PersonBase
{
     public String Name { get; set; }
}

public class Employee : PersonBase
{
}

I hope this helps get you pointed in the right direction for learning about these concepts.


Prove $\mathbb{C}^n \setminus X$ is path connected.

Question: Let $f \in \mathbb{C}[z_{1}, . . . , z_{n}]$ be a nonzero polynomial ($n ≥ 1$) and
$X = \{ z ∈ \mathbb{C}^n| f(z) = 0  \}.$
How do we prove that $\mathbb{C}^n\setminus X$ is path connected?
In one variable case the polynomial has only finitely many roots and by considering straight lines passing through any two distict points we can conclude that $\mathbb{C}^n \setminus X$ is path connected. How do we proceed for any $n$?
Answer: Hint: Any two points $a, b \in \mathbb{C}^n$ lie on the "line" $\{a + (b -a) z \mid z \in \mathbb{C}\}$. Use this to reduce to the one-variable case.
Comment: Why the downvote? I'm not saying that the line is disjoint from $X$.
Answer: Consider $\gamma(t) = a+(b-a)t$ and look at the function $f\circ \gamma(t)\in \mathbb{C}[t]$ . Now we need a path $\delta(t)$ connecting $0,1$ such that $f\circ \gamma \circ \delta \neq 0$ i.e. a path $\delta $ in $(f\circ \gamma )^{-1}(\mathbb{C}\setminus \{0\}) $ . Observe that $(f\circ \gamma )^{-1}(\mathbb{C}\setminus \{0\}) $ is path connected  being cofinite(polynomial in $\mathbb{C}[t]$ hence finite number of roots) and nonempty $(f\circ \gamma (t)\neq 0  $ for $t=0,1)$. Therefore there is such a path $\delta$, connecting $0,1$. And our required path is $\gamma\circ \delta $.


First and Fourth derivative tests giving different result

Question: Consider the function $$f(x)=2x^5-5x^4-10x^3$$
we have to find Local maxima and minima
So $$f'(x)=10x^4-20x^3-30x^2=0$$
critical points are $x=0$,$x=3$ and $x=-1$
$$f''(x)=40x^3-60x^2-60x$$
Now at $x=0$ $f''(0)=0$ so second derivative test fails.
Using First derivative test we have
$$f'(0^-)<0$$ and$$f'(0^+) \lt 0$$  so no change of sign in $f'(x)$  hence $x=0$ is neither point of Local max nor Min
But
$$f''''(x)=240x-120$$
$$f''''(0) \lt 0$$ so $x=0$ should be point of Local Max right?
what is going wrong here?
Answer: The fourth derivative test isn't applicable here.
When doing higher-order derivative tests, you're supposed to stop as soon as you get a nonzero derivative.  The third derivative is the first nonzero one at $x = 0$.  $f'''(0) = -60$.  Since an odd-order derivative is the first nonzero derivative at $x = 0$, then this means there is neither a max nor a min at $x = 0$.
Answer: $f''''(0)<0$ and $f'(0)=f''(0)=f'''(0)=0$ says that $x_{max}=0$ because $f(x)\leq0$ around $0$, which says that $f$ a concave function around $0$ because $y=0$ is a tangent to the graph of $f$ in the point $(0,0)$.
In our case we have $f'''(0)\neq0$. Thus, all this just is not relevant.


Understanding quadratic function - beginner calculus

Question: Drawing tangent line to $2x^2 + 2x + 4$ at $x = 3$ :

http://www.wolframalpha.com/widgets/view.jsp?id=5c1ac7fe2da56ef0295f7fd796371a56
Taken from http://www-math.mit.edu/~djk/calculus_beginners/chapter04/section02.html :

If you look at a quadratic function f at some particular argument,
  call it z, and very close to z, then f will look like a straight line.
  The line f resembles at argument z is called the tangent line to f at
  argument z, and the slope of this tangent line to f at z is called the
  derivative of f at argument z.

Is the z argument in this case the value 3 ?
Is following statement correct :

If you look at a quadratic function $2x^2 + 2x + 4$ at argument $x=3$,
  $2x^2 + 2x + 4$ will look like a straight line very close to argument
  x=3.
  The line $2x^2 + 2x + 4$ resembles at argument $x=3$ is called the
  tangent line to   $2x^2 + 2x + 4$ at argument $x=3$ and the slope of this
  tangent line to $2x^2 + 2x + 4$ at $x=3$ is called the derivative of
  $2x^2 + 2x + 4$ at argument $x=3$.
Comment: *"Is the z argument in this case the value 3 ?"* -> Yes.

In your statement, you wrote the *"The line 2x^2 + 2x + 4"*; here you probably wanted to put the equation of the (tangent) line, namely 14x-4.
Answer: yes z=3
The word "very close" means if you zoom in into the graph of f, then f will looks like a straight line. The straight line looks like the tangent line at any argument(example x=3).
Answer: Answering your question: "Is the following correct....":
The way the sentence is written is confusing.
In short (and without being strict mathematically...):

The derivative of a function of degree $2$ (Quadratic equation) is a function of degree one (a straight line) and can be refereed to as f'(x).
The derivative of a function $f(x)$ at any point $(s, f(s))$ represents the general equation of the slope. The value of the derivative at a point $(s, f'(s))$ is the slope at the point (s, f(s)). Notice careful y the difference between f and f' symbols. f represents the function, whereas f' represents the derivative.

The above is illustrated in hundreds of sites and books under the concept of derivatives and is fundamental to understanding Calculus.
If you have an issue I could explain further and give you references, for example:Meaning of the Derivative.


Subgroups in meta-analysis

Question: I am reviewing a dissertation that does a meta-analysis of studies looking at a certain behaviour in rodents.
The author analysed ~20 studies and did a meta-analysis. They then split those studies into sub-categories, depending on the specific methodology that was used in each study (the same thing can be measured in several different ways) and performed one meta-analysis per group.
Finally, they split the original set in a different way (depending on another factor) and performed some further multiple meta-analyses.
I am really not that familiar with meta-analyses, so I am wondering whether this is good practice, or whether they should have included methodology as a factor in their overall analysis instead? If splitting data into multiple subgroups should there be a multiple comparison correction?
Comment: @BCLC no, sorry, this is group in the "regular" sense... as "a subgroup of studies = a subset of the total studies". :)
Comment: just wondering. is this group in the algebra sense? or in the regular sense? seems regular but just double checking. (i saw this in hot network, and i remember i had this one statistics instructor who said something like - well it was in tagalog/filipino, so i'm not really sure - 'you know what i like about statistics? it has actual applications. unlike, say, group theory. oh wait. i think group theory has applications cryptography. hmm. (back to lesson)')
Answer: For simplicity let us assume there are two groups although the issues are the same for multiple groups. The choices are (a) to run an analysis on each group separately (b) to run an analysis on the whole data-set with a two-level factor as a moderator.
The advantage of option (b) is that you have more data and hence your estimate of $\tau^2$ will be more precise. With 20 studies it was probably not very precise anyway (suggest they give confidence intervals for $\tau^2$ or $I^2$). A slight disadvantage of (b) is that it assumes that $\tau^2$ has the same value in each group but there are options in software to relax that assumption. There is detail on how to do this in R using the metafor package here.
If the split was based on theory then there is no real multiplicity issue here but if it is data-driven then caution is obviously needed.
Answer: There definitely should be a multiple comparison correction.
Meta-analyses are...generally not of the highest quality, with regards to statistical soundness.
Answer: It depends whether the data obtained using different methodologies can be statistically compared. Normally in a MA you first show the results overall and then you run a sensitivity analysis e.g. stratified analysis.

Subgroups in meta-analysis


Como fazer para que uma function espere o resultado do $http?

Question: Estou tendo problema com o seguinte código:
$http({
    method: 'POST',
    url: '/publicacao/',
    data: $scope.publicacao,
    headers: {'Content-Type': 'application/json'}
}).success(function(publicacao) {
    $scope.publicacao = publicacao.data;
    console.log($scope.publicacao);

    //Upload de imagem
    if ($scope.tipo == 'imagem') {
        var arquivo = $("#imagem")[0].files[0];
        var nomeArquivo = $("#imagem")[0].files[0].name;

        UploadFileService.uploadArquivo('/upload', arquivo, nomeArquivo , publicacao.codigoPubl , 'imagem');
    }

    //Upload de arquivo
    else if ($scope.tipo == 'arquivo') {
        var arquivo = $("#arquivo")[0].files[0];
        var nomeArquivo = $("#arquivo")[0].files[0].name;

        UploadFileService.uploadArquivo('/upload', arquivo, nomeArquivo , publicacao.codigoPubl , 'arquivo');
    }

    $location.path('/timelines/' + $routeParams.codTime);
    $window.location.reload();
    $scope.addSucessoMsg();
}).error (function(erro) {
    console.log('Erro ao adicionar a publicação: ' + erro);
    $scope.addErroMsg();
});

Depois que a publicação é salva no servidor, preciso chamar o serviço UploadFileService para enviar uma imagem ou um arquivo pro servidor, enviando o código para que a imagem ou o arquivo possa ser linkado com a respectiva publicação.
A ideia é fazer com que a chamada do serviço UploadFileService espere até que o $http retorne com a publicação. Comecei a mexer com JavaScript e AngularJS faz pouco tempo e estou com dúvida em como fazer chained promises (Requisições síncronas), li alguns posts em português e em inglês mas não sei como usar isso pra resolver este problema.
Se alguém puder ajudar, agradeço.
Comment: Qual o problema que você está tendo?
Comment: Pelo que entendi, o `$http` faz uma chamada assíncrona, o que em teoria permite que o código continue sua execução enquanto ele não termina, certo? O problema que eu imagino é o seguinte, é possível de alguma forma que as chamadas do serviço `UploadFileService` sejam executadas antes de o `$http` ter recebido a resposta do servidor? Até o momento durante os meus testes não ocorreu de a publicação ficar como `undefined` e dar erro, mas quero poder evitar que isso ocorra. Comecei a ler sobre as promises faz pouco tempo, então ainda tenho dúvidas em como elas funcionam.
Answer: O serviço $http é uma função que leva um único argumento - um objeto de configuração - que é usado para gerar uma solicitação HTTP e retorna uma promessa (código fonte).
$http({
    //objeto de configuração
})
//...

No entanto, ele usa uma abstração de $q (documentação) e porque é uma abstração ele renomeia as funções de callback. Em vez de .then e .catch é .success e .error.
$http({
    //objeto de configuração
}).success(function(data) {
    //requisição HTTP executada com sucesso
}).error (function(error) {
    //algo correu mal
});

O serviço $q por sua vez ajuda você a executar funções de forma assíncrona e usar seus valores de retorno (ou exceções) quando eles são processados.
Ou seja, tudo que está dentro da função de callback definida no método .success será executado após a conclusão da requisição HTTP, caso a mesma seja executada com sucesso, caso contrário será executado a função de callback definida no método .error.
Porém a explicação acima é válida somente para as versões que ainda implementam os métodos success e error, que analisando o código inserido na pergunta, é o seu caso.
Como bem observado pelo @OnoSendai, tenha atenção que os métodos success e error como callbacks de $http foram declarados descontinuados. Em vez disso, use o método then passando como argumento as funções de sucesso e erro.
$http({
     //objeto de configuração
}).then(function successCallback(response) {
    //requisição HTTP executada com sucesso
}, function errorCallback(response) {
    //ocorreu um erro
});

Comment: O uso do success e do error feitos dessa forma, se não me falha a memória, são para as versões 1.4 pra baixo. As versões atuais ele usa o .then passando no parâmetro 2 funções que serão os callbacks da promise.
Comment: @PauloGustavo foi o que ele colocou na pergunta, pelo menos é o que está no código, então expliquei o motivo de ser usado esses 2 métodos, o que para mim fez sentido explicar.
Answer: Aguarde o retorno da operação HTTP em uma função de callback, que de acordo com a documentação do serviço $http deverá estar presente no primeiro parâmetro do método then() do objeto retornado:
$http({
  method: 'GET',
  url: '/umaUrlQualquer'
}).then(function successCallback(response) {

    // este callback é chamado assincronamente
    // quanto a resposta está disponível

  }, function errorCallback(response) {

    // chamado assincronamente quando um erro ocorre,
    // ou quando o servidor responde com um código de erro.

  });

Caso necessário, utilize promessas em cadeia para processar chamadas HTTP em cascata.
Observação: Não utilize success e error como callbacks de $http. A documentação da versão 1.5.9 possui o seguinte anúncio:

Deprecation Notice

The $http legacy promise methods success and error have been deprecated. Use the standard then method instead. If $httpProvider.useLegacyPromiseExtensions is set to false then these methods will throw $http/legacy error.

Que se traduz como:

Aviso de descontinuidade

Os métodos de callback success e error [do serviço $http] foram declarados descontinuados. Em vez disso, use o método padrão. Se $httpProvider.useLegacyPromiseExtensions estiver definido como false, então esses métodos irão lançar o erro $http/legacy.

A versão 1.6.0 já não inclui a notícia, o que me faz acreditar que os métodos foram retirados.
Fonte: https://code.angularjs.org/1.5.9/docs/api/ng/service/$http


Como fazer o autofocus com jquery

Question: Eu queria saber como fazer document.getElementById('input').focus() com jquery. Segundo o que eu vi na documentação $('input').focus() foi depreciado e eu não consegui fazer funcionar com $('input').on('focus'). Queria saber o que estou fazendo errado ou se existe outra forma.
Answer: Não sei se essa é a forma certa, mas consegui fazer funcionar usando $('input').trigger('focus')
Comment: Sua resposta pode ser melhorada adicionando informações fundamentais. Basta [edit] para adicionar mais detalhes, como citações ou documentação para que outras pessoas possam confirmar que sua resposta está correta. Você pode encontrar mais informações sobre como escrever boas respostas [na Central de Ajuda](/help/how-to-answer).

Como fazer o autofocus com jquery


Gauss Newton Direction

Question: I am working on Gauss Newton direction but I have a hard time understanding:
$\ J^tJ p = - J^tr $
What I searched and understood is as follow:
$\ - J^tr $ is in face $\ - \nabla f $ which is like steepest descent direction
but what why is there a $\ J^tJ $ at the begining next to $\ p $ , what does it mean and how could I compute $\ p $ out of this equation?
I also tried to review my linear algebra books but no luck.
enter image description here
Answer: Linearising $f$ around a point viz. $f(x)\approx f(a)+\nabla f^t (x-a)$ allows us to solve $f=0$ at first order, viz. $Jp=-r$ where $p:=x-a,\,r:=f(a),\,J:=\nabla f^t$. But how can we solve this? Well, here's the clever bit. Left-multiplying both sides by $J^t$ obtains $J^tJp=-J^tr$. Since $J^t J$ is square, it's invertible unless its determinant is $0$. This allows us to obtain $p$ as $-J^-r,\,J^-:=(J^tJ)^{-1}J^t $. It's easy to forget we can't expect $J$ to be a square matrix, but notice that if it were $J^-$ would simplify to $J^{-1}$, which is why the notation $J^-$ is used. It's called the pseudoinverse of $J$.

Gauss Newton Direction


Matrix equation with diagonal matrix

Question: Let $A \in\mathbb{R}^{n\times n}$ be a given Positive-Semi Definite matrix ,$\theta\in\mathbb{R}^n$ a vector, $x\in\mathbb{R}$ an unknown variable, and $a\in\mathbb{R}^+$ a positive constant. I have the following equation
$$
\theta^TA(A+xI)^{-1}(A+xI)^{-1}A\theta  = a
$$
where $I$ is the identity matrix.
Is it possible to solve this equation for $x?$
What I have tried:
$$
\text{trace}(\theta^TA(A+xI)^{-1}(A+xI)^{-1}A\theta)  = \text{trace}(a)
\\\theta^TAA\theta  \cdot\text{trace}((A+xI)^{-1}(A+xI)^{-1})  = a
\\ \sum_{i = 1}^n\frac{1}{(x+s_i)^2}=\frac{a}{\|\theta\|_{A^2}^2}
$$
where $s_i$ are the singular values of the $A$. Is it correct? How can i proceed from here?
Comment: Your description and equation doesn't make sense.  $A\in\mathbb{R}^n$ is not a psd matrix unless $n$ is a square number, but you are also claiming $\theta\in\mathbb{R}^n$ to be a vector that is compatible with $A$ with both (!) $\theta^TA$ and $\theta A$ appearing, so that doesn't happen unless $n=0$ (trivial) or $n=1$, in which case this is just a usual quadratic equation in $x$.
Comment: Assuming WLOG $A$ is diagonal.  Then the equation is $\sum_i\theta_i^2\frac{a_i^2}{(a_i+x)^2}=a$ which you can solve numerically (I don't think the $2n$-degree polynomial is solvable by radicals for generic $a_i,\theta_i$)
Comment: No, you can't pull $A\theta$ out, same as you can't pull $y$ out in $y^TBy\neq y^Ty\operatorname{tr}B$
Comment: Let $A=\operatorname{diag}(a_i)$, so $A+xI=\operatorname{diag}(a_i+x)$ and $A(A+xI)^{-1}(A+xI)^{-1}A=\operatorname{diag}((\frac{a_i}{a_i+x})^2)$ giving $\theta^TA(A+xI)^{-1}(A+xI)^{-1}A\theta=\sum_i\theta_i^2(\frac{a_i}{a_i+x})^2$.
Comment: Sorry there is a typo: $A\in\mathbb{R}^{n\times n}$. Updated
Comment: Oh thanks, that looks very similar to my attempt. can you look at it and suggest whether it's correct in your opinion?
Comment: how did you get to your equation then?
Comment: If you add this as an answer I will like and accept it. thanks!
Answer: Because $A$ is symetric psd matrix, we can diagonalize $A$ as: $A = UDU^T$ where $U$ is a orthogonal matrix ($U^T = U^{-1}$) and $D$ is a diagonal matrix.
Hence, we have
\begin{align}
(A+xI)^{-1} &= (UDU^T+xUU^T)^{-1} \\
&= (U(D+xI)U^{-1})^{-1} \\
&= U(D+xI)^{-1}U^{-1} \\
\end{align}
Then
\begin{align}
a & =\theta^TA(A+xI)^{-1}(A+xI)^{-1}A\theta  \\
& =\theta^TUDU^T \left(U(D+xI)^{-1}U^{-1}\right) \left(U(D+xI)^{-1}U^{-1}\right)UDU^T\theta  \\
& =\theta^TUD \left((D+xI)^{-1}\right)^2DU^T\theta  \\
\end{align}
The matrix $ \left((D+xI)^{-1}\right)^2$ is a diagonal matrix of $\frac{1}{(d_i+x)^2}$ with $(d_1,...,d_n)$ is the diagonal of the matrix $D$.
Let's denote $\eta =(\eta_1,...,\eta_n) = DU^T\theta \in \mathbb{R}^n$, we have
$$a = \sum_{i=1}^n\frac{\eta_i^2 }{(d_i+x)^2}$$
Comment: @Apprentice there is no closed form expression for this equation. And you have from $2n$ real roots. The sole method you can use is numerical method.
Comment: Hey, thanks a lot for your answer. Do you have any idea on how to solve the rational equation in the last line? Or at least if $a>0$ can we say something about the positiveness of the solutions?
Comment: what about the positivity of at least one of the solution for $a>0$?
Answer: $\def\T#1{\operatorname{tr}(#1)}$I would suggest using Newton's Method, i.e.
$$\eqalign{
f(x) &= 0, \quad
f_k &= f(x_k), \quad
f'_k &= f'(x_k) \quad\implies\quad
x_{k+1} &= x_k - \frac{f_k}{f'_k} \\
}$$
For typing convenience, define the matrices
$$\eqalign{
B &= A+Ix \quad\implies\quad
\frac{dB^n}{dx} = nB^{n-1} \\
M &= A\,\theta\theta^T\!A \\
}$$
Set up an appropriate function and apply Newton's Method
$$\eqalign{
f  &= a - \T{MB^{-2}} \\
f' &= +\T{2MB^{-3}} \\
B_k &\doteq A + Ix_k \\
x_0 &= 1, \qquad
x_{k+1}
  = x_k - \frac{a-\T{MB_k^{-2}}}{\T{2MB_k^{-3}}} \\
}$$
NB:  The iteration will converge to different roots depending upon the choice of $x_0$
Also note that if $A$ is diagonal, then $B$ is also diagonal and the matrix inversion required by the iteration can be computed very efficiently.

Matrix equation with diagonal matrix


JavaScript Regex Compile()

Question: Is there a shorter way to write this?
var needed = /\$\[\w+\]/mi;
needed.compile(/\$\[\w+\]/mi);

Why do I have to pass the pattern back into the regex when I've already declared it in the first line?!
Comment: If I don't include the pattern again, the regex takes about twice as long.
Answer: There are two ways of defining regular expressions in JavaScript — one through an object constructor and one through a literal. The object can be changed at runtime, but the literal is compiled at load of the script, and provides better performance.
var txt=new RegExp(pattern,modifiers);

or more simply:
var txt=/pattern/modifiers;

This is the same thing that cobbai is saying. In short, you do not have to do both.
Answer: from MDC:

The literal notation provides compilation of the regular expression when the expression is evaluated

so /\$\[\w+\]/mi is a compiled regex already.

JavaScript Regex Compile()


SCCM - can't reitre application due to active deployment?

Question: According to this documentation, I should be able to retire an application while it is still deployed, the purpose being that those deployments are preserved.
When I try to retire an appliation in SCCM v1706, it tells me:

"Configuration Manager cannot retire this application because other
  applications or task sequences reference it or it is configured as a
  deployment."

There are three deployments for this application - no task sequences etc refence it.
So is the documentation faulty or am I missing something here?
edit: as expected from the above error message I am able to retire the application as soon as I delete all deployments for it. So I guess the functionality of retiring applications (in SCCM 2012 this was "enable/disable" iirc) was changed at some point in Current Branch without adapting relevant documentation?
edit 2: I also posted this question in the Microsoft-forums and got an answer there which came as close to an explanation as can be for this topic: seems the documentation mentioned above is simply a little vague on the topic of deployments when retiring applications. The answer seems to be that retiring applications is not intended to preserve the deployment configuration, but it rather means that clients currently running that applications are not prompted to uninstall it.
Answer: Bad question: You have not read the document which clearly states:

Block quote

To delete an application, you must first retire the application, delete all deployments, remove references to the application by other deployments, and then delete all of the application's revisions.

Block quote
Comment: I do not want to delete the application just yet - I simply want to retire it and may delete it at a later time. I did read the documentation and it clearly states that:
"When you retire an application, it is no longer available for deployment, but the application and deployments of the application are not deleted."
Therefore I was of the impression that I can retire applications without first deleting its deployments.
Comment: What is this document? I see no link to a document, and your quotes are missing. Only "Block quote" is present, which doesn't mean anything.
Answer: I am certain in the past I have retired applications that had active deployments in 2012 or 2012 R2. My understanding then was existing deployments were preserved, but no new ones could be created. This is absolutely a change in functionality (or a bug).
Here is the 2012 era documentation: https://technet.microsoft.com/en-us/library/gg682031.aspx?f=255&MSPPError=-2147217396

When you retire an application, it is no longer available for deployment but the application and any deployments of the application are not deleted. Existing copies of this application that were installed on client computers will not be removed. Any revisions to the application will be deleted from Configuration Manager after 60 days. However, any installed copies of the application are not removed.
Comment: Also, I verified the change in behavior in our 1706 deployment. I was unable to retire an application that had an active deployment.
Answer: SCCM 1706 has been out of support since 2018:
https://learn.microsoft.com/en-us/mem/configmgr/core/servers/manage/updates#historical-versions.
It's definitely time to upgrade.


How can I reduce the size of this file to 83 bytes or less?

Question: Task description:
Create the divisibility function, which expects an array of integers and its size as a parameter. The function returns how many numbers divisible by two are in the array!
We want to save on the available storage space, so our source code can be a maximum of 83 bytes!
My current code:
int oszthatosag(int a[], int s){int r=0,i;for (i = 0; i < s; ++i)if(a[i] % 2 == 0)++r;return r;}

has a size of 96 bytes. I deleted all the unnecessary whitespaces and reduced the lenghths of the variables to a minimum, but it still doesn't seem to be enough.
Comment: There are still many useless spaces and the function name can be shortened.
Comment: By the way, I don't believe that this is a real question. Rather a quiz. The length of the source code is irrelevant, as C/C++ is compiled.
Answer: You can remove additional spaces, use a branch-less strategy to remove the if, move the initialization/increment of i outside the loop, and decrease r starting from s so to remove the ==0. The resulting code should not only be shorter, but also faster. This assumes s>=0 (otherwise r is smaller than expected).
Here is the final result:
int oszthatosag(int a[],int s){int r=s,i=0;while(i<s)r-=a[i++]&1;return r;}

As pointed out by @Brendan, here is an even shorter version (still assuming s>=0):
int oszthatosag(int a[],int s){int r=s;while(s)r-=a[--s]&1;return r;}

Note that in C, the default return type is int so you can omit it (required in C++). This is generally not a good idea (and cause compiler warnings), but it is shorter:
oszthatosag(int a[],int s){int r=s;while(s)r-=a[--s]&1;return r;}

Comment: Do you need `i`? Could be `while(s){ r-=a[--s]&1;}` if you don't need to worry about the caller giving you a negative `s`.
Comment: A bit-wise comparison (instead of the Mod) might be faster still (I don't know if the Mod operator is optimised for the case of 2):  `r-=a[i++]&1`
Comment: Compilers are able to optimize this easily if `a` is an `unsigned int` which is not the case here. Otherwise, it is indeed faster. The result is not the same for negative numbers but I guess it matches with the OP intent as long as the binary representation is C2 (which is the case on all standard platforms nowadays). Thank you.
Comment: @Brendan Indeed, good point. I was already assuming `s>=0` anyway.


Proving that without the axiom of choice there is a set with an accumulation point that isn'tthe limit of a convergeant sequence

Question: I've been reading the simple parts of Thomas Jech's book on the Axiom of Choice and came across the following proof on page 141. The proof assumes a mathematical model without the axiom of choice.

Lemma. $X$ is D-finite if and only if $X$ does not have a countable subset.
Theorem. There is a set $S$ of real numbers and a real number $a \not \in S$ such that a is in the closure of $S$ but there is no sequence $(x_n)^{\infty}_{n=0} \subset S$ such that $(x_n)^{\infty}_{n=0} \longrightarrow a$.
Proof. Let $D$ be a D-finite infinite set of reals. We claim that the set $D$ must have an accumulation point. To prove this claim suppose that all $d \in D$ are not accumulation points, then let $\{I_n:n=0,1,...\}$ be a fixed enumeration of open intervals with rational endpoints. Assign the least $n$ such that $I_n \cap D={d}$ to each $d \in D$. This makes $D$ countable and by the above lemma gives us our contradiction. So $D$ has an accumulation point $a$. Let $S=D \setminus\{a\}$ and since $S$ is D-finite, every convergent sequence in $S$ is eventually constant.

Could somebody explain this proof? Why is the last sentence true/ Why does this mean every convergent sequence is eventually constant?
I think the following theorem is important

Theorem. There is a model of ZF which has an infinite set of real numbers without a countable subset
Comment: The title and first paragraph are a bit misleading, because the hypothesis used in the theorem is "there is a Dedekind-finite infinite set of real numbers," which is stronger than $\neg \mathsf{AC}$.
Comment: I have a hunch this is not even the second time this topic is discussed on the site.
Comment: Also, the proof verification tag is for questions about *your* proofs that need to be verified.
Comment: To clear the problem that @Trevor points out, I suggest replacing "there is a set" with "there can be a set" in the title (and while at it, add the missing space).
Answer: Let $(x_n)$ a sequence in $S$ with $x_n\to x$. If the sequence is not eventually constant, we can define $y_n=x_m$ where $m$ is minimal with $x_m\ne x$ and $|x_m-x|<|y_k-x|$ for all $k<n$. Then $y_n\to x$ as well and $\{\,y_n\mid n\in\mathbb N\,\}$ is a countable subset of $S$. By the lemma $S$ is not D-finite.
Answer: Of particular importance is that for any D-finite set $F$, every function $\mathbb{N} \to F$ can take on only finitely many values.

If $f: \mathbb{N} \to F$ took only infinitely many different values then one could define $g : \mathbb{N} \to \mathbb{N}$ recursively according to $$g ( n ) = \min \{ k \in \mathbb{N} : f(k) \notin \{ f(g(0)) , \ldots , f(g(n-1)) \}\;\},$$
   and then the composition $f \circ g : \mathbb{N} \to F$ would be one-to-one, contradicting that $F$ has no countably infinite subset!

Using this it is fairly straightforward to show that any convergent sequence in a D-finite set of reals is eventually constant.
Answer: One point which is somewhat amiss amongst the answers is this:
If $D$ is a Dedekind-finite set and $S\subseteq D$, then $S$ is Dedekind-finite as well. The proof is simple from the lemma cited in your question. If $S$ was Dedekind-infinite, then it would have a countably infinite subset, and so would $D$ -- a contradiction.
Now, since $S$ is Dedekind-finite every countable subset is a finite subset. The range of a sequence is countable, by definition, and therefore finite. The only sequences with finite range which converge are those which are eventually constant.
Comment: This was pretty much the answer I wanted to write, and then I got confused and messed it up.
Comment: @Ben: Well, it happens. Don't forget that I have like 300 answers under my belt on this topic. And over 2300 in general. It takes experience to write concise answers, and I hate seeing my older ones because I find them... crappy (to some extent, anyway).
Answer: In this answer I'm going to use "infinite" to mean "not finite" (i.e. does not biject with any finite ordinal) and "countably infinite" to mean "in bijection with $\mathbb N$" (so in particular, $D$-finite sets are not countably infinite, even if they inject into $\mathbb N$). These usages are probably standard, but it's often easy to forget when working without Choice that a few distinctions that didn't matter now do, so the definitions sometimes have to be revisited.
The idea is that if the set of points that the sequence visited were finite, then since the sequence converges it would have to settle down to only one of them, so the sequence is eventually constant. For example, take half the smallest distance between two points in the finite set, and the sequence is eventually within that distance of its limit, so it can't jump between points anymore.
If, on the other hand, the sequence visits infinitely many points, then they form a countable subset of the set $D$, and this violates $D$-finiteness.
The tricky part is arguing "infinite $\implies$ countably infinite", since after all $D$ itself is infinite but not countably so! However, the range of the sequence can be well-ordered by "which element did I visit first", so then it must biject with an ordinal, and the ordinals don't exhibit pathological behaviour like being simultaneously infinite and $D$-finite.
Comment: I don't understand your last paragraph, beginning with "Now, any set that is not finite admits an injection from $\mathbb{N}$."  This seems to say that infinite implies D-infinite. Perhaps you meant "any subset of $\mathbb{N}$ that is not finite admits an injection from $\mathbb{N}$"?  But then it's easy to see it admits a bijection with $\mathbb{N}$ even without using Cantor-Schröder-Bernstein, just by the recursion theorem.
Comment: @TrevorWilson: You're right. I edited somewhat half-heartedly because Asaf's answer is so much better anyway :P


ng-include and src is not working on dynamic change

Question: I've something like below. I am binding countries to a dropdown.
On dropdown change i've to display different views.
 $scope.countries = [{id : 1, name : 'USA'}, {id : 2, name : 'India'}, {id: 3, name :'MIGHTY USSR'}];

 <select class="form-control" ng-model="selectedCountry" ng-options="country as country.name for country in countries">
    <option value="">Select Country</option>
 </select>

-

      This Text is showing

       -- Not Working

       -- I tried this as well

     Other Country

I also tried with

 &

.
My app folder looks like below
app
    views
        partials
           USA.html
           India.html
    dashboard.html
Index

Any solution please?
Comment: post your `countries` array?
Comment: I am using my solution in my project. Can you please reproduce your problem in plunker or fiddle ?
Comment: Please check I added working plunker in my answer.
Comment: please update your question, what you done so far ?
Comment: Finally got the solution. I was referring partials/USA.html... But it  is expecting  app/views/partials/USA.html... Took 3 hrs for this :(
Comment: switch case is not required. direct  ng-include="'views/'+selectedCountry.name+'.html'" suits.
Comment: how can get selected country value in corresponding partial view?
Answer: give a try like below
change the ng-options as below
.. ng-options="country.id as country.name for country in countries"..>

then when you select a drop down option, value of selectedCountry getting the id value of that option for ex: if you select USA then selectedCountry value will be 1, based on that id you can include the .html file u want as,
<ng-include src="'views/'+selectedCountry+'.html'"></ng-include>

and save the .html files as 1.html for USA and 2.htmlfor India
here is a DEMO
and note that if you prefer naming the .html files like India.html & USA.html then simply change the ng-options to
.. ng-options="country.name as country.name for country in countries" ..>

DEMO
Comment: I like this.. why not selectedCountry.Name? USA.html is good.. rather than 1.html. let me try this.
Comment: This example is working fine. But Why not  and why <ng-include ... difference please
Comment: its also working please check http://plnkr.co/edit/qtCr0l2QkrvSsOPcYGjX?p=preview
Comment: My original question also works fine. But,  I was referring partials/USA.html... But it is expecting app/views/partials/USA.html... Took 3 hrs for this :(
Comment: how can get selected country value in corresponding partial view?
Answer: You should not include html page direct into ng-include
Bind you html page in controller
use like this :
MarkUp

JS
$scope.usaPage = "partials/USA.html";

For selected Country :
MarkUp

JS
// in your selection event like ng-click
$scope.SelectedCountryPage = "partials/" + $scope.selectedCountry.name + ".html";

Updates :
Here is the working Plunker
Comment: Finally it is working... problem with path. I've to put this  and i was putting ........../app/views addition..            3 hrs wasted just for simple one. thanks for your support.
Comment: ".html" is missing i guess "partials/" + $scope.selectedCountry.name+".html" . Let me try this
Comment: ahh ! actually .html missing.
Comment: Something is wrong. your examples are working in plunker and not in my code. :(.
Comment: check html file name with your json name and this are case sensitive.
Comment: If i am printing SelectedCountryPage it is showing as partials/USA.html. But  is not showing. File name and Json name both are same
Comment: how can get selected country value in corresponding partial view?
Comment: You can use `service` to set selected Country than you get it from service by load service as dependency in any controller.
Comment: I didn't get. I've asked the same question. Please answer  https://stackoverflow.com/questions/32534680/how-to-get-parent-page-dropdown-value-in-partial-page
Answer: The problem is your {{}} (as well as a "):
'partials/'+{{selectedCountry.name}}+"'.html'

The ng-include doesn't want that. Instead do:
ng-include="'partials/'+ selectedCountry.name + '.html'"

Comment: @PrasadKanaparthi Huh?
Comment: India is example. For USA also it is not working. Let me try it
Comment: @PrasadKanaparthi do you get 'partials/USA.html' as the output in the ng-include?
Comment: Finally it is working... problem with path. I've to put this  and i was putting ........../app/views addition.. 3 hrs wasted just for simple one. thanks for your support.


Select only digits from Text

Question: Anyone can help how can I select only digits from Text?
Strings can be random like:
ABCD123DEF -> Result must be 123
393SEA981F -> Result must be 393981

Thanks!Firebird version is 2.5
Answer: The first that comes to my mind:
use stored procedure as:
SET TERM ^ ;

create or alter procedure GET_DIGIT_ONLY (
    IPARAM varchar(32))
returns (
    OPARAM varchar(32))
as
declare variable I integer;
begin
  oparam = '';
  i = 1;
  while (i <= char_length(:iparam)) do
  begin
    if (substring(:iparam from i for 1) similar to '[0123456789]')  then
      oparam = :oparam || (substring(:iparam from i for 1));
    i = :i + 1;
  end
  suspend;
end^

SET TERM ; ^

How to use:
execute procedure get_digit_only :input_param
returning_values :output_param

or
select get_digit_only.oparam from get_digit_only ('393SEA981F')

Comment: In Firebird 3 you could make a function instead (would be similar).
Answer: You could make EXECUTE BLOCK
EXECUTE BLOCK
RETURNS (number VARCHAR(20))
AS
  DECLARE VARIABLE temp VARCHAR(20);
  DECLARE VARIABLE temp_char VARCHAR(1);
  DECLARE VARIABLE step INT;
BEGIN
  FOR SELECT
    sometable.sometext
  FROM sometable
  INTO :temp DO
  BEGIN
    step = 1;
    number = '';
    WHILE (:step < CHAR_LENGTH(:temp)) DO
    BEGIN
      temp_char = SUBSTRING(:temp FROM step FOR 1);
      IF (POSITION(:temp_char IN '0123456789') > 0) THEN
        number = :number || :temp_char;

      step = step + 1;
    END
    SUSPEND;
  END
END

OR stored procedure by replacing EXECUTE BLOCK with CREATE OR ALTER PROCEDURE SomeProcedure.
EXECUTE BLOCK is runnable as it is, STORED PROCEDURE require a call like
SELECT SomeProcedure.number
FROM SomeProcedure

Answer: If you have a dirty data source this (Firebird 3.0) function may be of help.

Thanks to Val Marinov for the original function.

SET TERM ^ ;

CREATE OR ALTER FUNCTION GET_DIGIT_ONLY (IPARAM VARCHAR(15))
RETURNS INTEGER
AS
DECLARE VARIABLE I INTEGER;
DECLARE VARIABLE ONUM INTEGER;
DECLARE VARIABLE OPARAM VARCHAR(15);
DECLARE VARIABLE V_WORK VARCHAR(15);
BEGIN
    OPARAM = '';
    ONUM = 0;
    I = 1;
    V_WORK = TRIM(IPARAM);
    IF(V_WORK IS NULL) THEN
    BEGIN
        RETURN 0;
    END
    IF(TRIM(V_WORK) = '') THEN
    BEGIN
        RETURN 0;
    END
    WHILE (I <= CHAR_LENGTH(:V_WORK)) DO
    BEGIN
        IF (SUBSTRING(:V_WORK FROM I FOR 1) SIMILAR TO '[0123456789]')  THEN
            OPARAM = :OPARAM || (SUBSTRING(:V_WORK FROM I FOR 1));
        I = :I + 1;
    END
    IF(TRIM(:OPARAM) = '') THEN
    BEGIN
        RETURN 0;
    END
    ONUM = CAST(:OPARAM AS INTEGER);
    RETURN ONUM;
END;

SET TERM ; ^
;

Following the same idea here is a function to extract alpha characters only:
SET TERM ^ ;

CREATE OR ALTER FUNCTION GET_ALPHA_ONLY (IPARAM VARCHAR(15))
RETURNS VARCHAR(15)
AS
DECLARE VARIABLE I INTEGER;
DECLARE VARIABLE OPARAM VARCHAR(15);
DECLARE VARIABLE V_WORK VARCHAR(15);
BEGIN
    OPARAM = '';
    I = 1;
    V_WORK = TRIM(IPARAM);
    IF(V_WORK IS NULL) THEN
        BEGIN
        RETURN '@';
    END
    IF(TRIM(V_WORK) = '') THEN
    BEGIN
        RETURN '@';
    END
    WHILE (I <= CHAR_LENGTH(:V_WORK)) DO
    BEGIN
        IF (SUBSTRING(:V_WORK FROM I FOR 1) SIMILAR TO '[ABCDEFGHIJKLMNOPQRSTUVWXYZ]')  THEN
            OPARAM = :OPARAM || (SUBSTRING(:V_WORK FROM I FOR 1));
        I = :I + 1;
    END
    IF(TRIM(:OPARAM) = '') THEN
    BEGIN
        RETURN '@';
    END
    RETURN OPARAM;
END;

SET TERM ; ^
;

Select only digits from Text


Is there any replacement module for token actions and token starter modules in D7?

Question: I am using TokenActions and TokenStarter modules in my one of the project which is in D6.
Now, I have planned to upgrade it into D7.
I have found the D7 version of Tokens module but I didn't find Tokens Actions and Token Starter in that module.
Is that modules are removed are is it still existing in some other names?
I had googled a lot. But I didn't find anything really useful...
Coudl you guys help me out of this issue ?
Answer: From Dave..Mainter of token module... (As Received)
The Token Actions module has been replaced by the actions provided by core that support tokens. Use the follow button on http://drupal.org/node/1902294 to track progress for migrating those deprecated actions to system-provided ones automatically.
The Token starter is not an actual module that is intended to be used. It's just an example of how you make new tokens. It was deprecated by the token example module in http://drupal.org/project/examples. You should instead make a custom module with a good name for your custom tokens, rather than re-using the token starter module.


How to load aggregated styles / js in an 'external' script via DRUPAL_BOOTSTRAP_FULL?

Question: I have an external script / php application that I now have to implement into a running D7 site. So far DRUPAL_BOOTSTRAP_FULL seems to do the job just fine – I can read the session, check the user etc.
But I am currently stuck trying to load the $styles and $scripts into the head of that external application. I tried drupal_get_css();, also checked the $variables and also tried template_preprocess_html(); to preprocess the  variables –– but D7 won't return anything.
What I have so far:
define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']);
$base_url = 'http://'.$_SERVER['HTTP_HOST'];
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

I hope somebody can direct me in some direction – any pointers appreciated. Thank you!
Update: The solution suggested by oksana-c works quite well if you 'only' need to load the top css and js files. The site I'm working on however caches and aggregates all js and css files into one – including various files provided by different modules… So what I would actually need to find out is how to link to those aggregated js and css files. Anybody?
Update2: I could 'crawl' the folders where the aggregated css and js are stored – however currently I can see 4 different js files and 4 different css files in the head. Also according to the files' timestamps sometimes only 2 files were generated and loaded in the past – so I have basically no indication of how many of the most recent files I should include. Probably some hook would help that would let me list whatever cached/aggregated files are loaded at this time – but I still have no idea where/how to hook into the caching/aggregating functions…
Comment: You might be interested in this issue - https://www.drupal.org/node/2511630 sounds like what you're trying to do.
Answer: Here's the gist of it (w/ commentary).
<?php
// ... your code
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

// get current theme and it's variables
$current_theme = variable_get('theme_default','none');
$themes = list_themes();
$theme_object = $themes[$current_theme];

// uncomment to display structured information about $theme_object
// var_dump($theme_object);

// get current theme path
$theme_path = dirname($theme_object->filename);

    // get path of each stylesheet from current theme
  $final_stylesheets = array();
    if (!empty($theme_object->stylesheets)) {
    foreach ($theme_object->stylesheets as $media => $stylesheets) {
      foreach ($stylesheets as $name => $stylesheet) {
        $final_stylesheets[$media][$name] = $stylesheet;
      }
    }
  }
  foreach ($final_stylesheets as $media => $stylesheets) {
    foreach ($stylesheets as $stylesheet) {
            // will print relative path to the stylesheet
            // here you can wrap each stylesheet in <link type="text/css" ....> tags
            // and compose the output for hte head section of your script
            print $stylesheet;
    }
  }

    // Do same for scripts
  if (!empty($theme_object->scripts)) {
    foreach ($theme_object->scripts as $name => $script) {
      $final_scripts[$name] = $script;
    }
  }
  foreach ($final_scripts as $script) {
    print $script;
  }
?>

all you have left to do is to wrap each $stylesheet and $script in appropriate tags and insert that into the head.
Comment: you see 50 or so files because drupal generates different sets(combinations) of files according to what modules need to load on pages. that's why you see only 4 files in the page header. If you load another page that utilizes features from other modules - you'll see different combination of files. The questions here are, _why your external script should load all of those files_, and_ if it should load only those that are needed - how is your ext. script will define what files are really needed to run successfully? Your objective is kind of vague.
Comment: Thank you very much! I finally managed to implement the solution you suggested –– and it does basically load the basic stylesheets and the basic js files. But there seem to be still some files missing – I guess it's the module's css and js files…

The site I'm working on also aggregates / caches the js and css files into one. So what I would actually need is to get the path to those files… :/
Comment: aggregated css & js files are usually placed in folders `sites/default/files/public/css`, `sites/default/files/public/js`. If you need to load those, then white a script that will find all files in those folders and include them. This sounds a bit overkill though if core aggregation is used. You might want to consider using the [AdvAgg](https://www.drupal.org/project/advagg) module that @mikeytown2 suggested.
Comment: Thank you for your suggestion! The problem is: there is about 50 js and css files generated in the last 6 weeks. Sometimes 2 files are generated at a time, sometimes 3, sometimes 4. At the moment i see 4 js files and 4 css files loaded in the header. I was hoping that there would be some function I could hook in to load whatever is currently needed.

Also I can actually not install additional modules since a different contractor is taking care of everything concerning dp7. I can only use whatever is there…
Comment: I finally came back to the project – and found that the 'missing' details were just placed in another stylesheet called "dirty.css" … (Wow!) So I just added those missing styles to my stylesheet and load the default css the way you described above. Thank you @oksama-c !!


Is $\sqrt{2}^{\sqrt{2}^{\sqrt{2}^{\ldots}}}$ rational, algebraic irrational, or transcendental?

Question: Let
$$
x=\sqrt{2}^{\sqrt{2}^{\sqrt{2}^{\ldots}}}.
$$
Assume $x$ is algebraic irrational. By the Gelfond-Schneider Theorem, $x^x$, which is also $x$, is transcendental, a contradiction.
But I have no idea how to do the rest.
Comment: What does the "etc" mean?  And why does $x^x$ have to be transcendental?
Comment: now that someone removed the "etc.", what does the "..." mean ?
Answer: The only reasonable meaning of $\sqrt 2^{\sqrt2^{\sqrt2^{\cdots}}}$ would seem to be the limit of the sequence
$$ \sqrt2, \sqrt2^{\sqrt2}, \sqrt2^{\sqrt2^{\sqrt2}}, \ldots $$
which can also be defined recursively as
$$ x_0 = \sqrt 2 \\
x_{n+1} = \sqrt2^{x_n} $$
This sequence converges to the number $2$, which is rational.

Why? It is fairly easy to prove (using calculus) that if $x_n$ is less than $2$, then $x_{n+1}$ is between $x_n$ and $2$. Therefore the the sequence of $x_n$s is bounded and strictly increasing, so it must converge towards something. But by continuity the limit must be a solution to $\sqrt 2^x=x$, and the only such solutions are $x=2$ and $x=4$. The latter cannot be a limit because it would require the sequence to increase past $2$, so $2$ is the only possibility.
Comment: I just figured numerically the answer would be $2$, of course the proof above seems to does that  ... but not quite, your $x_0$ is between $1$ and $2$, not between $2$ and $4$, so why could you make the assumption that it is between $2$ and $4$? It seems, numerically, that the sequence converges to $2$ but from below, forming an increasing sequence.
Comment: Sequence is increasing, not decreasing
Comment: I just figured numerically the answer would be $2$, of course the proof above seems to does that  ... but not quite, your $x_0$ is between $1$ and $2$, not between $2$ and $4$, so why could you make the assumption that it is between $2$ and $4$? It seems, numerically, that the sequence converges to $2$ but from below, forming an increasing sequence. So, it is fairly easy that of $x_n$ is between $\sqrt(2)$ and $2$ ... ?
Comment: @Mirko: Whoops, I had the wrong starting point in mind. Fortunately the right argument is almost the same. Edited.
Answer: Your number is the limit of the sequence $a_0=1$ and $a_{n+1}=(\sqrt 2)^{a_n}=2^{a_n/2}$
This sequence is increasing and bounded.
So its limit is the solution of the equation $a=2^{a/2}$
From where you get $a=2$ which is rational.
Answer: Assuming it converges, you can take log of both sides to get 2ln(x)=xln(2), which has solutions 2 and 4.


What does this symbol mean?

Question: I am studying a book on functional analysis and came to a definition that started like this:

Let $M$ be a set and $F: M \hookleftarrow$ a function (...)

My only question is: what does the $\hookleftarrow$ mean?
Comment: an injective function?
Answer: The little curly bit means the function is injective; it is otherwise the same as an ordinary arrow. More generally it means the morphism is a monomorphism in the relevant category.
Comment: Just to expand, the sentence quoted seems to indicate that $F$ is a monomorphism of $M$ into itself.

What does this symbol mean?


issues with app.yaml and in the design of the server

Question: I need to impl a few basic features in this server:

display a nice main screen(html) with < select > widget and 2 buttons(one to choose a image from hd to upload and another to send) + TextEditBox for typing a msg
when the user clicks 'send' - take the users choice from the select widget and
the image will be uploaded

I have managed to implement all of it separately, now when I come to make it all work together I have a problem with app.yaml url paths due to a bad design.
app.yaml looks like:
runtime: python

handlers:
- url: /(.+)
  static_files: images/\1
  upload: images/(.*)

- url: /.*
  script: kserver.py

kserver.py:
class StartPage(webapp.RequestHandler):
    def get(self):
        select_items = db.GqlQuery( "SELECT * FROM Registration" )
        upload_url = blobstore.create_upload_url('/upload')
        self.response.out.write(template.render("tst.html", {'select_items': select_items}))

class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
    def post(self):
        upload_files = self.get_uploads('file')
        image = self.request.get("img")
        photo = Photo()
        photo.imageblob = db.Blob(image)
        photo.put()
        blob_info = upload_files[0]
        self.redirect('/serve/%s' % blob_info.key())

class DownloadImage(webapp.RequestHandler):
    def get(self):
        photo= db.get(self.request.get("photo_id"))
        if photo:
            self.response.headers['Content-Type'] = "image/jpeg"
            self.response.out.write(photo.imageblob)
        else:
            self.response.out.write("Image not available")

class Sender(webapp.RequestHandler):
    def post(self):
        ...
        ...
        self.response.headers['Content-Type'] = 'text/html'     # reply with 200 OK
        self.response.set_status( 200,"OK" )
        ...
        ...

class TokenService(webapp.RequestHandler):
    def post(self):
        self.response.headers['Content-Type'] = 'text/plain'
        self.response.set_status( 200,"Registration accepted" )
        ...

application = webapp.WSGIApplication([('/', StartPage),
                                      ('/sender',Sender),
                                      ('/upload', UploadHandler),
                                      ('/i', DownloadImage),
                                      ('/serve/([^/]+)?', ServeHandler),
                                      ('/token',TokenService)],
                                      debug=True)
def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

This is the tst.html :

        <select name="accountName">
            <option value=\"ALL\">ALL</option>
            {% for item in select_items %}
        <option value="{{ item.accountName }}">{{ item.accountName }}</option>
            {% endfor %}
        </select>
        <form action="sender" method="POST">
            <input  type="text" id="TextEditBox_1">
            <input  type="submit" name="submit">
            <input  type="file" name="img" id="Choose_file">
        </form>

note, Identation is fine, its only parts of code.
in the project, i have a images directory that contains app.ico and backgroung image (statics)
Okay, now the problem is i get in GAE logs :
Static file referenced by handler not found: images/token
Static file referenced by handler not found: images/sender

this is not intended. it should be in '/' i think
and
"/token 404 48ms 0kb            No handlers matched this URL."

in addition, when clicking on "send" it redirects me to a new page with :
The requested URL /sender was not found on this server.

this /token is a POST coming from outside to register to the server - the server than store registrations in db. when "send" button pressed ,it should use this db.register tokens.
any comments on the subject is most welcome. thanx!
Answer: The patterns in your app.yaml are too general:
- url: /(.+)
  static_files: images/\1
  upload: images/(.*)

will match just about anything, so the requests that are meant to be handled by code never get there.  Try something like this:
- url: /(.*\.(gif|png|jpg))
  static_files: static/\1
  upload: static/(.*\.(gif|png|jpg))

which will handle only files that end with gif, png or jpg.
Answer: Your first handler matches anything with at least one character after the first slash; you'll need to use a url like /images/.* or only match files ending in (jpg|gif|png|ico), e.g.


I want to know the points of a vector when I know one of the points and also the distance between the two.

Question: So I have a vector equation which is
$$(1,2,-1) + t(2,1,-2)$$
I also know a point of that line which is
$$(0,0,1)$$
I need to know all the points in which the distance is 3 from the point at (0,0,1)
Thank you.
Comment: Are you sure that (0,0,1) is actually ON the line?
Answer: It's a bit unclear, but I think you are looking for the values of $t$ such that the distance from (0,0,1) to (1,2,-1)+t(2,1,-2) is 3.  The Euclidean distance between the point and a parameterized point on the line can be written as
$$
\sqrt{(1+2t-0)^2+(2+1t-0)^2+(-1-2t-1)^2}
$$
so you are looking for $t$ such that
$$
\sqrt{(1+2t)^2+(2+t)^2+(-2-2t)^2}=3
$$
Comment: This makes a lot of sense. I don't why I didn't think of it myself. Thank you very much.