How do I know when to use u-substitution in a integral like this: $\int {x^2\over x^3+2}dx$?

Question: $$\int {x^2\over x^3+2}dx$$
I know I can use u-sub with $u=x^3+2$ and $du=3x^2dx$ to get:
$${\ln(x^3+2)\over3}$$
But what about a problem like:
$$\int 35\sqrt x e^\sqrt x dx$$
I first tried integrating by parts because I thought of it as functions $35\sqrt x$ and $e^\sqrt x$ multiplied together. I didn't know to set $u=\sqrt x$ until I got ${70\over 3}x^{3\over2}-35\int xe^\sqrt x$ through integration by parts (and then looked it up on an online calculator), and I'm assuming that would go into another loop of integration by parts because of the way derivatives with $e$ works.
How do I know whether to try a u-substitution or integration by parts first when there isn't an apparent function I can differentiate and easily replace within the integral? This includes problems with and without $e$.
Comment: On general principles of "substitute so that common terms are unified", I'd have tried the $u = \sqrt{x}$ substitution on that integral.
Comment: In this instance, $x$ appears only in the form $\sqrt{x}$, so I'd try substituting it away.
Comment: Thanks for the reply. Can you clarify which common terms you are talking about?
Comment: My rule of thumb is to look for composition of functions.  Let $u$ be the inside function and see what happens.  Seeing $e^\sqrt{x}$ would make me try $u=\sqrt{x}$.
Comment: Does this answer your question? [Is success realistic using u-substitution when the derivative isn't in the integrand?](https://math.stackexchange.com/questions/2881883/is-success-realistic-using-u-substitution-when-the-derivative-isnt-in-the-integ)
Answer: In $\int \frac{x^2}{x^3+2}$ you need to take the $u$ substitution of a term that cancels the numerator. Here if we take $u=x^3+2$ then $dx=\frac{du}{3x^2}$. So the $x^2$ term in the numerator gets canceled.
In the cases like $\int(6x^2)(2x^3+5)^6dx$ it is always advisable to take the number with the highest power. In this case $u=2x^3+5$
In the cases like $\int cos(5x-7)dx$ it is always advisable to take the number in the brackets. In this case $u=5x-7$
In the cases like $\int 35\sqrt{x}e^{\sqrt{x}}$ it is always advisable to take the exponent of $e$ as $u$. In  this case $u=\sqrt{x}$
Another example of this is $\int \frac{e^x}{e^x}dx=\int1+e^{-x}dx$, even in this case we take the exponent of e as $u$.
$u=-x$
Comment: Could you double-check your last example?
Comment: So in generally unless it's like my mentioned obvious case, I'd want to set the exponent of $e$ as u? Can you think of other integrals that wouldn't work this way?
Comment: Example-$\frac{e^x}{1-e^x}dx$ here we take $u=1-e^x$
Comment: Well I would say that's an obvious one with a clear u and du but thanks for the reply anyway


Subfield of a cyclotomic number field where a prime $p$ is inert

Question: I am reading this paper by Adleman,Lenstra on finding Irreducible polynomial over Finite field.
Here in Section VI(Proof of correctness of Algo B) I came across this argument:
Let  $q_i $ be a prime such that $q_i-1$ is square free. Then $\mathbb{Q}(\zeta_{q_i})$ contain a subfield $K$ such that $[K:\mathbb{Q}]=ord_{q_i}(p)$ and prime p is inert in $K$.
I am aware of following facts :

Cyclotomic polynomial splits in $\mathbb{F}_p$ as degree = $ord_{q_i}(p)$ irreducible factors.
Correspondence between splitting of ideal $ (p) $ in  $\mathbb{Q}(\zeta_{q_i})$ and factorization of $\Phi_{q_i}(x)$ in $\mathbb{F}_p$.
Since $ord_{q_i}(p) | q_i-1$, therefore there exist a field K' such that $[K':\mathbb{Q}]=ord_{q_i}(p)$.

But I am not sure of how these things give the claim given in the paper.
Answer: The galois group of cyclotomic field over $\Bbb Q$ is cyclic hence it will always contain such a subfield $\Bbb K$ and inertness follows from the fact that $\gcd([\Bbb K:\Bbb Q],[\Bbb Q(\zeta):\Bbb K])=1$ as $q-1$ is square free.


Espresso testing with Dagger 2 and custom scopes

Question: After a recent migration to Dagger 2, the app I am working on is using an @ActivityScope for every feature. Each app feature is implemented using MVP pattern and has it's own local dagger Component setup which depends on the Application component for the dependencies that are required during the entire app lifecycle (provided by the App). Each feature's Activity extends a base class which provides the main application component to a method that is overridden by each activity in order to set up the local dagger component (builds the local component and instantiates the local module).
The issue I am trying to solve is how to inject mocks into the Activity under test. The main problem I am experiencing is that I cannot swap the original local component and corresponding module with mocked ones at runtime. There are many articles on Espresso testing with Dagger 2 that I read, but they are not promoting clean architecture. For the most part they rely on the AppComponent to inject all Activities, where in my case, each feature's component is responsible for injecting it's own activity.
So far the best approach that I came up with was to  introduce a component builder that is only initialised as part of the test setup and in the Activity code to go with this setup if initialised, otherwise set up the real component.  However, I am reluctant to mix production and test code.
Here is a schematic which represents the Dagger setup:
Dagger 2 Setup
Answer: The approach that I took at the end was to create a custom AndroidJUnitRunner as described here and to create Components/Modules which provide mocks for each app feature, including the Application module check Google doc for best practices. Furthermore, each activity under test has to be overridden to inject the mocks (just the method that injects the mocked dependencies).
In order to keep the main app manifest clean, the overridden test activities are declared in a debug manifest.
Hope this approach helps people with a similar to my Dagger 2 setup to do their testing with Espresso and Dagger 2.
Have a rock 'n' roll day!


Rewrite formula using exponential generating functions

Question: In the equation below I want to extract $b_k$.
$$\frac{a_n}{n!} = \sum_{k=0}^{n}\frac{b_k}{k!(n-k)!}$$
For all other exercises in the book I had to use $e^x = \sum_{n=0}^{\infty}\frac{x^n}{n!}$ or its generating function, but I just don't see how I can use that now, to rewrite the function. I may be looking at the problem from a completely wrong direction.
Does anyone have a hint or a push in the right direction?
Thanks in advance.
Comment: Hi @pbs, that was the original formula in the book and because I am pretty sure I need to use generating functions, I already rewritten it to the formula I gave.
Answer: Suppose that:
$$ f(z) = \sum_{n\geq 0}\frac{a_n}{n!}z^n,\qquad g(z)=\sum_{n\geq 0}\frac{b_n}{n!}z^n. $$
Then:
$$ [z^m]g(z)e^z = \sum_{n=0}^{m}\frac{b_n}{n!}\cdot\frac{1}{(m-n)!}=\frac{a_m}{m!}=[z^m]f(z) $$
so $f(z)=e^z g(z)$, from which $g(z)=e^{-z} g(z)$. Since:
$$ e^{-z}=\sum_{n\geq 0}\frac{(-1)^n}{n!}z^n,$$
it follows that:
$$ \frac{b_n}{n!}=[z^n]g(z)=[z^n]e^{-z}f(z) = \sum_{m=0}^{n}\frac{a_m}{m!}\cdot\frac{(-1)^{m-n}}{(m-n)!}, $$
or:

$$ b_n = \sum_{m=0}^{n}\binom{n}{m}a_m (-1)^{m-n}.$$

Extraction complete.


how to extract characters until find a numeric in sub-string in asp.net c#

Question: how to extract characters until find a number in substring in asp.net c#
my string is like
NR21380
SR9956
NER6754
WR98765
SR98700
Comment: Where is your code showing your effort? What is expected output?
Comment: possible duplicate of [Regex for numbers only](http://stackoverflow.com/questions/273141/regex-for-numbers-only)
Answer: One easy way:
var firstLetterCharacters = text.TakeWhile(Char.IsLetter);

or the other way around:
var firstLetterCharacters = text.TakeWhile(c => !Char.IsDigit(c));

If you need a new string from it:
string newText = new string(firstLetterCharacters.ToArray());

Answer: You can use a regular expression to replace all non-letters:
string s=NR21380 SR9956 NER6754 WR98765 SR98700
string s2 = Regex.Replace(s, @"[^A-Z]+", String.Empty);

Answer: I just try to guess the output:
string s = "NR21380 SR9956 NER6754 WR98765 SR98700";
var list = s.Split()
            .Select(x => String.Join("", x.TakeWhile(c => char.IsLetter(c))))
            .ToList();

Output will be list of NR SR NER WR SR
Answer: try this
   String aa = "NR21380 SR9956 NER6754 WR98765 SR98700";
    //getting the first chars from the dummy string.
    var firstChars= Regex.Match(aa, @"[A-Z]+");


Concatenar aspas simples em variável de data?

Question: Tenho uma aplicação em VueJS e preciso concatenar aspas simples em uma varável que possui uma data como essa 2017-11-09T02:00:00.000Z .
Tentei da seguinte maneira e não tive sucesso:
var novaData = "'" + data + "'"
Tentei utilizar a mesma metodologia no servidor, porem ele me retorno o seguinte resultado:
'\'2017-11-02T02:00:00.000Z\''
E por nada nesse mundo não consegui fazer o replace() das \
O que eu preciso é que depois de concatenar a string que retorne seja parecida com isso:
'2017-11-02T02:00:00.000Z'
pois preciso da data nesse formato para fazer consultas no MongoDB.
Se alguém puder me ajudar eu agradeço...
Comment: Podes explicar melhor o formato original? tens uma string ou um objeto `Date`? Estás a enviar isso do Vue para o servidor?
Comment: Tenho um objeto `Date`, peço desculpas por me expressar mal, e sim, estou enviando do lado do cliente para o servidor
Comment: Sua pergunta está correta `Concatenar aspas SIMPLES...` ou seria `Concatenar aspas ...? Só para dar mais sentido as respostas
Answer: Você pode retonar a string da data com toISOString:

let dt = new Date();
console.log(typeof dt.toISOString(), dt.toISOString());
Answer: Podes enviar com o JSON.stringify, que cria uma string com aspas dentro da string:

var date = new Date();
var string = JSON.stringify(date);
console.log(typeof string, string); // string "2017-11-09T14:12:21.523Z"
Comment: É exatamente isso que eu preciso, funcionou perfeitamente...
Answer: Pergunta:
Concatenar aspas simples em variável de data? '2017-11-02T02:00:00.000Z'

var date = new Date();

var novaData = "'"+date.toISOString()+"'";

console.log(novaData);


Why is the value for ${applicationName} not supplied after migrating my Flutter app to Android embedding v2?

Question: I tried to immigrate a deprecated flutter application, but after following the steps provided on github im getting this
C:\Users\personal\AndroidStudioProjects\flash-chat-flutter\android\app\src\main\AndroidManifest.xml:10:9-42 Error:
    Attribute application@name at AndroidManifest.xml:10:9-42 requires a placeholder substitution but no value for <applicationName> is provided.
C:\Users\personal\AndroidStudioProjects\flash-chat-flutter\android\app\src\debug\AndroidManifest.xml Error:
    Validation failed, exiting

Comment: Can you add your AndroidManifest.xml file.
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: I ran into this as well. In my case it was because I had set manifestPlaceholders the "usual" way, by assigning with = (as all examples seem to do):
In android/app/build.gradle:
android {
    ⋮
    defaultConfig {
        applicationId "com.example.my_app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        // This right here!
        manifestPlaceholders = [someKey: "@string/some_value"]
    }
    ⋮
}

It turns out that multidex support introduced the need to dynamically determine the application name, hence the ${applicationName} placeholder in the manifest.
That value is determined by the Flutter Gradle plugin here by means of manifestPlaceholders, so if you replace the value by reassigning it then you will run into this issue. The fix is simple: add your values to the existing ones with += like so:
android {
    ⋮
    defaultConfig {
        applicationId "com.example.my_app"
        minSdkVersion flutter.minSdkVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
        // Fixed now! Note the plus!
        manifestPlaceholders += [someKey: "@string/some_value"]
    }
    ⋮
}

Answer: I got the same error:
You need to add this to your build.gradle (YourFlutterProject/android/app/build.gradle)
buildTypes {
    release {
        manifestPlaceholders = [applicationName: "android.app.Application"]
    }

    debug {
        manifestPlaceholders = [applicationName: "android.app.Application"]
    }
    build{
        manifestPlaceholders = [applicationName: "android.app.Application"]
    }
}

Comment: You do not need to do this; the framework does it for you. In fact the framework *needs* to do it dynamically in order to handle multidex scenarios properly. Per my answer, you simply need to avoid *overwriting* the values the framework provides.


Orientation and simplicial homology

Question: I'm reading Chapter 2 of Hatcher's Algebraic Topology, and I just can't figure out the computations of the boundary homomorphism for the examples provided. To provide some context, reproduced the figure for the torus from the book below:

As I understand it, to compute $\partial U$ we follow the faces (which are edges) counter-clockwise, negating an edge if the oriented arrow is "facing us." But starting in the top right corner and working around U results in $\partial U = (-1)^0 (-b) + (-1)^1 (-a) + (-1)^2 c = a - b + c$, which contrasts with the book's result of $\partial U = a + b - c$. I seem to be making some critically flawed assumptions. What am I not understanding?
Comment: Did you double-check that you correctly copied the labels from the book?  It looks to me like $\partial U = c - b - a$ and $\partial L = a - c + b$, so maybe you mixed up $U$ and $L$.  Other possibility is orientation - is Hatcher going clockwise?
Comment: I edited to include the picture in the post. I hope this is okay.
Comment: I've included the actual picture from the book (I opened [the pdf file of the book](http://www.math.cornell.edu/~hatcher/AT/ATpage.html) and took a screenshot of the page).
Comment: @Neal, I just checked again and I copied the labels correctly. From a figure later on in the book, it shows computations of boundaries with a counterclockwise motion. That, along with the following comment that "the orientations of the two hidden faces are also counterclockwise when viewed from the outside the 3-simplex," seems to me that I should also be going counterclockwise. But it's clear I'm definitely making a mistake somewhere, as he also notes that $\partial U = \partial L$, which only confuses me more.
Comment: @ZevChonoles and Jim Conant, thanks for the touch ups!
Answer: I don't understand your description of the boundary map, or your explicit calculation.  Here is how the calculation goes:
Imagine that you are standing in $U$, making a counterclockwise pivot, and looking at the boundary (in the naive sense) as you do so.  Let's begin facing the top right corner.  As we turn, our field of vision sweeps out $b$, but in the opposite direction to its arrow (we sweep out $b$ from right to left, while the arrow points from left to right), then $a$, again in the opposite direction to its arrow, and finally $c$, in the same direction as its arrow.
So $\partial U = -b - a + c$.  (If the text instead writes it as $a + b - c$, it must use the opposite orientation on $U$, i.e. a clockwise, rather than counterclockwise, orientation.)
The same procedure applied in $L$, starting by facing the lower right corner, yields $\partial L = a - c + b$, which is $- \partial U$, as one would expect.  (When you glue the $U$ and $L$ into a torus, the boundaries get glued to together, and so "cancel" one another.)
Comment: Thanks for the explanation! I think my error was in trying to use $\partial_n(\sigma_\alpha) = \sum\limits_i (-1)^i \sigma_\alpha | \left[v_0,\cdots,\hat{v_i},\cdots,v_n\right]$ in some horrible combination with the orientations given by the figure.
Comment: @bananas: Dear bananas, you're welcome!  Regards,

Orientation and simplicial homology


True or False question for Fubini's Theorem

Question: a) Is it true that $$\iint_{R} f(x,y)dydx=\iint_{R} f(x,y)dxdy$$
I thought this would be true because of Fubini's Theorem however Fubini's Theorem requires $f(x,y)$ to be continuous on $R$. There is no such condition in this problem. Therefore it is false?
b) If $R$ is the rectangle $0\leq x\leq a, 0\leq y\leq b$ and $S$ is the rectangle $-a\leq x\leq 0, -b \leq y\leq 0$ then
$$\iint_{R} f(x,y)dA=-\iint_{S} f(x,y) dA$$
I think this is false and the counter example I would use is
$f(x,y)=1$
Then $\int_{0}^{b}\int_{0}^{a} dydx = \int_{-b}^{0}\int_{-a}^{0}dydx$
Is this correct?
Comment: There is no continuity in Fubini's Theorem. Where did you read  Fubini's Theorem from?
Comment: https://tutorial.math.lamar.edu/classes/calciii/IteratedIntegrals.aspx
Comment: So is the answer then true?
Comment: Well, the result is true without continuity but I can prove it only using Measure Theory.
Comment: hmmm but I am in a vector calculus course, I have not learned any measure theory. So is the answer true for me?
Comment: In the link that I posted, it says that $f(x,y)$ needs to be continuous, but that is only over a rectangle. Is that why?
Answer:
a) Is it true that $$\iint_{R} f(x,y)dydx=\iint_{R} f(x,y)dxdy$$
I thought this would be true because of Fubini's Theorem however
Fubini's Theorem requires $f(x,y)$ to be continuous on $R$.

The continuity version of Fubini's Theorem in $\mathbb R^2$ is a special case.
The above equality does hold as long as $\int f(x,y)\,\mathrm dx$ and $\int f(x,y)\,\mathrm dy$ both exist on rectangle $R$'s respective edges.

b) If $R$ is the rectangle $0\leq x\leq a, 0\leq y\leq b$ and $S$ is
the rectangle $-a\leq x\leq 0, -b \leq y\leq 0$ then
$$\iint_{R} f(x,y)dA=-\iint_{S} f(x,y) dA$$
I think this is false and the counter example I would use is
$\int_{0}^{b}\int_{0}^{a} dydx = \int_{-b}^{0}\int_{-a}^{0}dydx$
Is this correct?

Yes (ignoring your typo where you interchanged $x$ and $y).$


performing few actions when adding a new specific class

Question: When my page is loading the is no class "changed_value" in the page.
I am adding the calss "changed_value" in several places in the code.
In case of adding this class I wish to perform several actions.
The problem is that  don't wish to write all these actions each time I add the class.
Is there a way to call to some function which will perform the few requested actions in case of adding (at the first time or every time) this new class?
Means, is there a trigger such 'change', 'click' but for adding new class?
Like addedClass?
(I am sure there is no such trigger but I need this idea)...
Thanks in advance!
Miki
Answer: Why don't you refactor your common code into a function, which you use to add the class? Something like:
function addClass($element) {
    $element.addClass("changed_value");
    // other code here
}

And then use it every time you want to add that class:
addClass($("my_selector"));

Comment: Thanks! it can be a greate idea!
Answer: you could something like this
function do_something(){
   // do something
}

$('selector').click(function(){
    $(this).addClass('class');
    do_something();
});


expectation of random probability measure

Question: Given $\mu(\omega, B)$ is a random probability measure on $\mathbb{R}_{\geq 0}$. This means for each $B$, it is a random variable, and for each $\omega$ it is a probability measure.
How could I show that
$$\mathbb{E}\bigg[\int_\mathbb{R} f d\mu\bigg] =\int_\mathbb{R} f d\mathbb{E}[\mu]$$
where $f$ is a bounded continuous function?
If $f$ is also differentiable, using Fubini theorem, we can rewrite
$$\int_\mathbb{R} f d\mu = \int_0^\infty f d\mu=\int_0^\infty f'(x)\mu(x,\infty) dx.$$
Is there any measurability issue for $\mu(x,\infty)$ when switching the expectation with the integral in the term below
$$\mathbb{E}\bigg[\int_0^\infty f'(x)\mu(x,\infty) dx\bigg]?$$
Answer: Measurability is not an issue but your second equality needs justification.
There is a  much simpler way. The required identity is obvious when $f$ is an indicator function. Hence it is true for simple functions, hence for non-negative measurable functions and finally for all functions for which the integrals exist. For bounded continuous functions the integrals do exist.


Probability problem (Urn 1 contains 3 white and 4 black balls, and Urn 2 contains 2 white and 6 black balls ...)

Question: I'm studying probability. This is not homework. I have been studying for a graduate master's since September 2015. The textbook is Probability : An Introduction (Grimmett & Welsh).
You are presented with two urns. Urn 1 contains 3 white and 4 black balls, and Urn 2 contains 2 white and 6 black balls.
(a) You pick a ball randomly from Urn 1 and place it in Urn II. Next you pick a ball randomly from Urn 2. What is the probability that the ball is black?
I made the following reasoning.
Prob of picking black from the Urn 1 = P(B1) = 4/7
Prob of picking white from the Urn 1 = P(W1) = 3/7
Prob of picking black from the Urn 2, after placing the picked ball in it = P(B2) = ?
B1 and W1 are a partition of Omega so I can use the partition theorem:
P(B2) = P(B2|B1)*P(B1) + P(B2|W1)*P(W1)
I intuitively know that P(B2|B1) = 7/9, because, given that I picked a black ball from the Urn 1 and placed it in the Urn II, now I have 7 possibility of success and 9 possible outcomes.
I intuitively know that P(B2|W1) = 6/9 for the same reason.
Then P(B2) = 7/9*4/7+6/9*37 = 0.73
I would like to know if my reasoning is correct and what is the formal way to show that P(B2|B1) = 7/9 and P(B2|W1) = 6/9.
Comment: Please add the `[self-study]` tag & read its [wiki](http://stats.stackexchange.com/tags/self-study/info).
Answer: The formality you request uses conditional probabilities..   A probability tree is a good way to reason with them.  Use it as a guide to the formal demonstration.

Let's begin at the end: what is the chance the ball is black?  It depends on what happened before.  That's the conditioning event.  So:

Let $\mathcal B$ be the event that the first ball is black and $\mathcal B ^\prime$ be the event it is not black.  Evidently $\Pr(\mathcal B) = 4/(3+4) = 4/7$ and $\Pr(\mathcal B^\prime) = 1 - 4/(3+4) = 3/7.$

Let $\mathcal C$ be the event that the ball selected from the second urn is black.  When $\mathcal B$ occurs, the second urn has $2$ non-black and $6+1$ black balls.  Otherwise, when $\mathcal B^\prime$ occurs, the second urn has $2+1$ non-black and $6$ black balls.  Consequently

$$\Pr(\mathcal C\mid \mathcal B) = \frac{6+1}{2 + (6+1)} = \frac{7}{9}$$
and
$$\Pr(\mathcal C\mid \mathcal B^\prime) = \frac{6}{(2+1) + 6} = \frac{6}{9}.$$
Because $\mathcal B$ and $\mathcal B^\prime$ are disjoint and partition the initial outcomes, the Law of Total Probability asserts
$$\Pr(\mathcal C) = \Pr(\mathcal C\mid \mathcal B)\Pr(\mathcal B) + \Pr(\mathcal C\mid \mathcal B^\prime)\Pr(\mathcal B^\prime) = \frac{7}{9}\times \frac{4}{7} + \frac{6}{9}\times \frac{3}{7} = \frac{28 + 18}{63} = \frac{46}{63}.$$


Natural log of 2 from geometric series

Question: We have that the Taylor series expansion of the natural logarithm function is $$\text{log}(x) = \sum_{n \geq 1}\frac{(-1)^{n+1}}{n}(x - 1)^n$$ and that its interval of convergence is $(0, 2]$, which is not hard to establish using e.g. the Ratio test (plus independent boundary analysis). However, I am aware of an alternative derivation of the Taylor series of log$(x)$ using geometric series, but I am uncertain of the behavior at the boundary. Specifically, using the fact that $\sum_{n \geq 0}r^n = \frac{1}{1 - r}$ for $|r| < 1$, we have that $$\frac{d}{dx}\text{log}(x) = \frac{1}{x} = \frac{1}{1 - (1 - x)} =^* \sum_{n \geq 0}(1 - x)^n$$ and so integrating should give us the Taylor series for log as already given. However, regarding the "$=^*$", we only have equality when $|1 - x| < 1$, i.e. when $x \in (0, 2)$. This means that this derivation does not justify why $x = 2$ is in the interval of convergence. How are we supposed to be able to infer the fact that the series also converges at $x = 2$ based off this derivation? Does this simply mean that this derivation is not rigorous/complete, and we should instead use alternative methods to establish that the given series really is the Taylor series of log$(x)$?
Comment: Generally speaking, convergence on the boundary cannot be resolved via kinds of tests which give absolute convergence in the interior of the interval of convergence.  In this case, with $x=0$, the resulting series is the Harmonic Series (which diverges---this is a fairly standard result), and with $x=2$, the resulting series is the Alternating Harmonic Series (which converges by the alternating series test).
Comment: The interval of convergence is $(0,2]$; the radius of convergence is $1$.
Comment: Oops, my mistake. Thanks for pointing it out - it's fixed now.
Comment: That being said, you seem to claim (in your first sentence) that you can establish convergence at $x=2$ using the ratio test.  I do not believe that this is correct.
Comment: I guess I am being slightly loose with my justification- what I really mean is "Ratio test plus independent boundary analysis".
Comment: I understand that these series do diverge (resp. converge) at $x = 0$ ($x = 2$) it is just that I am unsure why there is this seeming inconsistency: on the one hand we can independently verify that the series converges at $x = 2$, but on the other it seems that it shouldn't based on the formula/convergence criteria for geometric series. The geometric series derivation suggests that the series should diverge at $x = 2$, yet we can see at the end that it does not.
Comment: Under what conditions are you "permitted" to bring an integral or derivative into a sum?  You might want to check those hypotheses carefully.  The geometric series converges (absolutely) on an open interval; the series obtained by integrating that series converges (*a priori*) on that same open interval.  The behaviour on the boundary is not given by any particular theorem that I am aware of.
Comment: Ok I see. So we can say that log(x) is the integral of the sum, but as soon as we want to distribute the integral to each summand, we can only do so assuming absolute convergence of the series. And we do not have that for $\sum_{n \geq 0}(1 - x)^n$ at $x = 2$, meaning it bears no relationship to the integrated series $\sum_{n \geq 1}\frac{(-1)^{n+1}}{n}(x - 1)^n$ outside that interval of (absolute) convergence, namely at $x = 2$. Is that your point? In any case, thanks for your help!
Answer: The questions are:

"How are we supposed to be able to infer the fact that the series also converges at $x=2$ based off this derivation?" We can't, as you observe.
"Does this simply mean that this derivation is not rigorous/complete, and we should instead use alternative methods to establish that the given series really is the Taylor series of $\log x$?" The derivation is not complete in this detail, but it's certainly rigorous: it correctly proves the implication "if $|x-1|<1$ then the Taylor series converges to $\log x$", without making a claim for other values of $x$.
Comment: Thank you for your feedback. And as was pointed out in the comments, the reason that the analysis is not complete (in the sense of neglecting the case of $x = 2$) is that we can only integrate when the series converges absolutely, which is not the case for the above geometric series at $x = 2$. This explains why the geometric series diverges at $x = 2$ while the integrated series (corresponding to log(x)) converges at $x = 2$.

Natural log of 2 from geometric series


display user input from do while loop C#

Question: I have some code below that is almost finished, but the last thing I want to do is for the console app to display the number they have gotten from the user
EX: if user input 1, 3, 5
the console will display
The number you have inserted are:

One
Three
Five

Is it possible to do that ?
Thanks
static void Main (string []args)
        {
            string again;
            do
            {
                Console.Clear();
                Console.WriteLine("Insert Random number");
                int number = int.Parse(Console.ReadLine());

                Console.WriteLine("Would you like to Insert another number ?(Enter Y for yes /Enter any other key to exit)");
               again = Console.ReadLine();
            } while (again == "Y");

            Console.WriteLine("The number you have inserted are: ");

            Console.ReadKey();
        }

Comment: if i understand correctly, maybe this [answer](https://stackoverflow.com/questions/3213/convert-integers-to-written-numbers) will help
Comment: Of course, if your requirement is to translate an Arabic numeral (such as "1") to an alphabetic representation of that number (such as "One"), then you are looking at a **much** different problem, with a lot of interesting challenges around localization and translating the number into text, depending on the scope of the problem. For example, translating "1,001,010" into "one million one thousand ten" is actually quite tricky.
Comment: "Is it possible?" Of course it's possible. You need to store the user's input in some sort of list (like, perhaps, a `List`), and then at the end, iterate over the entries in the list and display them, or join the entries in the list into a string (with, perhaps, `string.Join`). Stack Overflow is not a code-writing service. Please attempt to solve the problem on your own and feel free to ask a question if you have a specific issue with implementing your solution.
Answer: First, you need a place to keep all the numbers you collected. Given this code, you may be expected to use an array, but real code is more likely to use a generic List<int>. Declare it near the beginning of the Main method like this:
List<int> numbers = new List<int>();

Add each number to it after Parse()-ing like this:
numbers.Add(number);

Then, in between the final WriteLine() and ReadKey() calls, you need to loop through the collected numbers:
int i = 0;
for (int i = 0; i < numbers.Length; i++)
{
    Console.WriteLine($"{i+1}. {numbers[i]}");
}

What you won't be able to do in a simple way is convert the digit 1 to the text value One. There's nothing built into C# or .Net to do that part for you. Since this code looks like a learning exercise, I'll leave you to attempt that part on your own.
Comment: Thank you for the answer, this array is probably what i need

my real assignment is actually to record a dish user want to eat
and then display it as a full course menu
but simplified it should look like that question

but the structure shouldn't be that different right ?


How to interpret posterior distribution plots for multiple priors?

Question: Let us consider the following Bayesian model:

$f(x|\mu, \theta)$ the observation model,
$\pi(\mu, \theta)$ the joint prior distribution,
$\pi(\mu, \theta|x)$ the posterior distribution.

It is possible to obtain the posterior distribution with a MCMC sampler. Then the posterior distributions can be plotted. Using Python pymc3 plot_posterior function for example, two pdf figures would be obtained: one for $\mu$, one for $\theta$. It seems these figures are fairly standard (I saw them too in Matlab documentation), so I doubt this is a pymc3 specific feature.
How do these figures relate to $\pi(\mu, \theta|x)$?
Answer: I would say the model you present has one prior for multiple parameters (in this case two: $\mu$ and $\theta$). Because there are two parameters, the prior is a joint prior. Similarly, there is a single joint posterior distribution for the two parameters: $\pi(\mu,\theta|x)$. I'm guessing the software that you refer to produces plots of the two marginal posterior distributions,
\begin{equation}
\pi(\mu|x) = \int \pi(\mu,\theta|x)\,d\theta
\end{equation}
and
\begin{equation}
\pi(\theta|x) = \int \pi(\mu,\theta|x)\,d\mu .
\end{equation}
In order to plot the joint posterior distribution (I'm guessing) you would need a different command.
Comment: I believe this answer is spot on; the only thing I can add to help answer the question is that from the MCMC sampler you should have paired samples for $\mu$ and $\theta$.   You can visualise  $ \pi ( \mu , \theta | x ) $   by doing a 2 variable density plot of these samples something like [this](http://2.bp.blogspot.com/-ZsGCOtScfq8/VATD76-mOpI/AAAAAAAAB3k/etTqFIpXIPY/s1600/hexbin2.png) perhaps


How to attach a view display switch to a view?

Question: I am wondering how I can attach a switch/ link from one view display to another view display within the same view. I can only think of messing around in the template files and hardcoding this navigation.

What is the best solution/ is there a better solution for that?
Update: both displays shall have a own url this for caching and possibility to link to a specific display.
myview/(default: display-table)
myview/display-table
myview/display-list

Comment: Use [Quicktabs](https://drupal.org/project/quicktabs) module
Comment: I fear quicktabs might be an overkill for that. I will wait for more answers
Answer: Display Suite
A possible solution to this is probably utilizing display suite.
You could trigger a link using display suite & display suite extras to open different view mode. The drawback to this is that the user would have to load a different page.
Quicktabs
Another solution would be to load the two views as blocks and use quicktabs to display the two views in that tab format you require. The drawback to this solution is that you have two views loaded.
Views Header
At the top of your views, just add a header anchor to your other views page. This solution is best if you just have one view where this output is being displayed. Otherwise, it would be difficult to maintain duplicate views.
Comment: actually I am fine with reloading that page. the content should not be preloaded. I update the question
Comment: Well then your solution seems to be best suited to try display suite and display the view as a entity.
Answer: There is the View modes module which does exactly what you need. However there is only a development version available.
If you prefer to avoid installing modules for small tweaks like this, you might want to create a simple switch in the views header.
You can do that either by adding a text area to the header of the view (notice this will require the PHP text filter to work properly), alternatively you can implement hook_views_pre_view to attach a header dynamically (-> better option).
For the link to retain page and filter values you will have to use the l() function along with drupal_get_query_parameters().
Take a look at the blog post I wrote for more details.
Comment: enabling PHP text filter really should not be recommended. hook_views_pre_view to attach the header is the better option, but still - after all this time I think my option of creating a menu, putting links to each view page in it, and using context to add this menu to whatever area the view is showing up when the view is beeing viewed is a good solution, which doesnt require code at all and still uses all inbuilt solutions (menu trail etc)
Comment: Context module is not inbuilt and displaying static links depending on url could be done with a simple (menu-) block, not requiring the Context module at all. However neither the context nor the block solutions will suit most use cases as they do not respect filters and page number - hence my answer. But since it's your question I guess you know what's best for you ;)
Answer: I actually found a good solution for this problem using the built-in menu system, providing menu links to these view pages and attaching the menu to the view using context module.
This works even better with Icon API


GCM - Only 200 devices out of 3000 received GCM push

Question: On the 24th of June 2014 ~10:30 (+2 UTC time zone) , we sent 3000 devices push notifications. The push was sent in groups of 50 with a 1 minute interval in between.
We received a success response from gcm for almost all the devices, but out of the 3000 different devices , only 200 acknowledged the push.
The push was sent through GCM HTTP Connection Server
All the devices where located in Singapore.
I would like to know if there are any known issues or limitations for that area or for the scenario we described?
Is there any way for you to confirm the push was actually delivered to all the devices. (other than the message we received when we sent the push).
thanks.
Comment: This question appears to be off-topic because it is about confirming Google's level of service in a certain geographical area. It's not a programming question.
Comment: yes but maybe more people encountered this kind of problem, if it's not GCM problem it's a problem with my app code so it's programming error....
Comment: "your system"? - well it certainly wasn't Stackoverflow's system, so I'm not sure what you expect this forum to do about it.
Comment: @JoseRo Your question is about confirming a level of service. There's no programming content so it's off-topic. If you ask a question about why your code behaves this way, supported by code snippets and sample data then possibly it would be on-topic.
Answer: only 200 acknowledged the push.
What do you mean by acknowledged here? Do you have any acknowledgement(webservice) service running that updates status of received GCM? If yes, problem could be with that webservice too.
Is there any way for you to confirm the push was actually delivered to all the devices.
No. There is no other way other than the one I mentioned above to know delivery status.
Comment: my app sends update to the server when the push received, on all my tests and all scenarios the app send the "ack" to the server, of course it could be bug on the app or the server, but I never encountered such problem on my client so I think something was wrong with the Push,  I tried to contact the google support but they refused to help me.


Automatically clear cache

Question: Theme: Basic 8.x-1.x-dev
I am trying to clear theme data after any change is done to twig files.  I see that rebuildThemeData is here: https://goo.gl/EA2YL4
Currently have this within my .theme file.
\Drupal::service('theme_handler')->rebuildThemeData();

\Drupal::service('theme.registry')->reset();

Does anyone have this sort of implementation complete and working for an example?
https://www.drupal.org/node/2608470
Answer: There are some defaults that ship with D8 in your sites/default configuration files that you can configure during development.
The application portion:
Open development.services.yml in the sites folder
and add the following block (to disable twig cache)
        parameters:
          twig.config:
            debug : true
            auto_reload: true
            cache: false

There is more information on this Drupal.org node.
Comment: Thanks Alex, Im actually attempting to do this within the theme in order to make it simpler for other themers to just check a box in the theme settings.    I will modify my question

Automatically clear cache


Assigning userform textbox entry to a variable in VBA procedure

Question: I have code that produces a userform, titled MaterialForm, which contains a textbox, titled txtGravity. My goal is to take the entry in the txtGravity box, check it to determine if it is numerical, and then store the numerical value as a variable to use in my procedure.
In the code that I am providing, the numerical check is working as intended and will only pass integers. The conversion from string to double is not working, however; and is storing the value "0" in my variable EnteredGrav.
Here is the code
Private Sub Cmd_Save_Click()
    With txtGravity   'Check for non-numerical or empty values
    If IsNumeric(.Text) = False Or Len(.Text) = 0 Then
        .Text = ""
        MsgBox "It must be a numeric value"
        .SetFocus
        Exit Sub
    Else  'Convert the text (string) to the data type double
        EnteredGrav = CDbl(Trim(txtGravity.Value))
    End If
    End With
End Sub

Thanks for any help you can provide!
Comment: It's declared as Double. And yes at the top of the module option explicit is stated. Does it need to be stated again before each sub? And sorry, what do you mean by how is the code triggered?
Comment: `Option Explicit` should be once only per module, on the top of the module. Thus it is ok. Concerning the triggered code - how do you call the code, how does it start, what do you do to start it? Can you make a [MCVE], which would be enough for anyone just to copy and paste it and to get the same error? If you provide this in your question, it would be answered quite quickly.
Comment: How is EnteredGrav declared? Do you have `Option Explicit` on the top of the value? Probably you are having a grammar error. How is the code triggered?
Comment: I updated the code with my sub info, but I'm not sure how to provide the code to produce the userform...if what I've provided isn't enough then thank you for attempting to help
Comment: you are still within your With block, EnteredGrav = CDbl(Trim(.Value)) so no need to specify txtGravity
Comment: What is the name of the userform after you produce it? What you need to do there is to ensure that the textbox that you are referring to is under the userForm that you produce.

You can try to use this With UserFormName.txtGravity instead of calling it txtGravity
Answer: Try these 3 lines:
Private Sub Cmd_Save_Click()

    Dim enteredGrav As Double
    enteredGrav = CDbl(Trim(Me.txtGravity.Value))
    MsgBox enteredGrav

End Sub

If it works, try building your code from there. Probably you are not entering the condition or not declaring correctly.


How to show tootlip for steparea series of the telerik chart?

Question: Not able to get the tooltip for the StepArea Series. Its working for Bar series but StepAreaSeries is having a problem.
Code is as below.
var limitSeries = new StepAreaSeries
                {
                    CategoryBinding = new GenericDataPointBinding<ChartDataItem, string> { ValueSelector = v => v.Name },
                    CombineMode = ChartSeriesCombineMode.Stack,
                    ValueBinding = new GenericDataPointBinding<ChartDataItem, decimal?> { ValueSelector = v => v.Limit },
                    RisersPosition = StepSeriesRisersPosition.OnTicks
                };
                limitSeries.SetBinding(ChartSeries.ItemsSourceProperty, new Binding(nameof(ChartDataItems)) { Source = this });
                limitSeries.SetValue(ChartAnimationUtilities.CartesianAnimationProperty, CartesianAnimation.Rise);
                limitSeries.TooltipTemplate = (DataTemplate)Application.Current.Resources["tttt"];
                ChartSeriesSource.Add(limitSeries);

XAML
<controls:CartesianChart.Behaviors>
       <telerik:ChartTooltipBehavior />
</controls:CartesianChart.Behaviors>

<DataTemplate x:Key="tttt" DataType="charting:CategoricalDataPoint">

Answer: Defined the PointTemplate , and then I was able to see the tooltip.

Issue is it cannot take the actual height and width dynamically as in barseries.


Is it possible to redirect anonymous users from /admin to /user?

Question: Say I have a site called drupal.local, the user login page would be drupal.local/user. And the admin 'homepage' would be drupal.local/admin.
The problem is that lots of people seem to expect drupal.local/admin to lead them to the login page if they are not already logged in. Unfortunately instead of doing that, they just get:

You are not authorized to access this page.

I guess (thinking about it) a decent solution would be to put a link to the login page in the 403 error template text - but it would be more elegant to redirect the user to /user if they weren't already logged in.
Is it possible to do such a thing?
Answer: Sure, you can install a module like Redirect 403 to User Login:

Redirect the HTTP 403 error page to the Drupal /user/login page with an optional message that reads:

"Access denied! You must login to view this page."

Also, the desired page is appended in the url query string so that, once login is successful, the user is taken directly where they were originally trying to go.
Comment: Awesome, just what I was looking for :)
Answer: You can also go for LoginToboggan
Provide a login form on Access Denied pages for non-logged-in (anonymous) users.

Comment: Thanks, seems like there's plenty of other useful things you can do with this one too :)
Answer: You could use the Rules module for this. Here is the rule you'd need for it (in Rules export format, just use copy/paste to import it in your own setup):
{ "rules_redirect_admin_path_to_user_path" : {
    "LABEL" : "Redirect admin path to user path",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules" ],
    "ON" : { "init" : [] },
    "IF" : [
      { "user_has_role" : {
          "account" : [ "site:current-user" ],
          "roles" : { "value" : { "1" : "1" } }
        }
      },
      { "text_matches" : {
          "text" : [ "site:current-page:path" ],
          "match" : "admin",
          "operation" : "starts"
        }
      }
    ],
    "DO" : [
      { "drupal_message" : { "message" : "To access this path (= /admin) you need to login first, you will be redirected automatically to  path (= /user)." } },
      { "redirect" : { "url" : user" } }
    ]
  }
}

This rule uses 2 Rules Conditions:

Is this an anonymous user?
Does the current path start with /admin?

Whenever such redirect actually happens (that is: both Rules Conditions are satisfied), the user will also receive an informational message like so:

To access this path (= /admin) you need to login first, you will be redirected automatically to  path (= /user).

If you don't want such message to appear, then just delete the line containing drupal_message in the exported rule above.
Similar to the previous answers, it might require you to enable an extra contributed module (Rules). But, as indicated by its growing popularity also, that module is probably already enabled in mostly any site (similar to the Views module), because there are dozens of use-cases for this module).
Note: IMO it makes sense to perform such redirect for any path that starts with /admin. But should you rather prefer to perform such redirect only for an exact match for path /admin (instead of starting with such path), then simply replace the 2nd Rules Condition with this one (that is: omit the "operation" which is "starts"):
  { "text_matches" : {
      "text" : [ "site:current-page:path" ],
      "match" : "admin"
    }
  }


What does (loco) mean?

Question: I was reading the classical guitar article on wikipedia and saw this "(loco)" notation used to describe the playing range of guitar:

What does "(loco)" mean?
Answer: "Loco" means "in place", and in a musical context "at this exact pitch" and negates a previous "8va", "8vb" or similar marking. Guitar music sounds an octave lower than it is notated (the '8' under the treble clef on the left implies this, but it's not usually written). The notes on the right are the highest playable notes written as they sound without the octave transposition.
In case it's not clear: the notes on the left are the open strings (sounding an octave lower).

What does (loco) mean?


How to fix this C3848 error on vs2013?

Question: I'm trying to implement Best First Search using C++ on VS2013. Below is the code.
    //node for tree
    struct Node
    {
        Node(std::string const& s, std::string const& p)
            : state(s), path(p)
        {}

        const std::string state;
        const std::string path;
    };

    //heuristic functor
    struct ManhattanDistance
    {
        std::size_t operator()(std::string const& state, std::string const& goal)
        {
            std::size_t ret = 0;
            for (int index = 0; index != goal.size(); ++index)
            {
                if ('0' == state[index])
                    continue;

                auto digit = state[index] - '0';
                ret += abs(index / 3 - digit / 3) + abs(index % 3 - digit % 3);// distance(row) plus distance(col)
            }

            return ret;
        }
    };

    //functor to compare nodes using the heuristic function.
    template<typename HeuristicFunc>
    struct GreaterThan
    {
        explicit GreaterThan(HeuristicFunc h, std::string const& g = "012345678")
            : goal(g), heuristic(h)
        {}

        bool operator()(Node const& lhs, Node const& rhs) const
        {
            return heuristic(lhs.state, goal) > heuristic(rhs.state, goal);
            return true;
        }

        const std::string goal;
        const HeuristicFunc heuristic;
    };

When testing this code in Unit Test, compiler complained that :

Error  1   error C3848: expression having type 'const ai::search::ManhattanDistance' would lose some const-volatile qualifiers in order to call 'size_t ManhattanDistance::operator ()(const std::string &,const std::string &)'

How to understand this error? How to fix it?
Comment: Hi @UlrichEckhardt ,not DFS or BFS. Best First Search uses a heuristic function to evaluate each node, so that we can use this value as the key to order nodes in a priority queue. This way sometimes has better performance than plain DFS or BFS. Check here for more detail : http://en.wikipedia.org/wiki/Best-first_search
Comment: Possible duplicate of [expression having type 'const CompareVPtrs' would lose some const-volatile qualifiers in order to call](https://stackoverflow.com/questions/19816139/expression-having-type-const-comparevptrs-would-lose-some-const-volatile-quali)
Comment: Don't you mean "Depth First Search" or "Breadth First Search"? "Best First Search" is new to me...
Answer: Your method std::size_t ManhattanDistance::operator()(std::string const& state, std::string const& goal) is not declared const, yet you try to call it on a const ManhattanDistance object.  The compiler is correctly rejecting this ill-formed program.
Change the defining line to declare the method const:
std::size_t operator()(std::string const& state, std::string const& goal) const
//                                                                        ^^^^^

How to fix this C3848 error on vs2013?


package does not exist (Maven)

Question: Vamos contextualizar o problema:
Tenho um projeto que consome alguns Web Services, nesse projeto tenho source folders separados conforme padrão sugerido pelo Maven ex:(main/java test/java), as classes geradas com base nos WSDL dos Web Services acabei separando em main/wsdl para que fosse possível excluí-las da cobertura de testes (Eclemma), foi a única forma que eu encontrei para fazer isso.
Quando eu executo o comando install do Maven via Eclipse tudo ocorre bem, porém ao executar o mesmo comando via linha de comando ele lança uma exceção dizendo que os pacotes que constam minhas classes geradas não existem (se perdeu).
Alguém já passou por isso e sabe como resolver?
Comment: Difícil dizer, mas parece que você tem o projeto Eclipse configurado para gerar as classes enquanto o projeto Maven não faz isso. É aquele momento em que você descobre que a IDE maravilhosa que faz tudo pra você acaba atrapalhando quando você tenta fazer as coisas sem ela.
Comment: Se quiser uma resposta mais específica, por favor, edite sua pergunta e acrescente detalhes sobre a geração de classes e sobre a configuração do seu projeto.
Comment: @utluiz não sei quais detalhes eu poderia acrescentar para que fique mais claro, qual parte você não entendeu?
Comment: Poderia postar, por exemplo, o trecho do `pom.xml` onde está configurada a geração de classes a partir do WSDL e também o trecho onde você inclui esse diretório no build. Entenda que o Maven não executa igual pelo Eclipse e por linha de comando. No Eclipse, ele depende de um plugin paga funcionar, que geralmente é o M2E (Maven to Eclipse). Esse plugin faz algumas "mágicas" beseado nas configurações do Eclipse que ficam no arquivo '.project', que ajudam no uso da IDE, mas te deixam na mão sem ela.
Comment: Não é que eu não entendi seu problema, só que não dá para adivinhar a causa sem saber como o projeto está configurado.
Comment: vou tentar esclarecer, os meu pacotes estão separados em: src/main/java (classes criadas por mim), src/main/resources (.properties e etc...) src/main/wsdl (classe geradas com base nos Web Service que consumo de outra aplicação) src/test/java (Testes unitários), quando dou o install pelo eclipse tudo ocorre bem, via linha de comando ele diz que não foi possível encontrar os pacotes (imports) das minhas classe geradas com base nos WSDL
Comment: Eu entendi perfeitamente o que você disse que fez, mas se você não mostra **como** fez não adianta nada. Não tenho como adivinhar. Como vou saber que a configuração feita está correta? Tudo o que eu tenho é a sua palavra de que *deveria* ser de tal e tal jeito. Mas se você acha que sua configuração está correta, então não sou eu quem vou falar que tem alguma coisa faltando ou incorreta.
Comment: @utluiz Acabei resolvendo o meu problema da seguinte forma, movi meu source folder de: src/main/wsdl para src/main/java/wsdl, eu pesquisei um pouco e descobri que o maven por padrão busca os fontes em src/main/java, o que estiver fora disso ele ignora, não achei uma maneira de configurar para que ele achasse em src/main/wsdl, mas como isso resolveu o meu problema por enquanto parei de pesquisar, de qualquer forma agradeço sua contribuição :)
Answer: Adicionei as seguintes configurações no meu pom.xml.
 <project>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>1.1</version>
        <executions>
          <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>add-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/main/wsdl</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

Answer: A forma que eu resolvi o meu problema foi mover o meu source folder de:
src/main/wsdl

para:
src/main/java/wsdl

por algum motivo o Maven busca por padrão os fontes em (src/main/java), o que estiver fora disso ele acaba ignorando, não encontrei uma maneira de configurar para que ele considere o que estiver fora desse padrão.
Comment: @utluiz eu tentei fazer essas configurações porém não obtive sucesso, devo ter feito algo errado, vou tentar novamente e posto aqui se conseguir
Comment: @utluiz deu certo :)
Comment: O motivo dele buscar nessa pasta é porque é exatamente assim que ele foi projetado, mas é possível adicionar outros diretórios adicionando algumas pequenas coisas figurações no seu POM. Veja, por exemplo: http://blog.sonatype.com/2008/05/adding-additional-source-folders-to-your-maven-build/#.Vmn_Kcs7bqA

package does not exist (Maven)


Question on Möbius Transformations

Question: If $z_{1}, z_{2}, z_{3}$ are distinct points in $C \cup \infty$ then there is only one Möbius Transformation which sends these points to $1,0,\infty$ Write out the formula for this Möbius Transformation. You will have to consider the cases when one of the $z_{j}'s $ is $\infty$
The first part of this question I have worked out. The second part is what I have trouble with. I think this has to do with the cross ratio in projective geometry. If $A,B,C,D$ are points that are collinear. then their cross ratio is
$$(A,B,C,D) = \frac{\bar{AC} * \bar{BD}}{\bar{AD} * \bar{BC}} .$$
If $A,B,C,D$ were points on the real numbers then the ratio would be
$$(A,B,C,D) = \frac{(C-A) * (D-B)}{(D-A) * (C-B)} .$$
Therefore I think the cross ratio of the three points would be
$$(z_{1}, z_{2} , z_{3}, z_{4}) = \frac{(z_{1} - z_{3})(z_{2} - z_{4})}{(z_1- z_{4}) (z_{3} - z_{2})}$$
The last formula is sort of what I want but the problem is I don't understand the part where we have to let one of the z_{j}'s equal to infinity. What do you think? Thanks for the help.
Answer: For the first part of the question, if all of the $z_i$ are in $\mathbb{C}$, you should have found that
$\displaystyle f(z)= \frac{(z-z_2)(z_1-z_3)}{(z-z_3)(z_1-z_2)}$
maps $z_1$ to $1$, $z_2$ to $0$ and $z_3$ to $\infty$. To see what happens if one of the $z_i$ is at $\infty$, consider what happens as it approaches $\infty$ and take the limit.
For example, as $z_1 \rightarrow \infty$, then $\frac{z_1-z_3}{z_1-z_2} \rightarrow 1$, so
$\displaystyle\lim_{z_1 \rightarrow \infty} f(z) = \frac{z-z_2}{z-z_3}$
and this function now maps $\infty$ to $1$, $z_2$ to $0$ and $z_3$ to $\infty$ as required.

Question on Möbius Transformations


Portugol duvidas sobre atribuição de valores a caracteres

Question: Gostaria de saber como atribuir a caracteres valores já digitados pelo usuário no laço de repetição.
Código:
nu,cont,contp :inteiro

pot :inteiro

tipo :caractere
inicio

cont <- 1
escreval("digite a qtd de usinas")
leia (nu)

escreval ("H-hidroeletrica")
escreval("T-Termoeletrica")
escreval("E-EOLICA")

repita

escreval("digite o TIPO de cada usina ")
leia(tipo)

cont <- cont+1

ate (cont > nu)

repita

contp <- contp+1

escreval("Digite a **POTENCIA** de cada usina ")
leia(pot)

ate  contp = nu)

Minha dúvida e eu pedi para o usuário dizer qual o tipo da usina H-E-O. Logo abaixo pedir para dizer a potência gostaria de saber como atribuir os tipos aos valores digitados?
Para um melhor entendimento onde quero chegar o exercício é esse:
Após ler esta quantidade de usinas, o programa solicita para cada usina qual o tipo de usina ( H-hidroeletrica, T-termoeletrica, E-eolica) e qual a potência gerada, após lidos os dados de todas as usina o programa contabiliza o total de energia gerado para cada tipo e avalia em qual bandeira a região deve operar. quando mais que 20% de energia gerada for proveniente de termoelétrica opera-se em bandeira vermelha. Quando a geração de termelétrica estiver entre 10 e 20% a região opera em bandeira amarela?
Comment: Parceiro tu escreveu de um jeito tão estranho que no fim eu não entendi a tua dúvida...
Comment: vou resumir ...   eu preciso fazer com que o programa atribua os valores aos caracteres digitados pelo usuario. para apartir dai eu calcular a porcentagem de cada tipo de usina ...
Comment: solicite ao usuario a quantidade de usinas de energia em uma região, apos ler esta quantidade de usinas, o programa solicita para cada usina qual o tipo de usina ( h-hidroeletrica T- termoeletrica E- eolica e qual a potencia gerada, apos lifdos os daods de todas as usina o programa contabiliza o total de energia gerado para cada tipo e avalia em qual bandeira a região deve operar. quando mais que 20% de nergeia gerada forproveniente de termoeletrica opera-se em bandeira vermelha. quando a geração de termeletrica estver entre 10 e 20 % a região opera em bandeira amarela
Comment: Você quer fazer tipo um menu?
Answer: Não dá para entender direito o que você quer, mas acho que isso te ajuda:
INICIO

    VARIAVEIS
    quantidade, potencia: inteiro;
    tipo: char;

    ESCREVA("Digite a quantidade de usinas: ");
    LEIA(quantidade);

    ESCREVA("Digite o tipo de usina: ");
    LEIA(tipo);

    ESCREVA("Digite a potência gerada: ");
    LEIA(potencia);

    SE (potencia >= 20) ENTAO
        ESCREVA("Bandeira Vermelha");

    SE (potencia > 10 E potencia < 20) ENTAO
        ESCREVA("Bandeira Amarela");

FIM


what is the logic behind the 'UPC -A' check digit?

Question: In UPC-A barcode symbology, the 12th digit is known as check digit and it is used by the scanner to determine if it scanned the number correctly or not.
<code>    the check digit is calculated as follows:
1.Add the digits in the odd-numbered positions (first, third, fifth, etc.) together and multiply by three.
2.Add the digits in the even-numbered positions (second, fourth, sixth, etc.) to the result.
3.Find the result modulo 10 (i.e. the remainder when divided by 10.. 10 goes into 58 5 times with 8 leftover).
4.If the result is not zero, subtract the result from ten.

For example, in a UPC-A barcode "03600029145x" where x is the unknown check digit, x can be calculated by
adding the odd-numbered digits (0 + 6 + 0 + 2 + 1 + 5 = 14),
multiplying by three (14 × 3 = 42),
adding the even-numbered digits (42 + (3 + 0 + 0 + 9 + 4) = 58),
calculating modulo ten (58 mod 10 = 8),
subtracting from ten (10 − 8 = 2).
The check digit is thus 2.
</code>
What is the logic behind calculating 'check digit' in such manner?
Can't two different combination of digits produce the same check digit?
Comment: It provides a quick check for errors. It doesn't catch all errors, but will catch many.  Like checking that your car has an even number of wheels :-).
Answer:
Can't two different combination of digits produce the same check digit? --

Yes. But that's not really the point. If the given check digit doesn't agree with the value computed from the other digits, then there's an inconsistency, so something is wrong. Either the check digit is wrong, or some of the other digits are wrong.
If the check digit is correct, this doesn't guarantee that the other digits are correct. There are various check-digit algorithms. They are designed so that simple common errors (like one digit wrong, or a transposition of two digits) will cause a change in the calculated check digit. So, if the check digit is correct, at least you know that no simple errors of this sort have occurred. Different algorithms target different types of errors.
Comment: Just to clarify, when you say *transposition of two digits*, you mean of course two *consecutive* digits (or, more generally, an odd-numbered and an even-numbered one), which is after all a common error. The exchange of the first and third digit, say, is not caught by the code.
Comment: @Andreas -- yes, that's right. Actually, I thought "transposition" always means swapping of adjacent digits. But, anyway, it's better to be explicit.
Comment: I know what you meant, but a source people are likely to look up http://en.wikipedia.org/wiki/Transposition_(mathematics)#Transpositions says otherwise, so, yes, better to be explicit.
Answer: Just a remark on your question
Can't two different combination of digits produce the same check digit?
Of course this happens, after all there are $10^{11}$ possibilities for the first $11$ digits, and only $10$ for the $12$-th one. So plenty of valid codes will share the same $12$-th digit, and a mistake that takes you from one to the other can't be caught. But as noted by @bubba, the code aims at catching two of the commonest errors.


EditText disapear if layout_width="wrap_content" and not layout_weight="1"

Question: The next code is OK for Eclipse Layout Editor and Android Studio. I tested it in several mobiles and works fine but, in a Samsung GT-S6310N (Android 4.1.2), this EditText dissapears. It goes at the end of a LinearLayout that defines the Layout width. The Layout is showed in a Dialog using android:Theme.Dialog.
<EditText
            android:id="@+id/et_clino"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:ems="4"
            android:inputType="numberDecimal"
            android:text="89.9" />

I've solved this changing the code to:
<EditText
        android:id="@+id/et_clino"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="4"
        android:inputType="numberDecimal"
        android:text="89.9" />

The question is: is wrong mi code or is a bug?
This is the code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp"
tools:context=".Measure" >

<RelativeLayout
    android:id="@+id/rl_a"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/TextView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignBaseline="@+id/et_from"
        android:text="@string/from"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/et_from"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/TextView1"
        android:ems="7"
        android:hint="@string/from"
        android:lines="1"
        android:maxLength="7"
        android:minLines="1"
        android:nextFocusDown="@+id/et_to"
        android:text="1234567" />

    <EditText
        android:id="@+id/et_to"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/et_from"
        android:layout_alignParentRight="true"
        android:ems="7"
        android:hint="@string/to"
        android:maxLength="7"
        android:maxLines="1"
        android:nextFocusDown="@+id/et_distance"
        android:text="1234567" />

    <TextView
        android:id="@+id/TextView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/et_from"
        android:layout_toLeftOf="@+id/et_to"
        android:text="@string/to"
        android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>

<LinearLayout
    android:id="@+id/ll_b"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/tv_distance"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/distance_abr"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/green" />

    <EditText
        android:id="@+id/et_distance"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="4"
        android:hint="@string/distance_abr"
        android:inputType="numberDecimal"
        android:lines="5"
        android:maxLength="6"
        android:nextFocusDown="@+id/et_rumbomag" />

    <TextView
        android:id="@+id/TextView3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/rumbo_mn_abr"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/et_rumbomag"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:ems="4"
        android:hint="@string/rumbo_mn_abr"
        android:inputType="numberDecimal"
        android:maxLength="5"
        android:nextFocusDown="@+id/et_measured_clino"
        android:text="360.0" />

    <TextView
        android:id="@+id/tv_clino"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/clino"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/et_clino"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="4"
        android:inputType="numberDecimal"
        android:text="89.9" />

  </LinearLayout>

<LinearLayout
    android:id="@+id/ll_d"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <RadioGroup
        android:id="@+id/rg_direction"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/rb_direct"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:hint="@string/direction"
            android:text="@string/direct" />

        <RadioButton
            android:id="@+id/rb_inverse"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="@string/inverse" />
    </RadioGroup>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true" >

            <Button
                android:id="@+id/btn_delete"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:text="@string/delete"
                android:textColor="@color/red" />

            <ImageButton
                android:id="@+id/ib_disto"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="fitCenter"
                android:src="@drawable/disto" />

            <Button
                android:id="@+id/btn_add"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:text="@string/save"
                android:textColor="@color/green" />

        </LinearLayout>
    </RelativeLayout>
</LinearLayout>

<LinearLayout
    android:id="@+id/ll_e"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:id="@+id/et_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="@string/description" >

        <requestFocus />
    </EditText>
</LinearLayout>

Comment: Can you put whole layout (.xml) file?
Comment: I tried with two layout, the first one with linear layout and relative layout into the linear layout. The second only a relative layout. The same aparience but distict programation. The result was the same.
Comment: Which is the root element, I mean `LinearLayout` or `Relative Layout`?
Comment: Linear Layout vertical.
I put the code above
Answer: I've made some changes (particularly the LinearLayout containing the cli_no EditText, @string and @drawable resources) in the xml file as below:
<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    android:id="@+id/rl_a"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/TextView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/et_from"
        android:layout_alignParentLeft="true"
        android:text="@string/from"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/et_from"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_toRightOf="@+id/TextView1"
        android:ems="7"
        android:hint="@string/from"
        android:lines="1"
        android:maxLength="7"
        android:minLines="1"
        android:nextFocusDown="@+id/et_to"
        android:text="1234567" />

    <EditText
        android:id="@+id/et_to"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/et_from"
        android:layout_alignParentRight="true"
        android:ems="7"
        android:hint="@string/to"
        android:maxLength="7"
        android:maxLines="1"
        android:nextFocusDown="@+id/et_distance"
        android:text="1234567" />

    <TextView
        android:id="@+id/TextView4"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/et_from"
        android:layout_toLeftOf="@+id/et_to"
        android:text="@string/to"
        android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>

<LinearLayout
    android:id="@+id/ll_b"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/tv_distance"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="distance_abr"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:textColor="@color/green" />

    <EditText
        android:id="@+id/et_distance"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:ems="4"
        android:layout_weight="1"
        android:hint="distance_abr"
        android:inputType="numberDecimal"
        android:lines="5"
        android:maxLength="6"
        android:nextFocusDown="@+id/et_rumbomag" />

    <TextView
        android:id="@+id/TextView3"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="distance_abr"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/et_rumbomag"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:ems="4"
        android:hint="rumbo"
        android:inputType="numberDecimal"
        android:maxLength="5"
        android:text="360.0" />

    <TextView
        android:id="@+id/tv_clino"
        android:layout_width="0dp"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:text="clino"
        android:textAppearance="?android:attr/textAppearanceLarge" />

    <EditText
        android:id="@+id/et_clino"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:ems="4"
        android:inputType="numberDecimal"
        android:text="89.9" />
</LinearLayout>

<LinearLayout
    android:id="@+id/ll_d"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <RadioGroup
        android:id="@+id/rg_direction"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <RadioButton
            android:id="@+id/rb_direct"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:checked="true"
            android:hint="direction"
            android:text="direct" />

        <RadioButton
            android:id="@+id/rb_inverse"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="inverse" />
    </RadioGroup>

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true" >

            <Button
                android:id="@+id/btn_delete"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="15dp"
                android:text="@string/delete" />

            <ImageButton
                android:id="@+id/ib_disto"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:adjustViewBounds="true"
                android:scaleType="fitCenter"
                android:src="@drawable/back02" />

            <Button
                android:id="@+id/btn_add"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingLeft="10dp"
                android:paddingRight="10dp"
                android:text="save"
                android:textColor="@color/green" />
        </LinearLayout>
    </RelativeLayout>
</LinearLayout>

<LinearLayout
    android:id="@+id/ll_e"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <EditText
        android:id="@+id/et_description"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:ems="10"
        android:hint="@string/description" >

        <requestFocus />
    </EditText>
</LinearLayout>

The reason for disappearing of the EditText is that you want to display items, which has total width greater than the width of the screen, so I've applied same layout_weight:"1" to all the elements inside the LinearLayout. May be this helps you for solving your issue.


Using MYTHEME_page_attachment_alter does not alter the favicon

Question: Based on other similar stackexchange questions and documentation, I've implemented the following in the MYTHEME_page_attachment_alter function in MYTHEME.theme file to change the favicon based on the url (inside a condition statement):
    foreach($page['#attached']['html_head_link'] as $k => $v) {
        if (array_key_exists('rel', $v[0]) && $v[0]['rel'] == 'shortcut icon') {
            unset($page['#attached']['html_head_link'][$k]);
            $page['#attached']['html_head_link'][$k] = array(
                array(
                  'rel' => 'shortcut icon',
                  'href' => '/themes/fu/favicon_urbana.png',
                    'type' => 'image/png',
                ),
            );
        }
    }

Using Kint::dump($page) confirms that the shortcut icon is indeed updated.  Why then will the tab for the page not show the updated favicon?  I've cleared the cache, ran drush cr multiple times, etc yet the page continues to show the theme's favicon.
Am I missing something?  Any advice would be greatly appreciated.
On a side note, we had this working successfully in Drupal 7 in MYTHEME_html_head_alter() and I am migrating this to Drupal 8.
Comment: What if you use `/favicon_urbana.png?v=1`? Just wanted to rule out the browser cache.
Comment: I just tried your suggestion and unfortunately that did not have any effect.
Answer: If its not a browser cache issue perhaps you should try modifying it with a hook called later namely THEMENAME_preprocess_html
function THEMENAME_preprocess_html(array &$variables) {
  $test = "";
  $variables["page"]["#attached"]["html_head_link"][0][0] =
    array(
      'rel' => 'shortcut icon',
      'href' => '/themes/fu/favicon_urbana.png',
      'type' => 'image/png',
    );
}

Comment: I tried this as you suggested and this still did not alter the favicon in the tab.
Comment: Some browser take some time before loading a new favicon, sometimes it might take a clear cache and a few page refreshes before seeing a new icon.  Try with another installed browser.
Comment: I did that as well.  Usually work with chrome and go to firefox if I want a 'clean' browser.
Comment: Try changing temporarily theme and see if the current favicon is provided by your theme.  Also see if metatag is overriding favicon.
Answer: You can change the favicon with MYTHEME_page_attachment_alter.
First you should remove the favicon added by the theme with.
unset($attachments['#attached']['html_head_link'][0]); as mentioned here then add you favicon here is a code sample works for me.
/**
 * Implements hook_page_attachments_alter().
 */
function MYTHEME_page_attachments_alter(array &$attachments) {
  // Remove the default favicon.
  unset($attachments['#attached']['html_head_link'][0]);
  // add new favicon.
  $attachments['#attached']['html_head_link'][][] = array(
    'rel' => 'shortcut icon',
    'href' => '/themes/fu/favicon_urbana.png',
    'type' => 'image/png',
  );
}

Result:
Comment: I have tried this as well.  The Kint::dump($attachments) clearly shows that the new href is new favicon.  I do not see the  in the code inspector though.
Comment: Did check if there is any other module / theme implement `hook_page_attachments_alter` and remove your new favicon?
Comment: Thanks for that suggestion.  I did see that the metatag_favicon.module does implement this.  I uninstalled this module and this did not help either.  I also moved the hook_page_attachments_alter to my module file and while the attachment's href shows the new favicon, the tab still isn't updating with the new image.
Comment: Should I be seeing a <link rel="shortcut icon" href="... /> in the  section?  I am not seeing one at all.  Even when I comment out the alter hook.  Do we have to have the metatag module enabled?
Comment: Yes you should see `` if there is no hook change it you should see the favicon of active theme
Comment: That's just it, I am not seeing the line of code at all.  Am I supposed to manually include it or drupal 8 automatically inserts this into the html page?  I do see the favicon of the active theme.  Just no link rel="shortcut icon" etc
Answer: It turns out I was missing

in the head section of html.html.twig.  Once I put that in there, the tags appeared and the favicon gets updated properly.


how to stop autoscroll animation when hover in css?

Question: I am a beginner and first time using animation and transformation. I am trying to stop the animation when I hover on "some text here" but I am not getting proper output maybe because of inaccurate or wrong placement of &:hover please help to resolve this problem.

#contentwrapper {
  height: 190px;
  background-color: tomato;
  overflow-y: hidden;
}

#inner-wrapper {
  animation: autoscroll 10s linear infinite;
}

@keyframes autoscroll {
  &:hover {
    animation-play-state: paused;
  }
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(0, -90%, 0);
  }
}

some text here

some text here

some text here

some text here

some text here

some text here

some text here

some text here

Answer: You can use :hover on the element itself:

#contentwrapper {
  height: 190px;
  background-color: tomato;
  overflow-y: hidden;
}
#inner-wrapper {
  animation: autoscroll 10s linear infinite;
}

#inner-wrapper:hover{
    animation-play-state: paused;
}

@keyframes autoscroll {
  from {
    transform: translate3d(0,0,0);
  }
  to {
    transform: translate3d(0,-90%,0);
  }
}

some text here

some text here

some text here

some text here

some text here

some text here

some text here

some text here


Detecting div while clicking on its child

Question: I have simple html structure

I WANT TO BE DIV

I WANT TO BE DIV

aside{
  width: 100px;
  height: 300px;
  border: 1px solid blue;
  color:black;
}
div{
  width: 100px;
  height: 100px
}

when i click on div , i want to invoke an function for it using
var x= document.querySelector("aside");
x.addEventListener("click",function(e){
  if( e.target.nodeName == 'DIV'){
    alert(e.target.nodeName);
  }
},true)

but when i click on the text , it wont get invoked. How can i modify my code in order for it to work?

https://jsfiddle.net/qc3ewpmz/
Comment: Your above code target will always be aside, so your condition will fail. IF you want to listen to the div, then x should query select DIV.
Comment: No, events are also triggered on child elements, and then the child is the target. this code should work as expected.
Answer:
The problem

It won't react to the text because the text is in a p tag and you are checking if the nodeName matches DIV.

How can i modify my code in order for it to work?

I've added an OR case, which accomodates this.
var x= document.querySelector("aside");
x.addEventListener("click",function(e){
  if( e.target.nodeName == 'DIV' || e.target.nodeName == 'P'){
    alert(e.target.nodeName);
  }
},true)

Here is a DEMO
Also, i'm not quite sure why you have the whole target.nodeName part. I would have something as simple as below
var x= document.querySelector("aside"); x.addEventListener("click",function(e){

 alert("Hi there");

},true)

Here is a DEMO
I would also strongly urge you to check out JQuery and it's selectors as a better alternative to this.
Comment: I understand why J.dd wants to do this: The alert should only appear if a `div` inside the `aside` is clicked, but he/ she doesn't want to add an event listener for every single `div`.
Comment: Fair enough, that makes sense!Somehow JQuery just seems like a much better use case here.
Answer: It's easy to test if the targets parent (Element.parentNode) is a
, but the probably best way is to go up the DOM tree until you reach a DIV or the element whith the event listener:
var x = document.querySelector("aside");

x.addEventListener("click", function(e) {
    for (var tg = e.target; tg !== x && tg != null; tg = tg.parentNode) {
        if (tg.nodeName === 'DIV') {
            alert('You clicked on a
 or an element inside it');
            break;
        }
    }
}, true);

Note that this even works on child elements of the paragraphs (e.g. a  or .
JSFiddle


Run command every 30 minutes in thread on Android service

Question: I have an Android service running within my app in the background, this service runs several threads, one of which is meant to run a command ever 30 minutes.
Thread InternetThread = new Thread() {
        public void run() {
            while (true){
                    try {
                        Thread.sleep(1800000);
                    } catch (InterruptedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                    Log.i("test", "We are running");
                    runCommand();
            }
        }
    };

However what I have found is this code will not always run every 30 minutes, some times it can be up to an hour between runs, never less than 30 minutes but can be more. I assume this has something to do with the service being pursed by Android?
But I am not really sure as this is at the limited of my understanding with Android services and threads.
Hopefully someone can help with a way to make sure the "runCommand()" does actually run exactly every 30 minutes.
Comment: 3600000/1000/60 = 60 minutes?
Comment: use scheduleAtFixedRate of ExcutorService
Comment: yes my bad should be 1800000 had writen out the code I am using 1800000 and getting random results
Comment: @Lestat 1800000 is correct.
Comment: @ZacPowell If you implement Thread or HandlerThread, be sure that your UI thread does not block while waiting for the worker thread to complete—do not call Thread.wait() or Thread.sleep(). Using thread.sleep() inside a thread is bad design. developer.android.com/training/articles/perf-anr.html. Use a ExecutorService as suggested by blackbelt. Alaram Manager can also be a good to use
Comment: @Raghunandan could you show an example for using one of these methods?
Comment: This isn't how you do it. Use AlarmManager setRepeating() to guarantee that it executes in every 30 minutes. And if you want it to happen lets say on 15 and 45 minutes past every hour, set triggerAtMillis.
Answer: The process may be freezing, try this:
Thread InternetThread = new Thread() {
    public void run() {
        long endtime = 0;
        while (true) {
            endTime = System.currentTimeMillis() + 1800000;
            while(System.currentTimeMillis() < endTime) {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            Log.i("test", "We are running");
            runCommand();
            }
        }
    };

Comment: If you implement Thread or HandlerThread, be sure that your UI thread does not block while waiting for the worker thread to complete—do not call Thread.wait() or Thread.sleep(). Using thread.sleep() inside a thread is bad design. http://developer.android.com/training/articles/perf-anr.html


Connect working Binding to a List

Question: I am binding to a property of an object CaptureNamesList. The variable I need to bind to is a List<string>.
It doesn't work when I bind straight to the List<string>. I created a wrapper class for strings, StringWrapper, and it works when I use the List<StringWrapper> _test4 as a backing variable. However, I need to somehow link this back to _test1. My attempt is shown commented out, but it doesn't seem to work.
How do I bind to this List<string> ?
xaml:
<ItemsControl ItemsSource="{Binding CaptureNamesList}">
     <ItemsControl.ItemTemplate>
          <DataTemplate>
              <TextBox Text="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
          </DataTemplate>
     </ItemsControl.ItemTemplate>
</ItemsControl>

c#:
public List<StringWrapper> CaptureNamesList
    {
        get { return _test4; }
        set { _test4 = value; }
        //get { return StringWrapper.castList(_test1); }
        //set { _test1 = StringWrapper.castBackList(value); }
    }

private List<StringWrapper> _test4 = StringWrapper.castList(new List<string> { "one", "two" });
private List<string> _test1 = new List<string> { "one", "two" };

The wrapper class for strings:
public class StringWrapper
{
    public string Value { get; set; }

    static public explicit operator StringWrapper(string value)
    {
        return new StringWrapper() {Value=value};
    }
    static public explicit operator string(StringWrapper value)
    {
        return value.Value;
    }

    public static List<StringWrapper> castList(List<string> strings)
    {
        List<StringWrapper> wrappers = new List<StringWrapper>();
        strings.ForEach(item => wrappers.Add((StringWrapper)item));
        return wrappers;
    }

    public static List<string> castBackList(List<StringWrapper> wrappers)
    {
        List<string> strings = new List<string>();
        strings.ForEach(item => strings.Add((string)item));
        return strings;

    }
}

Answer: Binding to a List<string> should be exactly the same, except that in your DataTemplate you don't have to specify any property for the binding:
<ItemsControl ItemsSource="{Binding CaptureNamesList}">
     <ItemsControl.ItemTemplate>
          <DataTemplate>
              <TextBox Text="{Binding Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
          </DataTemplate>
     </ItemsControl.ItemTemplate>
</ItemsControl>

Comment: So the code behind would be: 'public List CaptureNamesList { get { return _test1; } set { _test1 = value; } }' 'private List _test1 = new List { "one", "two" };' Doesn't bind.
Comment: What does `doesn't bind` mean? Do you have an error on your `output` window? Is there an exception? Is the DataContext set properly? I use this exact code snippet for plenty of my bindings to `List` . The only thing I can think of here if it doesn't bind is that your `DataContext` isn't properly set. Can you check the output window if there is anything?
Comment: Thanks for the response. I mean when I run it the values shows up but when I change them It doesn't seem to change the value of the _test1 (btw I added Path=. to make it compile)
Comment: If you want any `ItemsControl` to be synchronized to their source lists, you need to use `ObservableCollection` (which implements `INotifyCollectionChanged` ) rather than `List` . A `List` doesn't notify for its changes, so the view has no way of knowing it has to update. Replace your list by an `ObservableCollection` and it should work fine
Comment: so this? `public ObservableCollection CaptureNamesList {get { return new ObservableCollection(_test1); } set { _test1 = value.ToList(); }`    This doesn't seem to update either. I am stuck with the private variable being a `List` as I'm inheriting from my backend.

        }
Comment: In this case, nothing stops you from working UI-side with your `ObservableCollection` and then defer any change to the underlying `List`. You should create a spare `ObservableCollection` to work with. Check out this article for some help synchronizing lists if needed: http://www.codeproject.com/Articles/62537/M-V-VM-How-to-keep-collections-of-ViewModel-and-Mo
Answer: If you're binding a collection to your XAML, i suggest you use ObservableCollection<string>
public ObservableCollection<string> CaptureNamesList { get; set; }

Im not sure why you'd want to bind a list to a TextBox, maybe what you need is a TextBlock or ListView to show the items in a collection.
<ItemsControl ItemsSource="{Binding CaptureNamesList}">
 <ItemsControl.ItemTemplate>
      <DataTemplate>
          <TextBox Text="{Binding Mode=TwoWay}"/>
      </DataTemplate>
 </ItemsControl.ItemTemplate>

Connect working Binding to a List


Como alinhar campos de um formulário

Question: Boas, estou a desenvolver uma webpage com um formulário. Como posso alinhar as caixas de texto para preencher?
Tentei pôr tudo dentro de uma div com a class container, tentei definir o size para tamanhos aproximados, mas há sempre milimetros de diferença, e tentei fazer dentro de uma tabela, mas ficam com espaçamentos pequenos.
Até ao momento o código está assim:

        <form method="POST" action="<?php echo $_SERVER["PHP_SELF"]; ?>">

Dados Funcionario nº<?php echo $registo["IDFuncionario"]; ?>

Nome <input type="text" name="Nome" size="50" value="<?php echo $registo["Nome"]; ?>">

Username<input type="text" name="username" size="47" value="<?php echo $registo["username"]; ?>">

Password<input type="text" name="password" size="47" value="<?php echo $registo["password"]; ?>">

Morada<input type="text" name="morada" size="49" value="<?php echo $registo["morada"]; ?>">

Contacto <input type="text" name="contacto" size="47" maxlength="9" value="<?php echo $registo["contacto"]; ?>">

<input type="submit" value="Alterar" name="alterar"><input type="reset" value="Repor" name="B2">

        </form>

Comment: Seja bem vindo ao StackOverflow em Português. Para lhe ajudarmos de forma melhor e mais rápida, inclua o código que tens até o momento.
Comment: Seja bem vindo. Use as tags relevantes a duvida e não ao teu projeto todo amigo.
Comment: Editei por que não deves usar snippet para demonstrar códigos PHP. Use snippet para reproduzir "problemas" com CSS, html, js e só.
Answer: Dá pra fazer com CSS utilizando a tag , assim:

label.hora {

    display: inline-block;
    width: 90px;
}
Entrada 1:
<input type="time" id="input1">

Entrada 22:
<input type="time" id="input2">

Coloquei seu código da mesma forma, mas acho que vc não precisa colocar (ou pode estar colocando errado) a abertura do php dentro dos campos input... Dei uma editada no seu código, tirando as aberturas do php apenas pra testar, dá uma olhada como ficou (clicando abaixo, em executar trecho de código):

label.hora {

    display: inline-block;
    width: 90px;
}

<form method="POST" action="">

Dados Funcionario nº

Nome <input type="text" name="Nome" size="50">

Username<input type="text" name="username" size="47">

Password<input type="text" name="password" size="47">

Morada<input type="text" name="morada" size="49">

Contacto<input type="text" name="contacto" size="47" maxlength="9">

<input type="submit" value="Alterar" name="alterar"><input type="reset" value="Repor" name="B2">

</form>

Comment: `display: inline-block;` não é CSS3
Comment: Ok, valeu pelo esclarecimento e pela edição! PS: Eu aumentei um "2" no segundo horário pra mostrar que o alinhamento funciona mesmo com palavras de tamanho diferente....

Como alinhar campos de um formulário