Como desabilitar o scroll da página ao passar por cima de algum elemento utilizando Javascript e(ou) Css puros, e sem que esconda a barra de rolagem

Question: Tendo um exemplo de um slide que funciona com o scroll do mouse, porém ele é horizontal. O problema é que o scroll vertical da página conflita com o scroll horizontal do slide. Como eu poderia desabilitar o scroll da página enquanto o mouse entra no slide? No código eu coloquei uma solução de deixar o overflow da página como "hidden" ao passar o mouse em cima do slide, porém ele esconde a barra de rolagem, e gostaria que ela permanecesse, só o evento de scroll parasse de funcionar.
O código:

1

2

3

Answer: Galera, vasculhando aqui, acabei descobrindo uma resposta, mas vou deixar aí pra quem estiver com a mesma dúvida.
É só usar esse script, eu não sei exatamente como funciona, mas serve para desativar o scroll do windows:
function preventDefault(e) {
  e.preventDefault();
}

// modern Chrome requires { passive: false } when adding event
var supportsPassive = false;
try {
  window.addEventListener(
    "test",
    null,
    Object.defineProperty({}, "passive", {
      get: function () {
        supportsPassive = true;
      },
    }),
  );
} catch (e) {}

var wheelOpt = supportsPassive ? { passive: false } : false;
var wheelEvent =
  "onwheel" in document.createElement("div") ? "wheel" : "mousewheel";

E depois fazer a chamada, nesse meu caso, será ativada quando o mouse entrar no slide e desativado quando sair:
slider.addEventListener("mouseenter", () => {
  window.addEventListener(wheelEvent, preventDefault, wheelOpt);
});

slider.addEventListener("mouseleave", () => {
  window.removeEventListener(wheelEvent, preventDefault, wheelOpt);
});

O código inteiro funcionando ficou assim (só copiar e colar dentro do body no html):

1

2

3

Answer: Para ocultar o scroll mas continuar podendo fazer a rolagem vc pode usar:
/* Oculta scrollbar no Chrome, Safari e Opera */
.exemplo::-webkit-scrollbar {
  display: none;
}

/* Oculta scrollbar no IE, Edge e Firefox */
.exemplo {
  -ms-overflow-style: none;  /* IE e Edge */
  scrollbar-width: none;  /* Firefox */
}


Disable accounts on AD automatically

Question: here is a question that I couldn't find online.
Is there a way to disable accounts on AD automatically after a certain amount of time?
I know that you can just put an expiration date and the user wouldn't be able to login to the domain anymore but our audit dpt demand us to disable this account and delete it after 30 days.
I don't think a script that runs every day will be an option as, to be honest, we don't want to have scheduled tasks running all the time.
Let me know if I can provide any more information and thanks in advance!
Comment: Yet a script is probably your only option. What's wrong with a scheduled task? Unless the environment is very, very large, a daily scan of users doesn't take much time/resource.
Comment: I agree with @strongline. Scripts are a very useful resource. Even if you were to purchase a program that did this for you, it would *still* be a scheduled task, just not with a script.   Unless you're going to be running this script during a time when a lot of other scheduled tasks are running, in a large environment, on a not very powerful server, it will have no noticable performance penalty.
Answer: The answer to a non-scheduled task is in the question, use the expiration date.  If that's not possible, and you are prohibited from using scheduled tasks for whatever reason, make it someone's job duty to run a script once a week.  Be sure to use PowerShell, and the AD module, and be sure to use lastLoginTimeStamp not lastLogin.  And keep in mind that lastLoginTimestamp only forces update of the property when login has been > 14 days.  However it's better than lastLogin property which can only be used in single DC situation, or if you poll all the DCs and determine the most recent before using that timestamp.
Answer: http://mikefrobbins.com/2013/12/12/setting-an-active-directory-user-account-to-expire-at-a-specific-time-of-day-with-powershell/
The above link will go a long way.  Explained both in CUI and GUI.

Disable accounts on AD automatically


Is the identity map the only map from the positive integers to itself that simultaneously preserves multiplication, order, and primes?

Question: Is the identity map the only map $f$ from the positive integers $\mathbb{Z}_{+}$ to itself that satisfies all three of the following properties?

$f(mn)=f(m)f(n)$ for all positive integers $m$ and $n$ (which implies that $f(1)=1$)
$f(m)<f(n)$ whenever $m<n$ (which implies that $f$ is injective)
$f(p)$ is prime for any prime number $p$

The above three properties (actually, for property 2, the weaker assumption that $f$ is injective suffices) imply that applying $f$ to any positive integer will not change the prime signature, because all that happens with $f(n)$ is that each prime $p$ dividing $n$ is replaced with $f(p)$ while maintaining the same exponent.
Here are some examples that suggest that the answer might be "Yes" (because they only satisfy properties 1 and 3 and injectivity, but are not order-preserving on all positive integers, although they are order-preserving on prime numbers):

Let $f(p)$ be the next prime following $p$, with $f$ extended to composite numbers using (complete) multiplicativity. Then, $8<9$, while $f(8)=f(2^3)=f(2)^3=3^3=27>25=5^2=f(3)^2=f(3^2)=f(9)$.
Let $f$(the $n$th prime) be the $(2n)$th prime. Then, $27<32$, while $f(27)=f(3^3)=f(3)^3=7^3=343>243=3^5=f(2)^5=f(2^5)=f(32)$.
Let $f(p)$ be the $p$th prime. Then, $f(8)=27>25=f(9)$, as in the first example.
Let $f$(the $n$th prime) be the $(n^2)$th prime. Then, $3<4$, while $f(3)=7>4=2^2=f(2)^2=f(2^2)=f(4)$.

But of course, specific examples (using inductive reasoning) are not enough to conclude that the answer is in fact "Yes".
Answer: Building on the discussion in the comments of Teresa's answer, this follows from the six exponentials theorem. I will try to write a self-contained answer here.
First, as you say the given conditions imply that $f$ restricts to some strictly monotonic function on the primes, and is determined by its values on the primes. If $p_1, \dots p_k$ is any finite set of distinct primes, then strict monotonicity of $f$ means that if $\prod p_i^{e_i} < \prod p_i^{f_i}$ then $\prod f(p_i)^{e_i} < \prod f(p_i)^{f_i}$. Taking logarithms and subtracting, this gives
$$\sum q_i \log p_i < 0 \Rightarrow \sum q_i \log f(p_i) < 0, q_i \in \mathbb{Q}.$$
In other words, $f$ induces a strictly order-preserving linear map $F$ from the $\mathbb{Q}$-subspace of $\mathbb{R}$ spanned by $\{ \log p_i \}$ to the $\mathbb{Q}$-subspace of $\mathbb{R}$ spanned by $\{ \log f(p_i) \}$. This implies that $F$ is continuous (with respect to the subspace topology coming from $\mathbb{R}$), which gives that it must in fact be given by multiplication by some fixed real number $r$. Said another way:

Corollary: For real coefficients $r_i$, we have $\sum r_i \log p_i = 0 \Leftrightarrow \sum r_i \log f(p_i) = 0$. Equivalently, there is some $r$ such that $\log f(p_i) = r \log p_i$ for all primes $p_i$.

This is quite a strong condition. It's equivalent to the condition that $\frac{\log f(p)}{\log p} = \frac{\log f(q)}{\log q}$ for distinct primes $p, q$, which assuming Schanuel's conjecture (which implies that the logarithms of the primes are algebraically independent) gives $f(p) = p, f(q) = q$. (We can also assume the weaker four exponentials conjecture instead.)
But actually we can avoid Schanuel's conjecture by considering three distinct primes $p, q, r$ instead. The six exponentials theorem implies that if $f(p) \neq p$ then (using that unique prime factorization implies that the logarithms of the primes are linearly independent over $\mathbb{Q}$) the matrix
$$\left[ \begin{array}{cc} \log p & \log q & \log r \\ \log f(p) & \log f(r) & \log f(r) \end{array} \right]$$
has rank $2$. But we showed above that the second row must be a multiple of the first, so this matrix has rank $1$; taking contrapositives, it follows that $f(p) = p$, and since the argument works for any three distinct primes we get $f(p) = p$ for all primes $p$.
Comment: I see , you've written up the SET argument very clearly. +1
Answer: Start with $f(2) = p$ for some prime $p$. Then, we need a choice for $f(3)$. We certainly need that whenever $3^q > 2^l$ then $f(3^q) > f(2^l)$ i.e. $f(3)^q > f(2)^l$ i.e. $f(3) > f(2)^{\frac lq}$.
However, we also need that whenever $3^x < 2^y$ then $f(3) < f(2)^{\frac yx}$.
Therefore, we are constrained to have $\frac lq < \log_{f(2)} f(3) < \frac yx$ for all pairs of (positive, doesn't really matter) rationals $\log_2 3 > \frac lq$ and $\log_2 3 < \frac yx$. By density of rationals in the reals, we are forced to have $\log_{f(2)} f(3) = \log_2 3$, and therefore $f(3) = f(2)^{\log_2 3}$.
Now, we can write this as $f(3) = 3^{\log_2 f(2)}$.
I don't think there's anything special about $2$ and $3$ in the argument above, so doing it for any pair of primes gives you that $f(q) = f(p)^{\log_p q}$ for any pair of primes $p$ and $q$.
This is severely restrictive of all values of $f$,since given just $f(2)$ we get all the other values. So we have a partial answer : everything is decided by $f(2)$, since $f(q) = f(2)^{\log_2 q}$.
Let us write this in beneficial fashion : for the existence of such a function, we require that for all primes $p,q$ we have , using the fact that $\frac{\ln p}{\ln q} = \log_q p$, the relation $\ln f(r) \ln s = \ln f(r) ln s$ for any primes $r,s$.

Now, the point is that we are expecting that $f(q)$ is an integer only when $f(2) = 2$ so that $f(q) = q$. But this is not a "given", since we don't know if $f(2)$ could be a prime so that $f(q)$ were in fact a valid prime integer for every $q$!
To answer this question, we need to get to "quadratic relations between logarithms of algebraic numbers".
Now, usually when we prove that things involving logarithms aren't integers and so on, we usually break them into "relations" involving logarithms. Then we use results known for logarithms and exploit them for our purposes.
Now, there are nice theorems for "linear" relations involving logarithms. These lead to the transcendence of numbers such as $\log_2 3$, and $2^{\sqrt 2}$ (try to see that if they were rational, it breaks into a linear relation between logarithms).
However, the relation we have , of the form $\ln q \ln r = \ln s \ln t$, is called a quadratic relation between logarithms. It turns out that for quadratics , we have a series of conjectures, along with a nice theorem which I state first!

First, let us use the six exponentials theorem. We call a subset $\{z_1,...,z_n\}$ of complex numbers as rationally independent if for any rationals $r_1,...,r_n$ we have $r_1z_1+...+r_nz_n \neq 0$ if at least one of the $r_i$ is non-zero.

Six Exponentials Theorem : Suppose that $x_1,x_2,x_3,y_1,y_2,y_3$ are complex numbers such that :

$x_1,x_2,x_3$ are rationally independent over the integers
$x_1,y_1$ are rationally independent over the integers.
Furthermore, each of $e^{x_i}$ and $e^{y_j}$ are algebraic numbers (read this and transcendental numbers up).
Then the matrix :
$$
\begin{pmatrix}x_1&x_2&x_3 \\ y_1 & y_2 & y_3\end{pmatrix}
$$
is of rank $2$. In particular, at least one of :
$$
x_1y_2 \neq x_2y_1, x_1y_3 \neq x_3y_1,x_2y_3 \neq x_3y_2
$$
is true.

Let us see how to use this. Suppose that $f(2) = p \neq 2$. Note that automatically, $f(s) \neq s$ for all primes $s$. Choose a prime $r$ such that $f(r) \neq p, r \neq p$. Choose a prime $s$ so that $s,f(s) \notin \{2,p,r,f(r)\}$. Note that $\ln 2 , \ln r , \ln s$ are linearly independent over the rationals (using an argument via prime factorization) and $\ln 2 , \ln f(r)$ are also rationally independent. Consequently, let the $x_i$ be $\ln 2 , \ln r,\ln s$ and $y_i$ be $\ln p ,\ln f(r),\ln f(s)$. Then, all conditions are satisfied (the third one trivially, since integers are algebraic).
As a conclusion, one of $\ln 2 \ln f(r)  = \ln r \ln p$, $\ln 2 \ln f(s) = \ln s \ln p$ or $\ln f(r) \ln s= \ln f(s) \ln r$ must be false. But none of these can be false! Consequently, we get that $f(2) = 2$, for that's the only way in which I can violate such a situation which provided our $x_i$ and $y_i$.

Next we use the conjecture :

Four exponentials conjecture : (Read up all unknown terminology) let $a,b,c,d$  each be logarithms of some complex numbers, with $\frac ab$ and $\frac cd$ non-zero and irrational. Then $\frac ab \neq \frac cd$.

Sounds logical : it's saying that a relation $ad = bc$ can't exist between "incompatible" logarithmic quantities $a,b,c,d$.
To use this for our problem : we know that if $f(3) = q$ a prime, then $\ln 2 \ln q = \ln 3 \ln p$. But note that if $p \neq 2$ then $q \neq 3$ and $\frac{\ln 2}{\ln p}$ and $\frac{\ln 3}{\ln q}$ are irrational (use prime factorization), so they are not equal by the conjecture, contradicting the premise. Thus $f(2)=2$, $f(3) = 3$ and we can do this for any pair of primes.

Next, another conjecture of Schaunel, which is also nice. We start with $n$ complex numbers which are linearly independent over the rational numbers i.e. no rational combination of them is zero. To perform this argument, we first choose an $r$ prime with $r \neq p, f(r) \neq p$ so that  $\ln 2, \ln r , \ln p$ and $\ln f(r)$ (we are assuming $p \neq 2$) so that they are all linearly independent over the rationals (once again, you can use prime factorization to get this result).
The conjecture is, stated in simple words :

If there are $n$ complex numbers linearly independent over the rationals, say $z_1,...,z_n$ then consider the subset $\{z_1,...,z_n,e^{z_1},...,e^{z_n}\}$. There is a subset $S$ consisting of $n$ of these elements, say $\{s_1,...,s_n\}$, such that if I take any polynomial in $n$ variables $f(x_1,...,x_n)$ with rational coefficients, then $f(s_1,...,s_n)\neq 0$. This is equivalent to saying that the transcendence degree of the extension of the rationals by all of $\{z_1,...,z_n,e^{z_1},...,e^{z_n}\}$ is at least $n$.

Now, do this with our subset ,and because each of the exponentials of elements of  $\{\ln 2 , \ln r, \ln f(r) , \ln p\}$ are $2,r,f(r),p$ which are already rational so they don't add to the transcendence degree of the extension.  Thus, using the conjecture, these four elements are therefore algebraically independent! But then, the polynomial $f(w,x,y,z) = wx-yz$ cannot be zero at $w=\ln 2, x = \ln f(r), y = r, z = \ln p$, and therefore $\ln 2 \ln f(r) \neq \ln r \ln f(p)$, a contradiction. So $f(2) = 2$.

All these results/conjectures are very helpful in solving these existence problems, as I have shown.
Links :
1 . The Six Exponentials theorem
2 . The Four exponentials theorem
3 . Schanuel's conjecture
Comment: Nitpickery: it's certainly TRUE, but _do_ we know that $3^{\log_2(p)}$ can't be a whole number for other prime $p$? IIRC this sort of problem is notoriously sticky.
Comment: I think the most fruitful approach is likely to be what you mention in the last paragraph — make the same argument for many sets of primes and derive a contradiction in there somewhere, possibly using something like the six exponentials theorem.
Comment: This argument works conditional on Schanuel's conjecture, which implies that the logarithms of the primes are algebraically independent and so $\frac{\log f(p)}{\log f(q)} = \frac{\log p}{\log q}$ implies $f(p) = p, f(q) = q$: https://en.wikipedia.org/wiki/Schanuel%27s_conjecture
Comment: @QiaochuYuan Thank you! I was just editing that into the answer, since I can't answer this using the six exponentials theorem. I realize that the SET is for "linear relations" between logarithms. "Quadratic relations" require Schanuel's conjecture. I will edit this is as well, thank you.
Comment: @StevenStadnicki Right, I will look into it, it did look sticky but I did some handwaving in my head and left it as an exercise. I will look into it.
Comment: @StevenStadnicki Now that I look into it, you are right it does require one of those results, and to use the six exponentials theorem I probably need like some different number of primes for things to work out.
Comment: @QiaochuYuan Please check if this is correct, and thank you for your comment once again.
Comment: @StevenStadnicki You can see if I've used six-exponentials correctly. I also added proofs using the Schanuel conjecture and the four exponentials conjecture, to make life simple in case I somehow fudged the six exponentials proof.
Comment: @Teresa: I don't quite understand the six exponentials argument the way you've written it, nor do I quite follow whether your subsequent use of the four exponentials conjecture and Schanuel's conjecture is intended to be part of one long argument or two other independent arguments. But I think the six exponentials theorem handles this problem unconditionally, without the conjectures. I can write an answer with details.
Comment: @QiaochuYuan They are all meant to be independent arguments. I tried to write them up clearly, but I was struggling with what level the OP is at, so I tried to simplify all the statements. I think the last two arguments are straightforward and correct, and I think the SET one is also fine. However, please do write an answer, I would like to read what you have to say on this in more detail.


Simulating the impact of non-IID data on a model

Question: I have data that is non-IID, and I want to estimate if the dependence is bad enough that it will have a noticeable effect on a fitted classifier. I don't think the exact model type will matter in this case, but for argument's sake let's say I'm using elastic-net logistic regression. In this case the dependence takes the form of clustering among observations, in that if $Y_k = 1$ has a high probability then the probability that $Y_j = 1$ is very low for all $j\neq k$ within the data cluster.
Ideally, I would like to be able to compare the fitted model from the non-IID data set to a "comparable" or "similar" IID data set. So I'm thinking I could just simulate such a data set, fit the model on the fake data and the real data,

Is there a formal or rigorous definition of "similarity" that makes sense in this case? I certainly know a dissimilar data set when I see one, but it's hard to quantify exactly how I know.
Is there a straightforward way to generate an IID dataset from a non-IID data set that otherwise preserves some structure from the joint distribution of features?
Is this an X-Y problem? Is there a better way to evaluate the effect of data dependence on my estimates?

edit:

For a purely predictive task, does non-IID data even make a difference as long as the cross-validation procedure is constructed correctly? This answer suggests the answer is "no"
Comment: Elaborate more on why your data isn't IID? and what IID data might look like?
Comment: So you have negative correlations within clusters?
Comment: @kjetilbhalvorsen yes
Comment: You could try keeping the same data set, but re-assign the class values $(Y_k)$ independently at random (having the same overall proportion of $Y_k = 1$). You could run this analysis many times and see what changes. I've used a similar approach in a different problem, but it may not work here.
Comment: General: What is the classification? Question 1: What do you mean by similarity, e.g. having the same pdf? Q2: I don't understand what you mean. Q3: it might be, but I again I don't understand the example. In bullet point 4 it becomes clear, that two things are mixed: correlation (read as: non-independence) and generalization power are not really related. In other words: if there is correlation in your input/training data, then this does not mean that you're result/prediction quality is worse.
Answer:
I have data that is non-IID, and I want to estimate if the dependence is bad enough that it will have a noticeable effect on a fitted classifier. I don't think the exact model type will matter in this case, but for argument's sake let's say I'm using elastic-net logistic regression.

On the importance of the i.i.d. assumption in statistical learning
Regularized Logistic Regression: Lasso vs. Ridge vs. Elastic Net
Predictive Modeling - Should we care about mixed modeling?

Ideally, I would like to be able to compare the fitted model from the non-IID data set to a "comparable" or "similar" IID data set. So I'm thinking I could just simulate such a data set, fit the model on the fake data and the real data,

Is there a formal or rigorous definition of "similarity" that makes sense in this case? I certainly know a dissimilar data set when I see one, but it's hard to quantify exactly how I know.

An R software library can help, consider: "Statistical Patterns in Genomic Sequences" by Hart and Martínez which could be extended to work with arbitrary symbolic sequences, not only DNA sequences.
It features easy to use functions:

diid.disturbance - Construct feasible Random Noise Generating a Bernoulli Process
Produces a sequence of random noise which would generate an observed sequence of finite symbols provided that the sequence of symbols results from a Bernoulli process.
diid.test - A Test for a Bernoulli Scheme (IID Sequence)
Tests whether or not a data series constitutes a Bernoulli scheme, that is, an independent and identically distributed (IID) sequence of symbols, by inferring the sequence of IID U(0,1) random noise that might have generated it.
<code>Category       Function           Test
Uniformity     ks.unif.test       Kolmogorov-Smirnov test for uniform$(0,1)$ data
               chisq.unif.test    Pearson's chi-squared test for discrete uniform data,
Independence   lb.test            Ljung-Box $Q$ test for uncorrelated data
               diffsign.test      signed difference test of independence
               turningpoint.test  turning point test of independence
               rank.test          rank test of independence
</code>

Search for a library that exactly meets your requirements or modify one that nearly does.
Also check out the NIST SP 800-22 Statistical Tests which can be used to test your data.

Is there a straightforward way to generate an IID dataset from a non-IID data set that otherwise preserves some structure from the joint distribution of features?

Create something like a k-distribution by compounding some existing distributions to meet your requirements. Use something like DistributionFitTest to check the generated IID.

Is this an X-Y problem? Is there a better way to evaluate the effect of data dependence on my estimates?

A tiny bit XY, maybe; you've waited a year and a half for an answer, even Tweeted it. You made a minor edit. If I don't get an answer in less than a week I make certain to check if I missed something. You've been asked a few questions and answered one. I have no complaints or questions ...
Test with both (non-IID, IID) generated random models (easy with the software suggested above, though probably more power in a different package), your own data, and both. Create a set of "Ensemble Algorithms" that don't blow up.

For a purely predictive task, does non-IID data even make a difference as long as the cross-validation procedure is constructed correctly? This answer suggests the answer is "no": Predictive Modeling - Should we care about mixed modeling?.

The answer requested further information and links, further it was not an absolute "no".

See also:
"Choosing the Correct Statistical Test" (Derived from Dr. Leeper's work) - General guidelines for choosing a statistical analysis and links showing how-to using SAS, Stata, SPSS and R.
Choosing a statistical test, Data Analysis Resource Center, and GraphPad Analysis Checklist.
I might have time to return for another edit and improve this answer.
Comment: This is exactly what I was hoping to get. I appreciate you taking the time to read between the lines a bit; I struggled to express what I wanted clearly at the time, and even now reading over the question i can see what's wrong with it but I'm not certain how to fix it. I'm going to let this bounty expire so I can award you a bigger one.
Comment: Yep, that's what I did. You already have one, the next one is coming once the 24 hour window passses.


Most secure Flash > MySQL connection

Question: Currently the major means of connecting Flash AS2/AS3 to a MySQL database are:

Flash > PHP > MySQL -- "secure code" in PHP Scripts
Flash Asql or Assql > MySQL -- "secure code" in MySQL Stored Procedures

The second approach is newer, but directly connects to a MySQL DB using binary sockets and ByteArrays.
In which case would the "secure code" be less accessible and therefore more secure?
I'm assuming stored procedures cannot be accessed via FTP so that might be harder to break into?
Answer: It appears that both assql and binary sockets are synchronous links that use a socket connection to the database. Which might be great for an AIR application, but for a browser app might be highly problematical. Is this for sure what you want? Your question about access through stored procedures gives me the idea you aren't too sure about this stuff.
In fact, using PHP properly will likely be easier for building a solid abstraction and security indirection barrier between your app (and its host) and the database.

EDIT:
Web clients and servers use the http protocol to communicate. This is called a "stateless" and "connectionless" (which is only kinda true) protocol because the connection between the two only lasts as long as it takes for the client to request everything and the server to send back everything. The obvious benefit is that the server only knows about each client for a very brief period of time.
A socket (in the sense these two protocols use one) is a permanently established connection between the client and server that persists until one end or the other closes it (connection-based); and both sides know the state of the connection (open or closed). So they tie up a lot of host resources per client for a long time, and things get wacky when the connection breaks. Big difference, and it can't be run through the ports supporting web pages - another port needs to be provided (sometimes two) on the host and the client to support the socket.
Comment: I haven't worked with sockets myself but I'm assuming Asql will abstract that from my code... I assume they would've solved compatibility problems?
Comment: Great addition about the unreliability of sockets. Keep up the good lecturing! Keep things a little simpler and uncomplicated, and more people will understand. (Use bold to highlight important concepts!)
Answer: I'm not sure asql would work for users behind the proxy, so I wouldn't use it for website. Approach with PHP in the middle seems to be better and you can (and should) model api for your application that is different from your DB structure.
Answer: Stored procedures can only be accessed by someone with the correct database credentials so they will be secure assuming no one cracks your Data Base password. You know it might actually be that the PHP code is more secure as you can hold the Data Base password on the server instead of in the host app.
I suppose you can always decompile flash and try to locate the password in the host app because with asql the password will be stored in the host app, instead of on the server hidden behind PHP
Comment: So I'll stick with the traditional Flash > PHP > MySQL! Goodbye and thank you to Asql/Assql.
Comment: No wonder nobody uses method 2 much! And to think Asql is still in its infancy.. (Alpha release!)

Most secure Flash > MySQL connection


read sql cel, find row ID and update cell in same row

Question: In my C# program i want it to read a column, and find the value i return, then return to me the row id so i can write in another cell in that row. So if my parameter is "Test" for my method, it will run a query (thats what i need) and find "Test" and return a row id so i can update another cell in that row.
Like this: (say this is my sql table)
   Text    |Integer
1 "stuff"  |2
2 "Test"   |5
3 "other"  |7
4 "stuf"   |1

I would want it to find row 2 so i can update 5 as the integer. Thanks in advance. Tell me if you can't completely understand me.
Answer: You can do that in one go
UPDATE table1
   SET int_field = 5
 WHERE text_field = 'Test';

That's assuming that text_field has UNIQUE index defined for it. Otherwise it will update all records where textfield = 'Test'. And apparently you don't have UNIQUE index on that column since two records 1 and 4 have text_field set to 'stuff'.
But if you for some reason need to get an id and if you have that column defined then simple select will do the trick
SELECT id
  FROM table1
 WHERE text_field = 'Test';

Comment: @user2374093 You're welcome. Glad it helped. But be aware of and deal appropriately with entries that have duplicate values in text field. Good luck.


The route addition failed: Cannot create a file when that file already exists

Question: I get this error when using c:>route add <route_and_interface_here>
This happens on a RRAS server that has a PPTP site-to-site VPN setup with demand-dialing static route. This route shows in RRAS routing table but does not show in c:>route print table which might be the first source of the problem.
Anyone seen this before? Anyone with experts-exchange account that can read the proposed answers there?
Problem might be connected with applying SP2 on Win2k3 and installing RRAS after that from RTM disk.
Answer: Give a high route metric value then the PPtp adapter while adding the route.
There seems to be problem with windows 7 interface metric calculation.


Watir-webdriver: Firefox not clicking correct link but IE and Chrome working fine

Question: Question help
Hi I'm new to Ruby and watir-webdriver and I've searched all over and can't find an answer to this.
I have a link that is inside a table, this table has a header on top of the table that sorts the table numerically if clicked. In Chrome and Ie, the link is clicked fine and continues on but in firefox it clicks the header and reorganizes the table, but not the link and no error message is given.
I've tried xpath, regexp, table referencing, :href, :text, (there are no id or name fields), and using the .flash method I've seen that it looks at the correct link, but still clicks the top of the table.
Here is the html

            Contract #

              015633828

Here is the code I'm using that clicks the correct link in Chrome and Ie but not in firefox
link = "015633828"

exp1 = Regexp.new link

@browser.link(:href, exp1).click

Again to clarify: Using .flash method it finds the correct link(flashes the link I want to click inside the table), but on the actual .click operation it clicks the "Contract #" portion of the header not the link.
I think the problem might be that the table header, is a floating header, ie it moves with you as you scroll down the page and stays at the top of the page so that its always visible.
If you need more info to clarify let me know. Thanks!
Comment: How do you know a header is clicked, and not the link? Especially if flash flashes the link, but they click clicks the header.
Comment: Can you reproduce the problem just with the HTML you have provided here? I think there is no way that Firefox will click a header if you tell it to click the link.
Comment: Yea I wasn't sure if that was actually possible. I'm going off of just watching the browser as it runs through the test. It gets to the site, scrolls down until the link is at the top of the page, then the table reorganizes itself as if the header was clicked, then goes on to the next step as if it clicked the link correctly.
Comment: Also, if I try it on the same type of table, but with a smaller amount of information in it where all of it will fit on the screen it will click the link just fine.
Answer: I'm not sure why it is doing this, but as a potential workaround could you perhaps try something along the following lines to pull the href value out of the link and then have the browser goto it directly?
@browser.goto(@browser.link(:text, ' 015633828 ').href)

(you might need to add the base url for the site to the href to make that work, but you get the idea)
Comment: Yea that work around worked.

Wouldn't mind finding out if there was a way to get it to work with the floating header in case I run into this problem again. Thanks for everyone's answers/help though!
Answer: or possibly try with xpath:
@browser.link(:xpath,"//a[@text='someUser#']").click
Answer: Well, if you want to make sure a link inside td tag is clicked, and not a link inside th tag, try this:
browser.td.link(:href => /someUser#/).click

It is a good thing that you have provided both HTML and Watir code, but in the future, try to provide real HTML (or as real as possible). someUser# really confused me, I am not even sure I understood the problem.
If the solution I have provided does not work, please edit the question to contain real HTML.
Comment: I edited the post to contain the real html. The solution you provided still clicked the header.
Comment: I think that firefox is scrolling down until the link is at the top of the page, but doing that makes the floating header cover up the link and then it clicks the header. (Hopefully that makes sense)

Is there a way to lock the scroll bar?


My application relies Google play services, which is not supported by your device. contact the manufacturer for assistance

Question: I am creating a Google Map application on 4.4.2 (API 19) and added all Google Play services, Google repository and all packages under 4.4.2 (API 19).
But I'm getting this error:

My application relies Google play services, which is not supported by
  your device. contact the manufacturer for assistance.
Comment: I received this error after my Nexus 10 crashed during an update. Obviously nexus is part of the Google play ecosystem; there are multiple causes for this error, unfortunately.
Answer: Possible solution:

Make sure you are using the latest version of Google Play Service & most importantly your Play Services isn't disabled. You can download the latest version here,

https://play.google.com/store/apps/details?id=com.google.android.gms
Uninstall any previous updated before installing the new one
Goto -> Settings -> Apps -> Google Play Services -> Uninstall installed updates

Make sure your current date/time is correct.

UPDATED ANSWER:
If you are using an emulator you should keep in mind that emulator doesn't support Google Play Services by default. What you can do is download and install Google APIs from SDK Manager then create a new device in emulator using the Google APIs as target.
First install Google APIs from SDK Manager,

Create a virtual device like this,
For Android Studio,

For Eclipse,
Comment: Its running on android emulator.
Comment: For me this solution worked in Android Studio. At this moment the IDE looks a bit different but the solution still relies in these two steps provided by Prokash:

1. Install Google APIs from SDK Manager.

You can find it in Tools > SDK Manager > SDK Tools tab

Here I installed the 4 Google Play * options

2. In Tools > Device Manager create a Nexus device simulator
Answer: Very Late, just adding if it could help someone else.
In the latest versions of AVD emulators if you set a PIN Code/Pattern Security and checked "Require to start device". It happens just disable it or first make your Emulator boot completely before you run application. This happened To Me

After This I Press Back Button and entered pin and made device boot. After boot when I re-run, It Worked Fine. by the way I was using Captcha Service which required play services.


How to get id from URL as variable? In Node.js

Question: This is my express app running on Node.js

var express = require('express');
var app = express();

app.get('/', function(req, res){
  res.send('id: ' + req.query.id);
});

app.listen(3000);
console.log('working...');

//so i need url id as var
var gotID = req.query.id

//want to use this data to another js file
module.exports = gotID;

So I want that URL id as my variable.
Which is look like this URL

http://localhost:3000/[id that i want]

So what should I do?
I'm new to Node.js
Answer: This should work for you:
app.get('/:id', function(req, res) {
    res.send('id: ' + req.params.id);
});

req.query is used for search query parameters (i.e. everything after ? in http://something.com/path?foo=var)
Comment: If you need query parameters you should use `req.query`. `req.params` is for path parameters
Comment: Thanks for help but i had problem about url. this sytanx http://something.com/path?foo=var didnt work  and i used like that http://something.com/path/var


Does FLow Machine's AI music-generating algorithm rely substantially on current music theory?

Question: An example of Flow Machines artificial intelligence music generator can be found on Soundcloud.
Has it been discussed or published to what extent their algorithms were developed with standard music theory concepts "built-in" as opposed to just letting the AI learn "the rules" of popular (or other kinds of music) completely on its own from examples?
There is a discussion here which I have read but do not really understand. Markov models are a general mathematical tool and not specifically related to music or human experience, and that's fine. But here I'm just trying to ask if music theory was included a priori or not.
Related: Algorithms for music composition but I didn't see Flow Machines mentioned here.
Comment: I've only skimmed the page, but the mention of "Machine Learning" suggests to me that they just throw a large training set of songs in the desired style at the algorithm and then let it loose. There are links to some papers on the page, though, which probably answer the question, I just didn't have time to read them. A quick skim of the abstract and introduction of the first linked paper seems to support my guess: the only concepts that are "built-in" are "two-voice melody", "harmony", and "meter", but the *rules* are all learned using Deep Learning.
Comment: @JörgWMittag Thank you for your assessment. I just discovered that I didn't link "Discussion" correctly - I've fixed it now - it links to this [overview](http://www.flow-machines.com/overview/) which does go into more depth than the incorrectly linked page. Since I focused on the Overview page, *I missed those open access papers you mentioned*. I'll take a look at those this weekend. I'm glad you noticed and pointed them out, thanks!
Answer: I mean it uses a much logic as a Markov chain typically does which is use patterns in inputs to make an output. It will generate melodies, harmonies, rhythms, ect that are not necessarily music theory concepts. If you fed a Markov chain any book it will seem to make logical sentences, but it will not always be that way and the chain doesn't actually understand the language it just looks for patterns and the result may or may not make sense. This same idea goes for music as it will  There statement about how it's done is:

The Flow Machines project takes a computer science perspective on
  style: how can a machine understand style and turn it into a
  computational object? An object that users can manipulate to create
  new objects with their own constraints. Technically we develop new
  technologies based on Markov models. Markov processes are well-known
  tools used to model statistical properties of temporal sequences.

In general the Markov chain alone is pretty weak in making music and in fact you  will need at least a second order Markov chain to make anything make sense from a harmony perspective since tonal music's harmony goes somewhere. The key also is pretty important as the notes used in the melody and harmony will not be equally weighted for example how a C major chord is used in C major vs F major is different. In fact, the example video shows this weakness pretty well as the chords used and the melody kind of make sense, but it isn't very natural and has the meandering effect a low order Markov chain as the melody doesn't find a good point of rest.
They mention grouping styles which will help minimize these issues as mentioned in your second link:

We are currently investigating style and creativity under several
  perspectives: Technically we have made substantial progress in
  developing efficient Markov Constraints algorithms that can apply many
  types of constraints to arbitrary Markov models. Conceptually we are
  starting to build authoring tools in musical composition and text
  writing that enable people to generate content by manipulating the
  style of an existing author, possibly themselves.

Again this is not theory, but just using inputs to make an output. The chain won't understand any of the actual music theory concepts nor will it always do things that make musical sense. There's even a big red flag further down that page:

If you don't like the proposed sequence the system will suggest
  another one, and so on until you are satisfied with the result.

Which is just a way of saying "take another chance and you may like what you hear". While using a Markov chain is better than just randomly picking notes, duration, ect, it's still a long way from being aware of what it making or any of the theory behind it.

I'm not going to speculate on the exact mechanics and without looking under the hood I won't know for sure, but based on everything and what they are describing there is little to no actual music theory behind it. The only thing that is kind of theoretical is grouping the pieces by "style" before making the chains, but that's not really music theory as it is just grouping pieces that whoever made the groups thought they were similar.


Quasi and True Experiments

Question: If subjects are recruited using a convenience sample to take part in a study, and each participant is then randomly assigned to either treatment condition, A and B.
(i) Will my result be generalizable to the broader population? Yes or No
(ii) We need to be realistic that random sampling is not always possible, but random assignment to a treatment condition is possible. Statistically speaking,  what is the advantage of performing an experiment such as that described above?
(iii) If we are studying the relationship between two or more variables in this convenience sample that had random assignment, can this be inferred to the larger population?
Comment: [related](http://stats.stackexchange.com/questions/186660/randomisation-of-non-random-sample)
Comment: Thank you Glen for the link. However, this does not really answer my question.
Comment: Can you clarify (in an edit to your question) what your question is asking that is distinct from what's there, or explicitly identify what aspect of your question is not addressed there?
Answer: Short answer: Random assignment is a requirement for an experiment. It's necessary, but not sufficient.
Your question has a strong word "convenience sample" which triggers all kinds of red flags. However, you may not mean it that way.
It's obviously possible to recruit participants to a study in a scientifically rigorous manner. Medical studies do this all the time. But so do pop-psychology, recruit-some-college-students studies that are pure junk. Which are we talking about here? For the former, random assignment is a link in a solid chain, for the later it's a bandaid that's attempting to make things look scientific.
Once you've gotten a haphazard sample of convenience, nothing can get you out of that box. Nothing. So if you mean "can I recruit some students from my college for a psychology test and after that pretend it's a scientific experiment on the world's population" the answer is No. No for (i), No for (ii), No for (iii). (Again, I'd argue that (i) and (iii) are the same question, with no meaningful distinction.)
On the other hand, you could spend a LOT of time, planning, and effort to recruit a sample from the population you intend to generalize to. Or you can be satisfied with only drawing conclusions for people like the sample you actually got. Recruiting is a complication, but it's not the problem.
A lot of work outside of a laboratory is done with found data rather than experimental data. The line between "found data" and "convenience sample" is not well-defined -- certainly it's much less clear than the line between experimental data and the other two. With found data, the question is also how generalizable the results are, and there are actually Found Experiments which were unintended.
This is basic logic: a logical argument is as weak as its weakest link, and each link builds on prior links. Random assignment is necessary for a generalizable experiment, but not sufficient. Again, my (original, now deleted) example: you recruit some brothers from your fraternity to test the efficacy of (female) birth control pills. You can be as rigorous as you want after that -- double-blind, random assignment, independent verification, replication, etc -- but your initial sample put you in a box you can't get out of. You'll never be able to generalize the results to women.
Comment: To recap, I understand the answer to (i) is NO (ii) is acceptable in certain fields like social sciences. How about (iii)?
Comment: @user39531: Could you elaborate on the difference between "a result" and "the relationship between two or more variables"? Perhaps an example of the data you're thinking of and what kind of relationship you might find? I'm probably not being rigorous enough, but they sound the same to me.
Comment: A "relationship" between two variables - how one independent var influences a dependent var. It can also mean how strong the relationship (r-square) between two dependent var are.
Comment: @user39531: You haven't defined "result", and I can't imagine a result that isn't a relationship (as you define it). The bottom line is not what you're trying to do, but the fact that you are trying to extrapolate outside of your defective sample.
Comment: By  "result," I mean the findings of the study based on the convenience sample. For example, if the result suggests that "what is beautiful is usable." Can this result be generalized to the broader population?
Comment: And by "what is beautiful is useful" you mean that you found a relationship between an independent variable or variables ("beautiful") and a dependent variable or variables ("useful"). These variables may be structural or latent. Still, in any case, you are coming to some conclusion that you want to extrapolate well beyond the poorly-chosen subset of your population. If you had planned, you would be doing something ,ore like interploation. After-the-fact procedures can't change that much.
Comment: This is getting longer than necessary. In simple terms, I understand that findings obtained using a convenience sample is not generalizable to the actual population. In my initial posting, I asked if there is a combination of "convenience sample" and how the subjects were "randomly assigned" to two different conditions. Do we assume that the results obtained from this study can be generalizable to the actual population? Please answer yes or no. Thank you for your time
Comment: Thank you Wayne for the elaborated answer. That makes sense.
Answer: The answer to your question depends strongly on features of your experiment that aren't detailed in your description.
Consider a study that examines the limit of light detection. It turns out that the variability and absolute limit are very similar across people with otherwise good vision. A convenience sample is often perfectly adequate in this case and likely generalizes to the population of people with otherwise similar vision. However, if I were wanting to rank the production resources I put into various colours of my widget I wouldn't just ask the executives of the company to participate in a survey.

Quasi and True Experiments


elastic search optimal number of masters

Question: We currently have a cluster of 6 data node and one non-data node. Of those, two are currently master eligible. This cluster is on EC2.
What is the optimal number of master nodes, or is there a reason to discriminate at all?
Answer: A cluster cannot function without a master node. So, the number of master-eligible nodes depends on your tolerance for losing all master nodes.
It might be also helpful to have an odd number of master-eligible nodes and set discovery.zen.minimum_master_nodes to be larger than half of the number of master eligible nodes in your cluster. This should significantly reduce chances of your cluster going into split-brain condition.
For example, for a cluster with 3 master-eligible nodes, you can set discovery.zen.minimum_master_nodes to 2.
Answer: As described in Elasticsearch Pre-Flight Checklist, you can set discovery.zen.minimum_master_nodes to at least (N/2)+1 on clusters with N > 2 nodes.
Where N is the number of eligible master nodes.
Which means in your case, discovery.zen.minimum_master_nodes: 4 eligible master nodes - i.e (6/2)+1
Comment: The minimum number of master eligible nodes here is 2. If minimum master nodes is set to 4, the cluster will always be inoperable. It's best to always have more than 2 master eligible nodes for the quorum to work well.
Comment: Why did you say "in your case... 2". He mentioned 6 nodes so wouldn't that be 4 based on the formula?
Comment: @philfreo Yes it will be. I'll adjust my answer. Thanks for pointing it out.
Answer: minimum_master_nodes (the quorum) should be calculated based on the number of master nodes, not data nodes, Uyi's suggestion would be correct if and only if all of your data nodes are also master eligible nodes.
You should never have 2 master nodes, due to the potential of being in a split-brain situation, my suggestion would be, make at least 3 nodes master eligible and set minimum master node to 2.
Another thing to consider is to have smaller but dedicated master nodes, to make sure they are more stable and not under pressure from handling indexing.


Another square root question...

Question: I know $(-7)^2=49$.
I know $\sqrt{x^2}=|x|$
But how come if you take the root of both sides of the first line it looks like this:
$\sqrt{(-7)^2}=\sqrt{49}\longrightarrow-7=7$?
Comment: If you know that $\sqrt{x^2}=|x|$, then you should automatically also know that $\sqrt{(-7)^2}=|-7|=7$, not $-7$...
Comment: Because, as you state, $\sqrt x= |x| \rightarrow \sqrt{(-7)^2}=|-7|=7$.
Comment: $f(x)=x^2$ is not an injective $1-1$ function on the real numbers
Comment: The absolute value of both is equal. $\sqrt{(-7)^2}=\sqrt{49}=\text{POSITIVE}\boxed7$. But $-\sqrt{(-7)^2}=-\sqrt{49}=\text{NEGATIVE}\boxed7$. And |7|=|-7|=7$
Answer: You wrote:

$$\sqrt{(-7)^2}=\sqrt{49}\longrightarrow-7=7$$

But, you also wrote:

$$\sqrt{x^2}=|x|$$

So, how about:
$$\sqrt{(-7)^2}=\sqrt{49}\longrightarrow|-7|=7$$
Comment: The absolute value is used because the codomain of the square root function is the non-negative reals. Negative solutions are not allowed. I did not choose to represent it this way. *You* did. I used the format you provided and substituted the digits. I'm sorry this doesn't make sense to you. :(
Comment: But the reason $\sqrt{x^2}=|x|$ is because there are two potential solutions, not one. This relationship isn't an axiom or something like that, it's a relationship that was noticed due to the potential number of solutions. Your answer doesn't make sense to me. Arithmetic doesn't always work the same way as algebra. You're telling me that: $((-7)^2)^{1/2}=7$?
Comment: @zduff Yes, I'm telling you that $\sqrt {(-7)^2}=7$. That's how it's defined. Moreover, that's what you wrote when you wrote that $sqrt{x^2}=|x|. You said it before I did.
Comment: The part I don't understand is how: $\sqrt{(-7)^2}=((-7)^2)^{1/2}\neq((-7)^{1/2})^2$
Comment: I didn't choose to represent it that way. That's the way square root function is defined.
Answer: Never mind, found an answer that is satisfying. I realized that my conceptual problem was with the way square root functions are defined. They are defined to have a positive codomain so that they can remain a function. Here's a link:
Proving square root of a square is the same as absolute value
Comment: When you wrotr, "I know $\sqrt{x^2}=|x|$
," I thought you were satisfied with that definition. Sounds like it's the definition that was creating the problem for you. Glad you found your answer.

Another square root question...


Display solr result by specific field order

Question: I am implemented the Apache Solr with Search API module.
Everything working fine but now requirement is to show solr result by specific field order.
I have total 4 fields in content type

Field 1
Field 2
Field 3
Field 4

Now solr show result random order from this field i.e any field coming on top.
I need to show result by field order. i.e display all result on top by matching "field 1" then "field 2" and so on.. Anyone can help me to achieve this result...
Answer: I am resolve my problem by using edismax of solr.
Ref Link: https://cwiki.apache.org/confluence/display/solr/The+DisMax+Query+Parser
http://localhost:8983/solr/collection1/select?q=search_word&wt=json&indent=true
&defType=edismax&qf=field_1^20+field_2^19+field_3^18+field_4^17&pf=field_1+field_2+field_3+field_4


Please help me with python loop/if statements

Question: *> Repeatedly loop, prompting the user to select an option, then running

the appropriate commands and repeating until the user chooses to exit.
  The options are: 0 to exit the program; 1 to calculate a flow rate for
  a specific collection of values; 2 to calculate a Reynolds number, and
  3 to plot expected flow rates. If the user selects any other option,
  the program must keep asking them to select a valid value, until they
  do so.*

while i<=3:
i=input (" Please enter a number between 0-3:")

if i==0:
    print " program will exit."
    break

elif i==1:
     print ( " To calculate flow rate please input these values:" )
     pressure = input (" Please enter pressure drop in pascals: " )
     radius = input  (" Please enter radius in m: " )
     viscosity = input  (" Please enter viscosity of liquid in Pa.s: ")
     Length= input  (" Please enter length in m: " )
     Flowrate = (pressure * pi *(radius**4))/ ( 8 * viscosity * Length)
     print " Therefore, flow rate is " , Flowrate
     print " Program will run again for user to calculate flow rate..."

elif i==2:
    print ( " To calculate reynolds number please input these values:" )
    q=input ("Please enter a value for flow rate in m^3/s")
    radius = input  (" Please enter radius in m: " )
    density=input   (" Please enter density in kg/m^3 : " )
    viscosity = input  (" Please enter viscosity of liquid in Pa.s: ")
    Rno=(2*q*radius*density)/(viscosity*pi*radius*radius)
elif i==3:
    print " not implemented yet."
else:
    print " Program will start again!"

    ***new edited post***

Answer: One error I could spot is here:
Rno=(2*q*radius*density)/(viscosity*pi*radius*radius

Your code is missing a closing parenthesis.
Another (logical) error is that the input() call should be inside the loop, not outside it.
Comment: Recently, so many people are missing the `)` at the end of the line. Something weird is happening in this world.
Answer: I typically have people lay out these sorts of programs like
while(True):
    i = input("<Prompt>")

    if(i==1):
        # Do something

    elif(i==2):
        # Do something else

    #... any additional elifs

    else:
        break

Or like this
while(True):
    i = input("<Prompt>")

    if(i==1):
        # Do something

    elif(i==2):
        # Do something else

    #... any additional elifs

    elif(i==10):        # Assuming 10 here is the "exit" option
        break

    else:
        print("Unknown selection, please try again")

The second version requires the user to explicitly select the "exit" option while the first version will simply exit when an unknown/undefined option is selected.
Comment: So im meant to have the i=.... in the loop but its saying variable is not defined.
Comment: @user2228719: Yes, otherwise you'll only call it once and not prompt the user again.
Comment: @user2228719: As long as your put the `i=...` in a place where it will always be called before any place you use it, you shouldn't get that error.  Make sure that line is the first line in your `while` loop.
Comment: Oh okay! I have put it in my loop, on the first line. But, you said its needs to be called before any place I'm using it. Im using it on the first line of the while statement, so do I need to introduce another variable or...get rid of the i somehow?
Comment: Can you edit your post to show your new code?
Comment: yup done. The indentations are not really shown cos I copied and pasted it from my program.
Comment: Your while loop's condition includes `i` -- thats why you're getting the error.  Change it to `while(True):` and add an `elif:` option for exiting similar to my code examples.
Answer: You've said that your program should exit after user enters 0, so I would change this:
if i==0 :
    print " program will exit."
    i=4

to this:
if i==0 :
    print " program will exit."
    break

And also, you don't need to assign 0 to i in the second if, because i is already equals 0 in this block, so you can safely delete this line of code.
Comment: Thanks everyone! :OOO I didn't expect such quick responses.


Is there a standard notation for "Happy Birthday" with two names?

Question: When singing the well-known Happy Birthday song, is there a standard or official way of having two names? The measure has to be elongated, and there's a question of which note to sing the first name on.
Tempo
Should I change the time signature for that measure to fit the required notes? Or should the tempo be drastically reduced for the names and fit them within the standard two-quarter-note length?
Time Signature

Tempo

First name's note
As a second question, does the first name stay on the same note as the preceding "dear... ", or do both names get sung at the half step below?
Same Note

Step Below

I'm trying to find the right way to notate the music for two names. Is one more correct over the other? Or is this all opinion based?
Comment: In my limited experience with any double party,  people tend to say "Hyppolita and Aristosthenes"  as fast as they can to fit into the original meter. :-)
Comment: 2 cakes, and sing twice, or be prepared to deal with "She blew out my candle".
Comment: There may not be a standard, at least not in published form, because of copyright claims (which were largely thrown out last September).
Comment: It's going to depend a lot on the number of syllables in each name. There are a lot of combinations. 'Happy birthday to the twins' fits quite well...   Or - sing it twice; in order of birth time.
Comment: … with a rubato to get their breath back ;)
Comment: I thought "Annabell" would be sung entirely on the E, with none of the syllables being sung on the F# (unlike all of your examples).
Comment: I would slow down the tempo of the entire piece quite a bit so you can sing both names within the same measure without altering the time signature for just the one measure and keep the meter consistent throughout the piece.
Answer: If performing solo (or with rehearsal), I'd go for a melismatic approach. If for a group singing, just hold on the note until the crowd thinks it's finished. There doesn't seem to be any standard.
Answer: Personally, I would prefer sticking to the 8.-16 pattern with the step-down in the melody at each name's last syllable.
For the line "Happy birthday, dear Elizabeth and Annabell", it would mean:
d8. d16 d'4 b g8. g16 \time 5/4 g8. g16 fis8. fis16 fis8. fis16 e4\fermata

With an additional rest, the time signature does not even need to change:
d8. d16 d'4 b g8. g16 g8. g16 fis8. fis16 fis8. fis16 e4\fermata r4


How to analyze the relationship between two variables in a time sequence

Question: I have a question about how to analyze the relationship between two variables in a time sequence.
It is an eye-tracking experiment. I recruited two separate groups of Mandarin speakers to describe pictures with two characters, one group with native language Mandarin (L1) and one with second language German (L2; Language is independent variable). I would like to measure the fixation distribution/proportion on the two characters along the time when they plan their descriptions. So the fixation proportion is the dependent variable. Besides,I worked out a dataset included time information as below (The whole time from the picture onset was divided into separate time bins, each time bin 40 ms).
Stimulus   Participant   Areas         time_bin     Language
1          M1             character1     1               1
1          M1             character1     2               1
1          M1             character1     3               1
1          M1             character1     4               1
1          M1             character2     5               1
1          M1             character2     6               1
1          M1             character2     7               1
1          M1             character2     8               1

1          G1             character1     1               2
1          G1             character1     2               2
1          G1             character1     3               2
1          G1             character2     4               2
...

The question is (1) within a speaking group, the relationship between time bin and fixation distribution and (2) between groups, the relationship between language and fixation distribution along the time. Still, it would be good to treat the stimulus as a random effect, because both groups described the same stimuli.
I do not know how to deal with analysis with time sequences. I have searched quite a lot and find there are different methods such as growth curve analysis or fixed-time effect testing and so on. But I am not sure which method would be good.
Do you have some ideas or suggestions about how to solve the problem?
Answer: I'm going to be careful with this answer, since I think some things are not entirely clear. Also, bear in mind that there are multiple perspectives to data analyses, thus it is perfectly normal that there is more than one approach to analysing your data.
I will assume the below:

That pictures are the stimulus.
That there are several pictures shown to each participant.
Since you referred to growth curve analysis (GCA), that time is treated as a temporal continuous variable --  GCA is just a multilevel model with higher order polynomials (consider Mirman's book for a really basic and easy to read overview http://www.danmirman.org/gca).
That subjects are nested within language group, as each subject can only be within one language group (see more about nesting here: https://bbolker.github.io/mixedmodels-misc/glmmFAQ.html#nested-or-crossed and here: https://www.theanalysisfactor.com/the-difference-between-crossed-and-nested-factors/)

Considering these assumptions, I will follow the GCA approach. To answer 1 and 2, I think one plausible model could be:
Proportion ~ time_bin*Language + (1|Participant/Language) + (1|Stimulus)
However, the above assumes that the relationship between time and proportion is linear. People using GCA typically assume that time has a non-linear relationship with the outcome. If you assume that the relationship between time and proportion is non-linear, for example quadratic or cubic, you will need to incorporate these higher-order terms in your model. An added complexity is that polynomials are correlated, therefore the estimated parameters will be interdependent. You may want to create orthogonalized polynomials to avoid the potential problem of collinearity between the different time terms. The code below will create independent (orthogonal) polynomial time terms (linear, quadratic, and cubic).
t <- poly((unique(data$time_bin)), 3)
data[,paste("ot", 1:3, sep="")] <- t[data$time_bin, 1:3]

I do not know what kind of relationship is justified by theory/your research questions. To change the number of orthogonal terms generated you can change 3 to a larger or smaller number. For example, changing to 2 will create two additional columns in your dataframe with linear and quadratic terms of time, whereas changing it 4 four will add cubic and quartic. Be careful of over-fitting though.
After creating these polynomial terms, your model may look something like this:
Proportion ~ (ot1+ot2+ot3)*Language + (1|Participant/Language) + (1|Stimulus)

I have ignored something up to now, and that is that your outcome is a proportion (if I understood your question correctly). If that is the case, I would suggest that you consider running a binomial generalised linear mixed-effects model with weights or a beta regression (see: Fitting a binomial GLMM (glmer) to a response variable that is a proportion or fraction and How to apply binomial GLMM (glmer) to percentages rather than yes-no counts?).
Another thing to consider is the random effects structure. The candidate models above are considering variation in the intercepts, but you may also want to consider variation in the slopes. Once again, be careful of over-fitting (I would suggest Bates et al. https://arxiv.org/abs/1506.04967 and Matuschek et al. 2017 https://www.sciencedirect.com/science/article/pii/S0749596X17300013).
Comment: Hello @Michael R! Thanks for your answer! It's very helpful! I still have two questions:
1. I just tried to following code and recieved a "subscription out of bound":

Gaze_600ms_proportion_compare_Poly <- poly((unique(Gaze_600ms_proportion_compare$Bin)), 3)

Gaze_600ms_proportion_compare[,paste("ot", 1:3, sep="")] <- Gaze_600ms_proportion_compare_Poly[Gaze_600ms_proportion_compare$Bin, 1:3]

Do you have an idea to debug the error? I checked the types of variables and they should have no problem.
Comment: And my second question is about the type of dependent variable in GCA. You mentioned that the "proportion" is the dependent variable, which is linear. Is it possible to directly have the "areas" in the sample data as  (categorical variable) in a GCA and then have a logit regression? Thanks again for your generous help!
Comment: Hi @内卡厨房NeckarKitchen. The code should work; copy and paste what I wrote; change only "data" and "time_bin". Where I wrote data, specify the name of your data frame. time_bin should be replaced with the name of your time variable in your data frame. If your outcome is continuous and approximately normal, you can run a linear mixed-effects model, if it is a proportion or binary, you can run a generalised linear mixed-effects model -- GCA is just a regression with polynomial terms; both outcome types are fine. In your question you mentioned proportion; see the links provided in my answer.


Anyone seen a helper program to create a changelog for a server?

Question: I am working on getting our Linux (and eventually Windows if possible) systems setup so that we can monitor administrative changes and have a history of them to refer to.  Currently, I have a pretty good setup going with etckeeper, logwatch, and mercurial.
I would like to make this just a bit more robust by nagging any admin when they logoff with a message that asks them if they would like to create a changelog for what they just did on the server.  A "no" answer would continue the logoff process and a yes answer would take them to whatever editor they use where they could enter whatever they wanted about what they just changed on the system.  The changlog helper would then add some standard formatting to what they put there (add a date/time, username, indent, rewrap to 70 chars per line, etc.) and prepend that to a file somewhere on the system.  I would then include that changelog in the monitoring setup I have already which would result in it being version controlled and sent to a centralized location.
I am envisioning something that would look and work very much the way the commit/comment feature works with mercurial/git/svn, except the comment gets formatted different and saved to a file locally.  Bonus points for having some pre/post commit hooks or otherwise being able to customize it.
Thanks.
Answer: Two simple ideas come to mind:

Utilize the "logger" command to let admins send one-liners to syslog.  Since the user name is included, it makes for easy scripted reporting.  If you're logging to a central host, you get these changes logged centrally as well.
Simply appended all changes to /etc/motd, not only documenting the changes, but also displaying them to everyone when they log on.

Both methods lend themselves well to being done manually by faithful admins or by scripting.
Comment: I think logger is the correct answer here. An added bonus is that you're probably archiving syslog somewhere anyway, so you already have infrastructure to gather the changelog data.
Answer: Never heard of such a tool.
But I guess following can be done

Admin will write down the names of files modified in a some text file along
with the appropriate description.
Those files are then rsynced with some remote server or may be in some folder on same system with timestamp attached to it. This backup will also contain the file admin use to write about modifications.
The text file in which admin writes changes will have some standard format for writing down file names and respective description, which will be read by some bash / python / perl script before executing rsync.
Other backup tools like rdiff or rsnapshot can be used instead of rsync.
Comment: I already have the infrastructure to track changes to config files. I  am looking for a program or script solely for the purpose of facilitating the changelog.
Answer: If "whatever editor they use" happens to be Emacs, then you could make use of its change log editing commands. At the simplest, this could something as simple as running the following command
emacs -f add-change-log-entry

which will prompt for the change log file location, and automatically create a new entry with name, email address, and date, ready for editing.
Comment: Thanks for the suggestion, however I would prefer for this script to use the user's default editor (just like hg/svn commit) and I wouldn't want the user to have to specify the file.
Answer: use of something like iwatch or tripwire should be able to show you diffrences on files. - then save these reports with comments somewhere.
Comment: For clarification, I am already tracking changes to files.  I am only looking for info on a changelog "helper" program or script at this point.
Answer: I'm no Linux expert but it seems to me you would need to hook the system to capture any way the admin might log off the system. e.g. If someone typed exit at the console to log off, it would be necessary to have the shell perform a completely different action to it's normal response to exit, otherwise the user will simply be logged off.
Is that possible? Perhaps, but it would mean customising the shell(s). Of course I might be wrong and there is already a convenient way to hook the built-in commands bit if there is I don't know about it.
Of course none of the above would help at all if the user in question accessed the system remotely, such as via SSH.
Answer: I specifically don't document anything on servers. We use puppet, which is the canonical configuration resource for servers. The configuration for puppet is in version control. If a server needs to be rebuilt, we use puppet to do that. Any configuration that wasn't in puppet is lost. Therefore most configuration is in puppet and the changelog is in puppet commits.


GoogleMap onCameraIdle event not firing

Question: I'm trying to clustering the markers on google map because there's too many markers on the map (approximately 6000+ markers).
So I googled and found some documentations about marker clustering and I apply it to my source code, but markers are not shown in google map.
Partial source code of FragMap fragment.

@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    SupportMapFragment map = (SupportMapFragment) getChildFragmentManager().findFragmentById(R.id.display_map);
    if (map == null) {
        Log.e(Tag, "Google Map fragment(id: display_map) is null reference!");
        return;
    }

    map.getMapAsync(this);
}

@Override
public void onMapReady(GoogleMap googleMap) {
    if (DataPackage.getEQMarkerManager() == null) {
        if (!DataPackage.initializeEQMarkerManager(getActivity(), googleMap)) {
            Log.w(Tag, "EQMarkerManager initialization failure");
        }
    }
}

and partial source code of EQMarkerManager and it's implements GoogleMap.OnCameraIdleListener interface.

public EQMarkerManager(Context ctx, GoogleMap map) {
    // ...
    clusterManager = new ClusterManager<>(ctx, map);
    clusterManager.setRenderer(new EQRenderer<>(ctx, map, clusterManager));

    map.setOnCameraIdleListener(this);

    clusterManager.addItems(markers);
}

@Override
public void onCameraIdle() {
    Log.d(Tag, "onCameraIdle");
}

but onCameraIdle callback was never called. Why OnCameraIdle event is not firing?
gradle:
compile 'com.google.android.gms:play-services-maps:9.8.0'
compile 'com.google.maps.android:android-maps-utils:0.4.4+'

Tested on Marshmallow device (SDK version 23).
ADDED: What is the meaning of + on gradle compile?
Comment: Did you receive any error message? You might miss something. Check the sample code here which demonstrate event listener: https://developers.google.com/maps/documentation/android-api/events#code_samples
Comment: @d.datul1990 thanks for your interest, but unfortunately I haven't receive any error messages :/
Answer: The 'onCameraIdle' event was not firing because I called 'setOnCameraIdleListener' on another class.
Source code from my question
FragMap:
@Override
public void onMapReady(GoogleMap googleMap) {
    if (DataPackage.getEQMarkerManager() == null) {
        if (!DataPackage.initializeEQMarkerManager(getActivity(), googleMap)) {
            Log.w(Tag, "EQMarkerManager initialization failure");
        }
    }
}

EQMarkerManager:
public EQMarkerManager(Context ctx, GoogleMap map) {
    // ...
    clusterManager = new ClusterManager<>(ctx, map);
    clusterManager.setRenderer(new EQRenderer<>(ctx, map, clusterManager));

    map.setOnCameraIdleListener(this);

    clusterManager.addItems(markers);
}

initializeEQMarkerManager method does initialize EQMarkerManager class and EQMarkerManager#ctor calls setOnCameraIdleListener.
I don't know much about android, so I'm completely sure about those code works.
But it wasn't :/
Anyway, I solve this problem by calling setOnCameraIdleListener inside of FragMap.
@Override
public void onMapReady(GoogleMap googleMap) {
    if (DataPackage.getEQMarkerManager() == null) {
        if (!DataPackage.initializeEQMarkerManager(getActivity())) {
            Log.w(Tag, "EQMarkerManager initialization failure");
            return;
        }
    }

    googleMap.setOnCameraIdleListener(DataPackage.getEQMarkerManager());
}

Answer: The 'onCameraIdle' will not fire because 'setOnCameraIdleListener' is called internally by ClusterManager class . So what we can do is
mmap.setOnCameraIdleListener(this);

When implementing OnCameraIdleListener
    @Override
    public void onCameraIdle() {
        clustermanager.onCameraIdle();
    }

GoogleMap onCameraIdle event not firing


Best way to inform users after file upload

Question: I'm searching for a good solution to inform users after a file was uploaded (with standard upload URL: <code>...file/add</code>).
I would solve this with rules, but I can't find the right events for this.
Has anybody a good idea.
Answer: Have you checked out the Entity Rules module? I believe this is exactly what that module is for.
I did a brief check and you can create a reaction rule on a Create Entity action and then check the type of that entity.
Comment: Thank you, with this module I got the events I need to check for. With it I could solve the first step, but the 2. is a little bit more complex.
The files were tagged with a term, a term stands for a role. Now only the users which have the specific role, which belongs to the term, should get an email - not all of the users.
Comment: If you're trying to relate a taxonomy term representing a role to users with that role, you may find some difficulty in doing so. The best way I could see doing that is having a Rule for each role. That way you could check the Term value you set on the File entity and send the email to all users of a specific role. If you only have a few terms/roles to relate, then that shouldn't be a problem. If you have many [and/or it may change overtime] then this option may not work and you'd need to figure out a different way to relate the Term to the Role.
Comment: If the answer solved your initially posted question please consider marking it as such. Thanks!


trouble with search in angular

Question: I'm new to angular and experiencing some difficulty implementing a 'live search' type of feature. I have my JSON set as a variable in a javascript file and I am able to display that in the html with no problem. I then have a 'list' radio box which changes the size of the display. This is functional as well. I run into trouble, however, when accessing the reverse filter option which is denoted with another radio button. The intended result is to filter the book titles in reverse by their name, ye nothing happens. Here is my JSON if you want to see the structure. And below is the code where I try to perform the filter reverse action:

{{books.doc.name}}

and heres the js:
angular.module("myApp",["ngSanitize"])
.filter('replace', function () {
var pat = / /gi;
return function (text) {
    var clean = text.replace(pat, "-");
    var temp = clean.split("---");
    if (temp.length>1) {
      clean = temp[0];
    }
    return clean;
};
})
.controller("Example", function($scope, $interval) {
$scope.search = "orig";
$scope.books = books;
$scope.reverse = false;
$scope.list = false;
});

Comment: Do you have a boolean variable `reverse`? It's supposed to be a boolean https://docs.angularjs.org/api/ng/filter/orderBy
Comment: I do have a boolean var for reverse. sorry, heres the js: `angular.module("myApp",["ngSanitize"])
.filter('replace', function () {
    var pat = / /gi;
    return function (text) {
        var clean = text.replace(pat, "-");
        var temp = clean.split("---");
        if (temp.length>1) {
          clean = temp[0];
        }
        return clean;
    };
})
.controller("Example", function($scope, $interval) {
  $scope.search = "orig";
  $scope.books = books;
  $scope.reverse = false;
  $scope.list = false;
}); `
Comment: Don't put code here, edit your question.
Answer: I figured this out. Angular filter will not work on a json object, rather the data must be in the form of a json array. I removed the highest level enclosing curly brackets and replaced them with square brackets in addition to removing the numbers and colons like "1272:" that can be seen in the json file I posted. Taking these steps converted my data to a json array and allowed me to use the live search functionality.

trouble with search in angular


How to insert a shape in a powerpoint slide using OpenXML

Question: This question could seem rather basic, but how do I insert a shape (i. e. a rectangle) in a slide using OpenXML in c#?
I've searched around and all I see is "create a slide with the shape and use the SDK Productivity Tool to reflect the code. That's not really helpful :(
Answer: After hitting my head against the wall for a while, finally I took the advice, created a slide with the shape and used the tool to reflect the code. So for next generations, here is a brief explanation of how to do it by hand.
Firts of all you have to know is that a shape is inserted into a ShapeTree, which is part of a CommonSlideData:
Slide s = GetDesiredSlide(); // Get the slide where you want to insert the shape.
s.CommonSlideData.ShapeTree.Append(GenerateShape());

Second you should know is that a shape must contain at least 4 childs that describe its behavior:

A ShapeStyle object
A ShapeProperties object
A TextBody object
A NonVisualShapeProperties

In the sample code bellow I am using the following namespaces and variables:
using System;
using System.Collections.Generic;
using System.Linq;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Presentation;
using D = DocumentFormat.OpenXml.Drawing;

D.ShapeTypeValues shapeType; // Any of the built-in shapes (ellipse, rectangle, etc)
string rgbColorHex; // Hexadecimal RGB color code to fill the shape.
long x; // Represents the shape x position in 1/36000 cm.
long y; // Represents the shape y position in 1/36000 cm.
long width; // Shapw width in in 1/36000 cm.
long heigth;// Shapw heigth in in 1/36000 cm.

ShapeStyle Object
The shape style object describes general shape style attributes like the borders, the fill style, the text font and the visual effect (shadows, and other)
ShapeStyle shapeStyle1 = new ShapeStyle();

D.LineReference lineReference1 = new D.LineReference() { Index = (UInt32Value)2U };

D.SchemeColor schemeColor2 = new D.SchemeColor() { Val = D.SchemeColorValues.Accent1 };
D.Shade shade1 = new D.Shade() { Val = 50000 };

schemeColor2.Append(shade1);

lineReference1.Append(schemeColor2);

D.FillReference fillReference1 = new D.FillReference() { Index = (UInt32Value)1U };
D.SchemeColor schemeColor3 = new D.SchemeColor() { Val = D.SchemeColorValues.Accent1 };

fillReference1.Append(schemeColor3);

D.EffectReference effectReference1 = new D.EffectReference() { Index = (UInt32Value)0U };
D.SchemeColor schemeColor4 = new D.SchemeColor() { Val = D.SchemeColorValues.Accent1 };

effectReference1.Append(schemeColor4);

D.FontReference fontReference1 = new D.FontReference() { Index = D.FontCollectionIndexValues.Minor };
D.SchemeColor schemeColor5 = new D.SchemeColor() { Val = D.SchemeColorValues.Light1 };

fontReference1.Append(schemeColor5);

shapeStyle1.Append(lineReference1);
shapeStyle1.Append(fillReference1);
shapeStyle1.Append(effectReference1);
shapeStyle1.Append(fontReference1);

ShapeProperties
Define shape's visual Properties like Fill method (solid, gradient, etc.) Geometry (size, location, flipping, rotarion) Fill and Outline.
ShapeProperties shapeProperties1 = new ShapeProperties();

D.Transform2D transform2D1 = new D.Transform2D();
D.Offset offset1 = new D.Offset() { X = x, Y = y };
D.Extents extents1 = new D.Extents() { Cx = width, Cy = heigth };

transform2D1.Append(offset1);
transform2D1.Append(extents1);

D.PresetGeometry presetGeometry1 = new D.PresetGeometry() { Preset = shapeType };
D.AdjustValueList adjustValueList1 = new D.AdjustValueList();

presetGeometry1.Append(adjustValueList1);

D.SolidFill solidFill1 = new D.SolidFill();
D.RgbColorModelHex rgbColorModelHex1 = new D.RgbColorModelHex() { Val = rgbColorHex };

solidFill1.Append(rgbColorModelHex1);

D.Outline outline1 = new D.Outline() { Width = 12700 };

D.SolidFill solidFill2 = new D.SolidFill();
D.SchemeColor schemeColor1 = new D.SchemeColor() { Val = D.SchemeColorValues.Text1 };

solidFill2.Append(schemeColor1);

outline1.Append(solidFill2);

shapeProperties1.Append(transform2D1);
shapeProperties1.Append(presetGeometry1);
shapeProperties1.Append(solidFill1);
shapeProperties1.Append(outline1);

TextBody
Defines the textbox attributes like number of columns, alignment, anchoring, etc.
TextBody textBody1 = new TextBody();
D.BodyProperties bodyProperties1 = new D.BodyProperties() { RightToLeftColumns = false, Anchor = D.TextAnchoringTypeValues.Center };
D.ListStyle listStyle1 = new D.ListStyle();

D.Paragraph paragraph1 = new D.Paragraph();
D.ParagraphProperties paragraphProperties1 = new D.ParagraphProperties() { Alignment = D.TextAlignmentTypeValues.Center };
D.EndParagraphRunProperties endParagraphRunProperties1 = new D.EndParagraphRunProperties() { Language = "es-ES" };

paragraph1.Append(paragraphProperties1);
paragraph1.Append(endParagraphRunProperties1);

textBody1.Append(bodyProperties1);
textBody1.Append(listStyle1);
textBody1.Append(paragraph1);

NonVisualShapeProperties
Define non visual properties like the Name and the Id.
NonVisualShapeProperties nonVisualShapeProperties1 = new NonVisualShapeProperties();
NonVisualDrawingProperties nonVisualDrawingProperties1 = new NonVisualDrawingProperties() { Id = (UInt32Value)4U, Name = "1 Shape Name" };
NonVisualShapeDrawingProperties nonVisualShapeDrawingProperties1 = new NonVisualShapeDrawingProperties();
ApplicationNonVisualDrawingProperties applicationNonVisualDrawingProperties1 = new ApplicationNonVisualDrawingProperties();

nonVisualShapeProperties1.Append(nonVisualDrawingProperties1);
nonVisualShapeProperties1.Append(nonVisualShapeDrawingProperties1);
nonVisualShapeProperties1.Append(applicationNonVisualDrawingProperties1);

Putting all together
Finally you have to create the shape object and append these properties to it:
Shape shape1 = new Shape();
shape1.Append(nonVisualShapeProperties1);
shape1.Append(shapeProperties1);
shape1.Append(shapeStyle1);
shape1.Append(textBody1);

And then, add the shape to the slide's shape tree:
s.CommonSlideData.ShapeTree.Append(shape1);

Comment: Good job dude! This seems to be a good start. The examples and explanations of the msdn side are low and I have like thousand questions about the mechanics. But i think everyone need to find that out on his own way.


How to pass Arguments when call require_ok '*.pl' to test by Test::More

Question: I'm wondering the way to test each Subroutings in *.pl files individually.
But Can't use 'require' clause because some *.pl requires Arguments.
for example
use Test::More;
require "some.pl"

will always fail Test at 'require'.
because "some.pl " required a argument and end with
exit(0);

of the file.
I just want to test "Func1,usage,...whatever," every subroutings in '*.pl' individually.
some.pl is like that
my ( $cmd) = @ARGV;
if (!defined $cmd ) {
    usage();
} else {
    &Func1;
}
exit(0);

sub Func1 {
      print "hello";
    }

sub usage {
     print "Usage:\n",
    }

How can I write a test code for "sub Func1" by "Test::More"?
Any suggestions appreciate.
Comment: What do you want to test `Func1` for? It does not return any value. What do you try to do? [Test::Simple - tutorial](https://metacpan.org/pod/Test::Tutorial)
Comment: Thanks comment ,Polar.
poor explanation for my apology.
Update my question.
Still need your help.
Thanks
Comment: Still, your comment in the question is not clear. Normally tests are written to verify that a Module functions produce result properly. As rule return value from some function is compared with expected -- if return value match es then it passed the test. In you case both functions print some string in the terminal and no value returned. Or you just want to see that they fulfill their function -- print "hello" in one case and "Usage" in other?
Comment: Thanks Polar, You are right. now new problem come up one after another.
I have to struggle with this problem you pointed out in next stage.
Comment: If you have a `.pl` file that contains subroutines you want to use externally, it sounds like you have a Perl 4 style "perl library". You should update this to the modern age by making it a [module](https://perldoc.pl/perlmod). Then you can load the module and run its subroutines via the full package name, or import the subroutines from the module into your namespace. Finally you can make a script that also uses the same module, and does the script-specific logic like exit().
Comment: Thanks for your advise. I've taken over these old perl assets from generation to generation . That's why I'm in a trouble.What  you mentioned  "It's OLD STYE" is really consideration to me. I'm a middle level in perl . Updating these files to  modern style shold be paramount.
Answer: To exercise a standalone script that you expect to exit, run it with system. Capture the output and inspect it at the end of the system call.
use Test::More;
my $c = system("$^X some.pl arg1 arg2 > file1 2> file2");
ok($c == 0, 'program exited with successful exit code');
open my $fh, "<", "file1";
my $data1 = do { local $/; <$fh> };
close $fh;
open $fh, "<", "file2";
my $data2 = do { local $/; <$fh> };
close $fh;
ok( $data1 =~ /Funct1 output/, "program called Funct1");
ok( $data2 !~ /This is how you use the program, you moron/,
    "usage message not printed to STDERR" );
unlink("file1","file2");


curl nor wget was found

Question: When I use drush to download modules, I get this weird error:
drush dl registry_rebuild
exec(): Unable to fork [wget --version 2>&1] exec.inc:150 [warning]
exec(): Unable to fork [curl --version 2>&1] exec.inc:150 [warning]
exec(): Unable to fork [which curl 2>&1] exec.inc:150 [warning]
wget nor curl executables found. [error]
which wget gives me /usr/bin/wget and which curl gives me /usr/bin/curl. /usr/bin/ is in my PATH. This seldom works if I do drush cc drush. How do I solve this permanently?
Comment: possible duplicate of [wget or curl executables not found. Curl activated but not working](http://drupal.stackexchange.com/questions/12453/wget-or-curl-executables-not-found-curl-activated-but-not-working)
Comment: That error in on windows. Besides, my error goes away temporarily if I do a `drush cc drush`
Comment: which OS you are using?
Comment: I am using CentOS.
Comment: I tried to download and enable facetapi, and I got the errors again. I cc'd all, then there were no problems.
Answer: On Centos, to install wget:
sudo yum install wget

To install curl the following should suffice:
sudo yum install php-curl
sudo service httpd restart

++++++++++++++++++++ EDIT +++++++++++++++++++++++++
According to this post, "unable to fork" errors are likely to result from too many processes running.  They recommend increasing the limit like so:
sysctl -w kern.maxprocs=1000000

Comment: The op states that the commands are installed, this is tested by using 'which'.
Comment: well that's how you install them. :)  if it says they're installed, you should be able to use them. If you can't, it's possibly because the path hasn't been exported.
Comment: Right, I realize that's how they are installed, but that doesn't answer the question. It possibly is a path issue, but the op also states that the relevant directory _is_ in the `PATH` already.
Comment: oops, you're right. :s I've edited my answer to be more relevant.
Comment: `sysctl -w kern.maxprocs=1000000
error: "kern.maxprocs" is an unknown key`
Answer: On nginx on aws, I've found the php-fpm can get out of hand. To tell if that's happened, ps -ef |grep php-fpm|wc -l. If the number is more than 10 or so, you can reset php-fpm with: sudo service php-fpm restart
Answer: I fix the "Unable to fork could" with Drush by restarting my server.
I think @Ollie's anwser is right.

curl nor wget was found


ConcurrentModificationException while displaying chats in recyclerView

Question: I am displaying chats in fragment through firebase but it gives ConcurrentModificationException error.

Below is the code in which error is occuring.
CODE:
<code>public void readChats() {
    mUsers = new ArrayList<>();
    reference = FirebaseDatabase.getInstance().getReference("Users");
    reference.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
            mUsers.clear();
            for (DataSnapshot snapshots: dataSnapshot.getChildren()) {
                User user = snapshots.getValue(User.class);
                for (String id :usersList) {
                    if (user.getID().equals(id)) {
                        if (mUsers.size()!=0) {
                            for (User user1 : mUsers) {
                                if (!user.getID().equals(user1.getID())) {
                                    mUsers.add(user);
                                }
                            }
                        } else {
                            mUsers.add(user);
                        }
                    }
                }
            }
            userAdapter = new adapter(getContext(), mUsers);
            recyclerView.setAdapter(userAdapter);
        }
</code>
Comment: it can't occur on the place where the cursor is. SHow the line
Comment: If you consider at some point in time to try using [Cloud Firestore](https://firebase.google.com/docs/firestore/), here you can find a tutorial on how to create a complete and functional [Firestore Chat App](https://www.youtube.com/playlist?list=PLn2n4GESV0Ak1HiH0tTPTJXsOEy-5v9qb).
Answer: If you're looping over a Collection via its Iterator (like in a for(var : collection) loop ), you can't change that collection while you do so.  Doing so is a ConcurrentModification, and invalidates the iterator.
In addition, your code would be broken anyway.  If the last item in mUsers isn't user1, it would infinite loop even if it concurrent modifications were allowed.


CSS Columns on UL vs DIV

Question: Why is the output for

Item

Item

Item

Item

different from

Item

Item

Item

Item

with this CSS?
.tcol
{
  -moz-column-count: 3;
  -moz-column-gap: 20px;
  -webkit-column-count: 3;
  -webkit-column-gap: 20px;
  column-count: 3;
  column-gap: 20px;
}

I don't understand why an empty line is rendered.
How can I either remove the empty line in the first list or get the bullet points in the second one?
Live demo is here.
Answer: Add margin:0 to ul
.tcol
{
  -moz-column-count: 3;
  -moz-column-gap: 20px;
  -webkit-column-count: 3;
  -webkit-column-gap: 20px;
  column-count: 3;
  column-gap: 20px;
}
ul{
    margin:0
}

DEMO
Answer: Due to the browser splitting the
 into columns, the list-style-type has been pushed out of the normal view. You can correct this by adding list-style-position: inside; property to your tcol class.
There is also a very visible difference between the two layouts, not counting the missing list-style-type. Using the Elements panel in Chrome and hovering each
 and
 you can see how the browser is laying out the column content.
The second version of your markup seems to be more "correct", with the container correctly encompassing the list-items.
Answer: Elements have default styles, browsers apply those default styles if you don't specifically define them.
It's a good practice to use a CSS reset on your projects and then define the styles the way you need them.
Here is a good source for a start:

http://meyerweb.com/eric/tools/css/reset/
For example in your case FireFox renders a 16px top and bottom margin for the UL element (default box model).
Comment: I disagree. I don't think it is good practice to use CSS resets. I recommend reading [one good article](http://sixrevisions.com/css/should-you-reset-your-css/) against CSS reset but also http://stackoverflow.com/questions/167531/is-it-ok-to-use-a-css-reset-stylesheet which presents sides of the discussion.
Comment: @andyb while I respect your opinion, most of the mentioned "downwards" of using a CSS reset are said to be "forgetting to place a proper replacement for the reset styles" (For presentation, for keyboards users) and also an increased size of styles. This can be overcome by well written styles.
Comment: Sorry, I am not sure I understand your point correctly as I sounds like you are also not recommending CSS resets. I agree well written styles often negate the need to have a CSS reset but sometimes they are useful, for example Twitter Bootstrap's reset.

CSS Columns on UL vs DIV


File content is being modified sent over ftp

Question: I am using openssl to encrypt my backups before send it to an ftp server where I store them.
At first, when I tried to decrypt the files I was getting this error:
openssl rsautl -decrypt -inkey ../key.server.pem -in enc.key.txt -out key.txt
RSA operation error 139759177856680:error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block type is not 02:rsa_pk1.c:190:
139759177856680:error:04065072:rsa routines:RSA_EAY_PRIVATE_DECRYPT:padding check     failed:rsa_eay.c:616:

I am following this steps to encrypt.
I thought the problem was with the encryption, but checking the md5sum of the file show me that the file on the server had changed with the one I downloaded from the ftp server. A example:
I have a file called enc.key.txt that contains a passphrase to decrypt the backup:
$ hexdump enc.key.txt
//...
//...
0000100 16e3 c2e3 cecd 2afe eb8c 9617 8d58 *0dd0*
//...

And the hexdump of enc.key.txt once downloaded to my computer differ by one value, in this line:
//...
0000100 16e3 c2e3 cecd 2afe eb8c 9617 8d58 *0ad0*
//...

I've edited the value with an hex editor and then I was able to decrypt the file, but I don't know why is the file being modified.
I am sending the backups to the ftp server with ncftp like this:
### Dump backup using FTP ###
#Start FTP backup using ncftp
ncftp -u"$FTPU" -p"$FTPP" $FTPS<<EOF
mkdir $FTPD
mkdir $FTPD/$NOW
cd $FTPD/$NOW
put enc.key.txt
lcd $BACKUP
mput *
quit
EOF

Could you help me? Thanks in advance
Answer: The character 0a is Line Feed, and 0d is Carriage Return.  In "ASCII Mode", FTP transfers between different operating systems can change these.  For instance, a Unix/Linux-native file with LF line termination uploaded to a Windows SharePoint site will have each LF changed to CRLF. Some implementations may simply change the LFs to CRs. Check to be sure you're specifying binary mode in your transfers.
The documentation for ncftp indicates that it defaults to binary mode, but does accept the binary command like most ftp clients do.  I'd insert that command before any files are transferred and see if it helps.  If it does, that means something is somehow overriding the default.
In this case, the problem apparently isn't ncftp but Filezilla on the other end.  It defaults to "Auto", which means that a file with .txt extension is ASS|U|MEd to be ASCII, and it messes with line termination.
Comment: I suspected something similar but the default for ncftp is binary. That said I would suggest adding a "binary" command before your put in order to ensure the mode is correct
Comment: Thanks, I just changed the transfer to binary but didn't solve the problem.
Comment: Now the file differ in *0ace* and *0dce*. My computer and the server are running debian. Maybe i have to change as well filezilla to binary?
Comment: @algui91, I suggest you to look at `lftp`, `wput` and `curl` tools -- they all are able to perform FTP uploads. On the other hand, do you really need to use insecure procotol? SSH which has can do `SFTP` or simple transfers (using `scp`) does not suffer from the text/binary dichotomy syndrome and is secure.
Comment: Yes, definitely set filezilla to binary.  It defaults to "auto", and when it sees "txt" will mess with line termination.