Pearl, Causality: what are variables and functional relationship?

Question: In Pearl "Causality: Models...", he defines Causal Structure in (2.2.1) in terms of "variables" and "functional relationships".  This language conflicts with standard mathematical language where a functional is a map from either a vector space or a function to a field like $\mathbb{R}$.  I can guess that a random variable is a map from an event space to $\mathbb{R}$.
Can someone please explain what he means in terms of sets and functions?
Comment: The functional relationship is like a predictive model but for the counterfactual. Rubin's term for this was potential outcomes. Mathematically it's like a conditional mean model, except that the causal variables themselves are a network. Does that answer your question? What is the conflict that you perceive?
Comment: @AdamO  Could this be broken down into sets and functions?  That is the basic language of mathematics.
Comment: The RHS would be a probability model for the potential outcome--which is a set and a function. The LHS would be a possibly complex non-linear combination of covariates. Read about some models like GAMs for a sense of just how complex they can be. The idea behind Pearl's writing is (quoting him) "to exonerate [himself] from the actual specification and identification of such models".
Answer: You are conflating the adjective functional with the noun functional.  In this particular quote, functional relationship simply means an arbitrary function.
As you said, a functional (substantive) is a special name for a particular type of mapping, for instance, when the domain is a space of functions and the range is the real line. Functionals show up a lot in causal inference as well. Estimands, like $\sum_{z}P(y|x, z)P(z)$, for instance, are  functionals --- they assign a real number to any observed joint probability distribution $P(y, x, z)$ (a function).
You can see this use of functionals here which also shows up in Causality, p. 193.


Is R's glm function useless in a big data / machine learning setting?

Question: I am surprised that R's glm will "break" (not converge with default setting) for the following "toy" example (binary classification with ~50k data, ~10 features), but glmnet returns results in seconds.
Am I using glm incorrectly (for example, should I set max iteration, etc.), or is R's glm not good for big data setting? Does adding regularization make a problem easy to solve?
d=ggplot2::diamonds
d$price_c=d$price>2500
d=d[,!names(d) %in% c("price")]

lg_glm_fit=glm(price_c~.,data=d,family = binomial())

library(glmnet)
x=model.matrix(price_c~.,d)
y=d$price_c
lg_glmnet_fit=glmnet(x = x,y=y,family="binomial", alpha=0)

Warning messages:
1: glm.fit: algorithm did not converge
2: glm.fit: fitted probabilities numerically 0 or 1 occurred

EDIT:
Thanks for Matthew Drury and Jake Westfall's answer. I understand the perfect separation issue which is which is already addressed.  How to deal with perfect separation in logistic regression?
And in my original code, I do have the third line which drops the column that derives the label.
The reason I mention about "big data" is because in many "big data" / "machine learning" settings, people may not carefully test assumptions or know if data can be perfectly separated. But glm seems to be easily broken with "unfriendly" messages, and there is not a easy way to add the regularization to fix it.
Comment: Personally, I think those messages are very friendly. If you have a 50,000 x 10 data set with perfect separation, and don't realize it, I don't think you've learned enough about your data.
Comment: @smci: unfortunately, that's not really a viable option. For a variety of reasons, it's not so easy to pinpoint the "responsible variable" in this problem, nor is the idea of a responsible variable even well defined. They **can** tell you that your estimated probabilities are numerically equal to 0 or 1, which should indicate that there are potential problems with your model.
Comment: Regarding " Does adding regularization make a problem easy to solve":  yes, it can.  See http://statweb.stanford.edu/~tibs/sta305files/Rudyregularization.pdf: "Inclusion of $\lambda$ makes problem non-singular even if $Z^T Z$ is not invertible"
Comment: ...and your perfect separation / non-invertibility issue doesn't necessarily have anything to do with the size of your training data (i.e. whether you're dealing with "big data" or not)
Comment: `glm` doesn't fit regularized models because it's not designed to do so. Regularization will induce convexity and hence finite parameter estimates; however, it is not uniformly true that regularization is the correct answer in all contexts. Even if convex models are desired, they can be constructed from alternative, non-regularized models, so it's a matter of choosing the correct tool for the task at hand. Please see Scortchi's answer here: http://stats.stackexchange.com/questions/11109/how-to-deal-with-perfect-separation-in-logistic-regression
Comment: In general R won't work in big data setting since it loads all your data into RAM, so for terabytes of data you would need even more terabytes of RAM...
Comment: This is an FAQ: http://stats.stackexchange.com/search?q=fitted+probabilities+numerically+0+or+1+occurred. But it can't be said often enough that nothing's "breaking": predicted probabilities of zero or one aren't inherently absurd, & it's only the Wald standard errors that'll be way out.
Comment: @CliffAB: in order to be friendly, the messages would want to say *"fitted probabilities numerically 0 or 1 occurred **for variable varA [,varB,...]**"*
Answer: This has nothing to do with glm, you simply created a problem with an artificial perfect separation:
df <- data.frame(x = rnorm(100), y = rnorm(100))
df$y_c = df$y > 0

glm(y_c~., data=df, family=binomial())

Warning messages:
  1: glm.fit: algorithm did not converge
  2: glm.fit: fitted probabilities numerically 0 or 1 occurred

y is a perfect predictor of y_c.
Comment: While I think that perfect separation is still the basic issue, @hxd1011 excludes the price variable from d before fitting the model... see third line of code, though I am a bit unsure whether this works with operator precedence.
Comment: @Adrian Sure, that is why I said that the basic issue is correctly identified. However, note that this is not *artificial* perfect separation anymore.
Comment: @MatthewDrury y is taken out of the data (and the model) in the third line of the code.
Comment: @Erik even without that variable, it's possible to have perfect separation.  Even `lg_glm_fit=glm(price_c ~ carat, data=d, family = binomial())` starts to run into problems
Comment: @Adrian True, which is why I did not downvote. Still, my comment and yours right now would improve the answer if they got included.
Comment: Oh.  So it is.  Why is this getting so many upvotes?  I feel a fraud.
Comment: @Adrian my original question has that line... but both answers fail to see that.
Comment: I wouldn't get too hung up on Matthew's use of the word "artificial".  Perfect separation is the issue.  This isn't a problem with `glm` or with big data -- it's a problem with fitting an unregularized model when the solution is not unique (which can happen in big or small datasets).
Comment: I meant "artificial" in that the poster created it by leaving `y` in the regression, which should not be there.  Even if it did *not* fail so catastrophically, it would still be data leakage.
Comment: I must say @Erik, I unfortunately don't quite see your point on the price variable. But if you think it would be better to add some things to the answer, please feel free to edit.
Comment: @MatthewDrury I think you posted your answer before `d=d[,!names(d) %in% c("price")]` was added (i.e. the original question was edited), right?  In any case, there's still a problem of perfect separation after that edit, but it's no longer "artificial"
Answer: The unregularized model is suffering from complete separation because you are trying to predict the dichotomized variable price_c from the continuous variable price from which it is derived.
The regularized model avoids the problem of complete separation by imposing a penalty that keeps the coefficient for the price predictor from going off to $\infty$ or $-\infty$. So it manages to converge fine and work well.
You should remove the continuous price predictor from the design matrix in this toy example.
Edit: As @Erik points out, the continuous price predictor is already removed from the design matrix, which I somehow missed. So the complete separation arises from some other predictor or combination of predictors.
It's also worth adding that, of course, none of these issues have anything to do with the particular implementation of logistic regression in R's glm() function. It is simply about regularized vs. unregularized logistic regression.


Is $5^\pi$ an integer?

Question: I saw this very short math problem on Twitter:

Is $5^\pi$ an integer?

It isn't (it's 156.992545309…), but is there some technique to prove this without a calculator?
My first and only idea so far is to prove $156<5^\pi<157$ by taking logarithms, but it's annoyingly close to 157, and anyway I used a calculator to find those bounds.
Comment: Comparing $\pi$ to $3.1416$ should be enough to start a proof
Comment: A more general question is if $a$ is a positive integer $\geq 2$, then is $a^{\pi}$ not an integer? I suspect the answer is yes but I'm not sure the proof. Must have something to do with transcendental number theory.
Comment: Maybe! I'm not sure how to tackle computing either $5^{3.1416}$ or $\log_5(157)$ by hand.
Comment: Well, $5^r$ is rational for only countably many $r$ ["most" of which are trancendental I believe]. So the best I can think of is 1. "probably not", and 2. evaluate $5^{r'}$ where $r'$ is an approximation of $r$ to a certain precision: $|r-r'|\le \frac{1}{4r}$ say
Comment: *My mistake $|r-r'| \le 5^{-r-1}$. So $r$ evaluated out $m$ digits, for some $m$ that is $\theta(r)$
Comment: Okay, using the convergents of pi it should be possible. Specifically the convergent $\pi\approx 355/113$
Comment: If you know $\ln 10$ and $\ln 2$ then you know $\ln 5.$  Let $x=(\pi - 3)\ln 5.$ Then $5^{\pi}=125 \exp (x)=125(1+x+x^2/2!+x^3/3!+...),$ which converges quickly, as $x\approx 0.23.$
Comment: Lynn, were you OK with using calculators only to speed up the process? By what I read, it seemed that the problem of the calculator came from that you did not know how to make those calculations, so I assumed it was OK to use calculators to only speed the process up.
Answer: Proving the result by hand may take some effort, but the following process shows that it can be done. In what follows, one assumes the known estimates for $\pi$ and $e:$
$$\frac{201}{64}<\frac{333}{106}<\pi<\frac{355}{113}<\frac{3217}{1024}\qquad (1a)$$ and $$2.7182<\frac{1264}{465}<e<\frac{1457}{536}<2.7183.\qquad (1b)$$ By (1a), one has $$5^{\frac{201}{64}}<5^{\pi}<5^{\frac{3217}{1024}}.$$ To show that $5^{\pi}$ is not an integer, it suffices to show that $$156<5^{\frac{201}{64}}~{\rm and}~5^{\frac{3217}{1024}}<157.\qquad (2)$$ One completes the proof of (2) via the following Lemmas, where Lemma 1 is a direct consequence of the Alternating Series Test.
Lemma 1. Let $0<x\leq 1.$ Then $$\sum_{k=1}^{2n}(-1)^{k-1}\frac{x^k}{k}<\ln(1+x)=\sum_{k=1}^{\infty} (-1)^{k-1}\frac{x^k}{k}<\sum_{k=1}^{2n-1}(-1)^{k-1}\frac{x^k}k,\forall n\in{\mathbb N}.$$
Lemma 2. The inequalities $1.6094<\ln 5<1.60951$ hold.
Proof. One has $$\ln 5=\frac 3 2+\frac 12\ln\left(\frac{25}{e^3}\right).$$ It follows from (1b) that $$1.2446<\frac{25}{2.7183^3}<\frac{25}{e^3}<\frac{25}{2.7182^3}<1.2448.$$ Using Lemma 1 with $x=0.2448,$ one has $$\ln 5<\frac 3 2+\frac 1 2\left(x-\frac{x^2}2+\cdots+\frac{x^5}5\right)<1.60951.$$ Similarly with $x=0.2446,$ one has $$\ln 5>\frac 3 2+\frac 1 2\left(x-\frac{x^2}2+\cdots-\frac{x^6}6\right)>1.6094.$$ Hence the result follows.
Lemma 3. The inequality $156<5^{\frac{201}{64}}$ holds.
Proof. This is equivalent to showing that $$\ln(156)<\frac{201}{64}\ln 5$$
$$\Leftrightarrow \ln\frac{156}{125}+3\ln 5<\frac{201}{64}\ln 5$$
$$\Leftrightarrow \ln\left(1+\frac{31}{125}\right)<\frac 9{64}\ln 5.$$ Now by Lemma 1, one has $$\ln\left(1+\frac{31}{125}\right)<x-\frac{x^2}2+\frac{x^3}3\sim 0.22233,$$ where $x=\frac{31}{125}.$ By Lemma 2, one has $$0.22632\sim \frac 9{64}(1.6094)<\frac 9{64}\ln 5.$$ Hence the result follows.
Lemma 4. The inequality $5^{\frac{3217}{1024}}<157$ holds.
Proof. This is equivalent to $$\frac{3217}{1024}\ln 5<\ln(157)$$
$$\Leftrightarrow \frac{3217}{1024}\ln 5<3\ln 5+\ln\frac{157}{125}$$
$$\Leftrightarrow \frac{145}{1024}\ln 5<\ln\left(1+\frac{32}{125}\right).$$ Now by Lemma 2, one has $$\frac{145}{1024}\ln 5<\frac{145}{1024}(1.60951)\sim 0.22791.$$ By Lemma 1, one has $$\ln\left(1+\frac{32}{125}\right)>x-\frac{x^2}2+\cdots+\frac{x^5}5-\frac{x^6}6\sim 0.22792,$$ where $x=\frac{32}{125}.$ Hence the result follows.
Combining Lemma 3 and Lemma 4, the result is proven. QED
Answer: First note: I am not a mathematician, nor I have any mathematical training besides school, so my words should be taken with a grain of salt, a mountain of salt.
We can see by the approximation that (1) $3.1414 < \pi < 3.1416$ and, by asking Wolfram|Alpha, that (2) $5^{31416} < 157^{10'000}$ and (3) $5^{31414} > 156^{10'000}$. As you can calculate all of these by hand, I will assume it is acceptable to use those sources to just accelerate the process, as I have done. We now prepare the range-value of pi,
$3.1414 < \pi < 3.1416 $
$5^{3.1414} < 5^{\pi} < 5^{3.1416} $
$5^{3.1414} < 5^{\pi} \text{ and } 5^{\pi} < 5^{3.1416} $
(4) $5^{\pi} > 5^{3.1414} \text{ and } 5^{\pi} < 5^{3.1416} $
Now, we prepare inequalities (2) and (3),
$5^{31414} > 156^{10'000}$ and $5^{31416} < 157^{10'000}$
$5^{\frac{31414}{10'000}} > 156$ and $5^{\frac{31416}{10'000}} < 157$
(5) $5^{3.1414} > 156$ and $5^{3.1416} < 157$
We now use facts (4) and (5):
$5^\pi > 156$ and $5^\pi < 157 $
$156 < 5^\pi$ and $5^\pi < 157 $
$156 < 5^\pi < 157 $
As there is no integer between $156$ and $157$, then $5^\pi$ is not an integer.
Comment: +1. My edit was for a trivial typo... BTW, a 19th century mathematician,  who had performed as a "calculating prodigy" as a boy, noticed that $\exp (\pi\sqrt {163})$ is within  $10^{-12}$ of an integer. It's April 01, so I'm reminded that the late Martin Gardiner's monthly Mathematical Games article in Scientific American, once was an April Fools version which included "$\exp (\pi\sqrt {163})$ has been found to be an integer." The (very deep) Gelfond-Schneider theorem from the 1930's implies this number is transcendental.
Comment: $\exp (\pi\sqrt {163})\approx 10^{17}$  so if you want it to 12 or 13 decimal places then much of your work will have to be to at least 30 significant digits.
Comment: I feel like while this answer is technically correct, it is missing the spirit of the question. It is missing a couple of key bits: how do you notice that (1) 4 digits of  are enough and (2) the bounds 156 and 157, without access to a calculator? It's not about just "accelerating the process", but those seem like inputs for starting the proof (so that you "know where you're going in the right direction"), but I don't see how you derive those inputs from the question.
Comment: @DanielWainfleet, dammit! I though first of April was gonna be tomorrow. Thank you for the edit. That is the nerdiest, nicest joke I have ever seen. Pretty cool and weird number, though. I shall delete this comment after some time.
Comment: @typesanitizer, about point (1), I tried better and better upper and lower bounds until two of them satisfied inequalities (2) and (3). About point (2), similarly, you can take an upper or a lower bound of pi, then say $p < \pi < P$, then if, for example, the $P=3.16$,you verify if $5^{3.16} < X \equiv 5^{316} < X^{100}$, being X a guess, then, if it is the case, you approximated a value for $5^{\pi}$. You start with a big $X$ and go making it smaller and bettering the upper bound of pi. I'd start with like $X = 5^4 = 625$ or $X = 200$. It is boring, but it works, unless I've written it wrong.
Comment: >>> About the approximation of pi, there are a billion ways to approximate it. Though, it is important to get enough of an approximation so that you know $5^\pi$ is between two integers. Maybe even Archimede's one would work. In any way, I still suspect my question does not follow what the OP wanted, which is why I asked him.
Answer: This proof is intended be a more elementary than the existing proofs, relying more on "brute force". In exchange, it's more tedious, as you need to manually compute a bunch of square roots and multiplications.
As input, I assume that one knows that: $\pi$ has an expansion which is about 3.14159265...
We will try to prove that $5^\pi$ is not an integer
by multiplying $5^3 \times 5^\frac{1}{10} \times 5^\frac{4}{100} \times \ldots$
and using bounds.
Immediately, the problem one runs into is:
how do you compute powers like $5^\frac{4}{100}$ by hand? That's not usually covered in school math, but one does learn how to compute
square roots by hand.
So let's work with the expansion in base 2 instead of base 10.
$$
0.14159265... (\textrm{base 10}) \rightarrow 0.00100100001... (\textrm{base 2})
$$
We should first compute a bunch of values for $5^\frac{1}{2^N}$.
A good "checkpoint" value for $N$ that we will need (roughly) is such that
$5^\frac{1}{2^N} < 1.008$, because we will end up wanting
to bound:
$$
5^{3 + \frac{1}{8} + \ldots} < 5^\pi < 5^{3 + \frac{1}{8} + \ldots + \frac{1}{2^N}}
$$
and $5^3 \times 0.008 = 1$.
Tediously computing a bunch of square roots by hand:
$$
5^\frac{1}{2} = 2.23606\ldots \\
5^\frac{1}{4} = 1.49534\ldots \\
5^\frac{1}{8} = 1.22284\ldots \\
5^\frac{1}{16} = 1.10582\ldots \\
5^\frac{1}{32} = 1.05158\ldots \\
5^\frac{1}{64} = 1.02546\ldots \\
5^\frac{1}{128} = 1.01265\ldots \\
5^\frac{1}{256} = 1.00630\ldots
$$
Let's try the following:
$$
5^{3 + \frac{1}{8} + \frac{1}{64}} < 5^\pi < 5^{3 + \frac{1}{8} + \frac{1}{64} + \frac{1}{256}}
$$
For the left side:
$$
125 \times 1.2228 \times 1.0254 < 5^{3 + \frac{1}{8} + \frac{1}{64}} < 5^\pi \\
156.73\ldots < 5^\pi
$$
For the right side:
$$
5^\pi < 5^{3 + \frac{1}{8} + \frac{1}{64} + \frac{1}{256}} < 125 \times 1.2229 \times 1.0255 \times 1.0063 \\
5^\pi < 157.74\ldots
$$
Drat! We still have one integer $157$ within the bounds. But this was expected, because the interval size we're working with
is roughly 1, so when we got a lower bound of 156.73, the upper
bound should be around 157.73.
At this, point, the next 1 in the binary expansion of $\pi$ is 3 more digits
away, so the value must be relatively close to the lower bound. Let's try constraining the upper bound more.
$$
5^\frac{1}{512} = 1.0031\ldots \\
5^\frac{1}{1024} = 1.00157\ldots
$$
Retrying:
$$
5^\pi < 5^{3 + \frac{1}{8} + \frac{1}{64} + \frac{1}{1024}} < 125 \times 1.22285 \times 1.02547 \times 1.00158 \\
5^\pi < 156.99...
$$
So $156 < 5^\pi < 157$.

Is $5^\pi$ an integer?


Sent mails go to spam on Gmail but not on Yahoo

Question: Why is a message like the following going to Gmails SPAM folder?
I noticed that the same message goes correctly to Yahoo!s Inbox, but observing the header i see (in the received Yahoo message the following part: domainkeys=neutral (no sig);  from=mydomain.com; dkim=permerror (no key))
The following is the received gmail message.
Delivered-To: email@example.com
Received: by 10.58.136.2 with SMTP id pw2csp417955veb;
        Mon, 12 Nov 2012 08:56:07 -0800 (PST)
Received: by 10.180.8.134 with SMTP id r6mr11575409wia.19.1352739366833;
        Mon, 12 Nov 2012 08:56:06 -0800 (PST)
Return-Path: <firstname.lastname@example.com>
Received: from reco-server.mydomain.com ([126.96.36.199])
        by mx.google.com with ESMTP id i6si8062286wix.3.2012.11.12.08.56.06;
        Mon, 12 Nov 2012 08:56:06 -0800 (PST)
Received-SPF: pass (google.com: domain of email@example.com designates 188.8.131.52 as permitted sender) client-ip=18.104.22.168;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of email@example.com designates 18.104.22.168 as permitted sender) firstname.lastname@example.com
Received: by reco-server.mydomain.com (Postfix, from userid 33)
    id 35A9FC35AC; Mon, 12 Nov 2012 18:53:38 +0200 (EET)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mydomain.com;
    s=default.private; t=1352739218;
    bh=xB6AkthEgELFO1uSJiG0uEqE+qEnyoQ/RQnK9N0kGcY=;
    h=To:Subject:Date:From:Message-ID:MIME-Version:
     Content-Transfer-Encoding:Content-Type;
    b=HbafDiTnuJMT837tf/PWk0LZPMBStf17PJYM94StSg5odjEIPzuzf5hPxJc2DfQMV
     +e9MdhgDoKJ09YJJV0nvH07Y+20XB6uPOxk/sJry3ItYCFkqzbFFnK7YkAHRwIuSiy
     gueYz6tpfZekxpWTWysic465o4mRLxTG28EdnF2U=
To: email@example.com
Subject: =?UTF-8?B?zpXOu867zrfOvc65zrrOrA==?=
X-PHP-Originating-Script: 0:class.phpmailer.php
Date: Mon, 12 Nov 2012 18:53:38 +0200
From: firstname.lastname@example.com
Message-ID: <8002c9e1cccf93e64ea3b98588ae7971@localhost>
X-Priority: 3
X-Mailer: PHPMailer [version 1.73]
X-Mailer: phplist v2.10.19
X-MessageID: 13
X-ListMember: email@example.com
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"

MESSAGE TEXT

EDIT
Results from autmated email@example.com
This message is an automatic response from isNOTspam's authentication verifier service.  The service allows email senders to perform a simple check of various sender authentication mechanisms.  It is provided free of charge, in the hope that it is useful to the email community.  While it is not officially supported, we  welcome any feedback you may have at <firstname.lastname@example.com>.

Thank you for using isNOTspam.

The isNOTspam team

==========================================================
Summary of Results
==========================================================

SPF Check : pass
Sender-ID Check : neutral
DomainKeys Check : neutral
DKIM Check : invalid
SpamAssassin Check : ham (non-spam)
==========================================================
Details:
==========================================================

HELO hostname: [188.8.131.52]
Source IP: 126.96.36.199
mail-from: firstname.lastname@example.com
---------------------------------------------------------
SPF check details:
----------------------------------------------------------

Result: pass
ID(s) verified: firstname.lastname@example.com DNS record(s):
domain.com.     86400   IN  TXT "v=spf1 ip4:184.108.40.206 a mx -all" ""

----------------------------------------------------------
Sender-ID check details:
----------------------------------------------------------

Result: neutral
ID(s) verified: email@example.com DNS record(s):
domain.com.     86400   IN  TXT "v=spf1 ip4:22.214.171.124 a mx -all" ""

----------------------------------------------------------
DomainKeys check details:
----------------------------------------------------------

Result: neutral (message not signed)
ID(s) verified: firstname.lastname@example.com Selector= domain= DomainKeys DNS Record=

----------------------------------------------------------
DKIM check details:
----------------------------------------------------------

Result: invalid
ID(s) verified: firstname.lastname@example.com Selector= domain= DomainKeys DNS Record=._domainkey.

----------------------------------------------------------
SpamAssassin check details:
----------------------------------------------------------
SpamAssassin v3.2.5 (2008-06-10)

Result: ham (non-spam) (05.1points, 10.0 required)

    pts rule name              description
    ---- ---------------------- -------------------------------

    *  1.8 SUBJ_ALL_CAPS Subject is all capitals
    * -0.0 SPF_PASS SPF: sender matches SPF record
    *  3.2 RCVD_ILLEGAL_IP Received: contains illegal IP address
    *  0.0 DKIM_SIGNED Domain Keys Identified Mail: message has a signature
    *  0.1 RDNS_NONE Delivered to trusted network by a host with no rDNS

To learn more about the terms used in the SpamAssassin report, please search
here: http://wiki.apache.org/spamassassin/

==========================================================
Explanation of the possible results (adapted from
draft-kucherawy-sender-auth-header-04.txt):
==========================================================

"pass"
        the message passed the authentication test.

"fail"
        the message failed the authentication test.

"softfail"
        the message failed the authentication test, and the authentication
        method has either an explicit or implicit policy which doesn't require
        successful authentication of all messages from that domain.

"neutral"
        the authentication method completed without errors, but was unable
        to reach either a positive or a negative result about the message.

"temperror"
        a temporary (recoverable) error occurred attempting to authenticate
        the sender; either the process couldn't be completed locally, or
        there was a temporary failure retrieving data required for the
        authentication.  A later retry may produce a more final result.

"permerror"
        a permanent (unrecoverable) error occurred attempting to
        authenticate the sender; either the process couldn't be completed
        locally, or there was a permanent failure retrieving data required
        for the authentication.

==========================================================
Original Email
==========================================================

From firstname.lastname@example.com Mon Nov 12 12:38:18 2012
Return-path: <firstname.lastname@example.com>
Envelope-to: firstname.lastname@example.com
Delivery-date: Mon, 12 Nov 2012 12:38:18 -0600
Received: from [220.127.116.11] (helo=reco-server.domain.com)
    by s15387396.onlinehome-server.com with esmtp (Exim 4.71)
    (envelope-from <firstname.lastname@example.com>)
    id 1TXytm-0006Ks-F4
    for firstname.lastname@example.com; Mon, 12 Nov 2012 12:38:18 -0600
Received: by reco-server.domain.com (Postfix, from userid 33)
    id 6BF85C35AD; Mon, 12 Nov 2012 20:35:48 +0200 (EET)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=domain.com;
    s=default.private; t=1352745348;
    bh=ct/pgfefCHs8+LIeEBcMrJ5P+x8P9h/ezEkaBkHvCN4=;
    h=To:Subject:Date:From:Message-ID:MIME-Version:
     Content-Transfer-Encoding:Content-Type;
    b=KqwYkomSJ7DFGIYp9fwajqCAPr8bab5Blp8FlbN9MGaaNIAt4pBBlnlLOeKeqQ1Dk
     B9GzgDaYmzvCeufDu6vHsDX4l2RjzvMvEOu1zYedOni71Pcm8E1R30ACmRE21GMTh1
     ydht7n4dCV1ixaRch+yA+usEExUbrrMG5kvSoZyE=
To: firstname.lastname@example.com
Subject: TEST FOR SPAM
X-PHP-Originating-Script: 0:class.phpmailer.php
Date: Mon, 12 Nov 2012 20:35:48 +0200
From: firstname.lastname@example.com
Message-ID: <0a2dfc42198ab976374beeb033478102@localhost>
X-Priority: 3
X-Mailer: PHPMailer [version 1.73]
X-Mailer: phplist v2.10.19
X-MessageID: 14
X-ListMember: email@example.com
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-DKIM-Status: invalid (pubkey_unavailable)

This is a test

--
powered by phpList, www.phplist.com --
Comment: First check if everything is fine with your mail server by sending an email to firstname.lastname@example.com. Paste the result logs here then we can help you further.
Answer: Because gmail has a different (and generally regarded as "better") spam filter than Yahoo! does.  Different spam filters behave differently.
Gmail also has guidelines and a help page for bulk senders, which will probably be much more helpful to you than us, so I recommend you check it out.
Answer: The problem was hidden very deep in the configuration files of dkim-milter.
This "mean" config problem caused the signer to not function(properly) resulting in a mail which is not DKIM-signed.
Details:
i 'm using Debian, postfix & dkim-milter. The problem i had was the following line in /etc/dkim-keys.conf
*@domain.com:domain.com:/etc/dkim/keys/domain.com/default.private

The last part ( .private ) MUST BE REMOVED!!
Comment: That can't be your only problem. Massive numbers of unsigned emails are accepted by Gmail every hour. If signing the message "solves" your issue then I suggest your messages are still so close to being flagged as spam that you should look at the many other issues involved because just a small change of wording might be enough to tip them over the edge again.
Comment: I have the same issue... If our solution works, I will award you 50 rep bounty! Coz u will f... deserve it! Lemme check
Comment: Nope... Didn't work!


Uninstall php and nginx or fix setup

Question: First off, I'm a huge linux noob - sorry... I'm trying to setup nginx with php-fpm on debian and I'm pretty sure that I've completely screwed it up.  nginx seems to be running fine because I can it it from a web browser and it load the stock "Welcome to nginx!" page.  I'm not so sure about php-fpm though.  When I try something like
# restart php-fpm

I get:
bash: restart: command not found

First off php-fpm some how got installed as php5-fpm when I do root@server:/etc/init.d# ls, which seems to contradict every tutorial and help doc I've read (supposed to be 'php-fpm').
I can restart it with this:
service php5-fpm restart

And just enter the package name 'php5-fpm' I get this:
root@server:~# php5-fpm
[17-Nov-2012 23:15:36] NOTICE: PHP message: PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php5/20100525/suhosin.so' - /usr/lib/php5/20100525/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0
[17-Nov-2012 23:15:36] ERROR: An another FPM instance seems to already listen on /var/run/php5-fpm.sock
[17-Nov-2012 23:15:36] ERROR: FPM initialization failed

The root for nginx is /usr/share/nginx/html, when I try to navigate to a .php file in there with my web browser, it tries to download the file instead of interpret it.  I would like this folder to be in my user's home directory ie: /home/administrator/www or /home/nginx/www.  I know in order to do this I need to modify nginx.conf, but I find that configuration file difficult to understand.  I suppose the fact that my .php scripts aren't being handled is my bigger problem anyways.
When I try to see what running on port 9000 (php-fpm default port) with lsof -i :9000 it returns nothing - I guess indicating that it isn't listening.  then I head over to vim /etc/php5/fpm/php-fpm.conf and there is no where to designate a port number.

So should I just uninstall everything and start from scratch? If so,
how do I clean it all up? Any suggestions for a tutorial once I'm
ready to try again? Should I attempt to troubleshoot this mess?
If so where should I start?

Sorry guys, I'm feeling pretty stupid and lost right now.  I'm not sure what my next steps are in trying to resolve this issue are.  I realize that this is a horrible question for this type of Q&A site, but I'd really appreciate any guidance.
Comment: Perhaps, if you don't know Linux, try it with an http server that has a less-steep learning curve?
Answer: First of all, man saves your bacon. If you have tried man lsof, you'd eliminate one question.
Next, be attentive:

another FPM instance seems to already listen on /var/run/php5-fpm.sock

silently reminds you that it makes no sense to

try to see what running on port 9000

So should I just uninstall everything and start from scratch?
No, if you haven't encountered any installation errors.
how do I clean it all up?
You haven't done anything yet to clean up as far as I can see. Configure PHP-FPM && nginx.
Should I attempt to troubleshoot this mess?
That's a key to a solution! Use less /var/log/__yourlogfile__ every time you are in doubt.
If so where should I start?

man command, mentioned before. Use it like man service; man php-fpm.
lsof -U /var/run/php5-fpm.sock
wiki.nginx.org/Configuration
Use search better: Getting rid of "Welcome to nginx!" fits your question
Read the Debian Reference

Uninstall php and nginx or fix setup


Minimal generating set of a monomial ideal of $k[x_1,\dots,x_n]$

Question: Let $k$ be a field and consider the polynomial algebra $k[x_1,\dots,x_n]$. Suppose $I$ is a monomial ideal (generated by monomials). Since $k[x_1,\dots,x_n]$ is Noetherian we can choose a minimal generating set $\{f_1,\dots,f_k\}$ of $I$ consisting of monomials. Suppose $f_1=gh$ with $g,h$ coprime and $\deg (g), \deg (h)\geq 1$. Then is it true that $g,h\notin I$?
If the statement [If $g\in I$ then $g\in (f_2,\dots,f_k)$] is true, then I can conclude using minimality, but I'm not sure that this statement holds. Any hints?
Comment: Have you looked into Groebner bases?
Answer: One can show that if $f_1, \ldots, f_n, g$ are monomials, then $g \in \langle f_1, \ldots, f_n \rangle$ if and only if some $f_k \mid g$.
This is theorem $1.1.8$ of Moore, Rogers, and Sather-Wagstaff's Monomial Ideals and their Decompositions, available here.
Now if $f_1 = gh$, then $g$ and $h$ must be monomials (this is intuitively clear, but it's also proven in Chapter $1$ of the same book). So if $g$ were in $\langle f_1, \ldots, f_n \rangle$, we would need some $f_k \mid g$. But then we would have $f_k \mid f_1$, so $f_1$ would be redundant, contradicting minimality.

I hope this helps ^_^


Página HTML com margens ruins

Question: Eu estou tentando colocar um slideshow na minha página, mas por alguma razão, as imagens têm algum tipo de margem esquerda que não abrange a totalidade da página.
Aqui está a imagem:
Aqui está o HTML:
<xmp><!DOCTYPE html>

        <meta charset="UTF-8">
        <meta http-equiv="content-language" content="en">
        <meta name="author" content="João Paixão">
        <meta name="keywords" content="">
        <meta name="description" content="InfoCE, Information of Criptocurrency & Entertainment. You'll find the information you're looking for here">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>InfoCE</title>
        <link rel="stylesheet" href="corpo.css" type="text/css">
        <link rel="stylesheet" href="cabecalho.css" type="text/css">
        <link rel="icon" href="images" type="image/icon">

Ínicio

                    Criptomoedas

                            O que são criptomoedas?
                            Mineração
                            Faucets
                            Carteiras

                   Entretenimento

                           Filmes
                           Séries
                           Animes

Contacte-nos

                   <select onchange="location = this.value;">
                       <option value="indexpt.htm">Português</option>
                        <option value="indexen.htm">English</option>
                   </select>

    <button class="w3-btn" onclick="plusDivs(-1)">❮ Prev</button>
    <button class="w3-btn" onclick="plusDivs(1)">Next ❯</button>

  <button class="w3-btn demo" onclick="currentDiv(1)">1</button>
  <button class="w3-btn demo" onclick="currentDiv(2)">2</button>
  <button class="w3-btn demo" onclick="currentDiv(3)">3</button>

           InfoCE.com © 2017 Todos os direitos reservados | Política de Privacidade

</xmp>

E aqui vai o CSS:
body{
    overflow-y: scroll;
    font-family: sans-serif;
    margin: 0 auto;
}
section{
    margin: 0px auto;
    background-color: red;
    width: auto;
    height: auto;
    padding: 20px 20px 0px 30px;
    margin-top: -20px;
}
section a:link{
    color: darkgreen;
    background-color:transparent;
    text-decoration:none;
}
section a:visited{
    color: darkgreen;
    background-color:transparent;
    text-decoration:none;
}
section a:hover{
    color: blue;
    background-color:transparent;
    text-decoration:none;
}
section a:active{
    color: darkorchid;
    background-color:transparent;
    text-decoration:none;
}
.cts{
    margin-left: 760px;
}
select{
    margin-left: 4px;
    margin-top: -15px;
    width: 20px;
}

ul {
    list-style-type: none;
    padding: 0;
    overflow: hidden;
    background-color: darkorange;
    width: auto;
    margin-top: 0px;
    padding-bottom: -10px;
}
#top li{
    list-style-type: none;
    text-align: center;
}
li {
    float: left;
    padding-bottom: -2px;

}
li.home {
    margin-left: 10px;
}
li a, .dropbtn {
    display: inline-block;
    color: white;
    text-align: center;
    padding: 14px 16px;
    text-decoration: none;
}

li a:hover, .dropdown:hover .dropbtn {
    background-color: dodgerblue;
}

li.dropdown {
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #f9f9f9;
    min-width: 160px;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 1;
}

.dropdown-content a {
    color: black;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    text-align: left;
}

.dropdown-content a:hover {background-color: dodgerblue;
color: white;}

.dropdown:hover .dropdown-content {
    display: block;
}

@media screen and (max-width: 1020px){
    ul.topnav li.right,
    ul.topnav li {float: none;}
}
header{
    margin: 0 auto;
}
#top{
    margin-top: -71px;
    margin-bottom: 0px;
    text-align: left;
    width: 200px;
    height: 30px;
    float: right;
}
#top select{
    text-align: right;
    float: right;
    margin-top: 20px;
}
#logosite {
    position: relative;
    width: 100px;
    margin-top: -71px;
    height: 30px;
    margin-left: 750px;
}
header #logosite{
    float: left;
}
afinal nao kkk
footer{
    text-align: center;
    width: 100%;
    float: left;
    padding-bottom: 5px;
    margin: 0 auto;
    background-color: aqua;
}
footer a:link{
    color: darkgreen;
    background-color:transparent;
    text-decoration:none;
}
footer a:visited{
    color: darkgreen;
    background-color:transparent;
    text-decoration:none;
}
footer a:hover{
    color: blue;
    background-color:transparent;
    text-decoration:none;
}
footer a:active{
    color: darkorchid;
    background-color:transparent;
    text-decoration:none;
}

Comment: Hey dude, this is stackoverflow in portuguese, post your question here http://stackoverflow.com
Comment: O curioso é que a página dele está em português :)
Comment: O que seria o `afinal nao kkk` perdido no meio do CSS?
Answer: Você pode botar na classe mySlides:
.mySlides {
    margin: auto;
}

Isto centralizaria as imagens, já que elas tem display: block;
Agora, se quiser centralizar todo o conteúdo, eu recomendaria estas mudanças:
.displayimg {
    text-align: center;
}
.w3-content {
    display: inline-block;
}

Isso tudo seria uma sugestão bem simples sem maiores conhecimentos da sua página que me parece estar em Wordpress. Mas fica lançada a ideia.

Página HTML com margens ruins


O que é cálculo Lambda?

Question: Ouvi sobre esse assunto uma vez, mas não compreendo a relação dele com programação. Onde eu poderia aplicar esse conhecimento em desenvolvimento?
Comment: É a base matemática da [programação funcional](https://pt.stackoverflow.com/tags/programa%c3%a7%c3%a3o-funcional/info).
Answer: Cálculo λ
O cálculo λ se constitui de uma única regra de transformação, substituição de variável e um único esquema de definição de função. Ele foi introduzido na década de 1930 por Alonzo Church como uma maneira de formalizar o conceito de computabilidade efetiva. Também é considerado como menor linguagem de programação universal, no sentido de que qualquer função computável pode ser expressa e avaliada usando o formalismo desse cálculo.
Se você for um pouco mais a fundo, verá os primeiros resultados da teoria da computação foram desenvolvidos utilizando os formalismos da máquina de Turing e do cálculo λ. O conceito central no cálculo λ é a expressão, onde um identificador, ou seja, um "nome" ou "variável" são identificados por letras a, b, c, …. Uma expressão é definida como  <expression> := <name> | <function> | <application> ou <function> := λ <name>.<expression>, por exemplo.
Exemplos
(+ 4 5)
(+ 4 5) = 9

As aplicações de funções no lambda cálculo são escritas no formato prefixo.
λx.(x + 1)

A expressão pode ser lida assim: "função de x a qual (.) adiciona x a 1". Algumas vezes costuma-se usar operadores sempre prefixados, e neste caso se escreveria (+ x 1).
(λx. + x 1)

"função de x que (.) incrementa x de 1"
O λ determina que existe uma função, e é imediatamente seguido por uma variável, denominada parâmetro formal da função
Onde eu poderia aplicar esse conhecimento em desenvolvimento?
Acho que o maior valor agregado seria o conhecimento. Não sei afirmar onde você poderia aplicar Cálculo λ, mas muita coisa que existe hoje foi feita a partir da formalização desse cálculo. Por exemplo, John McCarthy estendeu o cálculo λ para construir a primeira linguagem da família Lisp.
Referências:

https://www.di.ubi.pt/~desousa/2013-2014/CF/apresentacao-lambda.pdf
https://www.inf.fu-berlin.de/lehre/WS03/alpi/lambda.pdf
http://www.inf.ufsc.br/~j.barreto/PF/CalLambda.htm

O que é cálculo Lambda?


Problem in jQuery sending values with $.post

Question: EDITED: After two hours trying to solve my problem I was obfuscated, so I came to StackOverflow, I read related questions that did´nt solve my problem, and finally I asked help. I simplified my code and posted this question. Testing the code you gave me I could see where I was failing. That's embarrassing: just before calling $.post I was changing the content of the form div to show an ajax loader gif, so when $.post was called the inputs had been deleted.
Hello. I´m testing jQuery AJAX functions, and I can´t send data by $.post.
This is the process:

form.php: a html form and a jquery script that send values by $.post and alerts the result
process.php: a php script that receives the values, work with them and returns something.

FORM
<form action="#" method="post">
Your name
<input type="text" name="name" id="name" />
Your email
<input type="text" name="email" id="email" />
<input type="button" value="send" id="btnSend" />
</form>

JQUERY
    function sendAjaxPost(){

        $.post('process.php',{
                name: $('#name').val(),
         email: $('#email').val()
         },
         function(data){
           alert(data);
         });
        }

$('#btnSend').click(function(){
   sendAjaxPost();
}

PROCESS.PHP
foreach($_POST as $key => $value)
{
 echo $key . ' => ' . $value . '
';
}

I can´t send $('#name').val(), but if I send a string everything works fine. I have alert $('#name').val() inside the jQuery function and it´s possible to read it. I have followed the sintaxis shown in $.post.
Could someone give me a light? Thanks in advance
Comment: what do you mean when you say, " but if I send a string everything works fine." ??
Comment: Are you sure that input field is the only one on the DOM with id="name"?
Comment: @tsegay if I send in $.post-> name: 'My name', email: 'My email' instead of name: $('#name').val()
Comment: @lan Sure. I have tried $('input[name="name"]').val() too with the same result.
Comment: Updated my Answer and see if that can help. On my system with same configuration works fine.
Answer: If you can read the input fields on the function, you can try this,
function sendAjaxPost(){
         name=$('#name').val();
         email=$('#email').val();
         alert(name);
         alert(email);
        //If this two alerts the name and email, try with $.get();
        $.post('process.php',{
                name: name,
                email:email
         },
         function(data){
           alert(data);
         });
        }

Comment: Aren´t you mixing JS and PHP sintax?. I have tried what you suggest with: var name = $('#name').val(); But it didn´t work
Comment: You are right. Your code work fine for me too. I found my error. I´m going to update my question. Thanks for your help!


How to do preprocessing for zero inflated variable in multiple regression?

Question: I am trying to build a multiple regression model, and many of my variables looks like this (histogram for time spent in the system).

The reason I had such data is because zero is actually represents another business case: customer created the account but never used it.
How should I user this types of the variables in a regression model? I have some ideas to do the preprocessing, are they valid? what else can we do?

Idea 1, replace zero with median value of non-zero ones.
Idea 2, create another indicator column on zero values, then replace zero with median value of non-zero ones.
Comment: Why are you imputing zero values with medians when there is clearly non-ignorable missingness? Is the goal to estimate the time they *would* have been in the system had they remained there? If you can replace the zero with a sensible censoring time, like last-login or record modification time, you might estimate a good probability model.
Comment: @AdamO thanks for the comment. I understand the problem of replace them with median but not the second point. San you tell me more about "replace the zero with a sensible censoring time, like last-login or record modification time"?
Comment: Idea 2 is correct. Idea 1 is not. On a somewhat similar note, in case you missed it the thread "[Time spent in an activity as an independent variable](https://stats.stackexchange.com/questions/56306)" is extremely related to your question. (To the point I would assume they could be potentially merged.)
Answer: To take these zeroes and convert them to the median would create a false sense of certainty that would bias your results.  I would assume that if these customers had nonzero values, the values would take on a range.  That's one reason why multiple imputation has become so popular:  it preserves some uncertainty, variability, in the imputed values while using all available information to assign them as plausibly as possible.  So rather than proceeding as you suggest, I would use multiple imputation as one approach.
A second approach would be censored regression, as described in the growing number of threads that you can find via a Google search or a search on this site.  I found this page helpful.  (Though it may be less helpful if all your zero-inflated variables are predictors.)
In either case I like your idea of including a binary column to indicate zero/nonzero.
EDIT:  for some good introductions to multiple imputation, see the articles by Melissa Azur et al. (2011); John W. Graham (2009); and Jeffrey C. Wayman (2003).
Comment: +1. The link you provided is really helpful. I searched for zero inflated topics but did not see that page!
Comment: Can you also give me some resources for multiple imputation?
Comment: Can you edit your post to include links to the papers, or at least also the journals in which they appeared? Thank you!


Generating GCP compatible Cloudflare SSL certificate


Spreadsheet_Excel_Writer making Rows width longer

Question: How can I make rows a bit longer? If I output the excel everything prints fine, but if the title is a bit long the title is not readable.
How can I fix that?
Answer: It's probably the column width that needs fixing then.
Excel hides any content in a cell that runs wider than the column width it is in. It's just like CSS overflow property. Usually that is indicated by a small icon on the right hand side of the cell. Double clicking the right edge of the column will autoexpand the column. To have it visible right from the start, you'd have to increase the column width.
Example taken from this newsgroup entry
// Creating a workbook
$workbook = new Spreadsheet_Excel_Writer();

//Setting column width
$worksheets1->setColumn(0,0,10.00);

Quoting the same entry (fixed spelling):

This example breakdown is as
  follows... setColumn(0,0,10.00)
  == the first column to be affected by the width setColumn(0,0,10.00) ==
  the last column to be affected by the
  width setColumn(0,0,10.00) == the
  width as a float
The setColumn() needs to be set before
  any data is being written to the
  spreadsheet. If you only want one
  column to be affected by
  setColumn() then you set the first and
  last column params to the same column
  number. If you want to affect more
  than one column you can set the last
  column to the desired column number,
  just remember the column numbering
  begins with a 0.

In case that's not working with the PEAR package, try PHPExcel
Comment: what about something like this

addFormat();
$style->setSize(20);
$style->setBold();
$style->setHAlign('left');
$style->setVAlign('vcenter');

// function setMerge($first_row, $first_col, $last_row, $last_col)
show/hide quoted text
$style->setMerge(0, 0, 0, 9);

show/hide quoted text
$sheet->write(0, 0, 'Hello World!', $style);
?>
Comment: i just get an error
  Call to a member function getXfIndex() on a non-object in /home/stre/sqw/inc/pear/Spreadsheet/Excel/Writer/Worksheet.php on line 1234
Comment: Can't help you with any errors the PEAR package gives. Never worked with it. I'm just pretty sure that the issue is the column width, because I know Excel.


Imploded PHP integer array for Mysql NOT IN clause

Question: I've been trying to use a PHP integer array for a MySQL query that uses the NOT IN clause, but despite no errors it seems to always return the results I want filtered out.
Example:
$IDS = $_SESSION['Posts'];
$Select = 'SELECT *
             FROM status
            WHERE (W_ID = '.$ID.')
              AND (ID NOT IN ("'.implode(',', $IDS).'"))
         ORDER BY ID DESC
            LIMIT '.$Begin.', '.$Number.'';

$Select = mysql_query($Select) OR DIE(mysql_error());

I'm pretty sure this is a logical syntax error.
What I've tested for:
I've made sure that $IDS is treated as an array. Also I have tested to see whether there are values stored within the array. I have also not quoted the integer array, but then I got a mysql syntax error for not having them.
Answer: The problem is the two " in the beginning and the end of the IN block. They cause the entire implode array to become a comma-separated string.
Comment: Removing those still gives me an error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')) ORDER BY ID DESC LIMIT 0, 20' at line 1
Comment: SELECT * FROM status WHERE (W_ID=3) AND (ID NOT IN (3, 4, 5, 6)) ORDER BY ID DESC LIMIT 0, 20 -- this SQL is perfect valid. Post yours please
Comment: Thanks I figured out that the initial value was blank for the first round  of the loop, your solution worked.
Comment: On input values also check mario's answer. As he points out it is not always safe to rely on the input data.
Answer: Your actual query will look like this:
ID NOT IN ("1,2,3,4")

"1,2,3,4" is one string, not several values. Get rid of the " quotes.
Comment: I was using this quite a long time but found some kind of strange behaviour. I have used `WHERE NOT IN(1,2,34,65,78,87,90,105)` which retuned something like `10,15,25,60,87,90` so it does not work properly.
Comment: how did you remove it?
Answer: You could try to use FIND_IN_SET rather than an IN clause.
  $IDS = mysql_real_escape_string(implode(',', $IDS));
  $Select = "SELECT * FROM status WHERE (W_ID=$ID)
             AND (NOT FIND_IN_SET(ID, '$IDS'))
             ORDER BY ID DESC LIMIT $Begin, $Number";

Anyway in SQL you are required to use single quotes for strings, not double quotes. That works with MySQL, but not for all configurations. Also gets more readable if you do it the other way round. (Single quotes in PHP for performance is retarded advise!)
Comment: the `NOT IN` user744319 is using is perfectly valid.
Comment: Yes it's valid. It's advisable even. But this one is easier to work with and seems more appropriate for OP. (easier to secure also, not sure where the ID values originate from)
Comment: Sorry, was referring to FIND_IN_SET. Agree with you on the escape part. You should mention that point in your answer.


What is the domain and range of the PMF of the Bernoulli distribution with p = 0.1?

Question: In probability theory and statistics, the Bernoulli distribution

is the discrete probability distribution of a random variable which
  takes the value 1 with probability p and the value 0 with probability
  ${\displaystyle q=1-p}$.

The probability mass function f of this distribution, over possible outcomes k, is

${\displaystyle f(k;p)={\begin{cases}p&{\text{if }}k=1,\\q=1-p&{\text{if }}k=0.\end{cases}}}$

let p = 0.1, and then
$f(k;0.1)={\begin{cases}0.1&{\text{if }}k=1,\\0.9&{\text{if }}k=0.\end{cases}}$
So, the domain of this particular function f(k;0.1), its domain is the set {0,1} with 2 elements, and its range is the set {0.9,0.1} with 2 elements.
In this specific case, is my understanding right?
Answer: Domain is the set of values that you can literally evaluate the function. Given the definition, you can't evaluate the function with $k$ outside the set $\{0,1\}$, which means it is indeed the domain of it. Note that wikipedia doesn't explicitly comment on the domain, but the support. However, if a discrete function is written in piecewise form like this and you don't see an else statement, it typically means you can't evaluate values other than listed in the definition.
Range is the set of values you can obtain when you evaluate the function within its domain. And, in this case, it is $\{p,1-p\}$ in general. For $p=0.5$, the range has only one element. Otherwise, it has two as you noted for $p=0.1$.
Comment: Thanks for your answer. What does "partial form" mean?
Comment: I've changed it as *piecewise*.
Comment: Does "... don't see an else statement" indicate that a PMF have to include the else part?
Comment: No, it doesn't have to include.
Comment: So, "can't evaluate values other than listed in the definition" only affects the generalization of this function, but the pmf $f(k;0.1)={\begin{cases}0.1&{\text{if }}k=1,\\0.9&{\text{if }}k=0.\end{cases}}$ here is legitimate, is it?
Comment: It is legitimate, you can evaluate $f$ for the values in the domain, i.e. $\{0,1\}$; but not for $k=2,3$ for example, since they're not in the domain as they're not included in the piecewise definition.
Comment: "k=2,3" is the concern about generalization, such that the Multinoulli distribution, is it?
Comment: Yes, it is a concern about its generalization, but what I'm really saying is this: you can't evaluate $k = 2,3$ or $-1$ for the Bernoulli distribution because it's not in the domain, and your understanding in the original question is right.
Comment: Thank you so much. What is the relationship between domain and support, in this particular case or any other simple example case?
Comment: I think it's better to contemplate on their definitions: domain is the values you can evaluate the function, support is the values the function is non-zero. So, the support is a subset of the domain, and sometimes they're equal. In this particular case, they're equal.
Comment: Would you please give an example that the support is not equal to domain?
Comment: The situation occurs more oftenly in continuous case: e.g. uniform distribution: https://www.wikiwand.com/en/Uniform_distribution_(continuous). By the way, in order to prevent this thread from elongating, it's better to frame your further questions as a separate one.
Comment: Normally, the domain of a pmf $p$ is taken to be $\mathbb R$ by defining $p(x)=0$ for all $x$ not in the support of the distribution. This is a substantial simplification because it means we don't have to explicitly specify the domain every time we give a pmf.  In this example, then, the domain is $\mathbb R$ (by default) and the range is $\{1/10, 9/10\}.$  Its *support* is $\{0,1\}.$
Comment: @whuber shouldn't the domain of pmf be finite or countably infinite, by definition?
Comment: That seems to confuse the *domain* with the *support.*  Although there's nothing technically wrong with insisting that the domain of a pmf be just the support of its distribution, it complicates things.  Indeed, one may define a pmf to be *any* function $p:\mathbb{R}\to\mathbb{R}$ for which (a) $p(x)\ge 0$ for all $x$ and (b) $\sum_{x\in\mathbb{R}}p(x)=1.$  As is conventional in algebra, this sum is defined provided at most a countable number of the values of $p$ are nonzero, so that is implicitly included in the latter assertion.
Comment: As an example of how this approach is simpler, consider defining the CDF of the distribution determined by a pmf $p.$  In my definition it is $F(x) = \sum_{y\le x}p(y).$ In  your definition you would have to specify something like $F(x)=\sum_{y\mid y\in\operatorname{Domain}(p)\text{ and } y\le x} p(y).$ Both are correct; both work; take your pick.


Qual a diferença entre funções e procedimentos?

Question: Estou estudando algorítimos e estou com uma certa dificuldade para entender a diferença entre eles e quando usar esses sub-algoritmos em um programa. Estou aprendendo a programar com algoritmo em Portugol.
Comment: É uma explicação meio "porca", mas só pra iniciar o assunto: na maioria dos contextos, a função retorna um valor, e o procedimento não. Na verdade, isso depende muito do contexto. Idealmente, procedimentos executariam tarefas passo a passo, e funções simplesmente fariam processamento de dados e devolveriam um retornoresultado, sem gerar efeitos colaterais, mas em linguagens imperativas essa coisa do efeito colateral fica meio relativizada.
Comment: possível duplicada em http://pt.stackoverflow.com/questions/11848/quais-s%C3%A3o-as-defini%C3%A7%C3%B5es-de-m%C3%A9todo-fun%C3%A7%C3%A3o-e-procedimento
Comment: Ainda não estudei nenhuma linguagem de programação, estou ainda no curso de algorítimos em portugol.
Comment: @Bacco Concordo com você ^^
Answer: Confusão
Muitos programadores experientes podem ter dificuldade de entender a diferença entre um e outro. Tanto confundem que algumas pessoas acham que linguagens do paradigma funcional são as linguagens que possuem funções e as linguagens do paradigma procedural são as que possuem procedimentos. O que é um completo absurdo, porque no fundo ambos são (quase) a mesma coisa.
No fundo é a mesma coisa
É raro encontrar linguagem que só possua procedimentos (algum dialeto de SQL pode ser, alguma linguagem muito antiga e virtualmente abandonada, ou em algum nicho muito específico).
Em algumas poucas linguagens de programação há uma distinção clara entre as duas, outras preferem tratar tudo como funções. Algumas até tratam as funções só como métodos.
No fundo tanto os dois citados na pergunta quanto métodos funcionam da mesma forma e concretamente a implementação é essencialmente a mesma.
O que difere
Conceitualmente um procedimento difere da função pela ausência de um retorno de valor.
Então um procedimento é um algoritmo que será executado, enquanto que a função é um algoritmo que será executado e produzirá um resultado final concreto que poderá ser usado por outro algoritmo.
Função pura
Como o termo "função" vem da matemática, ela deveria apenas executar um cálculo e retornar o resultado sem fazer operações extras, sem fazer entrada e saída, sem alterar estado fora de sua execução (só mexe em variáveis locais, criadas dentro da função), enfim, a função deveria ser pura (determinística, sem efeitos colaterais). Só algumas poucas linguagens funcionais realmente exigem a pureza. A prática da pureza é pouco pragmática para a maioria dos problemas comumente encontrados na computação.

Em outras palavras, a função computa algo (no sentido de cálculo) e o procedimento executa uma lógica de negócio (ainda que tecnicamente isso não deixe de ser uma computação).
Convenção
As linguagens que só possuem funções retornam "nada" quando se deseja apenas um procedimento, mas elas ainda são consideradas funções. Comparando:
procedimento teste()

é o mesmo que
funçao teste() : nada //tipo do dado que será retornado, o Portugol não possui "nada"

O que fazer com cada um
Cada linguagem ou até mesmo cada equipe pode definir o que pode ou não fazer dentro de uma função ou procedimento, mas isso costuma ficar em estilo de codificação e não regras rígidas obrigatórias para validade do código.
É comum que a linguagem exija que o procedimento só possa ser chamado como um statement (comando, algo no início da linha ou através de comando específico de chamada) e não como expressão, afinal uma expressão costuma exigir um resultado que o procedimento não fornece.
Então se for aplicar a um algoritmo definido abstratamente, deve-se considerar a sintaxe da representação usada para saber se haverá uma diferenciação sobre um ou outro. Agora que a pergunta tem uma definição que está usando Portugol posso dizer que ela segue um pouco o que o Pascal faz, que é uma linguagem que usa técnica um pouco antiga.
Para todos os efeitos entenda bem o funcionamento da função que saberá como deve ser o procedimento. A não ser que deseja aprender de forma muito acadêmica e só utilizar funções puras e deixar rotinas não puras para procedimentos. Não acho que vale a pena distinguir isso em casos práticos (não estou dizendo que aprender de forma acadêmica não tenha sua serventia teórica).
Conclusão
Não se assuste se encontrar definições diferentes em contextos diferentes.
Particularmente acho que essas linguagens muito abstratas acabam criando certos vícios no programador porque ele é obrigado fazer coisas que não faria em linguagem mais concreta. De que adianta aprender criar um procedimento se quase todas as linguagens modernas só possuem funções?
Coloquei no GitHub para referência futura.


Replacing text with javascript?

Question: After much trial an error and some progress I still can't mange to change every instance of ,- with kr on my website.
I'm very much a beginner at JS and have pieced together the following code from several sources. Is the code the problem or something else?
function skrivkr() {
var skrivkr = $('div').text().replace(/\,-/g, 'kr');
$('p').html(skrivkr);
}
window.onload = skrivkr();

Update:
Thanks for the replies. The site loads jquery 1.10.7.
@Niet the Dark Absol: No, I don't want to put anything in p elements. How do I remove that part? I just want to find all ,- and simply replace with kr without changing any formatting.
Update
OK! Progress, kind of. The ENTIRE content of every  and
 now changes to (0), instead of kr. With the odd exception of those tags including ,-.  I haven't designed the site myself.
If it helps, one of the ,- appears in the following markup:

1

Prtoduct name
4444,-

And the lastest script I'm applying is:
$(document).ready(function() {
$('strong, dd').html($('strong, dd').html().replace(/,-/g, 'kr'));
});

Comment: your code works in [this fiddle](http://jsfiddle.net/k518rdLg/)
Comment: Sure this doesn't work? It works for me. http://jsfiddle.net/wva2g8xe/
Comment: You're using jQuery. Did you include jQuery? You are taking the text content from all `` elements and putting it in all `` elements. Is this really what you want? Did you actually try understanding the code you copied?
Comment: This looks fine.  Can you post a sample of the text where it doesn't work?
Comment: if you to change the text on all the div, try running: $('div').text($(this).text().replace(/\-/g,'kr'));
Comment: Should be `window.onload = skrivkr;` (no parens). Also, I cannot really recommend using the same identifier for the function and an identifier within in, although it doesn't really matter.
Answer: You can update the content of each div like this
$(document).ready(function() {
    $('div').each(function(){
        var newText = $(this).html().replace(/,-/g, 'kr');
        $(this).html(newText);
    });
});

You can remove the var "newText = " and replace it with $(this).html($(this).html().replace(/,-/g, 'kr'));
The first example is easier to understand perhaps if you are new to programming.
You will, however only change the content of text placed in  tags.
I would place the text to replace in a div with some predefine class, like "autoKronor", it would then look like this:

123,-

and
$(document).ready(function() {
    $('.autoKronor').each(function(){
        var newText = $(this).html().replace(/,-/g, 'kr');
        $(this).html(newText);
    });
});

to en sure that only text you intended to change gets changed..
Example here: http://jsfiddle.net/akm1uw8h/2/
Also note the use of $(document).ready(); instead of window.onload. It does what you intended to do with window.onload.
if you really want to change EVERY single instance of ",-" to "kr" then you could do this:
$(document).ready(function() {
    $('body').html($('body').html().replace(/,-/g, 'kr'));
});

But i strongly advice against the last example because it will be the slowest to compute and more importantly you might change stuff you don't intend to, like any script block inside the page body (with that i mean other javascripts)
Comment: I tried the first version of the code and the result is that all site structure and formatting on the site disappears and I get a huge text block. Plus, the script itself appears in plaintext.
Comment: Try with the new version
Comment: Unfortunately it didn't work. The site keeps loading but not showing anything. The ,- on the site appears in `` and `` tags. would it be wise to specify by using $('strong;dd').html($(strong;dd').html()... ?
Comment: You will have to use $('strong, dd') as your selector, not just $(strong;dd') (probably just a typo, but it still matters). Have you designed the site yourself? Is it possible for you to change or add "css"-classes on tags? If you can, then using classes to designate where you want it to change the text would be the best, because then you can decide where it should change the text (and you don't need to worry about as many "what if" scenarios)
Comment: And yes, you CAN use whatever tag you want, but the more specific you are the better. That is why i would use classes to define where to swap the ,- for kr
Comment: For me your current code works, i have made a demo here: http://fiddle.jshell.net/Lkfnh2hv/ .I am sure we have asked you about this, but you are 100% sure you are loading jquery on your site, right? Can you also confirm that the link i posted in this comment works for you? The output should be something like "1 (broken image link) Product name 4444kr"
Answer: As has been mentioned innumerable times here on SO, do not try to manipulate the DOM as a string. Pain awaits.
Instead, traverse the DOM, finding text nodes, and perform whatever transformation you want to make on each text node. There are many ways to do that.
In your case, you have many problems, as mentioned already by some of the commenters and responders:

You're setting window.onload to undefined (the result of calling skrivkr), instead of to skrivkr itself.
You're extracting the text value of an element, which consists of the concatenation of all text down all levels, performing the replacement, then sticking it back in with html. This will wipe out all the element structure below.
Minor point, but there's no need to escape the comma in the regexp.
You're extracting the textual content of all div elements in the entire document, transforming it, then adding that back as the content of all p elements in the entire document. It's hard to imagine that's what you want to do.
Comment: Thans for the feedback. I see now the code was more faulty than I thought.

Replacing text with javascript?


How to handle age and timepoint variables in a mixed-model for longitudinal data?

Question: I have a longitudinal dataset:
DV: Task performance on three within-subject conditions at each time point
IVs

Timepoint (variable interval, up to three occasions, missing data at random)
Age at each time-point (variable initial age, variable interval between time-points)
Task categorical variable.

I would like to test for differences between the trajectories of within-person change in each of the three three within-subject task conditions while also accounting for the age differences.

What variables should be fixed and random effects (task, age, timepoint)?
How do I code timepoint since the intervals are variable?
Should I center age by the youngest age in the sample?
How do timepoint and age work together?
Comment: I understand how to use and interpret random slope and random intercepts. However, I'm not sure how to reconcile the two conceptions of time (age, and time points).
Comment: What do you mean that **timepoint** has "intervals [that are] are variable"?
Comment: I mean that there are three occasions that participants were tested. The time interval between testing was not fixed. Also the starting age was not fixed and covered a broad age-range.
Comment: ID TIMEPOINT AGE SCORE
Answer: Age is a time-varying-covariate.  They can be tricky.  In this case, you wouldn't include both current age and time, because they would be collinear.  Instead, you can have age at baseline as a (static) covariate, and also include timepoint.

My guess is that you would have fixed effects for age at baseline, timepoint, and task.  You would probably have a random intercept and a (possibly covarying) random slope on timepoint for each subject.
You could code the timepoints as time from when each subject began the study.  That is timepoint $= 0$ for each subject at the point you first interact with them (either applying some intervention or taking your first measurement).  For every additional measurement, timepoint would be the elapsed time since the beginning of their involvement with the study.
You needn't necessarily center age.  However, the intercept in your model / output will refer to the fitted mean response value when a subject is born, which may not be a meaningful value for you.  If you center age, the intercept will refer to the mean response value when a subject's age at baseline is equal to the mean age at baseline of your sample.
(See the comment at the beginning.)

Edit: (maybe now I understand what you're doing a little more clearly)
You need to also add an interaction between task and timepoint as a fixed effect, and add (possibly covarying) random effects for task and the task X timepoint interaction.  That way, each subject will be able to have their own slope over time for each task.  The model will fit the population mean trajectory for each task over time.
Comment: Thank you for your help. I do appreciate it. I've come to a similar conclusion about using time in study for WithinSubject change, while using age (possibly just at time one as a covariate) for BetweenSubject differences after referring to http://www.lesahoffman.com/944/944_Lecture11_Alt_Time.pdf.
Comment: Im still confused however about how to contrast the developmental  trajectories of the three task conditions measured within subject. Right now, I have all three scores in a single column in the data file and use an indicator variable as an IV and as a random effect. But I am just not sure that is right.


External gradle dependency on libGDX project

Question: I am working on an android game and external library using LibGDX.
I'm getting the following error:
Error:Execution failed for task ':android:transformClassesWithDexForDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException:
    org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Android\Android Studio\jre\bin\java.exe''
    finished with non-zero exit value 1

I'm trying to create an external shared project that all my other games can depend on for common code.
The problem is my shared library project depends on Libgdx as well as my game project which also depends on libgdx.
When launching my game on android devices.
The gradle sync and also the build project works fine, it only occurs when trying to deploy onto a device.
I can also deploy to desktop with no issues.
I think I may be exceeding the android method count limit of 65,536 due to the repeating library dependencies, but can't work out a better solution.
Or it could be that android doesn't like nested dependencies that aren't in the root.

I have included my project structure and gradle files below.
Would really appreciate a solution that allows me to continue to edit the library within the IDE of the game project.
I would also be open to having an alternate project structure if anyone recommends something else.

Directory / Project Structure:
C:\
    Projects\
        SharedProject
        Project1
        Project2
        ...

My android module dependancy tree (by running "gradlew -q dependencies android:dependencies --configuration compile"):
+--- project :core
|    +--- com.badlogicgames.gdx:gdx:1.9.6
|    \--- project :APD_Core
|         \--- com.badlogicgames.gdx:gdx:1.9.6
\--- com.badlogicgames.gdx:gdx-backend-android:1.9.6
     \--- com.badlogicgames.gdx:gdx:1.9.6

(Note: APD_Core is the shared project)

Possible Solutions:
I have tried to use multiDexEnabled but this has not helped.
I think I might need to exclude the gdx module when I compile the shared library into core
    but I have not worked that out yet.
    (I'm thinking that android does not like the shared library having the same dependancy on gdx that the android module also has)
Another possibility is that android needs my shared project to be built into a jar and then put into the libs folder within the android module.
    And this might be doable via the android gradle file, but I'm new to gradle and dont know if this is needed or how to do it.

What I have changed :
added the shared project to the settings gradle
include ':APD_Core'
project(':APD_Core').projectDir = new File(settingsDir, '../APD_Core')

added the dependency to the shared project in the core module
project(":core") {
    ...
    dependencies {
        ...
        compile project(':APD_Core')
    }
}

have the shared project depend on libgdx
dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}

Not much else has changed from the default generated project structure when using the gdx-setup.jar
Note the shared project is was created from intellij as a new gradle project and not using the gdx-setup.jar
Full gradle files bellow

GRADLE SETTINGS FILE:
include 'desktop', 'android', 'ios', 'core', ':APD_Core'
project(':APD_Core').projectDir = new File(settingsDir, '../APD_Core')

MAIN GRADLE FILE:
buildscript {
    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.2.0'
    }
}

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        appName = "MyGame"
        gdxVersion = '1.9.6'
        roboVMVersion = '2.2.0'
        box2DLightsVersion = '1.4'
        ashleyVersion = '1.7.0'
        aiVersion = '1.8.0'
    }

    repositories {
        mavenLocal()
        mavenCentral()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
        maven { url "https://oss.sonatype.org/content/repositories/releases/" }
    }
}

project(":desktop") {
    apply plugin: "java"

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"
    }
}

project(":android") {
    apply plugin: "android"

    configurations { natives }

    dependencies {
        compile project(":core")
        compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86"
        natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"
    }
}

project(":ios") {
    apply plugin: "java"
    apply plugin: "robovm"

    dependencies {
        compile project(":core")
        compile "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
        compile "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
        compile "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
        compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
        compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"
        compile "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"
    }
}

project(":core") {
    apply plugin: "java"

    dependencies {
        compile "com.badlogicgames.gdx:gdx:$gdxVersion"
        compile project(':APD_Core')
    }
}

tasks.eclipse.doLast {
    delete ".project"
}

CORE GRADLE FILE:
apply plugin: "java"

sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = [ "src/" ]

eclipse.project {
    name = appName + "-core"
}

dependencies {
    compile project(':APD_Core')
}

ANDROID GRADLE FILE(unmodified from the default generated one):
android {
    buildToolsVersion "25.0.1"
    compileSdkVersion 23
    sourceSets {
        main {
            manifest.srcFile 'AndroidManifest.xml'
            java.srcDirs = ['src']
            aidl.srcDirs = ['src']
            renderscript.srcDirs = ['src']
            res.srcDirs = ['res']
            assets.srcDirs = ['assets']
            jniLibs.srcDirs = ['libs']
        }

        instrumentTest.setRoot('tests')
    }
    packagingOptions {
        exclude 'META-INF/robovm/ios/robovm.xml'
    }
    defaultConfig {
        applicationId "com.mygame"
        minSdkVersion 10
        targetSdkVersion 23
        multiDexEnabled true
    }
}

// called every time gradle gets executed, takes the native dependencies of
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
    file("libs/armeabi/").mkdirs();
    file("libs/armeabi-v7a/").mkdirs();
    file("libs/arm64-v8a/").mkdirs();
    file("libs/x86_64/").mkdirs();
    file("libs/x86/").mkdirs();

    configurations.natives.files.each { jar ->
        def outputDir = null
        if(jar.name.endsWith("natives-arm64-v8a.jar")) outputDir = file("libs/arm64-v8a")
        if(jar.name.endsWith("natives-armeabi-v7a.jar")) outputDir = file("libs/armeabi-v7a")
        if(jar.name.endsWith("natives-armeabi.jar")) outputDir = file("libs/armeabi")
        if(jar.name.endsWith("natives-x86_64.jar")) outputDir = file("libs/x86_64")
        if(jar.name.endsWith("natives-x86.jar")) outputDir = file("libs/x86")
        if(outputDir != null) {
            copy {
                from zipTree(jar)
                into outputDir
                include "*.so"
            }
        }
    }
}

task run(type: Exec) {
    def path
    def localProperties = project.file("../local.properties")
    if (localProperties.exists()) {
        Properties properties = new Properties()
        localProperties.withInputStream { instr ->
            properties.load(instr)
        }
        def sdkDir = properties.getProperty('sdk.dir')
        if (sdkDir) {
            path = sdkDir
        } else {
            path = "$System.env.ANDROID_HOME"
        }
    } else {
        path = "$System.env.ANDROID_HOME"
    }

    def adb = path + "/platform-tools/adb"
    commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.mygame/com.mygame.AndroidLauncher'
}

// sets up the Android Eclipse project, using the old Ant based build.
eclipse {
    // need to specify Java source sets explicitly, SpringSource Gradle Eclipse plugin
    // ignores any nodes added in classpath.file.withXml
    sourceSets {
        main {
            java.srcDirs "src", 'gen'
        }
    }

    jdt {
        sourceCompatibility = 1.6
        targetCompatibility = 1.6
    }

    classpath {
        plusConfigurations += [ project.configurations.compile ]
        containers 'com.android.ide.eclipse.adt.ANDROID_FRAMEWORK', 'com.android.ide.eclipse.adt.LIBRARIES'
    }

    project {
        name = appName + "-android"
        natures 'com.android.ide.eclipse.adt.AndroidNature'
        buildCommands.clear();
        buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
        buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
        buildCommand "org.eclipse.jdt.core.javabuilder"
        buildCommand "com.android.ide.eclipse.adt.ApkBuilder"
    }
}

// sets up the Android Idea project, using the old Ant based build.
idea {
    module {
        sourceDirs += file("src");
        scopes = [ COMPILE: [plus:[project.configurations.compile]]]

        iml {
            withXml {
                def node = it.asNode()
                def builder = NodeBuilder.newInstance();
                builder.current = node;
                builder.component(name: "FacetManager") {
                    facet(type: "android", name: "Android") {
                        configuration {
                            option(name: "UPDATE_PROPERTY_FILES", value:"true")
                        }
                    }
                }
            }
        }
    }
}

SHARED PROJECT GRADLE FILE:
group 'APD_Core'
version '1.0'

apply plugin: 'java'

sourceCompatibility = 1.8

allprojects {
    apply plugin: "eclipse"
    apply plugin: "idea"

    version = '1.0'
    ext {
        gdxVersion = '1.9.6'
    }
}

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
    compile "com.badlogicgames.gdx:gdx:$gdxVersion"
}

Answer: If you are making common libraries for many games I'd suggest you to create a separate project containing these libraries, publish it to your local maven repo with the gradle maven-publish plugin and then declare the dependencies to these libraries in your game projects. That will help you now debug your problem, and it will make easier to modify those libraries and use them in other games in the future.
Comment: Tried this out on a new set of test projects and for some reason I'm getting the same issue, despite not depending on libGDX on the shared library in this test. Works fine for desktop but adding the local maven dependency to core causes the android deployment to fail with the exact same error. It even more confusing as the one thing that was causing the original project to fail has not even been introduced in this test and yet I'm getting the same problem. (Thanks for the help by the way, didn't know about local maven repos)
Answer: Adding:
compileJava   {
    sourceCompatibility = '1.7'
    targetCompatibility = '1.7'
}

to the root gradle file of the library project and removing the settings.gradle file from the library project resolved the issue.
Works with both maven local dependency and external gradle dependency.


Manage changes to cassandra.yaml and cassandra-env.sh

Question: How do you manage changes made to cassandra.yaml and cassandra-env.sh? During upgrading cassandra to a newer version, if you choose to retain the modified file, you will lose any new changes to those files.
Comment: I keep them in git, and push them out with a deploy.
Answer: you should merge your original changes back into the new files. This is because there may be new parameters introduced into the new file with new features or indeed new default values for new or existing features. Using an old file might cause you problems.
Use a good merge tool like meld (linux) or Winmerge (windows) to merge your files. Once you have a good template you can use this as a template.


How to create audit trails/order revisions?

Question: I've been working with Drupal Commerce for a few months now. As a non-profit, our organization hosts an e-commerce/e-learning site. We're a smaller organization with approx 20 staff users and <20,000 regular customers.
How do others handle creating audit trails/order revisions within Drupal Commerce? There are quite a few modules out there, but I have yet to find the right combination. Currently, we've added Line Item Revisions module and use the Order revisioning built into Drupal Commerce.
Here are some concerns I'm attempting to address:

How did the order end up in the current state (who and why)?
What was recently changed (line items, status, owner, coupons, etc. who and why also)
How do you identify who deleted records, specifically financial records? Secondly, how to you log what the deleted records originally entailed?

As a non-profit, we're audited annually and when staff can accidentally delete payments/orders/etc for money already collected or products already delivered, we lose any history of how it all happened. I'm hoping I'm not the only one who has this question and some of the more tenured users here can point me in a direction.
Answer: I'm assuming you're using Drupal 7 here but one of the most effective ways to do is to handle it the same way that Commerce Kickstart does: with the Message stack.
There is a Commerce Message module exposes some of the common events, you'll just need to create a view and tie it into your order page or figure out some other way of handling things.
Answer: IMO the Message module would be a perfect fit to answer this question. Using this module, you can create your own custom "Events logging" (to register things that happened in a site).
Specific to this question here, I'd create an appropriate set of so called "Message types" that fit your needs (the "concerns you're attempting to address", as in your question, seem to require multiple Message types). Some of the actual data you probably want to be included in one or more of them:

username ("who" did something).
event date ("when" did something happen).
any data about the actual orders you want to track, such as the order id (of course), etc.

You could even track how those data looked like before and after they got updated, a kind of "light" revisioning (only for those attributes you want to know about).
About Message types: think of them as equivalent to Content types, whereas you create messages (instead of nodes) of a specific Message type (instead of Content type).
Rules integration
A really interesting facility of the Message module is its perfect integration with the Rules module. Have a look at the answer to "How to implement a follow author (or user) function?" for way more details on that.
In your case, you'd simply create a (rather basic) custom rule which uses:

a Rules Event like "Before saving a new order", of "After updating an existing order" (or variations of these events).
a Rules Action to "Create a message" (of a selected Message type).

That's really it ...
Example included in Commerce Kickstart
A great sample of this can be found in Commerce Kickstart, which uses the Commerce Message module, to create such "Events logging". In that case in the format of an Order History, as shown in this screenprint (from this module's project page).
More info about the Message module
The Message module is an amazing module, it is fully entity based, which implies that it perfectly (out of the box) integrates with modules such as Views and Rules.
For more details about the Message module, refer to some interesting Use Cases detailed within its Community Documentation. And/or checkout the video introduction "Your Drupal site can talk" (if you want you can fast forward to about 03:30 where it really starts).
Learn from examples
There is not a lot of documentation about the Message module (which is what makes it a hidden Drupal gem). A possible way to get started with it, and to get an idea of the kind of things it can be used for, is to have a look at the answers to:

How to create a basic message - notifications system displaying a real time message counter badge?
How to show message view containing own and following activity?
How to integrate messaging into a custom module?

Replacement tokens
Because of the nature of your question, it seems you'll have quite a few of custom data to be included in your custom messages (= log records to be created). Most of them will NOT be supported out of the (message) box.
However, there is a pretty amazing technique you can take advantage of, i.e. the "replacement tokens" used by the Message module. For an in depth tutorial about how to use this technique, refer to "What's the purpose of "Replacement tokens" of a Message type?". Here are some examples where this technique is used:

Which user related token(s) can be used to create a Rule for setting up a message type?
How to implement a follow author (or user) function?
Comment: This is a very helpful response. I'll have to play around with the module a bit to see if it'll fit our use case, but it sounds promising. Thank you @Pierre.Vriens .
Comment: It's unfortunate that your post (after so much work) was downvoted. I'm relatively new to the community, so I'm sure there will be many more questions to come. Thanks to all the support from devs like you!


How is the module Userpoints Donation intended to work?

Question: I enabled the Userpoints Donation module (part of Userpoints Contrib). Then I put a check in the settings for the type of material - (Choose which content types should show a donate points link).
What's next? Nothing has changed. It says "Only the checked content types will show a donate points link". But no reference appeared.
Answer: The purpose of the Userpoints Donation module is mentioned near the top of the module's source:

... uses User Points API to give users ability to give points to users.

But "give" actually means "transfer", as shown in userpoints_donation_giveform_submit(), which:

increments the amount of points for the user who receives the donation (= receiver).
reduces the same amount of points for the user who donates them(= donator).

Before actually doing so, various extra validations are performed, such as:

Does the donator have sufficient points, so that after transferring the points the user points balance of the donator is still positive?).
The receiver has to be a valid user.
You cannot transfer points to yourself.
The amount of points donated cannot be below 1 user point (which also implies that the donator can only "give" points, not "take" points ...).
...

However, for an appropriate link (with title "Donate points to this user") to be shown to the user who wants to do such donation, it is required that such user has been granted the permission "give points to another user". So if "Nothing has changed" (as in your question), it could well be that the required permission has not been granted yet.


How do I export fields of a content type in one website and import it into another website?

Question: I'm trying to set up a data export through views that includes the title and a couple of fields of a content type and import it into another website. I'm using Feeds and Views Data Export and also tried Views XML but is doesn't seem to work.
How do I export fields and import them by creating nodes in another website?
Answer:
Create a rss feed of your view or using Views Bonus Pack create a csv of your data.
Create the Content Type that will be the container for your new content. Or alternatively export the content type using the "Content Copy" module shipped with cck and then import it on the new site.
Using Feeds Create a node importer to import your nodes. Details in the video linked.
Answer: Remember see this: comparison of content import and export modules http://groups.drupal.org/node/21338 and his respective comments.
from all this options Migrate (and also Migrate extras) seems an interesting option to drupal 7 (is my opinion) because is flexible, and stable, altough maybe is best build a custom script to export and import your content.
Comment: You might also be able to use the features module: http://drupal.org/project/features to help out.
Comment: What I was hoping for was a feed that uses views and allows fields instead of the whole entity.
Answer: Views lets you easily create any kind of RSS feeds of your content, if that is what you are looking for.
Answer: You may want to look into Bundle Copy if it's structure you're trying to move. This is similar to CCK's Content Copy in Drupal 6.


How function declarations work?

Question:     #include <stdio.h>
    void bar();

    int main()

    {

        void foo();

        printf("1 ");

        foo();
        bar();

    }

    void foo()

    {

        printf("2 ");

    }
    void bar()
    {
        foo();
    }

Output:
1 2 2
Shouldn't the function foo() be visible only inside main() ?
But this is not the case.
Are function declaration in C always to every functions?
Comment: Move the definition of `bar()` above `foo()` and try again.
Comment: @SLaks Does it mean that once functions are defined it is visible to all other functions defined later?
Comment: @PankajMahato I replied to your question on the comment on my answer.
Answer: let me explain commenting the original code you pasted :)
#include <stdio.h>
void bar(); //so, we declared bar here, thus it will be called successfully later

int main()

{

    void foo(); //we declared foo here, thus the foo two statements below also can be called

    printf("1 ");

    foo(); //this works because the void foo(); some lines above
    bar(); //this works because of bar() outside the main()

}

void foo() //here foo is defined

{

    printf("2 ");

}
void bar() //here bar is defined
{
    foo(); //this works because foo was declared previously
}

Indeed, you are both right, and wrong, right in the sense that the first declaration of foo() goes out of scope after main ends. Wrong in the sense that the linker would confuse stuff, the linker, that decides what function call calls what, can find the foo outside the main and figure that is the same foo declared inside the main.
That said, you should not declare functions inside other functions...
Also here is a better proof of what you want to know:
I tried to compile this:
#include <stdio.h>
void bar();

void bar()
{
    void foo();
    foo();
}

int main()

{

    printf("1 ");

    foo(); //line 18
    bar();

}

void foo()

{

    printf("2 ");

}

It gave me this error: prog.c:18:9: error: implicit declaration of function 'foo' [-Werror=implicit-function-declaration]
This is because the foo() inside bar() is valid, but the foo() on main is not, because although foo() is declared before main, it is still valid only inside bar()
Comment: Try using Ideone on c99 strict mode (instead of normal C mode, or a nonstrict mode) and it won't work.
Comment: @PankajMahato this should not even work in first place, the C standard (at least up to c99, if someone can tell me if c11 consider this valid, you are welcome), forbids DEFINING (instead of declaring) functions inside another function.
Comment: So, why it compiled the way it did in your compiler, then only your compiler can tell you, because it is custom compiler behaviour (not a behaviour from the standard)
Answer: foo() is visible in bar() because it has been defined before.
If you implement foo() after bar() there will be a compiler error
#include <stdio.h>
void bar();

int main()

{

    void foo();

    printf("1 ");

    foo();
    bar();

}

void bar()
{
    foo();
}
void foo()

{

    printf("2 ");

}

brings:
'foo': identifier not found

How function declarations work?


If $p$ is prime and $\gcd(m,p) = 1$ show that $\gcd(m,p^k) = 1$

Question: If $p$ is prime and $\gcd(m,p) = 1$ show that $\gcd(m,p^k) = 1$ where $k\geq1 $.
I think I have come up with a solution:
Suppose $m$ has prime factorization $m = p_1^{a_1}...p_n^{a_n}$ where $p_i$ is prime. Since $\gcd(m,p) = 1$ none of $p_i = p$. Now if $\gcd(m,p^k) \neq 1$ then the $\gcd$ must be $p^n$ with $0< n \leq k$. Note that the divisors of $m$ are the integers $p_1^{\bar{a_1}}...p_n^{\bar{a_n}}$ with $0\leq \bar{a_i} \leq a_i$.
So then we must have that $p^n = p_1^{\bar{a_1}}...p_n^{\bar{a_n}}$  so then both numbers must have the same prime factorization so that means that one of $p_i = p$ a contradiction. Which proves the result.
Is this argument fine?
Comment: Looks good. Longer than necessary. If $\gcd(m,p^k)\gt 1$, then some prime $q$ divides $m$ and $p^k$. Argue that $q=p$ from Euclid's Lemma, if a prime $q$ divides a product it divides one of the terms.
Answer: It is fine, though it feels a bit elaborate to start speaking of prime factorizations for this case (but it is still an excellent way to think about gcds in general).
It would probably be enough to say something like

Since $\gcd(m,p)=1$, $p$ cannot divide $m$ (otherwise $p$ would be a greater common divisor).
The only divisors of $p^k$ are $p^n$ for $0\le n\le k$ and if any of those except $1$ divides $m$, then $p$ will also divide $m$, which we know it doesn't. So $1$ is the only (positive) common divisor of $m$ and $p^k$.
Comment: Worth strong emphasis: it is not "enough" to say what is said above because it does not *justify* the claim that "the only divisors of $p^k$
 are ...". Usually this is justified by invoking FTA = existence and uniqueness of prime factorizations (or closely related results). It is essential to *explicitly* invoke such supporting Theorems *by name* in order to obtain a complete correct proof. There is nothing at all "elaborate" about doing such. $\ \ $
Answer: More generally,  $\gcd(m,n)=1$ iff $\gcd(m^k,n^l)=1$ for $k,l\in\Bbb N$.
Proof: If $\gcd(m,n)=1$ then by Euclidean algorithm $\exists\, a,b\in\Bbb Z$ such that $$am+bn=1.\tag1$$ Taking $k+l$-th power of both sides of $(1)$, we have
$$\left(\sum_{j=0}^{l}{k+l\choose j}a^{k+l-j}b^jm^{l-j}n^{j}\right)m^k+\left(\sum_{j=l+1}^{k+l}{k+l\choose j}a^{k+l-j}b^jm^{k+l-j}n^{j-l}\right)n^l=1.$$
So, $\gcd(m^k,n^l)=1.$ Only if part of the proof is easier.


Which method creates the cache directories inside sites/default/files

Question: I am trying to solve the question SETGID bit gets reset for newly created directories inside sites/default/files. Please Note the Update-2 there.
I want to know which method creates the directories like php, css and js inside the web/sites/default/files directory. I think the method or function which creates css and js abuse the chmod function because only PHP directories obeys the setgid (set group ID) bit rule.
Answer:
I think the method or function which creates css and js abuse the chmod function

There's no code that abuses chmod in Drupal. There simply couldn't be - the only interface to the system chmod that PHP provides is its own chmod function. It's not possible to abuse that function, it only accepts two basic parameters.
It would, of course, be possible to provide extra functionality via a custom PHP extension, but only you could know if you had such a thing installed.
But to answer your specific question:

I want to know which method creates the directories like php, css and js inside the web/sites/default/files directory

That's FileSystem::mkdir. You can see from looking at the handful of lines of code in there that there's no abuse of chmod - just the standard usage.
Comment: Yes but it seems, like Drupal 8.x currently using drupal_mkdir() which is deprecated. https://api.drupal.org/api/drupal/core%21includes%21file.inc/8.6.x . Can you please have a look on it. So I think this is why the setgid bit doesn't work proerly?
Comment: Does it? I thought most core code was using the service. Regardless, you can invalidate your own conclusion by just reading the code in `drupal_mkdir`