Rhombus and circles angle problem

Question: Let $ABCD$ be a rhombus.
The circle $(C_1)$ of center $B$ passing through $C$ and the circle $(C_2)$ of center $C$ passing through $B$.
$E$ is one of the two points of $(C_1) \cap (C_2)$.
The line $(ED)$ meets $(C_1)$ again in $F$.
It is asked to find the measure of angle $\angle AFB$.
I tried a lot of angle chasing but in vain.
I even took a square instead just to find out a means to a solution but failed to get the value.
From geogebra, the measure would be $60^{\circ}$.
Answer: A fast approach using Euclidean geometry

Since $\mathcal C_1$ and $\mathcal C_2$ have the same radius,
$\triangle BEC$ is equilateral.
$BE$ subtends on $\mathcal C_2$ the angle $\angle BDE$, which therefore has measure $30^\circ$, and \begin{eqnarray}\angle ADE &=& \frac12 \angle ADC + 30^\circ\\ &=& \frac12 \angle ABC + 30^\circ.\end{eqnarray}
On the other hand, $AE$ subtends on $\mathcal C_1$ the angle $\angle AFE$, by which we have \begin{eqnarray}180^\circ- \angle AFE &=& \frac12 \angle EBA=\\ &=& \frac12 \left(\angle ABC + 60^\circ\right).\end{eqnarray}
By 2. and 3. $\triangle AFD$ is isosceles, with $AD \cong AF$ and the thesis follows from the fact that $AB \cong AD \cong BF$.

EDIT (thanks to bjorn93 for his useful comment.)
The situation when $ED<EF$ is shown below. However, as you can notice, the relationships found above do not change.
Comment: @ahmed Note that there's actually two cases depending on the relative position of D, E, and F. In the second case, $\angle ADE= \frac 12\angle ABC-30^{\circ}$.
Comment: @bjorn93 edited; check it out. I think the relationship between $\angle ADE$ and $\angle ABC$ does *not* change.
Comment: well, there's actually more than 2 cases for the position of the points. For example, D and E can be in the same half-plane with respect to BC and $\angle BDE$ can be $150^{\circ}$. What I meant is that they give you 2 cases for the angles: $\angle ADE=\frac 12\angle ABC\pm 30^{\circ}$.
Comment: @bjorn93 ah ok! Got it. Now I turned off my PC, but as soon as possible I'll show one of the cases you mention. Thanks again!
Comment: I don't think it's necessary. In any case, we get the same answer and the solution is similar to yours with slight adjustments.
Answer: It should be clear that $\triangle BEC$ is equilateral. Denote $\angle BFD=\alpha$ and $\angle AFD=\beta$. We need to find $\alpha+\beta$. You can show that $\angle ADF=60^{\circ}-\alpha$ through some angle chasing. Sine law for $\triangle ADF$ gives you
$$\frac{AD}{AF}=\frac{\sin\beta}{\sin(60^{\circ}-\alpha)} $$
and the sine law for $\triangle ABF$ gives you
$$\frac{AB}{AF}=\frac{\sin(\alpha+\beta)}{\sin(2(\alpha+\beta))}=\frac{1}{2\cos(\alpha+\beta)} $$
Since $AB=AD$,
$$\frac{\sin\beta}{\sin(60^{\circ}-\alpha)}=\frac{1}{2\cos(\alpha+\beta)} $$
Can you prove that the last equality implies $\beta=30^{\circ}$ or $\alpha+\beta=60^{\circ}$ and that $\beta=30^{\circ}$ is a contradiction?

Rhombus and circles angle problem


Is there prime number of the form$1101001000100001000001.....$after the trivial one $k(0)=11$?

Question: Let

$k(0)=11$

$k(1)=1101$

$k(2)=1101001$

$k(3)=11010010001$

$k(4)=1101001000100001$

And So on....
I've checked it up to $k(120)$, and I did't find anymore prime of such form. Are there anymore prime numbers of that form ? (I just realized that only $k(6n+5)$ could be a prime (?))
Comment: Also, an important clarification:  what base are these numerals written it?  In base 10, 11 is prime, but 11 is prime in bases 2 (which seems the most likely alternative), 4, 6, ... also!
Comment: Well, we can be sure that $k(n)$ will never be prime for all $n\equiv 1\pmod 3$. Also, we have that $11\nmid k(n)_{n>0}$
Comment: Actually I am incorrect $-$ it should be that $11\nmid k(n)$ for $n$ odd. And, if $n$ is even, $11\mid k(n)$.
Comment: I think you have an off-by-one error, Peter.  Letting `k[b_][n_] :=
 FromDigits[Flatten[{1, 1}~Join~Riffle[Map[0 & /@ Range[#] &, Range[n]], 1]~Join~If[n != 0, {1}, {}]], b]`, then searching k=1...100 via `Position[PrimeQ /@ k[10] /@ Range[100], True]` gives `{{35}}`.
Comment: @evanb You are right, it is $k(35)$ with $667$ digits
Comment: @HenrikSchumacher But $k(35)$ is prime, check which numbers are calculated by your program.
Comment: @Peter. Yes, you are right. Code should have been `a = FoldList[#1 10^#2 + 1 &, 1, Range[122]][[
  3 ;;]]; Or @@ (PrimeQ /@ a)` (there was a superfluous `1` in the beginning).
Comment: Upto $n=199$, there is no further prime.
Comment: @evanb True, but this must be mentioned in the question in this case. Without any additional context, a decimal expansion is the most reasonable guess. And in the binary case, $1101$ is prime
Comment: With PARI/GP I could prove the primality of $k(35)$. If another prime exists, it must have more than $20\ 000$ digits.
Comment: The problem is base dependent.  Some posted answers interpret it as base 2!
Answer: The formation law is clearly
$$
n_k = 2^k n_{k-1}+1
$$
with $n_1=3$
n0 = 3;
For[i = 2, i < 50, i++, n1 = 2^i n0 + 1;
 If[PrimeQ[n1], Print[n1, " ", IntegerString[n1, 2]]]; n0 = n1]
obtaining
n = 13 -- 1101
n = 271302750695377321080849818469209754627603342031510693802940799730825845099036699701989532948734015220469369753358523432961 -- 11010010001000010000010000001000000010000000010000000001000000000010000000000010000000000001000000000000010000000000000010000000000000001000000000000000010000000000000000010000000000000000001000000000000000000010000000000000000000010000000000000000000001000000000000000000000010000000000000000000000010000000000000000000000001000000000000000000000000010000000000000000000000000010000000000000000000000000001
If the number is considered in basis $10$ then the procedure is analogous. In this case we have $n_1 = 11$ and the recurrence equation is $n_k = 10^k n_{k-1}+1$ giving

n = 1101001000100001000001000000100000001000000001000000000100000000001000000000001000000000000100000000000001000000000000001000000000000000100000000000000001000000000000000001000000000000000000100000000000000000001000000000000000000001000000000000000000000100000000000000000000001000000000000000000000001000000000000000000000000100000000000000000000000001000000000000000000000000001000000000000000000000000000100000000000000000000000000001000000000000000000000000000001000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000000100000000000000000000000000000000001000000000000000000000000000000000001 -- 1101001000100001000001000000100000001000000001000000000100000000001000000000001000000000000100000000000001000000000000001000000000000000100000000000000001000000000000000001000000000000000000100000000000000000001000000000000000000001000000000000000000000100000000000000000000001000000000000000000000001000000000000000000000000100000000000000000000000001000000000000000000000000001000000000000000000000000000100000000000000000000000000001000000000000000000000000000001000000000000000000000000000000100000000000000000000000000000001000000000000000000000000000000001000000000000000000000000000000000100000000000000000000000000000000001000000000000000000000000000000000001
Comment: In basis $2$ the multiplication by $2^k$ provides a left shift by $k$ places.
Comment: *Clearly?* Well then, you sir have a good eye :)
Comment: Hah, like a magician revealing their secret! I did not think to consider in base $2$. Good job! I cannot upvote as I have reached my daily voting limit, though, but well done :)
Comment: Is it clear that the numbers in the OP are given in base 2? It doesn't seem to say so anywhere.
Comment: The procedure is analogous. In this case we have $n_1 = 11$ and the recurrence equation is $n_k = 10^k n_{k-1}+1$. This case was attached to the answer. Thanks.
Answer: This is not really an answer but might be of some help.

According to the "Divisibility by $3$ Rule," if $n\equiv 1\pmod 3$ then $k(n)$ will not be prime as it will be divisible by $3$. And, it will be divisible by $11$ if $n$ is even.
That leaves only all the odd numbers for $n$ (since the congruence above is also even).
Comment: I think you mean that it leaves the congruence classes $3,5 \pmod 6$. For example, $1$ is congruent to $1$ mod 3 but is not even.
Comment: @JalexStark yes I probably did. I did not think of that :)
Answer: Here is a Mathematica search to answer your question:
b[1] = 1;
b[2] = 2;
b[n_] := b[n] = b[n - 1] + n - 1;
list[t_] := b /@ Range[t];
Reap@Do[a = ReplacePart[Array[0 &, b[t]], Transpose[{list[t]}] -> 1];
  c = FromDigits[a, 2]; If[PrimeQ[c], Sow@c], {t, 100}]

which yields
{Null, {{3, 13,
   2713027506953773210808498184692097546276033420315106938029407997308\
25845099036699701989532948734015220469369753358523432961}}}
Comment: can you elaborate on the format of your output for those in the math.SE community who are not fluent in Mathematica?
Comment: Sorry... This question is first asked in mathematica community,When i answered it.
Comment: Yeah, just hoping you could explain so the answer will fit in its new home


Como passar um argumento dinâmico para um método no Vue.js?

Question: Preciso chamar um evento v-on:click com um argumento dinâmico.
Tentei da forma mais lógica:
v-on:click="my_method({{value}})".
Não funciona.
Answer: Faça simplesmente assim:
v-on:click="my_method(value)"

Você não precisa usar interpolação dentro de atributos HTML dinâmicos. No VueJS 2 qualquer tentativa de interpolação em atributos gera uma mensagem de erro.


When is the partial derivative with respect to $x$, then $y$, is different from the partial derivative with respect to $y$, then $x$?

Question: In math, for most functions of $x$ and $y$, $$\frac{\partial^2 f}{\partial x\partial y}=\frac{\partial^2 f}{\partial y\partial x}$$ That is, the partial derivative of $f(x, y)$ with respect to $x$ then $y$ is the same as the partial derivative with respect to $y$, then $x$.
I have heard that there are functions for which this is not true. Can someone give me some examples?
Comment: Such a function must have $f_{xy}$ or $f_{yx}$ not continuous: https://calculus.subwiki.org/wiki/Clairaut%27s_theorem_on_equality_of_mixed_partials.
Comment: https://math.stackexchange.com/questions/219759/show-that-both-mixed-partial-derivatives-exist-at-the-origin-but-are-not-equal?rq=1
Comment: You want something with a slope in one direction but no well defined slope in the other. Take a balloon and pinch the top between your fingers. The balloon has a slope parallel to the pinch but not across the pinch.
Answer: On Wikipedia you can see the canonical example of the Italian mathematicians, Giuseppe Peano.
Here there is his example of a function with mixed partial second derivatives, it must have such non-continuous derivatives as in the following example Given a continuous function:
$$f(x,y)=\left\{\begin{matrix} xy \dfrac{x^2-y^2}{x^2+y^2} & \forall (x,y) \in \Bbb R^2 \setminus \{(0,0)\}\\  0 &(x,y) = (0,0)
\end{matrix}\right.$$
We have continuous prime partial derivatives:
$$f_x (x,y) =\left\{\begin{matrix} y \dfrac{x^2-y^2}{x^2+y^2} + xy \frac {2x (x^2+y^2) - 2x (x^2-y^2)}{(x^2+y^2)^2} & \forall (x,y) \in \Bbb R^2 \setminus \{(0,0)\}\\0 & (x,y) = (0,0)
\end{matrix}\right.$$
$$f_y (x,y)=\left\{\begin{matrix}  - x {y^2-x^2}{x^2+y^2} - xy \dfrac{2y (x^2+y^2) - 2y (y^2-x^2)}{(x^2+y^2)^2} & \forall (x,y) \in \Bbb R^2 \setminus \{(0,0)\} \\0 & (x,y) = (0,0)
\end{matrix}\right.$$
But the mixed second derivatives are not continuous and are different, in fact:
$$f_{xy} (0,0) = \lim_{k \to 0} \frac{f_x (0,k) - f_x (0,0)}{k} = -1, \quad f_{yx} (0,0) = \lim_{h \to 0} \frac{f_y (h,0) - f_y (0,0)}{h} = +1$$So $$f_{yx} \neq f_{xy}$$
Here $f_x=\frac{\partial f}{\partial x}$ and $f_y=\frac{\partial f}{\partial y}$, $f_{xx}=\frac{\partial^2 f}{\partial x^2}$ and $f_{yx}=\frac{\partial^2 f}{\partial y\partial x} $.


Exact differential equation identity

Question: I was looking at the solution to exact differential equations, and in the solution it states that if,
$$\frac{\partial g(x,y)}{\partial x} = M(x,y)$$
and,
$$\frac{\partial g(x,y)}{\partial y} = N(x,y)$$
Then it is implied that,
$$dg(x,y) = M(x,y) dx + N(x,y) dy$$
How does the last equation follow from the other two?
Comment: This is an example of a total differential/total derivative.
Answer: I find derivatives more palatable than differentials, so imagine dividing your equation by $dt$:
$$\frac{dg(x,y)}{dt} = M(x,y)\frac{dx}{dt} + N(x,y)\frac{dy}{dt}$$
If you substitute in your expressions, you get
$$\frac{dg(x,y)}{dt} = \frac{\partial g}{\partial x} \frac{dx}{dt} + \frac{\partial g}{\partial y} \frac{dy}{dt}$$
which is the chain rule for multiple variables.

Exact differential equation identity


Overriding Object's Length Property

Question: I found myself in an interesting situation. I am using an object literal to represent a product in the real-world. Now each product has a length associated to it for shipping purposes. It looks something like this:
var product = {
  name: 'MacBook Pro 15 Inch',
  description: 'The new macbook pros....',
  length: 15
  height: 15
  Weight: 4
}

This this works fine. But for products that have unknown length they default to length -1.
Again this works fine, until you try to do this:
console.log('Product has the following properties');
_.each(product, function(val, key) {
    console.log(key + ":" + val);
});

No keys will be printed for a product that has a length of -1. Why? Well because internally underscore uses the length attribute, that every object in Javascript has to loop over all the attributes of the passed in object. Since we overwrote that value, it is now -1, and since we start looping at i = 0, the loop will never be executed.
Now for the question, how can I prevent the length property from being overridden? Best practices to prevent this from happening would also be appreciated.
Answer: This is perhaps due to some magic in _'s each function as I suspect it accepts both Objects and Arrays .. make your own?
Simple implementation (that avoids some common pitfalls):
function each(obj, map_func) {
    var key;
    for (key in obj) {
        if (Object.prototype.hasOwnerProperty.call(obj, key)) {
            map_func(key, obj[key]);
        }
    }
}

The magic in _'s each is probably due a nasty 'habit' in JavaScript of having things that 'look' like Arrays but aren't actually Arrays, like the magical variable arguments, and I think options in a select DOM Elements as well.
Answer: I can't think of anything off-hand that overrides it. I suppose using the length property is a form of duck typing that marks it by jQuery as iterable.
But.. you can just not use the jQuery each method, and do it the manual way..
By simply using
for (key in product) {

}

You get your basic loop. Now if you are potentially overriding the object's prototype, you should also check product.hashOwnProperty(key) to make sure the current key you're iterating is defined in the product instance.
Now if you also need a new closure scope, that's pretty simple too.. here's an alternative each function..
var myEach = function(subject, callback) {

  for (key in subject) {

     if (subject.hasOwnProperty(key)) {
        callback(subject[key], key);
     }
  }

}

Note: untested.
Comment: I would like to point out the 'pitfall' here that your object can override the property `hasOwnProperty`, so use `Object.prototype.hasOwnProperty`, which is the function you want.
Comment: underscore actually has a method just for that case `_.has()` that uses the `Object.prototype.hasOwnProperty`. But yeah thanks for the answer :).
Answer: try this:
    var product = {
        name: "MacBook Pro 15 Inch",
        description: 'The new macbook pros....',
        length: 15,
        height: 15,
        weight: 4
    };
    console.log('Product has the following properties');
    _.each(_.keys(product), function(key){
        console.log(key + ":" + product[key]);
    });

Answer: If you can't change the name of the length property, you could add an additional check to underscore to prevent this case:
_.each = _.forEach = function(obj, iterator, context) {
  if (obj == null) return;
  if (Array.prototype.forEach && obj.forEach === Array.prototype.forEach) {
    obj.forEach(iterator, context);
  } else if (obj.length === +obj.length && obj.constructor != Object) {
    for (var i = 0, l = obj.length; i < l; i++) {
      if (i in obj && iterator.call(context, obj[i], i, obj) === breaker) return;
    }
  } else {
    for (var key in obj) {
      if (_.has(obj, key)) {
        if (iterator.call(context, obj[key], key, obj) === breaker) return;
      }
    }
  }
};

The addition here is the && obj.constructor != Object on line 5. It works, though monkeypatching underscore may not be the most desirable thing in the world.
EDIT: Actually, this breaks on pseudo-arrays like arguments, since its constructor is Object, but <an array-like object>.hasOwnProperty(<an integer>) is false. Woo JavaScript.

Overriding Object's Length Property


Python 3.x replace() with index

Question: A question I came up with:
I'm trying to write a function that replaces the first and the fourth letter of a word with the same letter just capitalized.
Currently I am working with the string.replace() method. It works great for most of the time, except when there is an equal letter to the one on the fourth place before it.
Example: "bananas"
What I would expect the program to do is to return "BanAnas" but for a reason it return "BAnanas". If I use the word "submarine" it would just work fine, "SubMarine".
The code I wrote is this:
def old_macdonald(name):
    name = name.replace(name[0], name[0].upper(), 1)
    name = name.replace(name[3], name[3].upper(), 1)
    return name

Can someone explain why this is happening?
Comment: Adjust your code. Add 4 spaces in beginning of each code line.
Comment: Run over each character and make it uppercase if the index matches: `[c.upper() if i in (0, 3) else c for i, c in enumerate('Bananas')]`. Simple thing left to do is [joning](https://docs.python.org/3/library/stdtypes.html#str.join) that back to a string (I'll leave that for exercise).
Answer: It's because name.replace(name[3], name[3].upper(), 1) looks for the first character matching name[3]. Stop using replace altogether, chop up your string by slicing.

Python 3.x replace() with index


Flutter Execution failed for task ':app:dexBuilderDebug'

Question: When i try to run my flutter project i get the "Execution failed for task ':app:dexBuilderDebug'" error.
Does anyone know how to solve this?
Answer: Go to android>app>build.gradle and delete 'apply plugin: 'kotlin-android''
Answer: I had the same problem "Execution failed for task ':app:dexBuilderDebug'" running debug flutter app.
Try delete this folder  C:\Users\USER_NAME\.gradle\caches


node-gcm sending successfully but I do not know how to get the data from the client side

Question: So I am sending on the server side like so, using node-gcm
(https://github.com/ToothlessGear/node-gcm):
<code>var gcm = require('node-gcm');

var message = new gcm.Message({
    collapseKey: 'demo',
    delayWhileIdle: true,
    timeToLive: 3,
    data: {
        type: 'pong',
        message: 'Hello Android!'
    }
});

var sender = new gcm.Sender(myAPIKey);
var registrationIds = [aDoc.registrationId];

sender.send(message, registrationIds, 4, function (err, result) {
    console.log(result);
});
</code>
And then on the client side, in my BroadcastReceiver, I get the Logcat message printing and the receive notification, but the extras (from the intent.getStringExtra("data") is null. How do I get it properly? I cannot find how to do it anywhere. The registration case works perfectly.
<code>@Override
protected void onHandleIntent(Intent intent) {
    String action = intent.getAction();
    Log.i(TAG, "GCM Received");

    switch(action){
    case GCM.ACTION_REGISTRATION:
        String registrationId = intent.getStringExtra(GCM.KEY_REG_ID);
        Log.i(TAG, "action received: registration: " + registrationId);
        ...
        break;
    case GCM.ACTION_RECEIVE:
        String extras = intent.getStringExtra("data");
        Log.v(TAG, "" + extras);
        ...
...
</code>
extras is consistantly null
Answer: Through experimentation, I have solved my problem. Instead of accesssing the data object directly, node-gcm adds the key-value pairs to the intent's extras directly:
Wrong:
<code>// returns null
String dataJson = intent.getStringExtra("data");
</code>
Right:
<code>// returns "pong"
String type = intent.getStringExtra("type");
</code>


How to upload file to google drive using jenkins pipeline

Question: I want to add stage with one step to my Jenkinsfile pipeline to upload an apk to google drive and then getting the shareable link of uploaded file.
Answer: Have you checked this? Looks like it could be of some use


NFL strength of schedule in deciding playoffs and draft picks

Question: Why is a lower strength of schedule percentage better than a higher one when determining a playoff spot or a draft pick?
I would expect that a stronger schedule wins out over a weaker one.
Answer: I think you are mistaken about how the Strength of Schedule tiebreaker works.
When ranking teams, there are a series of tiebreakers that are used.  Tie breaker number 6 is "Strength of Schedule," and it is indeed the team with the higher Strength of Schedule that is ranked above a team with a lower Strength of Schedule.
I think where you might be getting confused is that when determining draft picks, the teams that are ranked lower end up with a higher spot in the draft.  The draft picks are in reverse order of the team rankings.  Therefore, when determining the draft pick order, if two teams have identical records and the tiebreaker goes all the way to Strength of Schedule, then the team with the lower Strength of Schedule will be ranked lower, but will end up higher in the draft order.


How do you prevent an Active Directory 2012 R2 Domain Controller from advertising the domain on a specific interface?

Question: Short version: How do you prevent an Active Directory 2012 R2 Domain Controller from advertising the domain on a specific interface? I want that network to not be flagged as a domain network, and no domain services should be available.
Environment:
A self-contained AD for managing a small hyper-v cluster and the related VM's. The DC also runs the VMM server and has access to the production network because of the need to reach the VMM console.
Long Term Goal / Potential Solution: I would like to have absolutely no non-VMM traffic reach the production network. I have considered just blocking all non-vmm outgoing connections with the windows Firewall, but I don't know how to force a particular profile on an interface.
Thanks!
Comment: You can switch an interface to be on a "private" network instead of "domain" within the network and sharing center. Then, you can configure the firewall with the different profiles
Comment: Are you sure that option exist on a DC? I can't find it anywhere :(
Answer: If the domain controller is not part of your production AD but instead manages its own one, it will not advertise itself as a domain controller for your production domain(s). It should of course use itself as its DNS server, thus it will not even talk to your production DNS servers.
Furthermore, you can disable all Microsoft networking protocols on the production network by unchecking the "Client for Microsoft networks" and "File and printer sharing for Microsoft networks" on the network interface connected to your production network, and also by disabling NetBIOS on the TCP/IP properties of the same interface; TCP/IP will remain operational and you will thus be able to RDP into the server and even connect to the VMM console, but no Windows-style networking will take place on that interface.
You should also disable DNS registration on the production network interface, or your internal DNS will get polluted by the DC registering its production-facing IP address for internal domain services.
Comment: This is exactly what I needed, succinct, and includes additional concerns I may not have thought off. Excellent answer, thank you.


Overlaying text on video element

Question: I've got a full screen div which is set to play a video but requires me to put some HTML over the top of it. However whenever I place this, I can see the test button load up and then vanish when the video loads.
What am I doing wrong?
Snippet:

          <video autoplay muted loop="true">
            <source type="video/mp4" src="/backdropvideo.mp4">
          </video>

<button> test </button>

CSS:
.Splash {
    position: relative;
    width: 90vw;
    margin: 0 auto;
    height: 95vh;
    min-height: 710px;
    background: #000;
    overflow: hidden;
    background:black;
}

.video-container {
  position: relative;
  top: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.gamesplayed {
    background-image: url(assets/GamesBanner.png);
    background-color: black;
    background-size: contain;
    background-position: center center;
    background-repeat: no-repeat;
    width:100%;
    min-height:20vh;
}

.video-container video {
  /* Make video to at least 100% wide and tall */
  min-width: 100%;
  min-height: 100%;

  /* Setting width & height to auto prevents the browser from stretching or squishing the video */
  width: auto;
  height: auto;

  /* Center the video */
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}

Answer: If I remove the z-index from the inline style on the test button, and create a style rule for mt-5 (I picked that as it was undefined in the example, you can add the styling as a different class if needed) as follows then the button remains visible over the video:
.mt-5 {
    position: absolute;
    top: 5px;
    z-index: 10;
}

obviously depending on the z-index of other items on the page you may need to adjust this, but the key was adding the position and top attributes
Comment: Perfect, thanks for steering me in the right direction

Overlaying text on video element


Do all triads keep their function when inverted?

Question: Then I suppose another question would be, when you add the 7ths over the triads can those also be inverted without losing their harmonic purpose?
thank you
Answer: No. A super easy example is a I6/4 chord is often predominant.
This page lists just the functions of some 6/4 inversions:
http://academic.udayton.edu/PhillipMagnuson/soundpatterns/diatonicII/secondinv.html
The cadential 6/4 is probably the most obvious one to recall from music from the classical period. It is the I chord in second inversion. From the page linked above (emphasis mine):

In spite of the fact that this chord resembles tonic (containing ^1 - ^3 - ^5), in reality it has nothing in common with the tonic function to the ear. It does not provide stability and, in fact, has a strong need to resolve to dominant.

Regarding seventh chords, one example I can find is that the third inversion of the dominant seventh chord is often resolved to the second inversion of the tonic, so that makes the third inversion of the dominant seventh no longer necessarily dominant.
Inversion of a triad specifically speaks to which note of the triad is the lowest sounding. If the root is the lowest sounding note, the chord is not inverted. The lowest to highest order of the other notes of the triad beyond the lowest sounding note is often called the voicing of the chord. I'm not aware of a change in voicing changing the harmonic function, but a voicing change can have a more melodic function.
Comment: It may be helpful to note that many schools actually label this a V64, the logic being that the 6 and 4 above the bass are accented non-chord tones that resolve to the 5 and 3 above the bass, respectively. In this view, this chord isn't predominant, it's just dominant.
Comment: @ToddWilcox Also a V64. But it's not as confusing as it may seem; context clarifies it. If it's at the end of a phrase, approaching a cadence, and it resolves to a V in 53 position, we know it's a cadential 64.
Comment: Ok thanks and assuming that the bass is in the root position could you switch all the other notes as much as you like without any problems?
Comment: @Richard Then what is a V chord in second inversion called? (e.g., D G B in the key of C major)


Preventing webform saving in database

Question: Is there a way to prevent a webform submission to be saved in the database?
I have added a custom submit handler to my webform but I don't want to save in the DB but send it to an external webservice.
<code>function MY_MODULE_form_alter(&$form, $form_state, $form_id)  {

    if ($form_id == "MY_WEBFORM_ID")  {
        $form['#submit'][] = "_MY_MODULE_webform_handler";
    }

}

function _MY_MODULE_webform_handler($form, &$form_state) {
    // How do I stop data being saved in DB?
}
</code>
How do I do that? Thanks!
Answer: There is a module that's compatible with the 7.x-3.x branch that gives you the option to do just that:

This module adds the ability to choose whether a webform should be saved to database or not. Within settings of each webform you can choose the option.

There is also a related issue in Webform's queue that is tracking the progress of getting the functionality into the webform module.
If you don't want to use the sandbox module, I'm sure you could check out the source and see what they're doing differently from what you have posted above.
Comment: There is a better, more complete answer to this question. As @Teknotica pointed out, the sandbox module deletes the submission after the fact, which doesn't seem like a good solution. And according to an issue in the queue, it doesn't even do that correctly (doesn't use `webform_submission_delete()` which means remnants could be left over). I'll try to post a more complete answer that summarizes the discussion in [290448](https://drupal.org/node/290448) when I get a chance. Or someone else should feel free to do the same.
Comment: Basically, once the submission is saved they remove it from the db. Fair enough :)

Preventing webform saving in database


Aggregating JavaScript generates errors and breaks JS functionality

Question: My website is working well but I was required to aggregate CSS/JS by enabling the system.performance.js.preprocess config key.
Once the JS code is within one single file I got some errors that doesn't show up when JavaScript is not aggregated:
Uncaught TypeError: Cannot read property 'bindAjaxLinks' of undefined
    at HTMLDocument.<anonymous> (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:579)
    at HTMLDocument.dispatch (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:3)
    at HTMLDocument.q.handle (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:3)
    at Object.trigger (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:4)
    at HTMLDocument.<anonymous> (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:4)
    at Function.each (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:2)
    at r.fn.init.each (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:2)
    at r.fn.init.trigger (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:4)
    at initContextual (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:500)
    at js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:532
Uncaught TypeError: $autocomplete.autocomplete is not a function
    at Object.attach (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:899)
    at js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:174
    at Array.forEach (<anonymous>)
    at Object.Drupal.attachBehaviors (js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:171)
    at js_gQksidT9DzO4kWsJTVsAaOllA_i35znbvgoaoo5Ut8c.js:356
    at HTMLDocument.t (js_BKcMdIbOMdbTdLn9dkUq3KCJfIKKo2SvKoQ1AnB8D-g.js:4)

This breaks the entire JS functionality of my site like drop-down menus and slideshows.
I'm using a custom theme based on Acquia's Cog. My theme looks like this:
name: 'My Theme'
type: theme
description: 'Custom Cog subtheme for my website.'
core: 8.x
base theme: cog
libraries:
  - mytheme/fonts
  - mytheme/fontawesome
  - mytheme/global_styles
  - mytheme/slick
regions:
...

And my theme's libraries file:
global_styles:
  css:
    theme:
      css/styles.css: {}
  js:
    js/dist/scripts.js: {}

The js/dist/scripts.js file is a JS file built with npm and gulp.
I have read in other answers this may be caused of undeclared dependencies since the undefined variables could be loading before the Drupal ones. I tried to split it into another library and set dependencies like this:
global_scripts:
  js:
    js/dist/scripts.js: {}
  dependencies:
    - core/drupal
    - core/drupalSettings
    - core/jquery
    - core/jquery.once

But there's no effect at all. Any hints on how to solve this?
Comment: Unfortunately that's a too broad question that can't be debugged from afar. I'd suggest you'd be debugging this yourself systematically by removing your libraries one by one until the error is gone. Then in the matching file remove every function one by one. Then you'll know.
Answer: This issue is usually -- but not always -- because someone has written Javascript without adding semicolons in the appropriate places. JS is valid without them but only when there is also a line-end at that point. Many JS preprocessors remove line breaks, so making the JS invalid.
This can be resolved by examining the JS source for missing semicolons and adding them; a good JS IDE will be able to guide you as to where.
Another issue that sometimes occurs is when the JS code has not been properly context-wrapped. Drupal standard practice is to include a function() { js(); code(); here(); } (); wrapper around code blocks because that limits the scope of names to that block; without it, the scope could be global and thus can be interfered with by other blocks of code.
The Drupal solution, which also solves another problem, is to use the "Drupal.behaviours". construct. Check the Drupal JS files for that string for examples.


Firebase Audiences not reflecting data in cvs inform

Question: We are using firebase in one of our apps and in the Firebase server we can see the demographic data without problems, but when we download the informn as a .csv there is no data in the percentage of male in a age from 18-24, 25-34....
Answer: It seems like it is working fine as demographic data is not exported from Firebase to BigQuery due to privacy issues, which means the data exported to CSV may also not contain it. This question provides some insight on the same issue.


What's the qualitative difference between wooden and plastic recorders?

Question: Are wooden recorders better than plastic recorders? Do they have better tone or are more playable? Are these differences noticeable for cheap recorders?
What are the advantages of plastic recorders?
I'm aware of this question:
Why do wooden woodwinds sound better than plastic?
The given answer is interesting but doesn't exactly answer my question.
Comment: Seems a bit mysterious that nobody ever built a metal recorder (or maybe they did and I missed it).  After all, there's a reason recorder is 'blockeflote' and a flute is 'querflote.' They're not that different.  Anyway,  play some and buy the type you like.
Comment: Carl: the aluminium recorder, by Orthwest, is a beautiful instrument indeed! I have one of his bird flageolets (in wood) --- he does very lovely & meticulous work.
Answer: The advantages of a plastic instrument are:

Less care necessary concerning maintenance; not wiping the recorder after playing will do no irreversible harm. This is likely the reason, that the head (i. e. mouth piece) is sometimes from plastic even if the body is made of wood: It is not recommend to be cleaned due to the danger of damaging it.
Less sensitive towards humidity altogether - especially important for open air playing, when it starts raining.

Disadvantages:

not the real thing (in contrast to the linked answer I've never seen a professional on a recorder with a non-wooden head)
a fall to a hard floor may render it useless beyond repair

Ask the teacher for recommendations: In my superficial opinion there are good quality plastic recorders (no longer exactly cheap) as well as awful wooden ones.
Answer: The material of a wind instrument actually makes only a marginal difference to the sound.  There's no reason a very good recorder can't be made of plastic, and some are.  Of course, ALL cheap-and-nasty ones are made of plastic!
Comment: And some cheap-n-nasty recorders are made of wood!


Excel VBA - Is it possible to call sub on error?

Question: I've been searching, but I can't really find something that answers this question.
I'm getting an error and I know whats causing it and it not really a problem. It just needs to run another sub before running the next line of code if this error occurs. So that made me wonder:
Is it possible to do something like this:
On Error Call Sheet1.TestSub

Thanks in advance!
Answer: You could try something like this:
Sub test()
On Error GoTo 10
Set a = b
MsgBox ("still going")

Exit Sub
10:  test2
Resume Next

End Sub

Sub test2()
MsgBox ("Error")

End Sub

Answer: No.
The best you can do is to branch to a separate section of code to handle the error and then branch back to the line immediately below the line raising the error. (if you know what that line is!)
Comment: I know the line, so if I make an error handler, call the sub in there and then branch back( `GoTo 0` ) is the best way to do this?
Comment: That is the only easy way....you need a **label** on the line below the "raiser".  Then **GOTO* that label.
Comment: Ah I see, thank you very much! will accept answer as soon as 10 minutes are over ;)
Comment: **Update your post if you need more help.**


Linear programming exercise

Question: I want some help for the following exercise

I know that the leaving variable is the basic variable associated with the smallest nonnegative ratio with the strictly positive denominator. I can't understand how the current basic variables ($x_5$, $x_6$, $x_7$, $x_8$) are matched with the equations.
Answer: Let $x_r$ and $x_j$ denote the leaving and entering variables respectively.  ($r$ stands for "row"; $j$ runs through columns.)
Write the simplex tableaux.
$$
\require{enclose}
% inner horizontal array of arrays
\begin{array}{cc}
% inner array of minimum values
\begin{array}{r|r|r|r}
\text{basis} & a_j & b & b/a_j \\
\hline
5 & 1 & 4 & 4 \\
6 & 5 & 8 & 8/5 \\
\to7 & 2 & 3 & \enclose{circle}{3/2} \\
8 & * & 0 & -
\end{array}
&
% inner array of minimum values
\begin{array}{r|r|r|r}
\text{basis} & a_j & b & b/a_j \\
\hline
5 & 2 & 4 & 2 \\
6 & * & 8 & - \\
\to7 & 3 & 3 & \enclose{circle}{1} \\
8 & * & 0 & -
\end{array} \\
j=1,r=7 & j=2,r=7 \\
% inner array of minimum values
\begin{array}{r|r|r|r}
\text{basis} & a_j & b & b/a_j \\
\hline
5 & * & 4 & - \\
6 & * & 8 & - \\
7 & * & 3 & - \\
\to8 & 1 & 0 & \enclose{circle}{0}
\end{array}
&
% inner array of minimum values
\begin{array}{r|r|r|r}
\text{basis} & a_j & b & b/a_j \\
\hline
\to5 & 5 & 4 & \enclose{circle}{4/5} \\
6 & 6 & 8 & 4/3 \\
7 & 3 & 3 & 1 \\
8 & * & 0 & -
\end{array} \\
j=3,r=8 & j=4,r=5
\end{array}
$$
Fix $j$.  Observe that $r$ is the index which minimises $\{b/a_{rj} \mid a_{rj}>0 \}$.  (You may refer to a theoretical explanation for such choice.)

Linear programming exercise


How do I get in the habit of separating my words while singing?

Question: I sustain all my words together and would like to figure out how fix it.
For example if I sung "I can't wait" (quarter note, quarter, half) I would like to separate 'i' and 'can't' but I always leave them sustained and connected.
Comment: So you tend to be fond of legato phrasing while you sing. There may be a specific case of a piece of music that requires staccato singing but as a general rule of thumb, this should not be a bad thing. This may just be a stylistic thing that makes your voice YOURS.
Comment: It might be helpful to clarify the genre in which you're singing. From what I understand of it, choral contexts normally want total sustain, but with syllables differentiated by clear articulation of consonants. Is this really a question about "sustain" (what you do with your breath) or about articulation?
Comment: In general, it is not necessary to separate the words except as a matter of taste.  This rarely leads to ambiguity.  For example, you would not necessarily sing "I can't wait" differently from "Ike, aunt, wait!"  I'm posting this as a comment rather than as an answer because the ability to make these distinctions is a valuable skill.  It is, however, often overused to the point of breaking up the musical line.
Comment: @AndyBonner many choral conductors, however, insist on an overattentive observance of commas (of which, at least, there should not normally be one between "I" and "can't"), even to the point of calling for an actual inhalation at each one.  I have similarly been coached (by a woodwind player) to use the diaphragm for staccato articulation on repeated pitches that actually shouldn't have been staccato in the first place, much less rendered staccato by the breath.  Whatever one thinks of these choices stylistically (and I don't think much of them), one ought to be able to realize them if asked.
Comment: @CoolGuy Having listened to the track now: I think this becomes more a matter of dialing in your own personal idiom. I'd say it's very indebted to Old Time, and sustain is definitely an important part of that "[high lonesome sound](https://youtu.be/PoJkndLVcqM)." I think you just have to walk that fine line between "being yourself," sticking with what comes naturally, vs. exploring how you can broaden and tweak your style to your liking.
Comment: @phoog There's an argument that the larger the group of people singing or playing, the more articulation needs to be exaggerated, to remain clear despite the natural smearing-out of timing. (Of course, that's less important if all those people are so amazingly well-trained and technically adept that they can all use the exact same millisecond timing…)
Answer: Let's make your example a little longer in order to experiment with it, say, "I can't wait, for the day, you will be, here with me", all sung as 2 eighth notes and a fourth.
When I sing it as you describe, with each group of three words joined up, and a pause in-between the groups, it sounds like a standard line from a rock song. However, if I do the opposite, and sing the eighth notes staccato, and stretch the fourth note until it connects to the next eighth note, it reminds me more of a modern R&B song; the line takes on a different feeling, it has more attitude, especially with the stress that the staccato note gives to the "I" at the start of the line.
This little exercise already gives you two ideas to try: One, look outside your genre. Listen to how singers in different genres (and older vs recent music) use staccato or legato to phrase their lines. Practice singing songs from different genres that have interesting phrasing. (This is good advice in general; the most interesting musicians in any genre are the people who also listen to, and take influence from, other genres.)
Secondly, look at how the phrasing (both staccato/legato and dynamics) interacts with the lyrics. "I love you" sounds different from "I. Love. You.", or from "i love YOU"; each version conveys a different meaning. Use this to your advantage when singing, to turn your singing into a meaningful expression of the lyrics. (It's a well-known tip for jazz soloists: whatever your instrument, learn the lyrics to the songs you want to play.)
Answer: The specific case
In the specific instance of "I can't wait", use the "c" of "can't" to separate the words. In order to pronounce the letter C, the tongue briefly halts the flow of air. Extend that moment of haltedness before allowing air through to actually for the C. That is, the back of the tongue blocks the air at the very beginning of a C. Leave the tongue pressed against the roof of the mouth momentarily before allowing air through.
The general case

Practice speaking the phrases first. Enunciate each word in a careful, even exaggerated way, being especially conscious of leaving space (more than needed at first) between words.

Practice speaking the phrases on pitch, but not in rhythm. This is the same exercise as #1, except with pitches incorporated. Basically, put a rest between each note.

Practice singing slowly — enough so that the exaggerated spaces between words can be maintained without distorting the rhythm.

Practice singing in time. This will mean shortening the spaces between words, but which should be able to happen naturally now that their conscious presence has been practiced.
Comment: The articulation of the _c_ involves more than just the tongue.  The larynx of also involved, which is the difference between /k/ and /g/.
Comment: Oops!  My previous comment should say "the larynx _is_ also involved..."!
Answer: Take it slower.  Put an extra word between each word -  sing 'I-fish-can't-fish-wait'.
Then do the same, THINK the 'fish' but don't sing it.  Now, faster...
Think diction. Actually MOVE your lips, mouth etc. to create each sound clearly.
And don't rely on 'getting into the habit'.  It's YOUR brain, YOUR body.  Take control of what it does.


No matching function for call to 'init_pair'

Question: I use termux with clang. I've tried compiling the following code in clang but it outputs an error, mentioned in the title.
Here is the code.
#include <ncurses.h>
#include <string>
using namespace std;

int main(int argc, char** argv) {
  initscr();
  start_color();
  init_pair(1,argv[1],argv[2]);
  attron(COLOR_PAIR(1));
  for (int i = 3; i < argc; ++i) {
    printw("%s",argv[i]);
    attroff(COLOR_PAIR(1));
  }
  refresh();
}

Comment: init_pair requires three integers as input parameters: `int init_pair(short pair, short f, short b);` so you probably want `init_pair(1,atoi(argv[1]),atoi(argv[2]));`
Answer: The actual error message tells you what the problem is:
> clang -c foo.cc
foo.cc:8:1: error: no matching function for call to 'init_pair'
init_pair(1,argv[1],argv[2]);
^~~~~~~~~
/usr/include/curses.h:648:28: note: candidate function not viable: no known
      conversion from 'char *' to 'short' for 2nd argument; dereference the
      argument with *
extern NCURSES_EXPORT(int) init_pair (NCURSES_PAIRS_T,NCURSES_COLOR_T,NC...
                           ^
1 error generated.

The init_pair function uses short-integer parameters (not a char*).  You could make it compile by converting those char*'s to integer, e.g.,
> diff -u foo.cc.orig foo.cc
--- foo.cc.orig 2020-09-21 17:35:04.000000000 -0400
+++ foo.cc      2020-09-21 17:36:42.000000000 -0400
@@ -1,11 +1,12 @@
 #include <ncurses.h>
+#include <stdlib.h>
 #include <string>
 using namespace std;

 int main(int argc, char** argv) {
 initscr();
 start_color();
-init_pair(1,argv[1],argv[2]);
+init_pair(1,atoi(argv[1]),atoi(argv[2]));
 attron(COLOR_PAIR(1));
 for (int i = 3; i < argc; ++i) {
 printw("%s",argv[i]);

(though that's just a quick fix).


How to deal with badly behaved libraries that don't stop threads

Question: What are some workarounds when dealing with third party libraries that don't correctly clean-up threads when the library is shutdown?
Many libraries expose lifecycle methods, either explicitly or implicitly, for the code contained therein. For example, a web application framework exists within a web application context in a servlet container. When the context is created, the framework may start some threads, for various reasons.
Now, taking the example further, when the servlet container or the web application context is shutdown, the web application framework should terminate all these threads. Either the ExecutorServices created by the library should be shutdown, or some other means of stopping those threads should be enacted.
Worst case is that the threads are non-daemon threads. These would actually stop the termination of the Java process. But even if they are daemon threads, allowing threads to continue is probably bad practice. If (back to the example) the servlet container is embedded within other code that other code may continue to run with the threads still chugging away, which may cause problems.
There's no programmatic way exposed to stop these threads, so what can be done?
If you are using such a third party library, what are the ways to force existing threads to be shutdown?
Answer:
If you are using such a third party library, what are the ways to force existing threads to be shutdown?

In general, there is no safe way to do this that is guaranteed to work in all cases.  The closest you are likely to get to a safe solution is to use the ThreadGroup to enumerate all existing Threads, and use Thread.interrupt() to tell each thread to go stop.  Of course, there is no guarantee that the threads will pay attention, or that they will shutdown cleanly in response to an interrupt.
IMO, the best strategy is:

if the threads do not need to be shut down cleanly, then pull the plug on the JVM by calling System.exit()
if the threads need to be shut down cleanly to avoid the possibility of damage, then don't use the library ... or fix the problem yourself.
Comment: +1 You can run the library is a separate process which reduces the impact of killing the process. (Works for JNI libraries as well)
Comment: @Peter depends on the library of course... running in a separate process will make communication more difficult.
Comment: Thanks @Stephen . Yes, all threads can be retrieved, and their ThreadGroups, as described here: http://stackoverflow.com/questions/1323408/get-a-list-of-all-threads-currently-running-in-java . System.exit() only works when the library that was creating the threads is considered the 'first class' code for that process. It's no good if the library is simply *used by* the code.
Comment: @DanGravell It depends on whether killing everything to bring down the library is acceptable or not.
Comment: @DanGravell - I mean that the application should call `System.exit()`.  The 3rd party library can't be relied on to do anything.  I don't understand your point about "first class" libraries.
Comment: @Stephen I agree, it's just that the application may want to continue running, and the library isn't required anymore. Consider an OSGi container (this is what first prompted my question). In OSGi, when a bundle exits its Activator.stop() method all threads created by the bundle *must* have been stopped.
Comment: @DanGravell - as I said in the first sentence of my answer - *"there is no safe way to do this that is guaranteed to work in all cases"*.  If the library misbehaves, look for an alternative library ... or fix it yourself.
Comment: @Stephen Sure, and that's what clinched the answer tick (to be clear: I don't necessarily expect a catch all answer - as you said the way that thread interruption works precludes that).
Comment: just curious... does Microsoft's CLR handle this similarly?


Como rodar um crawler em Python com PHP

Question: Fiz um crawler com Python e executo ele por linha de comando:
python crawler.py

Assim que executo este comando ele me pede a palavra chave que será procurada e começar a rodar.
global keyword
keyword = raw_input('Keyword: ')

Esses dados são usados em uma plataforma Laravel/PHP. Mas eu gostaria de criar um botão tipo "Atualizar" para que o próprio usuário pudesse executar o crawler apenas clicando em algum botão e inserindo a palavra chave.
Comment: Todos os questionamentos e suposições ("se isso... se aquilo.. não seria melhor se...") que vc recebeu em comentários (e mesmo na resposta!) reforçam o fato de que a sua pergunta não está clara. Vc já recebeu uma boa resposta e até já a aceitou, por isso não vou votar pra fechar a pergunta como não clara. Mas no futuro, procure tomar mais cuidado e explicar direitinho a sua necessidade, ok?
Comment: Seria possível o *script* Python receber a *keywork* por argumento de linha de comando e executá-lo, no PHP, com a função `exec`? Algo como `exec("python crawler.py {$keyword}")`.
Comment: Porque não faz o crawler em PHP?
Comment: Concordo com o @GuilhermeNascimento, porquê forçar o uso de outra coisa e não fazer no Laravel com php?
Comment: @LucasLopes respondi, pode testar.
Comment: Só de curiosidade, não é melhor já fazer o crawler em PHP mesmo, se é pra usar no PHP?
Comment: @AndersonCarlosWoss executei o comando mas não funcionou. Coloquei a `$keyword = "urgente"` e depois executei a linha que você disse, mas não funcionou.
Comment: @LucasLopes você leu http://pt.stackoverflow.com/a/180360/3635 ?
Comment: @LucasLopes tinha um erro no script, troque fclose por pclose, editei a resposta.
Comment: Colega, a sua pergunta está bem confusa. Ela não deixa claro se a sua intenção de "botão para o usuário utilizar" seria em uma página Web ou numa interface gráfica no Python. Também não está claro se a sua dificuldade é na integração do PHP com o Python ou no uso do Python em si (entrada de dados direta pelo usuário versus recebimento de dados via linha de comando). Talvez sem querer ela leva o foco para o crowler (cujo código e objetivo nem constam na pergunta, porque talvez não seja mesmo importante), quando que me parece que o foco deveria ser na integração entre as linguagens.
Answer: Se você estiver criando o crawler ou se ele for simples, talvez seja melhor escrever totalmente em PHP, mas é apenas uma sugestão.
Agora se quiser enviar um "input" para outro programa ao invés de usar system, exec ou shell_exec, você deverá usar popen, que lhe permitirá "conversar" com o stream, ou seja poderá enviar comandos para programas como telnet (só um exemplo)

Não é necessário fgets ou fread, o próprio popen quando fechado envia o resultado para output (STDOUT), se quiser capturar a saida pode então usar ob_start

Um exemplo deve ficar assim:
<?php

$input = 'Comando enviado';

$dir = dirname(__FILE__); //Apenas para pegar a pasta relativa

$comando = 'python ' . $dir . '/crawler.py'; //Gera o comando

$handle = popen($comando, 'w'); //inicia o processo

fwrite($handle, $input);

pclose($handle);

E um exemplo de Python (aqui eu uso o 3.6, mas é só trocar o input por raw_input se for Python2):
import sys

keyword = input('Keyword: ')

print(keyword)

Todavia se for usar com outros programas ou sistemas talvez você enfrente algum problema, então para windows talvez você possa usar start /B e like-unix possa usar 2>&1, assim:
<?php
$dir = dirname(__FILE__);

$comando = $dir . '/crawler.py';
$input = 'Olá mundo!';

if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
    $comando = 'start /B python ' . escapeshellarg($comando);
} else {
    $comando = 'python ' . escapeshellarg($comando) . ' 2>&1';
}

$handle = popen($comando, 'w'); //inicia o processo

fwrite($handle, $input);

pclose($handle);

Como rodar um crawler em Python com PHP


Coming up with short "magical" proofs

Question: I was reading the solution to this problem:
Prove that $f(n) = 2n$ is the only non-constant solution to $2f (m^2 + n^2 ) = (f (m))^2 + (f (n))^2 .$
The solution used these identities, pulled out of the blue:
$(5k + 1)^2 + 2^2 = (4k + 2)^2 + (3k − 1)^2 ,$
$(5k + 2)^2 + 1^2 = (4k + 1)^2 + (3k + 2)^2 ,$
$(5k + 3)^2 + 1^2 = (4k + 3)^2 + (3k + 1)^2 ,$
$(5k + 4)^2 + 2^2 = (4k + 2)^2 + (3k + 4)^2 ,$
$(5k + 5)^2 + 0^2 = (4k + 4)^2 + (3k + 3)^2 .$
and proceeded to use strong induction to prove the hypothesis.
As I have spent more and more time studying mathematics, I see more of these "magic" solutions in which some obscure identity or property is pulled out of nowhere and used to facilitate a proof...often, multiple such jumps are used in a proof...and these proofs are meant to be done in an hour or so. I feel discouraged by this, because I don't understand how to do these "magical" things. I feel like I could spend 10 years trying to solve this problem, and still fail, because I don't have magical powers.
How can I improve myself? How do I learn to come up with magical proofs like these? I feel like practicing problem solving is useless because I can solve all the easy ones...but the moment a "hard" problem comes, I can't solve it at all. So I read the solution, and understand it, but the next problem is completely different and uses a different magical identity and so I haven't actually learned anything.
I'm sorry for ranting here, but I feel hopeless. I'm 19 and some people my age are solving these problems easily. Do I lack mathematical ability genetically or is is something I can gain through practice? I am wondering if I am just wasting my best years studying mathematics when I don't have the genes for it.
EDIT: For those asking why I couldn't just use a substitution...the actual problem was . to find all solutions, not just $f(n)=2n$
Comment: I don't see why anyone would solve this by citing these identities.  You can just evaluate both sides with $f(n) = 2n$ and see that they come out the same.
Comment: Hey now--I'm 19 and I'm nowhere near close to solving that problem.  `;)`  The important thing to keep in mind is that, no matter your skill level, there will *always* be someone better *and* someone worse than you in at least one topic.  Don't focus on being the best--focus on doing your best and being the best comes naturally.
Comment: Thank you so much for not using the word 'mathemagic' in your post
Comment: I think you should not attempt to train yourself to produce magical proofs. As you have already seen, other people learn very little from these. You should train yourself to produce understandable proofs that teach people things.
Comment: Can't you just prove it directly? It seems like if $f(n)=2n$ then $2f(m^2+n^2)=4m^2+4n^2=(2m)^2+(2n)^2=f(m)^2+f(n)^2$.  Do you want to prove that $f(n)=2n$ is the only such solution?
Comment: @Ethan Thank you for changing the title. I've added the tags soft-question and proof-writing, as I think they describe more accurately the idea of the question.
Comment: These particular "magical" relationships come from multiple factorizations of Gaussian integers. Gaussian integers often come up when dealing with problems about summing two squares.
Comment: There are three main rules in mathematics: you can't win, you can't cheat, and the stack is rigged against you. So smile! Because tomorrow will be even worse. Which is why you should just relax, and enjoy today. But just like a man can never give up on women just because he was unlucky so far, so a true mathematician could never conceive of letting go of his passion for this form of art, no matter how rare and underwhelming his realizations might be. Cheers! :-)
Comment: When I'm trying to write a proof of something, and I manage to get the result I usually go back and start looking for weird identities and shortcuts etc. that I could use to write a short "elegant" proof. IMO I think that's just what a lot of authors do.
Comment: @Thomas it seems it isn't the only such solution. Haven't looked through, but there are the trivial $f(n)=0$ and $f(n)=1$. It might be the only non-constant solution, but I haven't tried.
Comment: But it helps to understand the problem @Ethan. Is this a case where the proof is a "joke" - there is a one line proof of what he stated - or is it a case where it is necessary?
Comment: @ThomasAndrews The latter. I edited the OP.
Answer: There are ways to learn how to come up with "magic tricks", some are described in Polya's books. But perhaps that is not the right approach for you. Grothendieck, arguably the greatest mathematical genius of last century, describes this approach as thinking of "a theorem to be proved as a nut to be opened", and says that it is not his. He likens his approach to the rising sea where the theorem is "submerged and dissolved by some more or less vast theory, going well beyond the results originally to be established". Once you get a solution from such a comprehensive study it is sometimes possible to simplify and shorten it into a few lines that look like "magic". Many proofs and solutions that you will encounter will look this way, but that's not how their authors found them.
As Thomas Andrews pointed out, if you knew of Gaussian integers and saw this functional equation you would probably think of applying their properties to it, and come up with these identities. Maybe studying mathematical theories and methods systematically would suit you more than chasing after individual problems with clever tricks. I'd also like to point out that according to studies kids who believe in "genetic abilities" are less likely to work hard and more likely to give up quickly when things don't go easy for them. But working hard is always a must, so those "abilities" often become self-fulfilling prophecies.
There is more than one way to be a mathematician, you'll have to find yours, and 19 is still very young. If you like mathematics try different areas, different styles before you decide to give up.
Comment: Thank you very much for this comment. Your point about giving up quickly due to a belief in genetic abilities spoke to me. I realize now that I have to stop whining like a little bitch and start working harder.
Comment: As regards the simplification of a proof, I like to say that the first stage is in finding some proof. Even a long, ugly proof. One then proceeds to find a prettier proof. This can sometimes be the lion's share of the work. Finding elegant, "magic" tricks to quickly solve a problem comes mostly from experience and breadth. Math has a vast array of interconnections, and it should not be underestimated how a working knowledge of a field and topic far from your specific interests can open new avenues of discovery in the topics you most enjoy.

Coming up with short "magical" proofs


Measure set that intersects everything

Question: Does there exists a subset $X$ of $[0, 1]$ with (Lebesgue) measure $0 < \epsilon << 1$ such that for any open set $O$, $\mu(O \cap X) > 0$?
Comment: Perhaps try something like around each rational $p/q$ in lowest terms, the ball of radius $q^{-k}$.  By choosing $k$ large enough, the measure is sufficiently small.  But every open set contains rationals, so the intersection will be an open interval.
Comment: @MichaelBurr what you said works, except you have to ignore $0,1$ since those have $q=1$ and taking $k$ large doesn't help.
Comment: @MichaelBurr Oops! I got confused by the title, which just said "intersects everything"; didn't notice that farther down he changed it to "intersects everything in a set of positive measure".
Comment: You wrote "any open set $O$" but I'm sure you meant "any nonempty open set $O$".
Answer: Let $\epsilon\gt0$. Since $\mathbb Q$ has measure zero, there is an open set $X$ such that $\mathbb Q\subseteq X$ and $\mu(X)\lt\epsilon$. Since $\mathbb Q$ is dense, $X$ is a dense open set. If $O$ is any nonempty open set, then $O\cap X$ is a nonempty open set, therefore $\mu(O\cap X)\gt0$.
(You wrote "any open set $O$" but you must have meant "any nonempty open set $O$".)

Measure set that intersects everything


A non standard way to a probability problem

Question: We have teams $A$ and $B$.Every team has equal chance to win. A team wins after they have won $4$ matches. Team $A$ won the first match, what is the probability, that team $B$ won the whole game.
My try:
So team $A$ needs $3$ more wins to win the game. Team $B$ needs $4$ more wins to win the game. So the winner will be determined in maximum of $7$ games. So now I tried to do it my own way (I dont know if it is usual to do it this way)
Let's say that we are looking at the wins of team $A$. (They need $3$ more wins).
$$...A_i,...A_j,...A_n$$,
where $3$ dots symbolize the wins of team $B$. So $$(i-1) + (j-i-1) + (n-j-i-1) \leq 3 $$
(Because there must not be more than 3 losses, because at 4 team $B$ wins the game )
we get:
$$n-i \leq 6 \quad \text{and} \quad 0<i<n $$
If we look what integer tuples can satisfy the upper inequalities we get: $$N = \{(1,6),(2,6), (3,6),(4,6),(5,6),\\(1,5),(2,5),(3,5),(4,5),(1,4),(2,4),(3,4),(1,3),(2,3),(1,2)\}$$
Where $N$...possible winnings of team $A$
So we can count the number of elements ($15$) an that would be our number in the numerator, where in the denominator is the number of elements in our sample space.
To calculate the sample space I would do:
$$|\omega| = 1 + (\binom{4}{3} - 1)\\ + (\binom{5}{3} - \binom{4}{3} - 1)\\ + (\binom{6}{3} - (1 + (\binom{4}{3} - 1) + (\binom{5}{3} - \binom{4}{3} - 1)))\\ + (\binom{7}{3} -(1 + (\binom{4}{3} - 1)+ (\binom{5}{3} - \binom{4}{3} - 1) + (\binom{6}{3} - (1 + (\binom{4}{3} - 1)+ (\binom{5}{3} - \binom{4}{3} - 1)))) )$$
I guess we could also write this with a recursive formula. However we get $|\omega|=35$.
(What I did here is that $1$ is for $3$ consecutive wins, $\binom{4}{3} - 1$ are other possible matches in 4 games and so on.)
So if my procedure is correct the probability is $$P(\text{team B wins the whole game}) = 1 - \frac{|N|}{|\omega|} = 1 - \frac{15}{35} = \frac{20}{35}$$
However is my process atleas partially correct (I do not know the solution).
Comment: An easy way to solve the problem:  Assume all $7$ games are played (even if a winner is decided ahead of game $7$).  $B$ wins the series if and only if $B$ wins at least $4$ out of thee remaining $6$ games.
Comment: That answer does not make sense.  Clearly, $A$ has the advantage here, so the probability that $B$ wins must be $<\frac 12$.
Answer: Your approach looks right, but I think you made a couple mistakes when calculating $N$. First, you erred with your initial inequality. It should be
$$(i-1)+(j-i-1)+(n-j-1)\leq 3$$
$$\implies n\leq 6$$
This result should make sense because if you have $7$ games then clearly $B$ would have $4$ wins since $A$'s $3$rd win is always the last game.
The second mistake you made is when calculating $|N|$. You must find all triples $(i,j,n)$ that satisfy the inequality $n\leq 6$ (not just tuples $(i,n)$). This can be done with some combinatorics (or just brute force). However, one must consider the fact that two runs of games of different length do not have the same probability of occuring. For example, a game of length $6$ would have a probability of $2^{-6}$ of occuring while a game of length $5$ would have a probability of $2^{-5}$ of occuring.
So we will not actually solve for $|N|$, but rather a weighted sum of number of triples.
We will first fix $n$ as some integer that is at least $3$ (this is because we need at least $3$ games to get $3$ wins) and at most $6$. Then there are $n-1$ slots left before the $A_n$th game. There are $\binom{n-1}{2}$ ways to choose which of these slots get the other $2$ $A$ wins. So our probability becomes $\sum_{n=3}^6 \binom{n-1}{2}2^{-n}$
To actually solve this sum, we can use a related identity from putnam 2020 A2. Our sum is equivalent to
$$=\sum_{n=0}^3 \binom{n+2}{2}2^{-n-3}$$
$$=\sum_{n=0}^3 \binom{2+n}{n}2^{-n-3}$$
$$=2^{-5}\sum_{n=0}^3 \binom{2+n}{n}2^{2-n}$$
$$=2^{-6}\binom{5}{3}+2^{-5}\sum_{n=0}^2 \binom{2+n}{n}2^{2-n}$$
$$=2^{-6}\binom{5}{3}+2^{-5}4^2$$
$$=\frac{10}{64}+\frac{1}{2}$$
$$=\frac{21}{32}$$
Hence, the probability of $B$ winning is $1-\frac{21}{32}=\boxed{\frac{11}{32}}$

On a side note, while we never used the value of $|\omega|$, I would like to point out a more elegant approach to find its value since you did compute it. Consider all permutations of $3$ $A$'s and $4$ $B$'s. For each of these cut off from the $3$rd $A$ or $4$th $B$ depending on which comes first. These will each give new unique sequences of wins, so the total is just $\binom{7}{4}=35$.
Answer: To more simply calculate the odds of this problem, we can relate it to flipping a coin. A heads gives team $A$ the victory, while a tails gives team $B$ the victory. To solve the problem, we are looking for the probability that at least $4$ of $6$ flips are tails. This is not difficult to calculate.
Total possible outcomes: $2^6=64$
6 tails: $_6C_6=1$ way; $\dfrac1{64}$
5 tails: $_6C_5=6$ ways; $\dfrac{6}{64}$
4 tails: $_6C_4=15$ ways; $\dfrac{15}{64}$
Total: $\dfrac{1+6+15}{64}=\dfrac{22}{64}=\dfrac{11}{32}$. This gives a $34.375\%$ chance that team B manages to win the tournament.


How can I tell if I (or other male singers) are using falsetto or head voice?

Question: There are some related questions:

What is the difference between male head voice and falsetto? (but the accepted answer answers a different question)
How to differentiate between head voice and falsetto? (but it's not had a lot of attention)

As a novice singer one thing I'm trying to do is figure out my voice, in terms of my range and where I break between registers.
I always thought falsetto meant "really high squeaky" i.e. allowed you to reach notes much higher than normal/proper singing but I get the impression this isn't the case?
I struggle to tell when I "go high" if I am falsettoing or not - or if it even matters?
I'm interested in practical ways to tell the difference when singing or listening to other people singing, as well as in any description on their mechanical differences. Note, this is focused on male singers.
Answer: If you are singing in falsetto, you will notice that you won't need to exhale as forcefully to sing high notes. You should also sense a relaxation in the muscles that control your vocal chords. You will also be able to sing high notes much more quietly when singing in falsetto.
There is a distinct and recognizable physiological shift in the mechanics of the vocalization process when we switch to falsetto. Most people can feel this shift as it takes place.  This altered process of vocalization will also create a different tone.
In order to sing higher notes, it is necessary to lengthen and stretch the vocal chords (like tightening a guitar string). The tighter vocal folds will vibrate faster and thereby produce a higher sound frequency. Every singer will reach a point where their vocal chords are at maximum length (stretched to the max).
But alas, there is a way to eke out a few more "false" higher notes by switching to falsetto. Falsetto allows us to sing higher notes because the action of the vocal chords is altered in a way that allows a different part of the vocal anatomy to vibrate at a faster rate than the maxed out main vocal folds.
When we switch to falsetto, the vocalis muscle relaxes allowing the cricothyroid muscles to exert more tension on the vocal ligaments. During the use of falsetto voice, the main vocal membranes are relaxed and a faster vibration is permitted to occur in the vocal ligament which has now been allowed to stretch tighter than it could before it was released by relaxation of the vocalis muscle.
This relaxation of the vocalis muscle also creates a situation where the vocal folds are not drawn together. Therefore air can more easily and freely pass across the vocal chords and vocal ligaments because you don't need the air pressure normally required to push through the vocal folds. Since less air pressure is required, you can sing high notes in falsetto at lower volumes.
For most male singers, falsetto will sound breathier, not as loud, not as present, not as dynamic, and not as rich.  Although there are a few exceptional male singers who can deliver quite a rich and robust sound using falsetto, most will sound a little thinner in falsetto.
It is said that with practice, one can blend some falsetto with head voice and learn to transition more smoothly.  But for most male singers, there will be a discernable loss in the richness of the tone when singing in falsetto verses head or chest voice.
Here is a short YouTube video that illustrates the shift into falsetto in a male voice.  YouTube Video - male falsetto
The Beatles used falsetto often in many of their popular songs.  In this video you can hear Paul McCartney switching back and forth between head voice and falsetto between 3:20 and 3:38.  Also the background vocals are being sung in male falsetto.  Paul McCartney in Let It Be on YouTube
MORE EXAMPLES MALE SINGER SWITCHING INTO FALSETTO:
John Mayer Very clear example of switch into falsetto at 3:22
Elton John Tiny Dancer  In the chorus he switches in and out of falsetto to hit the highest notes.  Watch starting at 2:24 through the chorus.
Elton John Rocket Man Several examples appear in the verses and chorus.  Listen at 2:09-2:13 and again at 2:37-2:41 as he switches into falsetto to hit the highest note.  Again at the end of the song he uses falsetto on "long long time" to hit the highest note.
Billy Joel Leave A Tender Moment Alone In this song Billy Joel continually goes in and out of falsetto to hit the highest notes.  Prime example from 1:29-1:44
Cover of Marvin Gaye Hear great example of switch to falsetto at 5:03 - 5:09
Comment: Thank you for adding the examples.  But in the first example, the guy is too annoying for me to make it through the video.  The second example has octave jumps, so the OP's question would be ridiculously easy to answer.
Comment: My "top voice" certainly is a lot clearer/purer, it's perhaps reminiscent of a choirboy-voice. Which sounds like the description of falsetto but it's not airy to my ear, and I have reasonable dynamics i.e. I can vary the volume quite a lot maybe as much as my chest voice. I wouldn't care but I've seen warnings that you need to know which register is in use to train it effectively.
Comment: @Mr.Boy When shifting from head voice to falsetto, you might sense a shift in placement towards the front of your face.
Comment: @aparente001  Okay I added some more examples.  Tried to find some from the great R&B Singers like Lionel Richie and Marvin Gaye but they have such a rich high end that it's difficult to tell when or if they switch into falsetto.
Answer: Head voice is a transitional voice using both chest voice and falsetto mechanisms.  It's usually employed in the character of a lightened chest voice so it still has the "male tinge" to it.  It's probably the main upper register tool for the lyric tenor in contrast to the dramatic tenor which uses a stronger bout of chest voice.
"Reinforced falsetto" is a mixed voice type that instead is a falsetto solidified with chest voice components in its lower range.  It is a countertenor tool to avoid breaking character when going lower from a pure falsetto (which some but not all countertenors employ).  So this form of mixed voice use is sort of the antithesis of head voice: also employing both mechanisms, but from the principal vocal configuration of falsetto rather than chest voice.
Depending on how experienced a singer is, the transition may be entirely smoothly (particularly when singing at moderate volume) and hard to pinpoint.
Answer: On some singers it can be hard to tell,,,
The difference especially on bass and baritones I find is very easy to spot,, Falsetto has a totally different tone to it.. More breathy and airy,, You can with practice get a strong loud falsetto but it always sounds different than connected headvoice..
As Rockin Cowboy said,, the difference is in teh mechanics.. Falsetto is disconnected chords,, connected headvoice is as the name implies connected vocal chords.. THe latter is very difficult for an untrained singer,, it takes a lot of practice to get the control and the airpressure right to maintain connected chords when you go through your passaggio into your headvoice.. Too little pressure and the voice flips into falsetto,, TOo much pressure and your start to strain, shout and the larynx will often rise... Do that a lot and you will damage your voice in the long run...


Trying to place listbox in the middle of the page, with the scrollbar on the right

Question: I'm using a listbox with a scrollbar with Tkinter in python. I'm trying to put the scrollbar on the right of the page and allow it to expand if the user expands the window, and also have the listbox placed in the middle of the window, but for some reason the listbox is just stretching to the right and bottom of the page permanently, even when its not expanded
Here's my code, thanks for any help in advance.
from tkinter import *
import tkinter as tk

class SeaofBTCapp(tk.Tk):

    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)
        container = tk.Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)
        self.frames = {}
        for F in (StartPage,Task):
            frame = F(container, self)

            self.frames[F] = frame

            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(StartPage)

    def show_frame(self, cont):
        frame = self.frames[cont]
        frame.tkraise()
        frame.winfo_toplevel().geometry("1024x720")
        frame.configure(bg='#333130')

class StartPage(tk.Frame):

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

        global listboxz
        listboxz = Listbox(self,height='500',width='400')
        listboxz.place(x=10, y=120)
        scrollbar = Scrollbar(self)
        scrollbar.pack(side=RIGHT, fill=Y)

        listboxz.configure(yscrollcommand=scrollbar.set)
        scrollbar.configure(command=listboxz.yview)

class Task(tk.Frame):
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)

app = SeaofBTCapp()
app.mainloop()

Comment: Note that `width` and `height` of `Listbox` specify the number of characters per line and number  of lines respectively, not the number of pixels.  Your listbox will be too big to fit in the window.
Answer: To place something in the middle of the page with place() you need to use relx and rely, like this:
    listboxz.place(relx=.5, rely=.5, anchor='c')

Comment: thankyou very much, what do all of those do? relx, rely and anchor='c'
Comment: See [Place Geometry Manager](http://effbot.org/tkinterbook/place.htm).


Can the double stop E natural F sharp be played on cello?

Question: I'd like to find out if it is possible  to play the double stop of E natural and F sharp on the cello. Thank you
Comment: Why not change the tuning on one of the strings to accommodate this interval? http://en.wikipedia.org/wiki/Scordatura
Answer: I agree with Michael's answer. But there is another point of view :
If you are considering composing a piece with this chord, especially if it is to be played with the bow, I would advise you to consider having two cellos or two different string players forming it (for instance if it is with a sufficiently high E or F# to be played by a viola or a violin).
It is not only a matter of virtuosity, it is also one of composition quality, texture, sound quality and musicality.  If this chord is important in your piece, having two players will allow for more precision in intonation, easy adjustment of volume of each component, more control of transition from and to other notes, as well as attack combinations and sound richness that an instrument alone can have difficulty (or impossibility) to provide.
Also note that E, F, F# in the low registers (especially E_2, F_2, F#_2) are often troublesome notes on cellos because they can elicit parasite resonances (known as wolfs). So it may be a good idea to split them between instruments.
Comment: Great followup.  I totally agree that double stops should be used sparingly and knowingly for their specific effect when there is an alternative of using two players.
Answer: It will all depend on the octave -- the lowest E natural and F# are impossible since they both need to be played on the lowest string C (unless you want to tune the G string down to F#).  In higher octaves it ranges from "possible" (if using the thumb or playing in higher positions on lower strings) to easy.  If you'll be writing for double stops a lot, I suggest buying Donald Martino's String-O-Graph which lets you try out various positions on a strip of paper without needing a cello around.
If you don't have a string-o-graph, you may want to look at http://www.fransabsil.nl/archpdf/fingers.pdf which shows the distances for each instrument that are easily reached and are reached with a stretch.
Answer: The easiest way to play those pitches as double stops is as a minor 7th with the F# on bottom. Both F#2 – E3 and F#3 – E4 are quite easy. If you're looking specifically for the major 2nd with E on the bottom you are moving into much less common territory. E4–F#4 is almost certainly the easiest; an octave lower is quite a bit more stretch required unless it's played unusually high up on lower strings. In any case the stretch is the same as an 8ve double stop in the same position but with strings reversed. Having the higher finger on a lower string is definitely a bit more awkward, and definitely FAR less common. I wouldn't be surprised if some cellists tell you it's impossible. I would generally not use major 2nds in chamber pieces, and almost certainly not in an orchestral situation. If it's a solo piece, aimed at a virtuosic player comfortable with modern literature, then I think I might if the effect were desirable enough. In any case, you should give some time on either side of the double stop for the player to shift hand position (they will almost certainly need to use the thumb on the higher string).
As a 9th I would say this note combination is for all practical purposes impossible. I just tried it on my cello, and I can kind of do it, but it's very uncomfortable and I have relatively large hands. Best avoided.
Answer: So of course it depends on which E and which F sharp you want to play. Here are some examples:
E natural on the A string and F sharp on the D string: For this, you would use your fourth finger on the E and first finger on the F sharp. This is in 2nd position, if that means anything. I think this is the easiest one to play.
E natural on the G string and F sharp on the C string: You would then use 1st finger on F and 4th finger on E. This is in 3rd extended position.
There are various other ways to play it as you go down the fingerboard and the pitches get closer together. If you want to do this, then here are some steps to get a good fingering:

Find either the E or the F sharp first.
Then find the other note on a neighboring string.
Test the interval out with different fingering to find one that's comfortable and convenient
Roll with it! if If it turns out to not work, either start over from step 1 or step 3.


What is better for detection comments, split or substring

Question: I try to detect in C# Comments after ';'
Is it better to use Indexof and Substring or contains and split?
If i use index i get the ';' including all comments behind.
If i use contains and split i only get one comment but its less codelines.
            indexComment = 0;
            indexComment = line.IndexOf(";");
            if (indexComment >= 0)
            {
                commands = line.Substring(0, indexComment);
                comment = line.Substring(indexComment);
            }else
            {commands = line;}

VS
            if (line.Contains(";"))
            {
                commands = line.Split(';')[0];
                comment = line.Split(';')[1];
            }else
            {commands = line;}

Both codes works as expected but what would you prefer?
This is example code i want to detect
do something ;this line do something
x+5
;the line above add 5 to x

Comment: Neither of these is a good answer.  Parsing C# is a difficult process that isn't as easy as looking for a semicolon.
Comment: `IndexOf` will return the first occurrence of a semi-colon, so your use with `substring` just grabs the rest of the string after the first occurrence of the semi-colon. `split` seperates the string on every occurrence of a semi-colon and place it into an array. So, if you have semi-colons in the comments, `split` will move those into separate places in the returned array, you could always use `string.join` on the array returned from `split` ignoring the first index of the array. Please provide some example data and expected results.
Comment: As an example, your own posted code contains several lines where a simple check for the first `;` falsely detects comments.
Comment: You might be better off checking for real start-of-comment markers: `//` and `/*`. But still you need to skip these in string literals
Comment: Its not C# comments
its comment detection in c#
Comment: I believe comments will be ignore by the compiler at run time and you can not get that using either way.
Comment: Thinking that comments come after a semicolon is completely false. I think you don't take many possibilities into account.
Comment: It probably depends on the language you are parsing. Could you provide all the non-terminal rules which contain the semi-colon terminal? Do you have a rule that enforces a newline at the end of a statement? If not, do you want to ignore everything after the first semicolon (so maybe other valid statements)? And finally, why don't you use a parser generator, parser combinator or another parser toolkit?
Comment: Its not a langueage its a txt with commands(maybe a better instructions) and comments and its very difficult to read.
luckily all comments are marked with ; . After seperation i write line number /tab
command /tab comment to csv

The hole c# script works great and i have to do litte change and dont know split or contain
Comment: @maf what you describe is a language, if you look at it the right way :) A well-formed input can be considered a language, especially if it contains command (than there is a chance, it is a programming language).
If you used a parser, probably it would not be so "difficult to read". You should read up something about text processing, parsing and/or regular expressions.
Answer: The split seems better because builds the substrings for you.
Just add the Count parameter with 2, so if you have more than one ';', they will all be included in your comment variable.
And use a temporary variable to avoid splitting twice.
if (line.Contains(";"))
{
    string[] splitLine = line.Split(new char[] { ';' }, 2);
    commands = splitLine[0];
    comment = splitLine[1];
}
else
{ commands = line; }

Comment: Depends on the grammar of the parsed language. @maf do you have string/char literals in your language? If they can contain semicolons, this would fail.
Comment: why do you create a char array when you can use just `';'` or `";"`?
Comment: @Hawk Using the 'count' parameter requires the char array. It won't compile with just ';'.
Comment: if (line.Contains(';'))
works for this
Comment: This code sample fails on itself, because the semicolons in the strings would be considered the end of the line.
Comment: I looked at https://learn.microsoft.com/en-us/dotnet/api/system.string.split?view=netcore-3.1#System_String_Split_System_Char_System_Int32_System_StringSplitOptions_ which is .NET Core, where it exists. Sorry for confusion.
Comment: @SeanReid OP is not parsing a C# file. He did not provide the input format.
Comment: From the question I read it as him trying to find comments in C# code. Apparently he's since clarified in the comments he's trying to use C# to detect comments in an unspecified format.


Type '{ children: never[]; }' has no properties in common with type 'IntrinsicAttributes' when using material-ui with Typescript

Question: I'm new to typescript and trying to use an existing component  i.e tabs from material-ui.
SimpleTab.ts:
import React from 'react';
import { makeStyles, Theme } from '@material-ui/core/styles';
import AppBar from '@material-ui/core/AppBar';
import Tabs from '@material-ui/core/Tabs';
import Tab from '@material-ui/core/Tab';
import Typography from '@material-ui/core/Typography';
import Box from '@material-ui/core/Box';

interface TabPanelProps {
  children?: React.ReactNode;
  index: any;
  value: any;
}

function TabPanel(props: TabPanelProps) {
  const { children, value, index, ...other } = props;

  return (
    <div
      role="tabpanel"
      hidden={value !== index}
      id={`simple-tabpanel-${index}`}
      aria-labelledby={`simple-tab-${index}`}
      {...other}
    >
      {value === index && (
        <Box p={3}>
          <Typography>{children}</Typography>
        </Box>
      )}

  );
}

function a11yProps(index: any) {
  return {
    id: `simple-tab-${index}`,
    'aria-controls': `simple-tabpanel-${index}`,
  };
}

const useStyles = makeStyles((theme: Theme) => ({
  root: {
    flexGrow: 1,
    backgroundColor: theme.palette.background.paper,
  },
}));

export default function SimpleTabs() {
  const classes = useStyles();
  const [value, setValue] = React.useState(0);

  const handleChange = (event: React.ChangeEvent<{}>, newValue: number) => {
    setValue(newValue);
  };

  return (

      <AppBar position="static">
        <Tabs value={value} onChange={handleChange} aria-label="simple tabs example">
          <Tab label="Item One" {...a11yProps(0)} />
          <Tab label="Item Two" {...a11yProps(1)} />
          <Tab label="Item Three" {...a11yProps(2)} />
        </Tabs>

      </AppBar>
      <TabPanel value={value} index={0}>
     tab 1
      </TabPanel>
      <TabPanel value={value} index={1}>
     tab 2
      </TabPanel>
      <TabPanel value={value} index={2}>
     tab 3
      </TabPanel>

  );
}

and I've used inside homepage as below:
HomePage.ts:
import react , { useRef } from "react";
import SimpleTabs from '../Tabs/Tabs'

export default function Homepage(){
    const HomeheaderTabs = useRef<typeof SimpleTabs | null>(null);
    return(
        {HomeheaderTabs}

   )}

And this I'm using this homepage in the main page as below:
import React from 'react';
import Homepage from '../src/Components/HomePage/Homepage'

export default function App() {
  return (<>
    <Homepage>
      </>;);

}

I'm getting error in the return that this type has no children error.
I saw the below link, but I'm using material UI.
Typescript styled-component error: "Type '{ children: string; }' has no properties in common with type 'IntrinsicAttributes'."
Is there any solution for this?
Comment: I got the solution.Its because instead of   I was using
Comment: What you're returning in `HomePage.ts` seems very incorrect. That's not JSX.
Comment: Could you please suggest how to return it...as it was throwing error if I return the component directly
Answer: Make sure you are closing your components properly so in this case the '/' was missing from <Homepage /> as suggested by Hema


Logical AND, OR: Is left-to-right evaluation guaranteed?

Question: Is left-to-right evaluation of logical operators (&& ||) guaranteed?
Let's say I have this:
SDL_Event event;

if (SDL_PollEvent(&event)) {
    if (event.type == SDL_QUIT) {
            // do stuff
    }
}

Is this guaranteed to be the same as this?
SDL_Event event;

if (SDL_PollEvent(&event) && event.type == SDL_QUIT) {
    // do stuff
}

This can also be very important, let's say we have two requirements, a and b. Requirement a is much more likely to fail then b. Then it's more efficient to say if (a && b) than if (b && a).
Comment: A classic, important use for the sequencing implied by `&&` is testing for null pointers before use: `if (a != 0 && a->b != 0 && a->b->c != 0) { somefunc(a->b->c->d); }`.  The sequence is critical to avoiding core dumps.  (And I'm ignoring the Law of Demeter for the purposes of exposition!)
Comment: @Jonathan: I ignore it for the purpose of getting any work done!
Comment: These are not "comparison" operators.
Answer: Yes, it's guaranteed, otherwise such operators would lose much of their usefulness.
Important notice: this is valid only for the builtin && and ||; if some criminal overloads them, they are treated as "regular" overloaded binary operators, so in this case both operands are always evaluated, and in unspecified order as usual. For this reason, never overload them - it breaks a hugely important assumption about the control flow of the program.

Relevant standard quotations
Builtin && and || have guaranteed short-circuit behavior
§5.14 ¶1

Unlike &, && guarantees left-to-right evaluation: the second operand is not evaluated if the first operand is false.

§5.15 ¶1

Unlike |, || guarantees left-to-right evaluation; moreover, the second operand is not evaluated if the first operand evaluates to true.

If overloaded, they behave as "regular" binary operators (no short-circuit or guaranteed ordering of evaluation)
§13.5 ¶9

Operators not mentioned explicitly in subclauses 13.5.3 through 13.5.7 act as ordinary unary and binary operators obeying the rules of 13.5.1 or 13.5.2.

and && and || are not mentioned explicitly in these subclauses, so regular §13.5.2 holds:
§13.5.2 ¶1

A binary operator shall be implemented either by a non-static member function (9.3) with one parameter or by a non-member function with two parameters. Thus, for any binary operator @, x@y can be interpreted
  as either x.operator@(y) or operator@(x,y).

with no special provision for evaluating only one side or in a particular order.
(all quotations from the C++11 standard)
Comment: By the way, keep in mind that, if you have "simple" conditions (e.g. your second one) branching can cost more than evaluating the condition itself.
Comment: Conditions without side-effects can be moved anywhere the compiler likes. The compiler is allowed to eliminate a branch.
Comment: @MatteoItalia: it's _very_ important to note that if you override `operator&&` or `operator||` then it's treated like a regular function call, and the left-to-right evaluation is no longer guaranteed.[
Comment: Matteo Italia: `a` and `b` were hypothetical. They might've been `IsPrime(n)` and `IsEven(n)`, in which the right order is pretty obvious and serious savings can be made.
Comment: @nightcracker: sure, I was just pointing out a small but common misconception. :)
Comment: @MooingDuck: yep, that's really important indeed; added the remark and the relevant standard quotations.