greenplum hang forever when doing any search or insert actions with psql and centos7

Question: greenplum version is 5.3.0  centos 7
As title,
The following is  result of gplogfilter
<code>SELECT pg_catalog.quote_ident(n.nspname) || '.' FROM pg_catalog.pg_namespace n WHERE substring(pg_catalog.quote_ident(n.nspname) || '.',1,7)='test_vb' AND (SELECT pg_catalog.count(*) FROM pg_catalog.pg_namespace WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,7) = substring('test_vb',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) > 1
UNION
SELECT pg_catalog.quote_ident(n.nspname) || '.' || pg_catalog.quote_ident(c.relname) FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n WHERE c.relnamespace = n.oid AND c.relkind IN ('r', 'S', 'v' , 'x') AND substring(pg_catalog.quote_ident(n.nspname) || '.' || pg_catalog.quote_ident(c.relname),1,7)='test_vb' AND substring(pg_catalog.quote_ident(n.nspname) || '.',1,7) = substring('test_vb',1,pg_catalog.length(pg_catalog.quote_ident(n.nspname))+1) AND (SELECT pg_catalog.count(*) FROM pg_catalog.pg_namespace WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,7) = substring('test_vb',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) = 1
LIMIT 1000|0||postgres.c|1629|
2018-01-02 12:21:20.685964 UTC|||p20871|th-636074112||||0|||seg-1|||||LOG: |00000|3rd party error log:
Unexpected exception reached top of execution stack: major=200 minor=14 file=CTranslatorUtils.cpp line=162||||||||SysLoggerMain|syslogger.c|633|
2018-01-02 12:21:20.686005 UTC|gpadmin|testdb|p21604|th-636074112|[local]||2018-01-02 12:13:41 UTC|0|con8|cmd4|seg-1||dx22||sx1|LOG: |00000|Planner produced plan :0||||||SELECT pg_catalog.quote_ident(c.relname) FROM pg_catalog.pg_class c WHERE c.relkind IN ('r', 'S', 'v' , 'x') AND substring(pg_catalog.quote_ident(c.relname),1,7)='test_vb' AND pg_catalog.pg_table_is_visible(c.oid) AND c.relnamespace <> (SELECT oid FROM pg_catalog.pg_namespace WHERE nspname = 'pg_catalog')
UNION
SELECT pg_catalog.quote_ident(n.nspname) || '.' FROM pg_catalog.pg_namespace n WHERE substring(pg_catalog.quote_ident(n.nspname) || '.',1,7)='test_vb' AND (SELECT pg_catalog.count(*) FROM pg_catalog.pg_namespace WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,7) = substring('test_vb',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) > 1
UNION
SELECT pg_catalog.quote_ident(n.nspname) || '.' || pg_catalog.quote_ident(c.relname) FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n WHERE c.relnamespace = n.oid AND c.relkind IN ('r', 'S', 'v' , 'x') AND substring(pg_catalog.quote_ident(n.nspname) || '.' || pg_catalog.quote_ident(c.relname),1,7)='test_vb' AND substring(pg_catalog.quote_ident(n.nspname) || '.',1,7) = substring('test_vb',1,pg_catalog.length(pg_catalog.quote_ident(n.nspname))+1) AND (SELECT pg_catalog.count(*) FROM pg_catalog.pg_namespace WHERE substring(pg_catalog.quote_ident(nspname) || '.',1,7) = substring('test_vb',1,pg_catalog.length(pg_catalog.quote_ident(nspname))+1)) = 1
LIMIT 1000|0||orca.c|60|
2018-01-02 12:21:22.351554 UTC|gpadmin|testdb|p21604|th-636074112|[local]||2018-01-02 12:13:41 UTC|0|con8|cmd6|seg-1||dx23||sx1|LOG: |00000|statement: SELECT * FROM test_vb;||||||SELECT * FROM test_vb;|0||postgres.c|1629|
       in:      77 lines; timestamps from 2018-01-02 11:31:19.698317 to 2018-01-02 12:21:22.351554
      out:      77 lines; timestamps from 2018-01-02 11:31:19.698317 to 2018-01-02 12:21:22.351554
----------  /data/master/gpseg-1/pg_log/gp_era ----------
# Greenplum Database era.
# Do not change the contents of this file.
era = 27c9a01176c70c2c_180102113109
       in:       3 lines; no timestamps found
      out:       3 lines
</code>
Comment: You should probably add if this is open source or not.  Describe the nodes, segments per host, other activity, etc.  Have you analyzed the catalog yet?  Or ran reindex on the catalog?
Answer: Which version of CentOS 7 are you using?   There are known problems with RHEL/CentOS 7.0-7.2 (see Greenplum release notes).  You should be using 7.3 or 7.4 - there were kernel problems in the early version 7 of the OS that were fixed in 7.3/4.
Jim McCann
Pivotal
Comment: I found the reason:  packets lose unexpectedly .  I set gp_interconnect_type tcp, it works, but I don't know why packets lose.
Comment: CentOS Linux release 7.4.1708 (Core)
Linux tp-gpdb-ku02.novalocal 3.10.0-693.11.1.el7.x86_64
Comment: p.s. I don't have firewall,standby host, and mirror doesn't be set yet.
Comment: Even I reinstall greenplum, it has the same problem
Comment: 1 master and 3 segments with 4CPU/8G/100G
Comment: The database is new-build, and the occupied space of memory and disk are low
Comment: After hours of waiting it produces error
ERROR:  Interconnect encountered a network error, please check your network  (seg0 slice1 172.21.140.46:40000 pid=14733)
DETAIL:  Failed to send packet (seq 1) to 172.21.140.17:2938 (pid 1465 cid -1) after 3577 retries in 3600 seconds
CONTEXT:  SQL statement "select sum(gp_statistics_estimate_reltuples_relpages_oid(c.oid))::float4[] from gp_dist_random('pg_class') c where c.oid=16387"
Answer: Greenplum uses TCP connection when starting to active database and tell Segments the address of Master and other operations on database are with UDP connection and master address is got from prior TCP connection.  The problem is that the segment only get the modified address of master and try to send messages to modified address if master uses NAT method. Then one of the solve method is to tell segment the address when master send queries by modifying the value of proc->listenerAddr   in source code.
Answer: I was also facing same issue while selecting and inserting but Teddy's last comment worked for me i.e. enable UDP protocol for all hosts (master as well segment).
So for greenplum few protocol needs to be enable TCP, UDP, SSH, ICMP.


Why are the cut-offs used for Bayes factors and p-values so different?

Question: I am trying to understand Bayes Factor (BF). I believe they are like likelihood ratio of 2 hypotheses. So if BF is 5, it means H1 is 5 times more likely than H0. And value of 3-10 indicates moderate evidence, while >10 indicates strong evidence.
However, for P-value, traditionally 0.05 is taken as cut-off. At this P value, H1/H0 likelihood ratio should be about 95/5 or 19.
So why a cut-off of >3 is taken for BF while a cut-off of >19 is taken for P values? These values are not anywhere close either.
Comment: I am uncomfortable with saying "if BF is $5$, it means $H_1$ is $5$ times more likely than $H_0$".  The Bayes factor may be a marginal likelihood ratio, but it is not a probability ratio or odds ratio, and needs to be combined with a prior to be useful
Comment: If we do not have any particular prior information, then what can we say about meaning of BF?
Comment: Certainly, one has "some" prior information even if saying that there is no any particular prior info. Namely, in that case it's reasonable to assign equal probabilities to each hypothesis according to the principle of indifference. That is a simple example of a so called non-informative prior (admittedly a misnomer).
Comment: In this case will BF of 5 indicate one hypothesis to be 5x more likely?
Comment: Yes, but this problem is much more complicated than it might seem and goes into the area of model selection in statistics. You've been warned :))
Answer: A few things:
The BF gives you evidence in favor of a hypothesis, while a frequentist hypothesis test gives you evidence against a (null) hypothesis. So it's kind of "apples to oranges."
These two procedures, despite the difference in interpretations, may lead to different decisions. For example, a BF might reject while a frequentist hypothesis test doesn't, or vice versa. This problem is often referred to as the Jeffreys-Lindley's paradox. There have been many posts on this site about this; see e.g. here, and here.
"At this P value, H1/H0 likelihood should be 95/5 or 19." No, this isn't true because, roughly $p(y \mid H_1) \neq 1- p(y \mid H_0)$. Computing a p-value and performing a frequentist test, at a minimum, does not require you to have any idea about $p(y \mid H_1)$. Also, p-values are often integrals/sums of densities/pmfs, while a BF doesn't integrate over the data sample space.
Comment: Taylor is saying the threshold for evidence *against* one hypothesis ($\text{H}_0$) can't be directly compared to the threshold of evidence *for* another hypothesis ($\text{H}_1$), also not approximately. When you stop believing in a null-effect need not relate to when you *start* believing in an alternative. This is exactly why the $p$-value shouldn't be interpreted as $1 - (\text{belief in H}_1)$
Comment: Sorry, last comment: The reason you can't see it as evidence in favor of $\text{H}_1$ is that it is the chance of observing this large an effect size *if* $\text{H}_0$ were true. If $\text{H}_0$ is indeed true, the $p$-value should be uniformly random, so its value has no meaning on the probability of $\text{H}_1$. This subtlety in interpretation is by the way one of the reasons $p$-values see so much misuse.
Comment: Maybe this can be clarifying: https://en.wikipedia.org/wiki/Misunderstandings_of_p-values The frequentist $p$-value is not a measure of evidence *for* anything.
Comment: @benxyzzy: the distribution of a $p$-value is only uniform under the null hypothesis, not under the alternative where it is heavily skewed towards zero.
Comment: @benxyzzy To add to others: The point of using a $p$-value is that under null hypothesis it is uniformly random, so if you get a very small $p$-value, it hints that maybe it wasn't uniformly random so maybe the null hypothesis wasn't true.
Comment: @Xi'an and JiK, this is quite the revelation, thank you! I always felt the p value to be some statement of derived fact, like the sample mean, but this conception makes it sound more like the assessment of a distribution (of p's) from a single observation of "the p random variable". That does explain a lot of hitherto disparate facts about p value hypothesis testing, like why one should only speak of being over/under threshold (lower p != 'more important'). But then by similar token why are any such statements about specific p values meaningful, e.g. "it's the chance of getting this large..."?
Comment: What would you say is approximate Bayes Factor value corresponding to P=0.05?
Comment: If there are only 2 hypotheses, can't we take evidence `against one` as evidence `in favor of the other`?
Comment: How can a p value say something meaningful while being uniformly random? Let's say I compute a p value and it tells me the chance of getting this large an effect given the null is true. What then do you mean by p values being "uniformly random"? That this currently computed p value was as likely to be computed as any other? Then in what sense does it say anything about anything?
Comment: @benxyzzy it is not clear if you are in favor of P-value or against it.
Comment: @mso presumably the question can be answered irrespectively? I am asking for clarification from Frans Rodenburg as to this 'uniformly random' property of p values, which I have come across before but not understood as per the above.
Answer: The Bayes factor $B_{01}$ can be turned into a probability under equal weights as
$$P_{01}=\frac{1}{1+\frac{1}{\large B_{01}}}$$but this does not make them comparable with a $p$-value since

$P_{01}$ is a probability in the parameter space, not in the sampling space
its value and range depend on the choice of the prior measure, they are thus relative rather than absolute (and Taylor's mention of the Lindley-Jeffreys paradox is appropriate at this stage)
both $B_{01}$ and $P_{01}$ contain a penalty for complexity (Occam's razor) by integrating out over the parameter space

If you wish to consider a Bayesian equivalent to the $p$-value, the posterior predictive $p$-value (Meng, 1994) should be investigated
$$Q_{01}=\mathbb P(B_{01}(X)\le B_{01}(x^\text{obs}))$$
where $x^\text{obs}$ denotes the observation and $X$ is distributed from the posterior predictive
$$X\sim \int_\Theta f(x|\theta) \pi(\theta|x^\text{obs})\,\text{d}\theta$$
but this does not imply that the same "default" criteria for rejection and significance should apply to this object.
Comment: Using your formula, P for BF of 3 and 10 come out to be 0.75 and 0.91, respectively. Why should we accept these as moderate evidence since for P value we keep cut-off of 0.95 ?
Comment: Why is $0.95$ relevant in this framework? or at all? Deciding when large is large enough depends on your utility function.
Comment: The formula looks simpler as `P = B/(B+1)`
Answer: Some of your confusion might stem from taking the number 95/5 directly from the fact that the p value is 0.05 - is this what you are doing? I do not believe this is correct. The p value for a t-test, for example, reflects the chance of getting the observed difference between means or a more extreme difference if the null hypothesis is in fact true. If you get a p value of 0.02, you say 'ah, there is only a 2% chance of getting a difference like this, or a greater difference, if the null is true. That seems very improbable, so I propose that the null is not true!'. These numbers are just not the same thing that goes into the Bayes factor, which is the ratio of the posterior probabilities given to each competing hypothesis. These posterior probabilities are not computed in the same way as the p-value, and so thinking of 95/5 as being like posterior probabilities that would give a BF of 19 is not correct.
As a side note, I would suggest strongly guarding against thinking of different BF values as meaning particular things. These assignments are completely arbitrary, just like the .05 significance level. Problems such as p-hacking will occur just as readily with Bayes Factors if people start to believe that only particular numbers warrant consideration. Try to understand them for what they are, which are something like relative probabilities, and use your own sense to determine whether you find a BF number convincing evidence or not.


How to transform data to normality?

Question: We have financial some data (500-1000 samples), which is not normally distributed (well known fact from the literature). I have some ideas to do parametric transformations of this data (using some other data) to produce "adjusted" series. My goal is to find a transformation that makes the series normally distributed (with mean 0 and std deviation 1). What is the most appropriate statistic and corresponding test to optimize my parameters and determine if the outcome can be considered normally distributed?
Please also point me to an implementation, ideally in C/C++ or java.
Comment: Your transformation would need to be a bit weird in that it would need to pull the tails in -- preferably in a smooth way.  But I'm not convinced of the advantage.  What are you doing that you think you need a normal distribution?
Comment: Your question leaves me unclear.  You say you have financial data and refer to them as a "series".  Are you doing time series analysis, and want a procedure and test to achieve stationarity?  That's not quite the same as what you seem to be asking, and while you would need to get a stationary time series, as @PatrickBurns notes, it wouldn't necessarily need to be normally distributed.
Comment: Regarding transformations, there is a very trivial one that will make your data exactly standard normal.  You simply map the order statistics of your sample to standard normal quantiles.  I highly doubt you'd want to do this though, as it loses a lot of information and doesn't really accomplish anything.
Answer: For financial data I have successfully used heavy-tail Lambert W x Gaussian transformations.

Pyhon: gaussianize is an sklearn-type implementation of the IGMM algorithm in Python.
C++: the lamW R package has an elegant (and fast) C++ implementation of Lambert's W function.  This can be a starting point for a full C++ implementation of IGMM or MLE for Lambert W x Gaussian transformations.
R: the LambertW R package is a full implementation of the Lambert W x F framework (simulation, estimation, plotting, transformation, testing).

As an illustration consider the SP500 return series in R.
library(MASS)
data(SP500)
yy <- ts(SP500)
library(LambertW)
test_norm(yy)

## $seed
## [1] 516797
##
## $shapiro.wilk
##
##  Shapiro-Wilk normality test
##
## data:  data.test
## W = 1, p-value <2e-16
##
##
## $shapiro.francia
##
##  Shapiro-Francia normality test
##
## data:  data.test
## W = 1, p-value <2e-16
##
##
## $anderson.darling
##
##  Anderson-Darling normality test
##
## data:  data
## A = 20, p-value <2e-16

As is well-known, financial data typically have fat tails and are sometimes negatively skewed.  For the SP500 case, skewness is not too large, but it exhibits high kurtosis (7.7).  Also several normality tests clearly reject the null hypothesis of a marginal Gaussian distribution.
Since we only have to deal with heavy tails, but not skewness, let's fit a heavy-tailed Lambert W x Gaussian distribution using a method of moments estimator (one could also use the maximum likelihood estimator (MLE) with MLE_LambertW()).
# fit a heavy tailed Lambert W x Gaussian
mod <- IGMM(yy, type = "h")
mod

## Call: IGMM(y = yy, type = "h")
## Estimation method:  IGMM
## Input distribution:  Any distribution with finite mean & variance and kurtosis = 3.
## mean-variance Lambert W x F type ('h' same tails; 'hh' different tails; 's' skewed):  h
##
##  Parameter estimates:
##    mu_x sigma_x   delta
##    0.05    0.72    0.16
##
##  Obtained after 4 iterations.

The heavy tail parameter $\widehat{\delta} = 0.16$ is significantly different from zero and implies heavy tails.  For such a $\delta$ moments up to order $1 / \widehat{\delta} = 6.29$ exist.
The model check question is of course if the back-transformed data does indeed have a Gaussian distribution.  Let's check again using test_norm():
# transform data to input data (which presumably should have Normal distribution); use return.u = TRUE to get zero-mean, unit variance data
xx <- get_input(mod, return.u = FALSE)
test_norm(xx)

## $seed
## [1] 268951
##
## $shapiro.wilk
##
##  Shapiro-Wilk normality test
##
## data:  data.test
## W = 1, p-value = 0.2
##
##
## $shapiro.francia
##
##  Shapiro-Francia normality test
##
## data:  data.test
## W = 1, p-value = 0.2
##
##
## $anderson.darling
##
##  Anderson-Darling normality test
##
## data:  data
## A = 0.7, p-value = 0.07

I think the plot and normality test results speak for themselves.
The package also provides a single function that does all these steps at once: Gaussianize() (this is also what the Python package implements).
Comment: It appears to me that the graph of your transformed data speaks volumes suggesting  non-normality as the variance is clearly non-constant. Secondly your emphasis should be on generating a model which delivers normal errors as all the assumptions are about the errors not the deviations of observed values from a mean. Fat tails are easily handled by Intervention Detection flagging unusual i,e, non-predictable values.
Comment: My example is just a direct response to OPs question on how to transform data to something that's Normal.  OP also mentioned he is working with financial data, so I used the SP500 example to illustrate the marginal distribution transformation.  It is well known that financial data are not iid, but heteroskedastic and you can also fit a GARCH or SV type model to it to obtain (approx) normally distributed residuals.  However, that was not what the OP was asking for -- so I didn't elaborate on this time series model fitting exercise.  But in principle you are right.
Answer: It appears that you are just asking for a test for normality.  If so, Shapiro-Wilk is hard to beat.  This is not, however, the easiest test in the pantheon to implement.
Why not just use R?  The shapiro.test function will do the work for you.
Comment: the original poster is asking about how to transform data to normality, not how to test for normality.
Comment: @Macro - "What is the most appropriate statistic and corresponding test to optimize my parameters and determine if the outcome can be considered normally distributed?"  This isn't quite asking how to do the transform, it's instead asking how to evaluate whether the transform is effective, i.e., (in this case) a statistic and corresponding test for normality.
Comment: I don't know R :( And I have to do quite a lot of other computations in this program.
Comment: @Grzenio - I'll try to pull something together for you later today, probably in C/C++.

How to transform data to normality?


override view Use administration toolbar

Question: i have a view that using administration toolbar. Problemis theme suggestion is not showing the template names that should override the template. i guess because its using the administration toolbar .. What i am trying to acheive is showing the whole comment body, when the edit link is clicked
 , instead of going to an other page. How can i force drupal to show suggestion view templates. And is there a better idea.
Comment: Template suggestions will only ever be available for the current theme. You'll need to create a subtheme of your admin theme, and create them there
Answer: I found out that  i need to do a custom module then do theme hook suggestion.
<code>function my_module_theme($existing, $type, $theme, $path) {
    return array(
    'views_view__comments'=> [
        'template' => 'views/views-view--comments',
    ]);
 }
</code>
And then template in yout admin theme , or in your custom module. In my case in module forlder templates/view.


Different Sets of "K-up" Numbers

Question: Recently I stumbled across a problem that is as follows:

Is it possible to find a number K such that there is a three-digit number that is K times the sum of its digits (a K-up number)?

I started by writing an equation:
$100a+10b+c=k(a+b+c)$
However, I couldn't find any relation between a, b, and c, or what will happen to them as k changes.
According to the given solution, there are 180 three-digit numbers that follow this rule. However, they are separated into different sets of numbers when K= a different number each time. For example, when
$K=37$:
$111=37(1+1+1)$
$222=37(2+2+2)$
$333=37(3+3+3)$
$...$
$999=37(9+9+9)$
There are 9 three-digit numbers that qualify when K=37, and $a=b=c$ (the three digits of the number)
Therefore, when K=37,
$a=\frac{3b}{7}+\frac{4c}{7}$
$b=\frac{7a}{3}+\frac{4b}{3}$
$c=\frac{7a}{4}+\frac{3c}{4}$
It may be time consuming to find one of these number by just randomly coming up with a number for K and another one for either a, b, or c.
My question is:

Is there a general rule for all values of K?
Is there a specific relationship between the digits a, b, and c as K changes?
Comment: Your equations for $b,c$ under Therefore, when $K=37$ are not correct.  I would be surprised if there was anything better than search for this.  There are only $900$ numbers to check-just divide $\frac {100a+10b+c}{a+b+c}$ and see if it comes out whole.  You could do some pruning by considering divisibility, but it is probably not worth it.
Comment: Please provide a link to this problem and its solution; ideally, summarize the list of families of numbers, so that your question is self-contained. Perhaps someone can discern a pattern just from viewing those families, without having to do a full analysis.
Answer: Not really an answer, but data.
Below is a complete list of three-digit "$k$-up" numbers (that is, numbers that when divided by the sum of their digits, yield $k$), sorted by $k$. If there's an overall pattern, I don't see it. (Note that the $37$-up numbers include more than the multiples of $111$.)
$$\begin{array}{c:l}
k \\
\hline
11 & 198 \\ \hline
12 & 108 \\ \hline
13 & 117, 156, 195 \\ \hline
14 & 126 \\ \hline
15 & 135 \\ \hline
16 & 144, 192, 288 \\ \hline
17 & 153 \\ \hline
18 & 162 \\ \hline
19 & 114, 133, 152, 171, 190, 209, 228, 247, 266, 285, 399 \\ \hline
20 & 180 \\ \hline
21 & 378 \\ \hline
22 & 132, 264, 396 \\  \hline
23 & 207 \\ \hline
24 & 216 \\ \hline
25 & 150, 225, 375 \\ \hline
26 & 234, 468 \\ \hline
27 & 243, 486 \\ \hline
28 & 112, 140, 224, 252, 280, 308, 336, 364, 392, 448, 476, 588 \\ \hline
29 & 261 \\ \hline
30 & 270 \\ \hline
31 & 372, 465, 558 \\ \hline
32 & 576 \\ \hline
33 & 594 \\ \hline
34 & 102, 204, 306, 408 \\ \hline
35 & 315 \\ \hline
36 & 324, 648 \\ \hline
37 & 111, 222, 333, 370, 407, 444, 481, 518, 555, 592, 629, 666, 777, 888,
  999 \\ \hline
38 & 342, 684 \\ \hline
39 & 351 \\ \hline
40 & 120, 240, 360, 480 \\ \hline
41 & 738 \\ \hline
42 & 756 \\ \hline
43 & 516, 645, 774 \\ \hline
44 & 792 \\ \hline
45 & 405 \\ \hline
46 & 230, 322, 414, 460, 506, 552, 644, 690, 736, 782, 828, 874, 966 \\ \hline
47 & 423, 846 \\ \hline
48 & 432, 864 \\ \hline
49 & 441, 735, 882 \\ \hline
50 & 450 \\ \hline
51 & 918 \\ \hline
52 & 312, 624, 780, 936 \\ \hline
53 & 954 \\ \hline
54 & 972 \\ \hline
55 & 110, 220, 330, 440, 550, 605, 660, 715, 770, 825, 880, 935, 990 \\ \hline
56 & 504 \\ \hline
57 & 513 \\ \hline
58 & 522, 870 \\ \hline
59 & 531 \\ \hline
60 & 540 \\  \hline
61 & 732, 915 \\ \hline
64 & 320, 512, 640, 704, 832, 960 \\ \hline
67 & 201, 402, 603, 804 \\ \hline
68 & 612 \\ \hline
69 & 621 \\ \hline
70 & 210, 420, 630, 840 \\ \hline
73 & 511, 730, 803 \\ \hline
76 & 912 \\ \hline
78 & 702 \\ \hline
79 & 711 \\ \hline
80 & 720 \\ \hline
82 & 410, 820, 902 \\ \hline
85 & 510 \\ \hline
89 & 801 \\ \hline
90 & 810 \\ \hline
91 & 910 \\ \hline
100 & 100, 200, 300, 400, 500, 600, 700, 800, 900 \\ \hline
\end{array}$$

Different Sets of "K-up" Numbers


Basic easy rules for statistics

Question: In a binomial experiment, if we observe $x=0$ positive individual among $n$ individuals, then the proportion of positive individuals is significantly lower than $3/n$ with a type 1 error less than and very close to $5\%$. This fact, sometimes called the "rule of three", is a consequence of the inequalities $$\exp\left(-\frac{np}{1-p}\right) \leq \Pr(X=0) \leq \exp(-np).$$
Do you know other such basic easy rules for statistics? I find them very interesting and useful. This principle is not really a "rule of thumb" because it has a reliable theoretical foundation, but I don't see another tag for this question (I hope it is not off-topic)
Comment: "Normally, more than two-thirds of the people are average" (meaning within one standard deviation of the mean)?
Comment: One very simple one that comes to mind is how the variance of a sample proportion of successes out of $n$ Bernoulli trials is no more than $1/4n$ (which is achieved when the success probability is $1/2$)
Comment: Many "rules of thumb" are based on theoretically rigorous analyses or approximations.
Answer: Check out Gerald van Belle's book "Statistical Rules of Thumb" a very nice little paperback text loaded with examples of rules of thumb and explanations including the "Rule of three" that you mention above.
Comment: http://stats.stackexchange.com/questions/2715/rules-of-thumb-for-modern-statistics?rq=1
Comment: (+1) That seems like a nice book. Not only does he give rule-of-thumbs, but he also motivates them and discuss their validity.
Comment: Nice! I will ask to my boss to buy it :)
Comment: Ahah ! I've just send an email to my boss and actually we already have this book :)
Comment: Yes, it's a great book.  It's fun just to read it.
Comment: So Stephane.  It looks like someone else knowing about the book asked this question and got a variety of answers.

Basic easy rules for statistics


Find the value of : $\lim_{n\to\infty}\prod_{k=1}^n\cos\left(\frac{ka}{n\sqrt{n}}\right)$

Question: Find the limit (where a is a constant)
$\lim_{n\to\infty}\prod_{k=1}^n\cos\left(\frac{ka}{n\sqrt{n}}\right)$
I think the answer is $1-a^2/6$
Answer: Let $$f(n) = \prod_{k=1}^n \cos \left(\dfrac{ka}{n \sqrt{n}}\right)$$
$$g(n) = \log (f(n)) = \sum_{k=1}^{n} \log \left(\cos \left(\dfrac{ka}{n \sqrt{n}}\right) \right) = \sum_{k=1}^{n} \log \left(1 - \dfrac{\left(\dfrac{ka}{n \sqrt{n}}\right)^2}2 +  \mathcal{O} \left( \dfrac{k^4}{n^6}\right)\right)$$
$$\log \left(1 - \dfrac{\left(\dfrac{ka}{n \sqrt{n}}\right)^2}2 +  \mathcal{O} \left( \dfrac{k^4}{n^6}\right)\right) = -\left(\dfrac{\left(\dfrac{ka}{n \sqrt{n}}\right)^2}2 +  \mathcal{O} \left( \dfrac{k^4}{n^6}\right)\right) + \mathcal{O} \left(\dfrac{k^4}{n^6} \right)$$
$$\sum_{k=1}^{n} \log \left(1 - \dfrac{\left(\dfrac{ka}{n \sqrt{n}}\right)^2}2 +  \mathcal{O} \left( \dfrac{k^4}{n^6}\right)\right) = \sum_{k=1}^{n} \left( -\dfrac{\left(\dfrac{ka}{n \sqrt{n}}\right)^2}2 +  \mathcal{O} \left( \dfrac{k^4}{n^6}\right)\right)\\ = -\dfrac{a^2}{2n^3} \dfrac{n(n+1)(2n+1)}{6} + \mathcal{O}(1/n)$$
$$\lim_{n \to \infty }\sum_{k=1}^{n} \log \left(1 - \dfrac{\left(\dfrac{ka}{n \sqrt{n}}\right)^2}2 +  \mathcal{O} \left( \dfrac{k^4}{n^6}\right)\right) = -\dfrac{a^2}{6}$$
Hence, $$\prod_{k=1}^{\infty} \cos \left(\dfrac{ka}{n \sqrt{n}}\right) = \exp(-a^2/6)$$
The solution you have $1-a^2/6$ is a first order approximation to $\exp(-a^2/6)$ since $$\exp(x) = 1 + x + \mathcal{O}(x^2)$$
Comment: My argument is similar (and I hope a little cleaner) (+1)
Comment: @robjohn Actually, I do not see a difference between your answer and mine. :)
Comment: I had not read yours before writing up mine. Sorry.


$A^TJA = J$ $ \rightarrow \det(A) = 1$

Question: Why is this true? I cant seem to understand why the $\det(A) = 1$ for this to hold?
Comment: Before dealing with matrices, try scalars. If $a^2 j = j$ then we can have $a = \pm 1$. So it cannot be true for matrices.
Comment: What is $J$? If $J$ is a non-singular skew-symmetric matrix then one can indeed show that $\det A=1$.
Answer: It is not indeed the case. We might have $$\det (A)=-1$$ since $$\det(A^TJA)=\det(J)$$yields to $$\det(A^T)\det(J)\det(A)=\det(J)$$and if $J$ is invertible (i.e. the determinant is non-zero) we conclude $$\det(A)^2=1$$if $J$ is singuler ($\det(J)=0$) we cannot determine $\det (A)$
Comment: Thats what i thought, thank you
Comment: You're welcome. Good luck!
Answer: I assume the matrices are over the real numbers.

In general, $\det J$ can be anything.
If $J$ is invertible, then one can show that $\det A = \pm 1$ (see for example the answer by MostafaAyaz)
If $J$ is invertible and antisymmetric with $J= -J^T$, then one can show that $\det A =1$. The proof of this fact is not completely elementary as it involves the Pfaffian with $$\operatorname{Pf}(A^T J A) = \det(A) \operatorname{Pf}( J) \,.$$
As $A^T J A =J$ and $J$ is not singular, we follow $\det A=1$.
Answer: It is not true in all cases. The determinant is multiplicative, , and $\det \vphantom{A}^{\mathrm t\mkern -5mu}A=\det A$, so
$$\det(\vphantom{A}^{\mathrm t\mkern -5mu}AJA)=(\det A)^2\det J$$
and if it is equal to $\det J$ and $\det J\ne 0$, you can deduce $\det A=\pm1$.
Answer: We assume $\det A >0$
The multiplicative property of determinant implies $$ \det A^T JA =(\det A)^2 \det J =\det J$$
You may cancel $\det J $ and the result follows. We are also-assuming that $\det J \ne 0$
Answer: It is not true in full generality. For instance, if you are dealing with $1×1$ matrices, then matrix multiplication boils down to ordinary multiplication and the equation would be $A\cdot A\cdot J = J$, so assuming we are working over the rationals (though this can be generalized), we have $J=0$ or $A=1$ or $A=-1$.
In fact, this example can be generalized by applying the determinant to both sides of the equation and noting that $\det (A^T)=\det(A)$. This gives $\det(A)^2 \times \det(J) = \det(J)$, so if $\det(J)$ is not zero, then $\det(A)=1$ or $\det(A)=-1$.

$A^TJA = J$ $ \rightarrow \det(A) = 1$


looking for free source safe for visual web developer express 2008

Question: I am using visual web developer express 2008 for one of my personal projects. I am looking for a source safe or similar product that is free and that can integrate with visual web developer 2008. Please let me know if you know any products.
Thanks,
sridhar.
Comment: Lots of suggestions here: http://stackoverflow.com/questions/566595/best-subversion-tool-when-using-visual-studio-express
Answer: As far as I know, extension points allowing for such integration are unavailable in VWD. That's the price for using free Express version...
In your place I would use Subversion and Tortoise SVN, which is quite convenient, even though you'll need to manage your source control in Explorer windows, not in VWD. For some time I was working in a such way even using full VS.NET
Good luck :)
Answer: There's simply nothing better then Subversion.
Take a look at the article on how to set it up and integrate with Visual Web Developer Express 2008
Subversion with Visual Studio 2008
Comment: I agree. Subversion i widely used among larger companies as well.
Comment: Unless you agree with Linus Torvalds and think Git is The Bomb.
Comment: It's a bit complicated to use git on windows though.


Inner product and polynomials

Question:
Let $V = \mathcal{P}_2$ (vector space of polynomials of degree not greater than two). We define the inner product on this space according to the formula
  $$\langle \mathbf{p}, \mathbf{q}\rangle = \int_{-1}^1 \mathbf{p}\mathbf{q} \, \mathrm{d}x.$$
  Also consider the following two particular vectors
  $$\mathbf{p} = 1 - x + 4x^2, \mathbf{q} = 1 + 4x - 3x^2.$$
  The following questions are related to these vectors and the space
a) Calculuate the inner product $\langle \mathbf{p}, \mathbf{q}\rangle$.
b) Calculate the distance between $\mathbf{p}$ and $\mathbf{q}$.
c) Calculate the norm $\|\mathbf{q}\|$, of the vector $\mathbf{q}$.

a) Am I correct in saying that the inner product $\langle p,q \rangle$ is $-24/5$?
b) Does the distance need to be a single number or an equation? For example $7x^2-5x$?
c) Again, I am not sure if this is right. Would $\|q\|$ be $26$?
Comment: The best way to learn MathJax is to click "Edit" on a post where the form is as you would like to write it yourself (for example the answer from Fred). Then you see the right syntax and can write it easier yourself later.
Comment: Hi Twigleg. Welcome to MSE! Thank you for trying to learn MathJax. Since you were struggling, I've formatted your question (and you can get the next one). As Nurator says, clicking "edit" (or "improve this question/answer") will allow you to play around with the Mathjax code used in questions and answers. Have a look at the particular commands I've used, and try playing around with them. Good luck!
Comment: P.S. braces { } are for grouping things in MathJax. For example `$x^{10}$` produces $x^{10}$, whereas `$x^10$` produces $x^10$. If you actually want braces, use `$\{ \}$`, which produces $\{ \}$.
Comment: Thank you, I replied to Fred and was able to modify my reply to use MathJax. I still think it will take me some time to get my head around it.
Answer: a) You are correct.
b) The distance is given by $||p-q||= \sqrt{<p-q,p-q>}= (\int_{-1}^1 (p(x)-q(x))^2dx)^{1/2}.$
c) $||q||= \sqrt{<q,q>}= (\int_{-1}^1 q(x)^2 dx)^{1/2}.$
Comment: I had a look through what you said,
so is b) $\sqrt{544/15}$?
and c) is $\sqrt{184/15}$?

Inner product and polynomials


Website is down for 5 minutes every couple of days

Question: I am working on a website https://devsdata.com/. It is hosted on the Google Cloud Platform. We are using "Better Uptime" to monitor its health and every couple of days we receive an incident alert stating that the website is down. After being down for 4-5 minutes it then goes live back again without any work required. What could be the reason for this? Should I look into DNS? The server has enough free space to operate normally and CPU/RAM is more than enough for our typical load. It is a WordPress website created from the Openlitespeed Google Cloud package.
Comment: Does each outage occur at the same time of day?
Comment: @ceejayoz no, it doesn't. It occurred on 18, 25, 26, and 29 of September at 8:44 PM, 5:57 PM, 4:55 AM, and 9:33 PM respectively.
Comment: You'll want to consult your access and error logs around those times, then. Perhaps it's a badly configured crawler/scraper accessing the site or something.
Comment: @NikitaGrygoriev you mentioned that your website is hosted in GCP, Could you let us know what Machine type your are using in your VM Instance? did you use a deployment to create your Wordpress site?  Also, have you checked the logs for your instance on the [Logs Viewer page](https://cloud.google.com/logging/docs/view/overview) please share with us as much information as possible
Comment: @JoseLuisDelgadillo machine type is n1-standard-4 (4 vCPUs, 15 GB memory). Yes, I have used a deployment to create it (openlitespeed-wordpress deployment). The problem with logs is that the machine does not create any at the time the downtime occurs. The only log from the latest downtime is 12 hours off and as for the downtime on September 26th, there are no logs for that date at all.
Answer: If you want to discard the DNS issues, start monitoring the IP instead of the domain.
If you are monitoring the domain instead of the IP you are not monitoring directly the Instance, and there could be a lot of factors involved.
Also, it seems that the only way to monitor that has Better Uptime is through ping, and maybe port scanning but I'm not sure, they are not clear on how it works.
Additionally,  I consider that you could take a look at this page: Creating an uptime check it explains how to create and configure uptime checks.
You could create an uptime check to corroborate if your site is down.
I think it is a good idea to monitor the instance inside in order to compare the information you are receiving from Better Uptime with the information from your instance.
Comment: So I have created an uptime check as you recommended and have received an alert:

Failure of uptime check_id devsdata-website-uptime-check
Violates when: Any monitoring.googleapis.com/uptime_check/check_passed stream is above a threshold of 1 for greater than 1 minute

I did not manage to visit my website while this alert was taking place, but about 1 minute after receiving this alert the website was working perfectly.
Comment: Could you connect the events from your tool with your web server logs? It is not clear if your website is down, or if another factor is getting involved for example it could be a problem in the DB, or a plugin from Wordpress, that makes a status different to OK, Additionally, you could check your Uptime-check policy, it might not be adjusted correctly, you can take a look at this example: https://cloud.google.com/monitoring/alerts/policies-in-json#json-uptime.
Comment: These are the configurations of the uptime check:
Check Type HTTPS
SSL Validation Disabled
Path /
Port 443
Check Every 60s
Timeout 10s
Regions Global
And here are the logs for when the uptime check failed:
https://pastebin.pl/view/680bdefd
Could you take a look at it?
Comment: Did you match the information from your Uptime Check with the logs in your instance or with the information provided by Better Uptime?, I think it could be a good idea to have all the information in order to determine what could be the issue.
Another option is to [View the serial port](https://cloud.google.com/compute/docs/instances/viewing-serial-port-output) one output to get more information about what is happening in your instance at the moment of the issue.
Comment: Also, if you have a Free trial account you can have chat support through  [Console Support Center](https://console.cloud.google.com/support/chat?_ga=2.201203500.305402083.1598273128-638966553.1591892739), also, you can visit the following [link](https://cloud.google.com/support) for more information.


Is relationship of orthonormality & orthogonality equivalent to that of squares & rectangles?

Question: To confirm my analogy, I am asking if I can consider every orthonormal basis to be an orthogonal one (but not vv) in the same sense that every square is a rectangle (but not vv).
I believe the answer to be yes bc the only difference between an orthonormal basis & its orthogonal variation is that the former's columns are normalized. So in that sense, if someone were to ask a q of the following form...
Find an orthogonal basis for the column space of $A = \left[\begin{array}{ccc}
 1 & 0 & 0 \\
 1 & 4 & 0 \\
 1 & 4 & 6 \\
 1 & 4 & 6
\end{array}\right]$.
Then, I (technically) would be correct in providing an orthonormal basis instead?
Forgive me, I know the q is a silly one bc the answer is made obvious in the context of so many resources, but I seek a direct response.
Answer: Just so.
As an aside, your analogy is particularly apt in that a rectangle essentially defines an orthogonal basis for $\mathbb R^2$, while a square defines an orthonormal one.


Get last element from several results with cssselector

Question: So I have this CSS-selector query that returns several results:
div[class=b-folders] span[class=b-folders__folder]

And I want to get only the last one, I tried;
div[class=b-folders] span[class=b-folders__folder]:last-of-type

But nothing was found.
Comment: What do you mean classic CSS selectors ?
Answer: :last-of-type, :last-child and other relevant pseudo-classes/selectors check the element's position inside it's parent:

The :last-of-type CSS pseudo-class represents the last sibling with the given element name in the list of children of its parent element.

Instead, solve it using your selenium language bindings - get all elements matching the selector and get the last found element. For instance, in Python:
driver.find_elements_by_css_selector("div[class=b-folders] span[class=b-folders__folder]")[-1]

Comment: Any way to reach this last element using the css_selector query without take the last using the results in the code ?
Comment: @davidhol nope, I am afraid this is not possible in this case. Look into XPaths if this is important.
Answer: You can have an array list of elements and then select the last element by:
List<WebElement> elements= driver.findElements(By.css("css"));

element = elements.get(list.size() - 1);


Doubt on displacement of a parabola

Question: Find the equation which is an displacement of $x² - 3x + 4$ and passes though point $(-3, 3)$ and $(2, 8)$
I've already mounted an simple system of equations which looks obvious
$$\begin{align}
8 &= 4a + 2b + c \\
3 &= 9a - 3b + c
\end{align}$$
but I'm stuck here, does someone know where to go now ? thanks in advance.
Answer: We could think that since the new parabola is only a displacement of the first one, it must have the same leading coefficient, i.e., $a=1$ (otherwise we'd also be stretching, shrinking or reflecting it). Then we can solve the resulting system of two equations in two unknowns:
$\begin{cases}
8 =4 + 2b +c \\
3 = 9 - 3b + c
\end{cases}
\Longleftrightarrow
\begin{cases}
4 = 2b +c \\
-6 = - 3b + c
\end{cases} $
We could try subtracting the last two equations to get $10 = 5b$, then $b=2$ and replacing anywhere we get $c=0$. So the equation of the desired parabola would be $y= x^2 +2x$.
Comment: +1. To verify that the leading coefficients must match, simply observe that a displacement --say, by $(h,k)$-- of any parabola of the form $y=Px^2+Qx+R$ has the form $y-k=P(x-h)^2+Q(x-h)+R$. You don't even have to fully expand the new equation to see that the coefficient of $x^2$ will be $P$, just as in the original.
Comment: Thank you so much, it led me to the answer.

Doubt on displacement of a parabola


Does the algebra of real valued functions in Stone-Weierstrass Thm. equal to the set of polynomials?

Question: I am studying Stone-Weierstrass Theorem. I wonder whether A is equal to the set of polynomials? If so, how can I proof this? And the statement is as follows:

Let $S$ be a compact set, and let $A$ be an algebra of real valued functions on S. Assume that $A$ separates points and contains the constant functions. Then, the uniform closure of $A$ is equal to the algebra of all real continuous functions on $S$.
Comment: What do you mean by "in $R$, A is equal to the set of polynomials"?
Comment: Sorry. I mean that S is a compact set in R. ( Weierstrass theorem)
Answer: The point is that the theorem works for any such algebra. That's why it extends the original result of Weierstrass.
If in particular $S\subset \mathbb R$, the theorem applies if you take $A$ to be the polynomials (because they separate points and contain the constant functions).
Comment: Now I see that this is an extension. Thank you so much.


Algebraic Structures that are similar to Vector Spaces but exist over a Commutative Ring as opposed to a Field?

Question: I was just wondering if there are Vector Space 'like' structures in which instead of existing over a Field exist over a Commutative Ring?
Thanks, David
Comment: You're welcome
$$\textrm{}$$
-David
Answer: There exists the notion of a module over a ring, see http://mathworld.wolfram.com/Module.html.
Comment: No problem! I hope this helps.
Comment: The field that covers the study of modules over commutative rings is called commutative algebra.
Comment: Thanks @Matt. Much appreciated.
Comment: @ThomasAndrews - Thanks for that :-)


How can I allow remote access to specific folders in my site?

Question: I have a drupal 8 site that has a folder (/learning/sales) in it that is custom html/php/etc. In there I make an ajax call from one .html file to a .php file in another folder (from /learning/sales to /learning/sales/ajax/getAreas.php) when I try to run it it fails (403 error), and when I try to go directly to my php file to check to see if it works I get this error, "Forbidden
You don't have permission to access /learning/sales/ajax/getAreas.php on this server."
I think the solution to this is to edit my .htaccess file to allow access to those folders, however I don't really know how to do that.
Am I correct in my thoughts that it is the .htaccess file that needs to be fixed? and if so what do I need to do to get it to work?
And if not then what could be the problem?
Thanks!
P.S. Here is my .htaccess code for reference.
<code>#
# Apache/PHP/Drupal settings:
#

RewriteEngine On
# ensure www.
#RewriteCond %{HTTP_HOST} !^www\. [NC]
#RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

# Only serve the static site for a particular host.
# RewriteCond %{HTTP_HOST} ^local.learning\.com$
# Don't loop anything targeting the actual mask directory, to allow
# for linked scripts, stylesheets etc in the static HTML
# RewriteCond %{REQUEST_URI} !^/learning/
# Any requests that made it this far are served from the /static/ directory
# RewriteRule ^(.*)$ /learning/$1 [PT,L]

# Only serve the static site for a particular host.
RewriteCond %{HTTP_HOST} ^www.[sitename]\.com$
# Don't loop anything targeting the actual mask directory, to allow
# for linked scripts, stylesheets etc in the static HTML
RewriteCond %{REQUEST_URI} !^/learning/
RewriteCond %{REQUEST_URI} !^/learning/sales
#Any requests that made it this far are served from the /static/ directory
RewriteRule ^(.*)$ /learning/$1 [PT,L]

# Protect files and directories from prying eyes.
<FilesMatch "\.(engine|inc|install|make|module|profile|po|sh|.*sql|theme|twig|tpl(\.php)?|xtmpl|yml)(~|\.sw[op]|\.bak|\.orig|\.save)?$|^(\.(?!well-known).*|Entries.*|Repository|Root|Tag|Template|composer\.(json|lock))$|^#.*#$|\.php(~|\.sw[op]|\.bak|\.orig|\.save)$">
  <IfModule mod_authz_core.c>
    Require all denied
  </IfModule>
  <IfModule !mod_authz_core.c>
    Order allow,deny
  </IfModule>
</FilesMatch>

# Don't show directory listings for URLs which map to a directory.
Options -Indexes

# Set the default handler.
DirectoryIndex index.php index.html index.htm

# Add correct encoding for SVGZ.
AddType image/svg+xml svg svgz
AddEncoding gzip svgz

# Most of the following PHP settings cannot be changed at runtime. See
# sites/default/default.settings.php and
# Drupal\Core\DrupalKernel::bootEnvironment() for settings that can be
# changed at runtime.

# PHP 5, Apache 1 and 2.
<IfModule mod_php5.c>
  php_value assert.active                   0
  php_flag session.auto_start               off
  php_value mbstring.http_input             pass
  php_value mbstring.http_output            pass
  php_flag mbstring.encoding_translation    off
  # PHP 5.6 has deprecated $HTTP_RAW_POST_DATA and produces warnings if this is
  # not set.
  php_value always_populate_raw_post_data   -1
</IfModule>

# Requires mod_expires to be enabled.
<IfModule mod_expires.c>
  # Enable expirations.
  ExpiresActive On

  # Cache all files for 2 weeks after access (A).
  ExpiresDefault A1209600

  <FilesMatch \.php$>
    # Do not allow PHP scripts to be cached unless they explicitly send cache
    # headers themselves. Otherwise all scripts would have to overwrite the
    # headers set by mod_expires if they want another caching behavior. This may
    # fail if an error occurs early in the bootstrap process, and it may cause
    # problems if a non-Drupal PHP file is installed in a subdirectory.
    ExpiresActive Off
  </FilesMatch>
</IfModule>

# Set a fallback resource if mod_rewrite is not enabled. This allows Drupal to
# work without clean URLs. This requires Apache version >= 2.2.16. If Drupal is
# not accessed by the top level URL (i.e.: http://example.com/drupal/ instead of
# http://example.com/), the path to index.php will need to be adjusted.
<IfModule !mod_rewrite.c>
  FallbackResource /index.php
</IfModule>

# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on

  # Set "protossl" to "s" if we were accessed via https://.  This is used later
  # if you enable "www." stripping or enforcement, in order to ensure that
  # you don't bounce between http and https.
  RewriteRule ^ - [E=protossl]
  RewriteCond %{HTTPS} on
  RewriteRule ^ - [E=protossl:s]

  # Make sure Authorization HTTP header is available to PHP
  # even when running as CGI or FastCGI.
  RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

  # Block access to "hidden" directories whose names begin with a period. This
  # includes directories used by version control systems such as Subversion or
  # Git to store control files. Files whose names begin with a period, as well
  # as the control files used by CVS, are protected by the FilesMatch directive
  # above.
  #
  # NOTE: This only works when mod_rewrite is loaded. Without mod_rewrite, it is
  # not possible to block access to entire directories from .htaccess because
  # <DirectoryMatch> is not allowed here.
  #
  # If you do not have mod_rewrite installed, you should remove these
  # directories from your webroot or otherwise protect them from being
  # downloaded.
  #RewriteRule "/\.|^\.(?!well-known/)" - [F]

  # If your site can be accessed both with and without the 'www.' prefix, you
  # can use one of the following settings to redirect users to your preferred
  # URL, either WITH or WITHOUT the 'www.' prefix. Choose ONLY one option:
  #
  # To redirect all users to access the site WITH the 'www.' prefix,
  # (http://example.com/foo will be redirected to http://www.example.com/foo)
  # uncomment the following:
  # RewriteCond %{HTTP_HOST} .
  # RewriteCond %{HTTP_HOST} !^www\. [NC]
  # RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  #
  # To redirect all users to access the site WITHOUT the 'www.' prefix,
  # (http://www.example.com/foo will be redirected to http://example.com/foo)
  # uncomment the following:
  # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]

  # Modify the RewriteBase if you are using Drupal in a subdirectory or in a
  # VirtualDocumentRoot and the rewrite rules are not working properly.
  # For example if your site is at http://example.com/drupal uncomment and
  # modify the following line:
  # RewriteBase /drupal
  #
  # If your site is running in a VirtualDocumentRoot at http://example.com/,
  # uncomment the following line:
  # RewriteBase /

  # Redirect common PHP files to their new locations.
  RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]
  RewriteCond %{REQUEST_URI} ^(.*)?/(rebuild.php)
  RewriteCond %{REQUEST_URI} !core
  RewriteRule ^ %1/core/%2 [L,QSA,R=301]

  # Rewrite install.php during installation to see if mod_rewrite is working
  RewriteRule ^core/install.php core/install.php?rewrite=ok [QSA,L]

  # Pass all requests not referring directly to files in the filesystem to
  # index.php.
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_URI} !=/favicon.ico
  RewriteRule ^ index.php [L]

  # For security reasons, deny access to other PHP files on public sites.
  # Note: The following URI conditions are not anchored at the start (^),
  # because Drupal may be located in a subdirectory. To further improve
  # security, you can replace '!/' with '!^/'.
  # Allow access to PHP files in /core (like authorize.php or install.php):
  RewriteCond %{REQUEST_URI} !/core/[^/]*\.php$
  # Allow access to test-specific PHP files:
  RewriteCond %{REQUEST_URI} !/core/modules/system/tests/https?.php
  # Allow access to Statistics module's custom front controller.
  # Copy and adapt this rule to directly execute PHP files in contributed or
  # custom modules or to run another PHP application in the same directory.
  RewriteCond %{REQUEST_URI} !/core/modules/statistics/statistics.php$
  # Deny access to any other PHP files that do not match the rules above.
  # Specifically, disallow autoload.php from being served directly.
  RewriteRule "^(.+/.*|autoload)\.php($|/)" - [F]

  # Rules to correctly serve gzip compressed CSS and JS files.
  # Requires both mod_rewrite and mod_headers to be enabled.
  <IfModule mod_headers.c>
    # Serve gzip compressed CSS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.css $1\.css\.gz [QSA]

    # Serve gzip compressed JS files if they exist and the client accepts gzip.
    RewriteCond %{HTTP:Accept-encoding} gzip
    RewriteCond %{REQUEST_FILENAME}\.gz -s
    RewriteRule ^(.*)\.js $1\.js\.gz [QSA]

    # Serve correct content types, and prevent mod_deflate double gzip.
    RewriteRule \.css\.gz$ - [T=text/css,E=no-gzip:1]
    RewriteRule \.js\.gz$ - [T=text/javascript,E=no-gzip:1]

    <FilesMatch "(\.js\.gz|\.css\.gz)$">
      # Serve correct encoding type.
      Header set Content-Encoding gzip
      # Force proxies to cache gzipped & non-gzipped css/js files separately.
      Header append Vary Accept-Encoding
    </FilesMatch>
  </IfModule>
</IfModule>

# Various header fixes.
<IfModule mod_headers.c>
  # Disable content sniffing, since it's an attack vector.
  Header always set X-Content-Type-Options nosniff
  # Disable Proxy header, since it's an attack vector.
  RequestHeader unset Proxy
</IfModule>
</code>
Answer: the htaccess has these lines
<code># Pass all requests not referring directly to files in the filesystem to
# index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^ index.php [L]
</code>
Which means if it's an actual file, it won't be redirected to drupal. So there shouldn't be any Drupal reason you can't call a PHP file from your setup. Perhaps if you have an htaccess popup password (Basic Auth) in place, that could cause issues. Or if the permissions on your folder/file aren't correct, that could be an issue.
If your getAreas.php bootstraps (starts Drupal instance), then Drupal permissions come into play. And some Drupal files may not like being directly accessed.
Comment: Backup your htaccess before going crazy with it. Also, if you have ANYTHING of importance on the server, make sure to run apache's config check **before restarting apache** and trying the change. [link]https://git.drupalcode.org/project/drupal/blob/8.8.x/.htaccess[/link] shows the current drupal htaccess file. Run a diff between Drupal's and yours to see the differences. BUT... the Basic Auth you're running into may be set elsewhere in apache's config files. Your system admin should be able to assist with turning it off to test the ajax.
Comment: I am going to include my .htaccess code, because the person who worked on the site before me made a lot of changes to it and I am not sure what some of them do.
Comment: there is a popup password when you go to the front page of the site, how do I disable that/let me stuff go through that?


Get ID from a URL in drupal?

Question: I have cretad a menu for edit a form in drupal...
Code:
function pricepackages_menu()
{
    $items = array();
    $items['membership/packages'] = array(
        'title' => t('Add Membership Packages'),
        'page callback' => 'drupal_get_form',
        'page arguments' => array('pricepackages_form'),
        'access arguments' => array('access administration pages'),
    );
    $items['show/packages'] = array(
        'title' => t('Manage Membership Packages'),
        'page callback' => 'view_packages',
        'access arguments' => array('access administration pages'),
    );
    $items['package/%/edit'] = array(
        'title' => 'Edit Membership',
        'page callback' => 'drupal_get_form',
        'page arguments' => array('pricepackages_form_update'),
        'access arguments' => array('access administration pages'),
    );
    return $items;
}

3rd menu is for eidt purpose...
The codd to show form i worte is:
function pricepackages_form_update($form, &$form_state)
{
    $form['packagename'] = array(
        '#type' => 'textfield',
        '#title' => 'Package Name',
        '#required' => TRUE,
    );
}

Please let me know how can get the value of the id in the url :
URL : http://somedomain.com/package/1/edit
I want to get the id 1 from the url and than want to add a select query... please let me know how can i get that value so i can wrote teh select query...
Also do i have to specify a new parameter in the pricepackages_form_update() or not?
Thanks in advance...
Comment: I don't understand what you are asking. Do you just want the "1" in "/package/1/edit" in your form handler? If so, see "arguments" over here: https://drupal.stackexchange.com/questions/62473/how-should-i-implement-hook-menu/62474#62474
Comment: Yes exactly this is what i want to know.. thanks..:)
Answer: Try It works for me.
$items['package/%/edit'] = array(
'title' => 'Edit data Row',
'page callback' => 'pricepackages_form_update',
'page arguments' =>array(1),
'type' => MENU_NORMAL_ITEM,
'access callback' => TRUE,
);

function pricepackages_form_update($arg){
$my_object = db_select('your table name', 'a')
->fields('a')
->condition('your node id parameter', $arg )
->execute()
->fetchAssoc();
return drupal_get_form('your form menu', $my_object);
}

Get ID from a URL in drupal?


Add/Update from Offline DBs to Central DB - Access

Question: I've got a somewhat unique problem due to our infrastructure. I have two offline tablet's which are performing a survey and entering the information in an Access database. These tablets have their own copy of the database front end AND back end.
I need to, at the end of every day, update the master copy of the back-end (on an office computer) with the values in each of the two tablet databases. This master DB is then uploaded to each of the tablets, replacing their incomplete versions, and off they go the next day.
I've never done this sort of merging before and don't really know where to start. Basically, I need a query which will:

Delete the current values in the master DB
Add the values from tablet1, merged with the values of tablet2 into the master DB

I can delete the current values in the master DB because the tablets will contain the values from the days before as well (as they are sometimes needed for reference etc). Basically, the tablets will always contain the entire database + today's survey. It's just that + today's survey is different for each tablet.
Is it possible to do? How can I keep the ID fields, as there are relationships in place using KeyIDs?
I need MERGE, but havn't found any documentation on if it works in MS Access... MS seems to play with the standards however they please. Or maybe MSA2010 just hasn't updated to support Merge?
Comment: I've read that Access 2010 supports an off-line capability with SharePoint as a data source.  If you can substitute SharePoint for "master DB", perhaps the built-in off-line/on-line & synchronize features would simplify this situation.  http://office.microsoft.com/en-us/sharepoint-foundation-help/synchronize-a-sharepoint-2010-list-with-access-2010-HA101854203.aspx
Comment: Sorry, I assumed MSSQL was the syntax for Jet. I could be mistaken. It is for a standard Access Jet database, using the VBA/SQL syntax in Access. I will edit my question to dissolve the ambiguity.
Comment: I wish I had known about that sooner. It would have been the best way to go by the looks of it. I have found a work-around for now though.. so I think (since it's a sort of temporary database, used by 2 people for about 8 months) I'll save myself the hassle of transferring everything to SharePoint. Definitely a good idea though.
Comment: I'll post my workaround. Though I think for future users, you should share your SharePoint idea as an answer. It does solve the problem, and in a much more elegant and 'proper' way.
Answer: I found a workaround that works for me as a bandaid solution. I empty the existing Master table first. I then use:
SELECT * FROM myTable IN "LocationToTablet1/backend_tablet1.mdb"
UNION
SELECT * FROM myTable IN "LocationToTablet2/backend_tablet2.mdb"

and name that query "myQuery". Then
INSERT INTO myTable IN "LocationToOffice/master_backend.mdb"
SELECT * FROM [myQuery]

However for anyone having the same question, HansUp's solution of integrating with SharePoint seems like a good idea (see question's comments). It does not require end-user intervention, whereas I need to manually call these queries when the tablets return to the office.
Comment: It works like this: let's say on day five, there's 100 rows of data. On day six, tablet1 adds another 4 rows and tablet 2 adds another 7 rows. At the end of day six, there is then a total of 100+4+7 rows. The above deletes 100 rows from the master DB, then would add the 100+4 from the first tablet UNION (not UNION ALL) 100+7 from the second tablet to make 111 rows in the master DB. I then delete the DB on both tablets and re-upload the whole thing. It ensures tablet1 can't do something tablet2 has already done (proper keys/relationships restrict doing the same thing twice)


How does one determine the sample size and statistical analysis to be used?

Question: How does one determine the sample size and statistical analysis to be used for an experiment wherein there will be two interventions (no standard medicine for positive control) A and B, and the objective is to determine the effectiveness and viability of A and B on certain disease? There are 5 treatments: (1) disease no intervention (2) disease with intervention A (3) disease with intervention B (4) no disease no intervention (5) and maybe with disease with both interventions A and B.
Comment: What is the outcome variable and what values can it take on?  Are there other variables, besides treatment that can effect the outcome?  While this question seems rather simple, it is extremely complex and the answer is "it depends" on my different things.  It might be best to discuss your specific problem with a statistical consultant.
Answer: To answer this question, more information is needed. First, you need to have some estimate of effect size: How large an effect do you expect, or do you wish to be able to detect, statistically? I suggest taking a look at this information on power analysis:
Quick-R Power Analysis
In terms of the type of analysis to use, that depends entirely on the variables you're measuring and their values/distributions. It looks to me like you will be using a multi-way ANOVA, including interactions. You can use aov(), lm() or more complex functions as needed, assuming your data meets the required assumptions. You may need to look into non-parametric analyses as well.
We could probably help more if you provide more information on how you will be sampling. Will there be repeated measures on individuals? Will observations be nested inside individuals, or gender, etc.?
Comment: The subjects will be mice. I don't think repeated measures will be used in this thesis proposal. I really don't have a clue about sample sizes though. Anyway gender won't be affecting much I guess, but would it be better if the counts for each would be equal just to avoid a bias of some sort?
Effectiveness of the intervention would be qualitative assessment whether it resulted to either decrease or increase of the disease and quantitative according to the number of days it took to normalize the mice. I hope I don't give you a hard time.
Comment: Hi Brendan, the qualitative response is important to note, as is the fact that # of days is your quantitative response. You may want to look into logistic regression, or frequency analysis, since your qualitative response is binomial (better or not). However, that makes it a little difficult to determine effect size, and thus, sample size. If you choose frequency analysis (testing independence of treatment and response) you can use R to calculate sample size: pwr.chisq.test(w =, N = , df = , sig.level =, power = ). Check the link above to determine effect size in frequency analysis.


hook_menu() with enabled languages

Question: I'm trying to implement hook_menu() in my module. The problem is, it doesn't add the menu item for English while it does for Turkish. I'm guessing it has something to do with title arguments, but I can't be sure. Below is my code:
function suweb_agi_menu() {
  global $language;
  $lang = $language->language;
  $items = [];
  $items['agi'] = [
    'title' => ($lang == 'tr')?'AGİ (Aile Geçim İndirimi)':'AGİ (Family Status Declaration)',
    'page callback' => 'drupal_get_form',
    'page arguments' => ['suweb_agi_form'],
    'access arguments' => ['access content'],
    'menu_name' => 'menu-sol-menu'
  ];
  return $items;
}

What am I doing wrong?
Comment: What is the goal/logic behind this loop? If you are trying to provide a different title for each language, you are better off using the t() function, and then translate the strings via the Translate UI. That way you don't need a loop, or the suweb_agi_language() function.
Comment: Please look at my edited function in my OP, which also does not add the menu item for English.
Comment: What are the multilingual settings for your sol-menu Menu?
Comment: `Translate and Localize. Menu items with language will allow translations. Menu items without language will be localized.` is checked.
Answer: The following code does what you seem to need (screenshots attached). The following modules need to be activated:

i18n_menu (part of the i18n)

Further configuration:

I added a new language (tr) and set language detection to "Determine the language from the URL (Path prefix or domain)."
I added a new menu with machine name (menu-sol-menu) and set the translation mode to "Translate and Localize". Also added the new menu as a block to the header region of the theme.
Added the following code in a custom module and activated it.
function agi_menu() {
  $items = [];
  $items['agi'] = [
    'title' => 'AGI (Family Status Declaration)',
    'page callback' => 'drupal_get_form',
    'page arguments' => ['node_form'],
    'access arguments' => ['access content'],
    'menu_name' => 'menu-sol-menu'
  ];
  return $items;
}

I visited the menu admin page and saw that a new menu item was added:

I checked the language option for that new menu item, it was set to neutral.

I visited the home page of my drupal instance and checked that the menu item appears, for both english (default language) and turkish, using the URL to define the current language.

Finally, I looked in the translate interface for the title of the menu item.

Conclusion: The provided code with the described configuration works as expected by the OP.
Good luck!
N.B.: Especially for the 'title' and 'title callback' properties, the documentation is very clear about how to use them in a multilingual setting

"title": Required. The untranslated title of the menu item. "title
  callback": Function to generate the title; defaults to t(). If you
  require only the raw string to be output, set this to FALSE.
Comment: I did `%/agi` and `agi/%` as well, and the menu item disappeared.
Comment: What was the % argument for? Also, look at my comment below your OP. Why do you need a multiple menu items?
Comment: Because multiple languages
Comment: I did exactly as described, still no :S
Comment: Sorry, one step missing. The new menu item language was Turkish for me, and when I changed it to Language Neutral, the item was there for both languages, just not translated.
Comment: @Kartagis : Exactly, the translation needs to be done in a second step, look for some part of the menu item's title, e.g. "AGI", in the translate interface => admin/config/regional/translate/translate
Comment: @Kartagis : Did you manage to solve this?
Comment: No, but I think the only way left to do is make menu items manually. I was hoping I wouldn't have to
Answer: The code you are using doesn't work simply because hook_menu() is not called all the times. Drupal caches the result of the implementations of hook_menu() and call them when the cache is invalidated, for example, when after a module has been enabled/installed, or disabled/uninstalled. Changing language doesn't invalidate the cache Drupal uses for hook_menu(), so your code would keep using the title in the same language until a module is non installed, for example.
The code you are using is also useless. Just use the following one, and the title would be shown in the same language used for the page, if there is a translation for that language.
function suweb_agi_menu() {
  global $language;
  $lang = $language->language;
  $items = [];
  $items['agi'] = [
    'title' => 'AGİ (Family Status Declaration)',
    'page callback' => 'drupal_get_form',
    'page arguments' => ['suweb_agi_form'],
    'access arguments' => ['access content'],
    'menu_name' => 'menu-sol-menu'
  ];
  return $items;
}

You can always provide a translation for your menu title on admin/config/regional/translate/translate. (It requires the Locale module.)
Comment: I thought clearing the caches was sufficient for any changes you make in your hook_menu implementation.
Comment: I think the problem is not with the translation of the title, but with the actual inclusion/addition of a menu item in a menu. @Kartagis : Can you confirm this?
Comment: How do you mean? How can I confirm this? The menu hasn't  been added by me, by the way.
Comment: I meant if you can confirm that my understanding of what you ask for is correct; namely that the problem is not with translating the title of the menu item, but actually having the menu item appearing in the menu at all. Cheers
Comment: Oh yes, the problem is just with adding the menu item for English.
Comment: @Kartagis : Updated my answer, see below
Comment: @Kartagis Just visit the module page, and enable or disable a module. That is enough to clear the cache Drupal uses for `hook_manu()`.

hook_menu() with enabled languages


Is it possible to just use one policy in a self-play setting?

Question: I would like to ask is it possible to train an agent under self-playing setting but with just one policy to be trained? What are the foreseeable problems with such an implementation? My concern is as such: suppose agent A starts off as in role 1, and later goes role 2 (which is role 1's opponent) after a few iteration. When A switches to role 2, it might use the information gained when A was in role 1 to its current role's advantage. And after another few iterations when A switches back to role 1, A might use the information gained when A was in role 2 to its current role's advantage. This is because we assume there is just one policy for agent A, so the weights are updated and kept when A switches its role. The information gained can be things such as new strategies learnt, new information gained (when the agent's knowledge of the environment is incomplete), etc. So a more sensible way of training I think would be using two agents A and B with two separate policies to train - more like in a generative adversarial network setting in some sense. But then by definition this is not considered as self-play isn't it?
Add-on: So relating to the case of Alphazero playing chess, if the agent is really just playing with itself, despite chess belongs to the so-called perfect information game, but the opponent's thoughts/strategy/decision making process should be still unknown to the player. But if my assumption of how self-playing is true, then the agent A will have the thoughts/strategy/decision making process of role 2 when it is in role 1. Isn't that cheating (because in reality those knowledge are not attainable; rather one can only guess what are those information from its opponents)? (I haven't read through the Alphazero paper yet because I am not proficient enough to understand those technical details, so I would really appreciate it if anyone could explain the relevant part to me)
Comment: Cross-posted: https://cs.stackexchange.com/q/120598/755, https://cstheory.stackexchange.com/q/46336/5038, https://stats.stackexchange.com/q/448735/2921, https://stackoverflow.com/q/60143780/781723, https://ai.stackexchange.com/q/17943/1794.
  Please [do not post the same question on multiple sites](https://meta.stackexchange.com/q/64068).
Comment: But I didn't get many replies from cross-validated, and since this topic is also related to other field, why can't I post the question in other forums? Can the users from other forums see my question here?
Comment: See the link I provided for an explanation of why.  If everyone did that, it would be a lousy experience for answerers.  If you'd like further understanding, I suggest asking on meta.stackexchange.com.
Answer: If you switch policy under $A$ and $B$ or have a single policy where the first parameter for lookup is either $A$ or $B$, then it is the same.
It will only matter in terms of coding where you want to generalize across $A$ and $B$ roles and how you want the models laid out.
Comment: So does Alphazero use this way do to training as well?


Programmatically attaching files

Question: I have created the "Gallery" content type, and added two fields: "photo," and "document." I then used the following code for uploading a file in the "document" field:
$file = file_save_upload('document', array(
    'file_validate_extensions' => array('txt doc'), // Validate extensions.
));

// If the file passed validation:
if ($file) {
// Move the file, into the Drupal file system
if ($file = file_move($file, 'public://')) {
  $file->status = FILE_STATUS_PERMANENT;
 // $file->file_display = 1;
  $file = file_save($file);

} else {
  $output = t('Failed to write the uploaded file the site\'s file folder.');
}
 } else {
$output = t('No file was uploaded.');
 }

I am attaching this file to the node using the following code:
$customNode->field_document[$customNode->language][0] = (array)$file;

When I call node_submit() function, I get the following error:

Integrity constraint violation: 1048 Column 'field_document_display' cannot be null

Does anybody know what I am doing wrong?
Answer: I usually don't throw the (array)$file line because really the only thing the field data needs is the fid, description and display. So I usually do the following:
$node->field_image[LANGUAGE_NONE][] = array(
  'fid' => $file->fid,
  'display' => 1,
  'description' => '',
);
node_save( $node );

This way if the display is required, I don't get an error. But that's just me...
Comment: Confusing to me why it doesn't have default values.
Comment: You don't see default values because this is direct assignment.
Answer: Your solution is almost right; however, in some cases it requires that you also set display and description.
To make your code work do this:
$file = file_save_upload('document', array(
    'file_validate_extensions' => array('txt doc'), // Validate extensions.
));

// If the file passed validation:
if ($file) {
// Move the file, into the Drupal file system
if ($file = file_move($file, 'public://')) {
  $file->status = FILE_STATUS_PERMANENT;
 // $file->file_display = 1;
  $file = file_save($file);
  //set the extra values needed to make node_save work
  $file->display = 1;
  $file->description = "";
} else {
  $output = t('Failed to write the uploaded file the site\'s file folder.');
}
 } else {
$output = t('No file was uploaded.');
 }

Answer: I think the key here are those lines
$file->display = 1;
$file->description = "";

as Eric van Eldik pointed out. I was struggling with the exact same issue, adding just
$file->display = 1;

didn't help, but
$file->description = "";

made my day.
Answer: For adding file programmatically to node you can use
$managed = TRUE; // Whether or not to create a Drupal file record
$filename = 'public://imdb-cast-' . time() . '.jpg';
$iamge_file = system_retrieve_file($url,$filename , $managed);
if($iamge_file){
$file = file_load(db_query('SELECT MAX(fid) FROM {file_managed}')->fetchField());
$node->field_image['und'][0] = (array) $file;
  }
}

Answer: Just going to paste my solution here as well, I needed to create a new node, and upload an image programmatically.
$filepath = variable_get('file_public_path') . '/xmas_banner.jpg';
$file_temp = file_get_contents($filepath);
$file_temp = file_save_data($file_temp, file_default_scheme() . '://' .'xmas_banner_nl.jpg', FILE_EXISTS_RENAME);

$node = new stdClass();
$node->type = 'carousel'; // custom content type
$node->title = 'XMAS NL';
$node->field_banner_image['und'][0] = (array) $file_temp;
$node->uid = 1;
$node->status = 0;
$node->active = 0;
$node->promote = 0;
node_save($node);

Answer: Attach multiple files programmatically in Drupal 8:
foreach ($fileIds as $fid) {
  $node->field_images[] = [
    'target_id' => $fid,
    'alt' => 'ALT TEXT',
    'title' => 'TITLE TEXT'
  ];
}
$node->save();

Programmatically attaching files


Can PowerPoint templates support multiple languages?

Question: I need to make a PowerPoint template with a set of about 10 master slide layouts.  Several of these include text like "About our firm..." and "Before you begin..."
Is there a way to have the slide layouts support multiple languages so our German offices get the same layouts with "Über unsure Firma..." and "Bevor Sie beginnen?"
Ideally, I would only have one PPT template to support.  We are using Microsoft Office 2013.
Answer: I think you'll need to have multiple templates to make this fly, or write add-in code to set the language for the presentation at user request.  You'd probably need to do this in any case, because even if the text changes, if the language for the text is marked as, say, English, your German text will be flagged as misspelled, and if the presentation is set to English, any German text the user enters will get the red-squigglies as well.


Deploying Outlook through RemoteApp

Question: We have an RDS server where we host our software plus supply access to office and a few other programs. this is a multi tenant environment, we do not host any email or exchange but users can connect outlook to their email so all their need programs are within session.  Now after asking this question RDS 2012 Outlook Roaming Profile is seems outlook just does not roam and i dont want people to have to reconfigure email every time I add a new server to loan balance.
I was considering setting up a new VM with just office installed on it and deploying this to my other session host via remote apps.  As all folders are redirected i would this it would work pretty smoothly and would not require outlook to roam.
Is this feasible?
Answer: That would work since that data locations remain the same and are just surfaced in the Roaming profile.
It is quite common on VDI deployment to disable Outlook cached mode so it's running in "online" mode and not storing mail locally.  The downside is this requires a constant connection to Exchange, and for Exchange Online could generate substantial traffic depending on users and usage patterns. You don't have to settle for "online" only, you can mitigate the download times by limiting the amount of data that Outlook Caches. In outlook 2016 you can set this to as little as 3 days.  I believe 2013 is 1 week.

Deploying Outlook through RemoteApp


Should I create a second WAN Interface for a new SSLVPN setup on my Sonicwall 2400?

Question: Sonic Wall 2400
I'm setting up a new SSLVPN on our Sonicwall, very new to this.
I currently have an exchange server as well, so mail.company.com is directed to our mail server. I'd like to setup a clean link for my low end users, remote.company.com to be for the SSLVPN, but I'm not sure how to do this within the Sonicwall?
I setup SSLVPN on port 443. Only 1 WAN setup, on the X1 Interface.  We have an A record setup with the same static IP used on the WAN Interface, and is configured for mail.company.com.
Should I use a new static IP from our block of usable IP's to create the new Remote.Company.com? If so, I have no idea where to start on this on the Sonicwall?
Any suggestions?
Comment: I might be on the wrong track, but when I try to configure a new interface, like X2, I try to duplicate X1, with the only change being the new Static IP that I've configured for Remote.OurCompany.com.  I then get the error below.

: Error: Index of the interface.: Subnet on this interface overlaps with another interface
Answer: The only reason I would think you would need a 2nd WAN interface for this would be if you were running the SSLVPN on a separate ISP.
If the ports were already in use on that existing IP address (which might be the case for your 443 port for OWA, but maybe not) then you can still add a 2nd IP to the existing interface and give it an A record.
I would recommend creating a new A record and using a separate IP for your SSLVPN.
2 Reasons why:

You can easily monitor traffic by destination IP
You can create your A record for this IP and make it easier for users to remember (something like vpn.company.com)

There are KB articles for Sonicwall for adding a 2nd IP to an existing interface.  I'm pretty sure you can use the wizards in the GUI as well.  See here for a similar question here on SF: Sonicwall NSA 240 Multiple WAN IP Addresses to help you out.


LINQ Retorno da lista está com todos os registros repetidos

Question: Estou tendo problemas na realização de um select (usando LINQ) em uma View no SQL Server 2012.
Os valores armazenados no banco estão conforme abaixo:
   ID_Acomp    ID_Pessoa    Nome      Data
     26           300     MONTEIRO  01-01-2016
     27           300     MONTEIRO  02-02-2016
     28           300     MONTEIRO  03-03-2016

Quando realizo o select no SQL Manager, os valores retornam perfeitamente. Porém quando eu faço o mesmo select através do LINQ, o valor do ultimo registro é replicado sobre os demais registros acima, e fica assim:
   ID_Acomp    ID_Pessoa    Nome      Data
     28           300     MONTEIRO  03-03-2016
     28           300     MONTEIRO  03-03-2016
     28           300     MONTEIRO  03-03-2016

O código que estou utilizando na aplicação basicamente é este:
IQueryable<VW_PESSOA_ACOMPANHAMENTO> vwPessoaAcomp =
                            contexto.VW_PESSOA_ACOMPANHAMENTO.AsQueryable();

if (ID_Pessoa > 0)
{
    vwPessoaAcomp = vwPessoaAcomp(p => p.ID_Pessoa == ID_Pessoa);
}

var retorno = (from A in vwPessoaAcomp
                 orderby A.ID_Acomp descending
                   select A).ToList();

Abaixo está o código da minha view:
SELECT A.ID_Acomp, P.ID_Pessoa, P.Nome, A.Data
    FROM ACOMPANHAMENTO A, PESSOA P WHERE A.ID_ACOMP = P.ID_ACOMP

Comment: é mysql? qual a SQL que está rodando no SQL Manager? se puder poste na pergunta!
Comment: Uso o SQL Server 2012
Comment: Qual SQL você utiliza no SQL Manager?
Comment: Coloque o codigo da sua view, você pós o select do sql. Isso irá facilitar a ajuda. Você fez um debug no "retorno" para ver se gerou os registros do jeito que gostaria ?
Comment: O debug do retorno do linq sim, mas nunca fiz debug no sql manager.
Quando executo o select da view no sql manager o retorno está correto.
Comment: Vc está usando o entity framework?
Answer: O código abaixo deveria funcionar perfeitamente, se estiver retornando errado provavelmente o problema está na View, nas tabelas envolvidas, ou nos dados envolvidos:
var vwPessoaAcomp = contexto.VW_PESSOA_ACOMPANHAMENTO.AsQueryable();

if (ID_Pessoa > 0)
{
    vwPessoaAcomp = vwPessoaAcomp.Where(p => p.ID_Pessoa == ID_Pessoa);
}

var retorno = vwPessoa.OrderBy(p => p.ID_Acomp).ToList();

Eu modificaria o código da view para o seguinte código, que considero mais legível:
SELECT A.ID_Acomp, P.ID_Pessoa, P.Nome, A.Data
    FROM ACOMPANHAMENTO A JOIN PESSOA P ON A.ID_ACOMP = P.ID_ACOMP

Você poderia dar um SELECT * FROM PESSOA e outro SELECT * FROM ACOMPANHAMENTO e publicar os resultados aqui para sabermos quais dados estão envolvidos nesse caso.
Comment: O problema é que ao executar a view, os dados estão sendo exibidos perfeitamente.
Comment: @GleisonFrança o erro não está na LINQ, está em outro ponto do seu código. Você consegue criar um exemplo simples, programa console mesmo, completo e que reproduza o erro? Como também exibir os dados da sua query? Você está usando Entity Framework ou LINQ to SQL? Tente ver qual SQL está sendo emitido para recuperar os dados no banco. É até possível que sua rotina de exibição esteja fazendo algo errado. Pelo exemplo que está dando é impossível adivinhar onde está o problema.


Nested If Statements in a Function

Question: Hi so I am trying to make a function which actually detects the time and depends on date(H); shows what courses and some other info happen right now.
$holidays = false;
//$hour = date('H');
 $hour = "11"; //Changed it to test the code

function classes()
{
    if ($holdays == false) //Are we on holidays? No
    {
        if($hour > "9" && $hour < "21") //University working hours? yes
        {
            if ($hour = "10") //Hour 10? classes below
            {
                echo "
";
                    echo '...	';
                    echo '...	';
                    echo "...	";
                    echo "...	";
                    echo "...	";
                echo "
";
                //Another Class
                echo "
";
                    echo '...	';
                    echo '...	';
                    echo "...	";
                    echo "...	";
                    echo "...	";
                echo "
";
               //Another Class
                echo "
";
                    echo '...	';
                    echo '...	';
                    echo "...	";
                    echo "...	";
                    echo "...	";
                echo "
";
            }
            else{ //Hour not 10?
                echo "No classes right now.";
            }
        }
        else{ //Not working hours?
            echo "University closed at this time.
";

        }
    }
    else{ //Vacation?
            echo "University closed for vacation!";
    }

}

So I setted $hour value to 11 so it will pass the first two ifs successfully and I expect that it will echo that there are no classes right now, but it returns that university is closed at this time. I may also mess up the } on the code.
PS: I know i am using to many echos I am not that experienced yet to go with strings
Comment: [Variable scope](http://php.net/manual/en/language.variables.scope.php).... understanding this is a fundamental of working with functions in PHP
Comment: if ($hour = "10") should be if ($hour == "10")
Comment: Fabio == makes it accurate 10?
Comment: `$holidays` != `$holdays` your missing an `i`
Comment: @cmorrissey correct brother thanks
Comment: What is the current issue, wrong logic or code fails? This `I may also mess up the } on the code.` makes me think your page fails completely. If that is the case look at your logs.
Comment: @chris85 the point of the question is to help me fix the issue - logic has nothing wrong in my opinion I am just thinking that by messing } in this code ifs close when they should not and that affects the returning message.
Comment: Yes, that's what I mean by logic; your code outputs `No classes right now.` whereas you expect to get `University closed for vacation!` or some other scenario. I don't know what current expected behavior is or what you want. Variable scope will be an issue though. I also don't see where you call this function but I'll assume you are doing that..
Comment: @chris85 I am expecting to return "no classes right now" but it returns "closed for vacation". This function belongs to a functions.php file which is actually included on another page (include "functions.php";)  and the function is actually called later on that page (classes();)
Comment: looks like a switch statement would come in handy, how many `if($hour ==")` statements have you got ?
Comment: Non As i said before you only needed to use comparison `==`, you were just assigning again variable hour as 10, breaking your if condition. Check here http://codepad.org/olOjg4qc I also commented class to have a fast view of returning result. You also misspelled holiday in ur code, but for this example is not really important since a not assigned variable is equal to false, but it would be important to correct for further uses
Comment: @fabio thanks pal you're right. Function works fine. I noticed that you did also commented the last }
Comment: I commented the last closing braces because i commented the function
Comment: Please take note of @MarkBaker's comments. This will help you solve your issue.
Answer: Please take note of your variable scope. To access $holidays inside the function, declare it with global scope.
$holidays = false;
$hour = "11"; //Changed it to test the code

function classes()
{
    global $holidays, $hour;   // <=== HERE
    if ($holidays == false) //Are we on holidays? No
    {
      // your code here
    {
}

In addition, you have other errors that others have pointed out in your code.

if ($hour = "10") should be if ($hour == "10") – Fabio

and

$holidays != $holdays your missing an i – cmorrissey
Comment: Using `global` is never a good answer.... far better to pass the value as an argument to the function

Nested If Statements in a Function


In TypeScript, how can a declaration omit multiple methods from a base type?

Question: While searching for ways to fix errors in a d.ts file, I need to omit a few methods from the base type because the custom class I'm working on redefines them.
I found the Omit helper type, which is used in examples like this one :
type Foo = {
  a() : void;
  b() : void;
  c() : void;
  toString() : string;
};
type BaseFoo = Omit<Foo, "a">;

However, what if I need to remove both a, b, and c in BaseFoo?
It seems that I can do
type BaseFoo = Omit<Omit<Omit<Foo, "a">, "b">, "c">;

But is there a cleaner way to do this?
Answer: Yes, use union:
type BaseFoo = Omit<Foo, 'a'|'b'|'c'>;

Or just use Pick<Foo,'toString'>
Comment: You could also do `Omit` in order to omit specifically the properties which will be provided by the other class later.
Comment: @kaya3 good point


How can I reduce a $2$nd order ODE as $1$ st order ODE

Question: I'm trying to learn differential equations, I have some troubles with the following $2$nd order ode :
Let

$$\ddot{x}=-7\dot x +\omega(t)^2x(t) \:, \:\: x(0)=7,\dot x(0)=0$$

Where $\omega$ is a differentiable and periodic function on $\mathbb R$.
So my two questions are : How can I express this ODE as a  $1$ st order ODE ?  And how can I tell if the solution is global ?
Any help would be a lot appreciated. Best wishes.
EDIT: As marked in the comment there might be an error in the formula..
How would the same question be answered for

$$\ddot{x}=-\dot x -\omega(t)^2x(t) \:, \:\: x(0)=1,\dot x(0)=0?$$
Comment: you should not edit a question (changing it to something really different) after it was answered and accepted by you, you should probably ask another question instead
Comment: The OP changed the question. It's now a completely different question than the original one.
Comment: That was slightly better, but please leave the original content unchanged if the answers become less comprehensible without it. I changed that back and added the modified question as a follow-up section.
Comment: @LutzLehmann yes but we all have different values.
Comment: Are you sure about the sign of the last term? $$\ddot x+7\dot x+ω(t)^2x=0$$ would be an oscillator with variable frequency and (a rather large) friction term.
Comment: By the way you may be able to solve this equation with an integrating factor too!
Comment: With that sign you do not get oscillation. If $ω$ is constant you can solve the equation via exponential ansatz and characteristic exponents.
Comment: Please do not change answered questions to a different topic, I rolled it back to your first version. // You need not close an answered question, as that is the first step to deleting it. Setting the check-mark is sufficient notification.
Comment: Is https://math.stackexchange.com/questions/4063956/ordninary-differential-equation-global-solution also from your lesson group?
Answer: Hint
Set $y=\dot x$. Then $$\begin{pmatrix}\dot x\\ \dot y\end{pmatrix}=\begin{pmatrix}y\\ -7y+\omega (t)x\end{pmatrix}=\begin{pmatrix}0&1\\\omega (t)^2&-7\end{pmatrix}\begin{pmatrix}x\\ y\end{pmatrix}.$$
Comment: @RosaAmbre: Sorry, I misread your equation. I edited my answer.
Comment: I don't really see where it leads .. where the $\omega^2$ went ?
Answer: The solution of any linear DE with leading coefficient $1$ exists where or as long as the coefficients are continuous. Here that only depends on $ω$, if that function is continuous on $\Bbb R$, then any solution can be extended to the whole of $\Bbb R$, growing in a rule-of-thumb like $$\exp\left(\int_0^r(\sqrt{3.5^2+ω(s)^2}-3.5)ds\right)$$
where the integrand is $ω(s)^2/7$ for small $ω$ and about $(ω(s)-3.5)$ for large $ω$.

This estimate follows the WKB approach, try $x=e^U$ to find $u'+u^2+7u-ω^2=0$, $u=U'$, assume the changes in $ω$ and thus in $u$ are slow enough that $u'$ can be neglected (that is the reason for it being hand-wavy or a rule-of-thumb), and solve the quadratic equation for $u$, then integrate. There will be a second solution due to the quadratic equation that is strictly falling and thus not relevant for the growth of the solution.

If, as in the second equation $\ddot x+\dot x+ω^2x=0$, the sign of the last term was correct for an oscillation, one would get oscillating solutions of the approximate shape
$$
\frac{e^{-0.5·t}}{\cos\phi_0}·\cos\left(\phi_0+\int_0^t\sqrt{ω(s)^2-0.5^2}ds\right)
$$
if the frequency has a lower bound $ω(t)>0.5$. Here $\phi_0$ was introduced to be chosen so that the initial derivative becomes zero. (This is somewhat superfluous as the formula is an approximation anyway and will quickly deviate, probably first in phase, the amplitude shape remaining valid for a longer time.)
Comment: I added a motivation for the estimate.


8thWall Web : How to implement the multiple image target function?

Question: I want to use the multiple image target function. im using aframe. where do i put this line :
XR.XrController.configure({imageTargets: ['image-target1', 'image-target2', 'image-target3']})

and what do i do with the  attribute as i have

Right now im using a single image target like this :
    //IMAGE TARGET
    AFRAME.registerComponent('set-component-visible', {
        schema: {
            name: {
                type: 'string'
                XR.XrController.configure({imageTargets: ['HongLeong', 'KPJ']})
            }
        },
        init: function () {
            const object3D = this.el.object3D
            const name = this.data.name
            var scrollingArea = document.getElementById('scrolling-container');
            object3D.visible = false;
            scrollingArea.style.visibility = 'hidden';

            const showImage = ({detail}) => {
                if (name != detail.name) {
                    return
                }
                object3D.position.copy(detail.position)
                object3D.quaternion.copy(detail.rotation)
                object3D.scale.set(detail.scale, detail.scale, detail.scale)
                object3D.visible = true
                scrollingArea.style.visibility = 'visible';
            }

            const hideImage = ({detail}) => {
                if (name != detail.name) {
                    return
                }
                object3D.visible = false
                scrollingArea.style.visibility = 'hidden';
            }

            this.el.sceneEl.addEventListener('xrimagefound', showImage)
            this.el.sceneEl.addEventListener('xrimageupdated', showImage)
            this.el.sceneEl.addEventListener('xrimagelost', hideImage)
        }
    });

the html:

Comment: is it fixed , if yes please share the code
Answer: Find a solution, here is the good implementation ( put at end of body is better )
  window.addEventListener('load', function () {
      XR8.XrController.configure({imageTargets: ['imagetarget1', 'imagetarget2']})

})
Working like a charm