Is it possible that two Random Variables from the same distribution family have the same expectation and variance, but different higher moments?

Question: I was thinking about the meaning of location-scale family.
My understanding is that for every $X$ member of a location scale family with parameters $a$ location and $b$ scale, then the distribution of $Z =(X-a)/b$ does not depend of any parameters and it's the same for every $X$ belonging to that family.
So my question is could you provide an example where two random from the same distribution family are standardized but that does not results in a Random Variable with the same distribution?
Say $X$ and $Y$ come from the same distribution family (where with family I mean for example both Normal or both Gamma and so on ..).
Define:
$Z_1 = \dfrac{X-\mu}{\sigma}$
$Z_2 = \dfrac{Y-\mu}{\sigma}$
we know that both $Z_1$ and $Z_2$ have the same expectation and variance, $\mu_Z =0,  \sigma^2_Z =1$.
But can they have different higher moments?
My attempt to answer this question is that if the distribution of $X$ and $Y$ depends on more than 2 parameters than it could be. And I am thinking about the generalized $t-student$ that has 3 parameters.
But if the number of parameters is $\le2$ and $X$ and $Y$ come from the same distribution family with the same expectation and variance, then does it mean that $Z_1$ and $Z_2$ has the same distribution (higher moments)?
Comment: @Carl One parameter will suffice.
Comment: @Carl It's unclear what you mean by "same distribution."  Literally, that would refer to a unique distribution, with one law and therefore a unique expectation, unique variance, and unique moments (to the extent they are defined).  If you mean "same distribution *family*," then your remark is meaningless, because the family is whatever you define it to be.
Comment: Yes, they can. But, you would need at least 3 parameters in a generalized distribution.
Comment: @HardCore Since it seems you feel your question has been answered, please see [What should I do when someone answers my question?](https://stats.stackexchange.com/help/someone-answers)
Comment: @Carl I did upvote your answer too.  The OP's usage seems to support the notion of $Z=(X-a)/b$ as having the same standard distribution for all choices of $X$ in the family. Let's see which answer the OP accepts (if the OP ever reads Glen_b's comment and acts on it).
Comment: @DilipSarwate you are right, I did not specify it but  mean both $\mu$ and $\sigma$ finite
Comment: If you require two or fewer parameters, and are specifying a location-scale family, the two parameters will of necessity be the location and the scale.  Since you are requiring the same location and scale between the two distributions, that means the parameter values will be the same; if the distributions also have the same functional form, it must be that they are identical, since they have the same functional form and parameter values.  Since they are identical, all the higher moments will be the same as well.
Comment: The answer depends on the interpretation of
"... the distribution of $Z=(X−a)/b$ does not depend of any parameters and it's the same for every $X$ belonging to that family."
whether the "it's" means
"for _all_ $X$ in the family, the distribution of $(X-a)/b$ does not depend on $a$ and $b$"
**or**
"for all $X$ in the family, $(X-a)/b$ has the same distribution."
yyzz chose the latter interpretation but everyone else, including Moderator @whuber, prefers the former. Both interpretations have easy, but diametrically opposed, answers. It's unfair to call yyzz's answer incorrect; it is NOT.
Comment: @Carl, I do not get what your point is about the symmetric distributions (does that make it different?). I was pointing out to HC that already one of his examples (both normal, **both gamma** and so on) is a 2 parameter case the question was looking for. In your answer I neither see your point. To me it is difficult to read (e.g. it starts with a page long comment about downvoters) and I see not what your conclusion is about the distribution. For fixed $\mu$ we have just another example 2 parameter family: $$\dfrac{\beta}{2\alpha\Gamma\Big(1/\beta\Big)} \; e^{-\Big(|x|/\alpha\Big)^\beta}$$
Comment: @Carl, the gamma distribution is explicitly mentioned in the question *" (where with family I mean .. both Gamma and so on ..)"*. That is why I mention it. But certainly there are other flavors of this question and the family of generalized normal distributions with a specific fixed mean does the job if you think about symmetric distributions (the question is ambiguous about the fact whether it is about location-scale families ). Personally, I find the question about two parameter location-scale families the most interesting because that flavor of the question is not at all trivial.
Comment: @whuber The OP is asking about the same distribution, not different ones.
Comment: If $Z$ is a standard Cauchy random variable with density $\frac{1}{\pi(1+x^2)}, -\infty < x < \infty$, then $bZ+a = X$ is a scaled and displaced Cauchy random variable. The family $$\mathcal C(a,b) = \{X\colon X=a+bZ, Z~\text{standard Cauchy}, b\neq 0\}$$ is a location-scale family in the sense that you have defined it (the distribution of $\frac{X-a}{b}$ does not depend on $a$ or $b$ and is the same for all $a$ and $b$), but none of the random variables enjoys a mean or a variance.
Comment: @whuber To clarify, I mean distributions of the same form, before their parameters take values. For example, a normal distribution would have the form $\mathcal{N}(\mu,\sigma^2)$.
Comment: @DilipSarwate Agreed. Moreover, I feel that there is a more natural usage herein than "distribution family" and that is "distributions of the same form". For example, there are multiple distribution forms that are in the exponential family, so it can be too confusing to be natural. My answer relates to that, and is also not wrong despite downvotes. I have a problem with downvotes; they sometimes tend toward uninspired narrowness.
Comment: @DilipSarwate I very much appreciate your most broadminded contribution, would that it be shared.
Comment: @HardCore $Z_1$ and $Z_2$ will not be the same when $X$ and $Y$ are both Gamma (but with different shape parameter $k$).
Comment: @MartijnWeterings Indeed, $\mu$ is generally a location parameter, and gamma distributions, without generalizing them, do not have location parameters as well as, without generalization. being defined only on $[0,\infty)$. As per my answer below, the question, without generalization, only pertains to symmetric distributions.
Comment: @MartijnWeterings Your post shows a shape and scale parameter distribution without a location parameter. If you want to convert a generalization of the gamma distribution to be a generalized, symmetric normal distribution with shape, scale and location parameters you would do it as [follows](https://stats.stackexchange.com/a/331966/99274). How does that relate to the question, which is about location and scale parameter distributions? The gamma distribution without generalization does not fit in with the rest of the question as it is a scale and shape parameter containing distribution.
Answer: If you want an example which is an "officially named parameterized distribution family, you can look into the generalized gamma distribution, https://en.wikipedia.org/wiki/Generalized_gamma_distribution.  This distribution family has three parameters, so you can fix mean and variance and still have freedom to vary higher moments.  From the wiki page, the algebra do not look inviting, I would rather to do it numerically.  For statistical applications, search this site for gamlss, which is an extension of gam (generalized additive models, in itself a generalization of glm's) which have parameters for "location, scale and shape".
Another example is the $t$-distributions, extended to be a location-scale family. Then the third parameter will be the degrees of freedom, which will wary the shape for a fixed location and scale.
Comment: Thank you very much for your answer!! I choose Carl's one because it was more detailed but this was fine too .. thank you very much !!!
Comment: Although the [generalized error distribution](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.542.879&rep=rep1&type=pdf) may have been a better choice.
Answer: There is an infinite number of distributions with mean zero and variance one, hence take $\epsilon_1$ distributed from one of these distributions, say the $\mathcal{N}(0,1)$, and $\epsilon_2$ from another of these distributions, say the Student's $t$ with 54 degrees of freedom rescaled by $\sqrt\frac{1}{3}$ so that its variance is one, then
$$X=\mu+\sigma\epsilon_1\qquad\text{and}\qquad Y=\mu+\sigma\epsilon_2$$
enjoy the properties you mention. The "number" of parameters is irrelevant to the property.
Obviously, if you set further rules to the definition of this family, like stating for instance that there exists a fixed density $f$ such that the density of $X$ is $$\frac{1}{\sigma^d} f(\{x-\mu\}/\sigma)$$ you may end up with a single possible distribution.
Comment: I think it does because if the family of distributions is defined by the reunion of both the distributions of the $X$'s and the $Y$'s, then you have a contradiction to the property. A "family" of distributions is quite a vague notion.
Comment: Hard Core, you seem to confuse the *name* of a family with its *concept*.  This answer is a fine one and nicely illustrates the concept.  Your question doesn't ask that the solution be a location-scale family.  If you need it to be one, you can always take this answer--or any other answer--and prolong it to a location-scale family by allowing arbitrary translations and rescalings.  Xi'an's point about the number of parameters still holds.
Comment: thank you for the answer but I think that this is not what I asked
Comment: yes in fact is quite vague but if you read my question I wrote that in this context with family I mean for example both Normal or both Gamma and so on .. You made an example with one normal and one t student
Comment: @whuber I think it is confused as an answer. Student's-t by itself would be a better answer, rather than use the extreme answer of $df=3,\infty$ and not specify it. Indeed, it is $df$ which is the third parameter.
Comment: Why are you using a normal distribution when that is Student's-t with $df=\infty$. Then you are comparing that with $df=54$, which is almost indistinguishable from normal. Not especially good example.
Comment: @whuber I disagree because a normal distribution is Student's-t with $df=\infty$, or in more formal language a normal distribution is a limiting case of a Student's-t. Alternatively, Student's-t is a generalization of a normal distribution. So, either we are comparing the same Student's-t with the shape parameter, i.e., $df$, having different values, or we are comparing two different distributions. In either case, we are not satisfying the OP as this is not an answer to the question he asked.
Answer: There is apparently some confusion as to what a family of distributions is and how to count free parameters versus free plus fixed (assigned) parameters. Those questions are an aside that is unrelated to the intent of the OP, and of this answer. I do not use the word family herein because it is confusing. For example, a family according to one source is the result of varying the shape parameter. @whuber states that A "parameterization" of a family is a continuous map from a subset of ℝ$^n$, with its usual topology, into the space of distributions, whose image is that family. I will use the word form which covers both the intended usage of the word family and parameter identification and counting. For example the formula $x^2-2x+4$ has the form of a quadratic formula, i.e., $a_2x^2+a_1x+a_0$ and if $a_1=0$ the formula is still of quadratic form. However, when $a_2=0$ the formula is linear and the form is no longer complete enough to contain a quadratic shape term.  Those who wish to use the word family in a proper statistical context are encouraged to contribute to that separate question.
Let us answer the question "Can they have different higher moments?". There are many such examples. We note in passing that the question appears to be about symmetric PDFs, which are the ones that tend to have location and scale in the simple bi-parameter case. The logic: Suppose there are two density functions with different shapes having two identical (location, scale) parameters. Then there is either a shape parameter that adjusts shape, or, the density functions have no common shape parameter and are thus density functions of no common form.
Here, is an example of how the shape parameter figures into it. The generalized error density function and here, is an answer that appears to have a freely selectable kurtosis.

By Skbkekas - Own work, CC BY-SA 3.0, https://commons.wikimedia.org/w/index.php?curid=6057753
The PDF (A.K.A. "probability" density function, note that the word "probability" is superfluous) is $$\dfrac{\beta}{2\alpha\Gamma\Big(\dfrac{1}{\beta}\Big)} \; e^{-\Big(\dfrac{|x-\mu|}{\alpha}\Big)^\beta}$$
The mean and location is $\mu$, the scale is $\alpha$, and $\beta$ is the shape. Note that it is easier to present symmetric PDFs, because those PDFs often have location and scale as the simplest two parameter cases whereas asymmetric PDFs, like the gamma PDF, tend to have shape and scale as their simplest case parameters. Continuing with the error density function, the variance is $\dfrac{\alpha^2\Gamma\Big(\dfrac{3}{\beta}\Big)}{\Gamma\Big(\dfrac{1}{\beta}\Big)}$, the skewness is $0$, and the kurtosis is $\dfrac{\Gamma\Big(\dfrac{5}{\beta}\Big)\Gamma\Big(\dfrac{1}{\beta}\Big)}{\Gamma\Big(\dfrac{3}{\beta}\Big)^2}-3$. Thus, if we set the variance to be 1, then we assign the value of $\alpha$ from $\alpha ^2=\dfrac{\Gamma \left(\dfrac{1}{\beta }\right)}{\Gamma \left(\dfrac{3}{\beta }\right)}$ while varying $\beta>0$, so that the kurtosis is selectable in the range from $-0.601114$ to $\infty$.
That is, if we want to vary higher order moments, and if we want to maintain a mean of zero and a variance of 1, we need to vary the shape. This implies three parameters, which in general are 1) the mean or otherwise the appropriate measure of location, 2) the scale to adjust the variance or other measure of variability, and 3) the shape. IT TAKES at least THREE PARAMETERS TO DO IT.
Note that if we make the substitutions $\beta=2$, $\alpha=\sqrt{2}\sigma$ in the PDF above, we obtain $$\frac{e^{-\frac{(x-\mu )^2}{2 \sigma ^2}}}{\sqrt{2 \pi } \sigma }\;,$$
which is a normal distribution's density function. Thus, the generalized error density function is a generalization of the normal distribution's density function. There are many ways to generalize a normal distribution's density function. Another example, but with the normal distribution's density function only as a limiting value, and not with mid-range substitution values like the generalized error density function, is the Student's$-t$ 's density function.  Using the Student's$-t$ density function, we would have a rather more restricted selection of kurtosis, and $\textit{df}\geq2$ is the shape parameter because the second moment does not exist for $\textit{df}<2$. Moreover, df is not actually limited to positive integer values, it is in general real $\geq1$. The Student's$-t$ only becomes normal in the limit as $\textit{df}\rightarrow\infty$, which is why I did not choose it as an example. It is neither a good example nor is it a counter example, and in this I disagree with @Xi'an and @whuber.
Let me explain this further. One can choose two of many arbitrary density functions of two parameters to have, as an example, a mean of zero and a variance of one. However, they will not all be of the same form. The question however, relates to density functions of the SAME form, not different forms. The claim has been made that which density functions have the same form is an arbitrary assignment as this is a matter of definition, and in that my opinion differs. I do not agree that this is arbitrary because one can either make a substitution to convert one density function to be another, or one cannot. In the first case, the density functions are similar, and if by substitution we can show that the density functions are not equivalent, then those density functions are of different form.
Thus, using the example of the Student's$-t$ PDF, the choices are to either consider it to be a generalization of a normal PDF, in which case a normal PDF has a permissible form for a Student's$-t$'s PDF, or not, in which case the Student's$-t$ 's PDF is of a different form from the normal PDF and thus is irrelevant to the question posed.
We can argue this many ways. My opinion is that a normal PDF is a sub-selected form of a Student's$-t$ 's PDF, but that a normal PDF is not a sub-selection of a gamma PDF even though a limiting value of a gamma PDF can be shown to be a normal PDF, and, my reason for this is that in the normal/Student'$-t$ case, the support is the same, but in the normal/gamma case the support is infinite versus semi-infinite, which is the required incompatibility.
Comment: (-1) As has been stated in other comments, the issue is "what does a distribution family mean?". I can easily define a new "family" of distributions that are simply rescaled t-distributions to have mean = 0, sd = 1, with a single parameter: df. Then the 1st and 2nd moments are equal for all df, but  for different values of df, they have different higher moments.
Comment: Hard Core, that comment is difficult to fathom, given that your title itself contains the word "family"!  Moreover, if you deny that a family is meaningful, then the question makes no sense.  Please clarify by editing your question to reflect your intentions.
Comment: -1 because you start by saying "The answer is NO." and then proceed to give an example that effectively answers Yes (another example is given in kjetilbhalvorsen's answer that you favourably mention). This does not make sense to me. I think the math here is clear to all of us, so my downvote is only for the lack of consistency in presentation.
Comment: Thank you. Clearly you have a good conception of what you're writing about, but unfortunately your post propagates quite a bit of confusion about what the meanings of "distribution," "shape," "form," and "parameter" might be. As one example of the subtleties, consider a family of distributions created by any distribution law $F$ that has nonzero third central moment. The family is indexed by two real numbers $(\mu,\sigma\ne 0)$ and consists of all laws $x\to F(\sigma x+\mu)$. It is a location-scale family, but the shapes of these laws differ depending on the sign of $\sigma$.
Comment: Carl, there is a stark inconsistency between the question and Hard Core's comments.  The question is explicit: to "provide an example where two random [variables] from the same distribution family are standardized but that does not result in ... Random Variable[s] with the same distribution." Obviously some meaning of "family" is intended. The usual meaning is clear, despite there being various technical variants around, and the (easily demonstrated) correct answer is "yes, there are many such examples."
Comment: @CliffAB Just because you assign a value to a parameter does not mean that I will stop counting it as a parameter. You stopped counting it, I did not. I grant you that in the way you are counting, free parameters only, that you are correct. However, I strongly suggest that a distribution has the form of that distribution no matter what parameter values are assigned. You may choose to misunderstand what I am saying, that does not change what I have said.
Comment: @CliffAB For example, your definition of counting free parameters, only, would suggest that a standard normal distribution is not of the same form as an ordinary normal distribution. My method of counting parameters would suggest that a standard normal distribution has the form of a normal distribution. Which definition is more correct is not actually in question, I choose the latter and my exposé should be understood in that context.
Comment: I think there are sufficiently clear definitions available that confusion is not inevitable.  A little Googling suggests there are several variant meanings of many of these terms.  As an example, some people limit "location-scale" families to those with *only* a location and a scale parameter, whereas others (at least implicitly) allow for other parameters to be present too.  I don't think that reflects any deep-seated confusion: most likely it is determined by the applications people have in mind.  Similarly, differences arise constituting just what a valid "family" of distributions is.
Comment: There is a pervasive abuse of terminology.  A *distribution* is the probability law of a random variable, say $X$. The *distribution function* of $X$ is given by $F_X(x)=\Pr(X\le x)$ for all $x\in\mathbb{R}$. A *statistical model* for $X$ posits that $F_X$ is some element of a specified mathematical set of distributions: this is the broadest sense in which "family" of distributions is understood. Many statistical authors (ab)use the word "distribution" to refer to such a family, such as "the [*sic*] normal distribution." Parameters are subtler. Technically, there is a natural topology on ...
Comment: ... the set of all distributions. A "parameterization" of a family is a continuous map from a subset of $\mathbb{R}^n$, with its usual topology, into the space of distributions, whose image is that family. One and the same family can have different parameterizations. Locally, a parameterization should be one-to-one (but it might not be so globally). The upshot is that "family" is not a redundancy and one needs to be clear about the meaning and use of a parameterization.
Comment: ok thank you very much for looking into this. So your answer confirms my initial guess that it depends on the number of parameters!!! thank you
Comment: I believe your objection is that I just had to make up a new "family" of distributions for this example. But that's just a side effect of people trying to parameterize distributions using useful notation: most of the time, we care first about 1st moments, then about 2nd moments, etc. That's why most of the classic families require 3 parameters before we can fix the 1st and 2nd moment while having different higher moments. But that's a matter of coming up with convenient notation rather than a fundamental property of families of distributions.
Comment: Listen guys ... FAMILY of distribution does not mean anything ... FAMILY has no precise meaning in statistics, hence it is pointless that you keep saying: "i can define a family in this o that way ..." ... Because I was very well aware that the word FAMILY could have been misinterpreted  I specified in my question that "with family I mean for example both Normal or both Gamma and so on .." So Carl is the only one who gave an answer to my question ...The other ones answered the obvious question(not mine though) "does same expectation and variance mean same distribution?" .. that's what i think
Comment: I see. I have removed my downvote. I suspect that other downvotes were also provoked by the same sentence.
Comment: @Carl, why are you avoiding to clarify? You point to google for the definition of 'form' and add a sentence that makes no sense. If it is so simple then why not add a definition? It is mathematics, not art, being more precise is not a luxury.
Comment: I think you're missing the point of @X'ian's answer, which has nothing to do with convergence of Student's t-distributions to normal distributions with increasing degrees of freedom; but rests on the basis that you can define a family to include any two distributions you like. A parametric family to boot: a mixture of the two parametrized by weight does the job.
Comment: @Carl: by that reasoning, the exponential distribution is (at least) a three parameter distribution, as it is a special case of the generalized gamma distribution.
Comment: @CliffAB By that reasoning, it would not be possible to generalize an exponential distribution. In fact, two, three, or four parameter gamma distributions are a subset of possible generalizations of an exponential distribution. There is no contradiction here. All information is context dependent.
Comment: Thank-you very much. I would not have answered myself if I thought someone else was actually paying attention to what you asked. The excess downvotes I got were, I agree, because of confusing the meaning of the question with how it needed to be answered.
Comment: @whuber Obviously, there are some language difficulties here. They do not seem to bother me, or HardCore. I know what he means, he knows that I know, but lots of other people apparently do not. Can you suggest language that explains the question and does not incite? I used the expression "of the same form" which is more math-like. Got any suggestions, please? I do not like downvotes that I cannot address that do not appear to go to substance.
Comment: @amoeba I had another question in mind. However, I changed it to be the question you have in mind. You are not a mind reader, I suppose.
Comment: @whuber see above. Also, I changed my answer to what you suggested. Thanks for the suggestion.
Comment: @whuber As it would be for most asymmetric distribution I should think. However, a shape parameter, as is present for example in a gamma distribution, would not be present in a lognormal distribution. The two parameters μ  and σ are not location and scale parameters for a lognormally distributed random variable X, but they are respectively location and scale parameters for the normally distributed logarithm ln(X). So yes, it gets confusing. However, is this confusion mine, or does it come with the territory?
Comment: @whuber thanks for your comment ... I deny that the word family is meaningful because it is not .. And because of that I specify what I mean by saying family ..Honestly I don't know how to refer to a set of random variables e.g. all lognormal but with different parameters. Hence I used the expression "same distribution family" specifying what I mean. If you know a more formal way to state my answer I will gladly modify it. I did not mean  to argue I just wanted to discuss it with all of you guys. Thank you.
Comment: @whuber When I use the terms location, scale and shape, I use them as per the linked references. The answer I have given is either flawed or it isn't. If it is flawed, then I would solicit help in rectifying it, as Amoeba did, thank you, Amoeba. In that it is not, it would require, IMHO, a much more lengthy answer than I have already given, and that would be off topic. Consider, for example, MVUE location, and how complicated that is. Scale is even worse, as it is generally not one-one to variance, it is however, a metric. Shape is the worst, defining shape is very tricky....
Comment: @whuber When we use the phrase "distribution family" the word "family" I take to be redundant. For example, when we say gamma distribution, we are generally referring to an $f(x|\alpha,\beta)$ and not a form with substituted parameters like $f(x|\sqrt{2},\pi)$.  I use the concept of form of a formula to specify an $f(x|\dots)$ because it is neither redundant nor ambiguous. Need your help, here. Tell me a bit more explicitly what the problem is, please.
Comment: @whuber I do not fully understand 'A "parameterization" of a family is a continuous map from a subset of $\mathbb{R}^n$, with its usual topology, into the space of distributions, whose image is that family. ' so I cannot use it. See text.
Comment: Your definition of 'form' is very indirectly relating to location-scale family. You say that a substitution like $x = z + a$ must preserve the form (e.g. a translated quadratic function is still a translated quadratic function, but a translated sin function is not always another sin function). It is a bit arbitrary, and in your answer very unclear, that a 'form' is defined in this way or why a 'form' needs to have this property.
Comment: You seem to mean that a 'form' is any (single) shape and all of it's scaled and translated variants. In this way it becomes a bit of a tautology that a 'form' is only defined by two parameters since you put it explicitly in the definition. But the question, mentioning for instance 'Gamma', seems to be more ambiguous about this definition of family and it differs from your form. If you substitute $x = z + \pi/2$ in a Gamma distributed variable then you do *not* obtain another Gamma distributed variable.
Comment: Would the following pdf not be a 'form' according to your definitions?
(since the variables distributed according to it are closed under scaling and translation)

$$f(x;a,b) = \begin{cases}
 \vert b \vert e^{-b(x-a)}  & \text{if $(b>0$ and $x \geq a)$ or $(b<0$ and $x \leq a)$} \\
 0  & \text{if $(b>0$ and $xa)$}
\end{cases}$$

For any $X$ that is distributed according to the above distribution, a shifted and scaled $(X+s_1)/s_2$ would also be distributed according to the above distribution (but with other parameters $a$ and $b$).
Comment: @MartijnWeterings *One* uses the third person for politeness. A gamma distribution has no location parameter.  Its numerical location depends on form of the generalization of the gamma distribution one invents that [does have](https://reference.wolfram.com/language/ref/GammaDistribution.html) a location parameter, e.g., for proportional to

$(x-\mu )^{\alpha  \gamma -1} e^{-\left(\frac{x-\mu }{\beta }\right)^{\gamma }}$ for $x>\mu$ and otherwise zero, the ordinary gamma distribution would be viewed as having a location particular to that generalization.
Comment: @MartijnWeterings In other words, the location for a gamma distribution is ambiguous until one of an unknown number of generalizations is chosen the simplification of which is a gamma distribution and whose location is inherited from that particular generalized gamma distribution as a property assigned by the form of that generalization.
Comment: @MartijnWeterings The same applies to the exponential distribution which has at least two published generalizations with location parameters where each is of different form and would imply different location values (i.e., different constant values of location and not location parameters) for each respective simplification to an exponential distribution, where an exponential distribution has no location parameter *per se*.
Comment: Sure, the gamma distribution doesn't have a location parameter unless you speak about a generalized gamma distribution with additional location parameter. I don't believe that I said anything against that. So @Carl, how is that a reply to my comments? It doesn't define 'form' further, or explain why you use a vague esoteric term instead of the OP's term family.
Comment: @MartijnWeterings "form of an equation" as an exact phrase appears on Google 7,220,000 times. To call "form" exotic would require that the word "formula" be super exotic. The examples furnished show how a single form(ula) lacking a location parameter does not imply a unique family of curves of a more complicated form(ula) having a location parameter and that one cannot change location by substitution of a location implying form(ula) into a form(ula) lacking a location parameter with uniqueness, which was posited as trick questions for some indecipherable reason.
Comment: @MartijnWeterings "[Forma](http://latindictionary.wikidot.com/noun:forma)" is the  Latin root for [form](https://www.merriam-webster.com/dictionary/form). It has a meaning that is rather general and becomes more specific only in specific contexts.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/85895/discussion-between-carl-and-martijn-weterings).
Comment: @Scortchi OP used the word family to imply a restricted context better relating to form than more complicated functional substitutions. X'ian's answer is correct for families having different forms. People tend to either ferret out intended meaning or literal context. I.m.h.o. the former make for better tutors and reviewers, and the latter for better teachers and coauthors.
Comment: (1) Nevertheless, the discussion of convergence appears to be countering a claim that no-one's made. (2) How do you decide whether two density functions are of the same form? Why hasn't $f_X(x) =\frac{1}{\sqrt{2\pi}}\exp\left(\frac{-x^2}{2}\right)$ the same form as $f_Y(y) =\frac{\Gamma\left(\frac{55}{2}\right)}{\sqrt{\frac{54\pi}{3}}\cdot\Gamma(27)}\left(1+\frac{3y^2}{54}\right)^\frac{-55}{2}$? Has $f_X(x) = 1$ for $0\leq x \leq 1$ the same form as $f_Y(y) = \frac{1}{\pi\sqrt{y(1-y)}}$ for $0\leq y \leq 1$? You've introduced the term "form" but not defined it.
Comment: @Scortchi When you "transform" you change forms. Incorrect usage would be "$4x+2\sqrt{x}+1$ has the form of a quadratic $4z^2+2z+1$," and correct usage would be "We can write $4x+2\sqrt{x}+1$ in quadratic form by making the substitution (read as transformative) $x=z^2$.
Comment: I can't see how that leads to a definition of "form", or how you're applying the concept to density functions. Could you perhaps illustrate it with the examples I provided?
Comment: @Scortchi In my opinion, the two examples you have mentioned do not have the same form. Consider them as infinite series expansions and observe the complicated lack of agreement between those series. Indeed, there is no transform that that equates them, and even transforms, when available, do not, except in the trivial case or in isolated cases, relate forms, they relate transforms. For example, the substitution $x=z$ is the identity transform, the one that maintains form. The substitution $x=\frac{z-\mu}{\sigma}$ may conserve form, or maybe not, depending.
Comment: @Scortchi For example, $x=z-1$ as a transform is conservative of quadratic form, e.g.,  $x^2+x+1\to z^2 -z +1$, that is, although coefficients have changed, the variable powers have not changed. Counter example, $x=z+\frac{\pi}{2}$ would not conserve form for $\sin(x)\to\cos(z)$ because the infinite series expansion of sine is odd and that of cosine is even.
Answer: I think you are asking whether two random variables coming from the same location-scale family can have the same mean and variance, but at least one different higher moment. The answer is no.
Proof: Let $X_1$ and $X_2$ be two such random variables. Since $X_1$ and $X_2$ are in the same location-scale family, there exist a random variable $X$ and real numbers $a_1>0, a_2>0, b_1, b_2$ such that $X_1 \stackrel{d}{=} a_1 X + b_1$ and $X_2 \stackrel{d}{=} a_2 X + b_2$. Since $X_1$ and $X_2$ have the same mean and variance, we have:

$E[X_1] = E[X_2] \implies a_1 E[X] + b_1 = a_2 E[X] + b_2$.
$\operatorname{Var}[X_1] = \operatorname{Var}[X_2] \implies a_1^2 \operatorname{Var}[X] = a_2^2 \operatorname{Var}[X]$.

If $\operatorname{Var}[X] = 0$, then $X_1=E[X_1]=X_2=E[X_2]$ with probability $1$, and hence the higher moments of $X_1$ and $X_2$ are all equal. So we may assume that $\operatorname{Var}[X] \neq 0$. Using this, (2) implies that $|a_1|=|a_2|$. Since $a_1>0$ and $a_2>0$, we have in fact that $a_1=a_2$. In turn, (1) above now implies that $b_1=b_2$. We therefore have that:
$$
E[X_1^k] = E[(a_1X+b_1)^k] = E[(a_2X+b_2)^k] = E[X_2^k],
$$
for any $k$, i.e., all moments of $X_1$ and $X_2$ are all equal.
Comment: @Carl After re-reading this answer, I need to retract my original assessment: this answer is correct (and +1 for that), *and it is correct because it clearly explains how it is interpreting the original question.* (Specifically, there is a common yet narrow concept of a "location-scale family" as consisting of just a *single* standard distribution along with all its translates and positive rescalings.)  I believe the original question was intended to ask something a little different; the basis of that belief is the reference to more than two parameters in the post.
Comment: @Carl This answer is incorrect--that's why it's being downvoted.  Xi'an has already provided a counterexample.
Comment: I am sorry if I have not been very clear and I thank you for the time you have spent for looking into this but that is not what I asked.
Comment: (+1) I cannot find fault with this answer. Apparently someone does, and they also find fault with mine. I do not understand this unexplained behaviour.
Comment: @whuber Please see my comments under Xi'an's answer. I do not agree with him but did not downvote because both he and you have a right to your opinion, even if I consider it to be incorrect.
Comment: @Martijn We're suffering from a badly phrased question, so making one's interpretation clear is important.  I am focusing on the final statement, "But if the number of parameters is ≤2 and X and Y come from the same distribution family with the same expectation and variance, then does it mean that Z1 and Z2 has the same distribution (higher moments)?"  That makes no reference to location-scale families. The answer to it is a definite no. If it were to be modified to stipulate that it is a location-scale family, then the answer is yes, *assuming* a standard meaning of "parameter."
Comment: @whuber I congratulate you on your largess over a solitary interpretative approach. I wish this were more common.
Answer: Since the question can be interpreted in multipe ways I will split this answer into two parts.

A: distribution families.
B: location-scale distribution families.

The problem with case A can be easily answered/demonstrated by many families with a shape parameter.
The problem with case B is more difficult since one and a half parameters seem to be sufficient to specify location and scale (location in $\mathbb{R}$ and scale in $\mathbb{R_{>0}}$), and the problem becomes whether two parameters can be used to encode (multiple) shapes in addition as well. This is not so trivial. We can easily come up with specific two parameter location scale families and demonstrate that you do not have different shapes, but it does not proof that this is a fixed rule for any two parameter location scale family.
A: Can two different distributions from the same 2 parameter distribution family have the same mean and variance?
The answer is yes and it can already be shown using one of the explicitly mentioned examples: the normalized Gamma distribution
Family of normalized gamma distributions
Let $Z = \frac{X-\mu}{\sigma}$ with $X$ a Gamma distributed variable. The (cumulative) distribution of $Z$ is as below:
$$F_Z(z;k) = \begin{cases} 0  & \quad \text{if} & z < -\sqrt{k}\\
 \frac{1}{\Gamma(k)} \gamma(k, {z\sqrt{k}+k}) & \quad \text{if} & z \geq -\sqrt{k} \end{cases} $$
where $\gamma$ is the incomplete gamma function.
So here it is clearly the case that different $Z_1$ and $Z_2$ (distributions from the family of normalized gamma distributions) can have same mean and variance (namely $\mu=0$ and $\sigma=1$) but differ based on the parameter $k$ (often denoted 'shape' parameter). This is closely linked to the fact that the family of gamma distributions is not a location-scale family.
B: Can two different distributions from the same 2 parameter location-scale distribution family have the same mean and variance?
I believe that the answer is no if we consider only smooth families (smooth: a small change in the parameters will result in a small change of the distribution/function/curve). But that answer is not so trivial and when we would use more general (non-smooth) families then we can say yes, although these families only exist in theory and have no practical relevance.
Generating a location-scale family from a single distribution by translation and scaling
From any particular single distribution we can generate a location-scale family by translation and scaling. If $f(x)$ is the probability density function of the single distribution, then the probability density function for a member of the family will be
$$f(x;\mu,\sigma) = \frac{1}{\sigma}f(\frac{x-\mu}{\sigma})$$
For a location-scale family that can be generated in such way we have:

for any two members $f(x;\mu_1,\sigma_1)$ and $f(x;\mu_2,\sigma_2)$ if their means and variances are equal, then $f(x;\mu_1,\sigma_1) = f(x;\mu_2,\sigma_2)$

Can for all two parameter location-scale families their member distributions be generated from a single member distribution by translation and scaling?
So translation and scaling can convert a single distribution into a location-scale family. The question is whether the reverse is true and whether every two parameter location-scale family (where the parameters $\theta_1$ and $\theta_2$ do not necessarily need to coincide with the location $\mu$ and scale $\sigma$) can be described by a translation and scaling of a single member from that family.
For particular two parameter location-scale families like the family of normal distributions it is not too difficult to show that they can be generated according to the process above (scaling and translating of single example member).
One may wonder whether it is possible for every two parameter location-scale family to be generated out of a single member by translation and scaling. Or a conflicting statement: "Can a two parameter location-scale family contain two different member distributions with the same mean and variance?", for which it would be necessary that the family is a union of multiple subfamilies that are each generated by translation and scaling.
Case 1: Family of generalized Students' t-distributions, parameterized by two variables
A contrived example occurs when we make some mapping from $R^2$ into $R^3$ (cardinality-of-mathbbr-and-mathbbr2) which allows the freedom to use two parameters $\theta_1$ and $\theta_2$ to describe a union of multiple subfamilies that are generated by translation and scaling.
Let's use the (three parameter) generalized Student's t-distribution:
$f(x;\nu,\mu,\sigma) =  \frac{\Gamma \left( \frac{\nu + 1}{2} \right) }{\Gamma \left( \frac{\nu}{2} \right) \sqrt{\pi\nu}\sigma} \left(1 + \frac{1}{\nu} \left( \frac{x-\mu}{\sigma} \right)^2 \right)^{-\frac{\nu+1}{2}}$
with the three parameters changed as following
$$\begin{array}{rcl}
\mu &=& \tan (\theta_1)\\
\sigma &=& \theta_2\\
\nu &=& \lfloor 0.5+\theta_1/\pi \rfloor
\end{array}$$
then we have
$f(x;\theta_1,\theta_2) =  \frac{\Gamma \left( \frac{\lfloor 0.5+\theta_1/\pi \rfloor + 1}{2} \right) }{\Gamma \left( \frac{\lfloor 0.5+\theta_1/\pi \rfloor}{2} \right) \sqrt{\pi\lfloor 0.5+\theta_1/\pi \rfloor}\theta_2} \left(1 + \frac{1}{\lfloor 0.5+\theta_1/\pi \rfloor} \left( \frac{x-\tan(\theta_1)}{\theta_2} \right)^2 \right)^{-\frac{\lfloor 0.5+\theta_1/\pi \rfloor+1}{2}}$
which may be considered a two parameter location-scale family (albeit not very useful) that can not be generated by translation and scaling of only a single member.
Case 2: Location-scale families generated by negative scaling of a single distribution with nonzero skew
A less contrived example, than using this tan-function, is given by Whuber under the comments of Carl's answer. We can have a family $x \mapsto f(x/b + a)$ where flipping the sign of $b$ keeps the mean and variance unchanged but possibly changing the uneven higher moments. So this gives a bit more easily a two parameter location-scale family where members with the same mean and variance can have different higher order moments. This example from Whuber can be split into two subfamilies each of which can be generated out of a single member by translation and scaling.
Smooth families
If we try to make a single smooth two parameter distribution family (smooth: a small change in the parameters will result in a small change of the distribution/function/curve) by somehow making a composition of two or more families that are generated by translation and scaling, then we get into problems to have the two parameters cover both the variation of 'mean' and 'variance', as well as the third parameter 'shape'. A formal proof will have to go along the same lines as the answer to the question: Is there a smooth surjective function $f:\mathbb{R}^2 \mapsto \mathbb{R}^3$? (where the answer is no in the case of smooth, ie. infinitely differentiable, functions although there are continuous functions that would do the job such as Peano curves).
Intuition: Imagine there would be some parameters $\theta_1$, $\theta_2$ that describe the distributions in some location-scale distribution family and by which we can change the mean and variance as well as some other moments, then we should be able to express $\theta_1$, $\theta_2$, in terms of the mean $\mu$ and variance $\sigma$
$$\begin{array}{rcl} \theta_1 &= &f_{\theta_1}(\mu,\sigma) \\
\theta_2 &=& f_{\theta_2}(\mu,\sigma)\end{array}$$
but these need to be multiple valued functions and these can not make continuous transitions, the different values from $f_{\theta_1}(\mu,\sigma)$ for a particular $\mu$ and $\sigma$ are not continuous, and will not be able to model a continuous shape parameter.
I am actually not so sure about this final part. We could possibly use a space-filling curve (such as the Peano curve, if only we knew how to express coordinates on the curve to coordinates of the hypercube) to have a single parameter $\theta_1$ completely model multiple features like mean and variance, without giving up the property that a small change of the parameter $\theta_1$ is equivalent to a small change of the function $f(x;\theta_1)$ at every $x$
Comment: I'm not objecting to simplicity or the language, but to the confusion that is being sown. The problem with your $R^2\to R^3$ map points out why you need to impose additional mathematical structure--a suitable topology--on the family.  Allowing the distributions to change in such a (violently) discontinuous manner with $\theta$ is not only impractical and meaningless, it would likely invalidate useful methods and theorems for no good reason. For instance, MLE is almost always performed under the assumption that the distribution varies with $\theta$ in a piecewise differentiable manner.
Comment: I stopped reading after the initial definitions because they are so unclear and contradictory.  By "integrate" you of course mean integration *over $x$ only.*  By "$f,$" though, you *must* mean the CDF and not the PDF, because the division by $b\ne 1$ changes the integral.  By not imposing any restrictions on how $f$ can vary with $\theta$ you also adopt a much broader concept of "family" than is usual.  Only that allows you to discuss a "map from $R^2$ to $R^3.$" The problem with these "maps" is they cannot be continuous and will have no statistical meaning.
Comment: The second bullet is incorrect: it neither follows from any of the assumptions nor is it part of the definition of a location-scale family.
Comment: It is tremendously confusing because now all references to the $\theta_i$ are superfluous.  I believe the quantifiers now in your statement might not convey correctly the idea you have.  Why not just drop the $\theta_i$ and simply state that the family consists of the set of distributions $x \to F(bx + a)$ for one given $F$ and all $(a,b)\in\mathbb{R}^2$ with $b\gt 0$?  There's no need to refer to means and variances, either--that's just a distraction from the essential idea, which does not require $F$ to have any moments at all.
Comment: @whuber if you are generating location-scale family from one single example then indeed it would seem like it is much easier to use $\mu$ and $\sigma$. Here I am however imagining that we already have a family of curves parameterized by some alternative $\theta_1$ and $\theta_2$ and I wonder whether it could be possible that such a family contains *more* curves than just the curves created by scaling one member with $\mu$ and $\sigma$ (as in the transformation with the tangent). I will see if I can change the formulation somehow again (do you disagree with the idea or with the formulation?).
Comment: I think that's a good way to frame the question.  BTW, there are standard mathematical ways to describe the situation: you are considering the orbits of a mathematical structure (the set of distributions) under the action of a topological group.  "Contain more curves" means the quotient space consists of more than one point.
Comment: @Scorchi, I am not sure how to accurately define the difference between *encoding* and *parameterizing* (the difference is that *parameter* is more useful or has some physical intuitive meaning, whereas a encoding variable might make little sense?).  Indeed of all 'regular' two parameter location-scale families (by regular I mean anything that people actually use) there might be no example. However, the case 2 is not so strange to call it encoding instead of parameterizing. It has just a scale parameter that can become negative. (but the zero is not included and it is not a 'smooth' family)
Comment: You might consider moving some of this discussion about families to the [family oriented question](https://stats.stackexchange.com/q/320746/99274) that arose because of the 'out of context' use of that term in the question above. I would appreciate that because I am still not certain that the word has a very useful meaning for two reasons 1) it is ambiguous and flexible 2) and as a mapping, such a broad term that almost any PDF is related to any other one somehow.
Comment: That's not what it says, though: by using "$\theta_i$" and "$\theta_j$" you are explicitly indicating the possibility of *different* values of the additional parameters.  At a minimum, the notation needs to be clarified.
Comment: (+1) Some thought-provoking examples there. In both Cases 1 & 2 the trick involves squeezing more information into a real number than it needs to do its job as a scale parameter. Doesn't it then become a matter of *encoding* rather than just *parametrizing*?


Como obter posição(x, y) de Node inferior em BorderPane em relação à tela?

Question: Tenho um BorderPane onde define seu valor bottom com um HBox:
borderPane.setBottom(new HBox(children));

Gostaria de saber a posição (x,y) principalmente a y do HBox em relação à tela.
Answer: Achei a resposta no Stack em inglês:
Point2D bounds = borderPaneBottom.localToScene(borderPaneBottom.getLayoutBounds().getMinX(), borderPaneBottom.getLayoutBounds().getMinY());

Comment: Poderia incluir na sua resposta o link de onde achou a resposta?


Does intersection equal product for infinitely many comaximal ideals?

Question: If $I_1,...,I_n$ are comaximal ideals in a commutative ring, then $I_1\cdots I_n=I_1\cap \cdots \cap I_n$. Does this extend to infinitely many comaximal ideals? The proof I have seen uses induction, so not sure if this does extend.
Comment: How do you define an infinite product of ideals?
Answer: Posting a CW Answer per @DylanMoreland's Comment:
The intersection of an arbitrary family of ideals makes sense, but the product of an infinite number of pairwise coprime ideals (even if the ring is commutative with unity) stands in need of definition.  Of course one might choose to define the product in this case to agree with the intersection, but that kind of short-circuit is best avoided (unless it happens to serve an author's purpose).


Unity3D: generating a random colour combinations - colour switch wheel

Question: I'm creating a game similar to the colour switch game, I've created this script to generate a random colour combination out of 8 colours. I've split my wheel into 4 parts. I want each part to have a different colour when I press the button, however, after many attempts, I'm still getting my issue of two or more parts having the same colour. Can this be done?
A gif to demonstrate:

(In the example, I click the button 5 times, in two cases, the same colour repeated twice, aka the purple and the pink.)
My code:
<code> public SpriteRenderer[] colorWheels;
 public Color[] colorcombination;

public int uniqueRandomInt(int min, int max)
{
    int result = Random.Range(min, max);

    if(result == lastRandomNumber) {

        return uniqueRandomInt(min, max);

    }

    lastRandomNumber = result;
    return result;
}

public  void switchColour()
{
    for(int i = 0; i < colorWheels.Length; i ++)
    {
      colorWheels[i].material.color = RANDcolorcombination[uniqueRandomInt(0,8)];
    }
}
</code>
Thank you!
Comment: you want to have four colors selected (different) from a selection of 8  colors?
Comment: yeah, that's what I want to happen
Comment: So either remove colours picked or reject selection choice if it's already in the picked list
Comment: why would I want to remove the colours? I want to have the different colour combinations with each button clicked, but I don't want to get rid of any colours.
Comment: so the first button click could be blue, purple, yellow and red, then the next button click could be red, pink, green and purple (which is still good), but like for the third button click (as an example) I don't  want red, red, yellow, blue. (as red is repeated)
Answer: Sounds like what you actually would like is randomize the colors for each button click and then chose 4 colors from it:
<code>private System.Random random = new System.Random();

public  void switchColour()
{
    // Is shuffled but it is sure that it still contains the same elements
    var randomizedColors = colorcombination.OrderBy(c => random.Next()).ToArray();

    // You can now simply select the first 4 values from the shuffled array
    for(int i = 0; i < colorWheels.Length; i ++)
    {
      colorWheels[i].material.color = randomizedColors[i];
    }
}
</code>
This assures that each selected color is unique for this click. It is very unlikely but can and with enough clicks will still happen of course that a complete set of 4 colors occures twice ;)


Como usar JSON no Python?

Question: Estou usando o seguinte código para coletar a API do site Urbandictionary
import requests
import json

page = requests.get("http://api.urbandictionary.com/v0/define?term=hello")
print(page.content)

Logo após a execução, eu recebo o seguinte resultado:
b'{"tags":["hi","hi","hey","hey","greeting","greeting","yo","yo","goodbye","goodbye"],"result_type":"exact","list":[{"definition":"what you say when your talking casually with friends and your mom walks in the room","permalink":"http://hello.urbanup.com/69266","thumbs_up":3545,"author":"mad at the world","word":"hello","defid":69266,"current_vote":"","example":"What the hell(mom enters)-o mom.","thumbs_down":979},{"definition":"The only word on this site that has nothing to do with [sex] or [drugs]!","permalink":"http://hello.urbanup.com/2269237","thumbs_up":2132,"author":"pirates rule!!!","word":"Hello","defid":2269237,"current_vote":"","example":"person 1: hello\\r\\nPerson 2: hi\\r\\nPerson 1: goodbye\\r\\nPerson 2: Farewell, and may the forces of evil become confused in their eternal search for you\\r\\n*person 1 runs away*","thumbs_down":480},{"definition":"1.  A greeting\\r\\n2.  A for of incredulity","permalink":"http://hello.urbanup.com/390319","thumbs_up":723,"author":"DJ","word":"hello","defid":390319,"current_vote":"","example":"1.  \'HELLO!!!!!!\'\\r\\n2.  \'I satyed at home last night watching movies\'\\r\\n     \'... HELLO!!?!! You were supposed to come to my party last night!\'","thumbs_down":350},{"definition":"The opposite of [O-hell]\\r\\nYou use Hello when your pleased to see someone.","permalink":"http://hello.urbanup.com/322846","thumbs_up":797,"author":"Sam","word":"Hello","defid":322846,"current_vote":"","example":"\\"Hello, It\'s you!!\\"","thumbs_down":451},{"definition":"How to say Jell-O in Spanish. Like when that guy comes to the door in the Rocky Horror Picture show, and everybody tells him to say Jell-O in Spanish, and he says \\"Hell-O\\"","permalink":"http://hello.urbanup.com/562522","thumbs_up":422,"author":"That freakin guy","word":"hello","defid":562522,"current_vote":"","example":"<<<CRREEEEAAAAKKKK>>>> ...Hell-O.","thumbs_down":254},{"definition":"greeting to others form of friendly greeting","permalink":"http://hello.urbanup.com/379429","thumbs_up":365,"author":"Rahim Walji","word":"hello","defid":379429,"current_vote":"","example":"hello im silly","thumbs_down":225},{"definition":"(1) an almost obscelete form of greeting most associated with straightlaced people; \\r\\n(2) a polite way of answering a phone","permalink":"http://hello.urbanup.com/504054","thumbs_up":236,"author":"AuburnTIGER","word":"hello","defid":504054,"current_vote":"","example":"(1)Bob (sees Bill on street): \\"Hello, Bill!\\"\\r\\nBill: \\"Well, hello, Bob.\\"\\r\\n(2)(Phone rings loudly) \\r\\nJim: \\"Hello?\\"\\r\\nJames Watson from AT&T: \\"Hi, this is James Watson from AT&T.  I\'m calling to talk to you about your long distance plan.\\"","thumbs_down":166},{"definition":"What you say under your breath to your friend when a hot member of the opposite sex is walking by","permalink":"http://hello.urbanup.com/4890419","thumbs_up":137,"author":"fiubvevb","word":"Hello","defid":4890419,"current_vote":"","example":"-Hot person walks into the room-\\n\\nAdoring member of the opposite sex: \\"hello\\"","thumbs_down":73},{"definition":"A greeting.  A way of telling someone you noticed them.  Some synonyms of \\"hello\\" are: hi, hey, greetings, howdy, hola (Spanish for \\"hello.\\")","permalink":"http://hello.urbanup.com/856704","thumbs_up":129,"author":"I_Love_Me","word":"Hello","defid":856704,"current_vote":"","example":"Hello Sara.  How are you?\\r\\nHello Danny.  I am good.","thumbs_down":78},{"definition":"A spastic interrogative exclamation usually following complete ineptitude in the field of physics.","permalink":"http://hello.urbanup.com/626610","thumbs_up":54,"author":"Tea Cake","word":"hEllo?","defid":626610,"current_vote":"","example":"What\'s the field integral of the magnetic flux of the solenoid?\\r\\n\\r\\nDo you understand this?\\r\\n\\r\\nhEllo?","thumbs_down":33}],"sounds":["http://media.urbandictionary.com/sound/hello-7503.mp3","http://media.urbandictionary.com/sound/hello-9778.mp3","http://media.urbandictionary.com/sound/hello-9897.mp3","http://media.urbandictionary.com/sound/hello-10454.mp3","http://api.twilio.com/2008-08-01/Accounts/ACd09691b82112e4b26fce156d7c01d0ed/Recordings/RE35ab2d198fde01bc8889d6bedc7d3108.mp3","http://api.twilio.com/2008-08-01/Accounts/ACd09691b82112e4b26fce156d7c01d0ed/Recordings/RE7201bb8cc62883692ba7afc67037d5ff.mp3","http://wav.urbandictionary.com/hello-25244.wav","http://wav.urbandictionary.com/hello-37770.wav","https://api.twilio.com/2008-08-01/Accounts/ACd09691b82112e4b26fce156d7c01d0ed/Recordings/REa6a85510c89613bfc29fd715761f144c.mp3","http://wav.urbandictionary.com/hello-46397.wav"]}'

Como posso receber o valor incluído no "definition"?
Comment: Possível duplicata de [Pegar Dados na estrutura JSON com python](https://pt.stackoverflow.com/questions/206294/pegar-dados-na-estrutura-json-com-python)
Answer: Se o conteúdo que tu pegou foi em JSON tu pode usar o método .json() do próprio requests que irá retornar um dict.
Ficaria assim:
page = requests.get("http://api.urbandictionary.com/v0/define?term=hello")
print(page.json())
{'sounds': ['http://media.urbandictionary.com/sound/hello-7503.mp3', 'http://media.urbandictionary.com/sound/hello-9778.mp3', 'http://media.urbandictionary.com/sound/hello-9897.mp3', 'http://media.urbandictionary.com/sound/hello-10454.mp3', 'http://api.twilio.com/2008-08-01/Accounts/ACd09691b82112e4b26fce156d7c01d0ed/Recordings/RE35ab2d198fde01bc8889d6bedc7d3108.mp3', 'http://api.twilio.com/2008-08-01/Accounts/ACd09691b82112e4b26fce156d7c01d0ed/Recordings/RE7201bb8cc62883692ba7afc67037d5ff.mp3', 'http://wav.urbandictionary.com/hello-25244.wav', 'http://wav.urbandictionary.com/hello-37770.wav', 'https://api.twilio.com/2008-08-01/Accounts/ACd09691b82112e4b26fce156d7c01d0ed/Recordings/REa6a85510c89613bfc29fd715761f144c.mp3', 'http://wav.urbandictionary.com/hello-46397.wav'], 'result_type': 'exact', 'list': [{'defid': 69266, 'author': 'mad at the world', 'word': 'hello', 'thumbs_down': 979, 'thumbs_up': 3548, 'permalink': 'http://hello.urbanup.com/69266', 'example': 'What the hell(mom enters)-o mom.', 'definition': 'what you say when your talking casually with friends and your mom walks in the room', 'current_vote': ''}, {'defid': 2269237, 'author': 'pirates rule!!!', 'word': 'Hello', 'thumbs_down': 480, 'thumbs_up': 2133, 'permalink': 'http://hello.urbanup.com/2269237', 'example': 'person 1: hello\r\nPerson 2: hi\r\nPerson 1: goodbye\r\nPerson 2: Farewell, and may the forces of evil become confused in their eternal search for you\r\n*person 1 runs away*', 'definition': 'The only word on this site that has nothing to do with [sex] or [drugs]!', 'current_vote': ''}, {'defid': 390319, 'author': 'DJ', 'word': 'hello', 'thumbs_down': 350, 'thumbs_up': 723, 'permalink': 'http://hello.urbanup.com/390319', 'example': "1.  'HELLO!!!!!!'\r\n2.  'I satyed at home last night watching movies'\r\n     '... HELLO!!?!! You were supposed to come to my party last night!'", 'definition': '1.  A greeting\r\n2.  A for of incredulity', 'current_vote': ''}, {'defid': 322846, 'author': 'Sam', 'word': 'Hello', 'thumbs_down': 451, 'thumbs_up': 797, 'permalink': 'http://hello.urbanup.com/322846', 'example': '"Hello, It\'s you!!"', 'definition': 'The opposite of [O-hell]\r\nYou use Hello when your pleased to see someone.', 'current_vote': ''}, {'defid': 562522, 'author': 'That freakin guy', 'word': 'hello', 'thumbs_down': 254, 'thumbs_up': 422, 'permalink': 'http://hello.urbanup.com/562522', 'example': '<<<CRREEEEAAAAKKKK>>>> ...Hell-O.', 'definition': 'How to say Jell-O in Spanish. Like when that guy comes to the door in the Rocky Horror Picture show, and everybody tells him to say Jell-O in Spanish, and he says "Hell-O"', 'current_vote': ''}, {'defid': 379429, 'author': 'Rahim Walji', 'word': 'hello', 'thumbs_down': 225, 'thumbs_up': 365, 'permalink': 'http://hello.urbanup.com/379429', 'example': 'hello im silly', 'definition': 'greeting to others form of friendly greeting', 'current_vote': ''}, {'defid': 504054, 'author': 'AuburnTIGER', 'word': 'hello', 'thumbs_down': 166, 'thumbs_up': 236, 'permalink': 'http://hello.urbanup.com/504054', 'example': '(1)Bob (sees Bill on street): "Hello, Bill!"\r\nBill: "Well, hello, Bob."\r\n(2)(Phone rings loudly) \r\nJim: "Hello?"\r\nJames Watson from AT&T: "Hi, this is James Watson from AT&T.  I\'m calling to talk to you about your long distance plan."', 'definition': '(1) an almost obscelete form of greeting most associated with straightlaced people; \r\n(2) a polite way of answering a phone', 'current_vote': ''}, {'defid': 4890419, 'author': 'fiubvevb', 'word': 'Hello', 'thumbs_down': 73, 'thumbs_up': 137, 'permalink': 'http://hello.urbanup.com/4890419', 'example': '-Hot person walks into the room-\n\nAdoring member of the opposite sex: "hello"', 'definition': 'What you say under your breath to your friend when a hot member of the opposite sex is walking by', 'current_vote': ''}, {'defid': 856704, 'author': 'I_Love_Me', 'word': 'Hello', 'thumbs_down': 78, 'thumbs_up': 129, 'permalink': 'http://hello.urbanup.com/856704', 'example': 'Hello Sara.  How are you?\r\nHello Danny.  I am good.', 'definition': 'A greeting.  A way of telling someone you noticed them.  Some synonyms of "hello" are: hi, hey, greetings, howdy, hola (Spanish for "hello.")', 'current_vote': ''}, {'defid': 626610, 'author': 'Tea Cake', 'word': 'hEllo?', 'thumbs_down': 33, 'thumbs_up': 54, 'permalink': 'http://hello.urbanup.com/626610', 'example': "What's the field integral of the magnetic flux of the solenoid?\r\n\r\nDo you understand this?\r\n\r\nhEllo?", 'definition': 'A spastic interrogative exclamation usually following complete ineptitude in the field of physics.', 'current_vote': ''}], 'tags': ['hi', 'hi', 'hey', 'hey', 'greeting', 'greeting', 'yo', 'yo', 'goodbye', 'goodbye']}

Edit:
Como a função .json() retorna uma dict tu precisa acessar com as chaves no teu caso tu quer a definition.
page = requests.get("http://api.urbandictionary.com/v0/define?term=hello")
d = page.json()
for i in d['list']:
   print(i['definition'])

Pois existem várias definition e podem ser acessadas atráves da chave list
Recomendo que sempre que tu tiver alguma dúvida sobre o formato json use alguma ferramenta de formatação, como por exemplo: https://jsonformatter.curiousconcept.com/ Pegue o valor de http://api.urbandictionary.com/v0/define?term=hello lá.
Comment: @wmsouza claro pode ser também, é que eu quis mostrar que o d['list'] possui uma lista de dicts que possuem a chave 'definition', então utilizei um for para ilustrar que é possível percorrer os elementos.
Comment: e se eu quisesse pegar a string escrita dentro de definition?
Comment: Matheus Silva, eu editei minha resposta tenta ver se ela soluciona a sua dúvida!
Comment: @MarlonBaptistaQuadros não seria mais facil `d['list'][0]['definition']` ?

Como usar JSON no Python?


Find certain child element with CSS

Question: When an element with the class .parent is hovered over, it locates child elements with the class .child and applies the CSS to them.
Here is jsFiddle
Is it possible to achieve this effect purely with CSS?
html:

jQuery:
$('.parent').hover(
  function () {
    $(this).find('.child').css('background','yellow');
  },
  function () {
    $(this).find('.child').css('background','blue');
  }
);

Answer: Remove the inline styles and put the following in a stylesheet:
/* CSS */
.parent { background: red; margin: 20px; padding: 20px; }
.child {background blue; margin: 20px; padding: 20px;}
.parent:hover > .child { background: yellow; }

Comment: OK. Assuming he takes out the inline styles and moves them to the style sheet.
Comment: No problem : ) really useful little trick. see this article for more useful selectors: http://css-tricks.com/child-and-sibling-selectors/
Comment: Yes, or `!important` to override inline styling.
Comment: @UserIsCorrupt: You should avoid using the `!important` declaration whenever possible.
Comment: You may also have some browser compatibility issues, if the ">" isn't necessary, I would remove it (ie. if there are no other children with the class "child" it is unnecessary, and fixed one possible issue if you are worried about old browsers…
Comment: @animuson: Can you elaborate on that? Because our CSS guys use !important on  few styles, specially for styles relating to client side validation messages so no one can mess with them and break the intended unified look. Seems to make sense.
Comment: @FrançoisWahl [!important CSS Declarations: How and When to Use Them](http://coding.smashingmagazine.com/2010/11/02/the-important-css-declaration-how-and-when-to-use-it/) - "!important declarations **should not be used unless they are absolutely necessary** after all other avenues have been exhausted"
Comment: @animuson: I looked at the article and it says a lot about not using !important and it says a lot about people using it not knowing CSS and only keeping !important for special cases. It goes on about the cons being that you interrupt the natural flow of your rules. That is all good advise but is there an actual functional negative reason why !important is bad? I'm only asking cause if I don't want anyone to over-write something is that not then my natural flow of my rules? I will try not to use it myself as I assume it is bad going by the article.
Comment: @FrançoisWahl: No. It's more of an indicator. If you have to use it, your CSS probably isn't written well and anyone else who has to work with it is going to have a hell of a time figuring out which rules are being applied and overwritten.
Comment: @animuson: I see. I was looking for some functional negative impact when using it. What you saying makes sense and following good advise and getting into good habits is always good. Thanks for your response on that.
Comment: @FrançoisWahl: the main negative of using `!important` is that it makes your code less easy to change later on. When two style rules apply to the same element, the one with the more specific selector wins, unless you use `!important`, in which case that one will *always* win. That's fine until you *want* to override it, in which case you have to use `!important` in a later rule, which is fine until you want to override *that* one, and so on until you've got `!important`'s scattered throughout your stylesheet, when you really should have fixed the specificity problem you originally had.
Answer: Yup.
.parent .child {
    background: blue;
}

.parent:hover .child {
    background: yellow;
}

That replicates the effect your jQuery has. If you literally mean "child" (as opposed to descendant, which is what you're actually finding), then you want the following:
.parent > .child {
    background: blue;
}

.parent:hover > .child {
    background: yellow;
}

As @hobbs notes, this doesn't work in IE 6, because :hover is only supported on links in IE 6.
Answer: Yes, but you should move your inline styles into the classes as well so you don't have to use the !important declaration (otherwise the inline styles will always override the style sheet).

.parent {
    background: red;
    margin: 20px;
    padding: 20px;
}
.child {
    background: blue;
    margin: 20px;
    padding: 20px;
}
.parent:hover .child {
    background: yellow;
}

See the jsFiddle.
Answer: .parent .child {
    background: blue;
}

.parent:hover .child {
    background: yellow;
}

Should do the job, except on versions of IE where :hover only works on A elements (jQuery works around this; CSS doesn't.)

Find certain child element with CSS


CAShapeLayer with CIFilters

Question: I would like to apply CIFilter to CAShapeLayer.filters.
Is this correct assumption how to do this:

create CAShapeLayer
create CGImage or UIImage from CAShapeLayer
create CIFilter with CGImage or UIImage
add CIFilter to CAShapeLayer.filters

To create CGImage from CAShapeLayer I used CAShapeLayer.contents but in my case the contents is nil, also if I render CAShapeLayer to image context I could not get the image.
override func layoutSubviews()
    {
        if(self.shapeLayer == nil && self.path != nil && self.pathOriginationSize != CGSizeZero)
        {
            let scaleFactor = self.scaleFactor(self.pathOriginationSize, targetSize: self.bounds.size)

            _scaledPath = UIBezierPath(CGPath: self.path.CGPath)
            _scaledPath.lineWidth = self.path.lineWidth
            _scaledPath.applyTransform(CGAffineTransformMakeScale(scaleFactor.x, scaleFactor.y))
            _scaledPath.lineCapStyle = CGLineCap.Round

            self.shapeLayer = CAShapeLayer()
            self.shapeLayer.path = _scaledPath.CGPath
            self.shapeLayer.strokeColor = UIColor.blackColor().CGColor
            self.shapeLayer.lineWidth = self.path.lineWidth

            let imageSize = CGPathGetBoundingBox(_scaledPath.CGPath).size

            UIGraphicsBeginImageContextWithOptions(imageSize, false, UIScreen.mainScreen().scale)
            let context = UIGraphicsGetCurrentContext()
            self.shapeLayer.renderInContext(context!)
            _ = UIGraphicsGetImageFromCurrentImageContext()
            UIGraphicsEndImageContext()

            let cgImage = self.shapeLayer.contents as! CGImageRef

            let inputImage = CIImage(CGImage: cgImage)

            let blurFilter = CIFilter(name: "CIZoomBlur")
            blurFilter?.setValue(inputImage, forKey: kCIInputImageKey)
            blurFilter?.setDefaults()
            self.shapeLayer.filters = [blurFilter!]
            self.shapeLayer.shouldRasterize = true

            self.layer.addSublayer(self.shapeLayer)
        }
    }

Answer: CALayer.filters is not implemented on iOS.
There's no need to use a CAShapeLayer in this case (since you can't use filters). You can just create a CGImage from the UIBezierPath (as you're doing; just stroke and/or fill the path rather than calling renderInContext). Then use apply the CIFilter to the result, create a CGImage and assign that to contents. (From your above code, you seem to understand how to do all those things, so I'm not writing it out here.)
Comment: Hey Rob! Do you happen to know if there is an efficient way to filter CALayer as CALayer.filters is not working on iOS?
Comment: I'm not certain what you mean by "efficient" here. But if the above is not fast enough for you, you should be digging deeper into Core Image. I'd start with the most recent WWDC https://developer.apple.com/videos/play/wwdc2017/510/
Comment: Sorry for not explaining. We are developing a video-processing app. Part of the app is applying filters to the video. Using the higher level AVFoundation API, I can access the video frames as a CALayer object. But using a bit more complex API I can access the video frames by a CIImage object. So basically I'm asking if using this method is a lot SLOWER than using the CIImage mechanism (with a complexity downside).. What do you think?
Comment: I'd never do video this way myself; you want to stay in the Core Image space as much as you can, and convert to Core Graphics as late and infrequently as possible (if ever). But you'd have to test it to know if this approach were actually slow. I would stay in Core Image for control, not performance itself (so when you have a performance problem, you can fix it without redesigning your whole system). Apple typically builds their higher-level frameworks on top of lower-level frameworks very well, so you can't guess what performance hit you'll take. You have to test it.
Comment: Cool, thanks! I'll take a look at what you've sent. Have a great day!

CAShapeLayer with CIFilters


Semaphores C# Two threads

Question: The idea of my code is to WRITE into file(.txt) a letter then READ that file and if the letter that was read is consonant then it outputs it. If not, does nothing.
I am using Semaphores to do this. Created two threads. It WRITES and READS from file. However, cannot get this condition running. For some reason when reading from the file it shows conversion error. and the "letter" variable is equal to '\0'.

<code>namespace Sema
{
class Program
{
    private static Semaphore sPhore  = new Semaphore(2, 2);
    public static string path = "message.txt";

    private static void write(object input)
    {

        Console.WriteLine("\nEnter the consonant: ");
        sPhore.WaitOne();
        input = Console.ReadLine();
        TextWriter tw = File.CreateText(path);
        tw.WriteLine(input);
        tw.Close();
        sPhore.Release();
    }
    private static void read(object input)
    {
        sPhore.WaitOne();
       char letter = Convert.ToChar(File.ReadAllLines(path));
       //char letterChar = Convert.ToChar(letter);
        if (letter.Equals('q') || letter.Equals('w') || letter.Equals('r') || letter.Equals('t') || letter.Equals('p') || letter.Equals('s')
         || letter.Equals('d') || letter.Equals('f') || letter.Equals('g') || letter.Equals('h') || letter.Equals('j') || letter.Equals('k')
         || letter.Equals('l') || letter.Equals('z') || letter.Equals('x') || letter.Equals('c') || letter.Equals('v') || letter.Equals('b')
         || letter.Equals('n') || letter.Equals('m'))
        {
            Console.WriteLine("\nYou wrote this consonant:" + letter);
        }

            //TextReader tr = File.OpenText("message.txt");
        //Console.Write("\nYou wrote this char:" + tr.ReadAsync());
        //tr.Close();
        sPhore.Release();
    }
    //private static void read(object path)
    //{

    //}
    static void Main(string[] args)
    {

        for (int i = 0; i < 4; i++)
        {
            Thread ss = new Thread(new ParameterizedThreadStart(write));
            Thread sss = new Thread(new ParameterizedThreadStart(read));
            ss.Start(i);
            ss.Join();
            sss.Start(i);
            sss.Join();
        }
        Console.ReadLine();
    }
}
</code>
}
Comment: Read all lines returns an array, even if the file contains only a single line.
Answer: Read all lines returns string[]. In order to convert it to char you need to get first line and first char from the first line:
<code>    char letter = File.ReadAllLines(path)[0][0];
</code>

Semaphores C# Two threads


Communication between ASP MVC and WinForm Applications

Question: I am looking for a way user can communicate between an ASP and Winform applications.
I am looking for something like soluto.com, I want to let the user send commands to other computers via Website. So let's say the user signed up for 10 computers, which is registered on the mvc app. User can select all the 10 computer and send a "Do this task" with a click of a button.
I am thinking something like, Winform will create a httplisten server. Everytime winform is open, it will send a "I am online" post to mvc, along with IP:Port. The server will send a request to that ip:port when required.
That approach seems very unsecure though, having an open port, configuring firewall and etc, seems like a overkill.
I was wondering if there way any other way of accomplishing this.
Thank you for the help.
P.S. Before you claim this is a stupid idea, Piriform is doing something like this also. Take a look at Agomo.com
Answer: Use SingalR with properly architected web and windows applications (e.g. MVP, MVC, etc.)
SignalR with window client (WPF)
Console App & SignalR
Comment: There are other publish/subscribe frameworks like NServicebus (http://particular.net/NServiceBus) to look at too.
Answer: Create a WCF service within the WinForm application, specify endpoint(s) (and secure the endpoint appropriately), and connect to said endpoints from your ASP.NET application the same way you would also connect to a WCF service.
Answer: Why don't you just have the Winforms app use a standard HttpClient or WebRequest to periodically poll the service (maybe every 5 seconds or so) and ask if there if there are any tasks that need to be performed?
Unless you need realtime, low-latency, high performance communication then this is the easiest way to solve your problem with minimal to zero client side setup or security configuration.
The way I would do it is implement it like a stack in a data persistence layer.  So each client could have rows in a table that are added when a task is queued.  When the clients sends an HTTP GET request to the MVC server it will return the an array of tasks for that client and you could have it either delete them from the database right away or wait for the client to send a HTTP command later to indicate which tasks it completed.
You could represent tasks as a simple data object with a few properties, or just a string or int that you can lookup on the client in some way to invoke the appropriate code.
For reasonable security each client just needs to be given a unique key like a GUID or equivalent that it can later send to the server to validate its identity.  This is also known as a cookie, secret, or API key.
Comment: This is what I was thinking but won't it be trouble some having WinForms sending requests like every minute? I have 200 downloads a day on my program. So, let's say in a year, that'll be a LOT of program querying my server. Still better than real time I suppose.
Comment: What you really want is a publish/subscribe model, which is what @John S. has answered. Polling can also be slow, and also incurs a lot of overhead.


Create Map based on two other maps in Java

Question: How can I build a map based on two others maps using Java 8 streams? Namely, I have the following map structures:
map1 = Map<MyModel, List<String>>();
map2 = Map<String, String>();

where List<String> values of map1 are the identical with String keys in map2. In other words based on map1 values one can use it as keys in map2 and get values from there.
So, my question is how to merge those two maps with usage of streams and lambdas techniques and build a new map which will include MyModel as keys and List<Strings> as values with no duplicates?
This what I have so far:
map1 = Map<MyModel, List<String>>();
map2 = Map<String, String>();

Map<MyModel, List<String>> map3 = Stream.of(map1, map2)
    .flatMap(map -> map.entrySet().stream())
    .collect(Collectors.toMap(
        Map.Entry::getKey,
        Map.Entry::getValue,
        (v1, v2) -> v1
    )
);

Any help would be appreciated.
Answer: Lets start with transforming a List<String> list by looking up values form map2 and discarding duplicates:
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
.....

list.stream()
    .filter(map2::containsKey)  // make sure map2 has this key
    .map(map2::get)             // get the value
    .distinct()                 // discard duplicates
    .collect(toList());         // make new list

Now you just have to use the above as the value mapper  (with static imports of Collectors methods) to solve your problem:
map1.entrySet().stream().collect(toMap(
    Map.Entry::getKey,
    e -> e.getValue().stream()
        .filter(map2::containsKey)
        .map(map2::get)
        .distinct()
        .collect(toList())
));

Comment: Nice answer .. very concise
Comment: Thanks for the response. Using of your suggested method shows Non-static method cannot be referenced from a static context error for the `Map.Entry::getKey` and Cannot resolve method error for the `e.getValue().stream()`.
Comment: @Dozent Make sure you include static import of `toList` and `toMap`.  See https://www.ideone.com/mxeRTf
Comment: @Misha, I did it other way but with usage of your technique in stream scope. Thanks for the idea. It's accepted :D
Answer: Below is something I thought of quickly. There may be a more efficient way to implement your requirements but it will at least give you a start.
Code
public static void main(String[] args) {
    //Map 1
    Map<Integer, List<String>> map1 = new HashMap<>();
    map1.put(1, Arrays.asList("A", "B"));
    map1.put(2, Arrays.asList("C", "D"));

    //Map 2
    Map<String, String> map2 = new HashMap<>();
    map2.put("A", "Apple");
    map2.put("B", "Banana");
    map2.put("C", "Cherries");
    map2.put("D", "Dewberries");

    Map<Integer, List<String>> collect = map1.entrySet()
            .stream()
            .map(entry -> {
                return new AbstractMap.SimpleImmutableEntry<>(
                        entry.getKey(),
                        entry.getValue()
                                .stream()
                                .map(map2::get)
                                .filter(Objects::nonNull)
                                .collect(Collectors.toList())
                );
            })
            .collect(Collectors.toMap(AbstractMap.SimpleImmutableEntry::getKey, AbstractMap.SimpleImmutableEntry::getValue));

    System.out.println(collect);
}

Output
{1=[Apple, Banana], 2=[Cherries, Dewberries]}

Comment: @GarrethGolding, thanks for the response, your method also works! But as you mentioned above Misha's answer is nice and concise ;)
Comment: Using `entry.setValue` will attempt to modify the source map, which is dangerous.  And if modifying the original is acceptable, it's better to be explicit about it with `map1.replaceAll( (k,v) -> ....)`
Comment: Thanks for the feedback @Misha .. I've edited my code to not update the existing Map.Entry and instead create and return another object.


Display suite removing class id

Question: I split 2 columns my contetnt node with Display Suite and add custom class to the columns. (with Bootsrap responsive class col-sm-3) But display suite still render column with old style: group-left and group right. How can i remove old style?
Answer: The classes are only added to the existing ones, they don't replace them. If you want to remove the old styling, you can create a new layout and either add different default classes, or no classes at all.
Adding custom layouts to your theme (Display Suite)
You also might want to consider using Display Suite Bootstrap Layouts. Bootstrap 3.0 layouts are still in dev, but it's worth taking a look.

Display suite removing class id


AWS IOS SDK DynamoDB Scan - Thread de scan funciona no emulador, mas não ao debugar no dispositivo

Question: No meu app faço uso de um scan com o DynamoDB que funciona perfeitamente no emulador para todas versões de iOS que o xCode disponibiliza, entretanto, ao debugar no dispositivo (iPhone 5c), não executa a thread principal.
<code>[[[dynamoDBObjectMapper scan:[DDBTableRow class]
                  expression:scanExpression]
      continueWithExecutor:[BFExecutor mainThreadExecutor] withSuccessBlock:^id(BFTask *task) {
//Execução da Thread principal
.
.
.
return nil;
  }] continueWithExecutor:[BFExecutor mainThreadExecutor] withBlock:^id(BFTask *task) {
      if (task.error) {
          NSLog(@"refreshList Error");
      }
      return nil;
  }];
</code>
Alguma idéia?
Answer: Resolvido atualizando o pod  (AWSiOSSDKv2 2.0.17 (was 2.0.13)).
Mais detalhes: https://stackoverflow.com/questions/28951973/aws-ios-sdk-dynamodb-scan-mainthread-works-in-emulador-but-dont-in-device-de/29115231#29115231
Comment: Se você encontrou a resposta para sua dúvida favor marcar como respondida.


Property of a ring with unity

Question: Suppose $R$ be a ring with unity $I$ and $a$ belongs to $R$. How to prove that the ring is commutative if there exists a unique  $b$ in $R$ such that $ab=I$?
My teacher told me to prove $ba=I$, consider the product $a(ba-I+b)$. But I just want know if there is any another way to prove that the ring is commutative.
Please help.
Comment: There do exist non-commutative division rings, so even the second reading proposed by Edgar will not work.
Comment: I think this proposition has counterexample, for example, ring of quaternions.
Comment: Playing around with quantifiers, maybe we are really in the trivial ring, since there would not be such a $b$ for $0$ otherwise.
Comment: As an aside: Rings such that $ab=1\implies ba=1$ are called [Dedekind finite rings](http://en.wikipedia.org/wiki/Dedekind-infinite_set). The question is essentially establishing that if for all $a$ if $ab=1$ for a unique $b$, then $R$ is Dedekind-finite. I can't immediately cite a source, but I think it is true that in Dedekind-*in* finite rings, it happens that if $b$ is not unique, there are actually *infinitely* many $b$'s such that $ab=1$ (as opposed to just two or three).
Comment: @rschwieb If $a$ has two right inverses, then $a$ is a left zero divisor, so we can look at a problem in Lam's _First Course in Noncommutative Rings_ (Section 1 Ex. 14 p. 23) which states that under the hypothesis that $a$ has no left inverse but has a right inverse, then $a$ has infinitely many right inverses.
Comment: @peoplepower Thanks for remembering where that's at :)
Answer: It is true that if $a$ is an element of a unital ring $R$ and there exists a unique $b\in R$ such that $ab= I$, then also $ba=I$.  In this case, $b=a^{-1}$, and $b$ commutes with $a$, but this does not imply that $a$ commutes with everything else, let alone that the ring is commutative.  As Mariano mentioned, there are noncommutative rings in which every element is invertible, and as tetori mentioned, the ring of quaternions gives a specific counterexample.
Your teacher gave you a good hint for showing that $ba=I$. First you can simplify $a(ba-I+b)$, then you can use uniqueness of $b$ to finish.

Property of a ring with unity


Qual a diferença entre viewDidLoad e awakeFromNib?

Question: Qual a principal diferença entre viewDidLoad e awakeFromNib no desenvolvimento em Swift para iOS?
Answer: awakeFromNib é um método de NSObject e é chamado assim que o objeto é criado a partir de um arquivo do Interface Builder (ex: .xib)
viewDidLoad é um método de UIViewcontroller chamado após a view do ViewController ser criada
Em outras palavras awakeFromNib é chamado em qualquer objeto definido no interface builder (subclasses de UITableViewCell, UIView, UIViewcontroller, etc). Já viewDidLoad é invocado somente em subclasses de UIViewcontroller, independentemente da forma que a view foi construída. Ou seja, mesmo se a view for criada programaticamente, usando loadView, o método é chamado.
Em resumo, viewDidLoad é normalmente usado para inicialização de ViewControllers e awakeFromNib é usado para outras classes criadas com o Interface Builder como TableViewCells


Robô para informações

Question: Bom dia, Tarde , Noite.
gostaria de sabe se tem como criar um robô onde ele pega alguns preços de produto, e joga essa informação em um app.
estou com uma ideia para um app e sou iniciante ainda estou fazendo logica de programação e depois vou fazer java script
Comment: Cara.... o que você quer não é um robô, e sim um programa. Tente melhorar a qualidade da sua pergunta, pois quase não entendi ela (o que fazer javascript tem á ver com a pergunta??).
Answer: Creio que você quiz fazer referência ao Robo no caso de "algo que torne seu aplicativo capaz de consumir dados de Preços de algum lugar", no caso consumir dados de um banco de dados de preços por exemplo, ou consumir dados de uma API ok ("Application Programming Interface").
Na verdade existem diversas formas de entender sua dúvida, como você falou em Javascript seria interessante abrir uma ideia para você consumir estes dados via "Ajax" por exemplo, onde através da sua programação em Jscript você irá direcionar uma requisição de "GET" para seu aplicativo Web consumir seus dados de Preços, por exemplo por uma API retornando estes dados em formato JSON (JavaScript Object Notation). Então estes dados estariam dispostos em uma URL por exemplo: http://xxxx_precos_de_produtos , onde estariam num formato tipo assim: <code>{ "_idproduto" : "001", "nome_produto":"chuteira", "preco_produto":"150,00"}</code>.
Como falei acima existem outras formas de consumir dados, através de consultas diretamente ao banco de dados via querys e SQL (Structured Query Language), por exemplo, utilizando linguagens como PHP, Java, Python, etc.
Veja que há muitos caminhos e formas de se consumir dados! Tentei elucidar sua dúvida de uma forma simples, já que está iniciando e todo inicio é realmente confuso, mas continue em frente, estude, busque informação e tenha sucesso! Abraço.
Comment: Muito obrigado ^^, estou fazendo em python, utiizando o selenium conseguir pegar alguns dados. Mas ainda estou estudando MySQL, pois estou salvando esses preços em XLS e JASON

Robô para informações


Is hitting a foam ball against a wall in training detrimental to my tennis?

Question: I have recently begun hitting a foam ball against the wall to improve my volleys, since I have been playing more doubles lately. I think the benefits are reduced noise and it is not so hard on my arm joints, since it is not as heavy as a regular ball. It is a lot easier to keep the volleys going too, since it's more forgiving.
I do overheads, serves and volleys against a racketball court wall.  I think it's a great cardio exercise, and I have seem some improvements on my volleys; I am more aggressive at the net now.
Are there any drawbacks to hitting with the foam ball, if I still hit with the regular balls from time to time?
Answer: The central risk is getting used to incorrect technique. Since foam balls are significantly lighter than tennis balls, hitting them offers less feedback. Consequently many players begin swinging and/or using their wrists instead of leaning in. In the meantime, the light balls do not punish these mistakes and moreover obscure bad timing.
Answer: In and of itself, it's probably not detrimental, but it also probably isn't helping you very much beyond maybe half an hour a day.
Practice like you play. That means, practice by recreating the same conditions you will play in, to the greatest extent possible.


Converting date+time in Character format to CET while correctly taking into account daylight savings

Question: I have a small problem converting some characters (the format is CET, they are just stored as characters). I want to change the format from characters to date, such that I can convert between timezones. Here is a small part of the data that I'm looking at.
timestamps <- c("2023-10-29 00:00:00", "2023-10-29 00:15:00", "2023-10-29 00:30:00", "2023-10-29 00:45:00", "2023-10-29 01:00:00", "2023-10-29 01:15:00", "2023-10-29 01:30:00", "2023-10-29 01:45:00", "2023-10-29 02:00:00", "2023-10-29 02:15:00", "2023-10-29 02:30:00", "2023-10-29 02:45:00", "2023-10-29 03:00:00", "2023-10-29 02:15:00", "2023-10-29 02:30:00", "2023-10-29 02:45:00", "2023-10-29 03:00:00", "2023-10-29 03:15:00", "2023-10-29 03:30:00", "2023-10-29 03:45:00", "2023-10-29 04:00:00", "2023-10-29 04:15:00")

My first attempt was doing the following:
as.POSIXct(timestamps, tz = "CET")

but that gives the following output:
 [1] "2023-10-29 00:00:00 CEST" "2023-10-29 00:15:00 CEST" "2023-10-29 00:30:00 CEST" "2023-10-29 00:45:00 CEST" "2023-10-29 01:00:00 CEST"
 [6] "2023-10-29 01:15:00 CEST" "2023-10-29 01:30:00 CEST" "2023-10-29 01:45:00 CEST" "2023-10-29 02:00:00 CEST" "2023-10-29 02:15:00 CET"
[11] "2023-10-29 02:30:00 CET"  "2023-10-29 02:45:00 CET"  "2023-10-29 03:00:00 CET"  "2023-10-29 02:15:00 CET"  "2023-10-29 02:30:00 CET"
[16] "2023-10-29 02:45:00 CET"  "2023-10-29 03:00:00 CET"  "2023-10-29 03:15:00 CET"  "2023-10-29 03:30:00 CET"  "2023-10-29 03:45:00 CET"
[21] "2023-10-29 04:00:00 CET"  "2023-10-29 04:15:00 CET"

Here the CEST timezone is not properly allocated. They should be allocated up to the "2023-10-29 03:00:00" timestamp.
I also tried to use the "ymd_hms" from lubridate, but that did not do the trick either:
[1] "2023-10-29 00:00:00 CEST" "2023-10-29 00:15:00 CEST" "2023-10-29 00:30:00 CEST" "2023-10-29 00:45:00 CEST" "2023-10-29 01:00:00 CEST"
 [6] "2023-10-29 01:15:00 CEST" "2023-10-29 01:30:00 CEST" "2023-10-29 01:45:00 CEST" "2023-10-29 02:00:00 CET"  "2023-10-29 02:15:00 CET"
[11] "2023-10-29 02:30:00 CET"  "2023-10-29 02:45:00 CET"  "2023-10-29 03:00:00 CET"  "2023-10-29 02:15:00 CET"  "2023-10-29 02:30:00 CET"
[16] "2023-10-29 02:45:00 CET"  "2023-10-29 03:00:00 CET"  "2023-10-29 03:15:00 CET"  "2023-10-29 03:30:00 CET"  "2023-10-29 03:45:00 CET"
[21] "2023-10-29 04:00:00 CET"  "2023-10-29 04:15:00 CET"

Actually, 1 less time period is now being assigned the "CEST" timezone compared to before.
Does anyone have a solution for this problem?
Comment: If you only have the dates as strings and not in any other form, I don't know how you would tell R which of the ambiguous strings are CET and which are CEST. Only Idea I have is to recreate the dates in R, doing something like `seq(timestamp_start,timestamp_end,by = '15 mins')` after you have converted the first and last timestamp if they are unambiguous.
Answer: If you assume your data is sorted, you may add +0100 for the (duplicated) CET times and +0200 for the CEST times, and then add %z in the as.POSIXct call.
ifelse(duplicated(timestamps) | as.POSIXct(timestamps, tz = "CET") > as.POSIXct("2023-10-29 03:00:00"),
       paste0(timestamps, " +0100"),
       paste0(timestamps, " +0200")
       ) |>
  as.POSIXct(format="%Y-%m-%d %H:%M:%S %z")

Gives:
[1] "2023-10-29 00:00:00 CEST" "2023-10-29 00:15:00 CEST" "2023-10-29 00:30:00 CEST" "2023-10-29 00:45:00 CEST" "2023-10-29 01:00:00 CEST" "2023-10-29 01:15:00 CEST"
 [7] "2023-10-29 01:30:00 CEST" "2023-10-29 01:45:00 CEST" "2023-10-29 02:00:00 CEST" "2023-10-29 02:15:00 CEST" "2023-10-29 02:30:00 CEST" "2023-10-29 02:45:00 CEST"
[13] "2023-10-29 02:00:00 CET"  "2023-10-29 02:15:00 CET"  "2023-10-29 02:30:00 CET"  "2023-10-29 02:45:00 CET"  "2023-10-29 03:00:00 CET"  "2023-10-29 03:15:00 CET"
[19] "2023-10-29 03:30:00 CET"  "2023-10-29 03:45:00 CET"  "2023-10-29 04:00:00 CET"  "2023-10-29 04:15:00 CET"