Again about McGee objections to modus ponens

Question: I would like to "reopen" the previous post regarding Modus ponens because, frankly speaking, I'm not satisfied with some (most of ?) answers by the mathematicians community.
Disclaim: I'm not aiming to "unravel the mystery", but I'm not convincd either that mathematicians and philosophers speaks completely different languages.
This is my argument, in two steps : a "mental experiment" followed by some considerations about formalization and natural language.

The experiment I'm trying is based on a reformulation of McGee's first example (see Vann McGee, A Counterexample to Modus Ponens (1985)), regarding the US presidential election of 1980.
I'll neglect the aspects regarding "belief" and the nuances connected to verbal tense (see the paper of Robert Fogelin & W.Sinnott-Armstrong, A defense of Modus Ponens (1986)), also because I'm not a native english speaker.
I assume as domain of the problem a non-empty universe (call it $US$) where there are only two mutually exclusive subsets : $rep$ and $dem$ (so that : $rep \cap dem = \emptyset$).
I assume that the set $rep$ has only two elements $R$ and $A$ (i.e. $rep = \{ R, A \}$, and $A \ne R$).
I assume only one "obvious" axioms, translating the "rule of the game", using a single predicate $win$ :

$win(dem) \lor win(rep)$.

The first consideration - we will discuss it later - is that the above condition is really a "XOR": "a republican will win or a democrat will win, but not both".
We have also :

$\lnot win(rep) \equiv win(dem)$.

So we have the "tirvial" :

$\lnot win(rep) \lor win(rep)$.

But due to the fact that the only republican candidates are $R$ and $A$, the last amount to :

$\lnot win(rep) \lor [win(R) \lor win(A)]$ --- (A).

Note : we are not using $\rightarrow$ in this argument; if we would use it, with the classical truth-functional semantics, the sub-formula between the square brackets would amount to : $\lnot win(R) \rightarrow win(A)$.
I introduce now what I'll call Shoenfield rule (from Joseph Shoenfield, Mathematical Logic (1967), page 28 :

if $\vdash A$ and $\vdash \lnot A \lor B$, then $\vdash B$.

The above rule is proved in Shoenfield's system using three of the four "propositional" primitive rules [page 21 : the last one, the Associative Rule, is not used in the proof below] :

Expansion Rule : infer $B \lor A$ from $A$
Contraction Rule : infer $A$ from $A \lor A$
Cut Rule : infer $B \lor C$ from $A \lor B$ and $\lnot A \lor C$.

With the Cut Rule and the (only) propositional axiom : $\lnot A \lor A$, we can derive the Lemma 1 : if $\vdash A \lor B$, then $\vdash B \lor A$.
Now we prove Shoenfield rule :
(1) --- $\vdash A$
(2) --- $\vdash B \lor A$ --- from (1) by Expansion
(3) --- $\vdash A \lor B$ --- from (2) by Lemma 1
(4) --- $\vdash \lnot A \lor B$
(5) --- $\vdash B \lor B$ --- from (3) and (4) by Cut
(6) --- $\vdash B$ --- from (5) by Contraction.
Disclaim: nothing new; all is trivial (classical) propositional logic.
Now, we go back to (A) :

$\lnot win(rep) \lor (win(R) \lor win(A))$

and add the premise :

$win(rep)$;

by Shoenfield rule we conclude the "obvious" :

$win(R) \lor win(A)$.

Nothing has gone wrong ... We only has used standard rules for propositional connectives in a classical framework, with the use of $\lor$ in a situation where the alternative are mutually exclusive.

Question : Is the previous argument "sound" ?

The above argument, assuming it is "sound" suggests to me some considerations about formalization and natural language.
The "regimentation" that symbolic logic - from Frege on - has deliberately imposed on natural language has been greatly fruitful; this does not imply that the richness of natural language can be wholly "explained away" with formalization.
The dissatisfaction of McGee about the modus ponens seems to me the "old" dissatisfactions about the translation of "if ... then" in term of the truth-functional connective $\rightarrow$.
This one is blind about the nuances of natural language (that relevant logic try to recover). In the same way, when I use $\lor$ in a context where the alternatives are mutually exclusive, I "loose" some presuppositions (some implicit information that the speaker aware of the context knows).
This does not means that the rule of logic are "wrong"; neither that philosopher does not know logic. Aristotle and Leibniz and Peirce and Frege and Russell were all philosophers.

In conclusion, I think that there is no "contradiction" between the way mathematical logic formalize truth-functional connectives and natural language.
Comment: Your first derivation is sound. On the assumption that a republican (i.e. one of $R$, $A$) wins, you correctly derive that $R$ wins or $A$ wins. - For the rest I scrolled through the linke McGee question and could not understand the problem. If I accept (a) and (b) I personally am unable to not accept (c).
Comment: where does *(4)* --- $\lnot A \lor B$  come from?
Comment: @Willemien From assumption.
Comment: @frabala which assumption?, also why the tag philosphy (not philosophy)
Comment: @Willemien At that part, he tries to prove that *if $\vdash A$ and $\vdash\neg A\vee B$, then $\vdash B$*. So, formulas $A$ and $\neg A\vee B$ are given by assumption.
Comment: @frabala - thanks ! you are right. What I've called *Shoenfield rule* is of course good old *modus ponens* in disguise ... My attempt is to avoid the implicit "presuppositions" of "if ..., then" using a "less controversial" connective like "or".
Answer: The Schoenfield rule is equivalent to the classical two valued definition of the material conditional. This is perfectly adequate for classical two-valued logic.
People live in a realm of uncertainty, and experience leads them to intuitive ideas about valid reasoning in an environment of uncertainty. Natural language reflects that experience. However, natural language and intuition are often inconsistent and unsatisfactory.  Doubts about whether the the material conditional is adequate or whether modus ponens is always a valid rule of inference in a context of uncertainty continue to resurface.  Putting conditions on a problem that allow it to be restricted to a classical two valued solution does little to resolve such doubts.
There are partial successes with systems that reject one or other of the conclusions of classical logic, but the cirumlocution required means that the systems are highly technical and the essential ideas are buried in formal systems and symbolism which are not easy to work with, interpret, or even discuss intelligibly. The fact that the problems are perceived to be difficult has led to the development of ever more complex formal systems.
My experience and experimentation with going back to early work in the subject, such that of Lukasiewicz, Kleene, C.I. Lewis, and Heyting  and rethinking it with better tools for examining mathematical structure than they had, has led me to conclude that skepticism about the excluded middle, the adequacy of the material conditional, and the problems with modus ponens are both closely related and justified in the wider world of uncertainty, however well they work in classical two-valued logic.  If the conditional "if P then Q" or the implication it may express may be doubtful,  (does Q really follow from P?), there is little reason to expect conclusions using modus ponens to be valid.
Answer: TLDR version: in the earlier thread, Nate Eldredge and Mathieu Vidal had it basically right. In this thread, Confutus's obervation about people "living in a realm of uncertainty," as opposed to the realm of mathematics, is quite on point.
Long, read-if-you-like version.
Logic  deals with two kinds of truths, namely necessary and contingent. And it does two kinds of things with those truths: on the one hand it talks about what must be the case, if something else is the case; and on the other hand it talks about what a person should ideally accept, given that s/he asserts or accepts something else.
When it comes to the necessary truths of mathematics, we know from Goedel that there exist truths that can't be proven. Nonetheless, there's no difference between determining the truth of something and judging its assertibility. In this context, the material conditional treatment of "if…then" (translating "If A, then B" as "Either B or else not-A") works just fine, and McGee's modus ponens counterexample doesn't get any traction.
But philosophers (and linguists) also deal with contingent truths and statements about them. Here things get messy, because a gap opens up between what seems to be true (on our best understanding of how truth works) and what people are prepared to accept or affirm. Material implication starts to fail as a model of "if…then," because (to boil McGee's example down a bit) one might be quite prepared to say,  "Either Reagan or Anderson will win," since Reagan is way ahead in the polls and a Reagan win will make the statement true; and at the same time one would be reluctant to say, "If Reagan doesn't win, Anderson will," because almost surely if Reagan loses it will be to Carter.
There are two obvious ways to deal with this problem. One can say that contingent if…then statements don't have truthvalues at all, just assertibility conditions. Ernest Adams is the best-known proponent of that view. Or one can say that for if…then statements, the truth conditions are those of the material conditional but assertibility conditions are another thing. Frank Jackson is the leading exponent of this approach. There are many other maneuvers to be tried, but those are the two obvious ones.
Either way, one then ends up with the question whether assertibility relationships among statements, including conditional statements, can be codified--and if so, how. If we try this, we end up with something one could call a logic of assertibility. If you like, you can balk at calling this logic, but it has the structure of a set of symbols, and a set of rules for how to form statements, and a set of entailment relations, so it's certainly logic-like.
So then McGee should be understood to be pointing out that in a logic of assertibility, Modus Ponens is valid only with restrictions. He doesn't actually talk about a logic of assertibility, but his focus is on the realm of asserting, accepting, and so forth. He writes: "How do we account for this discrepancy [between standard logic and the given examples]? The simplest diagnosis is …. that we have noticed that, when we accept a conditional and accept its antecedent, we are prone to accept the consequent, as well. We have supposed that this pattern held universally.... However, [etc.]" (p. 468).
Two footnotes:
McGee is actually taking the position that not only doesn't the material conditional entail the plain-English "if...then" (lots of people would agree with him on that) but that English "if…then" doesn't entail the material conditional, either. That is an unusual view, but he makes an interesting case.
McGee discusses a rule known as import-export, according to which "If A, then if B, then C" is equivalent to "If A and B, then C." He offers a proof that if you accept unrestricted modus ponens AND import-export, you have to accept that the material conditional is the right model of English if...then. His Reagan/Anderson example and the other examples are offered to motivate the choice of rejecting unrestricted modus ponens and keeping import-export.


Configuracão .htacess - Página de Erro dinamica

Question: Gostaria de saber se é possivel gerar uma pagina de erro dinamica a partir de  parametros passados para uma pagina html e pegar esses parametros atraves de um codigo javascript? Ou de qualquer outra forma que não precise criar uma pagina para cada erro.
Exemplo:
ErrorDocument 400 /error.html?400
ErrorDocument 401 /error.html?401
ErrorDocument 403 /error.html?403
ErrorDocument 404 /error.html?404
ErrorDocument 500 /error.html?500

Comment: tenta se isso resolve
Options -Indexes, ai voce só precisa ter uma maneira de pegar com javascript e fazer a malandragem...

ErrorDocument 403 /pasta/403.html?id=403
ErrorDocument 404 /pasta/404.html?id=404
Answer: Isso é bem simples, pode fazer da seguinte forma:

ErrorDocument 403 /403.php
RewriteRule ^403.php$ erros.php?tipo=403 [L,QSA]

ErrorDocument 404 /404.php
RewriteRule ^404.php$ erros.php?tipo=404 [L,QSA]

ErrorDocument 500 /500.php
RewriteRule ^500.php$ erros.php?tipo=500 [L,QSA]

E por aí vai..
Os arquivos 404.php , 500.php , etc não precisam existir fisicamente. O .htaccess vai tratar eles de forma automática e redirecionar como você quer.
No arquivo erros.php (por exemplo), você trata o tipo de erro com $_GET['tipo'] e emite a mensagem pretendida.
Este artigo explica um pouco mais sobre como trabalhar com as paginas de erro no servidor.


Disproving Convergence of certain sequences in $\mathbb{R}^{\omega}$

Question: Let $\mathbb{R}^{\omega}$ be the countable product of $\mathbb{R}$. Make it a topological space using the box topology. Let $\pi_{n}$ denote the usual projection maps. Show that the sequence:
$ \{ x_{n} \in \mathbb{R}^\omega$ | $\pi_{k}(x_n) = 1/n$ if $k \leq n, \pi_{k}(x_n)=0$ if $k>n \}_{n\in \mathbb{Z}_+}$
does not converged to $(0,0,\ldots)$.
I noticed that this sequence is contained in the union $\cup_{N \in \mathbb{Z}_+}A_{N}$, where $A_N = \{x \in \mathbb{R}^\omega \mid \forall k>n: \pi_{k}(x) = 0\}$. In addition, I know that a given sequence $\{x_n \mid n \in \mathbb{Z}_+\}$ such that each $x_n$ is in $X$, $\{x_n\}$ converges to x if for any open set $U \subset X$ containing $x$ there is an $N \in \mathbb{Z}_+$ such that $x_n \in U$ whenever $n>N$.I feel that the fact this sequence is contained $A_N$ will be the most important facet to solving this problem; however I can't seem to utilize it.
Answer: No, this problem is much more closely related to the problem in this earlier question; it can be solved in exactly the same way.
Comment: What's throwing me off is the $k>n$. If $k>n$, isn't the projection function mapping nothing to 0?
Comment: @KangHoonYou: No; it just says, for instance, that $$x_4=\left\langle 1,\frac12,\frac13,\frac14,0,0,0,0,\ldots\right\rangle\;.$$
Comment: Consider this neighborhood:

$\{(-1,0) \cup (0,1) \times (-1/n, 1/n) \} \forall n \in \mathbb{Z}_+$

This neighborhood does not contain any elements in the sequence, correct?
Comment: @KangHoonYou: That's not a nbhd of the zero point: the first factor excludes it. Just use $\prod_n\left(-\frac1n,\frac1n\right)$, exactly as in the other question.
Comment: But since 0 is part of the sequence now, doesn't the exact solution not apply?
Comment: @KangHoonYou: I don't understand the question, I'm afraid; the first four terms of the sequence are $x_1=\langle 1,0,0,0,\ldots\rangle$, $x_2=\left\langle 1,\frac12,0,0,0,\ldots\right\rangle$, $x_3=\left\langle 1,\frac12,\frac13,0,0,0,\ldots\right\rangle$, and the $x_4$ of my earlier comment. The zero function in $\Bbb R^\omega$ is not part of the sequence.
Comment: Thank you for your help @Brian I really understand these concepts now.
Comment: @KangHoonYou: You're welcome.


How does the song feature work on the Casio CTK keyboards?

Question: I know the Casio CTK keyboards have 100 songs built in. I have seen several videos on Youtube showing how one can use this to learn the songs. For example, one selects a song and then the keyboard will play parts of the song and wait for you to repeat.
My question is: Is it possible to just listen to the songs? So without it stopping or trying to teach you. I know this is possible on the Casio SA 76 keyboard (but it only has 10 songs).
I looked in the manual and can see that one can start playing the demo songs (by pressing two buttons). What happens if one just selects a song and press just the play button?
Specifically I am interested in the models 2400 and 3200.
Comment: @ToddWilcox: According to http://music.stackexchange.com/help/on-topic one can ask about how to use specific hardware.
Comment: If you are lucky, someone who owns the keyboard you are interested in will weigh in either with a comment or answer.  If not, you might need to dig around on line a little more (Casio website maybe?) or see if they sell those at an on line music store like Sweetwater, Guitar Center, or Zzounds where you can actually speak to a salesman and ask questions about any of the products or instruments they sell.  Good luck.
Comment: FWIW - "hardware" as used in the help topic you referenced is most likely intended to refer to computer hardware used for recording as it appears in the context of software & hardware which would indicate computer.  But I suppose an electronic keyboard such as you described might fit a loose definition of "hardware".  A computer keyboard would certainly fit the definition as would a keyboard controller used in a recording studio.  So your argument has merit despite the fact that your usage falls outside recording studio applications. Hopefully someone will provide the information you seek.
Answer: In this respect the CTK boards are exactly the same as the SA 76, except they have a lot more songs to choose from (as you noticed).
So the answer to your question is: Yes.  You can just play them if you want to.


how can I reduce my code? A lot of it is repetitive

Question: The code creates a random addition problem and spits out "Congratulations" if correct and "sorry...." if the inputted value is wrong. The while loop repeats this process until the user inserts "N" for the question "continue (Y/N):, at the same time it keeps track of how many questions have been answered, and which ones are correct. The code works fine, my problem is it has repetitive code. I was wondering if there is a way to shrink it.
**I appreciate everyone one's help and advice. I"m a noob that's just learning python  **
import random

correct=0
count=1
num1=random.randint(0,100)
num2=random.randint(0,100)
print(format(num1,'4d'))
print('+',num2)
answer=int(input('='))
sum=num1+num2

if answer==sum:
    print('Congraulations!')
    correct+=1
else:
    print('Sorry the correct answer is',sum)
c=input('Continue (Y/N):')

while c == "Y":

    count+=1
    num1=random.randint(0,100)
    num2=random.randint(0,100)
    print(format(num1,'4d'))
    print('+',num2)
    answer=int(input('='))
    sum=num1+num2
    if answer==sum:
        print('Congraulations!')
        correct+=1
    else:
        print('Sorry the correct answer is',sum)
    c=input('Continue (Y/N):')

else:
    print('Your final score is',correct,'/',count)

Comment: Write the repetitive parts into functions.
Comment: can you provide an example please?
Comment: I recommend going through an interactive tutorial of Python first to get familiar with all the basic constructs. This seemed to explain your case in detail: [tutorial](https://www.learnpython.org/en/Functions)
Comment: I would advise against using a variable with the name sum, as it shadows the [built-in function](https://docs.python.org/3/library/functions.html?highlight=sum#sum) with the same name.
Comment: ok thanks for the suggestion
Answer: By initializing the variable c as "Y", the condition is met and the loop can be executed:
import random
correct=0
count=1
c = "Y"
while c == "Y":
    count+=1
    num1=random.randint(0,100)
    num2=random.randint(0,100)
    print(format(num1,'4d'))
    print('+',num2)
    answer=int(input('='))
    sum=num1+num2
    if answer==sum:
        print('Congraulations!')
        correct+=1
    else:
        print('Sorry the correct answer is',sum)
    c=input('Continue (Y/N):')
    c = c.upper()

else:
    print('Your final score is',correct,'/',count)

I also added the method upper() to the Y/N input so the user can also type it in lowercase
Answer: Try to move as much of the processing as possible into the loop.  The first "paragraph" of your code was basically a duplicate of the main-loop.  By creating the continuation variable c so that it drops straight into the loop, most of that first block could be removed.
import random

correct=0
count=0
c = 'Y'

while c == "Y":

    count+=1
    num1=random.randint(0,100)
    num2=random.randint(0,100)
    print(format(num1,'4d'))
    print('+',num2)
    answer=int(input('='))
    sum=num1+num2
    if answer==sum:
        print('Congratulations!')
        correct+=1
    else:
        print('Sorry the correct answer is',sum)
    c=input('Continue (Y/N):')

else:
    print('Your final score is',correct,'/',count)

The two formula printing statements can also be reduced to a single one:
    print(format(num1,'4d'))
    print('+',num2)

could be
    print( format(num1,'4d') + '+', num2 )

The variable sum could be removed, but it does make the code self-documenting, which is a good thing.
Answer: A first start, would be eliminating the code before the while, by initializing the count variable (which keeps track of the turns), in zero, and allowing the while loop to run the first turn, we just need to have a variable like want_to_play and by default it's True, so the first time we'll be playing, and at the end of the game If I don't input Y or y it will asume I don't want to play any more and set the variable to false, that way I can have all the turns ran by the while loop.
and you'll be getting something like this.:
from random import sample

correct = 0
count = 0           # STartint in turn zero
want_to_play = True # Control Variable

while want_to_play:
    count += 1
    # First turn this is zero, and adds one.

    [num1, num2] = sample(range(0, 101), 2)
    # Just another way of getting two random numbers from 1 up to (including) 100.
    # Printing could be done in one line.
    print(format(num1, '5d') + '\n+' + format(num2, '4d'))
    answer = int(input('= '))
    # The comparison really doesn't really hurt if you do it this way.
    if answer == num1 + num2:
        print('Congraulations!')
        correct += 1
    else:
        print('Sorry the correct answer is', sum)

    # HERE you ask if you want to play again or not, using a one line if
    # you decide.
    want_to_play = (True if 'y' == input('Continue (Y/N).lower():')
                         else False)
else:
    print('Your final score is',correct,'/',count)


Show that $f(z) =\log z$ is analytic everywhere in the complex plane

Question:
Show that $f(z) =\log z$ is analytic everywhere in the complex plane
  except at the origin. Find its derivative.

I tried solving it using Cauchy Riemann equation. But for that, $f(z)$ needs to be separated as $f(z)=u+iv$. I am not able to split $\log z =u+iv$. Please help.
$z=x+iy$
Comment: @Soumee Yes, the question is wrong. It is a well-known fact that there is no antiderivative of $g(z)=1/z$ on $\mathbb{C}\setminus\{0\}$, because the integral over a circle around $0$ is nonzero. An antiderivative exists on the plane without a ray from the origin. How is $\log z$ defined in the book where you got the question from?
Comment: It is not even defined on the complex plane (origin removed).
Comment: Please tells what $\log z$ is.
Comment: @egreg So, is the question wrong?
Answer: That's simply not true. You can't even define a continuous logarithm function in $\mathbb{C}\setminus\{0\}$. To define logarithm you need to choose a branch of argument. For example we can choose $arg(z)$ to be in $[-\pi,\pi)$, in that case we define logarithm in $\mathbb{C}\setminus(-\infty,0]$. Then logarithm is a function, let's call it $L(z)$. It is really analytic. Take a point $z_0$ in the domain. We can write $w=L(z),w_0=L(z_0)$. Then:
$\lim_{z\to z_0}\frac{L(z)-L(z_0)}{z-z_0}=\lim_{w\to w_0}\frac{w-w_0}{e^w-e^{w_0}}=\frac{1}{e^{w_0}}=\frac{1}{z_0}$
I just used the fact that the derivative of $e^w$ at the point $w_0$ is $e^{w_0}$.
Comment: I think there's a minus sign missing before that $\;\infty\;$ symbol in the third line.
Comment: Yes, of course. Fixed it.


Cb/B problem while creating lead sheet

Question: I'm making a lead sheet of the song "One" by Esperanza Spalding.
I chose the key of Bb because the song feels the most "at home" when the progression lands there at the guitar solo after the 3rd chorus. You could alternatively say it's in Db, which is the first chord of the verse each time. I'd like to hear which one people think it is.
Whichever you choose, the problem of Cb arises (chord bII in Bb or bVII in Db) during the guitar solo. I imagine players would rather just see "B" on the lead sheet, but I'll be expanding this lead sheet to a full arrangement afterwards, and I don't want to deal with the resulting accidentals when I'm writing the full charts.
So it occurred to me that I could just rewrite the whole thing in A#(or C#). But three double-sharps doesn't sound fun.
I don't think writing "Cb" on a lead sheet (especially this one) is so terrible but I'd like to hear what other people think before I commit to it.
Comment: If anything - and I mean anything, Gm sounds like a place it goes to more naturally.
Comment: Without playing along to the track, it's not easy to pinpoint a key, as to me, it modulates a lot. In fact, I'd be writing it out note by note, and seeing where it went later in the process - bit like movie music.
Answer: Well, if the key is Bb major, then Cb should be bII in that key, pretty much no matter what its purpose is. Unless there's some modulation or weird temporary tonicization going on, Cb is correct - there should be only one "B" note in a key, and Bb already fills that spot. Some guitar players may gripe about it, but it's better form to write it correctly as Cb. If the key were E major, you'd obviously write it as F, not E#, so here in Bb, write it as Cb.
Of course, nothing's stopping you from leaving some editorial note that Cb = B somewhere obvious in the lead sheet. If you do that, you can likely preempt any whining!
No matter which option you pick, Cb or B, you're going to get some dissatisfied customers. I personally would choose to write correctly and give beginners the chance to grow their theory knowledge rather than make things more obvious but annoy the more advanced musicians, but you might have reason to decide one way or another depending on specific circumstances.
Also, I would strongly advise against a rewrite in A# for the same reasons you identified yourself. A# major is a nasty key (with 10 sharps in it); don't use that unless you have to.
Comment: After reading Aaron's answer, I'm thinking Db is the more correct choice of key. The B/Cb problem remains the same regardless. I'm starting to think "Cb = B" might be a somewhat elegant solution, at the risk of pissing off some players who think they're above being told same... (not that I care)
Comment: My answer is assuming the key of Bb, because regardless of whether OP is truly correct about the key of the song, it's still a good question as to which enharmonic spelling one would use in the key of Bb.
Answer: The whole song is very chromatic but to me the vocal sections are in three separate keys, the opening verse is Bb (for a few seconds at least), the choruses are in G and the refrains are in Db. The term "refrain" is somewhat antiquated but I use it to distinguish these sections from the opening verse. The guitar solo harmony is based on the verse, starting in Bb but really all over the map.
There are a few approaches you can take, one is to insert key changes at the beginnings of all the sections. The other is to just go with an open key signature and use accidentals where necessary (pretty much everywhere). If you really want to use just one key go with Bb, it starts there and is a simple key to remember and play in (not that you'll be there long!) I wouldn't concern myself too much with writing Cb, skilled readers have no problem with it. Once you hit that Dbm7 (C#m7) in the 5th bar of the verse and guitar solo it really doesn't have much to do with Bb anymore (2-5 to B, 2-5 to E then Em, etc.) so B would also be acceptable in my book. Definitely avoid extreme sharp keys for the whole song though (A#! and C# aren't necessary in this case and you might get some dirty looks, lol). The whole song is SO chromatic that maybe the open key signature might be the way to go.
Comment: No key signature is indeed a common choice in realbooks.
Comment: @Tim it may depend on a realbook. Some examples I was able too google quickly: https://d29ci68ykuu27r.cloudfront.net/items/19424772/cover_images/cover-large_file.png https://atuneadayblogdotcom.files.wordpress.com/2013/08/sweet1.jpg
Comment: @user1079505 - checking through my real books - there's plenty of key sigs - except those in key C...
Comment: @Tim: Sure, most songs use key signatures, no-one's disputing that.  But for very chromatic songs like this one, it's quite common to *not* use a key signature as well.  (That said, I think this song could reasonably be written in Gm throughout.)
Comment: @PLL - which was my thought, but no-one else seems to concur.
Answer: The linked recording is in Db major. This is made clearest at the very final chord in which the bass plays Db and the voice lands on F.
It's important to consider, however, that vocal arrangements are typically pitched for the vocalist. So, if the arrangement is for a particular singer, the best option would be to find out what key best fits that singer's range and transpose the piece to match, Cbs or no.
Alternatively, if the arrangement is intended for more general use, consider just writing it in C or D major and avoiding the issue altogether. Since it sounds like guitar players are of particular concern, they might appreciate playing in C or D, which tend to lie better on the instrument, than Db.
Comment: Yeah, in Db it should be Cb as well, because relative keys.
Comment: @Aaron I agree about the key, after listening to it the whole way through again. I guess it modulates to Bb for the solo. I appreciate the thinking behind transposing to C or D, but I want to stay in the original key if possible (if for no other reason than a challenge). I would like to hear your opinion on whether to use Cb or B, though.
Comment: @yerman Cb for sure.
Comment: @yerman Context would be critical in that case; why is it that an Em/Fbm chord appears in this song? What's going on that can explain the strange chord? You may wish to ask a separate question with more details, but if you can find out what the Em/Fbm V-to-i chord sequence is doing there in the song, you will be well on your way to determining its proper spelling.
Comment: I should have persevered through to the end...  although songs such as this could very well modulate through several keys on their way to that end.
Comment: Okay I have a bit of a dilemma, because I'm realising that the following chord is E minor, and it stays in Em for a little bit afterwards. If the Cb/B chord is like a V of Em, then in this particular context might it make more sense to write B7 - Em than Cb7 - Fbm (which is a bit ugly)?
Comment: @yerman Agreed. B makes more sense in an Em context. Especially in a lead sheet, that would be standard practice.
Answer: A more important factor, for me if I was orching this, is that the tessitura seems quite high. So it may cut down on the number of vocalists who would be happy in that written key. I'd consider dropping it a tone or so, thus leaving it in a 'more friendly' - for vox and readers - key.
That said, it doesn't answer the question - but provides some solution.
If a key has to contain such as C♭, or E♯, so be it. This sort of music isn't for beginners, or the faint-hearted, so anyone playing it will understand that certain keys have 'odd-named' notes, and will cope accordingly. Also bear in mind that if there are transposing instruments to be written for, their written keys may produce other, similar problems.
Comment: I'm not saying you should - I'm saying what option I may give myself! But if one resorts to using a transpose button (I hate them, not you!), then writing in a more friendly-to-writer's key makes even more sense - to me.
Comment: I don't see why I should have to avoid the original key, to be honest. If a vocalist needs it shifted, I can hit the big red transpose button (don't h8 me) and fix any problems that causes. But for chord symbols, I want to make them as easy to read as possible.
Comment: I think that point about transposition is secondary to the nature of the question. Not an invalid argument by any means, but the last paragraph is where the answer to the underlying question lies.
Comment: @user45266 - hence the middle para? Sometimes we don't see the wood for the trees. Just an option I threw out...
Comment: Yeah, and I see why the middle line is there. Just pointing it out so people don't immediately jump on the "This should be a comment, not an answer" train.
Comment: Appreciate that. But if someone is so small-minded they react before reading it all, I'm stuffed. Maybe swap the paras round..?
Comment: A reordering may be in order (heh heh)!
Answer: Using alterations like Cb could be confusing for beginners or musicians used to simple harmonies.
Considering the artist and the fact that the song is far from being a "simple pop tune" with the usual 3/4 diatonic chords, I sincerely doubt that any musician interested in playing it would have any problem about that.
Answer: Music transcriptions intended for sight-reading should follow different conventions from those intended for analysis or as the basis for further transcriptions.  A transcription intended to be sight-read should be marked in whatever way will maximize the likelihood of the performer playing the desired notes, without regard for whether the markings make "musical sense".  Generally, markings that make musical sense will be more likely to yield a correct performance than those that don't, but given a choice between markings that would make sense if analyzed but are likely to be initially misunderstood, or markings that will be performed correctly but violate music theory conventions, the latter should often be preferred in editions intended to facilitate sight reading.
Answer: A ♭II chord is what it is.  You write it with a C♭ (in this case), or you are going to confuse experienced musicians very badly.
I can process a C♭ chord in a B♭ key, because it fits the key.  If you suddenly throw in a B chord, I'm going to be thinking "okay. . . we're modulating to-- F#?  E, maybe?"  And if you don't modulate, I throw the score in the garbage and walk away.
Comment: bII instead of bii I reckon. As in the comments above, I determined that B was more useful in this case than Cb since the following chord is Em (B is V of Em).
Comment: Yes, you're right, bII is the chord you wanted, that's my mistake.  If you are in fact modulating to Em, then use B, *except for a special case* if you've already gone through the same progression before without modulating, then sometimes when you change things up, you'll see both chords tied, so C♭M^BM, especially over a key signature change.  That tells the player "Hey, this is the same thing you've already done. . . but this time we're modulating, so get ready for it."

Cb/B problem while creating lead sheet


Gradle - Change the name of the jar

Question: I would like to change the name of the jar when I do a
./gradlew clean assemble

The name of my jar is my-awsome-app-0.0.1-SNAPSHOT.jar and I want to generate my-awsome-app.jar.
I tested to do this in the build.gradle:
configurations {
   jar.archiveName = "my-awsome-app.${jar.extension}"
}

...but this is not working, the name is still the same
Comment: This is what I have done and that is not working
Comment: Look at the link I posted, there's multiple answers in the post.
Comment: Sorry about the closing, I didn't notice the [spring-boot] tag before.
Answer: Since you are using Spring Boot, you should use the bootJar task instead (notice bootJar extends Jar).
Since archiveName in Jar has been deprecated, use archiveFileName:
bootJar {
   archiveFileName = 'my-awesome-app.jar'
}

Comment: Perfect solution when you need build version for the Jenkins pipeline and artifact but not the JAR name

Gradle - Change the name of the jar


THREE.js Model position Issue

Question: I am trying the following code:
var loader = new THREE.JSONLoader();
var onGeometry = function(geom) {
var tooth = new THREE.Mesh( geom, new THREE.MeshFaceMaterial());
tooth.position.set(xpos,ypos,0);
teeth.push(tooth);
scene.add(tooth);
xpos+=10;
};
loader.load('js/JsonModels/teeth1.js', onGeometry);
loader.load('js/JsonModels/tooth2.js', onGeometry);
loader.load('js/JsonModels/teeth1.js', onGeometry);
loader.load('js/JsonModels/tooth2.js', onGeometry);
loader.load('js/JsonModels/teeth1.js', onGeometry);
loader.load('js/JsonModels/tooth2.js', onGeometry);

The models does not appear on screen in the order in which I load them which in my case is necessary since I am positioning objects depending on the order in which I load them. Same was the issue when I used OBJLoader and used its callback to add the objects in to scene and store them in array.
So, how can I achieve this, How can I display multiple object on the screen positions that I can specify.
Any Suggestion?
Answer: Create a callback factory for which you can pass the desired position and have it saved in a closure:
function getGeomHandler(posx) {
  return function(geom) {
    var tooth = new THREE.Mesh(geom, new THREE.MeshFaceMaterial());
    tooth.position.set(posx, posy, 0);
    teeth.push(tooth);
    scene.add(tooth);
  };
}
var posx = 123;
var loader = new THREE.JSONLoader();
loader.load('js/JsonModels/teeth1.js', getGeomHandler(posx)); posx += 10;
loader.load('js/JsonModels/tooth2.js', getGeomHandler(posx)); posx += 10;
loader.load('js/JsonModels/teeth1.js', getGeomHandler(posx)); posx += 10;
loader.load('js/JsonModels/tooth2.js', getGeomHandler(posx)); posx += 10;
loader.load('js/JsonModels/teeth1.js', getGeomHandler(posx)); posx += 10;
loader.load('js/JsonModels/tooth2.js', getGeomHandler(posx)); posx += 10;

Comment: @BartekKosa: Presumably from somewhere outside the code snippet. xpos/ypos where not defined in the original question's example.
Comment: tnx a lot for the quick response. Let me try it. :)
Comment: Where does "posy" come from in "tooth.position.set(posx, posy, 0)"?

THREE.js Model position Issue


Clear method Glide Android

Question: I have a question about Glide's clear method. Docs says:
Cancel any pending loads Glide may have for the view and free any resources that may have been loaded for the view.
Which resources it is referring to? Deletes image from disk and cache? or clear the reference to imageView?
Answer: The resource here is referring to any loaded bitmap data or drawables which was supposed to be loaded inside the view.
Comment: So it returns ImageView to its default state?
Comment: Presumably, yes.

Clear method Glide Android


Nonnormal distributions for a monte carlo simulation in Excel

Question: My empirical (price-spread) time series data has a nonnormal distribution (see below) and it has no (partial)-autocorrelation. I am worrying about which distribution fits most to my data, but I think there is not a known distribution I could use. Please correct me here if I am wrong. Actually the huge amount of Zero Spreads is worrying me most.
My idea was to create some sort of a empirical distrubtion function based on the (2 years) sample and use the distribution for randomness in a monte carlo simulation.

Does my approach makes sense?

Can I do it via Excel or do I need advanced statistical software like R? Because ultimately, I want to derive random price spreads which I can use to conduct a monte carlo in Excel. I already prepared everything around in Excel, but the missing part is a correct distrubution. Currently I am using a triangular distribution.
Answer: I initially thought your data might exhibit zero-inflation, but when you look a little more closely, you note that the two bars right next to the high one at zero are also higher than the ones farther out. It looks like the peak at zero is not a peak of strict zeros, but part of a very narrow normal distribution. (Or one with yet additional zero inflation.)
Your data looks really like a mixture: the hump on the right looks nicely normal, you probably have a narrower normal distribution around zero, and then something asymmetric on the left side, with a rather long tail - a flipped gamma might be a possibility to model this, though the tail does look rather long.
In R, you might be able to use the mixtools package, though I don't know whether it can deal with a flipped gamma. Alternatively, you might need to set up your own likelihood function to optimize. Using the empirical distribution in Excel sounds like a possible approach with less work. I don't know of any packages or functionalities implementing mixture distributions in Excel.
Then again, I am a little skeptical that there really is no temporal dynamics in your data. Have you looked at ARCH/GARCH models? Especially for financial series, the dynamics often don't happen so much in the time series itself, but in the variance.
Comment: 1) The price distribition around 0 (in -1 cent steps) is shown here: https://s12.directupload.net/images/200729/wxnkqil6.png I think it does not look normal right? 2) Regarding the Temporal Dynamics: No I haven't looked into ARCH/GARCH models. Is there a simple way to test for ARCH? 3) Regarding mixture distribution: Sounds indeed very interesting, but I think it's quite challenging to use Excel to do it. I need to first understand the concept.
Comment: Ah. This does look like a peak by itself. So it might be useful to model a point mass at zero for one of the mixture components. This is indeed zero inflation (which is a specific kind of mixture, namely one with a point mass at zero), but since the rest of your distribution is a mixture all by itself, it makes the most sense to model all of your data as a three-component mixture. For ARCH/GARCH, there are packages in R - again, I don't know about Excel (but googling might turn something up).


ASP EF codefirst first query

Question: This issue has been opened several times before, but has not been resolved. The first query is recognized as slow and the performance of the queries increases significantly later. The project I'm working on is a multi-user Project. It's not possible to tell users to use it that way. I'm having serious problems with this. What can be done to speed up the initial query?
Comment: https://stackoverflow.com/questions/30423838/entity-framework-very-slow-to-load-for-first-time-after-every-compilation/30424382#30424382 and https://www.fusonic.net/developers/2014/07/09/3-steps-for-fast-entity-framework-6-1-code-first-startup-performance/
Answer: You can improve performance setting publish config to "Precompile during publishing".
It's is a simple way to get a faster initial request.

What happens, however, is that in the first database request, Entity Framework starts the model and it takes additional time, you can avoid this by making some query in the start-up of application. more here
It's maybe a problem with the application pool configuration in IIS, you can set to keep always on, and avoid the slow after a few minutes, more here.
Answer: I have done what @fsbflavio has suggested along with the App pool stuff and my first query is still always slow. Every query after the first query is fine.
I know this should not be my answer but until I find a better solution the following has worked for me.
My answer was to create a powershell script and to create a scheduled task to call it. For my situation, our servers are restarted nightly. So, I only need to schedule this to run upon restart and all queries work the rest of the day. Users of our web app no longer have to wait 10+ seconds for the first query.
<code>Invoke-WebRequest -Uri "https://MY_URL/api/WakeUp" -Headers  @{"accept"="text/plain"; "apiKey"="MY_API_KEY"}
</code>
Comment: I 've edited my answer, see the link about the first query in startup application, it's a workaround option too.
Comment: @fsbflavio - Thanks. I am working on a new application right now. I will add that to the Application_Start and see what happens. Much easier than the powershell script. To be honest, I haven't had to think about this for quite some time now because the powershell script just works but I would much prefer a code solution.

ASP EF codefirst first query


Dynamic table columns with PHP

Question: I want to make a table with 2 dynamic columns using one MySQL query. I was able to make the first row of columns but the second row is just blank. Any ideas? Here is my current code:
<?php
$query_dates ="SELECT uploadedby, count(item) as item, date_format(uploaddate, '%m-%d-%y') as date FROM `imsexport` WHERE uploadedby='Gerry Dellosa' and uploaddate between '2012-12-25' and '2013-01-15' GROUP BY date ORDER BY uploaddate ASC";
$result = mysql_query($query_dates,$prepress) or die(mysql_error());
$row_dates = mysql_fetch_assoc($result);
?>

    NAME
<?php do{?>
    <?php echo $row_dates['date']?>
<?php } while ($row_dates = mysql_fetch_assoc($result)); ?>

//This is the second row set of dynamic columns
   <?php do{?>
    <?php echo $row_dates['date']?>
   <?php } while ($row_dates = mysql_fetch_assoc($result)); ?>

Comment: After the first do while loop you have iterated over the entire result set so the second so while loop contains nothing.
Comment: Are you sure you want 2 equal columns? or you just want to show your data in 2 columns?
Comment: @YourCommonSense: sorry that was a typo. second set of columns are actually for $row_dates['item'];
Answer: <?php
$query_dates ="SELECT uploadedby, count(item) as item, date_format(uploaddate, '%m-%d-%y') as date FROM `imsexport` WHERE uploadedby='Gerry Dellosa' and uploaddate between '2012-12-25' and '2013-01-15' GROUP BY date ORDER BY uploaddate ASC";
$result = mysql_query($query_dates,$prepress) or die(mysql_error());
while($row_dates = mysql_fetch_assoc($result)) {
    $record[] = $row_dates;
}
?>

    NAME
<?php foreach($record as $rec ) { ?>
    <?php echo $rec['date'] ?>
<?php } ?>

//This is the second row set of dynamic columns
   <?php foreach($record as $rec ) { ?>
    <?php echo $rec['date'] ?>
   <?php } ?>

Comment: Worked great, thanks. Now what if there is no WHERE uploadedby='Gerry Dellosa' condition and I want uploadedby to echo vertically under the Name column while retaining the horizontal data values for each of the uploadedby values.
Comment: set the foreach for the line, not column, like ` ..name date.. .. foreach( .. ) { ..$rec[name] $rec[date].. }`
Answer: reset fetch loop before second row
mysql_data_seek($result,0);

Dynamic table columns with PHP


grep each line from a file recursively

Question: I have an alphabetically sorted file names.txt containing names:
Dio Brando
Erina Pendleton
Jonathan Joestar
Mario Zeppeli
....

and a folder containing files:
a1.txt
a2.txt
....
zn.txt

each having lines with Name: phone number. Assuming recursion goes though files alphabetically, I'd like to grep each line from names.txt and switch to the next name whenever it fails to find a match in the next one.
For example: I grep for "Dio Brando" and it reaches in file, say, D2.txt following lines:
Dio Brando: phone number 1
Dio Brando: phone number 2
Dio Brando: phone number 3
<not Dio Brando>: phone number 1

When I hit the <not Dio Brando> line, I want it to start searching for "Erina Pendleton" where it left off (from D2.txt onward). It's guarantied to find at least one match, and when it fails after that, it should switch to "Jonathan Joestar" etc. Is it possible without some serious scripting?
If resuming with the next name is not doable, just performing grep on each line through the whole folder will do.
Comment: The fallback strategy, `grep -r pattern ...` is listed here: https://stackoverflow.com/a/1987928/667820.

What you want to do can be done with some advanced `awk` programming, where you feed `awk` with a list of files, and use the names as variable patterns.  But that would be serious scripting.
Answer: It sounds like this might be all you need:
awk '
BEGIN { nameNr = 1 }
NR==FNR {
    names[NR] = $0
    next
}
{
    if ( index($0,names[nameNr]) ) {
        print FILENAME, FNR, $0
        found = 1
    }
    else if ( found ) {
        nameNr++
        found = 0
    }
}
' *.txt

but since you didn't provide sample input/output we could test with that's just an untested guess.

grep each line from a file recursively


How to solve $\tan^2x + \tan^2{2x} + \cot^2{3x} =1$

Question: How to solve $\tan^2x + \tan^2{2x} + \cot^2{3x} =1$?
I've tried to use some formulas and I've written that
but it didn't make much easier. The derivative is  ugly too.
 Mayby there is a simple way?
Comment: There do not seem to be any real solutions
Comment: I know there is not any solution, so how to prove that?
Comment: Do we have to differentiate? Or just prove LHS = RHS
Comment: You can add where the problem is from (try to be detailed, if it is possible add links to the book or pdf)
Answer: Let $u = \tan(x)$.
Using the equation you found, we can write:
$u^2 + \frac{4u^2}{(1-u^2)^2} + \frac{(1-3u^2)^2}{(3u - u^3)^2} = 1$
Simplifying, we get:
$u^{12} - 9 u^{10} + 43 u^8 - 94 u^6 + 91 u^4 - 17 u^2 + 1 = 0$
Finding the Sturm chain of the above polynomial, we see that there is no change in sign, thus implying that there are no real roots to the above equation.
Comment: Ok, so is it only that method?
Comment: @piteer Perhaps there is a simpler method, but I could only come up with this!


jQuery - How to select by attribute

Question: I have a HTML like this,
Link1
Link2
Link3
<input id="b_1" type="submit" disabled_onclick="true">Button1</input>
<input id="b_2" type="submit">Button2</input>
<input id="b_3" type="submit">Button3</input>

Now I need write a jQuery which returns me all the attributes in my html having a disabled_onclick property set to true. In this case, I should get 3 elements, two link tags and one input tag.
Comment: possible duplicate of [jQuery attribute selectors: How to query for an attribute with a custom namespace](http://stackoverflow.com/questions/91518/jquery-attribute-selectors-how-to-query-for-an-attribute-with-a-custom-namespac)
Comment: why are you closing  ?????
Comment: i guessed but still commented to bring in notice..
Comment: @dku.rajkumar: You could have edited given your reputation :)
Answer: Here's how to select all those elements:
$('[disabled_onclick="true"]');

Since true is a valid unquoted attribute value in CSS, you could even omit the quotes:
$('[disabled_onclick=true]');

If you care about valid HTML you should consider using a custom data-* attribute instead though.
<input id="b_1" type="submit" disabled_onclick="true">

<input id="b_1" type="submit" data-disabled-onclick="true">

That way it's valid HTML, and you'll still be able to select it as follows:
$('[data-disabled-onclick="true"]');

Answer: try this
$('[disabled_onclick="true"]')

Answer: $('input[disabled_onclick="true"]');

See http://api.jquery.com/attribute-equals-selector/
In the above line, you'd only query for input nodes, you can omit the input which would then query over all nodes in your entire markup (which is probably kind of slow'ish).
$('[disabled_onclick="true"]');

Comment: I don think it will return  tag too.
Comment: this selects only `input` tags and not `a` tags
Comment: @jAndy: I commented before you edited your answer, anyways, I'll take -1 back since your current answer is correct
Comment: @dku.rajkumar: yes, exactly. You figured it out correctly. You win.
Comment: @jAndy now what do you say.. i think you should not take it.. our intention was not to pin point you, just to make correction.
Comment: Was gonna upvote, but after reading the comments, decided not to... :(

jQuery - How to select by attribute


Showing a Process is a Martingale with Sum of I.I.D.

Question: I am proving the follow:
Let $V_1,V_2....$ be independent $N(0,1)$ random variables.  Let $S_n=V_1+...V_n$ and $X_n=e^{S_n - n/2}$.  Let $F_{n}^{V}$ be the sigma algebra generated by $V_1,...,V_n.$  Prove that $X_n,F_{n}^{V}$ is a martingale.
The process trivially satisfies that $X_n$  is $F_n$ measurable for all $n \in \mathbb{N}$ and $X_n \in L_1.$  It just remains to show that $X_s=E(X_n|F_s)$ for all $s \le n$.
I think I have an idea but I'm stuck on some of the details.  We have $E(X_n|F_s)=E(e^{S_n - n/2}|F_s).$  I think we can split this expression, but I'm not sure if I'm splitting it correctly.  $E(e^{S_n - n/2}|F_s)=e^{S_{n-1}-n/2}E(e^{V_n}|F_s).$
Given that the r.v. are independent we have,  $e^{S_{n-1}-n/2}E(e^{V_n}|F_s)=e^{S_{n-1}-n/2}E(e^{V_n}).$  Since $V_n$ is N(0,1) we can show that $E(e^{V_n})=e^{1/2}.$  Then together we have $e^{S_{n-1}-n/2}E(e^{V_n})=e^{S_{n-1}-n/2}e^{1/2})=e^{S_{n-1}-(n-1)/2}=X_{n-1}$.
Is this a correct line of reasoning?
Answer: Your calculations are right for the case $s=n-1$. Only this case you can take out $e^{S_{n-1}-n/2}$ from the conditional expectation. For general $s<n$ you can repeat just the same:
$$
E\left(X_n\mid F_s\right)=E\left(e^{S_n - n/2}\mid F_s\right)=E\left(\frac{e^{S_n - n/2}}{e^{S_s-s/2}}\times \underbrace{e^{S_s-s/2}}_{X_s}\biggm| F_s\right)=X_s\cdot E\left(e^{S_n-S_s-(n-s)/2}\mid F_s\right).
$$
Next, $S_n-S_s=V_{s+1}+\ldots+V_n$ does not depend on $F_s$ and the summands are independent from each other. Split the expectation into the product:
$$E\left(X_n\mid F_s\right)=X_s\cdot \underbrace{\prod_{i=s+1}^n E\left[e^{V_i}\right]}_{e^{(n-s)/2}}\cdot e^{-(n-s)/2}=X_s.$$


The order of a group with two generators

Question:
Let $G$ be an abelian group generated by $x$ and $y$ such that the order of $x$ is $16$, the order of $y$ is $24$ and $x^2=y^3$. What is the order of $G$?

The elements of $G$ are of the form $x^ny^m$ with $n=1,3,5,7,\cdots,15$ and $y=1,2,3,4,\cdots,23$. But I don't know how to quickly eliminate elements further, such as $xy^3=x\cdot x^2=x^3$. Can you help me with this? Thank you.
Comment: It is enough to take $n\in\{0,1\}$ and so the elements of $G$ are of the form $y^m$ or $xy^m$.
Answer: Consider the map ${\bf Z}/16{\bf Z}\times{\bf Z}/24{\bf Z}\to G$ extending $(1,0)\mapsto x$, $(0,1)\mapsto y$.
More specifically, invoke the first isomorphism theorem. What is the order of $(2,-3)$?
(Technically this yields that maximal possible order of $G$. Other possible orders are divisors of it.)
Comment: It should be pointed out that the statement in the brackets is true *in general*, but not here simply because any factor of the group $G$ constructed by anon will either not have an element of order $16$ or not have an element of order $24$. If we had $x^4=y^6$, say, as opposed to $x^2=y^3$ then the group $H$ constructed would not be unique as it maps onto $G$, and $G$ satisfies these conditions.


SQL Server: dbo vs db_owner role member?

Question: I'm assinging user to a new database. What is the difference of user being a default dbo user compared to assinging login as a db_owner role member?
Answer: Every database should have a dbo user, which by default is assigned to the db_owner database role. There's also a dbo schema, which is partially a holdover from SQL Server 2000 and earlier, where users and schemas were one in the same. It's also slightly special in that queries will look for objects in the dbo schema if they aren't found in the user's default schema (assuming the object name wasn't qualified with a schema name).
You can only map a single login to the dbo user in a database (as is the case with any database user), but you can assign as many users as you want to the db_owner role, giving them essentially full control of the database.
If you set a default schema for a database user, that won't have any effect in terms of security. It simply controls which schema by default will be used to create and reference objects when a specific schema name isn't provided with the object name. In SQL Server 2000 and earlier, since there was no separation of users and schemas, a user's default schema was always itself, unless explicitly specified otherwise, e.g. "CREATE TABLE dbo.test_table..." vs "CREATE TABLE test_table...". (Note that the dbo schema was still used for objects not found in a user's default schema.)
Answer: Default dbo user cannot view any database objects.db_owner can perform all configuration and maintenance activities on the database


Can any infinite metric space be isometrically embedded in some quasi-Euclidean space?

Question: I am wondering why the definition of metric includes 'the triangle inequality'. I browsed some answers before but none of them satisfy me.
I guess it may come from the geometric intuition of n-dimensional Euclidean space because any finite metric space can be isometrically embedded in an Euclidean space as some kind of graph representation of the set itself. This explains why all the finite metric spaces have the same nature: because their metrics can all be interpreted as some 'hidden' Euclidean metric.
This explanation seems to be invalid for infinite metric spaces, because in these spaces I cannot define clearly what an 'infinite' Euclidean space is. However, my intuition still tells me that this kind of explanation might work even in this situation.
The definition of 'norm' adopts the triangle inequality, too, which is a similar question.
I am asking for your help.
Comment: Are you asking about the motivation for the triangle inequality as one of the defining features of our notion of metric, or are you asking about when it's possible to isometrically embed metric spaces in Euclidean spaces?
Comment: Also, what makes finite metric spaces behave as characteristically as they do isn't that they are embeddable in Euclidean space. It is that they are compact and discrete.
Comment: The title seems about a different topic than the triangle inequality's role in defining metric spaces.
Comment: @Arthur I am asking about the motivation for the triangle inequality as one of the defining features of our notion of metric, and I suspect whether this explanation works.
Comment: If the real question is about motivation for the triangle inequality, then it is a duplicate of https://math.stackexchange.com/questions/37455/motivation-for-triangle-inequality
Comment: It's unclear what your question is. For the title question, the answer is negative (assuming that quasi-Euclidean means that it is quasi-isometric to some Hilbert space). The body of the question is totally unclear as written.
Comment: @MoisheKohan Thanks a lot. I attempted to find some kind of coordination representation of any metric spaces, but failed. I wonder whether any kind of metric space can have coordination representation (infinite, if needed)
Comment: @MoisheKohan Are there any counterexamples?
Comment: @Corn: Hyperbolic plane or regular tree with its standard graph-metric.
Comment: There are metric spaces of only four points that cannot be embedded in any euclidean space. For example, points A,B,C,D with |AB| = |BC| = |CA| = 7 and |AD| = |BD| = |CD| = 4. (This is because one can show that (2/3)*(√3/2)*7  >  4.) This example is due to Richard Schroeppel.
Answer: The metric function on a metric space intuitively measures the shortest distance between any two points of the space. The triangle inequality has a very simple intuitive meaning: This shortest distance between two points shouldn't shrink if we go via a third point. That would violate how "shortest distance" ought to work.
Euclidean spaces (with some standard metric, like Pythagoras) are the archetypal examples of metric spaces, and one could argue that the notion of metric space is intended to be a generalisation of the notion of Euclidean space (I don't know the actual history here, but it seems reasonable). But it is just that: a generalisation. There are many things that metric spaces can do that Euclidean spaces can't. This is what makes it a useful generalisation: we lose some specificity, so we can't prove all the same things. But on the other hand, the results we do find apply to many non-Euclidean contexts.
Ultimately, that's the reason for the triangle inequality: it works to make a useful generalisation. We could forgo it, and have much more general spaces. This way our results would apply much more broadly. On the other hand, we wouldn't get as many proven results. This is always a trade-off. And the particular trade-off we have made the way we have defined metric spaces has been popular and fruitful.
Comment: While you are explaining the 'shortest', you introduce a new concept: 'go'. In math it usually means a function, a map, or an operation. In a certain category, does there exist any kind of generalization of the triangle inequality that can describe the 'shortest' mapping from one object to another? I think in this way I can put my idea more clearly.
Comment: @Corn I am using "go" in the colloquial, informal meaning of a person (or something else) moving from one place to another. That's usually what "distance" cares about. So that's the word I chose to use. You're overthinking this.


Sum of odd powers of even number of complex numbers

Question: I've come across a result and I'm having a bit of trouble seeing where it comes from, and it seems like it should be obvious why it is true. Say we are given n complex numbers
$ \{z_1,...,z_n\}$ where n is even, such that the sum of their odd integer powers is zero for all powers less than $n$. Ie;
$$\sum_{i=1}^n z_i^k=0$$
for all k an odd integer less than n. Then if $m$ is an odd integer greater than n, we get that
$$\sum_{i=1}^n z_i^m=0$$
Again I have a feeling that this is a well-known result, or at least a re-wording or special example of one, but I don't know where to start looking.
Answer: This can be viewed as a consequence of the Girard-Newton identities.
If we put $p_k=\sum_{j=1}^n z_j^k$ for $k>0$, and $\prod_{j=1}^n(z-z_j)=\sum_{k=0}^{n}(-1)^k e_k z^{n-k}$ (so that $e_k$ are elementary symmetric polynomials in $z_1,\ldots,z_n$), these identities say $ke_k+\sum_{j=1}^k(-1)^j e_{k-j}p_j=0$ for $1\leqslant k\leqslant n$ (which gives $e_k=0$ for odd $k$, using induction on $k$), and $\sum_{j=k-n}^k(-1)^j e_{k-j}p_j=0$ for $k>n$ (which gives $p_k=0$ for odd $k>n$, again by induction on $k$, and we're done).
(The above basically shows that $p(z)=\prod_{j=1}^n(z-z_j)$ satisfies $p(z)=p(-z)$, so that $z\mapsto-z$ acts as a permutation on $z_1,\ldots,z_n$. This may give some intuition for other solutions.)


in MySQL Workbench, how do I create a mysql server on my localhost?

Question: In this question I am using Windows 7 32-bit, and MySQL Workbench 5.2.35 CE Rev 7915
I'm trying to create and connect to a mysql database on my localhost.  It seems obvious.  I should start up Workbench, go to Server Administration -> New Server Instance, tick the 'localhost' radio button and follow the wizard.  But I get to the 'Test DB Connection' step and it fails to 'Open Database Connection'.  The Message Log says:
Connecting to MySQL server localhost...
Can't connect to MySQL server on '127.0.0.1' (10061)
Now, my question is this:  Am I supposed to have already installed and started up a MySQL server on my localhost with some tool or program other than Workbench?  It seems like this wizard is just supposed to create a connection to an already existing mysql server, but I don't know how to create a server on my localhost.  I hoped Workbench would provide a way to do all of this:  Create MySQL server, start it up, connect to it, query it, etc.  but it seems like maybe it can only connect to already existing servers.
What should I do to create a MySQL server on my local machine and connect to it with MySQL Workbench?
Comment: Workbench is just a front-end. You do need to have the server software installed as well.
Answer: You can't. MySQL Server and MySQL Workbench are separate products, as Workbench is a GUI to the Server. To install both, download "MySQL Installer for Windows" and (by default) it will install both (and other) MySQL products.


Java Generics: Who is right, javac or Eclipse compile?

Question: Calling this method:
public static @Nonnull <TV, TG extends TV> Maybe<TV> something(final @Nonnull TG value) {
    return new Maybe<TV>(value);
}

like this:
public @Nonnull Maybe<Foo> visit() {
    return Maybe.something(new BarExtendsFoo());
}

compiles just fine in Eclipse, but javac gives an "incompatable types" warning:
found   : BarExtendsFoo

required: Foo
Comment: A working example without non-standard annotations and missing classes would make it easier for people to help.
Comment: I have a simple question... how will the compiler know the actual type you want to return in the call: `Maybe.something(new BarExtendsFoo())`?
Comment: why not
public @Nonnull Maybe visit() { ...}
?
Comment: dribeas, it should know that from the signature of visit(), which clearly states the desired type.
Answer: There are obviously some differences between javac and Eclipse. However, the main point here is that javac is correct in emitting the error. Ultimately, your code converts a Maybe<BarExtendsFoo> to a Maybe<Foo> which is risky.
Here's a rewrite of the visit() method:
  public static <TV, TG extends TV> Maybe<TV> something(final TG value) {
     return new Maybe<TV>(value);
  }

  public static class Foo { }

  public static class BarExtendsFoo extends Foo { }

  public Maybe<Foo> visit() {
     Maybe<BarExtendsFoo> maybeBar = something(new BarExtendsFoo());
     Maybe<Foo> maybeFoo = maybeBar;  // <-- Compiler error here

     return maybeFoo;
  }

This rewrite is practically identical to your code but it explicitly shows the assignment you're trying to make from Maybe<BarExtendsFoo> to Maybe<Foo>. This is risky. Indeed my Eclipse compiler issues an error on the assignment line. Here's a piece of code that exploits this risk to store an Integer inside a Maybe<String> object:
  public static void bomb() {
     Maybe<String> maybeString = new Maybe<String>("");

     // Use casts to make the compiler OK the assignment
     Maybe<Object> maybeObject = (Maybe<Object>) ((Object) maybeString);
     maybeObject.set(new Integer(5));

     String s = maybeString.get(); // Runtime error (classCastException):
                                   //   java.lang.Integer incompatible with
                                   //   java.lang.String
  }

Comment: The convertion from Maybe to a Maybe is not what I would expect. The something() method should return `Maybe`, so `TV` shold be Foo and not BarExtendsFoo. The rewrite is only valid (identical) for javac. Eclipse seams to use the expected return value to infer the (correct?) `TV` type so that something() creates a Maybe.
Answer: I do not understand why javac did not infer the correct type,
but you can help the compiler by supplying the types as in
public @Nonnull Maybe<Foo> visit() {
    return Maybe.<Foo, BarExtendsFoo>something(new BarExtendsFoo());
}

Comment: This indeed fixed the problem, although I hoped to avoid this explicit typing with that rather complicate signature of the something() method.

I have now simplified it to this, as I need to provide the type anyway:

 Maybe something(final TV value)

Thanks for all those hints.
Answer: Two comments:
a. As you mentioned in one of your comments, The TG type parameter in something()'s signature is not necessary at all, as there is nothing specific to the subclass TG that you're doing in the method.
b. The easiest soluion to this would be to help the compiler to understand which type you're using by explicitly assigning the newly created object to a variable (which is usually good practice anyway). It's now clearer to both the compiler and human readers how you'd like to call the method:
public @Nonnull Maybe<Foo> visit() {
    final Foo bar = new BarExtendsFoo();
    return Maybe.something(bar);
}


CLIPS match first field of a pattern

Question: I am trying to retract all facts of form:
<code>(<something> task-error)
</code>
To do this I wrote the rule:
<code>(defrule retract-task-error "retract task error"
         (declare (salience -1000))
         ?f <- (?n task-error)
         =>
         (retract ?f)
)
</code>
But it does not work with error:
<code>[PRNTUTIL2] Syntax Error:  Check appropriate syntax for the first field of a pattern.
</code>
Is it ever possible to accomplish this task with CLIPS or do I need a code rearrangement to avoid matching first fields of facts?
Answer: The first field of a pattern must be a symbol. The simplest solution would probably be adding a common symbol (such as task) to the beginning of all facts and patterns which can contain task-error:
<code>(defrule retract-task-error "retract task error"
         (declare (salience -1000))
         ?f <- (task ?n task-error)
         =>
         (retract ?f)
)
</code>

CLIPS match first field of a pattern


Node relationships, backwards or forward?

Question: I know node references are not as popular as entity references are, but I'm curious on backwards and forward relationships.
This is a use case I see someone doing.
Job  < -- Job Application
2 content types, and the node reference in the Job application point to Job.
In reality, shouldn't Job be pointing to the Job applications?
2nd use case
Project --> Files
When you create a project, you attach files to it, most of the time files are known beforehand so additional ones after parent node creation would be unlikely.
This is the more "correct" way as I see it, a Project can "have many" files. I also notice it could be done in the reverse as well, a file could reference a project.
The whole idea of Many to one, one to many, and many to many relationships in Drupal using the node / entity references module really make me wonder.
With the project user case, you can use references dialog, and you can create children right then and there. Doing the reverse of that, creating a parent could be possible, but why would one do that?
I've watched many videos, and I can see people doing it both ways almost with no consistency. I almost get confused myself when thinking about this. I come from doing things where these relationships are a bit more defined, and the DB schema is setup as so.
So does it really matter which way you put the reference? Also is it bad to have 2 node reference each other? I noticed there is some back references modules etc, what use do these have outside of making it easier for views? Did they have provide any other practical uses? (I know views3 with the node reference module , back references work out of the box now). Does it really just come down to workflow and how it would be easiest to get the creation forms to have the experience you want?
If someone could clear this up for me, I would really appreciate it.
Answer: A one-to-many relationship (also in DB design) is typically created by referencing the parent from the child. In the Jobs/Job Applications case, this translates into a reference from Job Application to Job, not vice versa.
In the Project/File case, if each file can only belong to one project, then it's also a one-to-many relationship and so File should reference Project. This is definitely how it should be if we were designing database tables for those entities.
However, in terms of Drupal and node references and given this particular example, Files are almost like properties to the Project node. So I wouldn't be surprised to see Files referenced from Project in a multiple-value node reference field, just for convenience.
Comment: Yes, thank you for the response, so the convenience you speak of is the "workflow" I mentioned above correct? Like if I wanted a Project/File and add files at the same time, it would be easy to go from Project to File and use the reference dialog to quickly add them for an easy workflow. Can the reference dialog work in a reverse manner? If so maybe that could keep workflow and keep it DB elegant?
Comment: Yes, the convenience I mentioned is mostly a workflow thing. Not sure if the reference dialog can work in a reverse manner though.


A sufficient condition for a finite group to have a $p$-power order

Question: Let $G$ be a finite group and $p$ a prime number. If $G$ is a $p$-group, i.e. the order of every element of $G$ is a power of $p$ then is the order of $G$ equal to some power of $p$?  How do I show this?
Answer: By Cauchy's theorem, if there is another $q$ dividing $|G|$, then there exist an element of order $q$ in $G$ for prime $q$ which conclude the result.
Comment: stackexchange eats apostrophes like in the link to Cauchy's theorem. I fixed it with the %27
Comment: ... but it does URL encoding automatically if the link is inserted via Ctrl-L (the "link" button in the editor). @JackSchmidt
Comment: @wordsthatendinGRY: awesome, thanks.
Answer: If $|G|$ has another prime-power factor $q^k$ ($k$ maximal), by the first Sylow's theorem, it has a subgroup whose order is precisely $q^k$. Then, if every subgroup has an order $p^j$, the order of $G$ can not have divisors that are not powers of $p$.


Pass a url as a parameter in Ruby on Rails route

Question: I'm trying to pass an audio URL as a parameter in Ruby on Rails, and googling "how to pass a url in a url" has proved to be problematic. The problem is that I can only get the url to return minus a crucial forward slash.
My route looks like:
get 'my_page/:title/*url', to: 'my_page', action: 'show'

The variable is defined in the controller like so:
@url=params[:url]

So the request would look like:
www.my_app.com/my_page/im_a_title/http://im_a_url.mp3

The url variable, however, ultimately results missing a slash after the prefix:
http:/im_a_url.mp3 <--notice the missing forward slash

Of note, the construction of the urls varies enough that it would be cumbersome to construct them. (Some begin with http and some https, for instance.) How do I preserve the syntax of my url? Or is there a better way to pass this parameter all together?
Answer: Why don't you pass the url as a required parameter. That way you can use the built-in to_query.
get 'files/:title' => 'files#show'

and in files controller
class FilesController < ApplicationController

  def show
    url = params.fetch(:url) # throws error if no url
  end

end

You can encode the url and unencode like so:
{ url: 'http://im_a_url.mp3' }.to_query
# => "url=http%3A%2F%2Fim_a_url.mp3"
Rack::Utils.parse_query "url=http%3A%2F%2Fim_a_url.mp3"
# => {"url"=>"http://im_a_url.mp3"}

Answer: You should url encode the parameters before passing them in
Comment: Yes, thank you, very close. Although, now I'm not getting the .mp3 suffix.
Answer: Rails 4
match 'my_page/:title/:url', to: 'my_page#show' , constraints: { url: /[a-zA-Z0-9][a-zA-Z0-9-]{1,61}[a-zA-Z0-9]\.[a-zA-Z]{2,}/}, via: :get, :format => false

constraints will match only a regex for a url.
format => false will ignore the dot part of the url


How to use JedisConfig pool efficiently without increasing number of connections more than maxtotal?

Question: Jedis pool is not working as expected .I have mentioned active connections 10 but it is allowing even above 10 connections.
I have overridden getConnection() method from RedisConnectionFactory. This method has been called almost for 30 times for getting the connection.
I have configured the jedis config pool as mentioned below.
Can some one please help me out why it is creating the connections more than the maxtotal? And can someone please help me out with the closing of jedisconnection pool as well.
@Configuration
public class RedisConfiguration {
        @Bean
        public RedisTenantDataFactory redisTenantDataFactory(){
        JedisPoolConfig poolConfig = new JedisPoolConfig();
                        poolConfig.setMaxIdle(1);
                        poolConfig.setMaxTotal(10);
                        poolConfig.setBlockWhenExhausted(true);
                        poolConfig.setMaxWaitMillis(10);

                        JedisConnectionFactory jedisConnectionFactory = new
                        JedisConnectionFactory(poolConfig);
                        jedisConnectionFactory.setHostName(redisHost);
                        jedisConnectionFactory.setUsePool(true);
                        jedisConnectionFactory.setPort(Integer.valueOf(redisPort));
    }

        #####
           @Bean
            public RedisTemplate<String, Object> redisTemplate(@Autowired RedisConnectionFactory redisConnectionFactory) {
                RedisTemplate<String, Object> template = new RedisTemplate<>();
                template.setConnectionFactory(redisConnectionFactory);
                template.afterPropertiesSet();
                return template;
            }
}

I have overridden getConnection() method from RedisConnectionFactory. This method has been called almost for 30 times for getting the connection.
Answer: It is probably a misunderstanding of the ConnectionPool behaviour. Without having the details about how you are using the pool in your application I guess.
So you pool is configured as followed:
...
poolConfig.setMaxIdle(1);
poolConfig.setMaxTotal(10);
poolConfig.setBlockWhenExhausted(true)
...

This means as you expect, you will not have more than 10 active connections from this specific pool to Redis.
You can check the number of clients (open connection) from Redis itself using RedisInsight or using the command CLIENT LIST, you will see that you will not have more than 10 connections coming from this JVM.
The fact that your see many call to getConnection() is just because your application is calling it each time a connection is needed.
This does NOT means "open a new connection", this means "give me a connection from the pool", and your configuration define the behaviour, as follow:

poolConfig.setMaxIdle(1) => you will have at least always 1 connection open and available for your application. This is important to chose a good number since "creating a new connection" is taking time and resources. (1 is probably too low in a normal application)
poolConfig.setMaxTotal(10) => this mean that the pool will not have more than 10 connections open in the same time. So you MUST define what happen when you have reach 10, and your app need one. This is where
poolConfig.setBlockWhenExhausted(true) => This means that if you have already 10 "active" connections used by your application, and the application call getConnection(), it will "block" until one of the 10 connections is returned to the pool.

So "blocking" is probably not a very good idea... (but once again it depends of your application)
Maybe you are wondering why your application is calling the getConnection() 30 times, and why it does not stop/block at 10....
Because your code is good ;), what I mean by that your application:
1- Jedis jedis =  pool.getCoonnection();  (so it takes one active connection from the pool)
2- you are using jedis connection as much as needed
3- you close the connection jedis.close() ( this does not necessary close the real connection, it returns back the connection to the pool, and the pool can reuse it or close it depending of the application/configuration)
Does it make sense?
Usually you will work with the following code
/// Jedis implements Closeable. Hence, the jedis instance will be auto-closed after the last statement.
try (Jedis jedis = pool.getResource()) {
  /// ... do stuff here ... for example
  jedis.set("foo", "bar");
  String foobar = jedis.get("foo");
  jedis.zadd("sose", 0, "car"); jedis.zadd("sose", 0, "bike");
  Set<String> sose = jedis.zrange("sose", 0, -1);
}
/// ... when closing your application:
pool.close()

You can find more information about JedisPool and Apache CommonPool here:

Getting-started
Apache Commons Pool
Comment: Thanks  for the info Tug Grall
Comment: Tug Grall ... Can u please look into this https://stackoverflow.com/questions/64426073/why-pool-parameter-of-jedisconnectionfactory-is-coming-as-null


How can I apply node template file only to node view page but not revision page?

Question: I have a node template named node-"content-type-name".tpl.php which overrides the default node.tpl.php for this content type.
But this template file is applied to also node revision pages. Is there anyway I can apply the node template file to just node view/edit page without revision page?
Answer: I don't have a D6 site around with revisions enabled so I can't test this, but the following code should disable the custom template for the revision pages:
function MYTHEME_preprocess_node(&$vars) {
  $template_name = 'node-content-type-name';

  // Work out if we're on a revision page
  $on_revision_page = arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == 'revisions';

  // See if the rogue template file is available as one of the suggestions.
  $template_index = array_search($template_name, $vars['template_files']);

  if ($on_revision_page && $template_index !== FALSE) {
    // Remove the rogue template file from the suggestions.
    unset($vars['template_files'][$template_index]);
  }
}

Comment: Thanks for the code but it doesn't work and throw this error  `warning: array_search() expects parameter 2 to be array, null given in` for this line `$template_index = array_search($template_name, $vars['template_files']);
`


Showing that the series $\sum \log{n}/n^2$ converges.

Question: I aim to show that the series $$\sum \frac{\log{n}}{n^2}$$ converges.
I know that the inequality $log(n) < \sqrt{n}$ holds for large $n$. So this give us one way to prove the convergence of $\sum \log{n}/n^2$ (by comparison). But to obtain this inequality we have to define log rigorously and put more advanced stuff in the game. Can we demonstrate without using this kind of properties, without continuity, derivatives and integrals? You can use simple properties of log (of the sum or product), the limit $\log{n}/n\to 0$, etc.
Comment: How do you define log non-rigorously?
Comment: if you want to impress your teacher, say that $\ln n = \mathcal{O}(n^{\epsilon})$ for every $\epsilon > 0$
Comment: $-\zeta '(2)=\sum _{n=1}^{\infty } \frac{\log (n)}{n^2}$
Comment: To be clear, what explicit properties of log do you mean to permit?
Comment: Could you be more specific? What kind of property do you allow for $\log$? Because if you don't want to "define it rigorously", you will have to throw some axioms for $\log$... otherwise how can you talk about something you know nothing about?
Comment: @Travis the relation between log and exp, log(ab)=log(a) + log(b), log(a/b)=log(a)-log(b), log(a^b)=b.log(a), log is strictly increasing, log1=0, log(n) tends to infty if n tends to infty, log(1/n) tends to -infty if n tends to infty.
Comment: @Hagen con Eitzen $log(a)$ is the number that we have to elevate $e$ to obtain $a$.
Answer: You can observe that, since $\log{n} \leq n $ for all $ n $,
$$\log{n} = \log{\sqrt{n}^2} = 2\log{\sqrt{n}} \leq 2\sqrt{n}$$
Asimptotically, the $ 2 $ changes nothing
Comment: Just that $\sum_{n=1}^\infty \frac1{n^\alpha}$ converges, if $\alpha>1$.
Comment: ok, he still needs to know more stuff to see why that finishes the problem right?
Comment: exactly${}{}{}{}{}$
Comment: If you want to see why that series converges you can just use the integral test.
Comment: But we can use numerical series stuff. This was good. Is there a simple way to prove that $\log{n} \leq n$?
Comment: Do you know how to show that exp(x) > x?
Comment: @Ryan for n large, yes. If $a>1$ and $p$ is a natural number fixed, $\lim a^n/n^p =\infty$. Put $a=e>1$ and $p=1$
Comment: @Jytug It is possible to show that $\log \sqrt{n} < \sqrt{n} assuming that $\log n < n$?
Comment: @FernandoVieiraCostaJúnior it's easier to do, assuming $ \log{x} \leq x $ for $ x $ real.
Comment: @Jytug yes, of course. But assuming only for $x\in\mathbb{N}$ I think that it is not possible.
Comment: @FernandoVieiraCostaJúnior it's possible to prove it without assuming anything
Comment: @Jytung nope. You will have to assume at least some axioms and others basic concepts.
Comment: Of course you will have to assume some basic concepts, what I mean is that proving the inequality $ \log \sqrt{n} \leq  \sqrt{n} $, knowing that $ \log n \leq n $ for integer $ n $ is not impossible
Answer: You could use the integral test, since $\int_1^\infty \frac{\ln x \text{d}x}{x^2}=\int_0^\infty u\text{e}^{-u} \text{d}u=\left[\left(-1-u\right)\text{e}^{-u}\right]_0^\infty=1.$
Comment: Mardon me, but a definition of log requires integral  or requires $\mathrm e^x$ be defined, which requires power series…
Comment: I think this is the way to go, it also works if you want to prove the auxiliary result in the other solution.
Comment: But integrals is out of cogitation. We are in the fourth chapter of the book, and integrals content is in the chapter 10-11.
Comment: The trouble with a lot of these textbooks is that, because no-one really learned all of mathematics starting from axioms from which it can all be derived (unless you were taught set theory at school as part of the New Math), but rather learned things in a jumbled order, we feel like we "can use" logarithms before calculus. The best we can do to even define the original problem is to say $\log_b n := \lim_{k\to\infty}a_k$ for a sequence $(a_k)_{k\in\mathbb{N}}$ with $\lim_{k\to\infty}b^{a_k}=n$. So we have to verify the choice of $(a_k)$ is irrelevant...
Answer: You can use the Cantor criterion:

Let $\{ a_n\}_n$ be a positive decreasing sequence of real numbers.
$\sum_n a_n$ converges if and only if $\sum_n 2^n a_{2^n}$ converges.

Applying this criterion to your series, you need to show that
$$\sum_{n=1}^{\infty} 2^n \frac{\log 2^n}{4^n}$$
converges. But now
$$\sum_{n=1}^{\infty} 2^n \frac{\log 2^n}{4^n} = \log 2 \sum_{n=1}^{\infty}  \frac{n}{2^n}$$
is convergent by the root test.
Comment: How can I prove that $\log n/n^2$ decreases?


Back slashes in Android NDK path keeps QT application from deploying

Question: I'm able to compile my application in Windows but when I try to debug on my tablet I get this error.
<code>/usr/bin/sh: line 1: C:androidndk/toolchains/arm-linux-androideabi-4.8/prebuilt/windows-x86_64/bin/arm-linux-androideabi-ranlib: No such file or directory
</code>
I figured the problem is that under Tools->Options->Android the path to my android NDK is listed as C:\android\ndk so I tried replacing the back slashes with forward slashes.  But when I do this the error is still there and when I open my Android options the back slashes are back.
Comment: *I tried replacing the back slashes with forward slashes* - what file did you change?
Comment: Does your path really contain C:androidndk?
Comment: There was no file, I changed an option under Tools->Options->Android.  And no, my path contains C:\android\ndk.  It looks like the Cygwin shell is removing the back slashes so I'm trying to replace "\" with "/".
Answer: I never got to the root of the problem but I created a new project and that worked just fine.  Since the path to the ndk looked messed up I thought there was a problem with my QtCreator setup but simply starting a new project fixed this issue.
Comment: Strangely, this does not help me. When I try to build my C++ library for Android, I see exactly the same issue even if NDK lies in C: root: `/usr/bin/sh: C:android-ndk-r10e/`


Secure EC2 instance from logging without .pem file

Question: I see here and here (under Connecting to Your Linux Instance if You Lose Your Private Key) ways to access EC2 instance without a .pem file that was created when the instance was created.
I would like to secure my EC2 so NO-ONE without the .pem file (that I have locally on my machine) will be able to access it.
BTW, I still have in the ec2 the keypairs of instances (public, fingerprint)
How can I do it?
Comment: Made a snapshot of the volume and then mounted it elsewhere, probably. It sounds as if you have an in-trusted person that has access to your key infrastructure. That is a big problem, and you need to revoke that person's access immediately.
Comment: By definition, as long as you have password auth disabled, having access to the private key is a pre-requisite to successful authentication.
Comment: Someone that had only the password to login to the console, logged-in into the servers without the pem file.  So it could happen. He didn't have username/password
Comment: EC2 does not enable true console access. The "console" they give you is merely an SSH client.
Comment: so how did he have access to my code on the tomcat server? I didn't have it on the AMI..
Answer: You didn't come out and say this right away, but you have given AWS console access to someone who you don't trust. That is the problem you need to solve. What you've done is equivalent to giving someone physical access to you server. Once you've done that, all bets are off. Game over.
So, the first thing that you need to do is revoke this person's access to your AWS account. After you've done this, all you need to do is protect your private key (which it already sounds like you're doing) and the chances of your servers being compromised via SSH are essentially zero.
Answer: You have a few options to control access. Take as many of these approaches as you can.

Use instance store backed EC2.
Setup MFA on your AWS console.
Setup Security Groups on your EC2 machine.
Add a passphrase to your SSH private key.
Disable password auth to SSH.
Disable root login to SSH.
Audit all user accounts for SSH public keys.

If you do all of the above steps, you have prevented the workaround described above in your question. The approach laid out in my answer can be considered "defense in depth" meaning making sure to solve the problem in multiple layers. Thus, even if there is a compromise or mistake on one layer, the others will prevent accesss.
Comment: With all due respect, your steps do nothing to invalidate the workaround described in the links the OP liked to.
Comment: No, anyone with access to the AWS console could still access the server.
Comment: AWS console access is the same as having physical access. Period. If someone has console access, they can access your data. Don't allow un-trusted people to have console access.
Comment: You're missing the point. Don't allow un-trusted people to have access to AWS. Period. Don't do it.
Comment: if I am out of time, which step would you recommend to start with as the most secure one to prevent from logging without .pem file?
Comment: I think if you read OPs question carefully and consider the part about "no-one" besides the owner of the pem file can access his machine you will see I am right.
Comment: @EEAA so someone with access to AWS console could or couldn't access the server? (not sure from your comments to my question)
Comment: :( I thought that a pem file could solve it.. :(


Import multiple CSV files into R and combine first two rows as the header column

Question: I have about 50 CSV files that need to be imported into R, and then I want to set a header row which is the first two rows of data in each file. As an example:
DATE      FIRST  LAST ID
(M/D/Y)   NAME   NAME

The data starts in Row 3. I can import all the files as their own unique dataframe which
temp = list.files(pattern="*.csv")
list2env(
  lapply(setNames(temp, make.names(gsub("*.csv$", "", temp))),
         read.csv), envir = .GlobalEnv)

But how can I change that code to combine the first two rows as a header
Answer: I'd recommend reading in the first two rows, making the column names you want, and then read in the rest, skipping the first 2 rows. Here's an example for one file, found at filepath x:
cnames = read.csv(x, nrow = 2)
cnames = sapply(cnames, paste, collapse = "")
data = read.csv(x, skip = 2, col.names = cnames)

I'd also strongly encourage you to leave your results in a nice, easy-to-use list, rather than creating about 50 data frames in your environment. My reasoning for this recommendation is detailed here. That could look like this:
temp = list.files(pattern="*.csv")
data_list = list()
for(i in seq_along(temp)) {
  cnames = read.csv(x, nrow = 2)
  cnames = sapply(cnames, paste, collapse = "")
  data_list[[i]] = read.csv(x, skip = 2, col.names = cnames)
}

names(data_list) = sub(".csv", "", basename(temp), fixed = TRUE)

# Then if you want to combine them all
complete_data = dplyr::bind_rows(data_list, .id = "source_file")

Comment: I see your point, what I'd ultimately like to do is use rbind to combine all of those 50 spreadsheets into one master spreadsheet, but the spreadsheets sometimes have additional columns so creating a standard header might not work for each of the spreadsheets
Comment: I'm not recommending a standard header - these three lines will be run for each data frame inside the loop/lapply.
Comment: @ac1998 see edits for a more thorough example. `dplyr::bind_rows` will include all columns that appear in any data frame.


What is a discrete table?

Question: I've been reading Bishop's book on pattern recognition and machine learning and I keep finding the term discrete tables (mostly in the hidden markov models chapter) but I can't seem to find any information about what those tables consist of. Could someone give me a hint?
Answer: I ctrl-f'd 'discrete table' and I found only one sentence with it.

Indeed, the model is tractable for a wide range of emission distributions including
  discrete tables, Gaussians, and mixtures of Gaussians.

It means that for any time $t$, the observational distribution $p(x_t|z_t)$ is just some custom finite distribution. There's no special name for this, so he just calls it a discrete table. Conditional on the state being some value $z_t$, $x_t$ can take on a finite number of values with corresponding probabilities, whatever you want them to be.
Comment: I think I saw it somewhere before that sentence but can't seem to find it. Thanks, I understand it now!

What is a discrete table?


system str_replace

Question: I have the following string produced by system("last").
user1 ftpd11967  89-23-224-162.d Fri Aug  3 01:42   still logged in

How can I use str_replace to replace...
still logged in

with...
still logged in

Tried
system("last", $rawOutput);
$output = str_replace ( "still logged in" , "still logged in" ,$rawOutput );

echo $output;

I have also tried, besides system:
$rawOutput = shell_exec("last");
$output = str_replace( "still logged in" , "still logged in" ,$rawOutput );

echo $output;

Comment: Couldn't you just... try something?
Comment: well I did and it didn't work, was trying for whole day thats why i'm here now
Comment: Maybe you weren't clear enough. Post what you have tried, and what you expect. Otherwise this question seems... trivial.
Comment: i have tried all kinds of tips and tutorials, it was nothing related to system with str_replace, now we are getting somewhere. All tutorials etc. were almost same like this one that sephoy08 posted. But at the moment there is no affect, but i believe someone will try it on own site and will find a solution.
Answer: Try this
// "user1 ftpd11967 89-23-224-162.d Fri Aug 3 01:42 still logged in"

system("last", $rawOutput);
$output = str_replace ( "still logged in" , "still logged in" ,$rawOutput );

echo $output;

Comment: this will not work because i need to first use system("last"); and then from that output replace still logged in to the green still logged in
Comment: Then just do `$rawOutput = system("last");`.
Comment: system("last", $rawOutput);$output = str_replace ( "still logged in" , "still logged in" ,$rawOutput );echo $output; i have tried your way and also this way
Comment: yeah. i edit it above. hope it helps!
Comment: well it isn't working, it has to be on some other way, I don't know what are we doing wrong here :(
Comment: what is the value of `$rawOutput`?
Comment: same like before, same output like there was no changes made
Comment: strange, once you past the value to the variable, it should be independent.
Comment: all what it changes is ofcourse server last logins. Here is the output http://pastebin.com/NDPve7Pr still logged in is not colored, i have tried with  and it didn't work also
Comment: may i see your code? maybe your missing something.
Comment: echo "";

system("last", $rawOutput);
$output = str_replace ( "still logged in" , "still logged in" ,$rawOutput );

echo $output;

echo "";
Comment: this should work fine... and the output of `$output`?
Comment: that is the output: http://pastebin.com/NDPve7Pr its the same like if i would use only `system("last");`
Comment: anyone else got an idea?

system str_replace