Why does the Australian soccer team compete in the Asian qualifiers for the World Cup?

Question: Today, the Australian soccer team plays a match against Saudi-Arabia in the qualification rounds for the World Cup. Qualifications for the World Cup are usually organized per continent; e.g. Europe (the UEFA) has its own tournament where only European countries compete. Presumably, Australia joined the Asian Football Confederation and since then competes in the Asian qualifiers, but why did they make this move? I can think of a few reasons:

Better chance of qualification (Australia's home continent, Oceania, has only 'half a place' in the World Cup, the winner of the qualifiers needs to win another play-off against another country)
Better opposition during the qualification (this is actually mentioned on Wikipedia, but you can also play friendly matches against better teams)
They expected more income (tickets sold, TV broadcasting rights)

Are there any references for these possible reasons, and what was/were the decisive one(s)?
Comment: To address your second point, Australia already played friendlies against better opposition before the move. Switching to a stronger qualification route ensured that not only the friendlies, but also the World Cup qualifiers and the relevant confederation cup (ie the AFC Asian Cup vs the OFC Nations Cup) were against strong opposition.
Answer: Australia used to play under the Oceania Confederation. The confederation only gets half a berth per World Cup. This means that after the preliminary rounds, the top team gets to play a two-legged tie with another playoff qualifier. The Asian, African, Oceanic confederations, as well as the CONCACAF, each get a playoff seed. The four teams qualifying from the listed confederations are randomly split into 2 pairs, and the winner of each pair gets a spot in the World Cup. All other confederations are given guaranteed spots as well.
Australia was the best team in the confederation throughout the years and often got the half berths. However, they didn't do well in the playoff matches. Australia had a 32 year hiatus from the World Cup ranging from 1974 to 2006. This was because they lost the playoff series in 1986, 1994, 1998, 2002 (Additionally, they also lost in 1966 and 1970 before their first appearance in the World Cup). Most of these losses were very close, and soon Australia got a reputation for having near misses. The Socceroos finally tasted World Cup playoffs victory against Uruguay to qualify for Germany's 2006 World Cup. Not surprisingly, after 2 games, the teams were tied, and Australia won in the penalty shootouts.
After many failed attempts to qualify for the World Cup, Australian Football Federation began talks to join Asian Confederation in 2005. Playing under the Asian bracket, they had a chance to secure one of the 4 guaranteed spots for the World Cup and avoid bad luck and drama that haunted them for more than 30 years.
The switch has proven to be a great decision for the Socceroos as they have been able to claim one of the guaranteed Asian spots for every World Cup since then, as well as winning the AFC Asian Cup in 2015.
Comment: @Glorfindel - I found some quotes from the national team manager, the CEO and Chairman of FFA, and the Prime Minister of Australia (at the time). The first reference also covers the AFC Champions League participation for A-League club teams as another reason that wasn't mentioned.

http://www.smh.com.au/news/Football/Goal-at-last-Australia-joining-Asia/2005/03/10/1110417621684.html,
http://www.abc.net.au/news/2005-03-12/farina-welcomes-asia-move/2570868,
http://websites.sportstg.com/assoc_page.cgi?c=2-1001-0-26515-0&sID=12574&&news_task=DETAIL&articleID=116042
Answer: Australia also switched for better competition.  Against OFC minnows, their best players often didn't show up for national team games.  They wouldn't leave their club teams for national team games, which meant the team lacked cohesion come those playoff games.  With tougher Asian competition (especially Japan, South Korea, Iraq, Iran, Saudi Arabia), they play together more often and have to play better to qualify.


Comparing 2 independent counts of the same data

Question: I am looking for an appropriate statistical method to test my hypothesis that there is no significant difference between counts conducted by 2 individuals of the same data.
The data is as follows:
I have videos of fish migrating up a river, and 2 different people counting the videos.
I have 960 videos, so each video is counted once by each person.
I am unsure what type of statistical test will evaluate the difference between counters, as this is ultimately what I am testing: How well do counters agree with one another, in other words, is one counter significantly different than the other counter when presented with the same data.
If anyone could suggest the appropriate statistical test that would be awesome.
Comment: Do you have counts for each of the 960 videos, or just the totals over all of the videos? If you have the raw counts, look at the distribution of the differences. Test whether the mean difference is zero.
Comment: The question (where it is fish that is counted and not the videos) has also been answered elsewhere: http://www.talkstats.com/showthread.php/53557-A-simple-question-Looking-to-compare-counts-conducted-by-2-counters-of-the-same-data
Answer: Your question is about agreement, which has its own tag on this site agreement-statistics. An earlier question similar to yours is

Testing for similarity on count data, also

What is the proper inter-rater reliability analysis for continuous count data?


Drupal 7 comments spam with Captcha installed

Question: I have a multilanguage - multidomain website developed in Drupal 7, and the database have been flooded with spam comments, even if I have Captcha module (image) installed. The spam comments are from 60 different IPs, and I have seen attempts to add node and add user (which is blocked) in the incidents reports.
So I cannot block so many IPs at the risk of them being dynamical and loosing potential users.
What could I do to prevent the spam and also to prevent the attacks? Thanks
Answer: "to prevent the attacks" - not much can be done here. If an attempt to access node/add page ends with access denied page, its ok. You cant prevent users from entering urls in their browsers.
As for spam in comments, try some different modules for Captcha (Google reCaptcha with noCaptcha for example).
For different aproach, Honeypot can help limiting "robots" behavior.
Comment: Thank you, I have added Honeypot module and the spam has stopt completely, and I hope, definitely.
Comment: As for the attacks, if they are serious, a white list approach could be tried, i.e., only a given bunch of predefined IPs are authorized to access those potentially harmful pages ( node/add, user/add ).


Definition of groups in a more abstract way

Question: I'm trying to understand the definition of group objects in categories, this is an extract of Paolo Aluffi's book:

QUESTIONS

Can I say that $e(1)$ is the identity in our group $G$ we have just built?
Why $1$ should be a final object? in another words, why the morphism $G\to 1$ have to be unique?
Why this category has to have finite products? it's not suffice just products with two components? (for the multiplication)

Thanks in advance
Comment: The fact that $1$ is a final object implies that $G\times 1 \cong G$ functorially. But I don't know what would happen if we ask for some other object $1'$ not final fitting the diagrams.
Comment: Regarding 3, existence of two-factor products is the same as existence of finite products. $G_1\times \ldots \times G_n\cong (\ldots(G_1\times G_2)\times \ldots )\times G_n$ canonically. (The diagrams already use three-factor product $(G\times G)\times G$, in the form of repeated two-factor products, and the canonical isomorphism with $G\times(G\times G)$).
Comment: Regarding 1, whhat do you mean with $e(1)$? This need not be a concrete category.
Comment: @HagenvonEitzen I'm sorry, I meant this in the category of groups, is that true that $e(1)$ is the identity in this category?
Answer:
What do you mean by "$e(1)$"? The identity in your group is the morphism $e$ itself.
In any category $C$ with a terminal object $1$, a morphism $1 \to c$ for an object $c \in C$ is called a global point of $c$. In some, but not all, categories, this often gives a reasonable "underlying set" functor $\text{Hom}(1, -) : C \to \text{Set}$, although it may not be the obvious one: for example, if $C$ is the category $G\text{-Set}$ of $G$-sets for a group $G$, then a global point is a fixed point.
So this is one reason you might not think it's totally crazy to ask that picking out a particular element should abstractly correspond to picking out a morphism from $1$. But there are at least two better reasons.
First, $e$ should describe the outcome of taking the product of zero elements of $G$, and the domain of this operation should be the product of zero copies of $G$, which is the terminal object.
Second, using the Yoneda lemma, you can show that a group object in a category $C$ is precisely the same thing as a "representable presheaf of groups on $C$," or more precisely a functor $C^{op} \to \text{Grp}$ which is representable in the sense that it is representable after composing with the forgetful functor $\text{Grp} \to \text{Set}$. Meditate in particular on the example of the group object $\text{GL}_n(-)$ in affine schemes, which is the functor which, given a commutative ring $R$, returns the group $\text{GL}_n(R)$.
As Najib pointed out in the comments to Marco's answer, having a terminal object and binary products is equivalent to having all finite products. But finite products is morally the correct condition anyway, because the morally correct definition involves all finite products: see this blog post and this blog post for details.
Comment: regarding #1, I didn't understand, $e$ is a morphism not an element of $G$.
Comment: @user: one should think of morphisms into an object as "generalized elements" of that object. For example, if $X$ is a set, then a morphism $1 \to X$ is precisely an element of $X$. This intuition is particularly useful, among other places, in algebraic geometry.
Comment: @user: for example, if $G$ is a group object I can "multiply generalized elements" of $G$ as follows: if $a : A \to G, b : B \to G$ are two elements, then I can form $a \times b : A \times B \to G \times G$, then compose with the multiplication to get $m \circ (a \times b) : A \times B \to G$, another generalized element of $G$.
Comment: If $G$ is a group in the category $grp$, $e(1)$ is the identity element of $G$?
Comment: @user: if I'm interpreting your question correctly, yes (but the correct terminology is "a group object in the category of sets." A group object in the category of groups turns out to be an abelian group; this is the Eckmann-Hilton argument).
Comment: But isn't the product of zero copies of $G$ a final object instead initial?
Comment: @user: that's correct, but I don't see where anyone mentioned an initial object.
Answer: It may be useful to see an example on a more interesting category.
Let $X$ be a topological space, and consider the category of all bundles over $X$. Recall that a bundle over $X$ is the same thing as a continuous map $E \to X$; $E$ is called the "total space" of the bundle. A morphism of between two bundles $E \to X$ and $E' \to X$ is a continuous map $E \to E'$ that fills in a commutative triangle.
In this category, $\mathbf{1}$ is the bundle $1_X : X \to X$. The product of two bundles $E \to X$ and $E' \to X$ is the one whose total space is the pullback $E \times_X E'$ (and whose structure map is the obvious map to $X$).
A simple example of this is the bundle $A$ defined by the map $\pi_1 : \mathbf{R}^3 \times \mathbf{R}^3 \to \mathbf{R}^3$ given by the projection map onto the first coordinate.
The maps $\mathbf{1} \to A$ are global sections of this bundle: continuous functions $s : \mathbf{R}^3 \to \mathbf{R}^3 \times \mathbf{R}^3$ that are the identity on the first coordinate. These, of course, can be identified with the composite $\pi_2 \circ s$, which you might know these under the more familiar name of a "vector field", and you may know the total space under the more familiar name of the "tangent bundle to $\mathbf{R}^3$".
If you grind out that the usual algebraic structure on the tangent bundle (where we only consider $+$ and $-$ and not scalar multiplication, since we're talking about groups), you'll see that it is an example of this abstract group in the category of bundles over $\mathbf{R}^3$.
And the group identity is not an "element" of the total space: it is a section of the bundle. (although, you'll eventually learn that sections provide a very good notion of the concept of "element" in categories like this)
Answer: 1.- You can not talk about the "identity" of $G$, because $G$ may not be a set. But thats the intuition.
2.- $1$ is a final object because thats the definition, not a consequence. The morphism $G \to 1$ is unique because $1$ is a final object.
3.- The two assertions are equivalent. A category has finite products if and only if has the product of every two objects and a terminal object.
Comment: Regarding #3: products of two objects *and* empty product (aka terminal object).
Comment: Yes, thank you.
Comment: regarding #2, I know that's the definition, but why the reason beyond it?
Comment: It's like when you said that if $e(1)$ was the indentity, deep in your heart you now that if $1$ is the identity group, then the map $e : 1 \to G$ gives you the identity in $G$. And if you look carefully you can notice that every diagram gives you an axiom of the definition of group.
Comment: Sigh. I miss when things were simple and a function was a set of ordered pairs...............
Comment: A functions is still a set of oredered pairs. This are morphisms in a category, not necessarily functions.


Not using Metal, but get error "Metal GPU Frame Capture Enabled"

Question: I am creating a simple SpriteKit game that uses SpriteKit, UIKit, Foundation, and nothing else in terms of frameworks.
However, every time I tun the app I got the following two errors:

Metal GPU Frame Capture Enabled
Metal API Validation Enabled

How do I un-enable the Metal frameworks and make these errors go away?
Comment: SpriteKit is internally using Metal. The messages aren't errors and can be ignored.
Comment: SpriteKit and SceneKit are both higher-level frameworks built on Metal now (instead of OpenGL before). If you want to specifically request OpenGL, you can see this: https://developer.apple.com/documentation/spritekit/skview/requesting_the_opengl_renderer  I'm not sure how well-supported the older OpenGL base is though; all the development effort is on the Metal side.
Comment: Huh.  Why is SpriteKit using Metal?  Is there a way to ask it not to?
Comment: I see.  In that case I will ignore the messages.  Any way to suppress them?
Comment: Not as far as I know. There may be something in the build settings to disable them though, which might do it. (Disable the validation and capture that is, but it's still going to be using Metal.)
Comment: Fix for [Metal API Validation Enabled](https://stackoverflow.com/questions/60645401/xcode-logging-metal-api-validation-enabled).
Answer: Do not worry, they are not errors just messages.
Answer:
If your target links to the Metal framework (or any other framework
  that uses the Metal API "SpriteKit"), Xcode automatically enables GPU Frame
  Capture and Metal API Validation. Enable these options in your app's
  scheme to use the host of tools Xcode provides with Metal Frame
  Capture, and to test for correct API usage with Metal API Validation.
  You only disable these options when you want to test your app's
  maximum performance level.

Enabling/Disabling Frame Capture


Conditional expectation of indicator function

Question: Could someone confirm if the following is correct. If not why? \begin{equation}
E[\mathbb{1_{X\leq x}}|Y]=P[X|Y]=\frac{P[X,Y]}{P[Y]}
\end{equation}
Thank you.
Comment: What does $P[X,Y]$ and $P[Y]$ denote?
Comment: In that case, the left-hand side is a random variable while the right-hand side is a real number. So except in degenerate cases, there can not be equality.
Comment: They are probability distributions of the two continuous RVs X and Y. So, P[Y]=P[Y<=y].
Comment: What term does the right (left)-hand side lacks such that the equality holds?
Comment: That's kind of awkward question, don't you think? Why don't you tell why you want to know this and in what context you have encountered it?
Comment: I want to understand how the Bays theorem work on this lhs expression. I thought is the same as when you have events, but I start to understand that there are differences and I want to understand how the two relate.
Answer: Assume that $Y:(\Omega,\mathcal F)\to(E,\mathcal E)$, that is, that the random variable $Y$ is $E$-valued (in most of the cases, $(E,\mathcal E)=(\mathbb R,\mathcal B(\mathbb R))$ but the natural setting of the question is more general). On the other hand, the random variable $X$ must be real valued, thus, $X:(\Omega,\mathcal F)\to(\mathbb R,\mathcal B(\mathbb R))$, and the measurable space $(\Omega,\mathcal F)$ is endowed with a probability measure $\Pr$.
By definition, for each real number $x$, $E(\mathbf 1_{X\leqslant x}\mid Y)=\Pr(X\leqslant x\mid Y)$ (the two notations are equivalent) is a real valued random variable $u(Y):\Omega\to\mathbb R$ where the measurable function $u:E\to\mathbb R$ must be such that, for every bounded measurable function $v:E\to\mathbb R$, one has $$E(v(Y):X\leqslant x)=E(v(Y)\mathbf 1_{X\leqslant x})=E(v(Y)u(Y)).
$$
This defines the random variable $u(Y)$ uniquely, up to null events. One can show that $0\leqslant u(Y)\leqslant1$ almost surely. Furthermore, if $\Pr(Y=y)\ne0$ for some given $y$ in $E$ then $u(y)=\Pr(X\leqslant x\mid Y=y)$, that is, $u(y)=\Pr(X\leqslant x, Y=y)/\Pr(Y=y)$.
Thus, for each real number $x$, $E(\mathbf 1_{X\leqslant x}\mid Y)=\Pr(X\leqslant x\mid Y)$ is a real valued random variable, that is, a measurable function from $\Omega$ to $\mathbb R$ while, for each $y$ in $E$ such that $\Pr(Y=y)\ne0$, $\Pr(X\leqslant x\mid Y=y)$ is a real number. The only function $\mathbb R\to\mathbb R$ in the picture is $u$ when $Y$ is real valued, otherwise $u:E\to\mathbb R$. In particular, for $y$ in $E$, $\Pr(X\leqslant x\mid Y)(y)$ is undefined, while, for $\omega$ in $\Omega$, $\Pr(X\leqslant x\mid Y)(\omega)$ is simply $u(Y(\omega))$.
A simple case is when $(X,Y)$ has a joint density $f$ with respect to $\mathrm{Leb}\otimes\mu$, for some measure $\mu$ on $E$, and $f$ is, say, positive everywhere on $\mathbb R\times E$. Then, $\Pr(X\leqslant x\mid Y)=u(Y)$ almost surely, where the function $u$ is defined, for every $y$ in $E$, by
$$u(y)=\frac1{f_Y(y)}\int_{-\infty}^xf(z,y)\mathrm dz,\qquad f_Y(y)=\int_{-\infty}^{+\infty}f(z,y)\mathrm dz.$$
Answer: This is true:
$\operatorname{\large E}[{\large 1}_{(X\leq x)}\mid Y] = \operatorname{\large P}[X\leq x\mid Y]$
This is also correct: $\operatorname{\large P}[X\leq x\mid Y\leq y] = \dfrac{\operatorname{\large P}[X\leq x,  Y\leq y]}{ \operatorname{\large P}[Y\leq y]}$
However: $ \operatorname{\large P}[X\leq x\mid Y]\neq \operatorname{\large P}[X\leq x\mid Y\leq y]$
Because the former is a random variable, while the later is a conditional probability density.
Thus: $\operatorname{\large E}[{\large 1}_{(X\leq x)}\mid Y](y) = \operatorname{\large P}[X\leq x\mid Y = y]$

For more detail on the notation, see also: http://en.wikipedia.org/wiki/Conditioning_(probability)#Conditional_expectation
Comment: Sorry but $\operatorname{E}[{1}_{(X\leq x)}\mid Y]$ is a random variable defined on $\Omega$, not on the real line, hence $\operatorname{E}[{1}_{(X\leq x)}\mid Y](y)$ is undefined.
Comment: How would you use the Bays theorem on the left hand side expressions?
Comment: @KAT You could not, unless $Y$ was a discrete random variable.
Comment: @GrahamKemp Not interested in straightening up this answer? *Schade*...
Comment: @Did could you please try and straightening up yourself?
Comment: @KAT Done. $ $ $ $


How do I access the value of this particular xml node?

Question: I'm transforming an XML document to HTML, and wish to pick out a few particular elements (for use in the head.title of the HTML page).
My source XML looks thusly:
<document>
  <vars>
    <var name="serialno">
      12345                     <<--- I want THIS value
    </var>
    <var name="rev-date" rev="old">
      2000-01-01
    </var>
    <var name="rev-date" rev="new">
      2011-05-01                <<--- ...and also THIS value
    </var>
    ... more vars
  </vars>
    ... more data
</document>

Now, the serial would be something along the lines of "<xsl:value-of select="/vars/var@serialno"/>", but I can't figure out how to address the var with that particular name. Similarly for the revision date, except that I need to specify two attributes. How do I do that?
Comment: Good question, +1. See my answer for two alternative solutions for each of your two questions. This is actually an XPath question.
Comment: @Dimitre, thanks for the tag adjustment.
Answer: <xsl:value-of select="document/vars/var[@name='serialno']"/>

AND
<xsl:value-of select="document/vars/var[@name='rev-date' and @rev='new']"/>

To test this out go to xmlper.com and key this as the XSL:
       <?xml version="1.0" encoding="ISO-8859-1"?>

     <xsl:value-of select="document/vars/var[@name='serialno']"/>

    <xsl:value-of select="document/vars/var[@name='rev-date' and @rev='new']"/>

And this as the XML document:
<document>
  <vars>
    <var name="serialno">
      12345
    </var>
    <var name="rev-date" rev="old">
      2000-01-01
    </var>
    <var name="rev-date" rev="new">
      2011-05-01
    </var>
    ... more vars
  </vars>

</document>

Comment: This sounds very concise and alluring, except it doesn't seem to work. I'll try some more...
Comment: Hi - I tested this on www.xmlper.com.  I've attached code above which you can use to test it (unfortunately the website doesn't allow me to save and send a link onto you).
Comment: Ah, I was missing a leading slash, `/document/...`
Answer: Use:
/*/vars/var[@name = 'serialno']/text()

to obtain the desired text node or just
string(/*/vars/var[@name = 'serialno'])

to get the desired string.
And use:
/*/vars/var
       [@name = 'rev-date'
      and
        @rev = 'new'
       ]/text()

to obtain the 2nd desired text node or just
string(/*/vars/var
           [@name = 'rev-date'
          and
            @rev = 'new'
           ]/text()
      )

to get its string value.
Comment: `Serial:
` worked like a charm. Thanks!


Why is the $\tan$ function differentiable even though it is not continuous?

Question: If only continuous functions can be differentiable, then how can the tangent function $\tan$ be differentiated, even though $\tan$ is not a continuous function?
Comment: @Alexey Ok sure, of course the statement is kind of silly. I was just trying to stimulate the person asking the question into thinking carefully about the domain of the function and its points of discontinuity.
Comment: $\tan x$ is not differentiable on $\Bbb R$.
Comment: $\tan$ is continuous. All elementary functions are continuous everywhere.
Comment: @Ruben, $\tan$ is not defined on $\mathbb{R}$.  "$\tan$ is not differentiable on $\mathbb{R}$" is a bit like saying that the square root function is not differentiable on $\mathbb{Z}[X, Y]$.
Comment: @alexey It's more like the square root function is not differentiable on $\Bbb R$, which is true.
Comment: @Ruben, ok, let's agree on a compromise: it is like the square root function is not differentiable on $\mathbb{R}[X,Y]$. :) (Note that $[0,\infty)\subset\mathbb{R}[X,Y]$.)  Though, here $\mathbb{R}[X,Y]$ is not a manifold of the same dimension as $[0,\infty)$, so, let's better talk about continuity: the square root function is not continuous on $\mathbb{R}[X,Y]$.
Comment: @Riya, incidentally, it is important to note the difference between the notion of *continuity* of a function and the notion of *connectedness* of its domain.  Virtually all functions that normal people encounter in their lives are continuous, but many of them do not have connected domain (see $\tan$, for example).  The domain of a function of a complex variable can also be connected but not *simply connected*, etc.  IMO, the emphasis on *continuity* in calculus courses is not well justified -- the connectedness of domains is less obvious to verify.
Answer: The tangent function is continuous. I suppose that you are confused by the fact that it has singularities at $k\pi+\frac{\pi}{2}$, $k\in\Bbb Z$, but these points are simply not in the domain of the function.
To be more precise: The function
$$ \tan\colon \Bbb R \setminus \{k\pi+\frac{\pi}{2}: k\in\Bbb Z\} \to \Bbb R$$
is continuous and indeed even differentiable.
Answer: Actually, $\tan$ is a continuous (and differentiable) function. Keep in mind that its domain is $\mathbb R\setminus\left\{\frac\pi2+k\pi\,\middle|\,k\in\mathbb Z\right\}$. Since it is the quotient of two differentiable functions, it is differentiable.


"Variable" was not declared in this scope

Question: I am getting this error when I try to compile my class. I have made sure there is function prototypes and variables are initilized correctly, hopefully someone can help me figure out the problem
g++ -c main.cc
g++ -c BankControl.cc
g++ -c Bank.cc
g++ -c Account.cc
g++ -c View.cc
g++ -c AcctList.cc
g++ -c Customer.cc
g++ -c CustArray.cc
g++ -c Transaction.cc
Transaction.cc: In function 'int getTransID()':
Transaction.cc:18:34: error: 'transID' was not declared in this scope
 int getTransID()        { return transID;  }
                                  ^
Transaction.cc: In function 'TransType getTType()':
Transaction.cc:19:34: error: 'tType' was not declared in this scope
 TransType getTType()    { return tType;    }
                                  ^
Transaction.cc: In function 'TransState getTState()':
Transaction.cc:20:34: error: 'tState' was not declared in this scope
 TransState getTState()  { return tState;   }
                                  ^
Transaction.cc: In function 'std::__cxx11::string getDate()':
Transaction.cc:21:34: error: 'date' was not declared in this scope
 string getDate()        { return date;     }
                                  ^
Transaction.cc: In function 'int getTAcctNum()':
Transaction.cc:22:34: error: 'tAcctNum' was not declared in this scope
 int getTAcctNum()       { return tAcctNum; }
                                  ^
Transaction.cc: In function 'float getTAmount()':
Transaction.cc:23:34: error: 'tAmount' was not declared in this scope
 float getTAmount()      { return tAmount;  }
                                  ^
Transaction.cc: In function 'void setDate(std::__cxx11::string)':
Transaction.cc:28:3: error: 'date' was not declared in this scope
   date = d;
   ^
Makefile:31: recipe for target 'Transaction.o' failed
make: *** [Transaction.o] Error 1

Here is my header file
    #ifndef TRANSACTION_H
    #define TRANSACTION_H

    #include <string>
    using namespace std;

    #include "defs.h"

    class Transaction
    {
      public:
        Transaction(TransType = TTERROR, TransState = TSERROR,int = 0 ,float = 0);
        int         getTransID();
        TransType   getTType();
        TransState  getTState();
        string      getDate();
        int         getTAcctNum();
        void        setDate(string);
        float       getAmount();
      private:
        static int  nextTransID;
        int         transID;
        TransType   tType;
        TransState  tState;
        string      date;
        int         tAcctNum;
        float       tAmount;

    };

    #endif

Here is my source file
#include "Transaction.h"
#include "defs.h"

#include <string>
using namespace std;

int Transaction::nextTransID = 2001;

Transaction::Transaction(TransType t, TransState s, int acct, float amount)
{
  transID   = nextTransID++;
  tType     = t;
  tState    = s;
  tAcctNum  = acct;
  tAmount   = amount;
}

int getTransID()        { return transID;  }
TransType getTType()    { return tType;    }
TransState getTState()  { return tState;   }
string getDate()        { return date;     }
int getTAcctNum()       { return tAcctNum; }
float getTAmount()      { return tAmount;  }

void setDate(string d)
{
  date = d;
}

I am kinda lost on what is the issue
Comment: In your source file the functions are global functions, not member function of the `Transaction` class.
Answer: This:
int getTransID()        { return transID;  }

has nothing to do with your class, it's a global function.
You meant:
int Transaction::getTransID() { return transID;  }

Also, that function (and the other getters) should be made const to signal that they don't modify the object.
Comment: Thank you, I am really really sorry. I did not notice that. I did not notice them for all the functions sorry.


How do I call a function that needs strings with "quotes"?

Question: I am trying to write a small script on Mathematica that graphs a particular set of data which I obtain using Python.
The data output is as follows:
It is a standard datetime object being echoed onto a tsv file.
2014-03-29 08:39:37.080834  04  0.403980970383  0.2
2014-03-29 08:39:39.449200  04  0.383723974228  0.2
2014-03-29 08:39:42.603058  04  0.475341081619  0.2
2014-03-29 08:39:44.882941  04  0.303984165192  0.2
2014-03-29 08:39:47.021998  04  0.312470912933  0.2
2014-03-29 08:39:48.951891  04  0.312346935272  0.2

The first column is the datetime object, time and date are separated by a space not a \t. The next 3 columns are the ones separated by a \t, but are irrelevant to the question at hand (although I'd be happy to tell what they mean if anyone is interested).
So what I am trying to do is import the first column into Mathematica so that I can graph the first and second column (i.e the date and time (x axis) with the 04s (y axis, representing events)).
To do so I did this:
data = Import["/home/pi/Desktop/data.tsv"]
dates = data[[;;,1]]
DateList[dates]

But on the last line is where I get an error. I know for a fact that if I call the DateList function and I give it one of the date objects in "quotes" it works, but since for some reason these strings are not in quotes it returns an error. The error indicates that the input cannot be interpreted as a date or time input.
I've tried using something like DateList[dates//InputForm[%]], but it still does not work.
Please help me understand how strings work in Mathematica! :)
Fed
Comment: Just in case you don't really need Mathematica: you know python can plot such data itself, right?  See [this page](http://matplotlib.org/1.3.1/users/recipes.html#fixing-common-date-annoyances) for examples.  (These days, there's no reason to use Mathematica for anything except some symbolic math, and occasionally its curated data, unless your boss/professor makes you use it.)
Answer: I don't have any experience with mathematica, but it should be easy enough to make sure that each of the dates has quotes around it:
data = Import["/home/pi/Desktop/data.tsv"]
dates = data[[;;,1]]
dates = ['"' + date + '"' for date in dates]
DateList[dates]

FYI I'm assuming that each date in dates is a string.
Answer: The string format for your dates includes "-" and " " and ":". The documentation for Datelist claims you are supposed to be able to give it a format string and get it to extract a date from a string, but repeated attempts to get that to work have failed. Carefully study the details of the documentation and see if you can give it a string format that works. OR just do a little string hacking and extract your own fields and be done with it.
In[1]:= data = Import["data.tsv"];
dates = data[[;; , 1]];
fixeddates = Map[ToExpression["{" <> StringReplace[#,
   {"-" -> ",", " " -> ",", ":" -> ","}] <> "}"] &, dates]

Out[3]= {{2014, 3, 29, 8, 39, 37.0808}, {2014, 3, 29, 8, 39, 39.4492},
   {2014, 3, 29, 8, 39, 42.6031}, {2014, 3, 29, 8, 39, 44.8829},
   {2014, 3, 29, 8, 39, 47.022}, {2014, 3, 29, 8, 39, 48.9519}}

where each date is now a list of numbers.
Ah, a little progress on getting formatting strings to work. This works
In[18]:= DateList[{"2014-03-29 08:39:48", {"Year", "-", "Month",
  "-", "Day", " ", "Hour", ":", "Minute", ":", "Second"}}]

Out[18]= {2014, 3, 29, 8, 39, 48.}

but this doesn't
In[19]:= DateList[{"2014-03-29 08:39:48.951891", {"Year", "-", "Month",
   "-", "Day", " ", "Hour", ":", "Minute", ":", "Second"}}]

During evaluation of In[19]:= DateString::str: String 2014-03-29 08:39:48.951891 cannot be interpreted as a date in format {Year,-,Month,-,Day, ,Hour,:,Minute,:,Second}. >>

Out[19]= DateList[{"2014-03-29 08:39:48.951891", {"Year", "-",
 "Month", "-", "Day", " ", "Hour", ":", "Minute", ":", "Second"}}]

So Datelist will extract Integer seconds but not Real seconds even though the documentation says "Day, hour, minute, and second values can be nonintegers:"
Unless someone else can come up with a good explanation that really looks like a bug.
Edit showing how to then plot the data
data = Import["data.tsv"];
points = data[[All, {1, 3}]]; (*extract date and 3rd column*)
fixedpoints = Map[{ToExpression["{" <> StringReplace[First[#],
   {"-" -> ",", " " -> ",", ":" -> ","}] <> "}"], Last[#]} &, points];
DateListPlot[fixedpoints, PlotStyle -> PointSize[0.02]]

...PlotSnipped...

Comment: This is very interesting! Thank you very much!
How can I plot the data?? I tried calling the DatePlotList function, but it still returns just the list of numbers. I believe it needs them to be in DateList Objects. I guess I'll try to truncate the seconds into integer seconds. But I still have no idea how to add the quotes around the numbers..
Comment: This is awesome! It works! That was exactly what I was trying to do. For some reason I couldn't combine the two lists in such a way that you are you have {{year, month, day}, event}
I had no idea how to do it.
Thanks again!!!


Streaming Audio FROM iPhone to Browser. Ideas?

Question: I have seen plenty of articles and SO questions about streaming TO an iPhone app, but my question is the reverse, that is, streaming FROM an iPhone app.
I have audio content in an iPhone app, that I want to stream to a browser.  So the idea is that the browser can connect to a server running on the iphone.  The server on the iphone will give the audio to the browser. The browser will play the endless stream.
I already have seamless looping content on the phone with AudioQueue.  I already know how to setup a server running on the phone with CocoaHTTPServer.  Is there a third piece that can make the AudioQueue (or a FileStream) stream to a browser connected to the internal iPhone server?
Anybody have any thoughts on how to implement this?
Answer: Well, there are a few good open source projects to dissect, port, or imitate for this. What I would suggest is looking at how Icecast and streamTranscoderv3 operate together. The latter will take an audio source and send it to an Icecast server as a source. Port parts of both and run them locally on the iPhone and you'd have a solution. I imagine that Bonjour could be used so that other systems on the LAN could find and listen to the iPhone.
Or send the streamTranscoder output to an Icecast server elsewhere and make it available for the world.
Unfortunately, neither project is over engineered - the code isn't super modular but it is comprehensible and modestly cross platform.


Sufficient statistics and randomized estimator in TPE

Question: I've been reading Lehmann and Casella's Theory of Point Estimation 2nd Edition (TPE). In Chapter 1 Section 6 (pp.32-33), they introduce the idea "randomized estimator". Their explanation is, if $X \sim \mathcal{P} = \{ P_\theta \mid \theta\in \Theta \}$ and $T$ is sufficient for $\mathcal{P}$, since $T$ contains all the information on $\theta$, one can generate $X'$ only from the information $T=t$ such that $X$ and $X'$ have the same unconditional distribution, so do $\delta(X) $ and $\delta(X')$. They call $\delta (X')$ a randomized estimator.
I am struggling to make a sense of this statement. For example, $X_1,...,X_n \sim N(\mu, 1)$, iid, then $\bar{X}$ is sufficient for $\mu$. If we want to estimate $\mu$ by $\delta(X) = \bar{X}$, then $\bar{X} \sim N(\mu, n^{-1})$. Upon looking on the realization of the sufficient statistics, $\bar{X} = \bar{x}$, we can generate new sample by $X_1', \dots, X_n' \sim N(\bar{x}, 1)$. Then, the unconditional distribution of $\delta(X') = \bar{X}'$ is $N(\mu, (2n)^{-1})$, so the unconditional distributions do not coincide. What part I am doing wrong?
Comment: Thanks! Your answer and the suggested link helped me understand the concept.
Comment: Would this [answer](https://math.stackexchange.com/a/1806087/14893) fit your question?
Answer: Randomised estimators are defined in a more general setting than in this case and in particular need not be connected with sufficiency. In full generality, a randomised decision rule is a decision rule that returns a random decision for a given observation (or dataset). To reproduce the quote from Lehmann and Casella :

The starting point of a statistical analysis, as formulated in the
preceding sections, is a random observable $X$ taking on values in a
sample space $X$, and a family of possible distributions of $X$. It
often turns out that some part of the data carries no information
about the unknown distribution and that $A$ can therefore be replaced
by some statistic $T = T (A)$ (not necessarily real-valued) without
loss of information. A statistic $T$ is said to be sufficient for $A$,
or for the family $V = \{P_\theta,\ \theta\in\Omega\}$ of possible
distributions of $A$, or for $\theta$, if the conditional distribution
of $A$ given $T = t$ is independent of $\theta$ for all $t$.
This definition is not quite precise and we shall return to it later
in this section. However, consider first in what sense a sufficient
statistic $T$ contains all the information about $\theta$ contained in
$A$. For that purpose, suppose that an investigator reports the value
of $T$, but on being asked for the full data, admits that they have
been discarded. In an effort at reconstruction, one can use a random
mechanism (such as a pseudo-random number generator) to obtain a
random quantity $X'$ distributed according to the conditional
distribution of $X$ given $t$. (This would not be possible, of course,
if the conditional distribution depended on the unknown $\theta$.)
Then the unconditional distribution of $X'$ is the same as that of $X$
, that is,  $$ P_0 (X' \in A) = P_\theta (X \in A)\quad\text{for all
  }A,  $$ regardless of the value of $\theta$. Hence, from a knowledge
of $T$ alone, it is possible to construct a quantity $X'$ which is
completely equivalent to the original $X$. Since $X$ and $X'$ have the
same distribution for all $\theta$ , they provide exactly the same
information about $\theta$ (for example, the estimators $\delta(X)$
and $\delta(X')$ have identical distributions for any $\theta$).

The estimator $\delta(X')$ is possibly random given the observed realisation $t$ of $T(X)$. Each time $\delta(X')$ is considered, unless $\delta(X')=\delta(X)$ with probability one, a different realisation occurs. This means that $\delta(X')$ is a random variable for the observed realisation of the original data $X$, rather than a deterministic value, which explains for the following quote where the notion of randomised estimator is introduced.

The construction of $X'$ is, in general, effected with the help of an
independent  random mechanism. An estimator $S(X')$ depends,
therefore, not only on $T$ but  also on this mechanism. It is thus not
an estimator as defined in Section 1, but  a randomized estimator.
Quite generally, if $X$ is the basic random observable, a  randomized
estimator of $g(\theta)$ is a rule which assigns to each possible
outcome $x$ of $X$ a random variable $Y(x)$ with a known distribution.
When $X = x$, an observation of $Y(x)$ will be taken and will
constitute the estimate of $g(\theta)$. The risk, defined by (1.10),
of the resulting estimator is then  $$ \int_{\mathcal X}\int_\mathcal{Y} L(\theta ,  y)dP_Y(y|X=x) dP_X(x;\theta,  $$ where the probability measure in
the inside integral does not depend on $\theta$.

In the special case of the Normal distribution proposed in the question,

the new sample $(X_1^\prime,\ldots,X_n^\prime)$ is generated conditional on $T(X^\prime)=\bar X$ and therefore $\bar{X^\prime}=\bar X$. In particular, if $\delta(X)=\bar X$, then $\delta(X^\prime)=\bar X$
the proposed estimator $\delta(X^\prime)$, namely the sample mean,  is then non-randomised, which definitely cancels the appeal of the example! If instead, the median of the sample was considered as the estimator of the mean $\mu$, the estimator $\delta(X^\prime)$ would then be truly randomised, since the new normal sample $X^\prime$ would differ from $X$ and the median would remain random conditional on $\bar X$. (With expectation $\bar X$, though.)


Meteor collection query 'undefined'

Question: I have the code
datas = new Meteor.Collection("datas")
var data = datas.findOne('101abcde1f2345ac00000001')

if (Meteor.is_client) {
    Meteor.startup(function () {
        console.log(data.name)
    });
}

But what I get in the console is an undefined error. However if I type console.log(data.name) into the web inspector's javascript console (presumably after some kind of wait it works. I'm already putting the code in Meteor.startup to ensure that the DOM is ready. what could I be doing wrong?
Comment: where is the Restaurants Collection ? Restaurants = new Meteor.Collection('restaurants');
Answer: It seems that you are using autopublish package. And (of course), Meteor.startup doesn't wait subscription completed.
Usually, we use reactive context & data  to do this in Meteor -
datas = new Meteor.Collection("datas")

if (Meteor.is_client){
  Meteor.autosubscribe(function(){
    var data = datas.findOne('101abcde1f2345ac00000001');
    if (data){ console.log( data.name )}
  });
}

Anytime datas collection has changes(?), the function in Meteor.autosubscribe will be called.
Comment: This does work but it gets called twice (once initially), and second when the datas collection is finally loaded up. Is there a way to only do it once? (ignoring changes-) because I have a .observe that only watches for when the particular document changes instead of any of the irrelevant ones
Comment: Sorry, I don't know. But I don't think it's really neccesary. Maybe you can take a look at the `_markAsReactive` under Minimongo, and help yourself.

Meteor collection query 'undefined'


Ember: how to add params from router to adapter

Question: I'm trying to fetch data from the following URL structure:
${ENV.APP.API_HOST}/api/v1/customers/:customer_orgCode/sites/

I'm using an adapter to shape the request with buildURL with the following files:
// router.js
this.route('sites', { path: 'customers/:customer_orgCode/sites' }, function() {
    this.route('show', { path: ':site_id' });
});

// adapters/site.js
export default ApplicationAdapter.extend({
  buildURL (modelName, id, snapshot, requestType, query) {
    // return `${ENV.APP.API_HOST}/api/v1/customers/${snapshot???}/sites/`;
    return `${ENV.APP.API_HOST}/api/v1/customers/239/sites/`;
  }
}

// routes/sites/index.js
export default Ember.Route.extend({
  model: function() {
    let superQuery = this._super(...arguments),
        org = superQuery.customer_orgCode;
    this.store.findAll('site', org);
  }
});

I'm able to get the customer_orgCode on the model, but unable to pull it into the adapter. I've noted that the model isn't being populated in the Ember inspector, but the sites data is present when I make the request. Does anyone know how I can dynamically populate the buildURL with the customer_orgCode from the params on the router? And then specify sites/index to use the 'site' model?
Comment: if you are using JSONApiAdapter then you can try using http://emberjs.com/api/data/classes/DS.JSONAPIAdapter.html#method_urlForFindAll
Answer: OK, I've figured this out. I needed to use query() instead of findAll() in the route. This allows buildURL to pickup the query parameter from the route and pass it in as the 5th argument ie. - buildURL(modelName, id, snapshot, requestType, query). Then in the route, I was neglecting return as part of my model setup. So the solution is below for anyone interested.
// router.js
this.route('sites', { path: 'customers/:customer_orgCode/sites' }, function() {
    this.route('show', { path: ':site_id' });
});

// adapters/site.js
export default ApplicationAdapter.extend({
  buildURL (modelName, id, snapshot, requestType, query) {
    let org = query.org;
    return `${ENV.APP.API_HOST}/api/v1/customers/${org}/sites/`;
  }
});

// routes/sites/index.js
export default Ember.Route.extend({
  model: function() {
    let superQuery = this._super(...arguments),
        org = superQuery.customer_orgCode;
    return this.store.query('site', {org:org});
  }
});


Rational power in modular arithmetic

Question: I was going through Batch RSA and in one such case they have used\
t = $\ m^x$ mod n where x is of the form 1/e where e is an integer.
what does t mean and will it be an integer ?
Eg if m = 10, e = 2 and n = 100 then will t = $\sqrt10$ mod 100 or something else
Please refer the figure. I'm asking about something like $\ V ^ (1/E) $
Comment: $2$ is not invertible modulo $100,$ so that's not a good example. What they mean by $1/e$ is some integer $d$ such that $de\equiv1\pmod{n}.$
Answer: Welcome to MSE! Have a look into my answer made today: What do some cryptographic terminology mean?(e.g. public params, security params)
In view of the RSA (Rivest, Shamir, Adlement) cryptosystem, each user chooses two large primes $p$ and $q$. Then she (beloved Alice) computes $n=p⋅q$ and $ϕ(n)=(p−1)(q−1)$. Afterwards she chooses an integer $e$ in the range $1<e<ϕ(n)$, usually a prime, such that $e$ is invertible modulo $ϕ(n)$. Then she computes $d=e^1$ in Zϕ(n). Then $(n,e)$ is the public key and $d$ is the private key.
In your context, $x$ equals $d$.
Comment: Thanks for the reply. I was going through Batch RSA

Rational power in modular arithmetic


Compartilhar objeto entre dois controllers no angularjs

Question: Estou estudando AngularJS e estou tentando fazer um CRUD simples, porem não estou conseguindo ter o mesmo objeto da minha listagem para o meu formulário, ou seja, na hora que clicar no botão de editar ir para o formulário preenchido pelo objeto.
Tenho a Factory (li sobre compartilhar dados porem só atributo, queria compartilhar o objeto inteiro)
app.factory('item', function(){
  return item;
});

Minha lista:

      {{item.id}}
      {{item.descricao}}
      {{item.status}}
      {{item.prioridade}}
      {{item.tipo}}

E meus Controllers
app.controller("listCtrl", function($scope, $http, $location, item){
    $scope.itemAux = item;
    $scope.loadData = function(){ ... };
    $scope.deleteItem = function(item){ ... };

    $scope.editItem = function(itemX){
         $scope.itemAux = itemX;
         $location.path('/cadastro');
    };
}

app.controller("formCtrl", function($scope, $http, $location, item){
    $scope.itemAux = item;

    $scope.save = function(){ ... }
    $scope.update = function(){ ... }
}

Comment: http://stackoverflow.com/questions/12008908/angularjs-how-can-i-pass-variables-between-controllers
Answer: Existem algumas maneiras de se obter o resultado que você deseja, como utilizar $rootScope, $broadcast ou então armazenar os dados no SessionStorage ou LocalStorage, etc.
Uma das maneiras mais simples é criar um Service pra compartilhar os dados entre os dois Controllers, Exemplo:

angular.module('myApp',[]);

angular.module('myApp').factory('myService', function() {
 var valor = {}

 function set(data) {
   valor = data;
 }
 function get() {
  return valor;
 }

 return {
  set: set,
  get: get
 }

});
angular.module("myApp")
    .controller("ctrl1", function($scope, myService){
    $scope.pessoa = {id: 1, nome: 'Diego', idade: 23};
    //Atribui um valor ao serviço
    myService.set($scope.pessoa);
});
angular.module("myApp")
    .controller("ctrl2", function($scope, myService){
     //Pega o valor atribuido ao serviço
     $scope.pessoa = myService.get();
});

Controller 1

  Atributo: {{pessoa.nome}}!

Controller 2

  Objeto: {{pessoa}}!

  Atributos: {{pessoa.nome}} -- {{pessoa.idade}}!

Para mais informações recomendo os links:
Services
Factory x Services
Comment: Obrigado, não sabia sobre service, deu certinho. obrigado!


PDDL syntax error, ':DURATIVE-ACTIONS' : domain definition expected

Question: I was modeling a domain file with durative actions. I am using the PDDL plugin for VS Code. The code does not have any syntax error problems. The Planner from HTTP://solver.planning.domains/solve return an error
<code>/tmp/solver_planning_domains_tmp_41rdIKx0z0gCb/domain.pddl: syntax error in line 5, ':DURATIVE-ACTIONS': domain definition expected Failed to parse the problem -- list index out of range</code>
The complete domain file big to post here, so the related part of code is:
I appreciated your help.
<code>(define (domain test)

(:requirements :strips :typing :fluents :durative-actions :duration-inequalities :negative-preconditions :equality )
(:types
    getbot - robot
    wp0 wp1 charging_station object_location - location
    a1 a2 a3 - area
    bat1 charger - power
    gripper
    obj- object
)

(:predicates
    ;General predicates
    (robot-at ?rb - robot ?l - location)
    (location-situated ?l - location ?a - area)    ;location situated in which area

    ;Gripper related predicates
    (object-found ?o - object)
    (object-at ?o - object ?obj_loc - location)
    (object-placed ?o - object ?obj_loc - location)
    (gripper-empty ?rb - robot ?gr - gripper)
    (holding-object ?rb - robot ?o - object)
</code>
Thank you in advance
Answer: The planner on that server doesn't support durative actions.


Equation of normals at the end of variable chord of parabola $y^2-4y-2x=0$

Question: Here is my problem:
If the normals at the ends of a variable chord PQ of the parabola $y^2-4y-2x=0$ are perpendicular then the tangents at P and Q will intersect at??
The correct answer is $2x+5=0$.
I could not figure out the way from where to start. Basically i am strucked with the equation of parabola since it is not the standard parabola. The vertex of the given parabola is $(-2,2)$. Thanks for any kind of help.
Answer: We have $x=(y^2-4y)/2$
If $y=2t,x=2t^2-4t$
So, any point $(A)$ on $2x=y^2-4y$ can be written as $(2t^2-4t,2t)$
The equation of the tangent at $A(2t^2-4t,2t)$ will be $$2t^2-2ty+x+2y=0\ \ \ \ \ (1)$$ which is a Quadratic Equation in $t$
If $P(t_1),Q(t_2)$   $t_1t_2=\dfrac{x+2y}2;t_1+t_2=y\  \ \ \ (2)$
$(1)$ can also be expressed as $y=\dfrac x{2(t-1)}+\dfrac{t^2}{t-1}$
So, the gradient of the normal at $A(2t^2-4t,2t)$ will be $\dfrac{-1}{\dfrac1{2(t-1)}}=2(1-t)$
$\implies2(1-t_1)\cdot2(1-t_2)=-1\iff 1-(t_1+t_2)+t_1t_2=-\dfrac14\  \ \ \ (3)$
Compare $(2),(3)$ to eliminate $t_1,t_2$
Answer: Let $P\left(\frac{p^2-4p}{2},p\right),Q\left(\frac{q^2-4q}{2},q\right)$ where $p\not=q$.
Now, one has $x=\frac{y^2-4y}{2}\Rightarrow \frac{dx}{dy}=\frac{2y-4}{2}=y-2$. Since the normals at $P,Q$ are perpendicular, one has
$$(p-2)(q-2)=-1\iff pq-2p-2q=-5\tag 1$$
By the way, since the tangents at $P,Q$ are
$$y-p=\frac{1}{p-2}\left(x-\frac{p^2-4p}{2}\right)\tag2$$
$$y-q=\frac{1}{q-2}\left(x-\frac{q^2-4q}{2}\right)\tag3$$
respectively, $(2)-(3)$ gives us
$$\begin{align}q-p&=\left(\frac{1}{p-2}-\frac{1}{q-2}\right)x-\frac{1}{p-2}\cdot \frac{p^2-4p}{2}+\frac{1}{q-2}\cdot\frac{q^2-4q}{2}\\&=\frac{q-p}{(p-2)(q-2)}x+\frac{(q-p)(pq-2p-2q+8)}{2(p-2)(q-2)}\end{align}$$
From $p\not=q$ and $(1)$, one has
$$1=-x-\frac{3}{2}\Rightarrow x=-\frac 52.$$


What are the core kubernetes Microservice components which Istio can replace?

Question: We are planning to integrate a microservices platform which is running in Kubernetes and the architecture will be similar to the below reference architecture.
https://www.ibm.com/devops/method/content/architecture/microservices/1_0
What are the core components which can be replaces by Istio on the above Kubernetes microservices architecture?
I understand it can help in request routing, traffic management, policies and control.
If I need to migrate one of the similar project what are the components which is available in Istio which can be replaced in Kubernetes or vice versa?
Comment: Please ask a more specific question after having tried the integration yourself. For eg: try out a requesting routing example between the 2 platforms yourself and if it doesn't work or you want feedback on the approach, show us what you tried out.
Answer: It doesn't replace any kubernetes core components. ISTIO is add-on for kubernetes to manage the micro service.
In the IBM article you can use ISTO for routing instated of Ingress Controller.
Comment: Thanks for your input.


Height and level order of tree Node

Question: Please have a look at the code and let me know where is an issue. As I want to find height and level order but the output is nothing. As the left and right node always contains null values.
Here is main function:
  public static void main(String[] args)
{

       Tree t1 = new Tree();
       Tree t2 = new Tree();
       t1.makeTree();
       t1.levelOrder(); //0 1 2 3 4 5 6 13 14 15 7 8 9 10 11 12
       System.out.println("height: " + t1.height()); //3
       t2.makeTree2();
       t2.levelOrder(); //0 1 2 3
       System.out.println("height: " + t2.height()); //1
       System.out.println("sub tree t1 and t1 " + t1.isSubTree(t1));
       System.out.println("sub tree t1 and t2 " + t1.isSubTree(t2)); //t2 is not a subTree of t1
       Tree t3 = new Tree();
       t3.makeTree3();
       t3.levelOrder();
       System.out.println("sub tree t1 and t3 " + t1.isSubTree(t3)); //t3 is a subTree of t1
       Tree t4 = new Tree();
       t4.makeTree4();
       t4.levelOrder();
       System.out.println("sub tree t1 and t4 " + t1.isSubTree(t4)); //t4 is a subTree of t1

     }
 }

Here is tree class:
class Tree{
   private static class TNode{
       private int value;
       private TNode parent;
       private TNode left, right;
       private List<TNode> children;

       public TNode(){
          this(0, null);
       }
       public TNode(int e){
          this(e, null);
       }
       public TNode(int e, TNode p){
          value = e;
          parent = p;
          left=right=null;
          children = new ArrayList<TNode>();
       }
   }

   private TNode root;
   private int size;

   Tree(){
     root = null;
     size = 0;
   }

   public TNode createNode(int e, TNode p){
        return new TNode(e, p);
   }

   public TNode addChild(TNode n, int e){
        TNode temp = createNode(e, n);
        n.children.add(temp);
        size++;
        return temp;
   }

   public void makeTree(){
        root = createNode(0, null);
        size++;
        buildTree(root, 3);
   }

   public void makeTree2(){
        root = createNode(0, null);
        size++;
        buildTree(root, 1);
   }

   public void makeTree3(){
        root = createNode(3, null);
        size++;
   }

   public void makeTree4(){
        root = createNode(2, null);
        size += 13;
        buildTree(root, 1);
        size -= 12;
   }

   private void buildTree(TNode n, int i){
        if (i <= 0) return;
        TNode fc = addChild(n, size);
        TNode sc = addChild(n, size);
        TNode tc = addChild(n, size);
        buildTree(fc, i - 1);
        buildTree(sc, i - 2);
        if (i % 2 == 0)
           buildTree(tc, i - 1);
   }

   public long height(TNode n){
       /*implement*/
       if (n == null)
            return 0;
         else
         {
             /* compute  height of each subtree */
             long lheight = height(n.left);
             long rheight = height(n.right);

             /* use the larger one */
             if (lheight > rheight)
                 return(lheight+1);
             else return(rheight+1);
         }
     // return 0;    }    public long height(){
       return height(root);
   }

   public void levelOrder(){
       /*implement*/
        Queue<TNode> queue = new LinkedList<TNode>();
         queue.add(root);
         while (!queue.isEmpty())
         {

             TNode tempNode = queue.poll();
             //System.out.print(tempNode.value + " ");

             /*Enqueue left child */
             if (tempNode.left != null) {
                 queue.add(tempNode.left);
             }

             /*Enqueue right child */
             if (tempNode.right != null) {
                 queue.add(tempNode.right);
             }
         }    }    public boolean isSubTree(Tree st){
       /*implement for extra credit*/ return false;
   }
}

Comment: My class was not defining left , right. I added them for the implementation of height. Original class have only following data members.
      private int value;
      private TNode parent;
       private List children;
Comment: Your main problems are code formatting and that `addChild` operates on `children`, whereas `height` and `levelOrder` operate on `left` and `right`. Choose either a binary tree (`left`/`right`) or an arbitrary tree (`children`).
Comment: Will you please guide me how i can find the height and level of arbitrary tree? I searched alot but all in vain
Comment: You already got good advice above. What have you done with it? You are populating `children`, not `left` and `right`, so when you have an algorithm that traverses via `left` and `right` it is normal that you get nothing.
Comment: Actually i want to find the height and level order of this tree. But i don't know how to do this? I need suggestion to do this
Comment: It starts by taking advice into consideration. It is a major flaw in your code which you should address first. It explains the problem that you described in your first paragraph. If you were able to write the code that you presented, then surely you can change it to remove the reference to `children` and replace it with appropriate use of `left` and `right`. Or is this code not yours?
Comment: Its partially mine, as i edited the code, my task was to find the height and level order. I implemented both functions with BST. and they are fine. Then i used same function in this code but no result. Then i debug the code and got that null values. I have got this point. As this code whole size is 16 and childern list are taking 3. But i am stuck at a point who can i traverse with children.
Comment: I cannot change the other code, i can only change both functions height and level order. Its requirement. It will be kind help if you guide me how to traverse with children array
Comment: It seems you are ignoring what has been said above. Why does your class define `left`, `right` and `children`? What is the purpose? Please explain their significance. Also only one of the two functions you mention uses a BST traversal.
Answer: With this extra bit of information, the question is now answerable:

Original class have only following data members: private int value; private TNode parent; private List<TNode> children;

So you're trying to implement height() and levelOrder() for an arbitrary tree. You already know how to implement these functions for a binary tree. What we need to do is adapt the algorithms you know for the data structure you have.
Let's start with the left/right version that you have:
public long height(TNode n){
  if (n == null) {
    return 0;
  } else {
    /* compute height of each subtree */
    long lheight = height(n.left);
    long rheight = height(n.right);

    /* use the larger one */
    if (lheight > rheight) {
      return(lheight+1);
    } else {
      return(rheight+1);
    }
  }
  return 0;
}

This is correct. All that needs to happen is to change it from recursing on left and right to using the contents of children. The algorithm is the same, as the comments indicate:
public long height(TNode n){
  if (n == null) {
    return 0;
  } else {
    /* compute height of each subtree */

    /* use the larger one */

  }
  return 0;
}

How can we compute the height of each subtree?
for (TNode child : n.children) {
  /* compute height of each subtree */
  long childHeight = height(child);
}

But we need to keep track of the largest one.
long highest = 0;
for (TNode child : n.children) {

  /* compute height of each subtree */
  long childHeight = height(child);

  /* use the larger one */
  highest = Math.max(highest, childHeight);
}
return highest + 1;

Putting it all together:
public long height(TNode n){
  if (n == null) {
    return 0;
  } else {
    long highest = 0;
    for (TNode child : n.children) {

      /* compute height of each subtree */
      long childHeight = height(child);

      /* use the larger one */
      highest = Math.max(highest, childHeight);
    }
    return highest + 1;
  }
  return 0;
}

As for levelOrder, you can follow the same logic there. I'll leave it as an exercise for you.

Addressing this comment:

Will you please guide me how to find a subtree from non binary tree?

Since this is an arbitrary tree, not a BST, we do not know anything about the order of the children, so we can't go hunting for specific values. Therefore, to find a subtree, we'll have to check every child.
/**
* haystack represents the tree we're looking inside
* needle is the tree we're looking for
*/
private boolean isSubTree(TNode haystack, TNode needle) {
  if (haystack == null && needle == null) {
    // Leaf
    return true;
  }
  if (haystack == null || needle == null) {
    // One is null, the other isn't
    return false;
  }
  if (haystack.value != needle.value) {
    // No match
    return false;
  }

  // We'll assume that order matters, and that all children need to match.
  if (haystack.children.size() != needle.children.size()) {
    return false;
  }

  // Iterate over all children and see if they match
  boolean result = true;
  for (int index = 0; index < haystack.children.size(); index++) {
    result = result && isSubTree(
      haystack.children.get(index),
      needle.children.get(index));
  }
  return result;
}

To invoke it, iterate over all nodes in this.root (perhaps by using levelOrder) and call the above method, returning true if any one call returns true. It's a O(n*m) algorithm, where n is the number of nodes in the haystack and m is the number of nodes in the needle.
Comment: Thank you so much. It works. But height is showing with one increment. I am trying to fix by myself.
Comment: I'm glad to hear that, @AliAhsan!
Comment: Will you please guide me how to find a subtree from non binary tree?
Comment: @AliAhsan: What kind of subtree is it? Is `b->c` a subtree of `a->b->c->d`? I.e., do all of the children need to match from a shared root, or is it just if the elements that intersect have the same parent/child structure?
Comment: The code is same and i have to implement the sub tree function. Above code will be used.
Comment: I have to implement the following function. public boolean isSubTree(Tree st){

      return false;
   }
Comment: I've added a sketch of the algorithm you could use to implement isSubTree to my answer.
Comment: Actually we cannot change the parameters of the function. We must have to use this. public boolean isSubTree(Tree st){ return false; } According to your answer you are taking two parameters of TNode class which we cannot use.
Comment: Yes, you have to use my algorithm within your function. I'm leaving that up to you. As I stated, `To invoke it, iterate over all nodes in this.root (perhaps by using levelOrder) and call the above method, returning true if any one call returns true.`
Comment: I am unable to understand. As my tree class uses root and size two data varriables only.
Comment: You have `this.root` and `st.root` available to you in the `isSubTree` method.
Comment: At this point, what you're after is a significantly different problem from the question you've asked above, so I would suggest the following: A) get a new, minimal snippet that you have to try to solve the `isSubTree` bit, B) be specific about what you want it to do and where your attempt is failing (with error messages, if applicable, and inputs and outputs) and C) put all of that in a new question titled "What is wrong with my isSubTree method?" tagged `java`, `algorithm`, `tree` and `data-structures`.

Height and level order of tree Node


How to manually draw graphs on a torus?

Question: I have to do some homework questions that require me to draw graphs on a torus. My drawing skills suck, so I wondered if there is a program which allows you to do something like this easily?
Comment: Are you familiar with the torus as a quotient of a square? It might be harder to interpret, but lacking such software, something you might fall back on.
Comment: @pjs36 nope, I am not :(
Answer: Some tips:

Instead of drawing on a torus, it's enough to draw on a topologically equivalent shape (e.g. a surface of a regular 3D object with a hole, like a mug where the hole is between the mug and its handle).

To help your imagination, just cut out a piece of paper and make (cut out) a hole in it, and draw your graph on it (and be aware you can go over the edge to the other side).

You could try to draw your graph on a plane with a bridge (like a regular real-life bridge): there are two places where the bridge starts and ends and you can go over the bridge without crossing the edges underneath it.

You could try to draw your graph on a simplified net of a torus, in particular
two disks with holes (remember the outer and inner edges of the disks will be glued together).

The best approach in my opinion would be to use just a normal rectangle with edges glued together (you glue together the horizontal edges and then also the vertical edges), it is a special case of simplified net of a torus. It means, that when you go over the edge, you come back from the other side (although mind your orientations, on the other side you "reappear" exactly at the same position you reached the first side).

All the above pictures were created with Inkscape. You can find sources here (download raw and open in Inkscape): 1, 2, 3, 4, 5.
I hope this helps $\ddot\smile$
Answer: Draw your graph in a unit square, then map it to a torus.
For example, in Maple:
with(plots):
tmap:= (x,y) -> [cos(x)*(2.5+cos(y)),sin(x)*(2.5+cos(y)), sin(y)]:
Torus:=plot3d(tmap(x,y),x=0..2*Pi,y=0..2*Pi,style=patchnogrid):
Pts:= [seq([cos(2*Pi*i/5),1/2+sin(2*Pi*i/5)],i=0..4)]:
display(Torus, spacecurve(
  [seq(seq(tmap(Pts[i][1]*(1-t)+Pts[j][1]*t,
    Pts[i][2]*(1-t)+Pts[j][2]*t),i=1..j-11),j=2..5)],
  t=0..1,colour=black),scaling=constrained,axes=none);

EDIT: Here's one  way to draw the complete graph on 5 vertices without crossing on the torus (it can't be done in the plane).
I'll do it step by step.  Note that my "tmap" function maps the plane to the torus with period $2\pi$ in the $x$ and $y$ directions.  First, here are the vertices.
Pts:= [[2*Pi/3,5*Pi/3],[2*Pi/2,5*Pi/3],[4*Pi/3,5*Pi/3],[2*Pi/2,4*Pi/2],[2*Pi/2,7*Pi/3]];
The edges joining all pairs except points $1$ and $3$ and points $2$ and $5$ go by straight lines in the plane.  The edge from $1$ to $3$ and the edge from $2$ to $5$ will "wrap around", horizontally and vertically respectively.  In the representation on the plane that means we go from $1$ to a version of $3$ displaced to the left by $2\pi$, and from $2$ to a version of $5$ displaced down by $2\pi$.
Pairs:= [seq(seq([Pts[i],
   piecewise(i=1 and j=3, Pts[j]-[2*Pi,0],
             i=2 and j=5, Pts[j]-[0,2*Pi], Pts[j])],
        i=1..j-1),j=2..5)];

And now we plot the curves together with a torus.  I'll revolve the viewpoint to show the whole thing.
display(Torus, spacecurve([seq(tmap(P[1][1]*(1-t)+P[2][1]*t,
 P[1][2]*(1-t)+P[2[2]*t),P=Pairs)],t=0..1,
colour=black),scaling=constrained,axes=none,
lightmodel=light3, viewpoint = circleleft);

Comment: Ah, but I specifically have to draw graphs without crossing! So, some of these graphs might not be able to be drawn on the plane without crossing, but can be drawn on a torus with crossing. Thus, is it a simple question of mapping 2D graphs onto a torus?

How to manually draw graphs on a torus?


Check if class has static method

Question: We can easily check if object has a method by using respondsToSelector:, but how we do it for static functions in class?
I would like to have something like this:
if ([cls classRespondsToSelector:@selector(staticMethodName)]) {
    ...
}

Answer: In Objective-C classes are objects too.
if ([[myClass class] respondsToSelector:@selector(classMethod)]) {

}

Also a small note, these are NOT 'static' methods. That means something specific which doesn't exist in Objective-C. They are class methods.
Comment: Snap! Deleted my identical answer. 28 seconds!
Comment: You can always get the class object from an instance, why would that matter?
Comment: why would the OP want to check for the existence of a class method given an instance of that class? to call a class method, they need the class object itself, so it would make more sense to be given the class object

Check if class has static method


request parameters from a jsp in java without using servlets

Question: I want to request parameters in a java file from a jsp without using servlets. Does anyone know how to do this? I believe its something to do with setting an attribute but I'm new to java so its all a learning game from me. I want to send the lotsize and bedrooms parameters to the java file. My jsp file is shown below and i need to know what to put in my java file in order to retrieve these parameters
Comment: jsp are also servlets
Comment: What do you mean by "without using servlets"?
Comment: @Hulk I want to just use java class to get the parameters. I do not want to use a servlet because I will be using sockets and they don't go well togeher
Comment: To use JSP you need a web server. And if you have webserver you can go with servlets or REST API (which is also kind of servlets).
Comment: Where and how is your `HouseWS` class running? If you need to call it from your JSP, then it will be running in the container anyway.
Comment: Why duplicating question from few minutes ago ? https://stackoverflow.com/questions/54111199/request-parameters-from-jsp-in-java-without-using-servlets/54111303#54111303
Comment: @user7294900 Because I still need an answer
Comment: See https://stackoverflow.com/help/how-to-ask
Answer: If you want this indeed, you should use HTML instead to JSP. For your question, I'm not sure, but I guess, because of the socket is based on the TCP protocol, so you can use a browser as a socket client, use GET or POST request to the socket server, you can enter the socket server's address in browser or submit an HTML form, the socket receives the request and response headers and HTML body to the browser.


How many libraries is too much before there is a performance issue?

Question: We are using Paragraphs module to allow for selecting of up to 15 different Paragraph Types. As part of this, each one requires its own CSS and JS since they are vastly different. We already have a common set of CSS and JS that can be shared (25% overall), but there is a large percentage (75%) that is unique to each Paragraph Type.
We were able to combine lots of the CSS and JS, which resulted in the creation of 10 libraries and 1 general library to help with the management of these types. We are concerned that if we add more Paragraph Types the number of libraries could increase to anywhere between 20-30 as newer Paragraph Types are needed.
How many libraries is too much for a custom subtheme before it cause a performance issue (if any)?
Since there is no extra preprocessing needed per Paragraph Type, we simply add them using the {{ attach_library('mytheme/name') }} in twig templates. The only hook that is used is the one to add the general library.
mytheme is a subtheme and is set as default and enabled
Examples:
paragraph--carousel.html.twig
{# this is the paragraph type specific library #}
{{ attach_library('mytheme/carousel') }}

 {{ content.field_title }}

 {{ content.field_sub_title }}

 {{ content.field_description }}

 {{ content.field_image }}

paragraph--jump-menu.html.twig
{# this is the paragraph type specific library #}
{{ attach_library('mytheme/jump-menu') }}

 {{ content.field_title }}

mytheme.module
function mytheme_preprocess_paragraph(&$variables) {
  // Add general library for paragraphs.
  $variables['#attached']['library'][] = 'mytheme/global';
}

Comment: Premature optimization is the root of all evil. ;)
Comment: I don't understand the question. You need as many as you need. My only suggestion would be to consolidate into as few CSS files as possible. If you have a solid global structure, then the remaining CSS would be small in filesize overall.
Comment: @Kevin I modified the question to be a little more clear. We were worried this may eventually lead to a `performance` issue if we had too many libraries that `Drupal` has to process.
Comment: Hum, this doesn't actually sound like a real problem in my opinion. I mean, do you experience any performance issues? Or have you tried like attaching 1 mio dummy libraries? What happened then? What's your server setup?
Comment: Well these libraries only get loaded if the template file loads, so nothing to worry about. I'm sure Drupal Core has a lots of libraries.
Comment: @NoSssweat right, so even a lot of `paragraph items` are added to the page, we should still be okay because not all of them will be loaded?
Comment: @leymannx We don't see any performance issue yet, but feared it would eventually lead to one if we didn't take any steps now.
Comment: And: Fear is a bad advisor. ;)
Answer: In Drupal, the best way to do your CSS is to keep it componentalized, and attach the CSS using #attached directly to the item to which it belongs. This way, the CSS is only ever attached when needed, and if a user overrides the render array further down the pipeline, removing the element to which the assets are attached, the assets will not be attached to the page, including unnecessary CSS.
Then you turn on CSS aggregation (or even better, use the ADVAGG module), and Drupal will handle the heavy lifting, aggregating the files as needed for the page.
So the answer to your question is that there aren't too many libraries. What is more important is effective management of the CSS/JS you are attaching.
Comment: the [Adding stylesheets (CSS) and JavaScript (JS) to a Drupal 8 theme](https://www.drupal.org/docs/8/theming/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-theme), states that the process to which to add `CSS` and `JS` is called a `library` as indicated under `The Process`, `Define a "library", which registers these CSS/JS files with your theme.`
Comment: Ahh I see. Sorry I've been working with composer too much recently. I'll edit my post, but the rest of what I said still stands.
Comment: using the `#attached` array to add the library assumes I print the default `{{ attributes }}`  in my `twig` template for the `paragraph` type. However if you look at my example, this is not the case here.
Comment: The organization is the key point.
Comment: I have two concerns with adding the library in a template. My first concern is that it won't aggregate correctly, though I suspect that my concern may be unfounded, seeing as the function to add the library exists in the first place. My second concern is more an architectural concern. Templates are for output of content, and should only have the output, and simple logic output from the template. Libraries are not part of the output of the template, and therefore I feel they should be added through hooks using the #attached property. Doing it this way covers my first concern as well.
Comment: do you have a way to replicate your first concern? The background behind the `attach_library` may be traced back to [issues #2398331](https://www.drupal.org/project/drupal/issues/2398331). When we have complex conditions to load a `library` we use the `hook_preprocess_hook()`, but in simple conditions we use `attach_library`. When setting the weight, it is important to keep in mind [CSS file organization (for Drupal 8)](https://www.drupal.org/docs/develop/standards/css/css-file-organization-for-drupal-8). This has allowed for proper aggregation.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/88115/discussion-between-jaypan-and-usernameabc).


Entering dummy variables and other covariates into the regression model

Question: I am controlling for education-level (two dummy variables) and another covariate in my regression model. I'm conducting a hierarchical regression analysis. I was confused about how I should be entering all the predictors. Do I enter the dummy variables and other covariate in the first block and then the main predictors in the next block? Or do I enter the dummy variables in the first block, the other covariate in the second block and the main predictors in the third block? Thank you!
Answer: It depends on what you want to find out, either choice could be correct.
If you are interested in the effects of a) The dummy variable  b) The covariate, controlling for the dummy variables and c) the main predictors, controlling for the dummy variable and covariate then you would do the regression in 3 stages.
On the other hand, if you are interested in the effects of a) The dummy variables and covariate and b) the main predictors, controlling for the dummy variable and covariate, then you could do it in 2 stages.
And if you are only interested in the main predictors, controlling for the dummy variable and covariate, you could do it in 2 stages as well.
Comment: And one stage is often the best - by pre-specifying the entire model and conditioning on everything in the right causal pathway.  Note that the original question implicitly assumed no heterogeneity within the 2 education levels, an assumption that is quite strange.


Evaluation of limit at infinity: $\lim_{x\to\infty} x^2 \sin(\ln(\cos(\frac{\pi}{x})^{1/2}))$

Question: $$\lim_{x\to\infty} x^2 \sin(\ln(\cos(\frac{\pi}{x})^{1/2}))$$
What I tried was writing $1/x=t$ and making the limit tend to zero and writing the cos term in the form of sin
Comment: Your question is missing a question.
Comment: There is a missing parenthesis in the expression.
Comment: @UmbertoP. How , in the question we have to just evaluate the limit of the given function at infinity
Comment: @user328114 Substitution is a good idea.  I've posted a solution using a different substitution from yours and found a way forward that does not rely on L'Hospital's Rule, series expansion/asymptotic analysis, or other differential calculus approach.  I hope that you find it as a useful alternative to the other approaches.  -Mark
Answer: Here, we present a way forward that does not rely on differential calculus.  Rather, we use only elementary inequalities and the squeeze theorem.  To that end, we proceed.

Inequalities 1:
Recall from basic geometry, that the sine function is bounded as
$$\bbox[5px,border:2px solid #C0A000]{\theta \cos(\theta)\le \sin(\theta)\le \theta} \tag 1$$
for $0\le \theta\le \pi/2$ (SEE THIS ANSWER).
Letting $\theta = \arccos(t)$ in $(1)$ reveals
$$\bbox[5px,border:2px solid #C0A000]{\sqrt{1-t^2}\le \arccos(t)\le \frac{\sqrt{1-t^2}}{t}} \tag 2$$
for $0<t\le 1$.
Inequalities 2:
In THIS ANSWER, I showed using only the limit definition of the exponential function and Bernoulli's Inequality the logarithm function satisfies the inequalities
$$\bbox[5px,border:2px solid #C0A000]{\frac{t-1}{t}\le \log(t)\le t-1} \tag 3$$
for $t>0$.

Let $L$ be defined as the limit
$$L=\lim_{x\to \infty}x^2\sin\left(\log\left(\cos^{1/2}(\pi/x)\right)\right)$$
Enforce the substitution $x=\frac{1}{\pi}\arccos(t)$.  Then, we can express the limit $L$ as
$$L=\lim_{t\to 1^-}\pi^2 \frac{\sin\left(\frac12\log\left(t\right)\right)}{\arccos^2(t)}$$
Applying inequalities $(1)-(3)$ we find that
$$\pi^2 \left(\frac{\frac12 \cos(\log(t))\,\frac{t-1}{t}}{\frac{1-t^2}{t^2}}\right)\le \pi^2 \frac{\sin\left(\frac12\log\left(t\right)\right)}{\arccos^2(t)}\le \pi^2 \left(\frac{\frac12 (t-1)}{(1-t^2)}\right)$$
or after simplifying
$$-\left(\frac{\pi^2}{2(1+t)}\right)t\,\cos(\log(t))\le \pi^2 \frac{\sin\left(\frac12\log\left(t\right)\right)}{\arccos^2(t)}\le -\left(\frac{\pi^2}{2(1+t)} \right) \tag 4$$
Applying the squeeze theorem to $(4)$ yields the coveted equality
$$\bbox[5px,border:2px solid #C0A000]{\lim_{x\to \infty}x^2\sin\left(\log\left(\cos^{1/2}(\pi/x)\right)\right)=-\frac{\pi^2}{4}}$$
Comment: Nice! It's good to have solutions that do not rely on Taylor series or other techniques... (although, I would argue that while it's good to know things can be done without them, *learning* these techniques is really important: as your answer shows, to compute such limits without them one has to be clever. With them, things are pretty much automatic and systematic.) [Also, small typo (?): the last word "inequality"... it's an equality)
Comment: @ClementC. Thank you!  Much appreciative of the comment.  And nice catch on the typo!!  +1  -Mark
Answer: Using Taylor series for $\cos u$, $\sqrt{1+u}$, $\ln(1+u)$, and $\sin u$ when $u\to 0$. When $x\to \infty$, $\frac{1}{x} \to 0$, so
$$\cos\frac{\pi}{x} = 1- \frac{\pi^2}{2x^2} + o\left(\frac{1}{x^2}\right)$$
and
$$\sqrt{ \cos(\frac{\pi}{x}) } = \sqrt{ 1- \frac{\pi^2}{2x^2} + o\left(\frac{1}{x^2}\right) } = 1- \frac{\pi^2}{4x^2} + o\left(\frac{1}{x^2}\right)$$
so that
$$\ln \sqrt{ \cos(\frac{\pi}{x}) } = \ln\left (1- \frac{\pi^2}{4x^2} + o\left(\frac{1}{x^2}\right) \right) = - \frac{\pi^2}{4x^2} + o\left(\frac{1}{x^2}\right)$$
and finally
$$
x^2 \sin \ln \sqrt{ \cos(\frac{\pi}{x}) } = x^2 \sin\!\left( - \frac{\pi^2}{4x^2} + o\!\left(\frac{1}{x^2}\right)\right)
= -x^2 \left(\frac{\pi^2}{4x^2} + o\!\left(\frac{1}{x^2}\right)\right) = - \frac{\pi^2}{4} + o(1)$$
Comment: How did you remove the square root
Comment: $\sqrt{1+u} = 1+\frac{u}{2} + o(u)$ when $u\to 0$. Or you could alternatively use the fact that $\ln \sqrt{} = \frac{1}{2} \ln$. But all the steps above are, by choice, done using Taylor expansions (known/classic ones, the ones mentioned at the beginning).
Comment: Can you please explain what did you do after writing 'finally'
Comment: Plugging the previous expansion into the sine, using that $\sin u=u+o(u)$... and multiplying the whole thing by the remaining $x^2$ of the original expression. If you're not familiar with Taylor expansions, don't worry -- there are other ways (see e.g. [Dr. MV's answer](http://math.stackexchange.com/a/1753716/75808)); but I suggest you practice and read on them, since knowing the (few) very frequent series and how to combine and compose Taylor expansions leads to a very powerful and systematic way to, among other things, compute limits like this one. @user328114
Answer: $\ln(\cos(\pi /x)^{1/2}) = 1/4\, \ln(\cos (\pi /x)^2) = 1/4\, \ln(1 - (\sin (\pi /x))^2)$. Also, $\lim_{z \to 0}\frac {\sin z} z = 1$ and $\lim_{u \to 0 }\frac {\ln(1-u)} u = -1$ (for example by l'Hopital). Now:
$$x^2 \sin(\ln(\cos(\pi/x)^{1/2})) = \\[12pt]  x^2\cdot \frac {\sin(\ln(\cos(\pi/x)^{1/2}))} {\ln(\cos(\pi/x)^{1/2}))} \cdot \frac {1/4 \,\ln(1 - (\sin(\pi/x)^2))} {(\sin(\pi /x))^2}\cdot \frac{(\sin(\pi/ x))^2}{(\pi/ x)^2}\cdot (\pi/x)^2
$$
Combine the first and last factor to get $\pi^2$, the second and fourth factor both have limit 1, and the middle factor has limit $-1/4$. So the overall answer is $-\pi^2/4$.
Many similar questions can be reduced to fraction algebra and common limits, without using Taylor series.
Comment: I have no idea why this received a down vote.  +1 ... I posted an answer in which I used only basic inequalities, obtainable without differential calculus, and then applied the squeeze theorem.  -Mark
Comment: perfect answer. +1 I was going to post a similar answer and I stopped when I saw this.
Comment: A quick remark: L'Hopital itself (in the "(for example by l'Hopital)") would also be unnecessary or circular: this is basically the very definition of the derivative of $f(u) = \sin u$ and $g(u)=\ln(1-u)$ at $0$.
Comment: @ClementC. - Totally agreed. Where I grew up using l'Hopital here would be considered a crime. Where I live now, NOT using l'Hopital would be considered a crime. My point with the solution I offered was the "decomposition" of the problem into smaller, almost trivial steps, more so than the actual evaluation of each limit.
Comment: Fair enough :) (and also, nice answer. )
Answer: Notice that
\begin{align*}
\ln\big(\cos(\pi/x)^{1/2}\big) &= \frac 1 2 \ln \cos \frac{\pi}{x} \\
&= \frac 1 2 \ln \left(1 - \frac 1 2\frac{\pi^2}{x^2} + O\left(\frac 1 {x^4}\right)\right) \\
&= -\frac 1 4 \frac{\pi^2}{x^2} + O \left( \frac 1 {x^4}\right)
\end{align*}
Now do you see how to show that the desired limit is $-\pi^2/4$?
Comment: @user328114 Are you asking about what is currently written (if so, do you know about Taylor expansions?), or what is missing and left to do?
Comment: @ForgotALot Indeed I did, thanks.
Comment: Can you please elaborate
Comment: How did you remove the logarithm
Comment: @ClementC. I know Taylor expansions but I couldn't understand how to remove the logarithm
Comment: @user328114 You have $\frac{\ln(1+u)}{u} \xrightarrow[u\to 0]{} 1$, or put differently (Taylor series expansion to order $u$) $\ln(1+u) = u + o(u)$. This is "removing the logarithm," taking $u=- \frac{\pi^2}{2x^2} + O(\frac{1}{x^4})$. (See also my answer, which is basically the same but 5 mn later.)
Comment: @ClementC. Thanks sir got it
Answer: Push $x^2$ to the bottom, then apply L'Hospital rule.
$\lim_{x\to \infty} \frac{\sin (\frac{\ln (\cos (\pi/x)}{2})}{x^{-2}}$ \ applying L'Hospital once and some simplification you will get, \
$-\pi^2/4 \lim_{x\to \infty} [\frac{\tan (\pi/x)}{\pi/x} \cos (\frac{\ln (\cos (\pi/x)}{2})]=-\pi^2/4$.
Comment: I have no idea why this received a down vote.  +1 ... I posted an answer in which I used only basic inequalities, obtainable without differential calculus, and then applied the squeeze theorem.  -Mark
Answer: Using $\pi/x=t$, you can compute
$$
\lim_{t\to0^+}\frac{\pi^2}{t^2}\sin\left(\frac{1}{2}\ln\cos t\right)
$$
Pulling the exponent out of the logarithm is possible because $\cos t$ is positive in a neighborhood of $0$.
Now recall that
$$
\cos t=1-\frac{t^2}{2}+o(t^2)
$$
so
$$
\ln(\cos t)=-\frac{t^2}{2}+o(t^2)
$$
and so your limit is
$$
\lim_{t\to0^+}-\frac{\pi^2}{4}\frac{t^2+o(t^2)}{t^2}
$$
Answer: By Taylor limited to the useful terms ($\cos(t)\approx1-\dfrac{t^2}2$, $\ln(1+t)\approx t$, $\sin(t)\approx t$),
$$\cos\left(\frac\pi x\right)\approx1-\frac{\pi^2}{2x^2},$$
$$\ln\left(\left(1-\frac{\pi^2}{2x^2}\right)^{1/2}\right)\approx-\frac12\frac{\pi^2}{2x^2},$$
$$-\sin\left(\frac{\pi^2}{4x^2}\right)\approx-\frac{\pi^2}{4x^2}.$$
Hence $$-\frac{\pi^2}4.$$

But how do we known how many terms to keep ?
The cosine gives even terms, with the constant coefficient $1$. The logarithm suppresses the coefficient $1$ and leaves the next term unchanged. The sine also leaves this term unchanged.


How can I use one image in two bundle (scss) files with webpack and file-loader? The last one of them returns undefined

Question: I have an issue with webpack (in combination with sass-loader and file-loader). I refer to an image in two different bundle (scss) files, where I point the background-image url to exactly the same path.
The bundle file that I import first is show properly, but the second files returns an 'undefined' url for the background-property.
Has anybody encountered this issue before?
I have tried various options for file-loader, but none worked so far.
The only option that does work for me is duplicating the image and refer to the duplicate (like referring to two different files).
This is far from best practise, because I load two images now, which are exactly the same.
My webpack.config.js looks like this:
const autoprefixer = require('autoprefixer');
var path = require('path');

module.exports = {
  entry: ['./src/app.scss', './src/app.js'],
  output: {
    filename: 'bundle.js',
  },
  module: {
    rules: [
      {
        test: /\.scss$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: 'bundle.css'
            },
          },
          {loader: 'extract-loader'},
          {loader: 'css-loader'},
          {loader: 'postcss-loader',
            options: {
              plugins: () => [autoprefixer()],
            },
          },
          {
            loader: 'sass-loader',
            options: {
              includePaths: ['./node_modules'],
            },
          }
        ],
      },
      {
        test: /\.js$/,
        loader: 'babel-loader',
        query: {
          presets: ['es2015'],
          plugins: ['transform-object-assign']
        },
      },
      {
        test: /\.(png|jpg|gif)$/,
        use: [
          {
            loader: 'file-loader',
            options: {
              name: '[name].[ext]',
              outputPath: 'Images'},
          }]
      }
    ],
  },
};

The two scss snippets (using the same url) look like this:
body.withLogo::after{
    content: '';
    display: block;
    position: fixed;
    z-index: -3;
    height: 100vh;
    width: 100%;
    background: url('../Images/logo-overlay.png');
    background-size: cover;
    background-repeat: no-repeat;
    opacity: 0.3;
    top: 0;
    right: -30%;
}

and
#logo-overlay{
    z-index: 10;
    position: absolute;
    top: 0;
    min-height: 100%;
    width: 100%;
    background: url('../Images/logo-overlay.png');
    opacity: 0.3;
    background-size: auto 100%;
    background-repeat: no-repeat;
}

Comment: The same issue!
Answer: I had this issue too.
The problem comes from extract-loader (in combination with css-loader) which you are also using.
You could go back a version prior v2.
E.g.: "css-loader": "^1.0.0"
Please compare:
https://github.com/webpack-contrib/css-loader/issues/864


How to tell if an SQL date is still in the future (not a query, I already have the desired row)

Question: I have a row from an SQL table, and one field is a DATE. (The value may be undefined, as DATE has no default value). How can I tell if this date, if it exists, is still in the future?
I searched for answers and found lots of ways to extract all records that pass this test, but I don't want to do that. I just want to check this one previously extracted record. Sorry for the newbie question!
$userQuery  = "SELECT * FROM  `passwords` WHERE `name` = '$name' LIMIT 1";
$userResult     = mysql_query($userQuery);
$userRow        = mysql_fetch_assoc($userResult);
$bestBeforeDate = $userRow['bestBeforeDate']; // field is in DATE format
// what now? How to find if the 'best Before Date' has passed?

Answer: You can do it in SQL as additional column
select case when (current_timestamp < date_column)
            then 1
            else 0
            end as is_in_future
from your_table

EDIT
You can do this in one query while reading other values from your table.
Example (not knowing the column names of your table)
select id,
       date_column,
       other_column,
       case when (current_timestamp < date_column)
            then 1
            else 0
       end as is_in_future
from your_table
where some_conditions

Example output:
id  date_column   other_column   is_in_future
 1  2012-01-01    abc            0
 2  2012-08-01    def            1
 ...

Comment: Does this select from the original table? There are many records that fulfil that query, but I just want to check the record I have already extracted.
Comment: @ChrisTolworthy: You can add that to your query where you extract the `bestBeforeDate` from your database.
Comment: Thanks. I need also to read other variables from that record, regardless of whether it passes the date test. It sounds like I need to just make two different queries? I.e. query the table once to get the record AND check its date, and query the table again to get the same record regardless of the date?


Use definition of limit to prove $\lim(\ln(\frac{ne+1}{n}))=1$

Question: Question is here
Been learning real analysis lately and I never came across limits of logarithms or sin functions most limits are rational polynomials in text books so I wanted to try something else on my own, How would I start the proof of this? I just need a hint, I mean I applied the definition and I just can't progress at all. Is it the squeeze theorem?
I need to use the definition of epsilon $|x_n-x|<\varepsilon$ to find this limit.
Comment: Please do not post links to images. Put the equestions into your question. [Here](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) is a MathJax tutorial.
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.
Comment: Prove that $\lim_{n \to \infty} \frac{ne + 1}{n} = e$
Comment: I will edit my question my deep apologies
Comment: Two hints: $log(a) - log(b) = log(a/b)$, and $log(e) = 1$.
Answer: Since $\ln$ is continuous
$\lim_{n \to \infty}(\ln(\frac{ne+1}{n}))=\ln(\lim_{n \to \infty}\frac{ne+1}{n})=\ln(\lim_{n \to \infty}(e+\frac1n))=\ln e=1$
you can also use $\epsilon-\delta$ definition since
$|\ln(\frac{ne+1}{n})-1|=|\ln(\frac{ne+1}{n})-\ln e|=|\ln(\frac{1+en}{en})|=|\ln(\frac{1}{ne}+1)|$
$e^x>x+1 \Rightarrow x>\ln(x+1)$
$x>\ln(x+1)\Rightarrow|\ln(\frac{1}{ne}+1)|<|\frac{1}{en}|$
According to Archemedian Property there exist a natural number $N$ such that
$Ne\epsilon>1$
$Ne\epsilon>1 \Rightarrow\frac1{Ne}<\epsilon$
$n>N \Rightarrow |\ln(\frac{ne+1}{n})-1|<|\frac1{en}|<\epsilon$
Comment: How do I write this using the epsilon definition of the limit?
Comment: @Jos I have added epsilon-delta proof.
Comment: Oh wow I completely forgot that lne=1 I'll try solving it on my own now and compare my solution to yours, thanks a lot!