Prove that $A$ is closed if and only if $A=\ cl(A)$

Question:
Prove that $A$ is closed if and only if $A=\ cl(A)$

So this is my attempt for an answer.
Pf-Suppose $A\subseteq X$ is closed.
In the backward direction, the proof is trivial since if $A=\ cl(A)\Rightarrow A$ is closed.
In the forward direction,
Since $\ cl(A)$ is the smallest closed subset that contains $A$ then by definition of the closure of a set, we obtain the trivial answer  $A\subseteq \ cl(A)$.
Since A is closed. let $x\in \ cl(A)$ $\Rightarrow \forall r>0,\space B(x;r)\cap A\neq \emptyset\space $. Now, fix $r>0\space$ so that   $\space B(x;r)\cap A\subseteq A\ \Rightarrow x\in A$ so we obtain we obtain $\ cl(A)\subseteq A$.
So we get $cl(A)=A$
Comment: What is your definition of closed set? What are you allowed to use?
Comment: This is from Conway's "A course in point set topology." A set is closed if the complement is open, typical definition they give on any course in topology or set theory A set is open if for every x you can find a ball of radius r and is contained in the set. An element is in the closure of a set if and only if for every r>0, the intersection of the ball and the set is nonempty
Answer: The mistake in your proof is that you don't justify why $B(x;r)\cap A$ contains $x.$
Let $x \in cl(A).$ Suppose $x \notin A.$ Then $x \in A^c.$ Since $A$ is closed, therefore $A^c$ is open. Therefore there exists $r>0$ such that $B(x;r) \subseteq A^c.$ Hence  $B(x;r) \cap A = \emptyset.$ However this contradicts $x \in cl(A).$
Answer: Well one direction is trivial, because the closure of a set is by definition a certain type of closed set.
The other direction is nearly as easy because of the type of closed set the closure is.  It's the smallest closed set containing $A$.  But there is no smaller set containing $A$ than $A$ itself.


Prove that $\frac{d\ f(c)-c\ f(d)}{f(d)-f(c)}=\frac{f(\xi)}{f'(\xi)}-\xi$ for some $\xi\in(c,d)$

Question: Let $f(x)$ be a continuosly-differentiable function defined on a segment $[a,b]$ such that $a,b\in\mathbb{R}$ and $f'(x)>0$ for any $x\in(a,b)$.
Prove that for every $c,d\in\mathbb{R}$ such that $a\le c\lt d\le b$ there is a number $\xi\in(c,d)$ such that:
$$\frac{d\ f(c)-c\ f(d)}{f(d)-f(c)}=\frac{f(\xi)}{f'(\xi)}-\xi\tag{1}$$
I have started from the basic fact that there is some $\xi\in(c,d)$ such that:
$$\frac{f(d)-f(c)}{d-c}=f'(\xi)$$
That was just a start that led me nowhere. I have also tried to rewite (1) in a slightly different way:
$$\frac{d\ f(c)-c\ f(d)}{f(d)-f(c)}=\frac{\frac{f(c)}c-\frac{f(d)}d}{{\frac1c}\frac{f(d)}d-{\frac1d}\frac{f(c)}c}$$
...and then introduce function $g(x)=\frac{f(x)}x$ and play with it. And that was a dead end too.
Any hint or help will be much appreciated.
Answer: Let $\kappa=\frac{df(c)-cf(d)}{f(d)-f(c)}$, and see
$$\int_c^d\frac{1}{\kappa+\xi}d\xi=\ln\left(\frac{\kappa+d}{\kappa+c}\right)=\ln\left(\frac{\frac{(d-c)f(d)}{f(d)-f(c)}}{\frac{(d-c)f(c)}{f(d)-f(c)}}\right)=\ln(f(d)/f(c)).$$
Also,
$$\int_c^d\frac{f'(\xi)}{f(\xi)}d\xi=\ln f(\xi)\bigg|_c^d=\ln(f(d)/f(c)).$$
So, since these are both continuous functions of $\xi$, with the same integral, they must agree somewhere.
Answer: According to Cauchy's version of Mean Value Theorem, there exists an $\xi\in(c,d)$,
such that
$$
\frac{cf(d)-df(c)}{f(d)-f(c)}=\frac{\frac{c}{f(c)}-\frac{d}{f(d)}}{\frac{1}{f(c)}-\frac{1}{f(d)}}
=\frac{\left(\frac{\xi}{f(\xi)}\right)'}{\left(\frac{1}{f(\xi)}\right)'}
=\frac{\frac{f(\xi)-\xi f'(\xi)}{f^2(\xi)}}{-\frac{f'(\xi)}{f^2(\xi)}
}=-\frac{f(\xi)-\xi f'(\xi)}{f'(\xi)}=\xi-\frac{f(\xi)}{f'(\xi)}
$$


SSL Cert for AWS Client-Side VPN

Question: We are in the process of migrating to AWS from Azure. I want to use a client-side VPN on AWS instead of a Bastion. Can I create a separate SSL cert for the AWS VPN using the same domain name that's used on Azure? For example our Azure site hosts our www.example13.com web apps.  Is it possible to obtain a separate cert, from a separate CA, for *.example13.com to use with our VPN service, vpn.example13.com?
Answer: In AWS you'll need to request a certificate through the Certificate Manager. When requesting a certificate you can verify domain ownership through DNS or email.

SSL Cert for AWS Client-Side VPN


Complex Taylor Series expansion - basic examples with radius of convergence

Question: Find radius of convergence and Taylor Series $\sum_{n=0}^{\infty}a_n(z-p)^n$ of $f$ where

$f(z) = \frac{1}{1-iz}$ with $p=0$
$f(z) = \frac{1}{1-z}$ with $p = i$
$f(z) = \frac{1}{1-z}$ with $p = 2$

Now, I feel like I can't just use
$$
\frac{1}{1-z} = \sum_{n=0}^{\infty}z^n
$$
and "plug in" $z = iz$ or move $p$ around and say that for example $\frac{1}{1-z}$ around $p = 2$ is just $\sum_{n=0}^{\infty}(z-2)^n$ with radius of convergence 1. What is the correct way to do those examples? Any hints appreciated.
Answer: You can replace $z$ with $iz$ in $\frac1{1-z}=\sum_{n=0}^\infty z^n$ to get the answer to the first question.
Concerning the second one, you can do\begin{align}\frac1{1-z}&=\frac1{1-i-(z-i)}\\&=\frac1{1-i}\cdot\frac1{1-\frac{z-i}{1-i}}\\&=\frac1{1-i}\sum_{n=0}^\infty\left(\frac{z-i}{1-i}\right)^n\text{ (when $\left\lvert\frac{z-i}{1-i}\right\rvert<1$)}\\&=\sum_{n=0}^\infty\frac{(z-i)^n}{(1-i)^{n+1}}\end{align}and the radius of convergence is $\sqrt2\bigl(=\lvert1-i\rvert\bigr)$.
Can you do the third one now?
Comment: Sure. That was a typo. I've edited my answer. Thank you.
Comment: Shouldn't it be $\sum_{n=0}^{\infty} \frac{(z-i)^n}{(1-i)^{n+1}}$ in the last line?
Answer: For $p=0$, that's precisely what you should do.
For other points $p$, you do need to "move $p$ around", so to speak, but not in the way you did it in your post. Just substituting $(z-2)$ for $z$ into the power series gives you a series for a different function:
$$\sum_{n=0}^{\infty}z^n=\frac{1}{1-z} \implies \sum_{n=0}^{\infty}(z-2)^n=\frac{1}{1-(z-2)}=\frac{1}{3-z}\ne\frac{1}{1-z}.$$
What you should do instead is rewrite the original function first so that $(z-2)$ appears in it before expanding it into a Taylor series:
$$\begin{aligned}
\frac{1}{1-z}&=\frac{1}{1-z+2-2}=\frac{1}{1-(z-2)-2}=\frac{1}{-1-(z-2)}= \\
&=-\frac{1}{1+(z-2)}=-\frac{1}{1-(-(z-2))}= \\
&=-\sum_{n=0}^{\infty}(-(z-2))^n=-\sum_{n=0}^{\infty}(-1)^n(z-2)^n=\sum_{n=0}^{\infty}(-1)^{n+1}(z-2)^n.
\end{aligned}$$
And the radius of convergence is determined by the fact that we substituted $(z-2)$ for $z$, so $|z-2|<1$.
Similarly, you can handle the remaining example.
Comment: StackExchange discourages people from commenting "thanks" but I had to do it - very kind of you to point out why my "moving p around" wouldn't work. Now it seems obvious! I appreciate.


Help with Finding $\sigma$<$x$> of $ \{[0,4]\} \cup\{[\frac{4}{2^{n+1}}\frac{4}{2^{n}}): n = 0,1,2,3....\}$

Question: Quick measure theory question. This is not a homework question. I just want to know if my logic is correct.
Suppose we are given a set $X = \{[0,4]\}$U$\{[\frac{4}{2^{n+1}}\frac{4}{2^{n}}): n = 0,1,2,3....\}$
And suppose we want to generate a sigma algebra $\sigma$<$x$>.
Wouldn't $\sigma$<$x$> $ = \{\emptyset, [0,4], \mathbb{R}, \mathbb{R}^{c}\}$ because for ever n the union $\{[0,4]\}$U$\{[\frac{4}{2^{n+1}}\frac{4}{2^{n}})\}$ is just $\{[0,4]\}$?
Answer: You are confusing $[0,4] \cup [\frac{4}{2^{n+1}}\frac{4}{2^{n}})$ which is indeed equal to $[0,4]$ for all $n$ with $\{[0,4]\} \cup \{[\frac{4}{2^{n+1}}\frac{4}{2^{n}})\}$ which is equal to $\{[0,4], [\frac{4}{2^{n+1}}\frac{4}{2^{n}})\}$. The last one is a set of two subsets of reals.
Comment: So X would equal {[0,4], [2,4), [1,2), [1/2,1/40)......}?
Comment: Yes, that's right.
Comment: Thank you so much. If you don't mind, I have one more question. Say we have the set X of subsets {[0,1), [1/2, 1), (1/8,1/4)} What would be the compliment of, for example (1/8, 1/4). Would it be the union of all subsets in X such that there is no overlap between that subset and (1/8, 1/4)? In this case, [1/2,1)? Im a tiny bit confused on what the complement of a subset is.
Comment: The complement is $X$ itself as none of the element of $X$ belongs to $(1/8,1/4)$.
Comment: Isn't (1/8,1/4) in x = {[0,1), [1/2,1), (1/8,1/4)}. How could the compliment of (1/8, 1/4) be x?
Comment: $X\setminus A=\{x \in X \mid x \notin A\}$. For $X= \{[0,1), [1/2,1), (1/8,1/4)\}$, none of the reals of $(1/8,1/4)$ belongs to $X$. You're confusing $(1/8,1/4)$ with $\{(1/8,1/4)\}$. What is true is $X= \{[0,1), [1/2,1), (1/8,1/4)\} \setminus \{(1/8,1/4)\}=\{[0,1), [1/2,1)\}$


Possible to customize the look/length of CKEditor Styles dropdown?

Question: I've added custom styles to the Styles dropdown in CKEditor included by default in Drupal 8. They work fine. However, the dropdown isn't convenient for editors to use because

It isn't tall enough
There's a lot of vertical spacing between items
Items have the style they represent, taking even more space

Here's a snip of my default Styles dropdown:

It's fine that the items have the style they represent, except it can take a lot of space in the very small box, especially if the font is large. Plus there's lots of vertical spacing between items.
I've figured a [hackish] way to keep the items from taking on their represented style, producing this:

But it's still too short with a lot of space between items, so only four styles of 20 show.
QUESTION:
Is there a way to customize the look of the Styles dropdown, or at least to make it longer? Lots of reading of posts and documentation hasn't provided an answer, if there is one.
Comment: Have you tried adding a CSS to the backend that overrides the default styles? I guess CKE is a bit off-topic for here.
Comment: Thanks, @leymannx. I asked the question here because I'm using CKE in Drupal and don't know whether it's somehow different from CKE in general. I attempted to inspect the Styles dropdown, but can't actually see the dropped-down elements in the Inspector, so I don't know what id/class to apply styles to.
Answer: After a good bit of trial and error (I'm slow, but persistent), I've figured out the classes to modify the height and item styles in the CKEditor Styles dropdown. Here's an example using values that work for me:
<code>div.cke_combopanel {
  height: 300px !important;
}
li.cke_panel_listItem a {
  padding: 3px 5px !important;
  font-size: .8em !important;
}
</code>
The div and li prefixes aren't required; I've included them here simply to identify the element types involved. Setting a fixed height for cke_combopanel is an imperfect solution, but better than the short one I get by default.


How can i set Mojo Paramater from the pom.xml of Mojo plugin without project

Question: I write a Mojo Plugin. It has a Pamameter like:
*@Mojo(name = "showModus", requiresProject = false, defaultPhase = LifecyclePhase.PROCESS_RESOURCES)

public class ShowModus extends AbstractMojo {

@Parameter (property = "modus", defaultValue = "${modus}")

private String modus;*

in Pom.xml of Mojo Plugin i define a property for this:
<properties><modus>1.1.1</modus></properties>

It works fine if i call the Mojo goal direct under project order per mvn
But if i call the mojo plugin direct form maven repo or. in directory without mojo plugin the Parameter modus is not set.
I understand that mvn can not find the pom.xml of mojo plugin project and therefore can not set the value to parameter.
Is there any way where i can set the pom properties of the mojo maven plugin to the generated plugin.xml ?
I wourd like to call (use) the mojo maven plugin direct from maven repo with certain parameter whereby their value set or inject from pom.xml of plugin
Greeting
Answer: I don't completly understand why you want to write these values as properties in the pom.xml.
It is much easier to write the in a Java constant. But maybe there are some aspects for this decision.
Some basics:

You can read and parse a pom.xml with the MavenXpp3Reader (this class is part of the maven-model module)
Maven writes the pom.xml into the jar at /META-INF/maven/<groupId>/<artifactId>/pom.xml
the plugin itself is on classpath while executing a maven goal
you can access classpath resources by using getClass().getResourceAsStream(...)
you can get the Properties by using the method getProperties

Packing up all these parts it looks something like this:
final String pathToPluginPom = "/META-INF/maven/de.example/example-maven-plugin/pom.xml";
try (InputStream stream = getClass().getResourceAsStream(pathToPluginPom)) {
    final MavenXpp3Reader reader = new MavenXpp3Reader();
    final Model model = reader.read(stream);
    final Properties properties = model.getProperties();
    final String myPropertyValue = properties.getProperty("myproperty");
    getLog().info("Property: " + myPropertyValue);
} catch (final IOException | XmlPullParserException ex) {
    getLog().error("ERROR!", ex);
}


Weird recyclerview refreshing issue

Question: I'm trying to create a file explorer synchronized with an FTP explorer, one of its features is to notify the new downloaded files. For that I store in Sharedpreferences the path of my file/folders and then I compare them with the new element stored in sharedprefs in my adapter, if my condition is true, I make a dot appear next to the folder/file name. It works really great except when I update my recyclerview as I switch back to the previous activity with notifyDataSetChanged() to update the file/folder if they have been read, or when I sort my list with notifyItemRangeChanged(). As you can see in my GIF, dots are appearing randomly everywhere in bad locations. I hope I explained well, how can I fix this issue? I'm really close, it's very frustrating.
Here's my onResume() :
    override fun onResume() {
    super.onResume()
    if(::recyclerViewRecents.isInitialized) {
        getRecentFiles()

        recyclerViewFolders.adapter?.notifyDataSetChanged()
        recyclerViewRecents.adapter?.notifyDataSetChanged()
    }
    }

And here my notifydatasetchange, I even try to clear the recycledViewPool but nothing change:
        recyclerViewFiles.adapter?.notifyItemRangeChanged(0,filesList.size)

Thanks
Edit:
Here's is my adapter code:
I check in onBindViewHolder if the file is registered to display the dot:
        val isRead: String? = prefNewFile.getString(currentFile.absolutePath, null)

    if (isRead!=null) {
        holder.fileIsRead.visibility = View.VISIBLE
        println(currentFile.name + " is unread")
    }

And here how I mark it as read:
private fun putAsRead(file: String) {
    println("$file read!")
    val editor: SharedPreferences.Editor = prefNewFile.edit()
    editor.remove(file)
    editor.apply()
    val folder = file.substring(0,file.lastIndexOf("/"))
    if(file.substring(file.lastIndexOf("/")) != "/CalvezDocs")
        putAsRead(folder)
}

Comment: Can you add adapter code here for reference?
Comment: Thank for yout consideration, sure
Answer: The solution is just to add else option on Visibility. For example, holder.fileIsRead.isVisible = isRead == true or isRead != null
It's short version of if (isRead != null ) View.VISIBLE else View.GONE
The reason of the problem is that RecyclerView reuses ViewHolders, when the adapter reuses a ViewHolder with holder.fileIsRead was set to View.VISIBLE previously, so you have extra item on your list.

Weird recyclerview refreshing issue


Is a brute force method considered a proof?

Question: Say we have some finite set, and some theory about a set, say "All elements of the finite set $X$ satisfy condition $Y$".
If we let a computer check every single member of $X$ and conclude that the condition $Y$ holds for all of them, can we call this a proof? Or is it possibly something else?
Comment: Yes.
Comment: @MitchKnight Most all mathematicians prefer elegant proofs to brute-force proofs (no matter the source). This preference has nothing to do with age.
Comment: The four color theorem was proved in that way (http://en.wikipedia.org/wiki/Four_color_theorem)
Comment: @camel brute force proofs, in general, are frowned upon not just because the chance of errors is much greater (which is one reason), but also because it tends to imply that there is no fundamental mathematical "reason" why the proof works, it "just so happens to work" for every possible case. IOW, there is a vague notion that a brute force proof is "a valid proof of a now provably-boring statement".
Comment: @camel: Human brains are certainly not failproof either.  Computer proofs are verified exactly the same way any proof is: by having enough eyes on it until it is "pretty certain" to be right.  Mathematical proofs have gone decades with flaws in them, only to be found later.  It doesn't invalidate the endeavor of mathematics.
Comment: One common example of this kind of proofs is in boolean logic. E.g. prove that `(a & b) | c` equals `(a | c) & (b | c)`. You simply write the truth table, enumerate all cases and assert the equation.
Comment: That's true. I was just suggesting that the use of computers to solve proofs is relatively new with regard to solve mathematical problems.
Comment: The older generation of pure mathematicians would prefer a concise, elegant proof. But yes, if you find the condition is satisfied for all elements then it is a proof.
Comment: Humans are not failproof, but you can rigorously check the logical assumptions they made (although it can be hard). If the computer is making the mistake (maybe there's a hidden software bug), it'd be impossible to check because some bugs can be due to the computer/compiler instead of the source code (you can't prove rigorously that it's getting executed correctly)

See wikipedia for the four color theorem as an example, there is-was controversy
Comment: Related: [Why are mathematical proofs that rely on computers controversial?](http://math.stackexchange.com/q/632705/119760)
Comment: I was told that there is some controversy behind computer assisted brute force 'proofs' because it's not entirely rigid, you're using a machine that isn't garantueed to never fail.
Comment: You must be more clear in the question. If I have convinced myself that a statement is true, by whatever method, then this is not in itself a proof. A proof is a (written) trace of my reasoning that could lead somebody else to also be convinced of the truth of the statement. If an exhaustive computer search produces such a trace, then _that_ may be considered a proof. The actual program text itself, if it can be easily checked and run, may also be quite convincing; I'm not sure I would call it a proof though.
Comment: @MarcvanLeeuwen I could write source code and then write a formal proof that says: "if the output of this program is X, then the assertion is true". Proving correctness is a big thing in Computer Science.
Comment: lots of examples/refs on recent [empirical/experimental math/TCS research](http://vzn1.wordpress.com/2014/02/14/great-moments-in-empiricalexperimental-mathtcs-research-breakthough-sat-induction-idea/)
Comment: Complete induction is in a way a brute-force method without doing all the work, isn't it? ;-) And it works on infinite sets.
Answer: Yes, you can. This method is known as proof by exhaustion.
Also, see computer-assisted proof.
Edit: As others have noted, this of course works only for finite sets.
Comment: To nitpick, it **does** work for infinite sets (brute forcing, not `proof by exhaustion`) if you only n0eed to prove existence.
Comment: @TC1 Chuck Norris can :D
Comment: @TC1 note that proving existence is recognizable, but not decidable using brute force. (That is, if it's true, you will eventually find it, but if it's false it will run forever, and at no point can you determine "it definitely doesn't exist" as it may find it on the next iteration) http://math.stackexchange.com/questions/25802/recognizable-vs-decidable
Comment: @TC1 True, but I was really thinking more of what the asker was talking about.
Comment: @Cruncher Of course, that's why I said "brute forcing, not proof by exhaustion". Obviously you can't exhaust an infinite set. :)
Answer: The more general question is, when is anything a proof.? There are a least two answers, but the one I think is relevant here is that something is a proof if it is a persuasive argument that someone skilled in the art will find convincing.  In this sense, your finite enumeration is a proof, if:

There is a persuasive argument that your enumeration of the cases is in fact exhaustive
The argument for each case is persuasive

There was a lot of controversy in the 1980s about the Haken-Appel proof of the four-color map theorem, which states that that every map in the plane can be colored with only four colors so that no adjoining regions are the same color.  Haken and Appel had an argument that showed that every map could be reduced to one of a few thousand cases, an argument that showed that if a case satisfied certain conditions then the corresponding maps could be four-colored,  a computer enumeration of the several thousand cases, and a computer-generated demonstration that each case had the desired property.
The arguments were checked and now everyone agrees that this was a proof.  But for a while it wasn't clear.
Answer: Yes, but some mathematicians think of it as an inferior way of proving things. They think that it's not "pure" and it doesn't really explain(on a deeper level) about what's going on.
One of the most famous computer-assisted proofs is the proof for the four color theorem.
EDIT:
Also note that this technique does not work for infinite sets(I personally think this is one of the biggest reasons why some prefer a more traditional proof). There are conjectures in number theory that are true for a huge huge huge chunk of numbers but are ultimately false.
Comment: Funny that you say "more direct". I'd say exhaustion is the most _direct_ way possible, though it's certainly not always the most efficient / concise / elegant way.
Comment: @leftaroundabout You're certainly right. I'll change the wording a bit.
Answer: Using a computer to brute-force can be the first step to a proof. The next step is to prove that the program is correct!
A few ways you might do this are:

Have the program output a proof for each member of the set. We can then check these proofs without having to trust the program at all. We could even send them all through an automated proof checker, which of course would also need to be proven correct! This may be worth doing, since proof checkers are generally simpler (easier to prove correct) and more general than proof finders; you might output proofs in a format understood by an existing proof checker.
Prove that the program is correct for each member of the set. This might defeat the point of using a program in the first place!
Prove that the program is correct for all possible inputs. This can be a good strategy, since the program only needs to simplify the problem, it doesn't need to solve it. For example, we might prove that our program returns "TRUE" if our property holds and "FALSE" if it doesn't; we specifically don't have to prove the more difficult part about which one it will actually return. To do that, we just run it.
Comment: What a spoil-sport!  Prove the program correct.  Then, prove the compiler correct.  Then prove the design of the CPU correct.  And so on...
Comment: @GEdgar FYI, the compiler step can be skipped, and that's probably the most likely place for this to fail.
Comment: Then prove the proof is correct.
Comment: @GEdgar So of course this is going to rest on some assumptions. Hell, there's no guarantee that the transistors work... These happen to be assumptions that we base on every day. If we run the same code, on many platforms, using many compilers and/or interpreters, different processors and architectures and produce the same result every time... I'd say we're looking pretty good.
Comment: We have a huge amount of empirical data for the behaviour of compilers, CPUs and transistors; they're not perfect, but many of their bugs are known and can be avoided. We have exactly *no* data about the brand-new program I just wrote to help with a proof, so we have no reason to trust it. In fact, all of the empirical data from software engineering says that it *will* be buggy, hence we have specific reason *not* to trust it!
Comment: @GEdgar Really, the chances of software/hardware errors conspiring to make an incorrect theorem seem correct by incorrectly running a provably correct program seem-- small.  A lot smaller than the chance of having a bug in a traditional proof, in fact. Especially if there are multiple interpreters/compilers for the language, and it can be run on multiple types of CPU and operating system, and it is published in a way to be repeatable by others, then I see no realistic need for deeper proofs.
Answer: Exhaustive checking is certainly a valid method proof, that is, everyone agrees that it is a proof.
It is usually considered a not very satisfying proof, though, because it usually fails to produce any insight why such-and-such is true. It just observes that it is true, but mathematicians are generally interested in understanding rather than mere facts, and that is something you don't get from an exhaustive search.
In contrast an "elegant" proof will generally tell you not only that such-and-such is true but will also give you an understanding why it has to be true.


Prevenir inserção de Zalgo Text em Inputs

Question: Tenho uma Aplicação Web que possui cadastro de usuários, gostaria de saber como faço para prevenir que o usuário envie como nome, email (dados cadastrais) um Zalgo Text.

Exemplo de Zalgo Text:

Ţ̟͓̯̘͓͙͔̃͟o̤̫͋ͯͫ̂ ̥͍̫̻͚̦͖͇̌ͪ̇ͤ̑̐͋̾̕i̢͖̩͙͐͑ͬ̄̿̍̚ͅn̵̢̼̙̳̒̄ͥ̋̐v̡̟̗̹̻̜͕̲ͣ̐ͤͤ͒́oͫ͂̆͑ͩ҉͇̰͚̹̠̫͔̗k̷̭̬̭͙̹̺̯ͩ̌̾̒̋̓ͤ͛͘͠e̥͙̓̄̕ ̵̫͈ͪţ̱̺̺̑̿̉̌͛̂̇h͙̣̬̓̂͞ę̡̲̟͎͉̟͛̓̉̆̉͘ ͍̯̱͎̬͍ͬ̒ͣͩ͟͡ḥ̗͖̝̮̗̼ͮ̋̉̃͐̿ͪͅi̞͉̯͖̞͉̙ͬͦ̄͋̈̂ͥ̊́̕v̶̝̼̫͔̬̯̯ͯ͑̈͠e̪͓͕̦̪̗̠ͯ͛͌̀̉͘ͅ-̸͉͍͖̥͓̭̗̖̍̉ͦ̈́͌m̳̤̺͓̜̪͙͕ͣͣͪ̇͂ḭ̛͉̮̬͙̩̩͋̏̎ͤ͆́ͅn̴̴̞̗ͩ̓̉̋̕d̝͇̬̣́̃ͦ̀͡ ̖̩̞̯̇̍́̆ͮͤ̄ͬ͂͜͡r̷͎͙͉̀͒͐͛́è̫̹͙̔ͭͦ͑ͩͮͯṗ̶̸͍̺̘͈́̄ͫ̅ͣ̇̃̚r̨͚͎̙̻̜ͬͬ̆͆e̩̞̹͈̱͕ͮ̈́̒̑͛̊̌͛͘ŝ̱̹̠̂ͭͦ̅̅͛̚͜e̝̳̞̊̍̐ñ͔̟̳̱͔ͣ̅̄ͮt̴̫̻̮̤̿̆̂̊͘i̷̫ͤͨ̏ͤͧͅͅn̛̜̠͋͐͆̆͑̎̍͑̚g̶̜ͧ́ͭͯ͐ͬ͛̇͜ ̳̩͉̣̤̜̰̠̌ͤ̆̚͟c̷̝̥͉͓͕͓͇̣͉̒̈̇ͧ͆̌ͣͣ͟ḩͥ̅ͥ̇ͩ͗҉̳͎̱ą̍̀͆͑̈́͂҉͍̤̘͔̹̭̱͢o̥̮̘ͨ̎̄̎́͢s̯̮̖͒.̨͋̈́͑̈́ͪ̚҉̻͓͔̤̯̲̤̺̀
͓̰͙̘͈̔ͨ̋̾̒̋̚̚I̧̗͇ͮ͠n̠̬͗ͮ̿ͭ͌̉̈ͦv̦͚͇̠̹̰̭ͤo̭̞ͫ̃ͨ̏ͥ̒́̚k̯̱͛ͫ͆͂̇͡͝i̗̪͎͈͕͚̥̫ͥ͂̐n̖̤͔̟̖͇̠͋̐̀ͅͅg̛͇̪͓̘͑ͪ ̠͇̮̪̎̒ͯͥͭ͂t̡͍̫̘̯̼̣̋ͤ̒h̨͇͕̺͍͈̠͖̤̱ͮ̃e͖̝̣̽ͬ͊̀ ͍ͫ̅̆͊́͌͡f̭͎̰̣̱̺̯̥ͫ̾é̻̪͖͙̮͓̊̌̓ͩ̑̆ē͙̤̪͈͉̦̭͛̃ͩͧͭ̏͒̕͢ľ̡҉̪͙̻̣̪̼̲i̜ͯ̄̐͠͝n̸̨̩̰̺̱̗̍̉̄̉̆͐̎g̹͖͈ͥ͗̍͝ͅ ̙̹͉̰̪̠͍͖͔ͧ̾̈́ͫ̔͋̈̍o̵̤̥͍ͬ̐̀̿̇ͯ̅f̵̜̟͚́͛͜͠ ̺̭̆̑ͭc̶̢̫̭͓̭̐͗h͍͉̞̩͕ͮ̉́͛͑ͤͯ͒͡ä̜̱͙͎̯̟ͮ̂͑̄͊̍̑͜o̟̲̗ͫ̋̿͌͢s̵̮̟̙̻̗̭̲͂̍͑͑͂ͤ́̚ͅ.̵̨͉̟͓ͦͯͬͤ͌ͧ͑̾
̝̥̰͋ͬ͂̋͛͑̚W̶̹̹̣̟͕ͪͤ̽̀i̳̪͉͇͇̟̲̇̃́ͧ̾ͭ̿̆ͯ͡t̬̪̬̑̿͊͊́̚h̋͑̈̇͋҉̴͖̜ͅͅo̴̠̭̯̫̽ͨṳ̡̟͕̝̦͓͖̪̇́́͢t̬̙̖̝͈͔̻͛͊ ̵̛̗̝̝̰̫̞̠̙̽̄̊͆o̺̮͆ͯ͊͑ͭ̚̕ṙ̶̟̺̱̜̺̻̘̰̀͊ͮ̀͡ḋ̢̰̂̎ͦͥe̛̩͍̯̍ͭͩͤͦ̚r͍̲̾ͯ̊͛͡.̮̙͙̠̦̜̳̋̓ͩ͒̓̒͜͝
̷̬̤̼͋͢T̸̯̞̥ͤ̽͛̈̎̚͜ȟ̨̲͚̪̩͚̺͖̠̌͋é̻̰̞̣̍̕͟ ̧̩͔̥̘͓̘̽̂͑̏ͣ͑̓̃͝N̬̙͈̗͍̣̻̓́ͨͫͮ͘͜͡e͍̜̠͓̹̙͓̱͑͡z̵̙̦̳̲͓ͭ̑ͮ̀p͒͐҉̹͎̱̯̰͜ȩ̨̗̝͓̥̳̣̈̽ͧ͋̎́͑ͯ̚͞r̮̖̟̆ͩḑ͍͉͚̪̲̭͈̮ͮͬͣͭ̽̐̄̓̑́͜i̶̪͎̹̰̭͎͋͗ͧ͌̎͛͜͢a͉̦͇̖͓̰ͣͭ̾͗n̮̞̣̝̤̤͔̎̊͜ ̧̗͐̃̊͂͢h̴͙̳͉̺͕͌̉ͫ͐͒̋͊i̢̳͓̤̖͎̼ͤ̃̓ͫ̐ͬ̆͌̕͢ṽ͎͉̳̭̭̠̠̬̠͂͐͊̾͊ȩ̣̺̖̒̏̌͠-̛͕̼̞͌͑ͣͨͩ̃̒͢m̶̱̣̥̥̭̉̿ͩͧ̓͛̚ͅi̢͍̙̠ͩ͐̏n̹̩̬͓̬̦̲̈́̉͊̐̎d̨̧̛̤̭̯̥͓ͧ̒ͥ ̞̙̮͌ͫͬͪͤ̌ợ̫̏̋͋͒̈̀f̶̳̿̀̊͐ͅ ̑͘҉̱̯̤̘͕̺͡c̢̭̭̜̲̙̥͊̓ͤ̍ͨ́ẖ̫̖̆̃ͪ̌ͭ͞ä̷̫̺̩̘̪͍́ͤͫͫ̒ͦ͆͂͠͡o̥̖̥͚̾̋͋͊ͨ̆ͅs̘͉͔̲̫̪͕̠̟ͯ̒͋ͦ̒͢.̣̦̦̞ͮͬͩ ̰̦̤̞̹̮̟ͩ̓̂̓̉͒̏ͫ͢Z̗̮̎́̉͘ạ̧̩͍̞͌͋̂͛̏l̛̟̥͎ͨ͒̐ͤ͛ͅg̰̣ͫͣ̂̋͊ô̷̶͕̩͎̳̻̣̯̘̋̊̅ͧ̏ͫ.̴̮̯̺̻̻̣̻̣̗̿ͯ͒
̹̮̮̱͖̫̝̋ͥ͆̌͛ͬ͌̄͗͟H̢̅҉̘̠̻e̷͊͊͋ͪ̑҉̮̻̬̞̖̖̭̩̩̕ ̬̪̍͜ͅw̴̧̳͓͓̤̤ͮ̍ͨ͒͜ͅh̳̱ͪ͋ͦ͗o͚͎̭͎͍̺̽ͣͦͅ ̣͙͊̑ͣ̄W͍͔̻͉̲̹͇̼̑̇ͥ̔̎ͮ̚͟a̫̞ͪ̔͘͜į̷̶͔͍̰͙̖̻̲ͯ̓̄͌̄̒̔̆t̷͚͓̼̼̔̈̄̀̚s̼̻̗͚̼̫ͭ̎͛ͨ ̵̨̦ͪ͂̂B͂̈́҉̸͎̩͓e͌͂҉̤͕̲͇̮h̴̤͎̟̫̐̀̐ͬį̖̪̜̦̋̔n̨̯͚̽͗̾̀̾̿̏̀d̙͔ͬͧ̃ͯ̀ͦͫ͌ ̸̮͓͎̣̻̪̹̒̈́ͧ̀͐̓̿͘͠T̮͎̫̝ͫ̔͛̈ͯ̈ͬͣ̈́͟h̲̉̆̀e̬̭ͧ̉ͮ̓ͥ̈́ͨ ̖̯͚̰̉̆̏͠W͎̞͕̺ͣ̉̓ͧ̎̽͟a̢̝̝̎̅̌̂ͦ͡ḽ͖͉̽ͥ̌̓̉̆l̠̣̾ͣ̾͛̕.̷̡̩̰̀̑͑̽͋̃̌̓
̴͙̼̭̺̙̱͚̳̪ͨ̈́́Z̵̶̲̘̗̩̜̍ͭ̀̿͒̊ͫA̴̸ͧ̊̚҉̺͖̠͖̜̠̩͇L̶̲̠̾͗ͦ͐͌ͯͤ̇G̫̞͔̭̻̖̥̜̗͊ͪͦͧ̔ͩ̀͘͜Õ̷͉͈̖̭̰̲̪̾ͭͯ͆̚!̷̘̥̞͕̱́̚͡
̧̱̯͎̜͚̝̙̄ͯ̿̅̾̃̑͘͡T͖̲̼͔̠̫̘̻͊̓͑͟h͉̦̬͙͇͙͎̺̯̒̇͌͗ͮͥ͐͡e̗͎͈̅̔̀ͅ ̢̬̥͕̙̈́͌ͩ̎ͯ̽̆͑ͫȩ̸̜̪̠͆̎͌́ͅn̰̩̘̎̔̒͑̄ͦ̾̊ť͉̺̪͚͔̪ͭ̔ͯ͝i̧̪̳̺̥̘͇͎̾̌ͪŗ̬͍̳̼͉̤̦ͣͦ̏͗̈́ͮ̓ͬ͡e̛͇̱̠̣͂͝ ̲̹͎̣̤͙̪̱̔̓̀̐̑r͈̩̭̠̘̫̪͂ͯ͆͗ͤͮͮ̀ͅǫ̸͇̤̜̙ͨ̑ͯ̐̃͛ͮo̭̖̺͍͍̙͗͂̄̃͞͡ͅm̢͎̱̫̪͈͆͡͞ ̹͕͎ͨ͐̽͗i͖ͨ̏̑̆͂ͥs͚̟̲͇̯̜̝̦̉̈͑͑͟ ̬͔̪̠͚̰̘̏̍̂̌͟f͕̟ͭ́́į̟͎͍̝̱̬ͮ̑͑ͣͦ͌l̡̗̝ͧͦ̃ͮͧͦ̇̉̆͜l̫̤͔͈̽̍ͭȩ̮͚̦̬̼̺̥͗́̃̍͊ͯ̄͠d̠͍͕̪̳͖ͤ́̊͑̈̂̒ ̢̝̮̜̞̥̥̭ͤ͜w̥̖̖̙͚͖̼̎ͭ́ͧȉ̺̰̗͂͐̑̓͊ͨͪ͂͠ṭ̝͎̮̞̫̰̳̓ͤ̇̌̀͘h͗ͬ͆̉̏͑҉̼͎̳͘ ̤̦͚̭̗̘̬̬̤̃ͪ̍ͭ̂͌̓ͨ̌̕͟Ẕ̥͓̘͎̐ͥ̔ͣͅá̵̯̼̯̒̌ͬͬ̀̀l̵̻̲̜̹͖͋̎̑̿̓͋̿g̴̛͎͔̏ͩ͋ͧ̎ͥͥ̀o͆̾̑͐̓̒̐ͬͬ̕҉̰̦̙͝.̢̢̦̮̩̭͖ͧ͞
̣̠̥̥̝̲͓ͯ̒̽̽̒͌̉ͣ͞
Comment: Olá, experimente ler isto [aqui](http://stackoverflow.com/questions/16458963/how-to-check-if-a-string-contains-zalgo-text).
Answer: Para conseguir detectar um zalgo text, primeiro precisamos entender como ele é feito.

Unicode Combining Characters
No Unicode existe a definição de combining characters. Basicamente, de maneira bem resumida, são caracteres que podem ser combinados com outros, para formar caracteres diferentes.
Um exemplo existente no português são os acentos (agudo e circunflexo), o til e a cedilha. Então se você combina a letra a minúscula com o acento agudo (COMBINING ACUTE ACCENT), o resultado é o caractere á (letra "a" acentuada).
Atualmente existem mais de 2000 caracteres com esta característica de poderem ser combinados com outros, listados nas categorias Mn (Mark, Nonspacing), Me (Mark, Enclosing) e Mc (Mark, Spacing).
O fato é que existem muitos idiomas nos quais é perfeitamente válido ter mais de um combining character aplicado à mesma letra, e por isso o Unicode permite esta situação. No caso do texto que está na pergunta, por exemplo, os primeiros caracteres são:

caractere
code point
Categoria
Nome

T
U+0054
Lu
LATIN CAPITAL LETTER T

̃
U+0303
Mn
COMBINING TILDE

͟
U+035F
Mn
COMBINING DOUBLE MACRON BELOW

U+034F
Mn
COMBINING GRAPHEME JOINER

̧
U+0327
Mn
COMBINING CEDILLA

̟
U+031F
Mn
COMBINING PLUS SIGN BELOW

͓
U+0353
Mn
COMBINING X BELOW

̯
U+032F
Mn
COMBINING INVERTED BREVE BELOW

̘
U+0318
Mn
COMBINING LEFT TACK BELOW

͓
U+0353
Mn
COMBINING X BELOW

͙
U+0359
Mn
COMBINING ASTERISK BELOW

͔
U+0354
Mn
COMBINING LEFT ARROWHEAD BELOW

Para entender o que é um code point, leia aqui.
Ou seja, o texto da pergunta começa com a letra "T" seguida de 11 combining characters. Somente esta sequência de code points produz isso:
Ţ̟͓̯̘͓͙͔̃͟

Segue uma imagem caso não renderize corretamente:

O restante do zalgo text segue o mesmo padrão: uma letra seguida de vários combining characters.

Outra característica que faz com que o zalgo text fique dessa forma tão peculiar é o algoritmo de stacking (definido no mesmo documento já citado), que define o que pode acontecer quando mais de um combining character é aplicado à mesma letra.
Basicamente, cada novo combining character pode acabar sendo renderizado acima ou abaixo dos já existentes (cada um tem uma regra que diz em que posição ele deve ir, mas a renderização exata também depende da fonte utilizada). Veja abaixo o que acontece quando vamos adicionando combining characters à letra T (a cada linha, um novo combining character é adicionado aos já existentes):
T    <-- letra "T" sem nenhum combining character
T̃    <-- adicionado COMBINING TILDE
T̃͟     <-- adicionado COMBINING DOUBLE MACRON BELOW
T̃͟     <-- adicionado COMBINING GRAPHEME JOINER
Ţ̃͟     <-- adicionado COMBINING CEDILLA
Ţ̟̃͟     <-- adicionado COMBINING PLUS SIGN BELOW
Ţ̟͓̃͟     <-- adicionado COMBINING X BELOW
Ţ̟͓̯̃͟     <-- adicionado COMBINING INVERTED BREVE BELOW
Ţ̟͓̯̘̃͟     <-- adicionado COMBINING LEFT TACK BELOW

Ţ̟͓̯̘͓̃͟     <-- adicionado COMBINING X BELOW

Ţ̟͓̯̘͓͙̃͟     <-- adicionado COMBINING ASTERISK BELOW

Ţ̟͓̯̘͓͙͔̃͟     <-- adicionado COMBINING LEFT ARROWHEAD BELOW

Ou seja, como o Unicode permite vários combining characters aplicados ao mesmo caractere, e na renderização esses são "empilhados" de forma acumulativa (podendo inclusive "invadir" as linhas de cima ou de baixo), o resultado é esse visual tão característico do zalgo text.

Uma tentativa de detectar zalgo text
Sendo assim, um critério para detectar que o texto é zalgo poderia ser verificar se há "muitos" combining characters seguidos. Algo como:
$texto = // string possivelmente contendo zalgo text
if (preg_match('/\p{M}{2,}/u', $texto)) {
    echo "zalgo\n";
} else {
    echo "not zalgo\n";
}

A ideia é usar regex com Unicode properties. No caso, \p{M} pega qualquer caractere que esteja nas categorias "Mark" (as três já citadas: Mn (Mark, Nonspacing), Me (Mark, Enclosing) e Mc (Mark, Spacing)).
E o quantificador {2,} indica "duas ou mais ocorrências", ou seja, se tiver 2 ou mais combining characters, eu já considero que é zalgo. Isso pode ser o suficiente se você quer aceitar apenas textos em português, já que neste idioma os caracteres têm no máximo um combining character.
Mas vale lembrar que há idiomas em que este limite pode ser maior. O Unicode define o conceito de Stream-safe Text Format, que de certa forma "define um limite" de 30 combining characters seguidos. Mas na prática, 30 é muito, pois a maior sequência conhecida é o caractere tibetano HAKṢHMALAWARAYAṀ, que é uma letra seguida de 8 combining characters. É esse aqui, e admito que para quem não conhece, pode muito bem ser confundido com zalgo text:
ཧྐྵྨླྺྼྻྂ

Segue imagem caso não tenha conseguido ver direito:

Então a menos que você vá aceitar textos em tibetano, usar \p{M}{8,} seria uma alternativa válida. Dependendo da quantidade escolhida, você pode acabar excluindo textos válidos em outros idiomas (muitos usam 2, 3 ou até mais combining characters), então vai ter que ajustar esse valor de acordo com as strings que você recebe, para evitar falsos positivos.
Claro que também pode-se argumentar - e aí é uma discussão bem subjetiva - que com apenas 2 ou 3 combining characters o texto não fica "zalgo o suficiente" (veja os exemplos do "T" acima, com apenas 2 ou 3 combining characters adicionados), pois visualmente não ficaria tão... "zalguificado". Ou seja, é bem difícil definir um critério preciso que atenda a todos os casos.

Outra forma de fazer seria usar a extensão php-intl (não esqueça de instalá-la). Com ela podemos iterar pelos code points da string e verificar se há uma sequência de combining characters maior que determinado tamanho:
// verifica se o caractere é um combining character
function isCombining($char) {
    $t = IntlChar::charType($char);
    return $t === IntlChar::CHAR_CATEGORY_NON_SPACING_MARK ||
           $t === IntlChar::CHAR_CATEGORY_ENCLOSING_MARK ||
           $t === IntlChar::CHAR_CATEGORY_COMBINING_SPACING_MARK;
}

function isZalgo($text) {
    $max_allowed = 2;  // considera que mais de 2 combining characters já é zalgo
    $i = IntlBreakIterator::createCodePointInstance();
    $i->setText($text);
    $seq = 0; // conta o tamanho da sequência de combining characters
    foreach($i->getPartsIterator() as $c) {
        if (isCombining($c)) {
            $seq++;
        } else {
            if ($seq > $max_allowed) {
                return TRUE;
            }
            $seq = 0;
        }
    }
    return $seq > $max_allowed;
}

$text = // texto que você quer verificar
if (isZalgo($text)) {
    // zalgo detected!
}

A outra resposta usa a regex [^\x20-\x7E], que basicamente exclui tudo que não é ASCII. Ou seja, mesmo que a string tenha apenas um caractere acentudado (como 'á'), ela é considerada zalgo text, o que não me parece ser um bom resultado, pois muitos textos válidos seriam considerados inválidos (e também não entendi pra que testar a mesma regex duas vezes). Enfim, ela acaba sendo restritiva demais, deixando de fora strings completamente válidas (veja aqui um exemplo).
No fim, vale o que já foi dito: quanto maior a quantidade de combining characters seguidos que são aceitos, menos casos válidos são deixados de fora. Em compensação, aumenta as possibilidades de zalgo text, pois quanto mais caracteres seguidos são aceitos, mais combinações - incluindo as inválidas (sendo que "inválidas" vai depender do contexto, do idioma usado, etc) - são possíveis.
E neste caso, outra alternativa seria ter whitelists de sequências válidas de combining characters nos idiomas que sua aplicação vai aceitar. Por exemplo, em português, seriam apenas vogais seguidas de um dos acentos, ou a letra c seguida do cedilha (COMBINING CEDILLA). Algo do tipo:
// textos em português: testa se depois do "c" tem a cedilha, ou se tem alguma consoante
// com acento, ou se tem vogal com algo diferente do acento agudo, circunflexo e til (ou a letra "a" com crase)
// (testado em alguns casos mais básicos, precisa de mais testes para ter certeza que é eficaz)
if (preg_match('/c[^\P{M}\x{327}]|[^aeiouc]\p{M}|[eiou][^\P{M}\x{301}-\x{303}]|a[^\P{M}\x{300}-\x{303}]/iu', $texto)) {
    echo "invalido\n";
}

Ou seja, em vez de detectar um zalgo text, eu tento verificar se é um texto válido (cuja definição varia conforme o contexto). E aí tanto faz se o texto inválido é zalgo ou seja lá o que for. É mais trabalhoso, mas tem o tradeoff de ser mais assertivo. No fim, não há uma solução mágica que funcione em 100% dos casos.

Referências:

How does Zalgo text work?
How to protect against diacritics such as Zalgo text
Comment: Ainda, um bom teste, diria que até melhor do que avaliar quantidade de acentos, é ver qual a % dos caracteres com acento. Em strings muito curtas tem que ter mais tolerância, mas conforme aumenta, o número de caracteres acentuados/"marcados" tem que ser muito menor do que o resto. Não estou especificando valores pois é um comment, e não resposta, e varia com a língua utilizada.
Answer: Você pode tentar usar este trecho de código no seu script PHP.
if ( preg_match ( '/[^\x20-\x7E]/', $text ) || preg_match ( '/[^\x20-\x7E]/', $text ) ) {
    die('ZALGO not allowed');
}

How to prevent Zalgo Text
Pelo que pesquisei, iso pode não solucionar o problema e acabar removendo palavras válidas, mas acho que vale a tentativa :-).
Comment: Não entendi pra que precisa testar a mesma regex duas vezes... Sem contar que **qualquer caractere acentuado** será considerado zalgo ([veja aqui um exemplo](https://ideone.com/jcpZVf)), então isso realmente "*pode não solucionar o problema e acabar removendo palavras válidas*"


How can the Feeds module fetch a file from a dynamic URL?

Question: The feeds module does fine importing a source file (CSV, in my case) from an external URL. However, I'm trying to schedule Feeds to pull in a report every X days. I need Feeds to fetch at a dynamic URL,
say:
www.example.com/report/%start-date%/%end-date%
I'm guessing this would use the Token module, but aside from that I'm not sure what to do.
Answer: As I know Feeds doesn't have something like that, its maybe a feature that you can propose on they issue list.
A workaround its to create a small module that will work as a proxy for your dynamic address.
You will have something like that :
<?php

function proxy_menu() {
  $items = array();
  $items['proxy-url'] = array(
    'title' => 'Proxy for danymic url',
    'page callback' => 'proxy_get_contents',
    'access callback' => TRUE,
    'type' => MENU_CALLBACK
  );
  return  $items;
}

function proxy_get_contents() {
  $url = 'http://www.example.com/report/%start-date%/%end-date%';
  $request = drupal_http_request($url);
  if ($request->code == 301 || $request->code == 304) {
    return $request->data;
  }
}

Comment: What a nice thinking @yvan. The only downside I can think about is the load. feeds requires its own site's page and that page has to be booted separately to fetch the actual URL.
May be a custom fetching mechanism can do the trick anyway.
Answer: You can extend the FeedsHTTPFetcher class and register your plugin with hook_feeds_plugins(). Then override the fetch method to handle your dynamic URL that's stored in $source_config['source'].


How to improve estimation if $\sigma^2$ is known

Question: I'd like to ask this rather theoretical question about estimating a linear model with known $\sigma^2$ for the error term. I read that if the variance of the error terms was known, it would've been possible to know the population slopes and intercepts. Can you give me a hint on how to insert this information in the estimator? Trying to minimize $(\varepsilon'\varepsilon - \sigma^2)^2$ it's kind of messy. Is it a good direction to try $\operatorname{Var}[y] = \operatorname{Var}[x\beta] + \sigma^2$ assuming $x$ and $\varepsilon$ are independent?
Comment: Why would it be possible to know the slopes and intercept just because you know $\sigma^2$?
Comment: Are you also assuming that the $\epsilon$ are normally distributed?  If so you could do maximum likelihood (taking $\sigma^2$ as given and estimating only $\beta$).
Comment: Knowledge of $\sigma^2$ will help a bit at small sample sizes  (e.g in terms of a smaller CI for a population coefficient -- at 13df for error the $t$ will give you a 10% wider CI than the normal would if you have $s=\sigma$) and hardly at all at large sample sizes.
Comment: What do you precisely mean by "improve?"
Comment: Where did you read this and what exactly was said? Can you provide a quote?
Comment: Not really the queston, but in the case where [$\sigma=\sigma(x)$](http://stats.stackexchange.com/tags/heteroscedasticity/info), I believe a known variance can be used to weight the error terms in the least squares objective function?
Answer: Perhaps there's a misunderstanding of the Gauss-Markov theorem taking place here. An assumption of the Gauss-Markov theorem is that $\mathrm{Var}\left(\epsilon_i \right) = \sigma^2 $. The best-linear unbiased estimator under the Gauss-Markov assumptions is $\hat{\mathbf{b}} = (X'X)^{-1}X'\mathbf{y}$. Observe that $\sigma^2$ doesn't enter the formula for the estimator not because it was assumed you didn't know $\sigma^2$. Rather, $\sigma^2$ doesn't enter the formula because it doesn't help!
If you drop the requirement that the estimator is unbiased (or otherwise deviate from the assumptions or objective of the Gauss-Markov theorem), you can get estimators that do depend on $\sigma^2$, such as the James-Stein estimator.
Answer: Building on @dsaxton's comment, here are two scatterplots with the same errors $u$, drawn from $N(0,\sigma^2)$, $\sigma^2=4$. The first has slope $\beta=4$, the second $\beta=6$.
How do you want to use knowledge of $\sigma^2$ to pin down $\beta$ if two populations with the same $\sigma^2$ have different $\beta$?

<code>sigma <- 2
beta1 <- 4
beta2 <- 6
u <- rnorm(100,sd=sigma)
x <- runif(100)
y1 <- beta1*x + u
y2 <- beta2*x + u

par(mfrow=c(1,2))
plot(x,y1,ylim=c(-4,8))
plot(x,y2,ylim=c(-4,8))
</code>
Answer: Thanks for your answers. I cannot find again the web site where it said something like "we do not know sigma, otherwise we could find the population intercept and slope".
I found it intriguing, I thought maybe there is some trick (by improving the estimator I meant reducing the variance of the estimator).
Thanks a lot for your time, you're very nice people,
Chris


Get n documents in a loop from mongodb

Question: I have a collection of 101 documents, I need to iterate over them taking 10 collections at a time and store a value of a particular field(of 10 documents) in a list.
I tried this:
values = db.find({},{"field":1})
urls = []
count = 0
for value in values:
if(count < 10):
    urls.append(value["field"])
    count = count + 1
    print count
else:
    print urls
    urls = []
    urls.append(value["field"])
    count = 1

It doesn't fetch the last value because it doesn't reach if condition. Any elegant way to do this and rectify ths situation?
Answer: You reset count to 0 everytime the loop restarted. Move the declaration outside the loop:
count = 0
for value in values:

If urls is already filled, this will be your only problem.
Comment: Should probably reset in `else` too, or use `% 10`
Comment: @jonrsharpe Not sure if i understand the question enough to provide a better answer.
Answer: As far as I can tell, you've some data that you want to organize into batches of size 10. If so, perhaps this will help:
N = 10

values = list(db.find({},{"field":1}))

url_batches = [
    [v['field'] for v in values[i:i+N]]
    for i in xrange(0, len(values), N)
]

Comment: Len(values) should be values.count() since values is a cursor.
Also after rectifying this, throws an error:
in
    for i in xrange(0, count, N)
  File "build/bdist.macosx-10.6-universal/egg/pymongo/cursor.py", line 504, in __getitem__
  File "build/bdist.macosx-10.6-universal/egg/pymongo/cursor.py", line 354, in __check_okay_to_chain
pymongo.errors.InvalidOperation: cannot set options after executing query
Comment: @wannaC If you've only got 101 documents, you can probably get away with converting from cursor to list (see edit).

Get n documents in a loop from mongodb


I am looking for a book focused on Euclidean Geometry

Question: So I look for a book that has geometric approaches to (quote unquote) everything there is to know about Euclidian geometry.
I am not a bookworm so I am basically wondering blindly in a dark room but the books I checked thus far did not satisfy me because they seem either to just be partially euclidean partially everything else (analytical/calculus/algebra/ other types of geometries etc)
Basically I would like a book like the elements but better written/written as a textbook (because the books I found on Elements are more focused on translating the ancient script rather than mentioning the concepts in a modern and easy to understand way and with an order that makes sense in nowadays geometric applications they also luck examples/conclusions/exercises)
After reading and understanding this book I would like to be able to know everything there is about e.g how to measure lines using circles and tangents in order to construct a shape or what not how to compare circles how to construct vertices using circles how to cut shapes or distances in equal parts etc etc etc
Actually what I described above is somehow misleading but it's hard for me to articulate what I am looking for....  think of Euclidea the game,  I want to be able to solve everything there (<-- this is not my target but I think it gives a good idea of what I am looking for)
The purpose of wanting this is that in many math problems I encounter there is an intuitive geometrical approach that I miss because my geometry knowledge is limited but my teacher or fellow students point out.
I thank you in advance for your time.
P.S No children's books with basic stuff, I need it to be as comprehensive as it can get.
Comment: Check The book by Evan Chen on Euclidean geometry. It's a wonderful book! It's covers almost everything along with olympiad problems. The exact name is Euclidean geometry in mathematical olympiads. It has $328$ pages.
Comment: @Spectre OP said they don't want Euclid's 'Elements'.
Comment: Hey, there's an old English print of Euclid's 'Elements' in Google Books...
Comment: @Spectre OP means "original poster", in other words papajo.
Comment: Check on Google Books... you'll get what you want **there**.
Comment: Well, what I meant is that related books may be available online, @littleO
Comment: And what does 'OP' mean here ? I have never used that short form before.
Comment: @Spectre Well if there is a good textbook equivalent please mention it because all the "Elements" books I checked up until now as I mentioned are focused on being true to the ancient script which besides the language issues is limiting because it does not offer conclusions or exercises or examples as modern textbooks do.
Comment: @littleO, thanks....
Comment: @papajo , I didn't check in  the net for what you want, although I luckily caught hold of an online version of Euclid's "Elements".......
Comment: I just made a guess.... that's all.
Comment: Hello you can try these books  1.Lemma's in Olympiad Geometry.
2.Eucilden Geometry For Mathematical Olympiad.
Comment: 3.Geometry Revisited!!!  4. Solving Problems in Geometry for Mathematical Olympiad (World Scientific).
Answer: I find The Bones to be really helpful. It includes all the definitions and diagrams from the Elements without the proofs.
Here is the publisher's page for it at the Green Lion Press. You can also look the book here on Google Books.
The text of the Elements which is present comes from Heath's translation, which is not so modern, but with so much pruned out, that for me at least, it is much, much more accessible than the elements itself.
Comment: Hello, try "Geometry" by Marcel Berger : https://books.google.fr/books/about/Geometry_I.html?id=5W6cnfQegYcC&redir_esc=y
Answer:
Hilbert, David :Foundations Of Geometry.

Coxeter, Donald : Introduction To Geometry.

Coxeter, Donald : Geometry Re-Visited.

I also recommend the geometric problems in "101 Great Problems In Elementary Mathematics" by Heinrich Dorrie.
BTW Archimedes invented a device for trisecting angles. It is so simple that I can never remember it.


Auto regressive process, maximum likelihood estimator

Question: A first-order autoregressive process, $X_0,\dots,X_n$, is given through the following conditional distributions:
$X_i | X_{i-1},\dots,X_0 \sim \mathcal{N}(\alpha X_{i-1},1)$,
for $i = 1,2,\dots,n$ and $X_0 \sim \mathcal{N}(0,1)$.
I know that the log-likelihood function $\ell{(\alpha)}$ is of the form:
$\ell(\alpha) = - \frac{1}{2} \sum (x_i - \alpha x_{i-1})^2 + c$. But I don't know how to show that.
I found for $\hat{\alpha}_{ML}$ the following solution: $\hat{\alpha}_{ML} = \frac{s}{t}, \mathrm{where} \; s = \sum x_1 x_{i-1} \mathrm{and} \; t = \sum (x_{i-1})^2$. Is this right?
Then I have to show that this is the global maximum. If I take the second derivative I get a constant. Is this the sign that I got the global maximum, because the first derivative is linear wrt to $\alpha$? Right?
Comment: The likelihood function of the sample is the joint density. Here the variables are not independent. Do you know how to apply the chain rule to decompose the joint density into conditional densities?
Comment: I thought about that. But I don't get it... Do you have a more concrete hint?
Answer: Using the chain rule, the joint density here can be decomposed as (denoting $\mathbf X$ the collection of the $n+1$ random variables)
$$f_{\mathbf X}(x_n,x_{n-1},...,x_0) = f(x_n\mid x_{n-1},...,x_0)\cdot f(x_{n-1}\mid x_{n-2},...,x_0)\cdot f(x_{n-2}\mid x_{n-3},...,x_0) \cdot...\cdot f(x_0)$$
$$=\left(\prod_{i=1}^{n}\frac {1}{\sqrt{2\pi}}\exp\left\{-\frac {(x_i-\alpha x_{i-1})^2}{2}\right\}\right)\frac {1}{\sqrt{2\pi}}\exp\left\{-\frac {x_0^2}{2}\right\}$$
Viewed as a likelihood function of $\alpha$, and taking its natural logarithm, we have
$$\ln L(\alpha \mid \mathbf X) = -\frac 12\sum_{i=1}^n (x_i-\alpha x_{i-1})^2 +c$$
...where in $c$ is also included the density of $x_0$ (but $x_0$ affects estimation of $\alpha$ through its presence in the conditional density related to $X_1$).
Then
$$\frac {\partial \ln L(\alpha \mid \mathbf X)}{\partial \alpha} = \frac {\partial }{\partial \alpha} \left(-\frac 12\sum_{i=1}^n (x_i-\alpha x_{i-1})^2\right)$$
$$=-\frac 12\frac {\partial }{\partial \alpha} \left(\sum_{i=1}^n (x_i^2-2\alpha x_ix_{i-1}+\alpha^2x_{i-1}^2)\right)  $$
$$=-\frac 12\frac {\partial }{\partial \alpha} \left(\sum_{i=1}^n x_i^2-2\alpha \sum_{i=1}^nx_ix_{i-1}+\alpha^2\sum_{i=1}^nx_{i-1}^2)\right) $$
$$=\sum_{i=1}^n x_ix_{i-1} -\alpha\sum_{i=1}^nx_{i-1}^2$$
Setting
$$\frac {\partial \ln L(\alpha \mid \mathbf X)}{\partial \alpha} =0\Rightarrow \hat \alpha_{ML} = \frac {\sum_{i=1}^n x_ix_{i-1}}{\sum_{i=1}^nx_{i-1}^2}$$
while $$\frac {\partial^2 \ln L(\alpha \mid \mathbf X)}{\partial \alpha^2} = -\sum_{i=1}^nx_{i-1}^2 <0$$
which guarantees a global and unique maximum, since it is negative irrespective of $\alpha$.
Comment: Thanks a lot! Did not expect such a detailed explanation, but it's great!
Comment: You're welcome Michael. I remember you are a biologist taking a stats course. How is it going so far?
Comment: Hey Alecos! It's very interessting! But I am laking many mathematical tools. That is why I ask so many questions here. But the good thing is that I understand the stuff after solving the exercises ;-)


How to check that current space is Dashboard?

Question: Sample code is
    [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(activeSpaceDidChange:) name:NSWorkspaceActiveSpaceDidChangeNotification object:nil];

Then
- (void) activeSpaceDidChange:(NSNotification *)aNotification {
         // code to check if current workspace is dashboard?
}

I want to check whether the current space is dashboard or not? Any idea?
Answer: The first think i have tried is get to the current space id according to this answer: Detecting when a space changes in Spaces in Mac OS X . The problem here is that the key kCGWindowWorkspace is deprecated in OSX 10.8. So there is no direct way to get this information.
In my solution now i check for different windows or owners which are only one the dashboard space or on all other spaces:

The user is on the dashboard if there is one window which kCGWindowName ends with .wdgt/
The user is not on the dashboard if there is one window with kCGWindowName == System Status Item Clone, kCGWindowOwnerName == SystemUIServer | Finder

So why i'm not just using the .wdgt/ check? -- Because if there is now widget on the dashboard this not working
So why i'm using more than one window check? -. Because i'm not jet sure which window is always on all spaces. At least System Status Item Clone and Finder are not always there.
Here my implementation is add this function as category to NSWorkspace
- (BOOL) userIsOnDashboardSpace {

NSArray*  windowsInSpace = (__bridge NSArray *) CGWindowListCopyWindowInfo(kCGWindowListOptionAll | kCGWindowListOptionOnScreenOnly, kCGNullWindowID);

NSUInteger indexOfWidget = [windowsInSpace indexOfObjectPassingTest:^BOOL(NSDictionary* obj, NSUInteger idx, BOOL *stop) {

    if ([obj objectForKey:(id)kCGWindowName]) {
        NSString *name = (NSString *)[obj objectForKey:(id)kCGWindowName];
        if ([name isEqualToString:@"System Status Item Clone"]) {
            *stop = true;
            return false;
        }
        if ([name hasSuffix:@".wdgt/"]) {
            *stop = true;
            return true;
        }
    }
    if ([obj objectForKey:(id)kCGWindowOwnerName]) {
        NSString *name = (NSString *)[obj objectForKey:(id)kCGWindowOwnerName];
        if ([name isEqualToString:@"SystemUIServer"]) {
            *stop = true;
            return false;
        }
        if ([name isEqualToString:@"Finder"]) {
            *stop = true;
            return false;
        }
    }

    return false;
}];
return indexOfWidget != NSNotFound;

}


What to do/tests to run when population size is unknown

Question: Shall I stick to descriptive statistics? Everything I know about making inferences about a population seems pretty redundant. Feel free to roast me
I'm working with some non-experimental cross-sectional data and afaia things like a standard error/p-values require info on population size. In a way, I have data of my entire population but isn't a population potentially infinite?
Comment: Population size or sample size?
Comment: Sample size is known, Informed by my lecturer that there's always a population when I thought I had data for the entire population, which has thrown me off.
Comment: The population size is pretty much irrelevant, unless it is close to the sample size.
Answer: If you truly have population data, then inferential statistics will not help you, as the aim of the tool is to aid in making inferences in the presence of sampling error--to reason from a finite set of observation to an infinite population.
Populations are not always infinite. Finite population corrections are available (or can be constructed) to adjust for the sampling variance reduction that occurs when sample size becomes an appreciable fraction (say, 5%) of population size. Sampling variance approaches zero asymptotically as sample size approaches population size.
In disciplines where finite population corrections have not taken hold (or are seen as "hard to do"), it is common to shortcircuit concerns about the matter by imagining some infinite population, even when there is good evidence that the entire population has been counted. One might imagine that respondents are actually typical of some larger set of respondents. But as the late gadfly David Freedman once wrote, "Generalizations to imaginary populations are themselves imaginary."
Comment: Thanks, this provides some guidance. The thing is, there is a population of sorts but the explanatory variable is only relevant for the data I have collected and means nothing for others. It could be modified to apply to all observations but it really is not of much interest. So I feel that I fall into a bit of a grey area.


Spacy NLP: For proper nouns that can be verbs - Ambiguities according to input order and split based on punctuation

Question: I am using spacy NLP. No parser can always correctly determine the PROPN/ NOUN / VERB status of an ambiguous token, since in most languages a word spelt the same can have different meanings.
For example, "Encounter" can be an Encounter in terms of aliens zapping you into their spaceship(Noun, an occurence), or "Encounter" like "Encounter the world" --> Come into contact with (Verb).
Spacy sometimes identifies the same spelt-word differently, even in similar situations:

Is it the punctuation(the "="?) that causes this?
I expected continuity of identification of the token as either verb or noun, but not to change. I understand using the trained spacy data (using en_small and en_medium) does not use LSTM as it progresses so I should not expect spacy to "establish continuity due to a previous decision in the same sentence", but I am still surprised given the same sentence format, also identical content, spacy identifies differently..
Encounter the world. Encounter the self" and "Encounter the world=Encounter the self
=>
parses to VERB, NOUN respectively

"Encounter the self. Encounter the world."
=> parses to VERB, VERB.
"Encounter the self"
=> parses to VERB
Comment: General advice: always segment your data properly. In this case, you clearly have two separate segments joined with a `=` char.
Comment: Have you tested by passing the two phrases separately?
Comment: @WiktorStribiżew although not shown in the example figure, Spacy was separating this sentence into two spans automatically around the =. I added further examples to demonstrate the unexpected results
Comment: @TiagoDuque Thank you for advising - added further examples of entirely separate sentences.
Comment: I'm probably not mistaken if I say that 'self' is not being rendered as 'noun', right? I guess it's rendering it as a pronoun.
Answer: Make sure that you are using an up to date version of spacy and an up to date model such as en_core_web_lg .
On my setup, I do not get the error you are describing:
nlp = spacy.load('en_core_web_lg')

doc = nlp("Encounter the world=Encounter the self.")
print([(t, t.pos_) for t in doc])
# [(Encounter, 'VERB'), (the, 'DET'), (world, 'NOUN'), (=, 'PUNCT'), (Encounter, 'VERB'), (the, 'DET'), (self, 'NOUN'), (., 'PUNCT')]

My version of spacy:
print(spacy.__version__)
# 2.2.1


How to stay in the same location after an alert?

Question: I have an alert box in JavaScript which is prompted by clicking a link down the page. When the alert box pops up, and the user presses ok, the user is redirected to the top of the page. How do I make it so the page stays where the user prompted the alert box? Thanks!
Answer: Add return false; to the end of the link.
<a href="#" onclick="alert('Hello, World!'); return false;">


What's the functional difference between the "disabled" and "external" caching setting?

Question: I've seen the answer elsewhere that "External lets you use varnish, etc" but what are the internal differences between external and no caching? Does external actually cache anything, or is there a difference in headers sent?
Answer: External caching is just a caching system that doesn't use the database tables used by Drupal to cache data, or doesn't use any table in the database used by Drupal. Example of external caching systems includes APC, eAccelerator, Memcache/Memcached, Varnish, XCache, or even a system that uses files instead of database tables.
All those systems surely cache data, or there would not be any difference between using them, and disabling the cache completely. The only difference with the standard Drupal cache system is where the data are cached.
Comment: You don't actually answer the question.
Comment: @googletorp The question body actually contains two questions, one of which is "does external actually cache anything?"
Comment: true, I guess combined we guess combined we got the perfect answer.
Answer: There is like you say a difference in the headers that drupal send out. I've based this answer on Drupal 6 since it seems from the text you quote that this is the version you are referring to.
Anyways, in bootstrap.inc, drupal will call drupal_page_cache_header_external when external cache is turned on. I posted the function below since I couldn't find it on api.drupal.org
/**
 * Set HTTP headers in for downstream caching.
 *
 * The headers allow as much as possible in proxies and browsers without any
 * particular knowledge about the pages. Used for the external caching mode.
 */
function drupal_page_cache_header_external() {
  // Get headers set in hook_boot(). Keys are lower-case.
  $hook_boot_headers = drupal_get_header();

  $max_age = variable_get('page_cache_max_age', 0);
  drupal_set_header('Cache-Control', 'public, max-age=' . $max_age);
  drupal_set_header('Last-Modified', gmdate(DATE_RFC1123, $_SERVER['REQUEST_TIME']));

  // HTTP/1.0 proxies do not support the Vary header, so prevent any caching
  // by sending an Expires date in the past. HTTP/1.1 clients ignores the
  // Expires header if a Cache-Control: max-age= directive is specified (see RFC
  // 2616, section 14.9.3).
  drupal_set_header('Expires', 'Sun, 11 Mar 1984 12:00:00 GMT');

  // Allow HTTP proxies to cache pages for anonymous users without a session
  // cookie. The Vary header is used to indicates the set of request-header
  // fields that fully determines whether a cache is permitted to use the
  // response to reply to a subsequent request for a given URL without
  // revalidation. If a Vary header has been set in hook_boot(), it is assumed
  // that the module knows how to cache the page.
  if (!isset($hook_boot_headers['vary']) && !variable_get('omit_vary_cookie', FALSE)) {
    drupal_set_header('Vary', 'Cookie');
  }
}


How many number of integer coordinates exists between a line segment, including the end points?

Question: There is a line segment say $AB$ with coordinates of end-points as $A=(x_1, y_1)$ and $B=(x_2, y_2)$. $x_1, y_1, x_2, y_2$ are integers. I need to find the number of integer coordinates which lie on the line segment including end-points.
I read somewhere that it is $\gcd(|x_1 - x_2|, |y_1 - y_2|) + 1$. But, I cannot understand why this works.
I do not get the intuition behind it. I searched for proof but did not find anything intuitive and straightforward.
Please help me understand this. I am stuck on it. I am expecting a nice proof with great explanation.
Thanks in advance!
Comment: Maybe this will make it easier for you. Without loss of generality, we can assume that $A=(0, 0)$, and $B=(x, y)$ with $x, y\geq 0$. ($B\neq A$)
Comment: There's [mathjax](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference) for all your mathematical writing needs. Please use it in the future
Answer: Using Jakobian's simplification, the problem looks as follows: For any $x_0, y_0 > 0$, how many integer coordinates does the line from $(0, 0)$ to $(x_0, y_0)$ pass?
We note first, that the slope of this line is $y_0/x_0$. So the problem is equivalent to asking: for how many integers $x$ with $0 \leq x \leq x_0$ is $y_0 / x_0 \cdot x$ an integer. Now let $d = gcd(x_0, y_0)$. We get $y_0 / x_0 \cdot x = (d \cdot \hat{y_0})/(d \cdot \hat{x_0}) \cdot x = \hat{y_0}/\hat{x_0} \cdot x$ for some $\hat{y_0},\hat{x_0}$ with $gcd(\hat{y_0},\hat{x_0}) = 1$. Now $\hat{y_0}/\hat{x_0} \cdot x$ is an integer if and only if x is a multiple of $\hat{x_0}$. So how many multiples of $\hat{x_0}$ are there between $0$ and $x_0$. It is exactly $d + 1$, because $x_0 = d \cdot \hat{x_0}$. Hope this helps.


How to check if a file has completed uploading into S3 Bucket using Boto in Python?

Question: I'm trying to upload an image into S3 bucket using boto. After the image has successfully uploaded, I want to perform a certain operation using the file URL of the image in the S3 bucket. The problem is that sometimes the image doesn't upload fast enough and I end up with a server error when I want to perform the operation dependent on the file URL of the Image.
This is my source code. I'm using python flask.
def search_test(consumer_id):

consumer = session.query(Consumer).filter_by(consumer_id=consumer_id).one()
products = session.query(Product).all()
product_dictionary = {'Products': [p.serialize for p in products]}

if request.method == 'POST':
    p_product_image_url = request.files['product_upload_url']
    s3 = boto.connect_s3(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY)
    bucket = s3.get_bucket(AWS_BUCKET_NAME)
    k = Key(bucket)
    if p_product_image_url and allowed_file(p_product_image_url.filename):

        # Read the contents of the file
        file_content = p_product_image_url.read()

        # Use Boto to upload the file to S3
        k.set_metadata('Content-Type', mimetypes.guess_type(p_product_image_url.filename))
        k.key = secure_filename(p_product_image_url.filename)
        k.set_contents_from_string(file_content)
        print ('consumer search upload successful')

    new_upload = Uploads(picture_upload_url=k.key.replace(' ', '+'), consumer=consumer)
    session.add(new_upload)
    session.commit()

    new_result = jsonify(Result=perform_actual_search(amazon_s3_base_url + k.key.replace(' ', '+'),

                                                      product_dictionary))

    return new_result
else:
    return render_template('upload_demo.html', consumer_id=consumer_id)

The jsonify method needs a valid image url to perform the operation. It works sometimes, sometimes it doesn't. The reason I suspect being due to the issue that the image would not have uploaded yet by the time it executes that line of code.
The perform_actual_search method is as follows:
def get_image_search_results(image_url):
global description
url = ('http://style.vsapi01.com/api-search/by-url/?apikey=%s&url=%s' % (just_visual_api_key, image_url))
h = httplib2.Http()
response, content = h.request(url,
                              'GET')  # alternatively write content=h.request((url,'GET')[1]) ///Numbr 2 in our array
result = json.loads(content)

result_dictionary = []

for i in range(0, 10):
    if result:
        try:
            if result['errorMessage']:
                result_dictionary = []
        except:
            pass

            if result['images'][i]:
                images = result['images'][i]
                jv_img_url = images['imageUrl']
                title = images['title']
                try:
                    if images['description']:
                        description = images['description']
                    else:
                        description = "no description"
                except:
                    pass

                # print("\njv_img_url: %s,\ntitle: %s,\ndescription: %s\n\n"% (
                # jv_img_url, title, description))

                image_info = {
                    'image_url': jv_img_url,
                    'title': title,
                    'description': description,
                }
                result_dictionary.append(image_info)

if result_dictionary != []:
    # for i in range(len(result_dictionary)):
    #     print (result_dictionary[i])
    #     print("\n\n")
    return result_dictionary
else:
    return []

def performSearch(jv_input_dictionary, imagernce_products_dict):
print jv_input_dictionary
print imagernce_products_dict

global common_desc_ratio
global isReady
image_search_results = []
if jv_input_dictionary != []:
    for i in range(len(jv_input_dictionary)):
        print jv_input_dictionary[i]
        for key in jv_input_dictionary[i]:
            if key == 'description':
                input_description = jv_input_dictionary[i][key]
                s1w = re.findall('\w+', input_description.lower())
                s1count = Counter(s1w)
                print input_description
                for j in imagernce_products_dict:
                    if j == 'Products':
                        for q in range(len(imagernce_products_dict['Products'])):
                            for key2 in imagernce_products_dict['Products'][q]:
                                if key2 == 'description':
                                    search_description = imagernce_products_dict['Products'][q]['description']
                                    print search_description
                                    s2w = re.findall('\w+', search_description.lower())
                                    s2count = Counter(s2w)
                                    # Commonality magic
                                    common_desc_ratio = difflib.SequenceMatcher(None, s1w, s2w).ratio()
                                    print('Common ratio is: %.2f' % common_desc_ratio)

                            if common_desc_ratio > 0.09:
                                image_search_results.append(imagernce_products_dict['Products'][q])

if image_search_results:

    print image_search_results
    return image_search_results
else:
    return {'404': 'No retailers registered with us currently own this product.'}

def perform_actual_search(image_url, imagernce_product_dictionary):
return performSearch(get_image_search_results(image_url), imagernce_product_dictionary)

Any help solving this would be greatly appreciated.
Answer: I would configure S3 to generate notifications on events such as s3:ObjectCreated:*
Notifications can be posted to an SNS topic, a SQS queue or directly trigger a lambda function.
More details about S3 notifications : http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html
You should rewrite your code to separate the upload part and the image processing part.  The later can be implemented as a Lambda function in Python.
Working in an Asynchronous way is key here, writing blocking code is usually not scalable.
Answer: you can compare bytes written to s3 with file size. lets say you use following method to write to s3:
bytes_written = key.set_contents_from_file(file_binary, rewind=True)
in your case it's set_contents_from_string
then I would compare, bytes_written with p_product_image_url.seek(0, os.SEEK_END)
if they match. whole file has been uploaded to s3.


Xcode: add Cocoa app target to command-line tool

Question: I've got a working ObjC command-line tool, compiles fine / builds fine / runs fine / been using it for months.  I finally decided to add a Cocoa-GUI to it and I'd like to utilize the classes I've already built for the command-line tool.  Aside from retro-fitting IBActions & IBOutlets to make the MainMenu.xib work with the existing classes, I'm stuck with a basic problem.
The .app product won't build or run while the pre-existing command-line tool will.  How do I make the .app product build and run?
Comment: What do you mean by "won't build or run"? Please provide error message and the relative code.
Comment: No error messages are thrown.  Relative code...not sure it's applicable.  Basically, execute command+r or select Build from the Product menu.  Result is the command-line tool is created - shows up in black under Products in the left-hand-side navigation pane.  But the Cocoa-GUI app remains red and no *.app file/bundle is created, nor can it obviously be run. That's the problem - command-line tool is created and can be used while Cocoa GUI app is not created.
Answer: Here's how to do it.

From the Scheme pulldown menu (embossed gray below project name / architecture in main tool bar), select Edit Scheme...
Then in the ensuing popup window, choose the 'Build' item in the left-hand navigation pane.
In the lower left click the '+' (plus) button
In the ensuing target build popup sheet, choose the newly created Cocoa GUI app target and click the Add button in the lower right of the sheet
Assess the Target actions for the Cocoa GUI app - Analyze, Test, Run, etc. - choose your desired values
Click the OK button in the lower right
Then build the project

Notice that the formerly 'red' .app target is now 'black'.  Verify that the new Cocoa app can be shown in the Finder and will launch when double-clicked.


How to serve static files with Apache and dynamic content with Morbo on same server?

Question: I have Apache httpd on port 80 and Morbo httpd server on port 3000 serving perl Mojolicious code. Morbo is available only from localhost.
Now I want to set up virtual host with proxy so that static files would be served by Apache and dynamic content would be serverd by Morbo.
This is my virtual host config:
<VirtualHost *:80>
    ServerName    mojo.myhost.com
    DocumentRoot  /opt/mojo/public
    RewriteEngine on
    RewriteCond   %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
    RewriteCond   %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
    RewriteRule   ^(.*)  http://localhost:3000$1 [NS,P,L]
    ProxyPassReverse  /  http://mojo.myhost.com
</VirtualHost>

The problem is that when I try to access http://mojo.myhost.com/ Apache subrequ is issued by Apache and request sent to Morbo is  http://localhost:3000/error/noindex.html and not http://localhost:3000/.
Here is part of mod-rewrite log:
[rid#2b20905c58e0/initial] (2) init rewrite engine with requested uri /
[rid#2b20905c58e0/initial] (3) applying pattern '^(.*)' to uri '/'
[rid#2b20905c58e0/initial] (4) RewriteCond: input='/opt/mojo/public/' pattern='!-f' => matched
[rid#2b20905c58e0/initial] (4) RewriteCond: input='/opt/mojo/public/' pattern='!-d' => not-matched
[rid#2b20905c58e0/initial] (1) pass through /
[rid#2b20905cb910/subreq] (2) init rewrite engine with requested uri /index.php
[rid#2b20905cb910/subreq] (1) pass through /index.php
[rid#2b20905cd920/subreq] (2) init rewrite engine with requested uri /index.html
[rid#2b20905cd920/subreq] (1) pass through /index.html
[rid#2b20905cb910/subreq] (2) init rewrite engine with requested uri /index.html.var
[rid#2b20905cb910/subreq] (1) pass through /index.html.var
[rid#2b20905cd920/subreq] (2) init rewrite engine with requested uri /index.htm
[rid#2b20905cd920/subreq] (1) pass through /index.htm
[rid#2b20905caf40/initial/redir#1] (2) init rewrite engine with requested uri /error/noindex.html
[rid#2b20905caf40/initial/redir#1] (3) applying pattern '^(.*)' to uri '/error/noindex.html'
[rid#2b20905caf40/initial/redir#1] (4) RewriteCond: input='/opt/mojo/public/error/noindex.html' pattern='!-f' => matched
[rid#2b20905caf40/initial/redir#1] (4) RewriteCond: input='/opt/mojo/public/error/noindex.html' pattern='!-d' => matched
[rid#2b20905caf40/initial/redir#1] (2) rewrite '/error/noindex.html' -> 'http://localhost:3000/error/noindex.html'
[rid#2b20905caf40/initial/redir#1] (2) forcing proxy-throughput with http://localhost:3000/error/noindex.html
[rid#2b20905caf40/initial/redir#1] (1) go-ahead with proxy request proxy:http://localhost:3000/error/noindex.html [OK]

I added NS flag to RewriteRule but subreq still modifies the URL before it is passed to Morbo.  How can I get Apache to pass / instead of /error/noindex.html to Morbo?
If both RewriteCond are removed from virtualhost config then it works but static files are also serverd by Morbo (which I don't like so much).
Answer: Here's what happens, step by step:

The server gets a request for /
The server checks the -f condition, and finds that / is not a file, so it matches the condition.
The server checks the -d condition, and finds that / is a directory, so it doesn't match the condition.
Since it doesn't match the second condition, the server tries to process it as a local file/directory. A resource ending in / should have an index file; so it tries looking for all the index files listed.
Since it can't find an index file, it wants to show you /error/noindex.html instead.
We now go back to checking the rewrite conditions, and this time we match both - there's neither a file nor a directory called /error/noindex.html, so this time the proxy request is made

The solution:
Add a RewriteRule that matches only the empty / and have that one do the Rewrite. Example:
RewriteRule   ^/$  http://localhost:3000 [NS,P,L]
ProxyPassReverse  /  http://mojo.myhost.com

This matches a request for only /.


How to get web url of a file from sourcegraph VSCode extension?

Question: I have installed sourcegraph VScode extension and it works well to search code. Often times I need to share the sourcegraph code link with the team.
I am not able to find the ability to access sourcegraph url from the extension.
I search for some text using extension, then open the file and tried "Copy relative path, Copy remote file URL" but all of them gives me file path without the host url.
It's a pretty simple task to append the hostname and file path but it would be much easier if there is quick way to copy the path url.
Comment: I just tried that and couldn't find `Copy Sourcegraph File Link` option. I am on `v2.2.0`.

However, I just found out Sourcegraph icon in top right corner, next to *Split Editor Right* button. Clicking on that icon, opened the browser with correct url.

However, that page ended up with error

```
Error
Sourcegraph encountered an unexpected error. If reloading the page doesn't fix it, contact your site admin or Sourcegraph support.

Illegal argument: line must be non-negative
```

This works for now. Thank you
Comment: Hi Rohit, I'm trying to find you an answer from a teammate.
Comment: Hello @rohit you can right-click inside the editor file, and get a shareable link by clicking on the  "Copy Sourcegraph File Link" option that shows up. Please ensure you are on the latest VS Code extension version.
Answer:
Search a file through sourcegraph extension
Open file
Click Sourcegraph icon in top right corner. (Open file in Sourcegraph web)


Como imprimir formulário actual em MS Access?

Question: Através dum botão de comando, desejo imprimir, numa base de dados, o formulário actual no MS Access.
Answer: Tente:
Option Compare Database

Private Sub Comando0_Click()

    DoCmd.PrintOut

End Sub

Este método aceita os seguintes parâmetros (depois de printout):

PrintRange
PageFrom
PageTo
PrintQuality
Copies
CollateCopies

https://msdn.microsoft.com/en-us/library/office/ff192667.aspx


Postfix with Dovecot on Ubuntu 20.04 postfix/mail fatal: no sasl authentication mechanisms

Question: Here's the output of doveconf -n:
# 126.96.36.199 (3c910f64b): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.7.2 ()
# OS: Linux 5.17.5-x86_64-linode154 x86_64 Ubuntu 20.04.4 LTS
# Hostname: mail.servicemouse.com
doveconf: Error: t_readlink(/var/run/dovecot/dovecot.conf) failed: readlink() failed: No such file or directory
auth_debug = yes
auth_mechanisms = plain login
auth_verbose = yes
disable_plaintext_auth = no
mail_debug = yes
mail_location = mbox:~/mail:INBOX=/var/mail/%u
mail_privileged_group = mail
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope encoded-character vacation subaddress comparator-i;ascii-numeric relational regex imap4flags copy include variables body enotify environment mailbox date index ihave duplicate mime foreverypart extracttext
namespace inbox {
  inbox = yes
  location =
  mailbox Drafts {
    special_use = \Drafts
  }
  mailbox Junk {
    special_use = \Junk
  }
  mailbox Sent {
    special_use = \Sent
  }
  mailbox "Sent Messages" {
    special_use = \Sent
  }
  mailbox Trash {
    special_use = \Trash
  }
  prefix =
}
passdb {
  driver = pam
}
plugin {
  sieve = file:~/sieve;active=~/.dovecot.sieve
}
protocols = " imap lmtp sieve pop3 submission"
service auth {
  unix_listener private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
}
ssl_cert = </etc/letsencrypt/live/<host>/fullchain.pem
ssl_dh = # hidden, use -P to show it
ssl_key = # hidden, use -P to show it
submission_relay_host = 127.0.0.1
submission_relay_ssl = starttls
submission_relay_trusted = yes
userdb {
  driver = passwd
}

Here's the output of postconf -n:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
broken_sasl_auth_clients = yes
compatibility_level = 2
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
mydestination = $myhostname, mail.servicemouse.com, localhost.servicemouse.com, , localhost
myhostname = mail.servicemouse.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = /etc/mailname
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_cert_file = /etc/letsencrypt/live/mail.servicemouse.com/fullchain.pem
smtp_tls_key_file = /etc/letsencrypt/live/mail.servicemouse.com/privkey.pem
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_path = private/auth
smtpd_sasl_service = smtpd
smtpd_sasl_type = dovecot
smtpd_tls_auth_only = yes
smtpd_tls_cert_file = /etc/letsencrypt/live/mail.servicemouse.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.servicemouse.com/privkey.pem
smtpd_tls_security_level = may
smtpd_use_tls = yes
virtual_alias_domains = site1.com, site2.com
virtual_alias_maps = hash:/etc/postfix/virtual

Answer:
/var/run/dovecot/dovecot.conf) failed: readlink() failed: No such file
or directory

Dovecot is not running. It would usually place a reference to the effective configuration there, that is why doveconf is showing this error.
Try to start it and review relevant logs to see why.
Comment: Error: service(submission-login): listen(*, 587) failed: Address already in use
Comment: I suspect you have both the Dovecot submission server and Postfix submission service attempting to listen on the same port on all interfaces. Depending on whether you actually *want* the Dovecot service, configure separate interface/port binding, or disable it.
Answer: My guess is that the path for the auth listener specified in your dovecot config is placed in a location to which postfix doesn't have access (as the path must be inside the chroot of postfix) - try to use the absolute path:
service auth {
  unix_listener /var/spool/postfix/private/auth {
    group = postfix
    mode = 0660
    user = postfix
  }
}

Comment: Could you further comment out the postfix parameter `smtpd_sasl_service` to reset the value to default?
Comment: I made that change and restarted dovecot: warning: SASL: Connect to private/auth failed: Connection refused mail postfix/smtpd[7416]: fatal: no SASL authentication mechanisms
Answer: I got dovecot running by editing 10-master.conf and under service auth I set the unix_listener to /var/spool/postfix/private/auth
Comment: Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer).
Answer: i had this problem after disabled ipv6. The solution for me was to modify  in /etc/dovecot/dovecot.conf the following line:
#listen = *, ::
listen = *

Comment: This does not provide an answer to the question. Once you have sufficient [reputation](https://serverfault.com/help/whats-reputation) you will be able to [comment on any post](https://serverfault.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/566478)


AppEngine Cloud Storage Python library timeout issue

Question: I am trying to migrate a fairly large amount of data from GCS to AppEngine via the task queue and 20 backend instances. The issue is that the new Cloud Storage library does not seem to respect the urlfetch timeout, or something else is going on.
import cloudstorage as gcs
gcs.set_default_retry_params(gcs.RetryParams(urlfetch_timeout=60,
                                             max_retry_period=300))
...
with gcs.open(fn, 'r') as fp:
    raw_gcs_file = fp.read()

So the following works just fine when the queue is paused, and I run one task at a time, but when I try to run 20 concurrent tasks against the 20 backends the following starts happening:
I 2013-07-20 00:18:16.418 Got exception while contacting GCS. Will retry in 0.2 seconds.
I 2013-07-20 00:18:16.418 Unable to fetch URL: https://storage.googleapis.com/<removed>
I 2013-07-20 00:18:21.553 Got exception while contacting GCS. Will retry in 0.4 seconds.
I 2013-07-20 00:18:21.554 Unable to fetch URL: https://storage.googleapis.com/<removed>
I 2013-07-20 00:18:25.728 Got exception while contacting GCS. Will retry in 0.8 seconds.
I 2013-07-20 00:18:25.728 Unable to fetch URL: https://storage.googleapis.com/<removed>
I 2013-07-20 00:18:31.428 Got exception while contacting GCS. Will retry in 1.6 seconds.
I 2013-07-20 00:18:31.428 Unable to fetch URL: https://storage.googleapis.com/<removed>
I 2013-07-20 00:18:34.301 Got exception while contacting GCS. Will retry in -1 seconds.
I 2013-07-20 00:18:34.301 Unable to fetch URL: https://storage.googleapis.com/<removed>
I 2013-07-20 00:18:34.301 Urlfetch retry 5 failed after 22.8741798401 seconds total

How can it fail after only 22 seconds? It doesn't seem to be using the retry params at all.
Comment: For now, i was able to get away with a quick hack job to cloudstorage/storage_api.py:do_request_async() by forcing that deadline param to 90 (seconds). Things still error/time out when running the 20 backends, but much less than before. Ill have to explore this further later on.
Answer: This is a bug in gcs client library. It will be fixed soon. Thanks!
You hack will work. But if it still times out frequently, you can try to do fp.read(size=some_size). If you files are large, with a 32 MB response (URLfetch response size limit) and 90 seconds deadline, we assume a transfer rate of 364KB/s.
Comment: This needs to be fixed ASAP. It's unacceptable to push people to migrate to GCS client library and away from file-like blobstore and the library released with critical bugs.


NGINX unable to get issuer certificate

Question: I am using NGINX web server. Configured my site with a setting where user will be challenged to present his certificate when he makes first request to the site by using following setting:
ssl_client_certificate /path/to/ca/cert/ca.crt;
        ssl_verify_client on;

When the user access the site, he gets prompted to present his certificate. but after selecting certificate, he gets following message:
400 Bad Request
The SSL certificate error
nginx/1.12.2

Access log shows: "GET / HTTP/2.0" 400 633 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36"
Error log shows: client SSL certificate verify error: (2:unable to get issuer certificate) while reading client request headers, client: 188.8.131.52, server: $xyz.net, request: "GET / HTTP/2.0", host:
running openssl verify -CAfile /etc/nginx/certs/ca.crt /etc/nginx/certs
resulted in following error:
unable to load certificate
140622725740432:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:707:Expecting: TRUSTED CERTIFICATE

I am very new to NGINX and short of ideas. please help.
Answer: Your client must present all the certificates in the chain bar the root CA to the server.
If your client is a browser, it must have access to the CA certificate which issued the client certificate as well as all other intermediate CA certificates up to but not necessarily including the root CA cert.
When using a command line tool such as OpenSSL, the client certificate file must be a bundle of certificates, which starts with the client certificate and contains all other CA certificates, in order, up to but not necessarily including, the root CA cert.
In both cases, sending the root is optional, but doesn't serve any purpose.
For more information, read RFC 5246 Section 7.4.6, which refers to section 7.4.2 and the certificate_list structure.

NGINX unable to get issuer certificate


When to set the rootViewController or to addSubview to main window

Question: I know that in  AppDelegate.m, you must set the root controller for the application. Otherwise you will see nothing in your App and receive a warning.
I found that some materials use:
[window addSubview:anyViewController.view];

or use:
window.rootViewController = anyViewController;

Both methods could make the App start correctly. I can't understand why the first method doesn't set the rootviewController for the user, but it still works well. Why is this? What is the difference between them?
Answer: rootViewController was added with iOS4 and is the newer and recommended method.
Comment: @ada Oh you were making a point, not asking a question, ok, yeah, true :)
Comment: Yes, with the first example more than one view (each with their own view controller) could be added as subviews of the window. Which of them would be the rootViewController?
Comment: @ade Which "first example" are you talking about? I can only see `anyViewController`
Comment: first example: "[window addSubview:anyViewController.view];" which could be followed by "[window addSubview:anyViewController2.view];" etc.
Comment: @ade That would not be a correct way to go in iOS development. Things are not done that way. There's only one view controller just below the window in the hierarchy, other view controllers are managed by it.
Comment: Exactly my point, I've seen people do this and worse. This is why your assertion to use "window.rootViewController = anyViewController;" is correct. It is possible (but wrong) to add more than one view controller view as subviews to a window and it will work (as in not crash and I've just done it to test it in simulator and on device), but it is wrong to do so.


16/16 vs 8/8 (accents)

Question: How would you notate:
/--/--/--/--/-/-
16/16 seems ungainly, but 8/8 puts a downbeat on an "and" in two places.
(To get my software drummer to do what I want, I am using two bars of 6/8 followed by one bar of 4/8, and doubling the tempo.  This, I assume, is not a preferred solution for scoring.)
Answer: You could write this time signature as an additive meter: (12+4)/8 or (12+4)/16
However, you might as well simply write it as 4/4 and use accent markers (>) to indicate accents.
Answer: There are a few ways of doing this. Two bars of 6/8 plus one of 2/4 (or 4/8, depending on whether the "four-ness" is really evident) would actually be the most common way, or you could do it as a bar of 12/8 followed by one of 2/4. Either way, an explicit "♪=♪" tempo marking over the first change of meter would probably be a good idea.
I would tend to use quavers (eighths) as the base unit as you are courting very "black" notation with semiquavers. I'm not going to say that a semiquaver denominator is incorrect; it's just perhaps a bit harder to read and count. I'm guessing that what you describe sounds like 4 longish beats followed by two less long beats. (I don't mean a slow tempo, but one kind of beat being half again longer than the other.) I suspect the apparent tempo of the piece will depend on how fast the dotted crochets (quarter notes) sound.
If you want to bring it all into one bar, use something like (12 + 4)/8, make sure your beaming does reflect the meter, and possibly insert a Bartók-style dotted bar line between the triplets and the duplets.
Comment: Another single bar method you might want to add is to write it as a single 16/8 bar with the beat divisions written above the stave as 3+3+3+3+2+2. I've also seen additive time signatures almost as long as {3+3+3+3+2+2)/8 but that is terrible to read.
Comment: Yeah, that would work, but I'm not sure it's necessary if the beaming is properly done. Actually, I've seen scores that dispense with the meter marking altogether in favour of beam groupings and dotted bar lines, so I'm not even sure my suggestions are necessary. ;)
Comment: Do you guys know if this rhythm has a common name?  It seems familiar, maybe from marching drumlines.  It feels almost like a natural expansion of 3+3+2.
Comment: Great use in pop song, by the way:  "Tin Man" by America.
Comment: Found another interesting example:  "Ween El-Kalam" by Hayajan.
Answer: Either 4/4, 16/8, or 8/4.  16/16 indicates sixteenth notes, which would only be useful if any beats are split into an odd number of sixteenth notes or if there are any sextuplet beats involved.  (Read about compound meter to understand better what I mean.)  8/8 would be odd to use as it is neither conventional nor encompassing of the entire 16-beat pattern.  I think that an additive time signature might be somewhat useful too, but it seems like it would just be unsightly.  4/4 is useful because while it splits the pattern in two, it is legible due to its conventionality, and 16/8 & 8/4 are useful because they place the entire pattern into a measure.
PS: Two examples of 16/8 / 8/4: the opening riff to "Summer of 69" by Bryan Adams and the "I ain't afraid of no ghost" bridge from the theme to Ghostbusters.  Also, "Pyramid Song" by Radiohead supposedly has this time signature, but I'm not sure if that's accurate (its meter has befuddled many).  Hope I could help, even if late to arrive.

16/16 vs 8/8 (accents)


understanding schematic analysis notation

Question: What do the numbers above and below the staffs represent?  I was assuming that the white-circled numbers under the bass parts were the thoroughbass and that the black-circled numbers above were the scale degrees, though that doesn't seem to be the case.

Thank you for helping!
-286642
Answer: This example is following Bob Gjerdingen's convention for schemata.
From the introduction to his Music in the Galant Style (pp. 20-21):

Names of scale steps.  When I refer to the steps of a scale or key
  from an eighteenth-century perspective, I often use the names favored
  at that time.  In place of the nineteenth-century English syllables
  doh, ray, me, fah, sol, and lah, the earlier musicians used the Latin
  forms ut (or do), re. mi, fa, sol, and la.  In referring
  to the steps of a scale or key as features of a schema, I use numbers
  within circles.  For features of the melody, the circles are black
  [...].  For features of the bass, the circles are white [...].  For
  passages that modulate between keys, such fixed scale-degree
  designations poorly represent the mobile cognition of pitch.  I will
  argue that older forms of note naming may have been superior for those
  contexts.

Both the melody and bass numbers are representing scale degrees in the local key.  As Albrecht has already noted in his answer, the excerpt begins in G minor and then moves to B-flat major, so the numbers refer to the scale degrees in those keys.
Answer:
I was assuming that the white-circled numbers under the bass parts were the thoroughbass and that the black-circled numbers above were the scale degrees ...

You are right, this is not the case.
I guess : The numbers are relating to the moveable do (DOREMI= 123).
The excerpt begins in Gm:
G,A,Bb,C,D = 12345
l.h. G =1, r.h. D =5
in the second line (2nd bar) we are in Bb: Bb=Do=1
r.h. Bb,C,D, = 1,2,3, l.h. Eb=4 and E = #4
Edit:
the black-circled numbers are above the melody (and not the r.h. - I can't write here on my tab and still see the whole display).
The white-circled are "solfegging" (doremi) the bass-line.
Comment: You're probably correct, but why are some places that could have a number in a circle blank?
Comment: Because this seem to be just a pedagogical assistance to practice the solfege. It won't make sense to define each single note - as it isn't necessary to mark the fingering of each single note. I've never seen this before but I used similar helping hints when teaching. Edited **I guess** ;)
Comment: Except that solfege isn't directly related to fingering. All it does is identify each note in relation to the others.
Comment: In relation to the key! it doesn't change  until the the piece is modulating. That's why the numbering is marked again when the tonic is Gm: latido = 123
Comment: Understand that. You mentioned it in relation to *fingering*.
Comment: @Tim: But I didn't relate it to fingering. I used the analogy : if C = finger 1 **you don't have to notate** D = 2, E= 3 .... it was the answer to your question: *but why are some places that could have a number in a circle blank?* as this is an exercise to practice the solfege. The student has to give the answers. (The r.h. Circles are black, the l.h. are white, this is obvious. .... I've edited my answer: the blank circle are referring to the tune of the vocal part. Is it this what you  mean?


How do you compare two text files with different line endings in PHP?

Question: I need to compare two text files in php. One file is user uploaded, and the other is supplied by the server, running on windows.
This works fine when the file is submitted from another windows computer, but from a linux computer the files come out different, I am assuming this is because of different line endings. Is there an easy way to compare windows text files to linux text files?
Currently this is my code;
$text1 = file_get_contents($file1);
$text2 = file_get_contents($file2);
if (strcmp($content, $content2) == 0) { etc;

Answer: You could replace CRLF line endings with LF line endings or the other way around in both files - try something like this:
$text1 = str_replace("\r\n", "\n", $text1)

And the same for $text2.
Answer: Just to add another, potentially more portable option (the replacing suggested by the other answerers will already fine for your the case), the file() function splits file data into an array and seems to be able to handle both Windows and Linux encodings:
$text1 = file($file1, FILE_IGNORE_NEW_LINES);
$text2 = file($file2, FILE_IGNORE_NEW_LINES);

if ($text1 === $text2) ....

It can also deal with Macintosh line endings if the auto_detect_line_endings runtime setting is turned on.
Answer: preg_replace('/\v+/','\n',$text1)==preg_replace('/\v+/','\n',$text2)