What exactly is circular reasoning?

Question: The way I used to be getting it was that circular reasoning occurs when a proof contains its thesis within its assumptions. Then, everything such a proof "proves" is that this particular statement entails itself; which is trivial since any statement entails itself.
But I witnessed a conversation that made me think I'm not getting this at all.
In short, Bob accused Alice of circular reasoning. But Alice responded in a way that perplexed me:

Of course my proof contains its thesis within its assumptions. Each and every proof must be based on axioms, which are assumptions that are not to be proved. Thus each set of axioms implicitly contains all theses that can be proven from this set of axioms. As we know, each theorem in mathematics and logic is little more than a tautology: so is mine.

Not sure what should I think? On the one hand, Alice's reasoning seems correct. I, at least, can't find any error there. On the other hand, this entails that... Every valid proof must be circular! Which is absurd.
What is a circular proof? And what is wrong with the reasoning above?
Comment: Your understanding, prior to reading about Alice and Bob, is correct.
Comment: "Thus each set of axioms implicite contains all thesis"  That's weaslely but not nesc. false.  However if Alice wishes to take that viewpoint then the job of a proof is to *demonstrate* how her thesis is contained specifically from the axioms.  Bob's complaint, in this viewpoint, isn't that Alice's thesis in contained via the axioms but that her demonstration failed to show how or why it is so contained in a satisfactory manner.
Comment: I agree with @amWhy. I deny that each set of axioms implicitly contain all theorems that can be proven from this set of axioms. To say such a thing would be to confuse truth utterly. Otherwise, we'd have to say that the statement, "$1+1=2$" is the same as $\frac{d}{dx}\,x^2=2x.$ They're not the same thing at all, even though they're both true.
Comment: @PoonLevi: I don't think we're using the word "contain" the same way. Surely any mathematician would agree that any given set of axioms would uniquely determine a set of theorems provable from those axioms. If that's how you're using the term "contain", then I'd agree. But if "contain" means that the meaning of the theorems is contained in the meaning of the axioms, I can't go there. Different statements mean different things, or there'd be no use for language at all and no one could distinguish one true statement from another.
Comment: @AdrianKeister "They're not the same thing at all, even though they're both true."  Although  I agree with you, I feel if you make such a claim, you are behoven to explain *why* you think $1+1=2$ and $\frac d{dx}x^2 =2x$ are different things.  (Because $1+1=2$ is an axiom/definition and the other is a result? According to Alice those are the same.  I disagree with her but I see her point.  Why are you claiming they are different.)  " But if "contain" means that the meaning of the theorems is contained in the meaning of the axioms, I can't go there."  I don't think that is Alice's viewpoint.
Comment: @AdrianKeister I beg to differ. Every mathematical proof is a proof that the axioms entail the theorem. In theory, knowing just the axioms already allows you to derive every possible theorem derivable from these axioms. It does not follow that all theorems are the same thing simply because they are all contained in the same set of axioms. However, to my understanding, accusations of circular reasoning are mostly about non-mathematical claims, since then you don't get to assert arbitrary axioms as true and see what follows.
Comment: @PoonLevi "I beg to differ. Every mathematical proof is a proof that the axioms entail the theorem."  I beg to differ with that.  Really, I would go so far as to say that there does not exist a mathematical proof that the collection of axioms imply the theorem.  How does one move from the collection axioms to the theorem without any rules of inference? "Surely any mathematician would agree that any given set of axioms would uniquely determine a set of theorems provable from those axioms."  If meant literally as a complete staement, Frege would have denied that wholeheartedly.
Comment: Keep in mind that you're taking Alice out of context. I can imagine accusations where something like this quote is accurate; e.g. if Alice gives a valid proof of "If A and B, then C", but then Bob incorrectly tries to invalidate the proof by citing "If C, then B" is also true.
Comment: @fleablood Some rule of inference is needed to deduce that the derivative of x squared is 2x.  I think that every proof I've seen implicitly relies on some rule of replacement ('substitution of equals with equals'... and hence my use of parentheses in infix notation).  No rule of inference is needed to conclude that (1 + 1) = 2.  Alice has, and should have, the freedom to claim them the same, but one might say that the paths to them are not equivalent.  A house two blocks down the road is not the same as a house that you sit in from your perspective, because how you get to each house differs.
Comment: I read somewhere that there are postulates that are true but cannot be proved.  My apologies for being off topic, but not every true statement can be proved from axioms,  Definitions, and UNDEFINED CONCEPTS.  I remember reading about "sense" in a geometry class.   We can eliminate the undefined concept by adding another axiom.
Answer:
Of course my proof contains its thesis within its assumptions. Each and every proof must be based on axioms, which are assumptions that are not to be proved.

Hold it right there, Alice.  These specific axioms are to be accepted without proof but nothing else is.  For anything that is true that is not one of these axioms, the role of proof must be to demonstrate that such a truth can be derived from these axioms and how it would be so derived.

Thus each set of axioms implicite contains all thesis that can be proven from this set of axioms.

Implicit.  But the role of a proof is to make the implicit explicit.  I can claim that Fermat's last theorem is true.  That is a true statement.  But merely claiming it is not the same as a proof.  I can claim the axioms of mathematics imply Fermat's last theorem and that would be true.  But that's still not a proof.  To prove it, I must demonstrate how the axioms imply it.  And in doing so I can not base any of my demonstration implications upon the knowledge that I know it to be true.

As we know, each theorem in mathematics and logics is little more than a tautology:

That's not actually what a tautology is.  But I'll assume you mean a true statement.

so is mine.

No one cares if your statement is true.  We care if you can demonstrate how it is true.  You did not do that.
Comment: To quote Google, a tautology (in logic) is "a statement that is true by necessity or by virtue of its logical form". That describes mathematics in a nutshell.
Comment: "Thus each set of axioms implicite contains all thesis that can be proven from this set of axioms."  No, that's not true.  At least not if rules of inference are not axioms, and axioms are not rules of inference.  Axioms don't imply anything at all without rules of inference.
Comment: @DougSpoonwood "Thus each set of axioms implicite contains all thesis that can be proven from this set of axioms" is a direct quote from Alice.
Comment: @TheoBendit I think google isn't correct about that, or maybe they are using some colloquial definition.  Most people who study formal logic use "tautology" to mean exactly that a statement is true under all possible assignments to the variables.  What "all possible assignments" and "variables" means depends on the logic.  So $a + b = b + a$ is a tautology in quantified arithmetic logic, but not if you are reasoning about strings with $+$ being string concatenation.  $\forall x. P(x) \to P(x)$ is a tautology in First Order Logic, letting $P$ range over all possible relations.
Comment: In my head, $1+1= 2$ is the _definition_ of $2$. Not a theorem, not an axiom. Simply stating that 'whenever I use the squggle "$2$", take that to be shorthand for "$1+1$"'.
Comment: @DougSpoonwood I'd agree with that.  But Alice wouldn't.  Alice would say rules of inference and all potentially inferred statements (even those which haven't yet been inferred) are in the .... whatever it is that Alice is calling th body of math.    This can be one way of looking at it, but it has nothing to do with proofs and *how* we know things are true or not.  I'd say Alice is wrong but,  I can't just say "she's stupid; ignore her"
Comment: @fleablood "Alice would say rules of inference...  are in the .... whatever it is that Alice is calling th body of math"  I don't know why you're saying that Alice would say that.  I don't see anything in what the author wrote which suggests that Alice would say that either.  So, I don't know why you've attributed that to Alice.  I disagree.  It does have something to do with how we know things.  We only know a proof valid because of the use of valid rules of inference.  So, we only know a conclusion correct when such rules have gotten used correctly and the axioms are true.
Comment: Theo: Not really. Let me illustrate. "1=1" is a tautology. "1+1 = 2" is an axiom. "The derivative of x^2 with respect to x is 2x" is a theorem that requires a proof that rests on several definitions and axioms.
Comment: @DanielV (and JKreft) I would argue that mathematics doesn't argue the truth of predicates, only statements. Mathematics can't prove that $a + b = b + a$, but it can prove (for instance) that for all $a, b \in \mathbb{Z}$, $a + b = b + a$, where $+$ is defined appropriately as the usual addition on $\mathbb{Z}$. If you're using deductive logic (which we all are, most of the time), then every step in your argument must be tautological; it must be true under all circumstances. Whether you write it out in full is another matter, but the tautologies must be there.
Comment: @JKreft: Pretty sure that $1 + 1 = 2$ is a theorem in most systems, e.g., Peano axioms: https://en.wikipedia.org/wiki/Peano_axioms#Addition
Comment: "These specific axioms are to be accepted without proof but nothing else is. " Is this the first axiom?
Comment: " If ... , then every step in your argument must be tautological; it must be true under all circumstances."  That seems a bit strange to me.  Oftentimes, non-tautological assumptions get made.  For example, when the cancellation law for groups gets proved, ab = ac is not a tautology.  And non-tautological formulas get deduced.  Also, the axioms in say any field of abstract algebra, such as group theory, aren't tautologies.  No one thinks that say, for example, the associative law for some abstract binary operation is tautologically true, since there exist non-associative binary operations.
Comment: Obviously, I was limited to a quick example by the text length. Yes, in Peano, it's a theorem, but in a simpler formulation of numbers, its an axiom. Arthur: Your definition, if taken as part of a further set of definitions of the integers, would count as an axiom. The point was not to recreate axiomatic definition of integers, but to illustrate the different tiers of tautology, axiom, and theorem to enlighten the original poster. Missed the forest for the trees, guys.
Comment: @DougSpoonwood If you refer to my answer below, I'm talking about the theorems of mathematics. In the process of proving implications, it is necessary to make assumptions, but only for the purposes of proving tautological statements. I would still say Alice is right: maths is little more than tautologies. While certain statements, taken out of context, are not, the only presentable interface mathematics has is tautology.
Comment: @TheoBendit Mathematical proofs often involve reasoning which shows things like A $\vdash$ B or A |= B where A is a set of assumptions which are neither true nor false, and B is neither true of false.  For example, A could be the set of axioms of group theory, and ab = ac, while B is b=c.  None of those are tautologies, nor is the set of any them a tautology, nor is A$\vdash$B, nor is A|=B.  In pure logic, natural deductive proofs more often involve showing something other than a tautology than showing a tautology holds.
Comment: @DougSpoonwood Once you unpack the definitions, the statement "All groups satisfy the cancellation law" is indeed a tautology. It doesn't matter if you express it as "Suppose $(G, \cdot)$ is a group. Then, for all $a, b, c \in G$, $a \cdot b = a \cdot c \implies b = c$."; it's still a tautology. And in order for it to be useful maths, it must be a tautology. You can't just tell someone that "$ab = ac$ implies $b = c$", without context, and have it be useful maths. Yes, some of the statements we write in order to prove our tautologies aren't tautologies in isolation, but that alone isn't maths.
Comment: @TheoBendit "es, some of the statements we write in order to prove our tautologies aren't tautologies in isolation..."  Well, that certainly contradicts what you wrote above: "If you're using deductive logic (which we all are, most of the time), then every step in your argument must be tautological".  By the way ab = ac is not a tautology, nor is d(ab) = d(ac), nor is (da)b = (da)c, nor is eb = ec, nor is b = c, where d is the inverse of a, and e is the identity element of a group.
Comment: @DougSpoonwood You're right there. What I meant (and what I think Alice meant) was that each theorem needs to be tautological. While certain statements in the steps of proofs are not tautologies, they must serve to establish tautologies, otherwise they are pointless.
Answer: All reasoning (whether formal or informal, mathematical, scientific, every-day-life, etc.) needs to satisfy two basic criteria in order to be considered good (sound) reasoning:

The steps in the argument need to be logical (valid .. the conclusion follows from the premises)
The assumptions (premises) need to be acceptable (true or at least agreed upon by the parties involved in the debate within which the argument is offered)

Now, what Alice is pointing out is that in the domain of deductive reasoning (which includes mathematical reasoning), the information contained in the conclusion is already contained in the premises ... in a way, the conclusion thus 'merely' pulls this out. .. Alice thus seems to be saying: "all mathematical reasoning is circular .. so why attack my argument on being circular?"
However, this is not a good defense against the charge of circular reasoning.  First of all, there is a big difference between 'pulling out', say, some complicated theorem of arithmetic out of the Peano Axioms on the one hand, and simply assuming that very theorem as an assumption proven on the other:
In the former scenario, contrary to Alice's claim, we really do not say that circular reasoning is taking place: as long as the assumptions of the argument are nothing more than the agreed upon Peano Axioms, and as long as each inference leading up the the theorem is logically valid, then such an argument satisfied the two forementioned criteria, and is therefore perfectly acceptable.
In the latter case, however, circular reasoning is taking place: if all we agreed upon were the Peano axioms, but if the argument uses the conclusion (which is not part of those axioms) as an assumption, then that argument violates the second criterion. It can be said to 'beg the question' ... as it 'begs' the answer to the very question (is the theorem true?) we had in the first place.
Comment: @DougSpoonwood, while your point is quite sensible in non-mathematical contexts, the mathematical answer is: natural deductions from *what?*  Whatever starting point for reasoning that you have, must, from a mathematical standpoint, be an assumption.  (In logical reasoning applied to life this is not so: your starting point can be an assumption, or a concrete observation.  Mathematics has no concrete observations not based on other assumptions.)
Comment: @DougSpoonwood Natural deduction systems tend to minimize or even eliminate *logical* axioms. The *non-logical* axioms that discuss the actual domain subject matter, e.g. real numbers, remain unless you go full type theory. In that latter case (and the former case to a lesser extent), instead of agreeing about axioms, you have to agree on what constitutes a valid rule of inference/construction. At any rate, the (usual, semantic) definition of "tautology" doesn't depend on the deductive system.
Comment: "Alice is correct that every proof relies on a set of axioms to which Alice and Bob have to agree beforehand."  Alice said: "As we know, each theorem in mathematics and logics is little more than a tautology"  Since she says all theorems are contained in the axioms, it seems that she would say that all axioms are tautologies.  But, natural deduction proofs exist which don't use any tautologies at all, nor any axioms.  Why need Alice and Bob agree on axioms instead of using a pure natural deduction system?
Comment: I feel it's important (albeit probably obvious) to note that, while we mustn't use our thesis as assumption in our proof, we must assume the negation of our thesis if we want to proof our thesis via contradiction.
Comment: It seems to me though that in defining good reasoning, you are using good reasoning. Is this not circular?
Comment: @PieterRousseau I don't see that: a definition is a definition; no reasoning is taking place in making a definition. Also, even if my definition is circular ... does that take away from any of my claims? In fact, if you think it does, you come close to making a similar mistake Alice seems to be making: "you say that my reasoning is circular, but 'yours' (all of mathematics) is circular as well" ... So? does that mean that Alice's reasoning is therefore somehow not circular?  Clearly not. This kind of mistake is closely related to the tu quoque fallacy, a subtype of the inconsistency ad hominem
Comment: @Bram: In formulating my own answer and rereading yours I think I agree with your answer, and this response. I was asking the question to formulate my own thinking on this question. Thanks for the reply. In response though, to apply step 1 of your definition you have to apply the whole definition which I would think is circular. But I do not object to it. It may well be that you have to use good reasoning to define good reasoning, just like one would use truth to define itself. Good answer btw.
Answer: I believe this has a simple resolution:
When we say informally that Alice is required to prove a result, it is sloppy language; she is actually required to prove the implication axioms $\implies$ result. So of course, she can have the axioms in her premises. However, she cannon have axioms $\implies$ result as one of her premises; that would be circular reasoning.
Comment: Are you defining circular reasoning, as making a statement that a certain conclusion (result) follows from a set of axioms, without proof?
Comment: @PieterRousseau I would say yes, at least as a practical definition that we use informally. However, if you back me into a corner, I would retreat to saying that a circular argument is any argument which has anything else other than axioms as premises (I would have to phrase it much more carefully m of course since that definition clearly encompasses more arguments than just the ones we would like to call circular.
Comment: " she is actually required to prove the implication axioms ⟹ result. "  For clarification, you're saying that basically Alice has to show "axioms $\vdash$ result" instead of "$\vdash$ (axioms $\rightarrow$ result)", correct?  Also, you said "However, she cannon..." I think you meant 'cannot'... though maybe Alice is a cannon *shrugs and laughs*.
Comment: @Ovi. Thanks for the clarification, I think I can agree with your more formal definition, because the premise (axioms ⟹ result) without proof is simply that: an unproven premise, nothing circular (I think). Unless I really misunderstood your answer.
Comment: @DougSpoonwood Yes, I think so. I'm just a student so honestly I wasn't even familiar with the sideways T. I looked it up and it seems to mean "RHS is provable from LHS", but then I'm not sure what just "$\vdash P$ means without a LHS
Comment: @PieterRousseau Well the goal of the proof is to prove (axioms $\implies$ result), so if that appears as one of the premises, I would call that a circular argument.
Comment: @Ovi Okay. I would rather call it unproved or assumed, which makes me think I am not understanding you accurately. Apologies.
Comment: @PieterRousseau Hmm sorry I'm not sure if I'm understanding you either. My position is: By definition, the last line in a proof is of the form (axioms $\implies$ result). If this line appears anywhere in the premises, the argument is circular.
Comment: @Ovi: Ah I get it! The result is used in the actual proof for the result. I understood you the mean the result is used as a premise (maybe in other proofs) WITHOUT a proof. Thank you for the clarification - I think I agree with your statements and it does answer the questioner but requires some unpacking to show why she is making a false comparison.
Comment: @PieterRousseau Ok thanks, I'm glad it makes sense to another person
Answer: The fallacious version of circular reasoning is an appeal to the proposition
$$(A \to A) \to A \tag{C}$$
That is, to establish a proposition $A$ from no premises, you first establish the proposition $A$ under an assumption of $A$.  Example:

Accuser: "You stole that."
Defendant: "No I didn't, it was mine."
Accuser: "It couldn't have been yours because you can't steal something you own."

In that case the accuser is correct as far as pointing out that "stealing" implies "not yours" which implies "stealing", the $A \to A$ part, but the fallacy comes from dropping the assumption and concluding "stealing" under no assumptions, which is the final $\to A$.
Guessing what Bob's side of the argument was : "Because the semantic meaning of a theorem is contained in the semantic meaning of the assumptions, you used circular reasoning".  Here Bob is making 2 mistakes.  First, he is equating circular reasoning with the proposition $A \to A$.  But that isn't what circular reasoning is, because $A \to A$ always holds, how can you object to that?
Second, he is not addressing the argument that Alice made.  Even if $(A \to A) \to A$ (for her specific claim) applies to the assumptions and conclusions of her argument: unless she appealed to that theorem as an inference, she hasn't made any mistake.  $(A \to A) \to A$ does hold in the case that $A$ itself is provable, such as when $A$ is a tautology.  Observing this isn't deductively equivalent to assuming $(A \to A) \to A$ holds in all cases and using that as an inference.
Answer: If her thesis is true, you could argue she is somehow right. But we dont know that her thesis is true. Lets say A is the set of axioms, and S(A) all true statements derivable from this set, and t her thesis. Then she wants to show that t in S(A). Only if this were true she could use that t is in S(A). But she doesnt know it.
To make it clear to her: you could ask why not use also not t to show that the axiom system is contradictory. How does she know not t is not in S(A)
Comment: This hits the nail right on the head.
Answer: (Not really an answer, but too long for a comment. Refer to amWhy's comment and Bram28's answer for a direct answer to your question.)
From what I understand, tautologies have a reputation in philosophy as being a waste of time. Things like "if I am cold and wet, then I am cold" don't seem to contain any new information, and have little value. But, the philosophers wonder, why is mathematics, which traditionally is 100% tautology, so non-trivial and produces unexpected results?
Well, I'm sure there are many answers to this, but the way I see it, it's finding a path from premises to conclusions that can be new information. Human beings aren't perfect; they cannot instantly account for every statement they hold to be true, and combine them in every possible way, to effortlessly see every consequence one can derive from them.
This is the point of proofs/arguments. I can read over and properly comprehend the axioms of ZFC, the definition of $\mathbb{R}^3$ and its Euclidean unit sphere, but that doesn't mean I instantly know how to prove the Banach-Tarski paradox!
Alice's reply seems to take the opposite stance. She seems to be assuming, implicitly, that there is no such gap between premises, consequences, and hence conclusions, rendering arguments useless. It's a view that I think most people would consider extreme (and wrong).
Answer: Supposing that Alice tells the truth about using circular reasoning, it can get demonstrated that Alice has made an error.  Alice says:
"Of course my proof contains its thesis within its assumptions. Each and every proof must be based on axioms, which are assumptions that are not to be proved. Thus each set of axioms implicite contains all thesis that can be proven from this set of axioms."
Alright, let's suppose the first two sentences correct.  The third is false though.  Why?  Because without rules of inference we can't conclude anything from any axioms.  So, we can't conclude that each set of axioms implies all of the theses, because axioms don't imply theses in the first place.  Ever since Frege it has been clear that rules of inference and axioms are not the same thing.  Only axiom and rules of inference taken together imply a thesis.  But then, the set of axioms doesn't implicitly contain all theses, because it's axioms and rules of inference that imply all theses provable in the theory.
Edit: Also, it really doesn't work out that "logic is little more than a tautology" or "logic is little more than a collection of tautologies".  Logic often involves showing something like A $\vdash$ B, where A is not a tautology, nor is B, and A $\vdash$ B is not a tautology.
Comment: So what if Alice rephrased her statement: "Of course my proof contains its thesis within its assumptions. Each and every proof must be based on rules of inference and axioms, which are assumptions that are not to be proved. Thus each set of rules and axioms implicitly contains all thesis that can be proven from this set."
Comment: So what you mean is that a set of axioms does not contain the rules of inference, without which no conclusions will follow anyways (Rules of inference + Axioms -> theses)?
Comment: @PieterRousseau Yes, that's it.
Comment: @PieterRousseau I don't think that a rule of inference can accurately get called an assumption.  Rules of inference don't bear truth, while assumptions do.  You also have seemed to have dropped Alice's "implicite".
Comment: "Rules of inference don't bear truth, while assumptions do." What do mean? Point of clarification: I am assuming with rules of inference that you are talking about rules of logic, such as A is A; A is not not A and if A is B and B is C then A is C.

(sorry about dropping the  "implicite" - I actually thought it was a typo, or I am misunderstanding what you mean - would you mind if we get back to that once I understand what you mean about assumptions.)
Comment: @PieterRousseau I'd say that all of those are statements, not rules of inference. Also, I don't think that authors of logic textbooks would call them rules of inference.  A rule of inference is more like "Suppose "A is B" is true and suppose that "B is C" is true also.  We may conclude that "A is C" is true."  There we have two sentences, not one, and no assertions of tautological character of the sentences get made.  The assumptions also do not, as a matter of form, get absorbed into a conditional as happened in your "if-then" statement.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/80853/discussion-between-pieter-rousseau-and-doug-spoonwood).
Answer: We can take the extreme case, where the axioms not only imply the conclusion, but contain the conclusion. Suppose I'm trying to prove it's raining outside. The following piece of reasoning is perfectly valid:

It's raining, therefore it's raining.

Nothing wrong with that, and no one would call it circular. It's just pointless. But suppose someone skeptical, without access to a window to look outside, were to challenge me to prove it's raining. If I now start my reasoning with "Well, we know that it's raining, so...", now I'm committing circular reasoning.
Notice that in both cases my proof and my axioms were the same, only the context changes. Circularity is not a property of a proof, it's a property of the context in which that proof is given. When we prove something from axioms, we should choose the axioms to be statements that are known to be true. If they're not known to be true, this is a Bad Thing. A special case of this kind of Bad Thing is where one of the axioms is the conclusion we're trying to prove (which is not known to be true): this special case is called circular reasoning.
Answer: The apparent dilemma arises from two words which do not mean the same thing.
You are talking about proofs. Alice is talking about truth. These are not the same thing.
A statement which is always true is a tautology, so in a sense, every such statement, including a true theorem, is a tautology.
But truth is not a proof.
Proofs are simply the re-expression of statements as other statements without relying on other statements (i.e., no circular reasoning).
But the result of a correct proof is no more true than the original statements, so a proof is likewise not always the truth.
Comment: "So in a sense, every true statement, including a true theorem, is a tautology."  The statement "it is raining withing 100 feet of me" is sometimes true and sometimes not true.  In mathematics, the statement "a = b" is only sometimes true, such as where 'a' and 'b' have particular, known computations, such as a = (2 + 2) and b = (3 + 1), or in say the case where (a + c) = (b + c).  So, I don't agree that every true statement is a tautology.
Comment: @DougSpoonwood You have proposed a sentence which depends on outside values to be true or false. This kind of statement is fine. It is called a conditional statement. I stated, "a statement which is always true is a tautology." I will edit my answer to make the phrase you quoted part of the same sentence so it is more clear.
Answer: Circular reasoning is when two statements depend on each other in order to be true (consistent with the model).

The inside angles of a triangles are supplementary
The co-interior angles of a line intersecting parallel lines are supplementary

Both statements can be used to prove the other but neither of the above statements can be proven from the existing set of axioms in Geometry unless one of them is assumed as true without proof (an axiom). This "straightens" the argument so as to begin at this assumption. This is not fallacious at all unless it produces a contradiction with existing assumptions. It just limits or rather refines the set of statements that can follow as a logical consequences of the additional assumption.
Alice's Argument that Mathematical Proofs are Circular can be understood as:

Each and every proof must be based on axioms.
Axioms implicitly contains all theses that can be proven from the set of axioms.

To prove any one of these two statements will require the other one. This is circular. To "straighten" it we must assume one of the two to be true and the other can follow by the rules of inference/logic.
Is Mathematics then a tautology? If you define a tautology as a system of statements that is true by necessity or by virtue of its logical form, then I think it unashamedly is, and has to be based on the rules of inference/logic and the assumption just made: Each and every proof must be based on axioms or restated: All theses must follow by the rules of inference (proof) from the set of axioms.
Is Alice's argument valid that, in form, it is equivalent to that of axiomatic system of Mathematics? Is it consistent with the model produced by the assumption: all theses must follow by the rules of inference (proof) from the set of axioms.
Proof by contradiction:
Assumed it is true that a proof contains its thesis within its assumptions.
Two situations,
1) The thesis is an existing axiom (assumption without proof).
If the thesis is an existing axiom, then of course her model is equivalent. A leads to A.
2) The thesis is not an existing axiom (assumption without proof).
If the thesis is not an existing axiom but it is an axiom because it is assumed without a proof, then is leads to a logical contradiction.
Which means her proof is only valid if her thesis is indeed an existing axiom.
Alice's solution:
So if her argument is indeed circular, then her solution is to admit that one of the statements that she is making must be is an necessary assumption to develop the model/argument/worldview etc. Then it could be equivalent to the axiomatic system of Mathematics if it does not contradict any existing assumptions/axioms.

What exactly is circular reasoning?


Is there a document for cordova as a node module?

Question: Most document is for command line, not for module.
I want to use cordova in my nodejs.
Anyone help?
I use it like below:
var cordova = require('cordova');
cordova.platform("add", "android");
……

Comment: Rly unfortunate there's no documentation.
Answer: No document.
You should use:
var cordova = require('cordova-lib');

not:
var cordova = require('cordova');

.
If you want to know how to use cordova-lib as a node.js module, you should look the source code at cordova-lib/src/cordova.
Answer: You can realize it with child processes in node.js. Create a JavaScript file myJsFileToRun.js in your root project folder and add for your example into it:
var exec = require('child_process').exec;
var child;

var command = "cordova platform add android";

child = exec( command, function (error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
      console.log('exec error: ' + error);
    }
});

In your shell start your script with node myJsFileToRun.js
Comment: I really know I can do it like this, but I don't think it's a good idea. any document for cordova as node module.


What is $\sum_{i=1}^{n}\frac{F_i}{i}$?

Question: Mathematica is able to evaluate the summation $\sum_{i=1}^{n}\frac{F_i}{i}$ in terms of the Lerch transcendent. It is natural to consider whether or not this summation can be expressed in a more simple way.
It is conceivable that it is possible that $a_{n} = \sum_{i=1}^{n}\frac{F_i}{i}$ may be expressed in a more compact way, perhaps in terms of Fibonacci and Lucas numbers somehow, using the nearest integer function or the floor function.
Integer sequences such as $(\lfloor a_{n} \rfloor)_{n \in \mathbb{N}}$, $([a_{n}])_{n \in \mathbb{N}}$, $( n! a_{n}  )_{n \in \mathbb{N}}$, and $( \text{den}(a_{n})  )_{n \in \mathbb{N}}$ are not currently in the On-Line Encyclopedia of Integer Sequences.
It appears that $\lim_{n \to \infty} \frac{\ln a_{n}}{n} \approx 0.481$ converges to a constant.  What is this constant? Can this constant be used to somehow express the sequence $(a_{n})_{n \in \mathbb{N}}$ in closed form?
Comment: Since $F_i$ is of the form $c(a^i-b^i)$, you can write $a_n$ as the difference of two truncated logarithmic series.
Comment: I don't know if it can be useful, but $$\sum_{n=1}^{N}\frac{F_{n}}{n}=\int_{0}^{1}\frac{z^{N+1}F_{N}+z^{N}F_{N+1}-1}{z^{2}+z-1}dz$$ and maybe using the Binet formula it is possible to find something.
Comment: I edited my answer with a more precise expansion that may be of interest too,
Answer: EXPANDED:
Let's define :
$$\tag{1}a_n(x):=\sum_{k=1}^{n}\frac{F_k}{k}x^k$$
and use $\,F_k=\dfrac {\varphi^{\,k}-\psi^{,k}}{\sqrt{5}}\;$ with $\;\varphi=\dfrac{1+\sqrt{5}}2,\ \psi=\dfrac{1-\sqrt{5}}2=-\dfrac 1{\varphi}\;$ (as suggested by Aravind and Wikipedia) then :
\begin{align}
a_n(x)&=\frac 1{\sqrt{5}}\sum_{k=1}^{n}\left(\varphi^{\,k}-\psi^{,k}\right)\frac{x^k}k\tag{2}\\
&=\frac 1{\sqrt{5}} \int\sum_{k=1}^{n}\left(\varphi^{\,k}-\psi^{,k}\right) \frac {x^{k}}x\,dx\\
&=\frac 1{\sqrt{5}}\left(\int \frac{(\varphi\,x)^{\,n}-1}{\varphi\,x-1}\varphi\,dx-\int\frac{(\psi\,x)^{\,n}-1}{\psi\,x-1}\psi\,dx\right)\\
&=\frac 1{\sqrt{5}}\int_{\psi\,x}^{\varphi\,x} \frac{u^{\,n}-1}{u-1}\,du=\frac 1{\sqrt{5}}\int_{\psi\,x}^{\varphi\,x}\ \sum_{k=0}^{n-1}\;u^{\,k}\,du\tag{3}\\
&\quad\text{writing the integrand at the left as a sum of two terms gives :}\\\\
a_n:=a_n(1)&=\frac 1{\sqrt{5}}\left(-B_{\varphi}(n+1,0)+B_{\psi}(n+1,0)-\log(1-\varphi)+\log(1-\psi)\right)\tag{4}\\
\end{align}
with $B_x(a,b)$ the incomplete beta function (the singularities in the integrals are removable and will not be considered).
All this is probably not very useful for practical evaluations but $(2)$ applied to $x=1$ allows to find a closed form for your limit $\;\displaystyle l:=\lim_{n \to \infty} \frac{\ln a_{n}}{n}$ using $\varphi>1$ and $|\psi|<1$ :
\begin{align}
a_n&=\frac 1{\sqrt{5}}\sum_{k=1}^{n}\frac{1}k\left(\varphi^{\,k}-\psi^{,k}\right)\\
a_n&\sim \frac 1{\sqrt{5}}\sum_{k=1}^{n}\frac{\varphi^{\,k}}k,\quad n\to\infty\\
&\sim \frac 1{\sqrt{5}}\frac{\varphi^{\,n}}{n}\sum_{k=1}^{n}\frac{\varphi^{\,k-n}\;n}k,\quad n\to\infty\\
&\quad\text{setting $\;j:=n-k\,$ gives}\\
&\sim \frac 1{\sqrt{5}}\frac{\varphi^{\,n}}{n}\sum_{j=0}^{n-1}\frac 1{\varphi^{\,j}\;\frac {n-j}n},\quad n\to\infty\\
&\sim \frac 1{\sqrt{5}}\frac{\varphi^{\,n}}{n}\sum_{j=0}^{n-1}\frac {1+\sum_{m>0} \left(\frac jn\right)^m}{\varphi^{\,j}},\quad n\to\infty\\
&\sim \frac 1{\sqrt{5}}\frac{\varphi^{\,n}}{n}\left(\frac 1{1-\frac 1{\varphi}}+\sum_{m>0}\frac 1{n^m}\sum_{j=0}^{n-1}\frac {j^m}{\varphi^{\,j}}\right) ,\quad n\to\infty\\
&\sim \frac 1{\sqrt{5}}\frac{\varphi^{\,n}}{n}\left(\frac {\varphi}{\varphi-1}+\sum_{m>0}\frac {\Phi\left(\frac 1{\varphi},-m,0\right)}{n^m}\right) ,\quad n\to\infty\tag{5}\\
a_n&\sim \frac{\varphi^{\,n+1}}{\sqrt{5}\;n\,(\varphi-1)},\quad n\to\infty\tag{6}\\
\end{align}
With $\Phi$ the Lerch transcendent $\;\displaystyle\Phi(z,s,a):=\sum_{n\ge 0}\frac{z^n}{(n+a)^s}$.
The limit will simply be :
$$l=\lim_{n \to \infty} \frac{\ln a_{n}}{n}=\log(\varphi)=\log\dfrac{1+\sqrt{5}}2\approx 0.4812118251$$
$$-$$
Let's use $(5)$ to get a more precise expansion defining $\;\displaystyle f_m(z):=\sum_{n\ge 0}n^m\,z^n=\Phi(z,-m,0)$.
For $m$ a nonnegative integer we have $\;\displaystyle f_{m+1}(z)=z\,f_{m}(z)'=z\sum_{n\ge 0}n^m\,n\,z^{n-1}=\sum_{n\ge 0}n^{m+1}\,z^{n}\ $
giving us the closed forms :
\begin{align}
f_0(z)&=\frac 1{(1-z)}\\
f_1(z)&=\frac z{(1-z)^2}\\
f_2(z)&=\frac {z^2+z}{(1-z)^3}\\
f_3(z)&=\frac {z^3+4z^2+z}{(1-z)^4}\\
\cdots
\end{align}
Using $\;z:=\dfrac 1{\varphi}\;$ so that $\,\dfrac 1{1-z}=\dfrac {\varphi}{\varphi-1}\;$ we may rewrite $(5)$ as :
\begin{align}
a_n&\sim \frac 1{\sqrt{5}}\frac{\varphi^{\,n}}{n}\left(\frac {\varphi}{\varphi-1}+\frac {\varphi}{(\varphi-1)^2\,n}+\frac {\varphi+\varphi^2}{(\varphi-1)^3\,n^2}+\frac {\varphi+4\varphi^2+\varphi^3}{(\varphi-1)^4\,n^3}+\cdots\right) \\
a_n&\sim \frac 1{\sqrt{5}}\frac{\varphi^{\,n}}{n}\left(\varphi+1+\frac {2\varphi+1}{n}+\frac {8\varphi+5}{n^2}+\frac {50\varphi+31}{n^3}+\frac{416\varphi+257}{n^4}+\cdots\right) \\
\end{align}
The sequences of integers appearing there are known : OEIS A000557 and A000556 allowing us to write this exponential generating function :
\begin{align}
\frac{\varphi+e^{-x}}{1-2\sinh(x)}&=(\varphi+1)+(2\varphi+1)\frac x{1!}+(8\varphi+5)\frac {x^2}{2!}+(50\varphi+31)\frac {x^3}{3!}+(416\varphi+257)\frac {x^4}{4!}+\cdots\\
\end{align}
The OEIS links should help you to find further relations and interesting links.
Comment: A more precise expansion would be : $$a_n\sim \frac{\varphi^{\,n+1}}{\sqrt{5}n\,(\varphi-1)}\left(1+\frac {\varphi}n+\frac{\varphi^4}{n^2}\right)$$

What is $\sum_{i=1}^{n}\frac{F_i}{i}$?


How to write pow( ) in swift and fix errors?

Question: I'm trying to write a pow function in swift and this is my code:
var recorder: AVAudioRecorder!
var levelTimer = NSTimer()
var lowPassResults: Double = 0.0

override func viewDidLoad() {
    super.viewDidLoad()
    let url = NSURL.fileURLWithPath("dev/null")
    //numbers are automatically wrapped into NSNumber objects, so I simplified that to [NSString : NSNumber]
    var settings : [NSString : NSNumber ] = [AVSampleRateKey: 44100.0, AVFormatIDKey: kAudioFormatAppleLossless, AVNumberOfChannelsKey: 1, AVEncoderAudioQualityKey: AVAudioQuality.Max.rawValue]
    var error: NSError?
    self.recorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL, settings:recordSettings, error:&error];
    if((recorder) != nil){
        recorder.prepareToRecord()
        recorder.meteringEnabled = true
        recorder.record()
        levelTimer = NSTimer.scheduledTimerWithTimeInterval(0.03, target: self, selector: Selector("listenForBlow"), userInfo: nil, repeats: true)
    }
    else{
        NSLog("%@", "Fehler an dieser Stelle");
    }
}
func levelTimerCallback(timer:NSTimer) {
    recorder.updateMeters()
    let ALPHA: Double = 0.05
    var peakPowerForChannel: Double = pow(10, (0.05 * [self.recorder.peakPowerForChannel(0)]))
    lowPassResults = ALPHA * peakPowerForChannel + (1.0 - ALPHA) * lowPassResults;

    NSLog("@Average input: %f Peak input: %f Low pass results: %f", [recorder.averagePowerForChannel(0)], [recorder.peakPowerForChannel(0)], lowPassResults);
}

I'm getting errors in two lines and I don't know how to fix them.
This is the first error in this line: (error: "Expected ',' separator). Is there a syntax error which I overlooked?
self.recorder = [[AVAudioRecorder alloc] initWithURL:soundFileURL, settings:recordSettings, error:&error];

This is the other error:"Could not find an overload for '*' that accepts the supplied arguments". I know that the types must be the same (Double * Double). But where exactly is the mistake?
var peakPowerForChannel: Double = pow(10, (0.05 * [self.recorder.peakPowerForChannel(0)]))

P.S.: I know there are a lot of questions like this, but I can not find a answer in swift. Thanks ahead!!
Comment: It looks like you pasted Objective-C code into a Swift file. I think you want to use `recorder = AVAudioRecorder(URL:…settings:…)`
Answer: Use Swift, not Objective-C, syntax to initialize your audio recorder:
recorder = try AVAudioRecorder(URL:…settings:…)

For calculating peakPowerForChannel, know that 10 will be an Int and peakPowerForChannel(_:) returns Float, not Double. You'll need to explicitly cast these:
var peakPowerForChannel : Double = pow(Double(10), (0.05 * Double(recorder.peakPowerForChannel(0))))

Also, since pow(_: _:) returns Double, you can delete peakPowerForChannel's type specification:
var peakPowerForChannel = pow(Double(10), (0.05 * Double(recorder.peakPowerForChannel(0))))


Popular combobox com uma lista de uma consulta

Question: Bom eu tenho uma classe DAO
DepartamentosDAO
eu queria popular um combo box com uma consulta que faço nesse DAO
meu DAO:
public class DepartamentoDAO {

    private Connection con;

    public DepartamentoDAO() {
        this.con = new ConnectionFactory().getConnection();
    }

    public boolean popularComboBox() throws SQLException{
        List<String> setores = new ArrayList<String>();
        String query = "SELECT * FROM departamentos";
        PreparedStatement ps = con.prepareStatement(query);
        ResultSet rs = ps.executeQuery();
        while(rs.next()){
           setores.add(rs.getString("nome_setor"));
           }

    ps.close();
    return true;
    }
}

meu controller:
@FXML
private JFXComboBox<Departamento> cbDepart;
private List<Departamento> departamentos = new ArrayList();

como eu conseguiria popular o meu combo box com essa lista DAO que está em outro metodo?
Answer: uma dica seria retornar uma lista em vez de boolean:
public List<String> setores findAllSetores() {
        List<String> setores = new ArrayList<>();
        /*operacoes*/

        return setores;
}

então em qualquer outro lugar voce pode obter essa lista simplismente fazendo:
List<String> setores = new DepartamentoDAO().findAllSetores();
if (!setores.isEmpty()){
   /*significa que a lista nao esta vazia*/
}

a partir disso poderia popular sua comboBox
JComboBox cb = new JComboBox();
            cb.addItem();


Opening a new fragment when a ListView item is clicked

Question: I'm pretty new to Android so I may be doing things completely wrong but I'm trying to get  a fragment to open up when a list item is clicked and then to close it when it is dismissed with the back button.
I now have something working but when the back button is clicked it redraws the whole initial view. SO the listview scrolls back up to the top and reloads all the items from the db.
On the list item click in the main activity I am doing this

public void onItemSelected(String id) {
    Intent detailIntent = new Intent(this, DetailActivity.class);
    detailIntent.putExtra(Fragment.CLICKED_ID, id);
    startActivity(detailIntent);
}

Then in the activity I am using this to show it.

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_open_day);

    // Show the Up button in the action bar.
    getActionBar().setDisplayHomeAsUpEnabled(true);

    if (savedInstanceState == null) {
        // Create the detail fragment and add it to the activity
        // using a fragment transaction.

        OpenDayFragment fragment = new OpenDayFragment();
        getFragmentManager().beginTransaction()
                .add(R.id.open_day_detail_container, fragment)
                .commit();
    }
}

and this to close it.
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    if (id == android.R.id.home) {
        NavUtils.navigateUpTo(this, new Intent(this, MainActivity.class));
        return true;
    }
    return super.onOptionsItemSelected(item);
}

AS i said it all works but the listview and all the tabs from MainActivity seem to be completley disposed of when the activity is run. Is there a way just to show a fragment over the top and dismiss it, leaving the previosu activity intact?
Thanks
Comment: My guess is that you should try using a `DialogFragment`. This is how I did it: http://stackoverflow.com/a/25056160/2413303
Comment: It is s fragment from a tab list, loading a fragment. See below though the finish() sorted my problem.
Comment: Not sure dialogfragment does what I need. I want it to be full screen and use the actionbar to display the heading. Just like in the twitter app when you click a tweet.
Comment: how are you displaying the current screen? Is it an ActionBarActivity or a Fragment too?
Answer: On close button you are recreating the home activity which will as a result launch every thing again. To void that you should finish the DetailActivity that will take you back to the Home Activity.
Comment: Brilliant! Easy when you know how. So I changed it to this.finish() instead of Navutils.navigateUp and all seems fine. Does that sound ok?
Answer: It reloads it again because you are creating the MainActivity again. To avoid that try finish(); in if (id == android.R.id.home) of your DetailActivity so it closes it, keeping the preview state of the MainActivity.


Combine inverse property and inverse class selector with existing selector

Question: I have this jQuery code:
$("#Filter ul input:checked").each(function () {
    if (!$(this).prop("disabled") && !$(this).hasClass("ignoreInput")) {

Can this be written in only one selector? Right now I'm taking in too many elements to test with the if statement.
Is it also better to use .find(selector) instead of writing all in one selector?
$(document.body).find("#Filter ul ...)

Answer: You could use a combination of :not() along with the attribute selector, like this:
$("#Filter ul input:checked:not([disabled],.ignoreInput)").each(function () {
    // your logic here
});

Is it also better to use .find(selector) instead of writing all in one selector?

This makes little to no performance difference.
Comment: @juFo It's all in the docs: https://api.jquery.com/has-attribute-selector/
Comment: @juFo That's the synthax for attribute selector
Comment: could you explain the squere brackets syntax of disabled?
Comment: so this code:
$("[class*='slider-range-']").each(function () { if (!$(this).prop("disabled")) {
would translate to:
$("[class*='slider-range-']:not([disabled])")


Can hazard ratios be undefined?

Question: Can a hazard ratio be undefined because you are comparing a "lower value" to a "higher value?"
For example, suppose you are interested in some variable $x \in [0, 100]$. Say you are interested in comparing 5 values of $x$. If you choose the highest value of $x$ to be the reference level... Would all the hazard ratios of the other values be undefined?
Edit. Suppose you have the following groups: $A,B,C$ and $D$ with $D$ as the reference level. You are looking at the outcome death for each of these groups. If there are no outcome events in group $A$ for example, would the hazards ratio for group $A$ be $0$ or undefined?
Comment: Could you state precisely what you mean by "hazard ratio" in this context?  Your use of the term does not seem consistent with [a standard definition](http://www.cancer.gov/dictionary?cdrid=618612).
Comment: @whuber: It is the ratio of hazard functions where a hazard function is the rate at which an event happens (e.g. death) in a short time interval.
Comment: That description doesn't match what you state in your question, Markk.  How do you construe values of a "variable" as if they were hazard functions?
Comment: @whuber: I am forming groups based on the values of $x$. For example all people with $x = 1.5$ form a group, all people with $x= 2.4534$ form a group etc... and then I am looking at some outcome event like death and choosing people in group $x = 2.35$ (for example) as the reference level.
Comment: I'm starting to see what you're doing, markk, but do not yet have a clear idea.  It would help to edit your question to describe your experiment, what you're measuring, how you're grouping, and what your analytical objective is.
Answer: To make any valid comparison using standard statistical tests, you'd need to define your two groups you are comparing as part of the experimental design. It does not make sense to define  two groups based on one variable, and then compare that variable between the two groups.
Comment: Motulsky: I am comparing hazards ratios for 5 groups (with 1 of the groups as the reference group) based on some value of a continuous variable.
Comment: markk: I still don't understand what your experimental design is, what statistical test you plan to use, or what question you are asking on this site.
Answer: Based on what I think you are asking:
It depends on how you coded the variable. Trying an applied example:
We have some continuous variable, lets say BMI, and an outcome, say time until first myocardial infarction. You want to find out what the hazard ratio is between a BMI of 25 as the referent group, and say 30, 40, 50 and 55.
Your question is what happens if there's no events in group 40.
If you used indicator variables to code these, my understanding is the hazard would be 0, not undefined. There is a probability, and it can be calculated - it just happens to be zero.
If you used a continuous variable for BMI, it doesn't matter. Regression - including survival-analysis techniques involving regression, with smooth over areas of missing data. You can get an estimate for 40 as it interpolates between other areas where you do have events - say 39 and 41. This is a problem however if for some reason your group doesn't just have 0 events through random chance, but because there's something about them that means they can't have the outcome. For example, the magic heart attack fairy protects you if you have a BMI of exactly 40 (there are clearly more realistic examples of this problem). This is called non-positivity, and it is a threat to the validity of your inference.

Can hazard ratios be undefined?


Sessão PHP com tempo de redirecionamento

Question: Preciso de ajuda em relação a um script de sessão de usuário em PHP com tempo tempo de espera,de forma que se não houver atividade na pagina ela seja redirecionada para uma página de saída.
Comment: Bem-vindo ao StackOverflow em Português! Por favor explique melhor o problema, e se possível inclua um [exemplo de código que reproduza o que está acontecendo](http://pt.stackoverflow.com/help/mcve), pois não está percetível a sua pergunta. [Veja na Central de Ajuda Como Perguntar](http://pt.stackoverflow.com/help/how-to-ask).
Answer: Após o usuário efetivar o login, você pode inserir o seguinte trecho de código:
<?php

    session_start();
    session_cache_expire(1800); //o tempo é medido em segundos

?>

Desta forma, toda página que necessitar da sessão de usuário, você deve verificar se há uma sessão de usuário ativa, assim:
<?

    if(!isset($_SESSION)){

        //aqui você aplica o redirecionamento
        header("Location: ".$enderecoPagina);
    }

?>

Comment: consegui com javascript
Comment: é automático amigo? em tempo real?
Comment: Estou meio confuso em relação ao seu "automático", você quer dizer que ao estourar o tempo já redirecione a página, ou se o usuário tentar ir para uma página que precisa de sessão e ela já esgotou, logo teria que redirecionar?
Comment: em tempo real mesmo


Not able to set value of hidden field using viewbag when value is type of bool.

Question: Controller side i have
ViewBag.CanAddNewStudent = Convert.ToBoolean(Request.Cookies["SignInOption"]["Can Add New Student"].Split(',')[0]);
And at the view side i take Hidden field as
 <input type="hidden" id="HiddenCanAddNewStudent" value="@ViewBag.CanAddNewStudent">
      @ViewBag.CanAddNewStudent

Here in Hidden field i get Value="value" instead of Boolean value.
Comment: It is possible when i pass value as string
ViewBag.CanAddNewStudent = Request.Cookies["SignInOption"]["Can Add New Student"].Split(',')[0];
I can't understand what is problem with Boolean value.

    @Html.Hidden("HiddenCanAddNewStudent", (bool)ViewBag.CanAddNewStudent) Is also working the only problem is
Answer: This is an unfortunate side effect of a feature introduced in Razor V2 called conditional attributes. If the value of the property is a bool it will repeat the attribute and is designed for use in attributes such as checked or disabled where you can use a bool value and if the value is true it will generate checked="checked" or disabled="disabled", but if the value is false then the attribute will be omitted.
You can read more about this feature in Cleaner Conditional HTML Attributes In Razor Web Pages and Applying Conditional Attributes in ASP.NET MVC Views
To generate the hidden input, you can use
@Html.Hidden("HiddenCanAddNewStudent", ViewBag.CanAddNewStudent)

which will also include a name="HiddenCanAddNewStudent" attribute in addition to the id="HiddenCanAddNewStudent" attribute. However, the MVC way to handle this is to use a view model that includes a property for your bool
public bool CanAddNewStudent { get; set; }

and set the value of that property before you pass the model to the view, then in the view
@Html.HiddenFor(m => m.CanAddNewStudent)

Answer: It is how boolean values usually work in HTML (for example, in checkboxes) -- the logical value is represented not by the value of attribute value, but by its presence (if the tag has this attribute, the value is true, otherwise false). It is really strange that this logic is applied to hidden fields, but probably the framework works this way.
Anyway, I would recommend to convert the boolean value into a string and assign this string to the field. By their nature, values of hidden fields are strings, not booleans.
Comment: As i mentioned in comment when i pass string value it is working, but i can't understand strange behavior of "Hidden Fields".
Answer: At top of View take boolean variable and save viewbag value in it and then pass that variable to your hiddenfield.
@{
    bool _canAddNewStudent=Convert.ToBoolean(Viewbag.CanAddNewStudent);
}

<input type="hidden" id="HiddenCanAddNewStudent" value="@_canAddNewStudent">

Answer: View(html)
@ViewBag.CanAddNewStudent

jQuery
$('#HiddenCanAddNewStudent').text(); //value of ViewBag.CanAddNewStudent
Answer: Try this, if you want to use input tag
<input type="hidden" id="HiddenCanAddNewStudent" email@example.com(ViewBag.CanAddNewStudent)>

this will return true in jQuery and also show in HTML value ="True"


Messaging PlugIn (Carel Lotz) in Xamarin PCL?

Question: So I have this button in my Portable Class Library that should directly attach an xml file I've created into a mail and send it using the Messaging PlugIn. The problem is that .WithAttachment() is not supported in PCL so I wanted to ask if I can get around this using DependencyService and if so, how?
Can I just return .WithAttachment() from the UWP class (as UWP is my target platform)? Wouldn't there be a conflict because I've read that the overload of .WithAttachment() in UWP is .WithAttachment(IStorageFile file).
private void Senden_Clicked(object sender, EventArgs e)
        {
            var emailMessenger = CrossMessaging.Current.EmailMessenger;
            if (emailMessenger.CanSendEmail)
            {
                var email = new EmailMessageBuilder()
                  .To("firstname.lastname@example.com")
                  .Subject("Test")
                  .Body("Hello there!")
                  //.WithAttachment(String FilePath, string ContentType) overload showing in PCL
                  //.WithAttachment(IStorageFile file) overload for the UWP according to the documentation
                  .Build();
                emailMessenger.SendEmail(email);
            }

        }

EDIT:
I've been able to modify Nick Zhou's answer a little bit to be able to send an email with attachment via button-click. I just changed this peace of code:
var picker = new Windows.Storage.Pickers.FileOpenPicker
    {
        ViewMode = Windows.Storage.Pickers.PickerViewMode.List,
        SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
    };
    picker.FileTypeFilter.Add("*");

to this:
StorageFolder sf = ApplicationData.Current.LocalFolder;
            var file = await sf.GetFileAsync("daten.xml");

Of course you then need to create the file inside the app's local folder instead of the documents library.
Answer:
The problem is that .WithAttachment() is not supported in PCL so I wanted to ask if I can get around this using DependencyService and if so, how?

Of course you can use DependencyService to achieve sending email with attactment. But you could create two interface like code behind.
SendEmail Interface
 public interface IMessageEmail
    {
       void SendEmailMehod(string address, string subject, string body, StorageFile attactment = null);
    }

IMessageEmail implementation in UWP project.
public void SendEmailMehod(string address, string subject, string body, StorageFile attactment = null)
 {
     var emailMessenger = CrossMessaging.Current.EmailMessenger;
     if (emailMessenger.CanSendEmail)
     {
         if (attactment != null)
         {
             var email = new EmailMessageBuilder()
       .To(address)
       .Subject(subject)
       .Body(body)
       .WithAttachment(attactment)
       .Build();
             emailMessenger.SendEmail(email);
         }
         else
         {
             var email = new EmailMessageBuilder()
       .To(address)
       .Subject(subject)
       .Body(body)
       .Build();
             emailMessenger.SendEmail(email);
         }
     }
 }

As you can see the .WithAttachment(attactment) parameter is IStorageFile. So you need pass a file to the method. Hence you could create another DependencyService.
IFilePicker Interface
public interface IFilePicker
    {
        Task<StorageFile> getFileAsync();
    }

IMessageEmail implementation in UWP project.
public async Task<StorageFile> getFileAsync()
{
    var picker = new Windows.Storage.Pickers.FileOpenPicker
    {
        ViewMode = Windows.Storage.Pickers.PickerViewMode.List,
        SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary
    };
    picker.FileTypeFilter.Add("*");

    var file = await picker.PickSingleFileAsync();

    if (file != null)
    {
        return file;
    }

    return null;
}

You can try the project I have upload to github.
Comment: Thank you so much again, Sir! Do you know if there is a way to get the file to be picked automatically or set the default location to the DocumentsLibrary? Because `SuggestedStartLocation` doesn't set it to DocumentsLibrary (according to documentation it just remembers the last folder the user has picked or something like that).
Comment: @Nick Ok I got it now! And you Sir, you da real MVP! Thank you SO MUCH <3


Explain as though I'm five years old: Infinite Numbers but Finite Length

Question:
All natural numbers are finite in length.
  The set of natural numbers is infinite.

The above is something that I accept as true, but something I don't understand. The argument I presented was:

Given a set $X$ of n consecutive natural numbers starting from $1$, to $n$ the length (number of digits) of $n$ is $>= log(n)$.
  If we take all the natural numbers $(\infty)$, the length of some number should be $log(\infty)$ which is?

I get that $log(n)$ is a (much) slower growing function than $n$, but I don't get what makes $n$ become infinite and $log(n)$ not? What is the limit if any on $log (n)$? It's something I find it difficult to wrap my head around.

For example, the harmonic series diverges to infinity, but $ln(n)$ provides an approximation for the harmonic series.

Why then does the harmonic series diverge to infinity, but length$(n)$ does not?
Comment: $\log n$ diverges to $\infty$ as $n\to\infty$, which is not even surprising: children, adults and machines have issues with big integers because *big integers are very long*. I don't understand why the part which begins with "For example" should be an example: I think it's just an unrelated fact you've heard somewhere and put it together with this.
Comment: "ELI5" is not a common abbreviation; I've edited the title accordingly.
Comment: "I don't get what makes n become infinite and log(n) not? "  $n$ does not become infinite.  $n$ is always a finite number.  "Why then does the harmonic series diverge to infinity, but length(n) does not"?  length (n) *DOES* diverge to infinity.  $length(n)$ and $n$ and $n^2$ and $e^n$ all diverge *to* infinity but *all* of the specific values are always finite.  You are confusing being infinite in number with being finite in value.  And this is true for $n$, not just for length.  But of for $n$ itself.
Answer: The length of the natural numbers does diverge as you go towards infinity. However, if you select a given natural number (regardless of how big it is), its length must be finite. Remember that infinity is not a natural number. Note that saying that all natural numbers have finite length is different from saying that the length of the natural numbers is bounded (which is not true).
If the set of natural numbers is finite, then we must have some natural number with a (finite) maximal length. But, because we can write a natural number with length at least as big as $\log(n)$ for any $n$ (such as $10^{\log(n)+1}$), and as $\log(n)$ diverges to infinity as $n\to \infty$, the maximum length is not finite and is therefore never achieved on the set of natural numbers, so the set of natural numbers cannot be finite.
Answer: tl;dr
You are confusing "being infinite in value" with "being infinite in number", and being "finite in value" with "being bounded/converging".
length($n$) is absolutely no different than $n$ in either.
Both {length($n$)} and {$n$} are infinite in number.  Both length($n$) and $n$ are finite in value. And both length($n$) and $n$ diverge to infinity.
So ... "but I don't get what makes n become infinite and log(n) not?":  Answer $n$ does not become infinite.
"What is the limit if any on log(n)?" $\lim_\limits{n\rightarrow \infty} \log n = \infty$
"but ln(n) provides an approximation for the harmonic series"  $\ln (n)$ provides an approximation of a partial harmonic series: $\sum_\limits{i=1}^n \frac 1i \approx \ln (n)$. But  $\sum\limits_{i= 1}^{\infty} = \lim_\limits{n\rightarrow \infty}\sum_\limits{i=0}^n\frac 1i = \lim_\limits{n\rightarrow \infty} \ln(n) = \infty$
"Why then does the harmonic series diverge to infinity, but length(n) does not?" Answer: length($n$) does diverge to infinity.
====
I think the issue of the length of a number is a misleading red herring.
Sure, the length of $n$ increases logrithmically slower than $n$ but .... that has nothing to do with it always being finite.  The square of all natural numbers increases geometrically faster than $n$ and the square of all natural numbers are always finite.
And all of those; the length of the numbers, the size of the numbers, and the squares of the numbers all are unbounded and do tend to infinity even though each log, square, and number is finite.
The issue is how can there be a set of things that are each finite, but the set  has an infinite number of them.
And if you think about it, there really is no issue.  How many things are in the group have nothing to do with anything about the things in the group.  A set of seven objects has seven things in it, whether those things are atoms, dustspecks, elephants, galaxies, or universes.
I suppose the confusion comes down to when   and everything that can be counted has a representative number and every number is finite, how can you count to something infinite. Or perhaps more accurately, how can you not count to something infinite if everything you have is finite.
I think the easiest explanation is the most common one.  "What is the largest number? Now add one to that."  Every number is finite but for every number there are more numbers larger than it.  Each one is finite but there is no limit to all of them as a group and the group is infinitely large.


About chords and intervals

Question: The chord formula is 1-3-5 (for a triad). When played with different notes in different scales, there will be a difference in the no. of semitones b/w the notes of the chord. Which will decide on the quality of the chord, wether it is major, minor, augmented, dimunished etc. Is this correct?
Edit: Each comment added something different & gave a more whole perspective. Cheers yall.
Answer: If I understand your question right, you're forming chords on scale degrees.  In the key of C major you'll get a major triad on some notes (C, F, G) a minor triad on some notes (D, E, A) and a diminished triad on one (B).
The way we identify the quality is to compare the tones to the major scale of the chord root.  Staying in C, we can compare the triads to the scales, and see which notes are altered:
C-E-G : compared to the C scale (C-D-E-F-G-A-B) it's 1-3-5, a major triad
D-F-A : compared to the D scale (D-E-F#-G-A-B-C#) it's 1-b3-5, a minor triad.  The third of the chord (F) is a half step lower than the third of the root tone's major scale (F#), and this is what makes it a minor chord
B-D-F : compared to the B scale (B-C#-D#-E-F#-G#-A#) it's 1-b3-b5, a diminished triad.  Both the third and fifth are lower than the corresponding tones in the root's major scale.
You'll get augmented triads if you harmonize some scales.  If you were in C harmonic minor (C-D-Eb-F-G-Ab-B) the chord built on Eb will be Eb-G-B.  Compared to the Eb scale (Eb-F-G-Ab-Bb-C-D) the fifth has been raised, making the chord formula 1-3-#5.
Answer: Correct.
Note that a diatonic triad will never be augmented in any traditional key. Most will be major or minor, a few will be diminished.
Comment: @Tim The supertonic in minor. Even though it's the same as the leading-tone triad in major, it functions differently, so my brain categorizes them as different.
Comment: Isn't there only one diminished triad obtainable from a diatonic set of notes - that based on the leading note? Which others make 'a few'?
Answer: Supposing you know how the triads are built - if not look up the theory! -  following procedure will help you to derive all chords in all keys on your own:
Draw a scheme of keyboard where all keys (b&w) have the same distance like this picture:

This imgur picture doesn't fit to my plan. I have to upload my own again:

(You can design the note names if you need)
Then write on a strip with a C-major scale or a movable doremi  all triads of all degrees horizontally so you can read all triads in all keys and derive and transpose them yourself.
Answer:
The chord formula is 1-3-5 (for a triad).

Yes. And you can keep stacking up the thirds 1 3 5 7 9 11 13 to get 7th chord, 9th chords, etc. Basing chords on thirds in this way is called tertian harmony.

Which will decide on the quality of the chord, whether it is major, minor, augmented, dimunished etc?

The 1 part of the chord is called the root, and of course the 3 and 5 are the third and fifth of the root. All triads will have a root, third, and fifth.
You can determine the quality with different methods but in the end you must consider both the third and the fifth above the root. Some people like to think of the triad as two stacked thirds. I prefer to think about it as a third and a fifth above a root.

When the fifth is a perfect fifth (seven semitones) the triad will be either major or minor

if the third is major, the triad is major (C E G)
if the third is minor, the triad is minor (C Eb G)

When the fifth is diminished (six semitones)...

...and the third is minor, the chord is diminished (C Eb Gb)
...and the third is major, the chord is not a diatonic triad and does not have a specific name (C E Gb)

When the fifth is augmented (8 semitones)...

...and the third is major, the triad is augmented (C E G#)
...and the third is minor, the chord is not a diatonic triad and does not have a specific name (C Eb G#), enharmonically this is an Ab major triad in first inversion, but with this specific spelling it technically isn't a major triad

I highlighted in both the combinations that make the four basic triad types. The other two bullet points - the ones that make odd triads without names - I included only so you can see those combinations aren't normally used.
You may wonder why I suggested first looking at the fifth, then the third.
Each key has 7 diatonic triads of which 6 have perfect fifths above the root. The 1 chord that is different is the diminished triad using the diminished fifth. The augmented triad isn't even included in the diatonic triads!
The perfect fifth is so important in tertian harmony that I prefer identifying the root and fifth first, then identifying the third.
Answer: Strictly speaking, a chord can't be "augmented" or "diminished".
A chord can only be "major" or "minor". The interval between 1 and 3 give the nature:
("T" = "Tone", "ST" = "Semi-tone")

1T1/2 between 1 and 3 implies "minor"
2T between 1 and 3 implies "major"

All of the other terms — augmented, diminished, etc. — require to define which interval is augmented, diminished, etc. Exception made for some of them (see below).
'augmented' means one semi-tone (ST) over the perfect state.
'diminished' means one semi-tone (ST) under the perfect state or the minor state.
On 6 degrees, the 5th (quint) is perfect. That means 3T1/2 from 1 to 5.
So the perfect state, 5th can be 'augmented' (3T1/2 + 1ST) or 'diminished' (3T1/2 - 1ST).
The same for the 4th (quart), its mirror interval : 2T1/2 is a perfect 4th. 2T1/2 + 1ST is an augmented 4th, 2T1/2 - 1ST is a diminished 4th.
We call such a chord a chord with augmented 5th (C aug.5th) or a chord with dinunished 4th (F dim.4th).
Sometime, we talk about de "augmented chord" for "chord with an augmented quint", but it's an « artistic licence», an abuse of language ;-). We do so because the 5th is the very most augmented interval, in a chord.
Like 3th which can't be perfect, the 7th can be minor (C-Bb) or major (C-B). Unlike the 3th, the 7th can also be diminished (F#-Eb).
So, you see, we (always) have to know which degree is altered in the chord to qualify it.
Exception made for:

"dim7", where we only talk about 7th. You have to know that in this chord the 3th is always minor and the 5th is always diminished. No exception. It's a so frequent chord that we have to give it a shortname, a pseudo.
"semi-dim7" (used in english? in french: 7e demi-diminuée). You have to know that 3th is always minor and 7 is always diminished.

I'd like to add:

sus (Gsus7, ), where the 3th is replaced with the 4th (G C D F -> 1 4 5 7)

(If someone wants to correct my very bad english, I give him white card ;-)

About chords and intervals


Sonar forces me to choose between FindBugs results or JaCoCo integration test coverage

Question: I have this strange problem in Sonar. I am using Sonar 3.2 + Ant + JaCoCo + Selenium.
I setup my sonar.binaries properties file in the Ant target, which is executed through Jenkins.
1) If I set the sonar.binaries property to point to my generated .class files, then FindBugs works fine but my JaCoCo Integration Test coverage displays 0%. The 0% is probably due to the fact that the class files are not the exact ones being deployed to the JBoss server, therefore Sonar cannot do the mapping.
2) If I set the sonar.binaries property to point to my .jar files (i.e. includes the above .class files) then FindBugs will give an exception upon build. After disabling FindBugs the Sonar build finishes fine, and this time I get the correct JaCoCo IT code coverage for all of my binaries!
Any thoughts? :)
Comment: interestingly, it is like comma separated values does not work for the sonar.binaries property? I have added three folders to the property, but only the first one is chosen. So I get IT code coverage only for the folder of class files that I have first specified :) the other folders separated with a comma are ignored.
Answer: It sounds like you are experiencing the bug: http://jira.codehaus.org/browse/SONARJAVA-164 - "The Sonar JaCoCo plugin takes into account only the first binary directories if several ones are provided"
This is due to be fixed in the next release of the Sonar Java Ecosystem plugin (1.3), which however is not released yet.
Comment: thanks Simon for the verification. Yes it seems like I am experiencing this bug. I got around it somehow (can't remember exactly) by importing all .class files (including .jar files) and then excluding some files. I imported folders, not individual class or jar files.


Getting syntax error, unexpected ',', expecting ']'

Question: For my php function.
i have these codes
DB::table('trades')->where('id', $trade->id)
                            ->update(['status' => 'done',
                                  'accepted_trade_message_id' => $message->id,
                                  'updated_at' => date("Y-m-d h:i:s")]);

But i getting these error while preview in website
FatalErrorException in PageController.php line 2644: syntax error, unexpected ',', expecting ']'

I can't figure out why i already without the ',' but still the same?
Thanks
Comment: What line is 2644?  Also do a `var_export()` of `$trade->id` and `$message->id`.
Answer: Answer figured out by previous function of ',' .
Thanks


How to hide the right and left regions from a customized login page?

Question: I'm working on Drupal 7, and trying to create one customized login page. I don't want to display the right and left regions in this page; I want a login page with only header, footer and content, where the content would be the "Username" and "Password" fields.
How can I do it?
Comment: Use different page templates. Are you using the default Drupal theme, or [Omega](http://drupal.org/project/omega) or something else? If you use Omega there is the [Delta](http://drupal.org/project/delta) module. Also [Context](http://drupal.org/project/context) module might help you.
Answer: Go to the Blocks admin page, admin/structure/block.
Find the regions you don't want to show. E.G., 'Sidebar A,' 'Sidebar B.'
'Configure' the blocks which appear in those regions. They will all have a 'Pages' tab at the bottom, and this is where you can configure which pages contain or exclude those blocks. You'd check 'All pages except those listed' and then put the path to your custom page.
HTH.
Answer: A good theme will have block-regions collapse (disappear) when there are no blocks in those regions.
So, every block which appears in those regions should be configured to not appear on the login page. This is a basic task with regard to configuring blocks, so, if you're not already familiar with how to define paths for block-display, you will easily find a handbook on drupal.org or many other guides or tutorials on the subject.


Best practices for setting Stratocaster pickup height?

Question: I recently bought my first stratocaster and after messing around with the heights of the pickups I've been having problems getting all three pickups to have the same volume.
I'm having trouble finding the sweet spot between equal volume & acceptable treble levels. As soon as I move the pickups closer to the strings the treble becomes quite problematic. Moving them further away results in a weaker and muddier sound.
Are there any best practices / commonly accepted rules on how single-coil pickups should be set as far as volume is concerned?
Comment: Depends on the type of pickups. Fender themselves explain it here: https://support.fender.com/hc/en-us/articles/212774786-How-do-I-set-up-my-Stratocaster-guitar-properly-
Answer: How to make better tone? / Pickup height secret!
1.3k upvote/45 downvote

Basically start at 2-3mm gap on bass side; 2mm gap on treble side.
ADDDENDUM ....
FENDER SAYS:
Set too high, pickups can cause myriad inexplicable phenomena. Depress all the strings at the last fret. Using a 6" (150 mm) ruler, measure the distance from the bottom of the first and sixth strings to the top of the pole piece. A good rule of thumb is that the distance should be greatest at the sixth-string neck pickup position, and closest at the first-string bridge pickup position. Follow the measurement guidelines in the chart below as starting points. The distance will vary according to the amount of magnetic pull from the pickup.
Bass Side   Treble Side
Texas Specials  8/64" (3.2 mm)  6/64" (2.4 mm)
Vintage style   6/64" (2.4 mm)  5/64" (2 mm)
Noiseless™ Series   8/64" (3.2 mm)  6/64" (2.4 mm)
Standard Single-Coil    5/64" (2 mm)    4/64" (1.6 mm)
Humbuckers  4/64" (1.6 mm)  4/64" (1.6 mm)
Lace Sensors    As close as desired (allowing for string vibration)
Comment: I've had problems with the middle pickup being too close to the strings for my picking style. I need more than 2mm on the treble side. Point being, this is good starting guidance but each player should work to figure out what is best for them.
Answer: I've always thought Strats sound best with a good gap. Too close & you can really hear the magnets getting in the way; strings will over-pitch more if you get too close at the low end - you hear the pitch fall slightly after the initial attack.
I've always gone with "If it falls off the thread you went half a turn too far, otherwise you're good to go" at the bass side. I balance the treble up to "same volume, by ear" after that.
Pretty much what the guy in the video on Randy's answer does, though I'd go even further. The further back, the sweeter it gets.
I do use heavy strings though, 10 - 52. I'd guess if you use skinny strings, you'd need to come a bit closer.


How to make the last part of this REGEX optional?

Question: I am looping through all the links on a page and matching their href values against the following pattern:
([^/]+)/([0-9]+)/([^/]+)

Problem is there are 2 types of link formats on the page:
1. /video/123/slug
2. /video/123

Number 1. gets captured fine with the above regex but the 2nd fails. I want to make the third piece of the regex (the slug) optional so that both link formats return true when matched agains the  regex. How to do this?
Answer: Put the last bit in brackets of a non-capturing group and add a ?:
([^/]+)/([0-9]+)(?:/([^/]+))?

Answer: Use ? quantifier, which makes your pattern optional. It matches either 0 or 1 occurrence of the pattern.
Also, you need to group the last slash, with your last part of your regex, in a non-capturing group.
([^/]+)/([0-9]+)(?:/([^/]+))?

Comment: Hi, what does the `?:` do in this expression? Thanks.
Comment: @thomas. That is for non-capturing group.
Comment: so putting `?:` at the beginning of any set of `()` will make the result unavailable to referencing what it captures later on? Does that mean that it is unnecessary? Is that the standard way to do it when you know you won't be referencing it later? Thanks much.
Comment: @thomas. Yes exactly that. It won't be captured in any group.
Comment: so it's just a way to save memory, or what?
Answer: If you add a ? that should make the last part of the pattern optional.


How to theme a node form from my custom module?

Question: I have a node type with machine name "resource", and I'm trying to theme it in my module "modulename".
I've tried doing this:
function modulename_theme() {
  return array(
    'resource_node_form' => array(
      'render element' => 'form',
      // 'template' => 'resource-node-form',
      // 'path' => drupal_get_path('module', 'modulename'),
    ),
  );
}

//I've tried both functions, getting nothing

function theme_resource_node_form($variables) {
  dsm($variables);
  return 'Testing';
}

function modulename_resource_node_form($variables) {
  dsm($variables);
  return 'Testing';
}

I've cleared cache, nothing happens. I've also tried with templating approach:
function modulename_theme() {
  return array(
    'resource_node_form' => array(
      //'render element' => 'form',
       'template' => 'resource-node-form',
       'path' => drupal_get_path('module', 'modulename'),
    ),
  );
}

And placing resource-node-form.tpl.php in modulename module folder. Cleared cache, nothing happens.
Sure I'm doing something wrong, but I can't figure it out. I've used templates for existing forms from a custom theme, but I'd like to do it this way, this time. Better approach for this project I'm working on, I think.
Thanks for your answers, ask me if you need more info!
Answer: Use this:
/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id) {

  switch ($form_id) {
    // Expected format: NODE_TYPE_MACHINE_NAME_node_form
    case 'resource_node_form':
      // Requires devel module to be installed.
      // See all available elements displayed using krumo.
      $dpm($form);
      break;
  }

}

Update:
Depending on the complexity of your layout, check Display Suite and Field Group modules, as their functionality might be what you need.
You can also follow up this article if you want to do this from a tpl file. The approach is similar to what you were trying to do.
Comment: Thanks for your answer, Topsitemakers! I've already done that to hide/show some fields, but I want to modify how the form gets printed. I want it to have two columns.
Comment: Answer updated.
Comment: Thanks Topsitemakers. I based my solution (the code I gave in my question) in that article, but it didn't work. Now I've tried again on a clean install, and it worked like a charm. So the error must be somewhere else in my site. If I find what's the problem, I'll come back here to comment. But I'll accept your answer, as it has worked on a clean install :) Thanks again.
Comment: Ok, in my hook_form_alter() I included a $form['#theme'] that created funny side effects. Thanks for all the answers!
Answer: Can you please try as following-
Go to your theme folder (used by your site) and create one new tpl file named as node-resource.tpl.php, then write your theming inside it.
May be it will help you.
For theming create node you can do as following-
node-resource-add.tpl.php
Comment: Hello Ankur, thanks for your answer! But wouldn't that be a template for the node? I want to theme the form that creates that node.
Comment: Check my updated answer.


How to make views header sticky while scrolling?

Question: I have created report using drupal views and i used views_merge_rows module. Now i wanted to create sticky header of report table. Can any one please help me.
Comment: u have used tables rite ?? under format in views
Comment: i have used table rowspan instead of views default table format using views_merge_rows module.
Answer:
Under the format in views select table.
Got to settings on table there will find the checkbox named Enable Drupal style "sticky" table headers (Javascript) . Enable it
In views preview u can see the sticky headers of the table.


How to show amount of energy usage in a gauge graph?

Question: I want to build a gauge graph where I can show if the current energy usage is high or low when compared to a previous period. The comparison would be shown as a percentage. So if the current usage is normal compared to a previous time set, the gauge graph is on 50%.
But, how to calculate this, without taking the high peaks that sometimes occur?
I could take the highest data amount in a time set and compare this to the current usage. So, for example, if I use 500W now and the highest peak in a time set is 800W the usage now is $\frac{500}{800} = 62.5\%$. But this is subject to distortion if I get a high peak for a few minutes because I turned on a heavy machine, and thus the percentage isn't valid anymore.
I was thinking about not comparing the current usage with the highest peak, but with the third quartile. What do you think of it?
Answer: If your readings are roughly normal, you can use mean and standard deviation as the benchmarks. That is, put the mean in the middle and highlight one or more standard deviations above and below it. Control Charts rely on the same concept, with more complicated limits.
If your readings are skewed, you might consider a transformation, such as plotting the quantile of each reading instead of the raw reading. That gives a linear scale with the median in the middle, but it may be too hard to interpret depending on your audience.


Ruby on Rails error - NoMethodError in Statuses#new

Question: I get this error NoMethodError in Statuses#new when I try to view a page in my app after I add the form field... I'm new to ruby on rails so am keen to be able to fully understand this...
<%= f.input :user_id %>

Here is the full error message:
NoMethodError in Statuses#new

Showing /Users/danlee/Projects/treebook/app/views/statuses/_form.html.erb where line #14 raised:

undefined method `user_id' for #<Status:0x007feb53cdd138>
Extracted source (around line #14):

11:

12:   <% end %>
13:
14:   <%= f.input :user_id %>
15:   <%= f.input :content %>
16:

17:     <%= f.button :submit %>
Trace of template inclusion: app/views/statuses/new.html.erb

Rails.root: /Users/danlee/Projects/treebook

Application Trace | Framework Trace | Full Trace
app/views/statuses/_form.html.erb:14:in `block in _app_views_statuses__form_html_erb__4012047659275744874_70324335923840'
app/views/statuses/_form.html.erb:1:in `_app_views_statuses__form_html_erb__4012047659275744874_70324335923840'
app/views/statuses/new.html.erb:3:in `_app_views_statuses_new_html_erb___64465850179705865_70324349236340'
app/controllers/statuses_controller.rb:29:in `new'
Request

Parameters:

None
Show session dump

Show env dump

Response

Headers:

None

Github repository for the app is here too: https://github.com/pixeljugglerdan/treebook
Answer: It looks like you haven't added the :user_id column to your statuses. This file isn't running any code in the #change method: https://github.com/pixeljugglerdan/treebook/blob/master/db/migrate/20120911210237_add_user_id_to_statuses.rb
You'll probably want to re-run the migration with something like:
class AddUserIdToStatuses < ActiveRecord::Migration
  def change
    add_column :statuses, :user_id, :integer
  end
end


Runtime of concatenating 2 lists in Python

Question: If I have 2 Python lists:
a = [1, 2, 3, 4, 5]
b = [6, 7, 8, 9, 10]

and I say:
print(a + b)

I get
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

What is Python doing behind the scenes to create this result? What is the Big O runtime of the operations it performs?
p.s. If this has been asked before or is available elsewhere online I couldn't find it
Comment: first a+b is done, which in python means concatenate the two lists. Then the concatenated list is printed. I don't know about the big O runtime of that list concat, but my guess is O(1)
Comment: With all due respect the fact it does a+b then prints the result is blindingly obvious... is it a for loop? a while loop? does it use list comprehension? I want to know the code behind the code and the runtime of that code
Comment: Oh well, you asked what's python doing behind the scenes for a print(a+b), I would edit the question to be more specific if the answer of @Mehrdad Pedramfar isn't specific enough
Answer: according to this Link:
There are two ways to do concatenating: you can use the append method or the concatenation operator (+).
The append method is "amortized" O(1)O(1). In most cases, the memory required to append a new value has already been allocated, which is strictly O(1)O(1). Once the C array underlying the list has been exhausted, it must be expanded in order to accomodate further appends. This periodic expansion process is linear relative to the size of the new array, which seems to contradict our claim that appending is O(1)O(1).
However, the expansion rate is cleverly chosen to be three times the previous size of the array; when we spread the expansion cost over each additional append afforded by this extra space, the cost per append is O(1)O(1) on an amortized basis.
On the other hand, concatenation is O(k)O(k), where kk is the size of the concatenated list, since kk sequential assignment operations must occur.


List of possible trichord/triad names

Question: I'm looking for the names that trichords can have.
I know chord naming and recognition is a complex dynamic, and context is important; but for now I'm only looking for names that are assigned to specific qualities of a trichord. Like "major triad" or "suspended 4th".
The ones I know:
Triads:

Minor
Major
Augmented
Diminished

Other trichords:

Suspended 2nd
Suspended 4th

Is there a name I'm missing?
Comment: [This page at wikibooks.org, with the title Complete List of Chord Patterns](http://en.wikibooks.org/wiki/Music_Theory/Complete_List_of_Chord_Patterns), might be of interest to you.
Comment: Also [this question](http://music.stackexchange.com/questions/12417/how-do-you-name-chords-in-20th-century-music-chords-stacked-in-intervals-other) is related, but perhaps not what you are looking for.
Answer: Here's a little algorithm using the music21 toolkit we developed at MIT.  The #s refer to the number of semitones above C.  It's a post-tonal context: enharmonic spelling is not taken into account:
     >>> for i in range(1,5):
     ...     for j in range(1+i, 9):
     ...         c = chord.Chord([0, i, j])
     ...         print "0,%d,%d: %s" % (i, j, c.commonName)

     0,1,2: chromatic trimirror
     0,1,3: phrygian trichord
     0,1,4: major-minor trichord
     0,1,5: incomplete major-seventh chord
     0,1,6: tritone-fourth
     0,1,7: tritone-fourth
     0,1,8: incomplete major-seventh chord
     0,2,3: minor trichord
     0,2,4: whole-tone trichord
     0,2,5: incomplete minor-seventh chord
     0,2,6: incomplete dominant-seventh chord
     0,2,7: quartal trichord
     0,2,8: incomplete half-diminished seventh chord
     0,3,4: major-minor trichord
     0,3,5: incomplete dominant-seventh chord
     0,3,6: diminished triad
     0,3,7: minor triad
     0,3,8: major triad
     0,4,5: incomplete major-seventh chord
     0,4,6: incomplete half-diminished seventh chord
     0,4,7: major triad
     0,4,8: augmented triad

0,3,8 is the major triad in first inversion.  0,2,5 it an incomplete minor seventh in third inversion.  0,1,8 is likewise a major-seventh in third inversion, while 0,4,5 is in second inversion. 0,2,6 is the dominant-seventh in third inversion minus the third, while 0,3,5 is in second inversion.
But most of these names are not standard.  They come from: Larry Solomon's "The List of Chords, Their Properties and Use in Analysis," in Interface, Journal of New Music Research , 1982, v11/2. Online list: http://vladimir_ladma.sweb.cz/english/music/structs/mus_rot.htm
Comment: see http://meta.music.stackexchange.com/questions/240/guitar-tab-plugin-jtab-should-be-active-only-in-questions-tagged-guitar
Comment: something seems to not be working the answer is not appearing.  View Source to see the list.  Or maybe someone can figure out why...
Comment: (Newer versions of music21 will answer in a tonal context for common chords.  For instance, "C E G" will give "major triad" and "C F-flat G" will give "enharmonic equivalent to a major triad")
Comment: Note that some of these are not Forte-style prime forms.  For instance, 038 (major triad [1st inversion]) and 047 (major triad, root position) can both be reduced in prime form to 037 (minor triad)
Answer: I think you have all the basics already.  :)
but then again...
I had a search based on SeuMenzes mention of quartal chords and It looks like it's called a Viannese trichord, according to wikipedia.
The problem with naming chords based on their quartal harmony, to me, is that they have to have been used enough to have a definition in themselves.  Perhaps a 20th century music expert can be clearer on this, but chords as standard are stacked in 3rds.  when you start using quartals you must also start considering chords stacked in 2nd's, 5ths, 6ths, 7ths, 9ths and so on and so fourth.  In fact, this topic merits a question in itself!
For chords with a non-standard pattern,  I believe you just get creative with the name, so for example a 1,b2 and 5 would be named be a susb2 chord.  1,b2,#5 could be an augmented susb2 chord.
I found out looking around the web that you can also get a sus2sus4 chord, (which contains 1 2 4 5).  It's not a triad, but it shows how non standard chords are usually just named based on what clearly describes them.
Related:
What determines a chord's name?
How do you name chords in 20th Century Music? (Chords stacked in intervals other than 3rds)
Answer: There is not much that I can think of by now, but  one could add the quartal trichord: notes stacked on perfect fourths, like C-F-Bb -- even though this could be an inversion of Bb(sus2), but with arguably different implications on overall sonority and voice-leading. The same applies to the open sus2 chord (take for example C-G-D), which has a unique sonority (harmonicizing the circle of fifths) but is also an inversion of both quartal chord and closed sus2 chord.
There are also trichords derived from modes, like the phrygian sus2 (think of it as a susb2, like in C-Db-G) and the lydian sus4 (something like sus#4, like in C-F#-G). Inversions of these trichords can be related to the locrian mode as well, and the inverted phrygian sus2 has been especially used in effect by Scriabin, becoming famous as his signature "mystic chord" (for instance, Db-G-C).

List of possible trichord/triad names