New to reading kit music - questions about technique

Question: I'm a self taught drum kit player and this is my first time reading drum sheet music. I've made drum sheets before with MuseScore, so I can read most things fine, but there's one section where it asks me to play 3 notes at once (a ride, snare, and an unspecified drum played with the hand I assume to be a tom of some sort).

What does it want from me? Obviously I can't play 3 drums with 2 hands.

Also, it occasionally says "pop" (written in quotations on the sheet music), in reference to a snare drum. What does that mean?
Comment: I think the three hits at once notations are mistakes. If the original really sounds like all three are hit, I might just not hit the ride since it has the longest sustain from the previous hit.
Comment: Drum kit notation isn't completely standardised.  If the first space above the staff is being used for the ride cymbal, maybe the fourth space is for the hi-hat.  If so, for the first groove you could play these hi-hat notes with the left foot.
Comment: Can you add an example of such notation, and author and title of the music?
Comment: Sure, I just didn't want to get in copyright trouble. The title is "Themes from 007 (A Medley for Orchestra) arranged by Calvin Custer
Comment: You can probably play a snare and a rack tom if they are positioned the right way and you use both ends of a stick simultaneously. I can't say for sure if that is what they are after.
Comment: Drum music, as you've possibly found, is somewhat idiosyncratic. The notation can vary from engraver to engraver. Generally, the higher on the stave, the higher the sound from the drum/cymbal. But that's only a rough guide. I prefer it when there's a legend attached. 'Pop' can be achieved by tuning the batter head as tight as possible. Often then loosening off the snare head and snares themselves. It will depend a lot on the drum and your technique.
Comment: @elements in space that's an interesting thought, although I would've appreciated it if they told me what it was lol
Comment: @Tim If I tune the batter head tightly for the 'pop' sections what do I do once it asks for the original/ordinary version (I'm assuming that's what ord. means from google)
Comment: @ToddWilcox unfortunately there is no original as this is an arrangement wihtout an official recording.
Comment: If you want/need to be exact, the answer is to use two snare drums. Over the top, for some, but could be seen as authentic for others.
Answer: As a percussionist and drum set player, There's some stuff that's just 'wrong' with the sheet music in front of you (using normal as opposed to X noteheads for cymbals, along with your 3 hand instruments at once issue).
I would just pick 2 of the three based on personal taste/your ear. Personally I would very rarely be inclined to play a high tom along with a snare on every two and four, but I'm sure there's some musical context for it somewhere. Listen to some recordings of the piece if possible, ask your bandleader, and play what sounds good (such is the life of a percussionist).
If you still aren't sure, is there a guide/diagram on your music telling you what each line/space on the stave stands for? It might be in the directors score?
Answer: The "pop" text goes together with the "R.S." text above it.
R.S. means rimshot, but I think what's probably intended here is a side-stick rather than a rimshot.


Why is the set of all intervals on [0,1] not a sigma algebra

Question: I am working my way through "A First Look at Rigorous Probability Theory" by Rosenthal and I'm a bit confused by something.
In chapter 2 p.9 he mentions the set $J$ as being all intervals (open/closed/half-open/singleton/empty) contained in $[0,1]$
He then goes on to say that $J$ is not a $\sigma$-algebra.
My question is why not? I have gathered by trawling this site that it fails the condition because it is not closed under countable unions - could someone please provide a sort of "proof" of that?
Comment: Maybe I misunderstand something here but $[0.1,0.2]\cup [0.3,0.4]\cup_{i=3}^{\infty}\emptyset=[0.1,0.2]\cup [0.3,0.4]$ is not an interval.
Comment: The union of two disjoint intervals in $J$, as an example take $[1/4,1/3]\cup[3/4,1]$, does not belong to $J$.
Comment: It doesn't even contain all the open sets, as it's not closed under finite unions, let alone countable unions.
Answer: The set $J$ generates a $\sigma$-algebra, but $J$ itself is not one, since for example, the complement of an open interval is not an interval.
Comment: Right - it's not closed under unions because (as someone above said), if you take the union of two disjoint sets, that is not an interval. Thank you very much.
Comment: So does it fail as a sigma-algebra because it is not closed under complements?
Comment: Yes, nor under unions.
Answer: If $(a,b)$ and $(c,d)$ are intervals and $c>b$, then $(a,b)\cup (c,d)$ is not an interval.  In an interval $I$, if $x,y\in I$ then any $z$ with $x\le z \le y$ is also in $I$.  In contrast, in the union described, $(1/2)(a+b)$ and $(1/2)(c+d)$ belong to the union, while $b$ and $c$, which lie between $(1/2)(a+b)$ and $(1/2)(c+d)$, do not:  the union is therefore not an interval.


Go program compiles but returns wierd error when is run

Question: So i am new to Golang (started learning it today) and i have been writing a URL shortener however after running go install and then running the compiled program from the CLI it returns this error:
2014/04/05 19:05:27 invalid character '<' looking for beginning of value
exit status 1

code refrence: https://github.com/hullswitch/urlshortnr
Answer: You problem is caused by your request to Google URL Shortner. It returns a 404 Error with HTML body instead of JSON. You could debug it adding log.Println(string(output)) to if handling err after the Unmarshal.
Comment: i will try that - ok so the API is not found :/ i guess its just a malformed link or something


Proof that limit points are unique

Question: I ams having problems to prove that the limits points of a sequence are unique. For example given the following sequence
\begin{equation}
x_n=(-1)^n+\frac{1}{n}
\end{equation}
To find the limit points, I establish these subsequences
\begin{equation}
y_n=x_{2n}=(-1)^{2n}+\frac{1}{2n}=1+\frac{1}{2n}
\end{equation}
\begin{equation}
z_n=x_{2n+1}=(-1)^{2n+1}+\frac{1}{2n+1}=-1+\frac{1}{2n+1}
\end{equation}
Where it can be seen that
\begin{equation}
y_n\rightarrow 1
\end{equation}
\begin{equation}
z_n\rightarrow -1
\end{equation}
My question is how can I prove that these are the only two limit points of the sequence.
I suppose that it is related to the fact that
\begin{equation}
Image(f(n))+Image(g(n))=\mathbb{N}
\end{equation}
Being
\begin{equation}
f(n)=2n\; \; \; \;
g(n)=2n+1
\end{equation}
Comment: If you pick any other point $y \in \mathbb{R}$, can you show that there is always a small enough open interval around it such that it hits $x_n$ at most finitely many times?
Comment: Any subsequence contains infinitely many terms of one of your subsequences (which forces any limit to be 1 or $-1$).
Answer: If the sequence had a limit point $p$ other than $-1$ or $1$, then there would exist a subsequence $(x_{n_k})$  such that $x_{n_k}\to p$.
Note that the set $S:=\{n_k:k\in \mathbb N\}$ can't have an infinite intersection with the set of even natural numbers because if it did, then $(x_{n_k})$ and $(y_n)$ will share a subsequence $s$. Since every subsequence of a convergent sequence must converge, $s$ will also converge to $p$ and to $1$, which is impossible.
Similarly, the set $S$ can't have infinite intersection with the set of all odd numbers.
Therefore $S$ can't be an infinite set, which contradicts our assumption that $(x_{n_k})$ is a subsequence.
It follows by contradiction that no subsequence of $(x_n)$ can have a limit point other than $-1$ or $1$.
Answer: Suppose that $L$ is another number, not equal to $1$ or to $-1$. Then we can find neighborhoods of $1$, $-1$, and $L$, all mutually disjoint. Since the sequence is eventually inside the union of the neighborhoods of $1$ and $-1$, then it's eventually outside the neighborhood of $L$, so $L$ is not a limit point.
Comment: G Tony Jacob's. My answer is similar to yours. If you feel it is just a copy of yours I delete. Wanted to be a bit more concrete.
Comment: @PeterSzilas, it doesn't bother me. It's nice to have the answer couched in both kinds of language: more concrete, and more..... topological? Cheers :D
Comment: @PeterSzilas, I notice that you made the same mistake I did, which I just corrected in my answer. There is no reason to assume that the third point is a limit point, since we never use that assumption. It's just a number distinct from $\pm 1$.
Comment: G Tony Jacobs. A nice way of looking at it. Thanks:))
Comment: G Tony Jacob's. I wrote: There is another limit point (means a not equal to $\pm 1$).What should I correct?
Comment: @PeterSzilas, I changed mine to just make $L$ another *number* not equal to one of the two known limit points, not another limit point.
Comment: G Tony Jacobs. Does saying another limit point a not imply that a not equal 1 or - 1? Set it up slightly differently from you. Assumed that there is an a, and found a contradiction.
Comment: @PeterSzilas, it's not really a proof by contradiction unless you use the assumption that the other point is a limit point. What the argument itself shows is that if $a\ne 1$ and $a\ne -1$, then $a$ is not a limit point. Nowhere is the contradictory hypothesis used.

I admit it's kind of a pedantic point. The argument is clear, in any event.
Comment: @PeterSzilas, to answer your direct question: Yes, saying that $a$ is *another* limit point does imply that $a$ is distinct from $1$ and $-1$. However, assuming something that (one-directionally) implies what you really need is assuming something stronger than you need. It doesn't make any part of it false, just kind of logically clunky.
Comment: G Tony Jacobs. Edited. Thank you.
Comment: G Toni Jacobs. Thank you for pointing out that that my original post set up, as a proof by contradiction, was a bit " clunky".  Going over it and your comments you were absolutely right, not much of a contradiction. I feeel I have learnt something Thank you for your patience:))
Answer: Take $a\in\Bbb R\setminus\{1,-1\}$. Then, take $\varepsilon=\min\{|a+1|,|a-1|\}$. Since $a\ne\pm1$, $\varepsilon>0$. Since $\lim_{n\to\infty}x_{2n}=1$ and $\lim_{n\to\infty}x_{2n-1}=-1$, there is some $N_e\in\Bbb N$ such that$$n\geqslant N_e\implies|x_{2n}-1|<\frac\varepsilon2$$and there is some $N_o\in\Bbb N$ such that$$n\geqslant N_o\implies|x_{2n-1}+1|<\frac\varepsilon2.$$But then, since each natural number is either even or odd, if $n$ is large enough, then you have $|x_n+1|,|x_n-1|<\frac\varepsilon2$. So, since $\varepsilon\leqslant|a+1|,|a-1|$, $|x_n-a|>\frac\varepsilon2$. Since the inequality $|x_n-a|>\frac\varepsilon2$ takes place for every $n$ is large enough, $a$ cannot be the limit of a subsequence of $(x_n)_{n\in\Bbb N}$.
Answer: Suppose $\ L \not\in \{-1,1\}\ $ is a limit point of $\ \{x_n\}_{n\in\mathbb{N}}\ $ and define $\ \delta := \min \left\{\ \frac{\vert L-1 \vert}{2} ,\ \frac{ \vert L-(-1) \vert }{2}\  \right\}.\ $
Show that $\ (L-\delta, L+\delta) \cap \{x_n\}_{n\in\mathbb{N} }\ $ is finite and conclude.
Answer: One more attempt:
Consider a point $a\not =\pm 1.$
There are open neighborhoods of $a, - 1,1$ that do not intersect each other: $U_a, V_{-1}, W_{1}$.
There is a $n_0$ s. t. for $n \ge n_0$ $x_n \in V_{-1}$ or $x_n  \in W_1$.
There are only finitely many indices $n <n_0$, s. t. $x_n$ not in $V_{-1}$ or $W_{1}.$
Hence:
$a$ is not a limit point of $x_n$.
Recall:
$a$ is a limit point of the sequence $x_n$ if for every open neighbourhood of $a$ there are  infinitely many indices $n$ s.t. $x_n$ is in this neighbourhood.

Proof that limit points are unique


Why should you not restore a DC that was backed up 6 months ago?

Question: Why should you not restore a DC that was backed up 6 months ago?
As I am learning Active Directory Domain Services I came across this question in one of the blogs but I was unable to find a detailed answer. So please can anybody explain this concept to me.
Comment: Because you should have more recent backups?
Comment: regular, automated, **monitored** *and* **tested**. You really don't want to realize that your backup is failing for 3 month or cannot be restored at the very moment you absolutely need it.
Comment: Unless... all the more recent backups were on the same nuclear deposition area, making this singular off-site backup the only usable backup of the last DC. On _force majeure_ cases no-one would blame you for not having a backup for the unexpected. For anything less you should have regular and automated backups.
Comment: Many years ago I restored an ancient NT4 AD server to some spare kit, dumped the parts of the AD needed, and then massaged them in a text editor.  Could have imported that massaged data into the live server, but that wasn't needed.   Memory's getting woolly after ~17 years, can't think of the software's name sorry.
Answer: There is a thing called tombstone lifetime in Active Directory. When you delete an object in Active Directory it is not immediately gone, it is converted to a tombstone and this information is replicated to the other DCs. When the tombstone lifetime is reached the object will be purged. If you restore prior to a state before the deletion and the tomsbtone is not replicated to the restored DC before it expires, the object will remain present in your restored DC but not in the other DCs. Now you have inconsistent data. Default tomsbtone lifetime for Server 2008 and onwards is 180 days (= 6 months).
Comment: It can be restored if it is the only domain controller in the domain. If it isn't the only DC the restore is irrelevant because the other domain controllers will not replicate with a restored DC that is older than TSL. There also aren't any practical cases to restore a DC if other DC's are available, unless the entire domain/forest is smoked. In that case, they wouldn't keep any of the existing DC's, but would restore the old backup to one DC, and promote all new DC's.
Comment: Yeah, restoring such an old backup will get you more trouble because the secure channel passwords expired too, so no client will talk to this DC and you will have to rejoin all clients to the AD. All in all this is not a good idea.
Comment: I don't think anyone is saying it is a good idea.  If the only backup available is older than TSL, it can be restored.
Comment: Ok, I'll remove the last sentence from my answer because it can be misleading.
Answer: Not only deleted objects.
Let us assume for a while that some servers have been configured IIS, Certificate server (PKI), policies have been applied on OU, delegation has been given to some users, Authentication has been done on some AD users like VPN access, etc.
All these changes will be replaced with old Active Directory.  This action is not acceptable at all.
Comment: Not necessarily. Non-authoritative restore will replicate the existing data from another DC but it will lead to inconsistent data if the tombstone lifetime has expired (besides the fact that it won't let you restore a backup which is older than the tombstone lifetime in the first place).
Answer: The reason you cannot restore an object older than 6 months is because of 2 elements in AD.   Tombstone Lifetime, and the object's Relative Identifier, or "RID".
RIDs are basically a sequential number, handed out by the "RID Master" FSMO role holder to every DC in the domain in "pools" of 500. RIDs become the last octet of an objects Security Identifier, or "SID" and SIDs are used for permissions to NTFS files, Applications, etc.  So, the object SID is a key element in granting access to resources. Because of their security sensitive nature, the value of the RID for each object must be unique. As such, RIDs cannot be assigned by the admin who created the object. Microsoft uses the RID master to keep tight control over those RIDs. Each DC uses their "pool" of RIDS sequentially, and so, when AD objects are created, the RIDs are assigned in a semi-sequential order.
...and this is very important to understand: YOU cannot decide which RID your new user or group, etc. will get. And, for obvious security reasons, you cannot change the RID/SID value of an object. Allowing an admin to set this value would be a BIG security violation on how Permissions work in the entire AD infrastructure.
Enter Tombstone Lifetime (aka "TSL"): Microsoft didn't design this so that you can restore objects... they designed TSL so that every DC in the domain would be updated about the deleted state of an object, even if that DC was offline for an extended period of time. 60 days wasn't cutting it, so in Windows Server 2003 SP2, they changed to 180. So, when you delete an object, it isn't actually purged from the Directory until TSL is reached. Instead, the object is moved into the Deleted Objects container, and all but the essential attribute values are stripped from it. The SID is one of those "essential" attributes that is kept.
If you have the AD Recycle Bin enabled, things are a bit different: The object still moves into the Deleted Objects container, but all its attributes are kept (nothing is stripped). It stays this way for 180 days in a "Deleted" state, and then it changes to a "Recycled" state, which is just like the original Tombstone state (i.e. most attribute values are stripped from the object). When you look in the AD recycle bin, "Deleted" objects will show, but "Recycled" objects are there too, they're just hidden.  So, "Recycled" = "Tombstone", and that 180 days in the "Recycled" state = the original 180 days in a "Tombstone" state, better known as "Tombstone Lifetime, or "TSL".
(Note: If you have the AD Recycle Bin enabled, Microsoft does not recommend restoring objects that have reached a "Recycled" state... but I've done it, and it works. I think they don't recommend this because of how tedious it was to restore objects before the AD Recycle Bin)
Still with me?  Good! :)  So, this whole time of "Deleted" "Recycled" or (original) "Tombstone" state, the object can be restored, because the RID (SID) is still on the tombstone object. With the AD Recycle Bin you can simply Restore an object, and you don't need a backup at all, because all its attributes are there. If the object is a Tombstone (or "Recycled") you'll need a backup to restore all the attributes.  But after Tombstone Lifetime, a Garbage Collection process purges the object from the directory completely. Garbage Collection is an internal process that runs on each DC every 12 hours. Now the RID doesn't exist anymore in the Directory, and so even if you have the object in a backup, Microsoft will not allow you to write it back in, because YOU CANNOT ASSIGN a RID value to an object.
So, in summary:

You cannot restore an object older than TSL because the Tombstone (and thus the RID) has been purged from the directory, and you cannot re-introduce it.
If you try to restore an entire DC from a backup > 180 days, the DC will identify this and automatically disable inbound and outbound replication (and I think stop authentication of anything other than admin accounts) in order to keep inconsistent data (like "lingering objects") out of your directory.

I do hope this helps.  If so, please give me some credit! :)


Bass notes on the treble scale (wavy lines)

Question: Could someone please assist with an explanation of these wavy lines in the bass with notes moving up to the treble scale? I am not sure how to interpret this information.
Anastasia - P.F. Webster, Alfred Newman
 *
vs
Comment: Please add what piece/composer these are from.
Comment: Meter? Clefs? Is the bottom one with triplets and four slur lines a separate piece, another edition, something you notated?
Comment: A distinction I think none of the answers will cover - the top notation is lightly implied to involve both hands, while the bottom notation is similarly implied to involve the left hand only.
Comment: More than LIGHTLY implied I think!
Answer: The first example is 8ths, in 12/8 time (or possibly triplets in 4/4, well enough established for the numbers to be omitted) slurred in six-note groups. The wavy lines are one way of writing a slur that crosses between staves.
The second is triplet 8ths, in 4/4 time, slurred in three-note groups.
The first might have been written like this.  Not as pretty?
Comment: Schubert Impromptus in C minor, Eb major, Gb major, and both in Ab major.  Chopin Nocturnes Op 15/1, 27/1, 32/2, 48/2, and 72/1. And Moonlight is in cut time, not 4/4. Don't be insulting.
Comment: There's not enough information to presume 12/8 time. It could be 4/4 with the triplets already well established and so not explicitly notated as such. 12/8 *feel* would be fair, though that would apply to both exceprts.
Comment: OK, I'll give you that.  Though I bet you can't quote an example other than the 'Moonlight'!
Answer: Two different answers.
The top ones are phrase marks, meaning the 6 notes, 3 bass, 3 treble are played as one phrase - in one breath if you like.
The bottom are marks to denote triplets, 3 notes played in the time of 2.  The number 3 is a giveaway here, sometimes written in the mark, sometimes over. Here, under.
The top and bottom wavy lines are not related to each other in any way.
Comment: On the bottom example I would say the notes also have phrase marks but in groups of 3's since the triplets are marked on the bottom and triplets are sometimes indicated with simply a number "3".
Comment: @Tim Of course but I was referring to them being slurred together in groups of 3's as opposed to groups of 6's in the first image. I see the phrasing marks over the notes as independent of the "3" numbers on the bottom.
Comment: They're both slurs rather than phrase marks I think.   Non-slurred triplets could have a bracket, or have just the number.
Comment: The bottom ones do not denote triplets; that's what the 3s do. The slurs denote legato and phrasing.
Comment: Just legato.  There COULD be an overall phrase mark as well.  But there isn't.
Comment: @JohnBelzaguy - aren't triplets usually played with 'groups of three' phrasing? I thought that was the point, to differentiate them from quavers in 3/4 time. Unless it's the America thing again.


How to use summary field conditionally for display?

Question: I have created a content type Band with a Description field (as Long Text and Summary). When I am viewing the Band page, I want to see the full description field. And when I am viewing a listing of bands, I want to see a summary description or the first hundred characters if the summary description is missing.
How do I show appropriate Description for the Band page and the listing pages?
Comment: @KrishnaMohan  ,I have updated my que.. **Description** field is  type of  "Long Text and summary".
Answer: The Description text field needs to be of type Long text and summary.
With view modes (admin/structure/types/manage/band/display) you can configure how the fields must be rendered.
In the view mode Teaser you could set the format to Summary or trimmed and in other view modes to Default.
When viewing the content type Band as a full page you can render the view mode Default. When rendering a list of Bands with views you can set the view mode to Teaser.


Is it possible to restart a server without access to its SSL key?

Question: I'm given a server (with root access) by a tech department to run a web-app app on some sub-domain. But the app requires authenification. So I requested the SSL key for the domain. The tech squad is reluctant to give me the key -- this is understandable.
I need to restart the server from time to time. Is it possible to configure permissions for a non-root user to be able to restart the server, but with no access to it's SSL key?
The server might be either of apache or nginx. If I run either of two with no root access I get the following:

apache:
AH00526: Syntax error on line 35 of /etc/apache2/sites-enabled/canvas-misis-ru.conf:
SSLCertificateKeyFile: file '/etc/ssl/private/ssl-cert-snakeoil.key' does not exist or is empty

nginx:
nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2014/09/21 17:08:55 [warn] 16805#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:2
2014/09/21 17:08:55 [emerg] 16805#0: SSL_CTX_use_PrivateKey_file("/etc/ssl/private/ssl-cert-snakeoil.key") failed (SSL: error:0200100D:system library:fopen:Permission denied:fopen('/etc/ssl/private/ssl-cert-snakeoil.key','r') error:20074002:BIO routines:FILE_CTRL:system lib error:140B0002:SSL routines:SSL_CTX_use_PrivateKey_file:system lib)

Comment: You should not start apache/nginx process under another user than root so they can impersonate user/group defined in their config files and read config files owned by root. A common solution is to create a nopassword SSL key only readable for root and allow users to `sudo` a daemon manager to gracefully restart apache or nginx processes.
Answer: It is possible to grant root-rights for a single command to a user using a rule in /etc/sudoers.

Do sudo visudo
Add a new rule
someuser ALL=(ALL) NOPASSWD: /usr/sbin/service apache2 restart

As you can see, it is possible to also parameters.
The user someuser is the allowed to do the following:
sudo service apache2 restart

Comment: Suppose I'd like to run `apt-get install` with no password. What is the correct rule than?
Comment: Seems like it is `someuser ALL=(ALL) NOPASSWD: /usr/bin/apt-get install` -- so no `/sbin` binaries are possible, and full path is due.
Comment: `/usr/sbin` is possible. And full absolute paths are mandatory, yes.


Every first order logic formula can be written in disjunctive normal form

Question: How can i prove that: Every first-order logic formula can be written in disjunctive normal form?
It is easy if the formula does't contain any quantifiers.
 i think i have to use induction on formulas but again i'm stuck in the non-quantifier-free formulas...
Comment: Are you familiar with [prenex form](https://en.wikipedia.org/wiki/Prenex_normal_form)?
Answer: First, let's get clear on what we mean by a first-order logic formula that is in disjunctive normal form (DNF).  This means that the formula is of the form
$$Q_1 x_1 Q_2 x_2 .... Q_n x_n \ \varphi(x_1, x_2, ..., x_n)$$
where each $Q_i$ is either $\forall$ or $\exists$, and where $\varphi(x_1, x_2, ..., x_n)$ is a quantifier-free truth-functional formula in DNF (I assume it is well-known what it means for a truth-functional formula to be in DNF).
In this form, all the quantifiers are said to be 'in front of' the statement, though note that an individual quantifier may appear after other quantifiers. So this is what I mean when below I talk about 'pulling quantifiers out in front of the statement'.
Now, you can take any first-order logic formula, and go through four steps to get it into disjunctive normal form:

Rewrite all truth-functional operators other than $\land$, $\lor$, and $\neg$ in terms of $\land$, $\lor$, and $\neg$
Change variables in such a way that each different quantifier quantifies a different variable. For example, change

$$\forall x P(x) \lor \exists x Q(x)$$
to
$$\forall x P(x) \lor \exists y Q(y)$$

Use the Quantifier Negation Laws and Prenex Laws to pull any quantifiers to the front:

Quantifier Negation Laws
Where $\varphi$ is any formula:
$\neg \exists x \ \varphi \Leftrightarrow \forall x \ \neg \varphi$
$\neg \forall x \ \varphi \Leftrightarrow \exists x \ \neg \varphi$
Prenex Laws
Where $\varphi$ is any formula and where $x$ is not a free variable in $\psi$:
$ \forall x \ \varphi \land \psi \Leftrightarrow \forall x (\varphi \land \psi)$
$  \psi \land \forall x \ \varphi  \Leftrightarrow \forall x (\psi \land \varphi)$
$ \exists x \ \varphi \land \psi \Leftrightarrow \exists x (\varphi \land \psi)$
$  \psi \land \exists x \ \varphi  \Leftrightarrow \exists x (\psi \land \varphi)$
$ \forall x \ \varphi \lor \psi \Leftrightarrow \forall x (\varphi \lor \psi)$
$  \psi \lor \forall x \ \varphi  \Leftrightarrow \forall x (\psi \lor \varphi)$
$ \exists x \ \varphi \lor \psi \Leftrightarrow \exists x (\varphi \lor \psi)$
$  \psi \lor \exists x \ \varphi  \Leftrightarrow \exists x (\psi \lor \varphi)$
Notice that because of step 1 the only truth-functional operators left are $\land$, $\lor$, and $\neg$, so there are only three possibilities if a quantifier is not yet in front of the statement:
A. It is being negated ... ok, so apply Quantifier Negation
B. It is a conjunct of a conjunction... ok, so pull it outside the conjunction using Prenex Laws .. which we are guaranteed to be able to apply since we renamed variables, so the variable quantified by the quantifier cannot occur in the other conjunct(s)
C. It is a disjunct of a disjunction: similar to B
This means that if we keep applying these rules, all quantifiers are guaranteed to end up in front of the statement.

Now that all quantifiers are in front, the body is a truth-functional formula, which we know can be put into DNF


cat on a quoted variable fails

Question: I have this code snippet:
userjobs=$(grep -rw "$USER" /my/job/dir/|awk '{print $1}'|sort|uniq|rev|cut -c 2-|rev)
for job in "${userjobs[@]}"; do
  cat "$job"
done
exit 0

When I run it as is, I get the following output:
cat: /my/job/dir/45
/my/job/dir/46: No such file or directory

However, if I unquote $job, I no longer receive this behavior, and it cats each of the files as expected.
I've done some reading up on globbingand splitting to see if this is occurring, but it seems like double-quoting should prevent that from happening. Can anyone explain why the behavior is different between "$job" and $job?
Comment: `"${userjobs[@]}"` only makes sense if `userjobs` were an array, but it's not; it's just a regular string.
Comment: ...btw, a pipeline with that many components is generally a code smell (which is to say, an indication that there's a better way to solve your larger problem).
Comment: In particular, piping `grep` to `awk` is rarely necessary, since `awk` can do its own matching. `sort | uniq` should be `sort -u`, but `awk` can also do its own uniquing.
Comment: assuming their sort has a -u.
Comment: `awk` could also remove your last two characters, making the double `rev` moot as well.
Answer: This happens because your variable looks like:
userjobs='/my/job/dir/45
/my/job/dir/46'

If you expand it as an array, with "${userjobs[@]}", that it acts as an array with exactly one element -- that string. Thus, behavior is identical to:
userjobs=( [0]='/my/job/dir/45
/my/job/dir/46' )

...still exactly one string with a literal newline in it.
Thus, cat "$job" looks for a file with a literal newline in its name.

To load your result into a real array you can iterate over with "${userjobs[@]}" expanding to a distinct element per line, use:
readarray -t userjobs < <(grep ...)

Answer: userjobs needs to be an array. Put parentheses around the value when assigning it:
userjobs=($(grep -rw "$USER" /my/job/dir/|awk '{print $1}'|sort|uniq|rev|cut -c 2-|rev))

Comment: NMDV, but [BashPitfalls #50](http://mywiki.wooledge.org/BashPitfalls#hosts.3D.28_.24.28aws_....29_.29). Better to suggest `readarray -t userjobs < <(...)` so globs aren't expanded, or *at least* set `IFS=$'\n'` first so non-newline whitespace isn't split into extra names.

cat on a quoted variable fails


export const getting undefined

Question: When I am accessing const value of a js file from my another js file am getting undefined Data
Abc.js
import { Platform } from 'react-native';

      const abc = Platform.select({
        ios: [
          'com.abc',
          'com.xyz'
        ],
        android: [
          'com.pqr',
          'com.lmn'
        ]
      });

    export default abc

App.js
import React, { Component } from 'react';
import {
  Platform,
  StyleSheet,
  Text,
  Button,
  View
} from 'react-native';

import { abc } from "./Abc";

const instructions = Platform.select({
  ios: 'Press Cmd+R to reload,\n' +
    'Cmd+D or shake for dev menu',
  android: 'Double tap R on your keyboard to reload,\n' +
    'Shake or press menu button for dev menu',
});

onPressgetData = () => {
  console.warn("DATA " + JSON.stringify(abc));
}

export default class App extends Component {
  render() {
    return (
      <View style={styles.container}>
        <Text style={styles.welcome}>
          !! Welcome to React Native !!
        </Text>
        <Button title="get Data"
          color="#841584"
          onPress={() => onPressgetData()} />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  welcome: {
    fontSize: 20,
    textAlign: 'center',
    margin: 10,
  },
  instructions: {
    textAlign: 'center',
    color: '#333333',
    marginBottom: 5,
  },
});

I am accessing abc const data from my App.js when I click get Data instead of array I am getting undefined in warning. I don't know where I have mistaken Thank you in advance
Answer: You've exported your module as default and importing it as a named import, therefore it is undefined.
Change
import { abc } from "./Abc";

to
import abc from "./Abc";

to get correct result
Answer: When you are exporting a single component from a file you can use export default abc and this can be imported directly in other files by import abc from './abc'
When your files have many components/functions, you will have to export each function individually using export functionName and import them using
import { functionName, functionName2, functionName3 } from './abc'
You can also use export default SpecialFunctionName along with other exports.
So, when you
import SpecialFunctionName(can use any name here) from './abc'
you will always get SpecialFunctionName as it was default export-ed.

export const getting undefined


Prevent direct access to mp3/wav files while allowing a flash player to access them with .htaccess (or PHP)

Question: How do I prevent direct access/download to mp3/wav files while allowing a flash player to access them with .htaccess (or PHP)? I've been looking for a solution with only partial and non-functioning solutions to show for my efforts.
The solution below seemed like a great fix at first but it also blocks my flash player from accessing the files. Could I only allow access from particular pages?:
< Files ~ ".*\..*">

order allow,deny

deny from all

< /Files>

The solution below seemed great at first because it didn't allow people to view the files in the directory but if the user knows the exact URL of the music file, they can download it:
SetHandler application/x-httpd-php

SetHandler application/x-shockwave-flash

Now, I came across this post that forces a user to produce a username and password using htaccess but I dialog box pops up when on the flash player screen. Is there a way for the page the send the login info without the user doing anything?

If this isn't a secure method, can someone suggest a secure and relatively straight-forward method of implementing this restriction feature? URLs and examples would be greatly appreciated
P.S. This is a WordPress site, hence, I'll be using PHP as a programming language to implement any solution.
P.S. Looking to block novices from downloading, NOT hackers/crackers/internet wizards.
Answer: Since PHP is available, use it to protect the files. Don't have them in them in the web root, but somewhere that is accessible to PHP. Then generate a one-time-use URL like:
<?php
  $unique = md5( uniqid() );  // 32 hex characters
?>

Then store that unique value in the session/server/db and have another page validate the unique string prior to streaming the file:
Stream Me

Be sure to expire that unique token after the first use (or maybe after a few times if you are feeling generous). It won't stop the die-hards from capturing the HTTP stream anyway, but it should prevent casual linking.
Comment: -1 uniqid() alone is a very weak random number and not meant to stop attacks.  Further more md5() does not make the value more random.   Other than that this is nearly identical to my post but contains less information.
Comment: @Rook: I wrapped uniqid() in an md5() call to ensure the output characters are all URL friendly - not to enhance the cryptographic security. It may be totally unnecessary. And while uniqid() may be weak, it is probably "good enough" in this case to stop direct linking. If you can improve on the information/examples provided please add it to your answer and let it get up-voted.
Answer: As The Rook points out, you can't have it both ways. You can't both give and not give your users access to your data. No matter how complex your authentication scheme becomes, competent users will always be able to bypass it because in order for the Flash player to function they must have credentials. Personally, I think the correct solution is to recognize that you can't prevent a determined user from saving your content and just let them. If you insist on making it more difficult, what solution is right for you will be determined by what segment of users you want to be effective against and how much work you're willing to put into implementation.
A simple solution would be to generate a one-time key each time you serve a viewer page and then serve the content through a PHP script that checks it. That way the user at least has to load the viewer page for the content they want and examine its source to extract the key instead of just putting a URL in their browser's address bar. However, if your site becomes at all popular someone will probably make available a script that does that automatically. For example, see youtube-dl, a Python script that downloads YouTube videos.
In your post you mention password protecting the files with Apache. It may be possible to have the Flash player application submit HTTP authentication, but I doubt that any existing players support that and modifying one to do so would require both the sources and experience with ActionScript. Any solution that will survive such trivial attacks as reading the page source is likely to require modifying the player.
Comment: My apologies for the redundancy. I wasn't getting the usual "someone else sumbitted an answer / edited their answer" notifications while composing this.
Answer: Someone will always be able to appear as though they are running flash and be able to download your music.  TamperData can be used to see all traffic the browser produces (including flash),  and have the ability to replay, intercept and modify all requests. Flash is easy to decompile,  but this probably isn't necessary.
The only thing you can do is to raise the bar and to prevent direct linking to your content.  You can do this by using PHP to restrict access to the media.  Put all of the media outside of the web root,  or protect the directory with a .htaccess deny from all.  Have the flash application first send a "request to download",  give the flash app a temporary single use token (cryptographic nonce).  This token is then used in the next request to download the music from a PHP file.  This is easy to fool,  but its the best you can do.
Comment: I know that from it's on the Internet it can never be truly secure but I'm targeting the typical techie user who might see the location playlist.xml file and browse it, open it and then go the mp3 file urls included. I'm NOT looking to block the hackers and crackers out their in the wild west.
Comment: @Julian I'm talking about defending against children,  the most simple of attacks.  It is trivial to intercept traffic and to decompile flash applications.   You can obtain a truly secure server,  but this service is inherently flawed.  What i have suggested is what major vendors music vendors like bleep use.
Comment: @Julian  also don't use words like "cracker" and "wild west".  You are getting the facts from a very skilled white hat hacker.
Answer: There is another solution, tried and quite successful: load the song in a . Direct access to the song will be restricted in the PHP code.


uWSGI optimize option

Question: I was looking at adding some assert statements in my code and wanted to be able to pass an argument to uwsgi to be able to turn off evaluating those statements in production.  I can't seem to figure out how the optimize option in uwsgi maps to the -O command line value for python.  uWSGI's option takes an integer but has no description as to how it interprets or uses that integer other than saying "Set python optimization level".  However, the python docs never mention integers except with relation to the environment variable and only that an integer is equivalent to multiple -O arguments (which I can't see any description of what that does either, though I suspect it may do something like -OO)
So, what should I set the optimize value to to simply shut off assert statements and what should it be set to if I also want to remove docstrings? And is setting it to 0 (zero) the default value?
Answer: I tested it by setting it to zero and debug was still on but setting it to any number greater than zero turns debug off.
My code looks like this
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    assert(not __debug__)
    return "Hello World"

And my call looks like this
uwsgi --http 0.0.0.0:8000 --wsgi-file app.py -O 1

EDIT
I also added a doc-string to the function and this to the end of the app.py file
print "DOC STRING: %s" % application.__doc__

And tested with -O set to 1 and 2, with 1, I got a doc-string, with any value greater than 1 I got a None.

uWSGI optimize option


Which of the wysiwyg modules will get in to the core of Drupal 8?

Question: I heard that there will be a wysiwyg editor in core for Drupal 8. Is there any decision made yet which one will make it?
I heard about:

CKEditor
Aloha Editor
Wysiwyg

I have a decision to make which module I will add to my site and I need some deeper integration of the wysiwyg to the Drupal core. For example, that all external links are programmatically get stored in a link field an so on.
So I am hoping to get some of those features in feature when I choose the right module backported to Drupal /.
Answer: Dries answered this in From Aloha to Ckeditor on Jan 02, 2013:

Therefore, we are going to switch from Aloha to CKEditor for Drupal 8
  core. By making this switch, we will not only have a more mature
  WYSIWYG editor, but we also free up resources to work on other parts
  of Drupal's authoring experience. The CKEditor team has committed to
  fix the 8 functional gaps that we've identified in their two next
  upcoming releases.
Comment: To add to your answer. ckeditor has already been committed to D8 and in the wysiwyg session at the recent Drupalcon it was mentioned that there will be nothing backported to D7 in this regards. At least from Drupal's side of things. The ckeditor team may add some of the features on their side, but nothing definitive.
Comment: @user5950 If you look at the Git history for the Drupal 8 core ckeditor module ... I believe all the committers are Core drupal contributors and not the D7 "ckeditor" module maintainers. See: http://drupalcode.org/project/drupal.git/history/HEAD:/core/modules/ckeditor  I believe its a completely new module -- not intended to be backwards compatible (as is the rest of D8 <-> D7)
Comment: Ok, that's clear, but does that mean that the base of the integration will be the module "CKEditor", thy still could use the Wysiwyg API module to do the integration or something new.


pg.rb segmentation fault [Mojave upgrade]

Question: Segmentation fault in pg.rb:56
versions:
rails: 5.2.0,
ruby: 2.4.4,
pg gem: 0.20.0
After upgrading to Mac OS mojave i have encountered problems with my local host server. The server itself, starts fine, however when trying to access it through a web browser, it crashes and I have the segmentation error shown above.
Comment: Try reinstalling the `pg` gem - this should recompile the native code with the current libraries on Mojave.
Comment: I have narrowed it down to the `workers ENV.fetch("WEB_CONCURRENCY") { 2 }` line in my puma.rb file. Do you know why this could be causing a segfault ?
Comment: Thanks of the help, I have tried that but unfortunately it does not work. After digging around a little I have found that when I remove the puma gem from the app, and the server runs with WEBrick, it loads fine and no segmentation fault.
Comment: puma also has some native extensions - have you tried reinstalling the puma gem as well?
Comment: Yeah, I have tried reinstalling the puma gem and reinstalling the gem to the latest version.
Comment: How did you proceed?
Comment: The problem seems to be running puma in multi connection mode. Option 1: updating ruby worked but wasn't the best option for me at the time, Option 2: Setting the workers to 1, meaning puma was in single user mode in my dev environment.

`workers_count = Integer(ENV['WEB_CONCURRENCY'] || 1)
if workers_count > 1
  workers workers_count`
Comment: For me the sefault is only happening in rails console, not when running webserver (all in development)
Answer: As this issue is only occuring in the development environment, I made it conditional. This solution in puma.rb works for me until the bug gets fixed.
workers ENV.fetch("WEB_CONCURRENCY") { 2 } unless Rails.env.development?
Comment: This fixed it for me. I don't understand what the actual issue is here, if you do, would you mind putting a link to it so we can track it?
Comment: This worked for me as well. And to clarify, the fix is in `config/puma.rb`.
Answer: in .env file set
WEB_CONCURRENCY=0
and you do not need to add any logic in config/puma.rb
Comment: This, of course, if _dotenv_ is being used. But it's a good idea!
Answer: I had a similar issue, in which my test environment was often crashing in Ruby 2.6.3 with Segmnentation Fault lib/pg.rb line 56.
What worked for me was setting pumb.rb to have zero workers in the test environment:
# config/puma.rb
(ENV.fetch("RAILS_ENV") == 'test') ? (workers 0) : (workers ENV.fetch("WEB_CONCURRENCY") { 2 })


How do I combine select rows into a new row within my query

Question: I am very new to coding in general, so please excuse any basic mistakes in my syntax or knowledge. I am using a query that I didn't write, but that I am trying to improve.
set @year = 2020;
set @reportd = '###';
set @asofday = '2020-01-01';

select format(sum(x.value), 0) xvalue, x.ptype
    from
        ( select p.mnum, (p.bvalue + p.lvalue) as value,
        p.exeamount, p.excamount,
        p.damount, phis.ptype
        from history h
            join Dfee d
            on d.p_id = h.p_id
            and d.dcode = @reportd
                join( select max(history.id) as id,
                pc.ptype
                from history
                join cash c on history.id = c.p_id
                join pclass pc on history.pc_id = pc.id
                where c.year = @year
                and date(c.cdate) <= (select x.date
                    from (select date(cdate) date,
                    count(date(cdate)) A
                    from cash
                    where year = @year
                    group by date(cdate)
                    having A > 1
                    order by A desc
                    limit 1) x)
                    group by history.mnum ) phis.id = h.id) x
                    group by x.ptype ;

What this gives me is two columns and 4 rows
   +------------+------------+
   |      xvalue|    ptype   |
   +------------+------------+
   | 124,213,122|      home  |
   +------------+------------+
   | 223,334,552|      work  |
   +------------+------------+
   | 112,112,220|      away  |
   +------------+------------+
   | 154,556,454|     lunch  |
   +------------+------------+

What I am trying to do is to combine two of the rows into one under a new name. I can't alter the database in any way, so this all has to be within the query if possible.
Below is what I would like it to return. I want to combine the rows of 'away' and 'lunch' into a total sum of the two.
   +------------+------------+
   |      xvalue|    ptype   |
   +------------+------------+
   | 124,213,122|      home  |
   +------------+------------+
   | 223,334,552|      work  |
   +------------+------------+
   | 266,668,674|       afk  |
   +------------+------------+

If I add this
     , SUM(xvalue) xvalue
  FROM
     ( [YOUR QUERY HERE] ) x
 GROUP
    BY xtype;

Then my query returns
   | xvalue| ptype |
   +-------+-------+
   | 124   | home  |
   +-------+-------+
   | 223   | work  |
   +-------+-------+
   | 112   | afk   |
   +-------+-------+
   | 154   | afk   |
   +-------+-------+

FIXED AND UPDATED
set @year = 2020;
set @reportd = '###';
set @asofday = '2020-01-01';

select (case when y.ptype in('Work', 'Home') then y.ptype else 'Afk' end) ptype, format(sum(xvalue), 0) yvalue
from (
 select format(sum(x.value), 0) xvalue, x.ptype
    from
        ( select p.mnum, (p.bvalue + p.lvalue) as value,
        p.exeamount, p.excamount,
        p.damount, phis.ptype
        from history h
            join Dfee d
            on d.p_id = h.p_id
            and d.dcode = @reportd
                join( select max(history.id) as id,
                pc.ptype
                from history
                join cash c on history.id = c.p_id
                join pclass pc on history.pc_id = pc.id
                where c.year = @year
                and date(c.cdate) <= (select x.date
                    from (select date(cdate) date,
                    count(date(cdate)) A
                    from cash
                    where year = @year
                    group by date(cdate)
                    having A > 1
                    order by A desc
                    limit 1) x)
                    group by history.mnum ) phis.id = h.id) x
                    group by x.ptype) y
                    group by ptype;

This correctly joined and sumed the two rows into a new one.
+------------+------------+
   |      xvalue|    ptype   |
   +------------+------------+
   | 124,213,122|      home  |
   +------------+------------+
   | 223,334,552|      work  |
   +------------+------------+
   | 266,668,674|      afk   |
   +------------+------------+

Comment: Welcome to SO. Please see: [Why should I provide an MCRE for what seems to me to be a very simple SQL query?](https://meta.stackoverflow.com/questions/333952/why-should-i-provide-a-minimal-reproducible-example-for-a-very-simple-sql-query)
Comment: I believe that you want me to provide a reproductible example, but seeing as how complex this is I don't really see how I can simplify it any. I'm sorry if I have done something incorrect.
Comment: I have faith in you.
Comment: Lol. I'm glad that you have faith it me. I have cut some more from it. If I need to simplify it further please let me know. And I do appreciate your help. I want to be able to use your site correctly
Comment: Why do you list `p.exeamount *  exeamount` twice? And why qualify some columns and not others?
Comment: Also, perhaps it was an error of concision, but this bit makes no sense: `) phis.id = h.id`
Comment: I have further cut it down. ```p.exeamount``` and ```p.excamount``` are two different columns. I qualify the columns that I have to so they aren't ambiguous as many of the tables share column names.
Comment: It's good practice to qualify ALL columns, It greatly aids readability when you come to review what you wrote months later.
Comment: I agree completely. Unfortunately I didn't write this query, it was written by the person in the job before me, and it and many of the other queries that were left are very difficult to decipher.
Answer: SELECT CASE WHEN ptype NOT IN('home','work') THEN 'afk' ELSE ptype END  xtype
 -- or CASE WHEN ptype IN('home','work') THEN ptype ELSE 'afk' END  xtype
     , SUM(xvalue) xvalue
  FROM
     ( [YOUR QUERY HERE] ) x
 GROUP
    BY xtype;

Would ouput...
+-------+-----------+
| xtype | xvalue    |
+-------+-----------+
| afk   | 266668674 |
| home  | 124213122 |
| work  | 223334552 |
+-------+-----------+

If you want the formatting (bad idea), just move the formatting to this new superquery
Comment: Doing this correctly renames the two rows I want to rename, but it doesn't combine them, and it cuts down the value to just the digits before the first comma.
Comment: So for example, 1,000,000 being 1, and 121,122,000 being 121.
Comment: I didn't understand what you meant by it being a bad idea, but you were right. Removing the formatting returned the values to their correct value.
Comment: I fixed it. I was trying to group by ``` x.ptype ```. grouping instead by ``` ptype ``` correctly joined the two rows. You're a saint. I had been stuck on this for two days
Comment: Yep - that's an annoying idiosyncrasy of aliases that can sometimes occur. I wonder if I've done enough to get an upvote


Why is there different Pedaling in different editions of Chopin's op 57?

Question: In seeking the score for this piece, I came across 2 frequent editions: one that shows to use the pedal for half the bar, the other to use 2 bursts of pedal

Which pedaling is correct?
Comment: Have you checked out the [IMSLP page](https://imslp.org/wiki/Berceuse,_Op.57_(Chopin,_Frédéric)) for this piece?  It has a manuscript, first edition, and many other versions.
Comment: Which editions are these?
Answer: TL;DR
The edition shown in the second video is correct insofar as it matches Chopin's hand-written copy.

The source editions
Video #1
The edition used in the first video I am not able to identify. It's not any of the editions currently on IMSLP, and several Google searches, including image searches for different parts of the score, did not turn it up.
Video #2
This is the Peters Sämtliche Pianoforte-Werke, Band X: Berceuse, Barcarolle, etc. edited by Herrmann Scholtz, which can be found on IMSLP.
Chopin's original
There is an autograph copy, available on IMSLP, that was used for the first German edition. It clearly shows pedaling at the half-measure.

Almost every edition on IMSLP follows this autograph. The variations are the French first edition — the piece's first publication, the German came next — and editions clearly based on the French edition. These are wrong, based on the evidence of the autograph.
Why the variation
The Video #2 edition — the Scholtz — correctly follows Chopin's autograph. The Video #1 edition, however, seems to follow neither the French nor German editions. The French edition has twice-per-measure pedaling in mm. 13–14, for example; whereas, the Video #1 version maintains the first-half-of-the-measure pedaling in those measures. The departure from the autograph/German editions is obvious from the first measure.
This leaves three possibilities.

The Video #1 edition is just sloppy and poorly written, based on the French edition.

The Video #1 edition is based on the French edition, but the editor figured that the French edition's departures from first-half-of-the-measure pedaling (e.g., mm. 13–14) were errors.

The edition is an editorial performance edition, reflecting not Chopin's "urtext" (which may or may not have been available to the editor), but rather reflecting how the editor felt the piece was best performed.
Comment: @ElementsinSpace Your point is perfectly valid, but well beyond the scope of the question. The question simply asks why there are different editions, and I've covered the possibilities: mistakes or different interpretations. Whether one interpretation is more valid than another is a separate question. One worth asking, but separate, and requiring a very different, and much deeper, and potentially highly subjective, kind of analysis. I would welcome the opportunity to consider it, but it's too far beyond the scope here.
Comment: If we ignore the authority of each source, which version is "musically correct", and why?
Comment: @ElementsinSpace Are you suggesting ignoring the authority even of Chopin's hand-written copy?
Comment: "these are wrong based i'on the evidence of the autograph":the first edition could have been based on another autograph that has not survived.
Comment: Your answer so far is excellent research and certainly useful.  But manuscripts can have mistakes, and musically informed "improvements" can sometimes be made.  I don't think your answer has yet gone to *why* (musically) the pedalling change might have been made, and whether it makes the piece any "better" or "worse".  I think "Which version is 'musically correct?'" is more interesting.
Comment: @ElementsinSpace "which version is musically correct" is just a matter of opinion.  It's entirely possible that Chopin wrote the piece out more than once and applied different pedal indications in different copies.  It's also possible that the image here shows the only autograph manuscript, but even still, it's possible that the first edition was prepared with Chopin's participation and is therefore authoritative.  If the composer himself had different opinions at different times, there's not much we can do to say which is "correct."
Comment: @phoog - We can at least split by edition - e.g. versions of Bernstein's *Candide* are quite drastically different, as are versions of Liszt's Csardas Macabre. However, we can validly say which portions of Bernstein's 2nd version of *Candide* are not in his 1st, and which portions of the urtext version of Liszt's Csardas Macabre are taken out of other editions.
Comment: @Dekkadeci ok, but that's a bit excessive in this case, don't you think?  It's just a few pedal markings.
Answer: Often an editor will add his own fingering, phrasing or pedalling into a score which doesn't make it right or good.  It just is.


Are Objective-C blocks autoreleased?

Question: If I declare a block like this ^{ DoSomething; } and put it in an instance variable, do I need to Block_copy() if I'm going to keep it around?
Comment: Note .. for ARC, some example code is here: http://stackoverflow.com/a/20760583/294884
Answer: Yes, you need to copy. Not because they are autoreleased, but because they start on the stack. Note that blocks also behave like regular Objective-C objects, so that you can copy them using the regular copy message:
void storeBlockForLater: (dispatch_block_t) block
{
    [someArray addObject:[[block copy] autorelease]];
}

Or, if you have a block property:
@property(copy) dispatch_block_t block;

Retaining does not help here.
Comment: Thanks, I also found this great article on the subject: http://cocoawithlove.com/2009/10/how-blocks-are-implemented-and.html
Comment: Yup;  and if you use `copy`, use `release`.   If you you use `Block_copy()`, use `Block_release()`.  Don't mix 'em.
Comment: @openfrog: You still need to copy the block, but that's all. You don't have to – and can't – release nor autorelease it.
Comment: @bbum Is it safe to use `Block_copy()` and `autorelease`? Should you only use `autorelease` with `copy`?

Are Objective-C blocks autoreleased?


Como recarregar página web caso find_element não encontre o XPath escolhido

Question: Boa tarde!
Estou estruturando um bot de coleta de dados, mas como o site que estou fazendo a raspagem demora as vezes pra carregar ou nem carrega, o bot da erro por não encontrar o XPath.
Assim que der esse erro estou tentando fazer um loop para dar refresh na página até encontrar o XPath esperado.
segue abaixo a parte do código que estou com dificuldade caso o site não carregue o XPath
driver.get(URL)
driver.find_element(By.XPATH,"*****").send_keys(user)
driver.find_element(By.XPATH,"*****").send_keys(password)

time.sleep(5)

Tabela_mercado = driver.find_element(By.XPATH,"*****table")
Htmlcontent = tabela_mercado.get_attribute("outerHTML")
soup = Beautifulsoup(Htmlcontent, "html.parser")
Table_Dados = soup.find(name="table")
df(pd.read_html(str(Table_Dados))[0]
df.to_csv("Dados de mercado.csv", encoding="UTF-8", sep=";")

Agradeço a ajuda!

Answer: Eu recomendo você usar o WebDriverWait
Ele vai esperar o elemento pelo tempo que você passar.
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

element =WebDriverWait(driver, timeout=10).until(EC.presence_of_element_located(("COLOCA SEU XPATH AQUI")))

Agora ele vai esperar 10 segundos até o elemento aparecer, mas se mesmo assim você quiser recarregar a pagina use: driver.refresh()
OBS: Onde eu coloquei "COLOCA SEU XPATH AQUI tem que ser uma tupla tipo assim:
(By.XPATH,"//h1")


Compute likelihood of two events happening at the same millisecond

Question: I would like to write a python (or R, etc) function that computes the likelihood of two events happening at the same millisecond. The events are independent an can happen at any time of the day. My goal is to be able to say "when there are 1.000.000 events a day, the likelihood of both happening on the same millisecond is X%".
I've read a bit about the Poisson distribution and the python function random.expovariate that could be used to predict likelihood of events based on the Poisson distribution. But to my uneducated mind it is not clear whether the Poisson distribution is the right one.
Could it maybe even be as simple as the following?
<code>likelihood=(1/86400000)*(1/86400000)*number_of_events
</code>
Comment: By "likelihood" do you mean "probability" -- they are *different* things, so it's unclear what do you mean (check http://stats.stackexchange.com/questions/2641/what-is-the-difference-between-likelihood-and-probability ) ..? Is it about probability of two or 1000000 events?
Comment: A technical hint: when having such small numbers like `(1/86400000)*(1/86400000)`, you have to take care about [the machine epsilon](https://en.wikipedia.org/wiki/Machine_epsilon) (for R see http://stackoverflow.com/questions/2619543/how-do-i-obtain-the-machine-epsilon-in-r).
Answer: The phrasing of your question is a bit ambiguous, so I'm going to interpret it like this: "The expected number of events per day is 1,000,000. Given that an event has just occurred, what's the probability that the next event occurs within 1ms?"
We can consider event times to be generated by a homogeneous Poisson process. This means that they're independent, and there's a parameter $\lambda$ that gives the expected number of events per unit time. $\lambda$ itself doesn't change over time in this model (if you want it to, you'd need an inhomogeneous Poisson process).
In your example, $\lambda$ = 1e6/8.64e7 (events per ms) = (events/day)*(days/ms)
For a homogeneous Poisson process, the time between successive events (let's call it the inter-event interval) has an exponential distribution with mean $1 / \lambda$. In your example, this gives an average of 86.4ms between events.
Given that an event has just occurred at time $t_0$, we want to calculate the probability that the next event occurs at time $t_1 \le t_0 + 1$ ms. That is, the inter-event interval will be between 0 and 1ms. To do that, we can integrate the probability density function (PDF) of the inter-event interval from 0 to 1ms. This is the same as evaluating its cumulative distribution function (CDF) at 1ms. The CDF of the exponential distribution is:
$$1 - e^{-\lambda t}$$
Evaluating this at $\lambda$=1e6/8.64e7 and $t$=1ms gives a probability of ~0.0115


Why is convolve() not commutative? The end result depends on the order of the convolutions

Question: Convolution is supposed to be commutative - the order of the operations should not matter. This example therefore creates three beta PDFs and then convolves them in three different orders. Convolutions 1 and 3 result in the same end function. However, convolution 2 produces a different end function. Surely they should be the same ?
# Define beta distribution shape parameters.
s1a <- 3.52; s1b <- 65.35;
s2a <- 1.684; s2b <- 189.12;
s3a <- 5.696; s3b <- 32.34;

# Define quantiles and beta PDFs.
mQ <- matrix(data=seq(0,1,1/1000),ncol=1); # quantiles
mp1 <- matrix(dbeta(mQ,s1a,s1b),ncol=1);
mp2 <- matrix(dbeta(mQ,s2a,s2b),ncol=1);
mp3 <- matrix(dbeta(mQ,s3a,s3b),ncol=1);

# Convolution 1: mp1,mp2,mp3.
mC1 <- matrix(data=convolve(mp1,rev(mp2),type="open"),ncol=1L); # Convolve mp1, mp2 into MC1
mC1 <- matrix(data=mC1[seq(1, nrow(mC1), 2),],ncol=1L); # Halve the array to ensure consistency with quantiles.
mC1 <- 2L * mC1; # correct probailities for the halving above.
mC1 <- matrix(data=convolve(mC1,rev(mp3),type="open"),ncol=1L); # Convolve mC1, mp3
mC1 <- matrix(data=mC1[seq(1, nrow(mC1), 2),],ncol=1L);
mC1 <- 2L * mC1;

# Convolution 2: mp3,mp1,mp2.
mC2 <- matrix(data=convolve(mp3,rev(mp1),type="open"),ncol=1L); # Convolve mp3, mp2 into mC2
mC2 <- matrix(data=mC2[seq(1, nrow(mC2), 2),],ncol=1L);
mC2 <- 2L * mC2;
mC2 <- matrix(data=convolve(mC2,rev(mp2),type="open"),ncol=1L); # Convolve mC2, mp2
mC2 <- matrix(data=mC2[seq(1, nrow(mC2), 2),],ncol=1L);
mC2 <- 2L * mC2;

# Convolution 3: mp2,mp1,mp3.
mC3 <- matrix(data=convolve(mp2,rev(mp1),type="open"),ncol=1L); #Convolve mp2, mp1 into mC3
mC3 <- matrix(data=mC3[seq(1, nrow(mC3), 2),],ncol=1L);
mC3 <- 2L * mC3;
mC3 <- matrix(data=convolve(mC3,rev(mp3),type="open"),ncol=1L); # Convolve mC3, mp3
mC3 <- matrix(data=mC3[seq(1, nrow(mC3), 2),],ncol=1L);
mC3 <- 2L * mC3

# Plot them up.
maxP <- max(mC1,mC2,mC3);
plot(x=mQ,y=mC1,type="l",col="blue",lwd=2,ylim=c(0,maxP));
lines(x=mQ,y=mC2,col="black",lwd=2);
lines(x=mQ,y=mC3,col="red",lwd=2)

Answer: The way your code is set up, the "convolve and subsample" operator is non-commutative for vectors of different lengths.
cc <- function(x,y) convolve(x, rev(y), type="open")
cch <- function(x,y) cc(x,y)[seq(1,length(x),by=2)]*2

(It looks like you may be coming from Matlab; R is sloppy about treating vectors as row/column vectors as appropriate, so you can skip all of the stuff that converts results back into matrices ...)
set.seed(101); x <- rnorm(20); y <- rnorm(40)
all.equal(cc(x,y), cc(y,x))   ## TRUE
all.equal(cch(x,y),cch(y,x))  ## lengths differ

The result of cch(x,y) is longer than z, so we have a convolution of unequal-length vectors and the resulting operator no longer commutes.
Comment: Thanks Ben, much appreciated!


É possível implementar métodos a null ou undefined?

Question: Se eu quisesse implementar uma verificação de variável sempre que eu fosse utilizar o método .indexOf() do javascript isso seria possível?
Por exemplo usando a.indexOf(b); é possivel detectar quando o a é null ou undefined e alterar o método para retornar -1?
Comment: Podes explicar melhor como queres usar? queres modificar o `indexOf()`? dá um exemplo, pf
Comment: Por exemplo `a.indexOf(b);` queres tratar se o `a` f^r `null` ou o `b` fôr `null` ? e que resultado dar caso `b`seja `null`?  `-1`?
Comment: Sim. Quero modificá-lo. Para sempre que for usar ele já tratar se é nulo ou undefined e seguir o codigo sem dar erro.
Comment: No caso somente tratar se "a" é null ou undefined. E o resultado seria -1 caso fosse.
Answer: Não é possível estender o null ou uma variavel que seja undefined. Ou seja se tiveres:
a.indexOf(b);

no caso de o a ser null ou undefined isso vai dar erro.
Soluções?!
Uma variante é usares try{}catch(e){} dessa maneira crias uma zona segura onde podes correr código sem que pare a execução por causa de erros.
var result;
try{
    result = a.indexOf(b);
} catch(){
    result = -1;
}

Outra opção é criares uma função para fazer isso.
function indexOf(str, el){
    if (!str && str != 0) return -1;
    return str.indexOf(el);
}
var result = indexOf(a, b);


Counterexample to Convergent Sequence Proposition

Question: The proposition is:

If $\lim S_n = L$ and for every $n$, $S_n$ is in the interval $[a,b]$, then $L$ is also in $[a,b]$.

I have proved this effectively, but now the question is to provide a counterexample to the stronger assumption, for the interval $(a,b)$.
Basically, where this proposition does not guarantee that $L$ is also in $(a,b)$.
Comment: By the way, welcome to MSE.   I see that you haven't accepted any of the answers you got on   this site. Please do so, since otherwise - the questions remain unanswered.
Answer: Hint:
Think about the sequence ${1\over n}$. Can you figure out the interval for the counter example?
Comment: That is the one I have kept using, but (0,1) works doesn't it?
Comment: OHHHH, because it is no longer an equality, it no longer works!  Is that right?
Comment: @DavidHouse what about (0,10)?
Comment: Yes, it doesn't work anymore. Take $1/n$ from $n=2$, for example. Or as @Learner suggested, just use $(0,10)$ and then you can start from $n=1$...
Comment: if the interval is (0,2) wouldn't that be fine as well.  n∈N so as long as the interval doesn't include 1 I should be ok, right?
Comment: @DavidHouse yeah thats fine!
Comment: Yep, that's fine.
Answer: What about $1/(n+1)$ in $(0,1)$?


Preciso de ajuda para retornar dados

Question: Olá, sou bastante novo na área e estou fazendo um pequeno projeto.
Quero retornar todos as parcelas de um aluno com um loop for mas ele retorna apenas o último item do array, alguém pode me ajudar?
ParcelaController
  public function store(ParcelaRequest $request)
{
    $request->validated();
    $data = new Carbon($request->data_vencimento);

    $valor = $request->valor_curso / $request->qtd_parcelas;
    for ($i = 0; $i <= $request->qtd_parcelas; $i++) {

        $parcelas = [
            'aluno_id'        => $request->aluno_id,
            'matricula_id' => $request->matricula_id,
            'num_parcela'     => $i,
            'valor_parcela'   => $valor,
            'data_vencimento'=> $data->addMonths(1),
        ];

    }
    return response()->json([
         $parcelas
    ], 200);
}

retorno da api
Answer: O problema é que a cada iteração do loop você está sobrescrevendo o valor da variável $parcelas.
Fiz algumas alterações no seu código:
public function store(ParcelaRequest $request)
{
    $request->validated();
    $data = new Carbon($request->data_vencimento);

    $valor = $request->valor_curso / $request->qtd_parcelas;
    $parcelas = [];
    for ($i = 0; $i <= $request->qtd_parcelas; $i++) {

        $parcelas[] = [
            'aluno_id'        => $request->aluno_id,
            'matricula_id' => $request->matricula_id,
            'num_parcela'     => $i,
            'valor_parcela'   => $valor,
            'data_vencimento'=> $data->addMonths(1),
        ];

        /*
        $parcelas = [
            'aluno_id'        => $request->aluno_id,
            'matricula_id' => $request->matricula_id,
            'num_parcela'     => $i,
            'valor_parcela'   => $valor,
            'data_vencimento'=> $data->addMonths(1),
        ];
        */
    }
    return response()->json($parcelas, 200);

    /*
    return response()->json([
         $parcelas
    ], 200);*/
}

Ao colocar os colchetes após a variável você está dizendo ao PHP: essa variável é um array, adicione o valor que está à esquerda do sinal de = ao final do array.
Assim, a cada iteração do loop, você terá os valores adicionados ao array $parcelas.
Comment: muito obrigado! consegui fazer funcionar
Comment: Se a resposta te ajudou, selecione ela como aceita para que outros possam saber que sua questão foi resolvida.

Preciso de ajuda para retornar dados


Why I can't print 0 with %7.d or other %x.d in C

Question: Can someone help me in printing 0 with %x.d i.e. %1.d, %2.d, %3.d, etc.
Actually if I'm printing 0 with %7.d and it is not showing on terminal. You can visit My GitHub for more reference.
#include <stdio.h>

int main() {
    int num_1 = 0;
    int num_2 = 10000;
    int num_3 = 999;

    printf("Value of \'num_1\' is = %7.d\n", num_1);
    printf("Value of \'num_2\' is = %7.d\n", num_2);
    printf("Value of \'num_3\' is = %7.d\n", num_3);
    return 0;
}

Comment: I think the issue is that 0 doesn't need *any* digits to represent, so when you use `%7.d`, which is equivalent to `%7.0d`, you don't get any digits of *precision*.  What you get is 7 spaces.  If you wrap the format in some visible delimeters, e.g. `<%7.d>`, you can see that it is *not* empty, it's just blank.  If you change it to `%7.1d` it will force at least one digit, which will make zero appear as `0` rather than blank.  You'll still get 7 characters total.
Comment: @PraneethKumar With the `i` and `d` conversion specifiers, when both the value and the precision are 0, as in your example, the conversion results in no characters. The padding is still there, that's the `7` part.
Comment: Try `%7d` instead of `%7.d`  The `.` indicates that the "precision" is to *follow*, i.e. the number of digits of precision.  Since the precision value is missing, it is taken to be zero.
Comment: @TomKarzes but tom but taking the 7 value into consideration. it should have at least printed 6 spaces followed by a 0. can you explain more on this. why it's missed for 0 but for others it worked fine.
Comment: @Aman Why `%7.d` instead of `%7d`? What are you hoping for with that `.`?
Comment: Welcome to SO. For future question please remember to include your output together with expected output. Your statement "it is not showing on terminal" is not really useful. It could mean a line with 7 spaces or nothing at all which are very different things. Therefore please try to be precise and add all relevant information.
Answer: The printf conversion specifier %7.d, equivalent to %7.0d, will convert an argument of type int to its decimal representation with at least 0 digits and pad it with initial spaces up to at least 7 characters.
As a special case, converting the argument value 0, yields no digits and the output will be seven spaces.
You probably do not want these semantics as you expect 0 to produce       0, so you should not specify a precision field with a .. Use %7d instead.
Note also that the \ in front of ' is not required in a C string, but it is in the C character constant '\''
Here is a modified version:
#include <stdio.h>

int main() {
    int num_1 = 0;
    int num_2 = 10000;
    int num_3 = 999;

    printf("Value of 'num_1' is = %7d\n", num_1);
    printf("Value of 'num_2' is = %7d\n", num_2);
    printf("Value of 'num_3' is = %7d\n", num_3);
    return 0;
}

Output:
Value of 'num_1' is =       0
Value of 'num_2' is =   10000
Value of 'num_3' is =     999


combinatorics problem: two ways to solve same problem?

Question: Currently i'm struggling alot with combinatorics.
The problem: There are four siblings. What is the probability that at least two of them are born in the same month?
This question asks to get two equal solutions using two ways.

differ between siblings and count the variations how you can distribute the months on the 4 siblings
don't differ between siblings and count the 4-element-combinations out of the 12-month-"alphabet"

I already understand that the first way is using ordered sampling and the second way is unordered sampling.
I came up with two solutions using $n=12$ and $k=4$
*First solution**:
separating the individuals
since it is a "at least" - problem i want to subtract the cases in which there are no repetitions.
$ P_{1} = 1 - \frac{\frac{{n}!}{(n-k)!}}{n^k} \approx 0.43$
Second solution:
$P_2 = 1 - \frac{ {n \choose 4}}{{n + k -1 \choose k}} \approx 0.64$
${n \choose k}$: combinations i can choose of the 12 months without repetitions.
${n+k-1 \choose k}$: combinations i can choose of the months with repetitions.
so with these solutions i don't differ between the siblings. i just count the k-combinations with repetitions (all possible combinations) and the one without repetitions (the combination i want to substract).
Source: https://www.probabilitycourse.com/chapter2/2_1_4_unordered_with_replacement.php
here i take all the combinations with repetitions and subtract the the combinations without repetitions (n choose k).
Is any of these the correct solution? Why do they get different answers?
I know that the difference is that solution one is working with ordered and solution 2 with unordered sampling. But in my understanding it should still be the same since i only take relations (by division).
Answer: The probability that at least two of them are born in the same month is equal to $1 -$ the probability that they are all four born in different months, and that's the probability that we will calculate (your first solution.)
The first one can be born in any month.  The probability that the second one is born in a different month is $11/12$.  Given this has occurred, the probability that the third one is born in a different month than either of the first two is $10/12$, and, similarly, the probability that the fourth is born in a different month than any of the first three is $9/12$.
Multiplying through and subtracting from one gives $0.427$, your first solution.
If you work through the algebra by expanding the choose functions into their component factorials and canceling where you can, you will, not surprisingly, see that they are not in fact the same.  This is, I strongly suspect, because you have misunderstood what "unordered sampling with replacement" in the link refers to.  In unordered sampling, the sample $(1,2,3,4)$ is considered the same as $(4,2,1,3)$, and similarly for other arrangements.  Thus, all the combinations with months $(1,2,3,4)$ taken together count a total of once in terms of what $n+k-1 \choose k$ evaluates to.  However, when you subtract $n \choose 4$ from that, you are subtracting the number of ordered samples without replacement.  You should be able to see that subtracting the number of ordered samples w/o replacement from the number of unordered samples with replacement may be a curiosity, but is unlikely to be useful, and certainly not for your application.
Comment: thanks alot for the answer. i edited the post to make i more clear (hope it worked).
Answer: (1) Focus on siblings. Probability all different: First sibling chooses any of the 12 months, second chooses a different month with probability $11/12,$ third chooses non-repeated month with probability $10/12,$ similarly, probability id $9/12$ for the fourth. So $12(11)(10)(9)/12^4 = 0.5729167.$
Probability of at least one repeat: $1 - P(\text{All different})=0.4270833.$
Using R as a calculator:
prod(12:9)/12^4
[1] 0.5729167
1- prod(12:9)/12^4
[1] 0.4270833

(2) Focus on months. Probability all months different:  Choose 4 different months in ${12 \choose 4}$
different ways. These can be arranged in $4!$ ways. Total ordered ways of choosing $4$ months without restriction is $12^4.$ So
$P(\text{All different}) = \frac{4!{12 \choose 4}}{12^4}= 0.5729167,$ as in part (1).
factorial(4)*choose(12,4)/12^4
[1] 0.5729167

$P(\text{At least one repeat}) = 1 - 0.5729167 = 0.4270833.$
(3) Approximation by simulation. In R, the code
mos = sample(1:12, 4, rep=T) selects four months at random from among 12 (with replacement). We do this a million times. For each sample of four months,
code length(unique(mos)) finds the number $X$ of uniquely different months. Thus, the following simulation which approximates
$P(\text{At least one repeat}) \approx 0.427 \pm 0.001.$
set.seed(407)
x = replicate( 10^6, length(unique(sample(1:12,4,rep=T))) )
table(x)/10^6
x
        1        2        3        4
 0.000591 0.044351 0.382570 0.572488
 mean(x < 4)
[1] 0.427512             # aprx P(At least one repeat) = 0.42708
2*sd(x < 4)/sqrt(10^6)
[1] 0.0009894357         # aprx 95% margin of simulation error
mean(x);  2*sd(x)/sqrt(10^6)
[1] 3.526955
[1] 0.001168797

The vector x < 4 is a 'logical' vector with a million elements TRUE or FALSE; its mean is its proportion of TRUE's.
The average number of
different birth months is $E(X) \approx 3.527 \pm 0.001.$
The exact probability that all four siblings are born in the same month is $1/12^3
= 0.0005787037,$ approximated here as $0.000591$ (again accurate to about three decimal places).

Here is a histogram of the number of the simulated proportions of the numbers of different birth months. The red circle shows the exact value, obtained above by
combinatorial methods.
Comment: thank alot. Can you give me hint why my second solution is not working?
it is just the version for unordered sampling. how do i know in this case i need to use the ordered one?
Comment: Sorry. don't understand what you're doing there. I used ordered samples in (2). It was easier for me to use $12^4$ in denom, and then numerator has to be ordered also.
Comment: ok. it's hard to express. i meant unordered. sorry for the confusion. i think it should also be possible to derive the solution using the ordered sampling equations. i got this from https://www.probabilitycourse.com/chapter2/2_1_4_unordered_with_replacement.php


Linear transformations that send basis vectors to the same images

Question: In my book it says as a passing remark to finish off a problem: "...two linear transformations that send basis vectors to the same images must be equal...".
I'm wondering if this is a definition or some result that would have a proof. If the latter, can someone provide a sketch of the proof?
Answer: Assume $\{v_1,\dots,v_n\}$ is a basis. If $T(v_i)=0$ for all $i$ then $T=0.$ Why? For any $v\in V$ there exist $a_1,\dots, a_n$ such that $v=a_1v_1+\dots+a_nv_n.$ Then
$$Tv=T(a_1v_1+\dots+a_nv_n)=a_1Tv_1+\dots+a_nTv_n=0.$$
Now assume that $R(v_i)=S(v_i)$ for any $i.$ Consider $T=R-S.$ What can you conclude?
Comment: Let me disagree. The statement is $T(v_i)=0$ and the thesis is $T=0.$
Comment: don't you mean " If $T(v_i)=0$ for *all* i then $T=0$"?
Comment: Also nowhere have you made assumptions that lead to $v$ being in the kernel. This answer doesn't even make sense.
Comment: @WilsonBrians Yes, I mean for all. Who has assumed $v$ is in the kernel? I have shown it must be in the kernel if $T(v_i)=0$ for all $i.$
Comment: you should write "*Assume* $T(v_i) = 0$ for all $i$. Not "if".
Comment: @WilsonBrians What's the problem with the sentence "If ... then ..."?
Comment: it's just confusing here because the "if" statement corresponds to your conclusion that $T = 0$.


linux tool for real time file replication between servers

Question: I have a web application. It is database and file driven (database is postgresql, users upload and create files)... I would like to balance the load between two+ servers, and that means not only database replication (which I can achieve with tools like Slony), but also real-time file replication.
The file replication is necessary because a user could log in in a first server, log out,
then log in in the other server (because of the balancing), and his files should be there.
I don't really need to duplicte the whole drive, just a group of folders.
Also because if one server fails, I would like to have the other one with a full set of all data & files.
Is there any tool available on linux that automates reliable file replication, like the way Slony does for databases ?
Is DRBD a recommended solution ?
Comment: Would mounting a network drive (NFS share) work for you? If not, why not?
Comment: maybe... i´m looking for the simplest of solutions, yet scalable and efficient : )
Answer: We use Gluster for this, it works like a charm.
Answer: What is needed is a bidirectional filesystem (or folders) syncing. Search for Unison or DirSync Pro and give them a try


What is wrong with this python program? (Traceback error)

Question: my question is why isn't my program working in python 3, It appears to be triggered in the "Speed=dist/time section. Your help would be appreciated.
If you could also correct it would be very helpful.
Illegal=[]
Legal=[]
Count = 0
DIST = 0
TIME = 0
SPEED = 0

def CalSpeed():
    global SPEED
    SPEED=DIST/TIME
    return SPEED

print (" Welcome to the Speed check calculator by Awiar Nasseri")
print ("\n")

Count=int(input("How many registration numbers are there?: "))
LIMIT=int(input ("Speed limit (M/S): "))
VAR=int(input ("How many (M/S) should be allowed over the limit?: "))
LIMIT=LIMIT+VAR

while Count > 0:
    Count=Count-1
    REG = input ("Enter Registration number: ")
    TIME =int (input("Enter the time that the vehicle was in the zone in seconds (e.g. 1min= 60)"))
    DIST = input ("Distance inside the zone (M): ")
    SPEED=(DIST/TIME)

    if SPEED>LIMIT:
      Illegal.append(REG)

    elif SPEED<LIMIT:
        Legal.append(REG)

print ("Press P to print illegal and legal cars or press nothing to exit: ")
if option=="P":
    print (Legal[0])
    print (Illegal[0])
print("Thank you for using the program, Goodbye")
sys.exit(0)

Here is the error:
Traceback (most recent call last):
  File "\\bhs-students\1515787\Desktop\assess.py", line 26, in <module>
    SPEED=(DIST/TIME)
TypeError: unsupported operand type(s) for /: 'str' and 'int'

Comment: `DIST` is a string, convert it to an int/float as well.
Comment: post error in question not comments
Comment: Can  you provide the  error returned by the execution of this program ?
Comment: Please provide the error you receive. Closing as unclear until then.
Comment: Traceback (most recent call last):
  File "\\bhs-students\1515787\Desktop\assess.py", line 26, in
    SPEED=(DIST/TIME)
TypeError: unsupported operand type(s) for /: 'str' and 'int'
Comment: just corrected it harwee, thanks
Answer: Change line no 26 to
DIST = int(input ("Distance inside the zone (M): "))
SPEED=(DIST/float(TIME))

Answer: You are not converting the DIST variable to an Int, meaning that if fails as it can't divide a string by an int.
Answer: Just as the error is indicating, you cannot divide a string by an int. You need to convert your input to a numeric type
DIST = float(input("Distance inside the zone (M): "))


To delete the last character with regex

Question: regex.Pattern = "(.*?),$"

Examle Text:

Lorem ipsum,lorem,ipsum,lorem,

I want (True)

Lorem ipsum,lorem,ipsum,lorem

the last character , (comma) to be deleted
I'm using Classic ASP.
kelime = "Lorem ipsum,lorem,ipsum,lorem,"
Dim regex
Set regex = New RegExp
regex.IgnoreCase = True
regex.Pattern = "(.*?),$"
Set colMatches = regex.Execute(kelime)
If colMatches.Count > 0 Then
    strTitle = colMatches(0).Value
    'strTitle.Remove(strTitle.Length - 1)
Else
    strTitle = ""
End If
response.write strTitle

Comment: regex.Pattern = "(.*?)," negative. because result : Lorem ipsum,
Answer: kelime=left(kelime,len(kelime)-1)
Comment: why especially longtext
Comment: strTitle.Remove(strTitle.Length - 1) bunu regex içinde mi kullanmam gerekiyor huseyin. in regex did not work
Comment: This looks more like ASP.NET than Classic ASP.
Comment: longtext field does not work. varchar worked. But I have to use my longtext
Comment: because there are areas in more than 500 characters.

To delete the last character with regex


SU(2,$\Bbb C$) homeomorphic to $S^3$

Question: Good day,
I understand how to show that for a $M= $$
        \begin{pmatrix}
        a & b \\
        c & d \\
        \end{pmatrix}
$$ \in$ SU(2,$\Bbb C$), $M=$$
        \begin{pmatrix}
        a & b \\
        -\bar b & \bar a \\
        \end{pmatrix}
$ and that $|a|^2+|b|^2=1$. However, I don't understand why the set $A=\{ (a,b) \in \Bbb C^2 | |a|^2+|b|^2=1 \}$ is homeomorphic to the set $(a,b)\in S^3 $; since $\Bbb C^n$ maps bijectively to $\Bbb R^{2n}$, shouldn't $A$ be homeomorphic to $(a,b) \in S^4$ instead?
Best wishes
Answer: The convention is that $S^n$ is the sphere in $\mathbb{R}^{n+1}$. (With dimension $n$) Here you work in $\mathbb{R}^4$ so the sphere you're interested in is $S^3$.

SU(2,$\Bbb C$) homeomorphic to $S^3$


Printing a multidimensional array (board game)

Question: Im trying to print a board game called snake and ladders. I only managed to print the first simple column.
var multiArray=[[" ___","|   |", "|   |","|___|"],
                ["|   |","|   |", "|___|","|   |"],
               ["| E |", "|___|","|   |","|   |"],
               ["|___|","|   |","|   |","|___|"],
               ["|   |","|   |","|___|","|   |"],
                ["| P |","|___|","|   |","|   |"],
                ["|___|"]];

for(var i=0; i<multiArray.length;i++){
    for(var j=0; j<multiArray[i].length;j++){
        print(multiArray[i][j]);
    }
}

Execution:
 ___
|   |
|   |
|___|
|   |
|   |
|___|
|   |
| E |
|___|
|   |
|   |
|___|
|   |
|   |
|___|
|   |
|   |
|___|
|   |
| P |
|___|
|   |
|   |
|___|

How can i do it so that the same column gets printed 7 more times beside it to look like this:
 ___ ___
|   |   |
|   |   |
|___|___|
|   |   |
|   |   |
|___|___|
|   |   |
| E |   |
|___|___|
|   |   |
|   |   |
|___|___|
|   |   |
|   |   |
|___|___|
|   |   |
|   |   |
|___|___|
|   |   |
| P |   |
|___|___|
|   |   |
|   |   |
|___|___|

I tried using .concat but it just adds it to the bottom of the other column. .join and .push is also not working unless im not using it correctly.
Comment: Where are these strings displayed? If it's a browser, you could use html and CSS to define the column layout and add each column's text individually. If you're printing to a console, you have to print by rows.
Comment: im using a school website called codeboot.org
Answer: One way I can think of is this
var multiArray =
[
    [" ____",   "|   |",    "|   |",    "|___|"],
    ["|   |",   "|   |",    "|___|",    "|   |"],
    ["| E |",   "|___|",    "|   |",    "|   |"],
    ["|___|",   "|   |",    "|   |",    "|___|"],
    ["|   |",   "|   |",    "|___|",    "|   |"],
    ["| P |",   "|___|",    "|   |",    "|   |"],
    ["|___|"]
];

for (var i = 0; i < multiArray.length; i++) {
    for(var j = 0; j < multiArray[i].length; j++){
        // storing the second column. first col = second col
        var secondColumn    = multiArray[i][j];
        // checking if the column has E or P in it
        if (secondColumn.match(/(E|P)/)) {
            // if it does, change the column to empty one
            secondColumn = "|   |";
        }
        // print the same column twice (without E or P)
        console.log(multiArray[i][j] + secondColumn);
    }
}

Since you want to print the same column twice but without the letter E or P, a simple regexp will solve the problem.
If you want to use this in a html page, not in console or 'codeboot.org', you will have problems with your columns. You can't use multiple spaces in a string. HTML page will parse it as a single space. You need to change your spaces with  .   means a single space. You can use that multiple times.
You can see the space problem here: fiddle.
EDIT: You said you want to print it 7 times. The code below will do.
for (var i = 0; i < multiArray.length; i++) {
    for(var j = 0; j < multiArray[i].length; j++){
        var col = multiArray[i][j];
        if (col.match(/(E|P)/)) {
            col = "|   |";
        }
        console.log(multiArray[i][j] + col + col + col + col + col + col);
    }
}

I don't know what E or P stands for, so the rest of the columns are empty.
EDIT2:
If you want to add to or remove from the columns with the current code, that's gonna be troubling. Addressing to the desired column would be hard since the columns are not organized. I give you an alternative way.

var container = document.getElementById("container");
var rows = 7;
var cols = 8;

for (var i = 0; i < rows; i++) {
    container.innerHTML += '

';
    var curRow = container.getElementsByClassName("row")[i];
    for (var j = 0; j < cols; j++){
        curRow.innerHTML += '

';
    }
}

function addPlayer(p ,r, c) {
    var row = container.getElementsByClassName("row")[r-1];
    var col = row.getElementsByClassName("col")[c-1];
    col.innerHTML = p;
}

function clearColumn(r, c) {
    var row = container.getElementsByClassName("row")[r-1];
    var col = row.getElementsByClassName("col")[c-1];
    col.innerHTML = "";
}

// try passing player name, row number and column number
// in the given order
addPlayer("E", 3, 4);
addPlayer("P", 5, 2);

// you can also clear a specified column
// enter row number and column number
// clearColumn(5,2);

You should create your own html page and work with HTML/CSS if you want to improve this. An online interpreter won't help much.
You can see the live demo here: fiddle.
Comment: yes i would like to print the next 7 columns but there are different letters in them. lets say that Player 1 is on the first row column 3. then i would have to xenter p1 at that location.
Comment: @user3268216 Updated my answer. It should solve your problems.
Answer: Perhaps it would be easier to print out the board by row rather than by column.  This way, you're using the problem of only being able to print below as the solution by intentionally printing each row under the previous row.
This would require a redefinition of your multiarray, but the first row could look something like this:
var upperBound  = '  _______________________'
var side        =  '|  |  |  |  |  |  |  |  | '
var bottomBound =  '|__|__|__|__|__|__|__|__|'
console.log(upperBound, '\n', side, '\n', bottomBound)

Then you could repeat that 7 more times (without the upperBound), and get your board!
console.log(upperBound, '\n', side, '\n', bottomBound)
for(var i = 0; i < 7; i++){
    console.log(side, '\n', bottomBound)
}

Hope that helps!
Comment: Well, sort of, but it would be the same in the case of printing columns.  To enter something in the box, you could just remove one of the spaces.
Comment: wouldnt everything be changed if i would to enter something into the boxes?as in the rows or columns will not fit