How to create a custom header with print module and tcpdf

Question: I'm using print module to generate pdf files of the articles. I'm using tcpdf library, I couldn't find the header options in the settings page. I can see options for Logo and footer, but no header options.
When I tried to get the pdf file. In the header section, there appears logo in the left corner and title of the article on the right corner. I was looking for the header settings in such a way to fix header with an image and nothing else.
I tried to google it but ended with empty hands. This article, suggests to create sub-class of tcpdf - I don't know where to create, I mean where to integrate the code??. I also found views PDF module to set header - I don't think it will be a better option.
Is there any better way to set custom header (as image).
Answer: Since there's not an option for that, you'll need to work on the code, and you have two different options there.
First, work on your theme's print.css file and add something like
.article-name{display:none}

If it has none, add on to its .info file with
stylesheets[print][] = 'css/print.css';

Second, if you need "bigger" changes not achievable trough css (or just need too many), copy the print template from the print module to your theme template's folder and edit at wish.

consider however that the cas changes will be applied to every page you will print, and the template changes to every page printed trough the print module, both pdf and all the others.
Comment: I made the changes, but there is no change in the output. I don't what you are trying to suggest.
Comment: and clear the cache for the changes to be registered
Comment: I didn't get your second point - copy print template from print module to your theme template's folder. I couldn't find print template in print module.
Answer: <?php

class PrintTCPDF_No_Headers extends PrintTCPDF {
  public function Header() {
    if ($this->page > 1){
      return;
    }
    parent::Header();
  }
}

you try out this more detials for idea


The relation between matrices and linear maps

Question:
Context

I've been learning about linear maps and matrices while I'm a little confused about some of the details. To make my description of the problem clear, I'll set the general case: a linear map $T\in \mathcal{L}(V,W)$, where $V$ and $W$ are two finite dimensional vector spaces, $\mathcal{M}(T)$ is the matrix of $T$ with respect to the bases: $v_1,v_2,...,v_n$ of $V$ and $w_1,w_2,...,w_m$ of $W$.

Confusion

I'm clear that the linear map $\mathcal{M}$ is an isomorphism between $\mathcal{L}(V,W)$ and $\mathbf{F}^{m,n}$, so for every linear map we can get its matrix with respect to two bases. However, what about the inverse case, how can I determine the linear map behind a specific matrix $A$?  Maybe let $T$ be the map from $V$ to $W$ such that $Tv_k=\sum_{j=1}^mA_{j,k}w_j$ ?
If that's right, since we also know that each m-by-n matrix $A$ induces a linear map from $\mathbf{F}^{n,1}$ to $\mathbf{F}^{m,1}$, namely T that takes $x\in\mathbf{F}^{n,1}$ to $Ax\in\mathbf{F}^{m,1}$, now, is this $A$ the matrix of this $T$? If this is true, then it is much simpler to determine the linear map behind a matrix.

Why I want to know this?

Since I often encounter problems with matrices, and I am thinking of convert them into the problems of linear maps (or operators), is that a way to easily turn the matrix into the linear map behind it so that I can deal with the certain linear map ?
Comment: The notation needs to indicate the bases $\mathcal V$ and $\mathcal W$ as well. Maybe $\mathcal M(T;\mathcal V,\mathcal W)$?
Comment: @TedShifrin You are right, the formal notation should be $\mathcal{M}(T,(v_1,v_2,...,v_n),(w_1,w_2,...,w_m))$, but since the bases are clear from the context I just use the simpler notation.
Answer: It's not possible to know the bases of a particular matrix with only the knowledge of the entries in that matrix. However, if you know the bases of that matrix then the corresponding linear map can be written
$T(v)=T(\alpha_1 v_1+\dots+\alpha_n v_n)=\alpha_1T(v_1)+\dots+\alpha_nT(v_n)=\alpha_1(A_{1,1}w_1+\dots+A_{m,1}w_m)+\dots+\alpha_n(A_{1,n}w_1+\dots+A_{m,n}w_m)$
So your idea is correct. It may be helpful to consider the below theorem if you haven't already done so.
Proving that there is a unique linear map such that $T(u_i)=v_i$.
Comment: Thank you. So in this manner, if, as I said in my second paragraph, let $T: x \to Ax$ then $A$ is actually the matrix of this $T$, under the standard bases of the two spaces ($\mathbf{F}^{n,1}$ and $\mathbf{F}^{m,1}$), right?
Comment: @Smaug Yes, in this case $A$ is the matrix representation of $T$, but it doesn't have to be with respect to the standard bases. If the bases of the matrix representation of $T$ change, then the entries in that matrix may also change. The entries of $x$ and $Ax$ may also change, because they are matrices of vectors defined $(a_1, \dots, a_n)$ such that $v=a_1 v_1 + \dots + a_n v_n$ for some basis $(v_1 , \dots , v_n$). Note that matrices of vectors are distinct from vectors, although the matrix of a vector with respect to the standard basis will have the same entries as that vector.
Comment: @Smaug Naturally, regarding the equation in the answer, $(v_1 , \dots , v_n)$ and $(w_1 , \dots , w_m)$ are the bases of the matrix $A$ in the equation. The theorem in the link may be needed to understand this topic. Let me know if this makes sense.
Comment: @Smaug Also, please kindly mark my answer as accepted if this answers your question, and vote it useful or not useful.


Show two content types in same view

Question: Drupal 8 newb here,
I have two basic types I need to show in my front page: There's a "Restaurants" content type and a "Chefs" content type.
These are shown in my site like this:

The types are unrelated, I just need to show them in the same page as featured.
I've found documentation on how to make blocks and views but nothing about mixed content, which seems to me like a common use case.
Thanks in advance.
Comment: Since you want to list each type separate and not mixed, your only choice is to create two separate view blocks for each type. You could then add those view blocks to the header or footer of page view by adding a "view area".
Comment: I'd do exactly the same as @NoSssweat ... hey there, bonjour !!!
Comment: Thanks a lot guys! exactly how I did it
Answer: You don't need to use blocks: You can create a view with a page and an attachment. First from admin/structure/views/add, you create a view for content, selecting the content type to show and selecting Create a page.

Click on Save and edit.
On the next page, which shows the view settings, click on the + Add button and select Attachment.

The next page will show the settings for the attachment.

The attachment shows nodes for the same content type the Page view does. The first step is changing that. Click on the Content: Content type in the filtering criteria.

On the top, change For from All displays to This attachment (override), select the content type to show. Click on Apply (this display).
The attachment still need to be attached to the Page view. On  Attach to: Not defined click on Not defined.

On the dialog box, select Page and click on Apply.

If you want the attachment to appear after the main content, change from Attachment position: Before to  Attachment position: After*. Then, click on Save to save the settings.
The view needs to be styled better (for example, selecting Grid as format instead of Unformatted list), but it shows two different content types on the same page.
Comment: Thank you very much! Did it almost the same except I created blocks instead of attachments as I had to manage lots of other fields

Show two content types in same view


jquery POST method callback function query

Question: $("#submit_js").click(function() {
            var commentmsg = $('#comment').val();
            $.post(
            "user_submit.php",
            {comment: $("#comment").val(), aid: imgnum, uid:$("#uid").val()},
            function(data){
                /*alert(data);*/
                //$('#greetings').html('Your choice was submitted successfully. Thank You for voting.');
                $('#confirm_msg').addClass("on");
                $('#care_parent').addClass("off");
                $('#fb_user_msg').html(commentmsg);
                //$('#fb_user_msg').html( commentmsg );
            });
        });

the above is my jquery POST function. in the callback function i am doing some html stuff. this is the successful POST version. that means, when the POST procedure is complete or added to the DB. now in my user_Submit.php i am checking to validate whether I should add the data to the DB or not.
Can the callback function be modified so that if I dont add to the DB in user_Submit.php, I should display some other message to the user...
what I really want to ask is, how to make PHP pass a 0/1 value ot JS? can someone help?
Answer: In your user_submit.php, just echo 1 if it was successful and 0 if not. That variable will be returned to your handler function in the data parameter. Then just do a simple if/else to see what the value was.
Comment: It should work. Are you sure you are outputting the success code properly? What happens if you visit `user_submit.php` with your browser? (You should see a `0`)
Comment: i am doing echo 0; and it is appearing fine in firebug console. but somehow if i alert(data); nothing appears. also i tried checking the if/else part too, but nothing happens.


Does a DVR of equal characteristic with a perfect residue field contain it?

Question: Let $R$ be a DVR of equal characteristic with a perfect residue field $k$. Does there exist a unital homomorphism $k\rightarrow R$ such that the composition with the projection $R\rightarrow k$ is the identity?
If the residue field is imperfect of characteristic $p$ consider $k[x]_{(x^p-a)}$ where $a$ is an element that is not $p$-th power. The residue field is $k(a^{1/p})$ but since the fraction field of $R$ is $k(x)$ it does not contain a $p$-th root of $a$.
If $R$ is of mixed characteristic, then there can not be a unital homomorphism from the residue field to $R$ (never mind the composition with the projection).
What have I tried: if $R$ is complete then it is isomorphic to $k[[x]]$ so the statement is true.
Comment: Nice example!!!
Answer: No, consider the DVR $\mathbb{R}[x]$ localized at the the maximal ideal $(x^2 +1)$. The residue field is $\mathbb{C}$ but no subset of $R[x]_{(x^2+1)}$ contains the square root of $-1$.


Simplifying $(m^3)^4(2x^3)^7(m^2)^5(3x)^2$

Question: I am having trouble with simplifying the following algebraic expression:
$$(m^3)^4(2x^3)^7(m^2)^5(3x)^2$$
I have been able to do the exponents and all the other equations I needed to simplify but not this one. If somebody could provide a step by step solution to the equation then that would be greatly appreciated.
Comment: where is "equation."
Comment: Hint: $(n^a)^b=n^{ab}$ and $(n^a)(n^b)=n^{a+b}$
Comment: You want to call this an "expression". Equations have equal signs.
Answer: Ok, so you want to simplify
$$
(m^3)^4(2x^3)^7(m^2)^5(3x)^2
$$
As the other answer attempts to, you can focus on each factor on its own. You simply use the rules that

$x^ax^b = x^{a+b}$ and
$(x^a)^b = x^{ab}$ and
$(xy)^{a} = x^ay^a$

So
$$
\begin{align}
(m^3)^4 &= m^{3\cdot 4} = m^{12} \\
(2x^3)^7 &= 2^7(x^3)^7 = 2^7x^{21}\\
(m^2)^5 &= m^{10}\\
(3x)^2 &= 3^2x^2
\end{align}
$$
So
$$\begin{align}
(m^3)^4(2x^3)^7(m^2)^5(3x)^2
&= m^{12}2^7x^{21}m^{10}3^2x^2 \\
&= 2^73^2m^{12}m^{10}x^{21}x^{2} \\
&= 2^73^2m^{22}x^{23}
\end{align}
$$
Comment: It's not (m^3)^2 but instead (m^3)^4. And the calculator is giving me an answer of 128x^21 for (2x^3)^7.
Comment: @Anonymous: I already fixed that :)
Comment: The calculator is giving me an answer of 1152m^22x^23.
Comment: @Anonymous: Well, what is $2^7$ times $3^2$?
Comment: Isn't (2x^3)^7 equal to 128^21?
Comment: @Anonymous: Nope. $(\color{red}{2}\color{green}{x^3})^7 = \color{red}{2}^7(\color{green}{x^3})^7$ because of the rule $(\color{red}{x}\color{green}{y})^n = \color{red}{x}^n\color{green}{y}^n$
Comment: I don't get it.
Comment: @Anonymous: Consider this example $6^3 = 216$. And since $6 = 2\cdot 3$ you could also do $(2\cdot3)^3 = 2^3\cdot3^3 = 8\cdot 27$ which is still $216$.
Comment: Interesting. But what about (2x^3)^7=2x^3*2x^3*2x^3*2x^3^2x^3*2x^3*2x^3?
Comment: @Anonymous: Exactly, so you will have $7$ factors of $2$ and $7$ factors of $x^3$.
Comment: Are you sure that's the correct answer?
Comment: @Anonymous: I am pretty sure.


P-Value Clarification

Question: I'm new to P-Values and Hypothesis testing and I noticed that p-values are explained differently everywhere I go. In my lecture notes it has a method for hypothesis testing and the last part says that "if the p-value is not small enough to rule out chance, we fail to reject null hypothesis". A p-value is stated as:  the probability of observing a value of the test statistic at least as contradictory to the null hypothesis as the one computed from the sample data"
Now, what doesn't make sense to me is that if p-value tells me the probability of observing a value of a test statistic at least as contradictory to the null hypothesis, then surely a low p-value(less than significance) would mean that it isn't very contradictory and thus we fail to reject but in fact they do it the other way around. I.e if p-value is less than significance, they actually reject null hypothesis?
Some sites say that the p-value is the strength of the evidence from the test statistic. Any clarificaiton?
Comment: You ask a good question, but the answer would be a book chapter. And many (including me) have written that chapter! For a good answer here, I think you'll need to ask a more focussed question.
Answer: Many people attempt to simplify the definition of a p-value, and inevitably subtle errors or misunderstandings seep into their discussions.  It's best to resist the urge, and speak precisely as possible:

A p-value is the conditional probability of observing a statistic equal or more extreme than the value produced by the data actually collected, given all the assumptions of the null hypothesis.

That's it.
The general procedure for producing such a thing is:

State precisely a null hypothesis.
Use the null hypothesis to create a probabilitic model of how your data would be generated if the null hypothesis is true.
Create a measure of the "extremeness" of your data, this is the test statistic.
Use the probabilistic model from the second bullet point to derive a distribution of the test statistic from the third.
Compute the conditional probability from the definition of p-value.

The standard tests that people learn in school are just patterns of the above procedure that tend to come up repeatedly in various situations.
Answer: Let's use a simple example. You obtain a group mean of 10. Your H0 hypothesized or reference mean is 0.  Is 10 sufficiently different from 0 to declare statistical significance?  Well that depends on the variability (and possibly other factors like N) inherent in your data, and that then dictates your p-value.
Smaller p-values do suggest more 'evidence' against the null hypothesis, but be careful - an effect either is or is not significant under the NHST regime (c.f. The Neaman-Pearson approach of effect sizes).
And here's where your confusion lies: the p-value is the probability of observing such an extreme (or more) mean by chance alone. So lower values mean that it's less likely to have happened randomly.

P-Value Clarification


What Is Netty DecoderResult and How to Use It?

Question: I'm learning how to use Netty (so totally new the the tool). I studied the HTTP server example given in Netty documentation. But I don't understand what DecoderResult is and how it's used in the example.
What I learned so far:
1. Decoders are to convert bytes to more complex objects. In this case bytes to HttpRequest.
2. In the last ChannelInboundHandler (after all decoding is completed) I receive my object (e.g. HttpRequest).
3. The implementation of channelRead0 method of HttpSnoopServerHandler is quite clear: get the object, down cast, extract information, build the response, and write it when it's ready.
What I don't understand is why checking for the result of decoding (i.e. appendDecoderResult) is done at after reading some stuff from the HttpRequest object? Shouldn't I check for such failure before touching msg. More generally what happens when the decoding fails?
For the record, here's the part of the code which I'm confused:

@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
    if (msg instanceof HttpRequest) {
        val request = (HttpRequest) msg;

        // read all sort of stuff from request
        // and add them to the response buffer;

        // This is the line confused me :/
        appendDecoderResult(buf, request);
    }
}

Answer: It's actually the HTTP decoder, meaning it reads the data and tried to decode it into an HTTP request. While doing this it may encounter some problems which may cause the decoding process to fail. Never the less the already decoded data can be used. So I guess the order does not matter.


PostgreSQL Select Columns Then Add Random Value

Question: SOLVED! Thanks Gordon Linoff!
Is it possible to get query result like this in PostgreSQL?
UserName | Count |
Sukri    |   1   |
Azis     |   2   |
Adit     |   1   |
Total    |   4   |

The row "Total" value is the sum of 3 columns.
SELECT
CASE
    WHEN (res."UserName"IS NULL OR res."UserName" = '') THEN 'TOTAL'
    ELSE res."UserName"
END AS "UserName",
res."Count"
FROM
(
    SELECT "UserName", count("UserName") AS "Count"
    FROM "Ticket"
    GROUP BY GROUPING SETS ( ("UserName"), () ) ORDER BY "UserName"
) AS res

Comment: There is no chance to answer this when we don't know the tables you are selecting from.
Answer: I am going to guess this is an aggregation query.  If so, use grouping sets (or rollup):
select coalesce(username, 'Total') as userid, count(*) as cnt
from t
group by grouping sets ( (username), () );

Comment: That works! It returns the sum of count column, but the username column returns null...
Comment: The result is like this:

UserName | Count |
Sukri    |   1   |
Azis     |   2   |
Adit     |   1   |
[null]    |   4   |


Why would one use `random' confidence or credible intervals?

Question: I was reading a paper recently that incorporated randomness in its confidence and credible intervals, and I was wondering if this is standard (and, if so, why it is a reasonable thing to do). To set notation, assume that our data is $x \in X$ and we are interested in creating intervals for a parameter $\theta \in \Theta$. I am used to confidence/credibility intervals being constructed by building a function:
$f_{x} : \Theta \rightarrow \{0,1\}$
and letting our interval be $I = \{ \theta \in \Theta \, : \, f_{x}(\theta) = 1\}$.
This is random in the sense that it depends on the data, but conditional on the data it is just an interval. This paper instead defines
$g_{x} : \Theta \rightarrow [0,1]$
and also a collection of iid uniform random variables $\{U_{\theta} \}_{\theta \in \Theta}$ on $[0,1]$. It defines the associated interval to be $I = \{ \theta \in \Theta \, : \, f_{x}(\theta) \geq U_{\theta} \}$. Note that this depends a great deal on auxillary randomness, beyond whatever comes from the data.
I am very curious as to why one would do this. I think that `relaxing' the notion of an interval from functions like $f_{x}$ to functions like $g_{x}$ makes some sense; it is some sort of weighted confidence interval. I don't know of any references for it (and would appreciate any pointers), but it seems quite natural. However, I can't think of any reason to add auxillary randomness.
Any pointers to the literature/reasons to do this would be appreciated!
Comment: (+1) This is called a *randomized procedure.*  They are a standard part of the statistical estimation and testing framework, so you can rely on just about any rigorous textbook to provide explanations. Additional motivation for their use can be found in the game theory literature.
Comment: Actually, bootstrapping is *not* a randomized procedure.  It is a *determinate* procedure whose *approximate calculation* is performed by means of random sampling.
Comment: Thanks for the response. I realized after reading this comment that e.g. bootstrapping fits into this framework, but in that situation the reason for randomization is clear (you don't have access to f, just g). In my case, the authors explicitly calculate $f_{x}$, and THEN look at $g_{x}$. Although I have many stats textbooks, I don't see this anywhere... do you have a suggested text?
Answer: Randomized procedures is used sometimes in theory because it simplifies the theory.  In typical statistical problems, it does not make sense in practice,  while in game-theory settings it can make sense.
The only reason I can see to use it in practice, is if it somehow simplifies calculations.
Theoretically, one can argue it should not be used, from the sufficiency principle: statistical conclusions should only be based on sufficient summaries of the data, and randomization introduces dependence of an extraneous random
$ U $ which is not part of a sufficient summary of the data.
UPDATE

To answer whuber's comments below, quoted here:  "Why do randomized procedures "not make sense in practice"? As others have noted, experimenters are perfectly willing to use randomization in the construction of their experimental data, such as randomized assignment of treatment and control, so what is so different (and impractical or objectionable) about using randomization in the ensuing analysis of the data? "
Well, randomization of the experiment to get the data is done for a purpose, mainly to break causality chains.  If and when that is effective is another discussion.  What could be the purpose for using randomization as part of the analysis?  The only reason I have ever seen is that it makes the mathematical theory more complete! That's OK as long as it goes.  In game-theory contexts, when there is an actual adversary, randomization my help to confuse him. In real decision contexts (sell, or not sell?) a decision must be taken, and if there is not evidence in the data, maybe one could just throw a coin.  But in a scientific context, where the question is what we can learn from the data, randomization seems out of place. I cannot see any real advantage from it!  If you disagree, do you have an argument which could convince a biologist or a chemist?  (And here I do not think about simulation as part of bootstrap or MCMC.)
Comment: Why do randomized procedures "not make sense in practice"? As others have noted, experimenters are perfectly willing to use randomization in the *construction* of their experimental data, such as randomized assignment of treatment and control, so what is so different (and impractical or objectionable) about using randomization in the ensuing *analysis* of the data?
Comment: @kjetil I think you might not have completed your statement about the sufficiency principle, it seems to have been cut off mid-sentence ("statistical conclusions should...").
Comment: (+1) But I think it's begging the question to invoke the Sufficiency Principle, the argument for which is that once you know the observed value of the sufficient statistic, taking any other aspect of the data into account is *equivalent to introducing an extraneous random $U$*. So someone proposing to do just that wouldn't give a fig for the Sufficency Principle. Also, see Basu (1978), "Randomization in Statistical Experiments", *FSU Statistics Report M466* for a couple of randomized procedures proposed in earnest.
Comment: @whuber: It is a clear, principled argument that randomization in obtaining the data may be advantageous. (It breaks causal chains). What is that principled argument for using randomization as part of the analysis?
Comment: Kjetil: It enables you to achieve the intended risk function, rather than accepting a risk function (often in the form of nominal size and power) that is not what you wanted. Moreover, if a procedure is "theoretically" useful then there certainly can be no objection to its use in practice, other than impracticability (which is usually not the case with randomized procedures). Thus your question should be turned on its head: the burden is on *you* to demonstrate there is something wrong with using randomized procedures. How do you accomplish that without contradicting yourself?
Comment: @whuber: I have problems accepting this. In a real decision problem, maybe.  But the use I am accustomed to is really in evaluating scientific evidence. There can be no role for extraneous randomization in defining the evidence about some hypothesis from a scientific experiment!
Comment: That's an insightful distinction: we cannot demand that all statistical procedures be optimal for all applications. We could argue over whether randomized procedures have a role in doing science--which is rather an epistemological debate rather than a statistical one--but I'll let that drop and just point out that statistical methods are applied in many other circumstances, such as helping people make decisions and take actions. Note, too, I am not maintaining that people *should* use randomized procedures, but only suggesting that their use should not be ruled out.
Comment: That's right: the suspicion with randomization is that it's too easy to cheat--just keep drawing random numbers until you get the decision you want! But in some circumstances you can get around that problem by announcing your procedure in advance and even drawing the random numbers in advance. It is only through such careful controls that randomization actually works for selecting experimental subjects in heavily regulated arenas such as drug trials.
Comment: @whuber I think your comments here and under the original post, about the decision-theoretic advantages, possibly deserve breaking out into a separate answer.
Comment: whuber: As I said, it goes aganst he sufficiency principle.
Comment: Thank you for completing that sentence. However, it does not really seem to address the point I was quoting. After all, the *selection* of the data themselves was based on "extraneous random" variables, so what is the matter with using one more such variable as part of the overall experiment?
Comment: @whuber:  Yes, thanks. I can even imagine situation where using a randomized decision procedure could give you problems in a court case ... needing to defend the use of randomization in front of a jury ...
Answer: The idea refers to testing, but in view of the duality of testing and confidence intervals, the same logic applies to CIs.
Basically, randomized tests ensure that a given size of a test can be obtained for discrete-valued experiments, too.
Suppose you want to test, at level $\alpha=0.05$, the fairness of a coin (insert any example of your choice here that can be modelled with a Binomial experiment) using the probability $p$ of heads. That is, you test $H_0:p=0.5$ against (say) $H_1:p<0.5$. Suppose you have tossed the coin $n=10$ times.
Obviously, few heads are evidence agaist $H_0$. For $k=2$ successes, we may compute the $p$-value of the test by pbinom(2,10,.5) in R, yielding 0.054. For $k=1$, we get 0.0107. Hence, there is no way to reject a true $H_0$ with probability 5% without randomization.
If we randomize over rejection and acceptance when observing $k=2$, we may still achieve this goal.
Comment: This is a nice explanation of the use of randomization, but it would be nice if it explained why we might be interested in attaining arbitrary $\alpha$ in the first place. Why is it a desirable goal?
Comment: Well, that I guess brings us back to the history of statistics, when R.A. Fisher somewhat arbitrarily decided to work with a significance level of 5% to decide whether some initial evidence warrants further study. As we know, 5% has since morphed into a sort of gold standard in many fields, despite lacking good decision-theoretic foundation.


Show $\det(F_n)=1$ for all $n$

Question: Consider the $n\times n$ matrix $F_n= (f_{i,j})$ of binomial coefficients
$$f_{i,j}=\begin{pmatrix}i-1+j-1\\i-1\end{pmatrix}$$
Prove that $\det(F_n)=1$ for all $n$.

My current idea is to apply Leibniz formula for determinants and induction, but it seems too complicated. Any better ideas and suggestions are welcome.
Comment: @Phicar I have never heard of it
Comment: Do you know Lindström–Gessel–Viennot lemma?
Answer: Using the formula $\binom{n}{k}=\binom{n-1}{k}+\binom{n-1}{k-1}$ you get, by applying the column operations
$$
\left\{
\begin{array}{lcl}
C_n&\gets& C_n-C_{n-1} \\[1mm]
C_{n-1}&\gets& C_{n-1}-C_{n-2} \\[1mm]
&\vdots\\[1mm]
C_2&\gets& C_2-C_{1}
\end{array}
\right.
$$
that
$$\det(F_n) = \det\left(
\begin{array}{c|ccc}
1&0&\cdots&0\\\hline
*\\
\vdots&&F_{n-1}\\
*\end{array}\right)
=
\det(F_{n-1})$$ So that the sequence $\det(F_n)$ is constant equalt to its first term $\det(F_1)=1$.

Show $\det(F_n)=1$ for all $n$


Como eu faço um Redirect no route caso seja a primeira vez que roda?

Question: Minha estrutura está assim:
var app = angular.module('MainApp',[
    'ngRoute',
    'mainAppControllers'
]);

app.config(['$routeProvider',

function($routeProvider){
    $routeProvider.
        when('/tutorial', {
            templateUrl: 'partials/tutorial.html',
            controller:  'TutorialCtrl'
        }).
        when('/menu', {
            templateUrl: 'partials/menu.html',
            controller:  'MenuCtrl'
        }).
        when('/termo', {
            templateUrl: 'partials/termo_de_uso.html',
            controller:  'TermoCtrl'
        }).
        otherwise({
            redirectTo : '/tutorial'
        });
}
]);

No entanto eu quero que quando for a primeira vez que abre o app ele direcione para uma página e se for a segunda vez que abre direciona para outra página.
Como posso fazer isso?
Comment: Seu objetivo é criar algo como se fossem diversas etapas?
Comment: Oi @AndréRibeiro  minha ideia é na primeira vez que abrir o app ele levar para uma tela de tutorial e depois disso na segunda vez que abrir ele levar para outra tela. A tela de tutorial apareceria apenas na primeira vez q rodar o app
Answer: Você pode armazenar uma entrada no localStorage assim que o controller do tutorial for carregado e na função app.run() do Angular você verifica se essa entrada existe e, caso não exista, você redireciona pra rota do tutorial.
A função .run() é chamada sempre na inicialização do módulo.
Ex.:

app.run(['$location', function($location){
  // tutorial foi visualizado? Se não (getItem() === null) redireciona pra rota do tutorial.
  if(window.localStorage.getItem("tutorial") === null) {
    $location.path('/tutorial');
  }
}]);

Ao carregar TutorialController a entrada é adicionada.
app.controller('TutorialCtrl', ['$scope', function($scope){
    // ...
    window.localStorage.setItem("tutorial", 1);
    // ...
}]);

Lembrar de mudar a rota padrão pra algo que não carregue TutorialCtrl:
app.config(['$routeProvider',

    function($routeProvider){
        $routeProvider.
            when('/tutorial', {
                templateUrl: 'partials/tutorial.html',
                controller:  'TutorialCtrl'
            }).
            when('/menu', {
                templateUrl: 'partials/menu.html',
                controller:  'MenuCtrl'
            }).
            when('/termo', {
                templateUrl: 'partials/termo_de_uso.html',
                controller:  'TermoCtrl'
            }).
            otherwise({
                redirectTo : '/menu' // rota padrão que não seja a do tutorial
            });
    }
]);

Dessa forma o tutorial sempre será ser carregado na primeira vez que o app rodar independentemente da rota que for acessada. Nos carregamentos posteriores o funcionamento será normal.
Comment: Muito obrigado! Funcionou perfeitamente


Details of Bayesian linear regression

Question: In Bayesian Linear Regression, we have a data set with {$x_{i}$, $t_{i}$} where $x_{i}$ are input vectors and $t_{i}$ are their resulting observations. We want to find a vector $\bf{w}$ in order to maximize the posterior distribution $p({\bf{w}}|{\bf{t}})$  and hopefully make good prediction for future $x_{i}$'s.
In this Bayesian formalism, we multiply a prior $p({\bf{w}}|\alpha)$ by the likelihood function $p({\bf{t}}|{\bf{w}})$ to obtain $p({\bf{w}}|{\bf{t}})$ and then use this distribution as a prior and repeat the process again. However, I have a question regarding the details of this procedure.
For example, suppose we don't have any data points at first and rely exclusively on the prior, and as long as we can infer the hyperparameter $\alpha$, we are going to be able to do that. In the next step, we receive a data point $\{x_{1}$, $t_{1}\}$, and we calculate the likelihood $p({\bf{t_{1}}}|{\bf{w}})$ which involves a Gaussian with mean ${\bf{w}}^{T}\phi({x_{1}})$ and variance $\beta^{-1}$. Using a model such as $w_{0}+w_{1}x$, this amounts to this:
$$p({\bf{t}}|{\bf{w}}) \propto \exp{\{\beta(t_{1} - (w_{0}+w_{1}x_{1}))^{2}\}}$$
so if that is correct, we know everything except $w_{0}$ and $w_{1}$. Do I get a probability for each combination of $w_{0}$ and $w_{1}$? In any case, I think this is a function of $\bf{w}$ that we can multiply by the prior to obtain a posterior.
Did I understand anything wrong about this procedure of $\text{posterior}\propto\text{likelihood}\times\text{prior}$? If so, I would appreciate any corrections.
UPDATE: I added a picture from Bishop's book "Pattern Recognition and Machine Learning" in which this process is described. The first column is the likelihood, second column is the prior/posterior and third column describes the input vectors in blue and samples of $\bf{w}$ taken from the posterior in the equation $w_{0}+w_{1}x$.

Thanks
Comment: Quick comment (I hope I haven't misunderstood your question): it is $\text{posterior}\propto\text{likelihood}\times\text{prior}$ and not equal to. There is a proportionality constant that should not be neglected and that ensures that the posterior is a probability density for any likelihood and prior.
Comment: @tibL Yes, I meant proportional to the likelihood $\times$ prior. I already change that part in my question.
Comment: This sounds a question asking for re-assurance, and basically, yes you've got the interpretation correct.  Bayes is similar to the "loss function" + "regularising penalty" framework of machine learning.  In bayes you have log-likelihood and log-prior as the equivalents - but you also get accuracy measures as well as predictions.
Comment: @probabilityislogic Yes, I'm looking for re-assurance and in the process, I'd like to get another detailed description to make sure I understand how it works. The part that I thought was a bit weird is that we have a likelihood with $\bf{w}$ as unknowns, so it's not possible to solve it (although we can plot it for every value of $\bf{w}$) but after multiplying likelihood by the prior, we obtain a probability $p({\bf{w}}|{\bf{t}})$ where is natural to ask for a given $\bf{w}$ and get a number.
Answer: One interesting thing (and the reason it is 'a bit weird' and we can't solve for a unique ${\bf{w}}_{\text {ML}}$) about the likelihood functions plotted in the left column of Fig. 3.7, is that they use fewer data points than the number of parameters in the linear model, i.e., $M\lt N$. So this is the 'opposite' situation compared to that of the usual 'tall', $N\times M$ with $N>M$, design matrices, $\bf\Phi$, the geometry of which is discussed in section 3.1.2. There we can solve for a unique least squares ${\bf{w}}_{\text {ML}}=({\bf\Phi}^{\text T}{\bf\Phi})^{-1}{\bf\Phi}^{\text T}$${\bf t}$ such that ${\bf\Phi w}_{\text {ML}}$ is the orthogonal projection of $\bf t$ onto the $M$-dimensional hyperplane spanned by the columns of $\bf\Phi$ (assuming $\text{rank}({\bf\Phi})=M$). But with a wide($N<M$) $\bf\Phi$, there is a non-empty null-space, $\text{Kern}$, of dimension $M-N$ (assuming $\text {rank}({\bf\Phi})=N$).
For the likelihood functions of Fig. 3.7, $M=2, N=1$, $\text{dim}(\text{Kern})=1$. A single point does not uniquely define a line.  (Here is an example of a situation where it is impossible to normalize the likelihood function so it can't be a density.) If we held off and plotted the likelihood functions based on 2 or more points, they would have unique maxima(assuming at least 2 didn't fall on top of each other). In either case, the posterior have unique ${\bf w}_\text{MAP}$ as you pointed out.
Comment: One question I have is why doesn't the mode/mean of the posterior distribution march from that of the prior to the MLE as data points are added? It seems that it should given what Bishop says in sec 2.3.6 about eqs 2.141, 2.242, and the analogous eqs 3.50, 3.51 as $N$ goes from 0 to large.

Details of Bayesian linear regression


How to navigate through tables and get results by a query in sqlite

Question: Having some tables where I store information about a patient and type of tests (there are 3 types of tests, those I store in other table) patient were exposed I got:
CREATE TABLE IF NOT EXISTS patients (
  ID         INTEGER PRIMARY KEY AUTOINCREMENT,
  Name     VARCHAR(50) NOT NULL,
  Tel   VARCHAR(35) NOT NULL,
  Email      VARCHAR(35) NOT NULL
);

CREATE TABLE IF NOT EXISTS tests (
  id_test   INTEGER PRIMARY KEY AUTOINCREMENT,
  id_patient    INTEGER,
  id_type_test  INTEGER,
  id_graph  INTEGER,
  id_graph2 INTEGER,
  date_test VARCHAR(10),
  FOREIGN KEY (id_patient)  REFERENCES patients(id_patient) ON DELETE CASCADE,
  FOREIGN KEY (id_type_test) REFERENCES type_tests(id_type_test) );

CREATE TABLE IF NOT EXISTS type_tests  (
    id_type_test     INTEGER PRIMARY KEY AUTOINCREMENT,
    name_test      VARCHAR(6) NOT NULL
);

INSERT INTO type_tests values (1,'Audi');
INSERT INTO type_tests values (2,'Log');
INSERT INTO type_tests values (3,'na');

INSERT INTO patients values (1,'John','5653346','firstname.lastname@example.com');
INSERT INTO patients values (2,'Karla','234346','email@example.com');
INSERT INTO patients values (3,'Chad','6667653346','firstname.lastname@example.com');

INSERT INTO tests values (1,1,1,50,160,'02/02/2010');
INSERT INTO tests values (2,1,3,55,165,'12/05/2010');
INSERT INTO tests values (3,1,3,65,170,'03/12/2010');

I would like to retrieve all patient information of all patients plus their studies ordered by most recent date like:
ID Name Tel Email Date Test graph graph2

To solve that first I tried getting all studies of one patient like:
SELECT te.name_test AS Test,
       e.date_test AS Date,
       e.id_graph AS id_graph,
       e.id_graph2 AS id_graph2
  FROM tests e
       INNER JOIN type_tests te
           ON e.id_type_test = te.id_type_test
 WHERE e.id_patient=1
ORDER BY
       e.date_test DESC;

I got:
Test    Date         id_graph   id_graph2
na       12/05/2010   55    165
na       03/12/2010   65    170
Audi    02/02/2010    50    160

How can I get all patient information of all patients?
Here is a sqlfiddle
desired output would be
ID Name Tel       Email         Test Date        id_graph id_graph2
1  John 5653346   firstname.lastname@example.com  na   12/05/2010  55       165
1  John 5653346   firstname.lastname@example.com  na   03/12/2010  65       170
1  John 5653346   email@example.com  Audi 02/02/2010  50       160

If there were more patients I would like to show all patients...
Answer: Simply join the patients table:
SELECT p.ID,
       p.Name,
       p.Tel,
       p.Email,
       te.name_test AS Test,
       e.date_test AS Date,
       e.id_graph AS id_graph,
       e.id_graph2 AS id_graph2
  FROM tests e
       INNER JOIN type_tests te
           ON e.id_type_test = te.id_type_test
       INNER JOIN patients p
           ON p.ID = e.id_patient
 WHERE e.id_patient=1
ORDER BY
       e.date_test DESC;

SQL Fiddle
Comment: That query woill work to retrieve all info for patient with ID = 1, How to get all info of all patients?
Comment: If you don't want to restrict it to id=1, just remove the `WHERE` condition.


Prove $(x_n)_{n\in\ \mathbb N}$ is a convergent sequence.

Question: Let $(x_n)_{n\in\ \mathbb N}$ and $(y_n)_{n\in\ \mathbb N}$ be two sequences in $\mathbb R$. Suppose $|x_n - x_m| \le y_n$ for all $n,m \in \mathbb N$ with the condition that $m \ge n$. Show that if $\lim_{n \rightarrow \infty} y_n = 0$, then $(x_n)_{n\in\ \mathbb N}$ is a convergent.
I'm guessing that I should most definitely prove the sequence $(x_n)_{n \in \mathbb N}$ is a cauchy sequence and from there use the big Cauchy theorem.
Since we can assume the $\lim_{n \rightarrow \infty} y_n = 0$, I know for any $\epsilon >0$ there exists $n\in \mathbb N$, then $\forall m \in \mathbb N$ such that $m \ge n$ we have $|x_n - x_m| \le |y_n| \le \epsilon$, but I'm stuck here since, I need to show that $|x_n - x_m| \le \epsilon$ $\forall n,m \in \mathbb N$ and choose a new $N \in \mathbb N$ such that these are greater than N.
I'm wondering if I could get any feedback, thank you.
Answer: Given $\epsilon> 0$, there exists $N$ such that $n\geq N$ implies that $|y_n|<\varepsilon$. In particular if $m\geq n\geq N$, then
$$
|x_n-x_m|\leq y_n<\varepsilon,
$$
This means that $(x_n)$ is a cauchy sequence and thus converges.
Comment: @FlorianSuess What difference does it make having $m\geq n$? Since you're taking the absolute value of the difference, you could swap the terms or relabel them and you'd still have the same inequality.
Comment: Is that complete though? Because we're fixing the condition that $m \ge n$. And for cauchy you need that to be true for all choices of $n$ and $m$ greater than $N$.


re-parked domain at godaddy and assigned A record, domain is not refreshed for everyone

Question: I had a domain that was parked at linode.
I moved it back to godaddy and parked it there. then i My A record "@" have the ip value of my new server.
it has been more then 10 hours since then, for some computers this works and they get the new website on the new server. for other computers (asked friends around the world) it isn't updating.. and they still get the old server with old website.
anyway I can hurry this process up? will it get updated eventually for everyone?
thanks
Comment: general rule of thumb: allow 48 hours for DNS changes to take effect.
Comment: guy schaller : impossible to know with so little details. Give the domain name and we can run dig to see the TTL, the state of various caches, the synchronization of authoritative name servers, etc. Otherwise, we can just guess.
Comment: Are you sure it's not just client side cacheing? Have them flush their DNS cache.
Comment: Bryan : the typical value is much shorter now. 48h is now more an urban legend than a measured fact
Answer: No you cannot, each DNS server has its own setting to refresh their cache and you can add to this local DNS caches stored on the computer. You only have to wait.
Comment: But +1 because any DNS server is free to ignore these.  Many ISPs set their servers to ignore TTLs which they consider to be too low.
Comment: -1 because the duration of stay in the caches is *not* controlled by the cache but by the authoritative server which sets the TTL (time to live).


Determining Exchange Server Version in Exchange 2013 Using Powershell

Question: Hoping someone can help me understand the following:
In an Exchange 2013 environment, when I issue the Get-ExchangeServer cmdlet in a powershell session, I see output that reports the AdminDisplayVersion property as "Version 15.0".  That is correct for a 2013 Exchange Server.
However, when I issue the Get-ActiveSyncOrganizationSettings cmdlet in the same 2013 environment, I see the ExchangeVersion property reported as "0.10 (188.8.131.52)".
That indicates a 2010 Exchange Server.
Is this a defect in one of the Microsoft cmdlets, or are these correct, but for different components of the Exchange environment?
Comment: You asked Exchange for the ActiveSync version, not the version of the software itself. I think you need to look elsewhere for a way to determine the server's version at runtime.
Comment: Thanks for the confirmnation on this, Brian.  Makes sense since the cmdlet is Get-ActiveSyncOrganizationSettings. Very helpful.
Answer: I created a PowerShell function to retrieve the proper version information for Exchange 2007, 2010 and 2013. My blog post includes the code and some usage examples. Since the function is over 200 lines, I will not include it here. The following is some sample usage and output of the function:
Get Installed Updates (Cumulative and Update Rollups) for a Single Server
<code>[PS] Get-ExchangeServerPlus -cn exch01 | select -ExpandProperty update | ft inst*,upd*,desc* -AutoSize

InstallDate UpdateBuild Description
----------- ----------- -----------
11/11/2012  8.3.279.5   Update Rollup 8-v2 for Exchange Server 2007 Service Pack 3 (KB2756497)
02/18/2013  8.3.298.3   Update Rollup 10 for Exchange Server 2007 Service Pack 3 (KB2788321)
</code>
Output All Exchange Server Object Properties with Installed Updates
<code>Get-ExchangeServerPlus | % {"Name`t: $($_.Name)"; "Version`t: $($_.Version)"; "Edition`t: $($_.Edition)"; "Build`t: $($_.Build)"; "Role`t: $($_.Role)"; "OSVer`t: $($_.OSVer)"; "OSSP`t: $($_.OSSP)"; "OSArch`t: $($_.OSArch)"; if ($_.Update) { $_ | select -ExpandProperty update | ft inst*,upd*,desc* -auto } else { [Environment]::NewLine }}

...
Name    : EXCH160-02
Version : 2013
Edition : Enterprise
Build   : 15.0.620.29
Role    : MB,CAS
OSVer   : Microsoft Windows Server 2012 Datacenter
OSSP    : 0
OSArch  : 64-bit

InstallDate UpdateBuild Description
----------- ----------- -----------
04/21/2013  15.0.620.29 Microsoft Exchange Server 2013 Cumulative Update 1
...
</code>
Answer: You might be able to get the exchange version by checking the file versions on the installed bits.  I don't have access to a 2013 environment, but I'll bet there is a few files (.exe or .dll) which will have the version.  To extract it:
<code>[System.Diagnostics.FileVersionInfo]::GetVersionInfo("somefilepath").FileVersion
</code>


Let $*$ be the operation $a*b = ab^2$ over the integers. Is this a group?

Question: I'm trying to prove associativity and I think this operation fails.
This is what I have:
$$\begin{align}
(a*b)*c &= a*(b*c)\\
(ab^2)*c &= a*(bc^2)\\
(ab^2)(c^2) &= (a)(bc^2)^2\\
ab^2c^2 &\neq ab^2c^4
\end{align}$$
Comment: All you still need is examples of integers $a$, $b$ and $c$ so that the final line holds.
Comment: Alternatively, $1$ would have to be the identity for this operation. Then $2$ can't have an inverse because $2*b=2b^2$ is even, and can't ever be 1.
Comment: What you have in your post is what might be called "scratch work" for the final answer. All that you need to show or even should show in almost all cases (notable exceptions: an expository article, test, or textbook) is the example that proves your point. You absolutely should do scratch work and write a "rough draft" of the solution, which can include your train of thought. Your "final draft," however, should only prove what needs to be shown as clearly and concisely as possible. In this way, a math proof is just like an essay.
Answer: Yes, you're correct. Well done!
Let $a=b=1, c=2$. That would complete things.
It would be a better proof, though, in my opinion, if you put sentences or at least punctuation marks between the equations. (This is just better form.)
Comment: I am never sure about punctuation between equations. I was once told (by someone I respect greatly, and who cares deeply about these things!) that putting implies arrows ($\Rightarrow$) with each equation/line looks amateurish. There is also the debate as to whether one should end such a sequence of equations with a full stop (I feel that it is ambiguous here as the colon ends the sentence, while "This is what I have," would require a full stop in the last line...).
Comment: Perfect! I wasn't sure if it was necessary but I should use a counterexample to solidify the proof. I usually do include things like that to strengthen my argument but wasn't sure if it was unnecessary information. In response to @user1729, In this case as a conclusion I wrote out "Shown above, $(m*n)*o \neq m*(n*o)$." and used punctuation there, but didn't when I was showing the centered work I posted here.
Comment: An introductory description and a conclusive statement at the end would be nice in a formal proof, but the actual content seems perfectly fine as is.


Modify array of interface{} golang

Question: This type assertion, def-referencing has been driving me crazy.  So I have a nested structure of Key string / Value interface{} pairs.  Stored in the Value is an []interface which I want to modify each of the values.  Below is an example of creating an array of Bar and passing it into the ModifyAndPrint function which should modify the top level structure.  The problem that I come accross is as written it doesn't actually modify the contents of z, and I can't do a q := z.([]interface{})[i].(Bar) or & thereof.
Is there a way to do this? If so, what combination did I miss?
package main

import "fmt"

type Bar struct {
   Name string
   Value int
}

func ModifyAndPrint(z interface{}){
    fmt.Printf("z before: %v\n", z)
    for i, _ := range(z.([]interface{})) {
        q := z.([]interface{})[i]
        b := (q).(Bar)
        b.Value = 42
        fmt.Printf("Changed to: %v\n", b)
    }
    fmt.Printf("z after: %v\n", z)
}

func main() {
    bars := make([]interface{}, 2)
    bars[0] = Bar{"a",1}
    bars[1] = Bar{"b",2}

    ModifyAndPrint(bars)
}

https://play.golang.org/p/vh4QXS51tq
Comment: http://stackoverflow.com/questions/15945030/change-values-while-iterating-in-golang
Comment: I'm confused by that link.  It seems like it says to use indexing, which I am doing.
Answer: The program is modifying a copy of the value in the interface{}. One way to achieve your goal is to assign the modified value back to the slice:
for i, _ := range(z.([]interface{})) {
    q := z.([]interface{})[i]
    b := (q).(Bar)
    b.Value = 42
    z.([]interface{})[i] = b
    fmt.Printf("Changed to: %v\n", b)
}

playground example
Comment: That works, but is there a better way that doesn't involve creating a modified element and assigning back?  Can I just work with the original value?

Modify array of interface{} golang


Get all AD users not in parent group

Question: I have a group that I use named staff.  It is a parent of a few nested groups.  I need to audit the group to list the users who aren't a part of that group or any nested child groups within it.  I have found scripts that will give me the users who aren't part of the Staff group, but it doesn't include any of the child groups so a user could be part of the child group but still be listed as not being in the parent group.  I don't want to have to script that for each child group of the parent.
Is there any way to list all accounts that aren't part of a group but also all of it's children?
Comment: Of course there is a way. By modifying the script.
Get the list of all child groups and select users not in those groups
Answer: You can run a single LDAP query like that by using what it called the LDAP_MATCHING_RULE_IN_CHAIN operator.
The numeric OID for this operator is 1.2.840.1135188.8.131.521. You request this type of option in the LDAP search by placing the numeric OID between the attribute and the value you are searching for (attribute:OID:=DN). You can run LDAP queries with the PowerShell cmdLet like this:
get-adobject -ldapfilter "(&(objectcategory=person)(objectclass=user)(!memberof:1.2.840.1135184.108.40.2061:=CN=some,CN=group,DC=yourco,DC=com))"

This query also uses the not (!) operator as you are looking for users who are not a nested member of the group. You can also run LDAP queries through ADUC/DSA by selecting "Custom Search" and the "Advanced" tab.
Two MS articles that cover this and some other details on LDAP search syntax that makes this possible:

https://support.microsoft.com/en-us/help/914828/a-hotfix-is-available-that-improves-the-performance-of-programs-that-q
https://msdn.microsoft.com/en-us/library/aa746475(v=vs.85).aspx
Comment: This is perfect.  Thanks for the info about the OID, and the links as well.  Super helpful!

Get all AD users not in parent group


fair distribution of table tennis players in roster

Question: Say I have 18 players who have been ranked in order of ability 1-18. I need to make up 6 teams each with 3 players. How do I choose the members of each team such that based on the ranking of the players there has been a fair distribution so that the teams are balanced.
Answer: One way would be to ensure the sum of the rankings of players in each team are the same.
Let's say team A has players 1,2,3,16,17 and 18. Team B has 4,5,6,13,14 and 15.
You'd expect 16,17 and 18 to lose all of their matches against Team A, meaning 18 wins for Team B in a round robin. However, 1,2,3 would win all their matches, meaning 18 wins for Team A in a round robin. In 36 matches, the teams would be even. Team C taking players 7 through 12 would also win 18 matches against either team, and lose 18 against either.
This gets a little more complicated if you're not playing a round robin, however.
If each team player plays only one match, you'll want one from 1,2,3 on each team and one from 4,5,6 on each team, etc. If Team A had the top player from 1-3, you'd want Team B to have the top player from 4-6 and Team C to have the top player from 7-9, etc. You'd also want to have each team have only one second best player from each of these subdivisions of the rankings, and each to take one third best from each of these subdivisions.
Note that if you did this, then again you'd find that the sum of the rankings of each team is equal, at 57.


Increasing number on button click till X, then start over again

Question: I have to do button that starts from zero and if you click it, it increases by one. After 3 it start over from zero.
Here is the code I wrote
html:
<button id='counter-button'>0</button>

Dart:
import 'dart:html';

main() {
  var button = querySelector('#counter-button');
  button.onClick.listen(increase);
}

increase(e){
  var button = querySelector('#counter-button');
  var value = int.parse(button.text);
  while(true){
    value = value + 1;
    button.text = '$value';
    if(value == 4){
      value = 0;
    }
    continue;
  }
}

What I am doing wrong? I think I should use while loop but something ain't right.
Comment: You should not use any loop to solve this problem.
Comment: Oh yeah, I forget that the main function calls the increase function every time the button is clicked. I got it working, thanks.
Answer: You may go as simple as that:

const incrementTo3 = ({target}) => {
  const currentCounter = +target.textContent
  target.textContent = (currentCounter+1)%4
}
<button onclick=incrementTo3(event)>0</button>
Answer: Unnecessary while loop:
increase(e){
  var button = querySelector('#counter-button');
  var value = int.parse(button.text);
  value = value + 1;
  if (value == 4)
    value = 0;
  button.text = '$value';
}

Answer: increase(e){
  var button = querySelector('#counter-button');
  var value = int.parse(button.text);
  if (value  < 3){
 button.text = value ++;
return;
}
button.text = 0
}

Answer: What output are you getting at the moment?
I'm not super familiar with Dart-specific functions, but follow the logic below and it should work:
increase(e){

      //1. grab button object
      var button = querySelector('#counter-button');

      //2. grab value, check it's actually an integer by logging it
      var value = int.parse(button.text);

      //3. if it's already 3, make it zero, otherwise increment
      value = (value == 3) ? 0 : (value + 1);

      //4. set value back in
      button.text = '$value';
    }

On step three above, it's basically another way of writing this:
if (value == 3){
    value = 0;
} else {
    value++; //or value = (value + 1)
}

Answer: increase(e){
  var button = querySelector('#counter-button');
  var value = int.parse(button.text);
  value == 4 ? value = 0 : value+1;
  button.text = '$value';
}

Comment: The mistake you are actually doing is appending the value to the button before checking it is 3. If you can check and then append the value to the button it will solve your issue.


Using Selenium to run webdriver (Chrome) and setting up proxy to log browsed URL

Question: I'm new to automation. I wanted to know how we can use selenium webdriver and python together, so that when the webdriver uses Chrome to launch the website, a proxy gets attached to the chrome webdriver to monitor user actions.
Proxy can be a ran using 'jar'or an 'exe'. Please suggest!
Answer: <code>from selenium import webdriver
PROXY = "220.127.116.11:3128" # IP:PORT or HOST:PORT
chrome_options = webdriver.ChromeOptions()
 chrome_options.add_argument('--proxy-server=%s' % PROXY)
chrome = webdriver.Chrome(chrome_options=chrome_options)
 chrome.get("http://whatismyipaddress.com")
</code>
This is a way how to attach proxy to a browser, I am personally using a for loop from my txt file where i have written all proxies .. ( code doesnt look good cuz typing it from a phone ) but thats the way how to acctualy do it ^.^ , another thing as I can see you are completly new in programming, because Jar is for Java files , Exe is executable file and python is using .py at the end of its sctipts ... and last thing about monitoring ... well selenium is a browser similar to chrome, but its controlled by python ... you cant monitor whats going on with python much ( alike a beginner ) but the esiest way would be that you just make a script that will make a screenshot every few seconds or basicly look for a tutorial how to make a keylogger ^.^ I hope i helped you ^.^ if no ask me questions in a comment section, if I did please lick that check icon and ^ button
- thanks you ^.^
Comment: Great! It works.. all credit to you. One last thing - once the browser has loaded the web page, when I click on some link in the loaded web page, it takes me to different URL. How can I capture that URL using webdriver?
Comment: Well there should be a function thsts getting your current url ... i think its webdriver.current_url ... but not sure ... when i come home i can loom forit if you will still struggle ... but try something like that current_url or google selenium get current url
Comment: I will try that! Cheers!


Instascan QR Code scanner 'scan' listener won't update Angular 5 component view

Question: I've implemented Instascan (https://github.com/schmich/instascan) to allow users to read QR Codes from within my Angular 5 app.
I have to trigger some actions after a successful scan and update my component's view accordingly.
I'm using the following code inside my component to detect my cameras and start scanning:
cameras: Array<any> = []
selectedCamera: any
scanner: any
content: string

ngOnInit () {
    let vm = this
    Instascan.Camera.getCameras().then(function (cameras) {
      if (cameras.length > 0) {
        vm.cameras.push(...cameras)
      } else {
        console.error('No cameras found.')
      }
    }).catch(function (e) {
      console.error(e)
    })
  }

startScan () {
    let vm = this
    this.scanner = new Instascan.Scanner({
      video: this.videoContainer.nativeElement,
      backgroundScan: false,
      mirror: false
    })
    this.scanner.addListener('scan', function (content) {
      vm.content = content
    })
    this.selectedCamera = this.cameras[0]
    this.scanner.start(this.selectedCamera)
  }

And in my template I have an element that exists only if 'content' exists, and on click emit the scanned content to the parent component through an EventEmitter:

          PROCEED

The problem is that in 'scan' event callback the changes in 'content' seems to don't be applied to my view, and my 'PROCEED' button don't become visible. An even stranger behavior happens: after I click anywhere in the screen, those changes are applied to my view.
I've also tried using ChangeDetectorRef.detectChanges() method inside the callback and binding 'this' into the callback, but both are not working.
How can I overcome this issue?
Thanks!
Answer: I've managed to solve this problem by using NgZone like this:
import { NgZone } from '@angular/core'

constructor (
    private ngZone: NgZone
  ) {}

startScan () {
    this.scanner = new Instascan.Scanner({
      video: this.videoContainer.nativeElement,
      backgroundScan: false,
      mirror: false
    })
    this.scanner.addListener('scan', function (content) {
      this.ngZone.run(() => {
        this.content = content
      })
    }.bind(this))
    this.selectedCamera = this.cameras[0]
    this.scanner.start(this.selectedCamera)
  }

I don't know if this is the best solution, and actually I don't know how NgZone usage affects the application performance/state at all.
If someone know a better solution, it will be welcome!
Thanks!


Proof that $\int\delta(t)\cos(t)dt = 1$ using integration by parts

Question: According to the properties of the Dirac Delta function $\int\delta(t)\cos(t)dt = \cos(0) = 1$.
I tried proving this using integration by parts but got stumped:
$
\require{cancel}
\int_{-\infty}^{\infty}\delta(t)\cos(t)dt = H(t)\cos(t)\big|_{-\infty}^{\infty} + \int_{-\infty}^{\infty}H(t)\sin(t)dt = \cancel{0 \cdot \cos(t)|_{-\infty}^{0}} + 1 \cdot \cos(t)\big|_{0}^{\infty} + \cancel{ \int_{-\infty}^{0}0 \cdot \sin(t)dt } + \int_{0}^{\infty}1 \cdot \sin(t)dt = \cos(t)\big|_0^{\infty} - \cos(t)|_0^{\infty} = 0
$
$H$ is the step function.
Comment: What makes you think that such an integration by parts is valid?
Comment: Note, when you see $\cos(t)\vert_0^\infty$ you are in trouble.  It diverges by oscillation.  Therefore, this calculation is invalid.
Answer: The integral of $H(t) \sin(t)$ over an infinite domain is obviously not convergent; it oscillates between $-1$ and $1$ as the upper limit grows.
Instead, you need to e.g. choose some $a>0$ and compute
$$
\begin{align}
\int_{-a}^a \delta(t) \cos(t) \ {\rm d}t
&= \left[H(t) \cos(t) \right]_{-a}^a + \int_{-a}^a H(t) \sin(t) \ {\rm d}t
\\ &= \cos(a) + \int_0^a \sin(t) \ {\rm d}t
\\ &= \cos(a) - \left[\cos(a) - \cos(0)\right]
\\ &= 1
\end{align}
$$
Now you can take the limit $a \to \infty$ safely. (The oscillating $\cos(a)$ terms have cancelled.)

Edit: In some sense your calculation would still have "given you the right answer" if you had been slightly more careful with your evaluation of $\left[H(t) \cos(t) \right]_{-\infty}^\infty$. For some reason you split it up into $[0,\infty)$ and $(-\infty,0)$ and then in one of these you chose $H(0)=0$ and $H(0)=1$. This isn't at all consistent! The more consistent thing would be to directly evaluate $H(\infty) = 1$ and $H(-\infty) = 0$ and write "$\cos(\infty)$"... but obviously this now makes clear why you should be careful with $\infty$s! Had you ploughed ahead and written $\cos(\infty) - \left[\cos(t) \right]_0^\infty = \cos(0) = 1$ you would have at least got the right answer however. Then you might realize that you should go back and replace $\infty \to a$ throughout to be more precise.


Utilizar o Jquery Validate em conjunto com Form Wizard

Question: Estou montando um formulário passo a passo.
Fiz um teste um o Validate no campo de e-mail e, a verificação do e-mail deu certo, porém, o Validate não barra ir para o próximo passo, caso o campo esteja em branco.
Segue o que fiz até agora.

<!DOCTYPE html>

<meta charset="utf-8">
<title>Steps</title>

<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">

   <form class="" name="form_contato" id="form_contato" method="post" action="">

                                First Name
                                <input type="text" class="form-control" id="exampleInputEmail1_x1" name="exampleInputEmail1_x1" placeholder="First Name">

                                Last Name
                                <input type="text" class="form-control" id="exampleInputEmail1_x2" placeholder="Last Name">

                                Email address (TESTE)
                                <input type="email" class="form-control" id="email" name="email" placeholder="Email">

                                Confirm Email address
                                <input type="email" class="form-control" id="exampleInputEmail1_x3" placeholder="Email">

                                Mobile Number
                                <input type="text" class="form-control" id="exampleInputEmail1_x4" placeholder="Email">

                            Email address

                                        <input type="email" class="form-control" id="exampleInputEmail1_x5" placeholder="Email">

                                        <input type="email" class="form-control" id="exampleInputEmail1_x6" placeholder="Email">

<button type="button" class="btn btn-primary next-step">Save and continue</button>

<button type="button" class="btn btn-default prev-step">Previous</button>

<button type="button" class="btn btn-primary next-step">Save and continue</button>

Basic Details

<stong>Date of birth</stong>

                                            <select name="visa_status" id="visa_status" class="dropselectsec1">
                                                <option value="">Date</option>
                                                <option value="2">1</option>
                                                <option value="1">2</option>
                                                <option value="4">3</option>
                                                <option value="5">4</option>
                                                <option value="6">5</option>
                                                <option value="3">6</option>
                                                <option value="7">7</option>
                                                <option value="8">8</option>
                                                <option value="9">9</option>
                                            </select>

                                            <select name="visa_status" id="visa_status" class="dropselectsec1">
                                                <option value="">Month</option>
                                                <option value="2">Jan</option>
                                                <option value="1">Feb</option>
                                                <option value="4">Mar</option>
                                                <option value="5">Apr</option>
                                                <option value="6">May</option>
                                                <option value="3">June</option>
                                                <option value="7">July</option>
                                                <option value="8">Aug</option>
                                                <option value="9">Sept</option>
                                            </select>

                                            <select name="visa_status" id="visa_status" class="dropselectsec1">
                                                <option value="">Year</option>
                                                <option value="2">1990</option>
                                                <option value="1">1991</option>
                                                <option value="4">1992</option>
                                                <option value="5">1993</option>
                                                <option value="6">1994</option>
                                                <option value="3">1995</option>
                                                <option value="7">1996</option>
                                                <option value="8">1997</option>
                                                <option value="9">1998</option>
                                            </select>

<stong>Marital Status</stong>

                                      <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> Single

                                      <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> Married

<stong>Highest Education</stong>

                                    <select name="highest_qualification" id="highest_qualification" class="dropselectsec">
                                        <option value=""> Select Highest Education</option>
                                        <option value="1">Ph.D</option>
                                        <option value="2">Masters Degree</option>
                                        <option value="3">PG Diploma</option>
                                        <option value="4">Bachelors Degree</option>
                                        <option value="5">Diploma</option>
                                        <option value="6">Intermediate / (10+2)</option>
                                        <option value="7">Secondary</option>
                                        <option value="8">Others</option>
                                    </select>

<stong>Specialization</stong>

                                    <input type="text" name="specialization" id="specialization" placeholder="Specialization" class="dropselectsec" autocomplete="off">

<stong>Year of Passed Out</stong>

                                    <select name="year_of_passedout" id="year_of_passedout" class="birthdrop">
                                        <option value="">Year</option>
                                        <option value="1980">1980</option>
                                        <option value="1981">1981</option>
                                        <option value="1982">1982</option>
                                        <option value="1983">1983</option>
                                        <option value="1984">1984</option>
                                        <option value="1985">1985</option>
                                        <option value="1986">1986</option>
                                        <option value="1987">1987</option>
                                        <option value="1988">1988</option>
                                        <option value="1989">1989</option>
                                        <option value="1990">1990</option>
                                        <option value="1991">1991</option>
                                        <option value="1992">1992</option>
                                        <option value="1993">1993</option>
                                        <option value="1994">1994</option>
                                        <option value="1995">1995</option>
                                        <option value="1996">1996</option>
                                        <option value="1997">1997</option>
                                        <option value="1998">1998</option>
                                        <option value="1999">1999</option>
                                        <option value="2000">2000</option>
                                        <option value="2001">2001</option>
                                        <option value="2002">2002</option>
                                        <option value="2003">2003</option>
                                        <option value="2004">2004</option>
                                        <option value="2005">2005</option>
                                        <option value="2006">2006</option>
                                        <option value="2007">2007</option>
                                        <option value="2008">2008</option>
                                        <option value="2009">2009</option>
                                        <option value="2010">2010</option>
                                        <option value="2011">2011</option>
                                        <option value="2012">2012</option>
                                        <option value="2013">2013</option>
                                        <option value="2014">2014</option>
                                        <option value="2015">2015</option>
                                    </select>

<stong>Total Experience</stong>

                                            <select name="visa_status" id="visa_status" class="dropselectsec1">
                                                <option value="">Month</option>
                                                <option value="2">Jan</option>
                                                <option value="1">Feb</option>
                                                <option value="4">Mar</option>
                                                <option value="5">Apr</option>
                                                <option value="6">May</option>
                                                <option value="3">June</option>
                                                <option value="7">July</option>
                                                <option value="8">Aug</option>
                                                <option value="9">Sept</option>
                                            </select>

<button type="button" class="btn btn-default prev-step">Previous</button>

<button type="button" class="btn btn-default next-step">Skip</button>

<button type="button" class="btn btn-primary btn-info-full next-step">Save and continue</button>

Completed

            </form>

Answer: É preciso verificar no .on("click"... se o estado do $("#form_contato") é verdadeiro para poder continuar.
Você verifica isso com $("#form_contato").valid():
if($("#form_contato").valid()){
    // o formulário foi validado
}

Logo, você deve fazer esta verificação escutador do botão que prossegue para o próximo passo:
$(".next-step").click(function (e) {
   if($("#form_contato").valid()){
      var $active = $('.wizard .nav-tabs li.active');
      $active.next().removeClass('disabled');
      nextTab($active);
   }
});

É preciso também, informar nos métodos do validador as ids dos campos. No seu caso, a id do campo "First name" é exampleInputEmail1_x1, logo:
$("#form_contato").validate({
   rules: {
      exampleInputEmail1_x1: {
         required: true,
         email: true
      }
   },
   messages: {
      exampleInputEmail1_x1: {
         required: "Informe o e-mail",
         email: "Informe um e-mail válido"
      }
   }
});

Veja funcionando:

$(document).ready(function () {
   //Initialize tooltips
   $('.nav-tabs > li a[title]').tooltip();

   //Wizard
   $('a[data-toggle="tab"]').on('show.bs.tab', function (e) {

      var $target = $(e.target);

      if ($target.parent().hasClass('disabled')) {
         return false;
      }
   });

   $(".next-step").click(function (e) {
      if($("#form_contato").valid()){
         var $active = $('.wizard .nav-tabs li.active');
         $active.next().removeClass('disabled');
         nextTab($active);
      }
   });

   $(".prev-step").click(function (e) {
      var $active = $('.wizard .nav-tabs li.active');
      prevTab($active);
   });
});

function nextTab(elem) {
   $(elem).next().find('a[data-toggle="tab"]').click();
}

function prevTab(elem) {
   $(elem).prev().find('a[data-toggle="tab"]').click();
}

$().ready(function() {
   $("#form_contato").validate({
      rules: {
         exampleInputEmail1_x1: {
            required: true,
            email: true
         }
      },
      messages: {
         exampleInputEmail1_x1: {
            required: "Informe o e-mail",
            email: "Informe um e-mail válido"
         }
      }
   });
});
.wizard {
margin: 20px auto;
background: #fff;
}

.wizard .nav-tabs {
    position: relative;
    margin: 40px auto;
    margin-bottom: 0;
    border-bottom-color: #e0e0e0;
}

.wizard > div.wizard-inner {
    position: relative;
}

.connecting-line {
height: 2px;
background: #e0e0e0;
position: absolute;
width: 80%;
margin: 0 auto;
left: 0;
right: 0;
top: 50%;
z-index: 1;
}

.wizard .nav-tabs > li.active > a, .wizard .nav-tabs > li.active > a:hover, .wizard .nav-tabs > li.active > a:focus {
color: #555555;
cursor: default;
border: 0;
border-bottom-color: transparent;
}

span.round-tab {
width: 70px;
height: 70px;
line-height: 70px;
display: inline-block;
border-radius: 100px;
background: #fff;
border: 2px solid #e0e0e0;
z-index: 2;
position: absolute;
left: 0;
text-align: center;
font-size: 25px;
}
span.round-tab i{
color:#555555;
}
.wizard li.active span.round-tab {
background: #fff;
border: 2px solid #5bc0de;

}
.wizard li.active span.round-tab i{
color: #5bc0de;
}

span.round-tab:hover {
color: #333;
border: 2px solid #333;
}

.wizard .nav-tabs > li {
width: 25%;
}

.wizard li:after {
content: " ";
position: absolute;
left: 46%;
opacity: 0;
margin: 0 auto;
bottom: 0px;
border: 5px solid transparent;
border-bottom-color: #5bc0de;
transition: 0.1s ease-in-out;
}

.wizard li.active:after {
content: " ";
position: absolute;
left: 46%;
opacity: 1;
margin: 0 auto;
bottom: 0px;
border: 10px solid transparent;
border-bottom-color: #5bc0de;
}

.wizard .nav-tabs > li a {
width: 70px;
height: 70px;
margin: 20px auto;
border-radius: 100%;
padding: 0;
}

.wizard .nav-tabs > li a:hover {
    background: transparent;
}

.wizard .tab-pane {
position: relative;
padding-top: 50px;
}

.wizard h3 {
margin-top: 0;
}
.step1 .row {
margin-bottom:10px;
}
.step_21 {
border :1px solid #eee;
border-radius:5px;
padding:10px;
}
.step33 {
border:1px solid #ccc;
border-radius:5px;
padding-left:10px;
margin-bottom:10px;
}
.dropselectsec {
width: 68%;
padding: 6px 5px;
border: 1px solid #ccc;
border-radius: 3px;
color: #333;
margin-left: 10px;
outline: none;
font-weight: normal;
}
.dropselectsec1 {
width: 74%;
padding: 6px 5px;
border: 1px solid #ccc;
border-radius: 3px;
color: #333;
margin-left: 10px;
outline: none;
font-weight: normal;
}
.mar_ned {
margin-bottom:10px;
}
.wdth {
width:25%;
}
.birthdrop {
padding: 6px 5px;
border: 1px solid #ccc;
border-radius: 3px;
color: #333;
margin-left: 10px;
width: 16%;
outline: 0;
font-weight: normal;
}

/* according menu */
#accordion-container {
font-size:13px
}
.accordion-header {
font-size:13px;
background:#ebebeb;
margin:5px 0 0;
padding:7px 20px;
cursor:pointer;
color:#fff;
font-weight:400;
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px
}
.unselect_img{
width:18px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
.active-header {
-moz-border-radius:5px 5px 0 0;
-webkit-border-radius:5px 5px 0 0;
border-radius:5px 5px 0 0;
background:#F53B27;
}
.active-header:after {
content:"\f068";
font-family:'FontAwesome';
float:right;
margin:5px;
font-weight:400
}
.inactive-header {
background:#333;
}
.inactive-header:after {
content:"\f067";
font-family:'FontAwesome';
float:right;
margin:4px 5px;
font-weight:400
}
.accordion-content {
display:none;
padding:20px;
background:#fff;
border:1px solid #ccc;
border-top:0;
-moz-border-radius:0 0 5px 5px;
-webkit-border-radius:0 0 5px 5px;
border-radius:0 0 5px 5px
}
.accordion-content a{
text-decoration:none;
color:#333;
}
.accordion-content td{
border-bottom:1px solid #dcdcdc;
}

@media( max-width : 585px ) {

.wizard {
    width: 90%;
    height: auto !important;
}

span.round-tab {
    font-size: 16px;
    width: 50px;
    height: 50px;
    line-height: 50px;
}

.wizard .nav-tabs > li a {
    width: 50px;
    height: 50px;
    line-height: 50px;
}

.wizard li.active:after {
    content: " ";
    position: absolute;
    left: 35%;
}
}

<link type="text/css" rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">

            <form class="" name="form_contato" id="form_contato" method="post" action="">

                              First Name
                              <input type="text" class="form-control" id="exampleInputEmail1_x1" name="exampleInputEmail1_x1" placeholder="First Name">

                              Last Name
                              <input type="text" class="form-control" id="exampleInputEmail1_x2" placeholder="Last Name">

                              Email address (TESTE)
                              <input type="email" class="form-control" id="email" name="email" placeholder="Email">

                              Confirm Email address
                              <input type="email" class="form-control" id="exampleInputEmail1_x3" placeholder="Email">

                              Mobile Number
                              <input type="text" class="form-control" id="exampleInputEmail1_x4" placeholder="Email">

                              Email address

                                 <input type="email" class="form-control" id="exampleInputEmail1_x5" placeholder="Email">

                                 <input type="email" class="form-control" id="exampleInputEmail1_x6" placeholder="Email">

<button type="button" class="btn btn-primary next-step">Save and continue</button>

<button type="button" class="btn btn-default prev-step">Previous</button>

<button type="button" class="btn btn-primary next-step">Save and continue</button>

Basic Details

<stong>Date of birth</stong>

                              <select name="visa_status" id="visa_status" class="dropselectsec1">
                                 <option value="">Date</option>
                                 <option value="2">1</option>
                                 <option value="1">2</option>
                                 <option value="4">3</option>
                                 <option value="5">4</option>
                                 <option value="6">5</option>
                                 <option value="3">6</option>
                                 <option value="7">7</option>
                                 <option value="8">8</option>
                                 <option value="9">9</option>
                              </select>

                              <select name="visa_status" id="visa_status" class="dropselectsec1">
                                 <option value="">Month</option>
                                 <option value="2">Jan</option>
                                 <option value="1">Feb</option>
                                 <option value="4">Mar</option>
                                 <option value="5">Apr</option>
                                 <option value="6">May</option>
                                 <option value="3">June</option>
                                 <option value="7">July</option>
                                 <option value="8">Aug</option>
                                 <option value="9">Sept</option>
                              </select>

                              <select name="visa_status" id="visa_status" class="dropselectsec1">
                                 <option value="">Year</option>
                                 <option value="2">1990</option>
                                 <option value="1">1991</option>
                                 <option value="4">1992</option>
                                 <option value="5">1993</option>
                                 <option value="6">1994</option>
                                 <option value="3">1995</option>
                                 <option value="7">1996</option>
                                 <option value="8">1997</option>
                                 <option value="9">1998</option>
                              </select>

<stong>Marital Status</stong>

                           <input type="radio" name="inlineRadioOptions" id="inlineRadio2" value="option2"> Single

                           <input type="radio" name="inlineRadioOptions" id="inlineRadio3" value="option3"> Married

<stong>Highest Education</stong>

                        <select name="highest_qualification" id="highest_qualification" class="dropselectsec">
                           <option value=""> Select Highest Education</option>
                           <option value="1">Ph.D</option>
                           <option value="2">Masters Degree</option>
                           <option value="3">PG Diploma</option>
                           <option value="4">Bachelors Degree</option>
                           <option value="5">Diploma</option>
                           <option value="6">Intermediate / (10+2)</option>
                           <option value="7">Secondary</option>
                           <option value="8">Others</option>
                        </select>

<stong>Specialization</stong>

                        <input type="text" name="specialization" id="specialization" placeholder="Specialization" class="dropselectsec" autocomplete="off">

<stong>Year of Passed Out</stong>

                        <select name="year_of_passedout" id="year_of_passedout" class="birthdrop">
                           <option value="">Year</option>
                           <option value="1980">1980</option>
                           <option value="1981">1981</option>
                           <option value="1982">1982</option>
                           <option value="1983">1983</option>
                           <option value="1984">1984</option>
                           <option value="1985">1985</option>
                           <option value="1986">1986</option>
                           <option value="1987">1987</option>
                           <option value="1988">1988</option>
                           <option value="1989">1989</option>
                           <option value="1990">1990</option>
                           <option value="1991">1991</option>
                           <option value="1992">1992</option>
                           <option value="1993">1993</option>
                           <option value="1994">1994</option>
                           <option value="1995">1995</option>
                           <option value="1996">1996</option>
                           <option value="1997">1997</option>
                           <option value="1998">1998</option>
                           <option value="1999">1999</option>
                           <option value="2000">2000</option>
                           <option value="2001">2001</option>
                           <option value="2002">2002</option>
                           <option value="2003">2003</option>
                           <option value="2004">2004</option>
                           <option value="2005">2005</option>
                           <option value="2006">2006</option>
                           <option value="2007">2007</option>
                           <option value="2008">2008</option>
                           <option value="2009">2009</option>
                           <option value="2010">2010</option>
                           <option value="2011">2011</option>
                           <option value="2012">2012</option>
                           <option value="2013">2013</option>
                           <option value="2014">2014</option>
                           <option value="2015">2015</option>
                        </select>

<stong>Total Experience</stong>

                              <select name="visa_status" id="visa_status" class="dropselectsec1">
                                 <option value="">Month</option>
                                 <option value="2">Jan</option>
                                 <option value="1">Feb</option>
                                 <option value="4">Mar</option>
                                 <option value="5">Apr</option>
                                 <option value="6">May</option>
                                 <option value="3">June</option>
                                 <option value="7">July</option>
                                 <option value="8">Aug</option>
                                 <option value="9">Sept</option>
                              </select>

<button type="button" class="btn btn-default prev-step">Previous</button>

<button type="button" class="btn btn-default next-step">Skip</button>

<button type="button" class="btn btn-primary btn-info-full next-step">Save and continue</button>

Completed

            </form>

Comment: Espetacular! Entendi o que houve. Muito obrigado!
Comment: Esqueci de um pequeno detalhe: quando chega no fim dos passos, é possível enviar os dados formulário para o PHP? No Smart Wizard 3, que já usei mas não gostei muito, ele pega um input hidden () e joga para o PHP (form is sumbitted"; } ?>). Seria possível fazer algo similar?
Comment: @RogérioPancini Coloque um botão, tipo "Enviar", com type="submit" no último passo, e coloque a página php no action="" do form.


Under which conditions maximizing a ratio of functions is equivalent to minimizing its reciprocal?

Question: Assume two non-linear functions, $f(x)$, $g(x)$ respectively, both positive and monotone non-decreasing, $f(x)$ is concave, $g(x)$ is convex.
I am trying to maximize their ratio, $\frac{f(x)}{g(x)}$, subject to some inequality constraints. I do not have these functions in closed form but I noticed experimentally that minimizing their reciprocal ratio gives me the same solution as maximizing their ratio. I would like to understand better why this happen. Are there any known conditions for this result?
Answer: One sufficient condition: the constraints don't bind and the first ratio is strictly concave and second strictly convex (you can twice derivate these ratios to characterize these). Moreover, the $f$ and $g$ are twice differentiable. Then both the unique maximum of $\frac{f(x)}{g(x)}$ and unique minimum of $\frac{g(x)}{f(x)}$ is given by the first order condition
\begin{equation}
f_x(x)g(x)=g_x(x)f(x).
\end{equation}


Show that $\dim H^0(\mathbb{P}^n, \mathcal{O}_{\mathbb{P}^n}(m)) = {n + m \choose n}$ if $m \geq 0$, and $0$ otherwise.

Question: Show that $\dim H^0(\mathbb{P}^n, \mathcal{O}_{\mathbb{P}^n}(m)) = {n + m \choose n}$ if $m \geq 0$, and $0$ if $m < 0$. This statement came up in an algebraic geometry text with no explanation provided, and I'm trying to understand why it's true.
Thoughts so far:
Since $H^0(\mathbb{P}^n, \mathcal{O}_{\mathbb{P}^n}(m))$ is the vector space of regular sections of $\mathcal{O}_{\mathbb{P}^n}(m)$ over $\mathbb{P}^n$, we can try to find a basis. Since the regular sections are the degree $m$ polynomials in $x_0, \dots, x_n$, it seems like the collection of degree $m$ monomials in $x_0, \dots, x_n$ should work. But I don't see how there are ${n + m \choose n}$ of these. Is it just a basic counting argument that I'm struggling with?
On a side note, I think I understand what global sections of $\mathcal{O}_{\mathbb{P}^n}(m)$ look like, but how can we describe the regular sections over a distinguished open set $D(f)$? Is it something like degree $m$ polynomials with denominator $f$?
Answer: I think it is indeed just the basic counting argument you are lacking. To see that there are $\binom{n+m}{n}$ monomials in $x_0,\ldots, x_n$ of degree $m$, for me it is helpful to think about the equivalent question: how many ways can you divide $m$ unlabeled balls among $n+1$ labelled bins (corresponding to the variables $x_0,\ldots, x_n$)? Any such division can be represented (uniquely) by a pictorial representation of balls 'O' divided by lines '|'. For example, the picture
OOO|O||OO|O
represents a way of dividing up 7 balls into 5 labelled bins. The first bin has 3 balls, the second has 1, the third is empty, the fourth has 2, and the fifth bin has 1 ball. In terms of monomials, we might think of this as the monomial $x_0^3x_1x_3^2x_4$.
This establishes a bijection between possible divisions (i.e., monomials) and strings of length $n+m$ consisting of $m$ balls 'O' and $n$ lines '|'. Any such string is determined uniquely by the choice of position of the lines, i.e., in choosing a set of $n$ positions from a possible $n+m$ positions. Thus the total number of monomials is $\binom{n+m}{n}$.
I hope this answer was clear!
Comment: Yes, it's coming back to me now. What a great answer! Can you offer any enlightenment with respect to the second question?
Comment: @user99182: Sorry, I'm not an algebraic geometer, so I'm not comfortable answering that. But I will say your guess seems reasonable to me!
Answer: About your side note question:
If  $f\in H^0(\mathbb{P}^n, \mathcal{O}_{\mathbb{P}^n}(m))$ is a homogeneous polynomial of degree $m$, then the open subset $D(f)\subset \mathbb{P}^n$ is an affine variety (this can be seen with the Veronese embedding of degree $m$).
The restriction of $ \mathcal{O}_{\mathbb{P}^n}(m))$  to $D(f)$ is the trivial line bundle.
The $k$-algebra $ H^0(D(f), \mathcal{O}_{\mathbb{P}^n}(m))=H^0(D(f), \mathcal{O}_{\mathbb{P}^n})$ is then infinite-dimensional, and so  also is the space of sections of any line bundle on $D(f)$.
Actually any line bundle on $D(f)$ is the restriction of some line bundle on $\mathbb{P}^n$ because of the exact sequence $$\mathbb Z\to \text {Cl}(\mathbb{P}^n)\to \text {Cl}(D(f))\to 0$$ (Hartshorne II, Prop. 6.5 (c))
The simplest example is to take $f=x_0^m\in H^0(\mathbb{P}^n, \mathcal{O}_{\mathbb{P}^n}(m))$, so that $D(f)=\mathbb A^n$ and since all line bundles $L$ on $\mathbb A^n$ are trivial, we have $$H^0(\mathbb{A}^n_k, L)=H^0(\mathbb{A}^n_k, \mathcal O)=k[x_0,\cdots ,x_n] $$