Determine whether the following integral is convergent or divergent $\int^{2}_{0} \frac{1}{\sqrt[3]{x} (x+\sqrt{x})}dx$

Question: Please, help me to determine the following integral:
$$\int^{2}_{0} \frac{1}{\sqrt[3]{x} (x+\sqrt{x})}dx$$
As we know, this is the II order indeterminant integral. I've tried to use comparison test, and bound above the following function by $\frac{1}{x^4/3}$ but this one by the p-test is being divergent, and our integral is convergent for sure. How to proceed?
Answer: The function $f\colon(0,2]$ defined by
$$
f(x) = \frac{1}{x^{1/3}(x+x^{1/2})}
$$
is continuous, so the only possible issue is at $0^+$. But at $0^+$, we have
$$
f(x) = \frac{1}{x^{4/3}+x^{5/6}} \operatorname*{\sim}_{x\to 0^+} \frac{1}{x^{5/6}}
$$
so is integrable by comparison, since $\frac{5}{6} < 1$.

We used the fact that $x^{4/3}+x^{5/6} = x^{5/6}(1+x^{1/2}) = x^{5/6}(1+o(1)){\displaystyle\operatorname*{\sim}_{x\to 0^+}} x^{5/6}$ when $x\to 0^+$.
Comment: Or you could also bound $\frac{1}{x^{4/3}+x^{5/6}} \leq \frac{1}{2x^{5/6}} $, for $x\in (0,1)$. You can even do without the factor $2$ if you want simpler.
Comment: What does o(1) mean?
Comment: "Converging to $0$" [(Landau notation)](https://en.wikipedia.org/wiki/Big_O_notation#Little-o_notation). If you are not familiar with it, just use comparison -- the simplest being my comment above.
Answer: Substitute
$$x=\frac1u\implies dx=-\frac{du}{u^2}\implies \int_0^2\frac{dx}{x^{1/3}\left(x+x^{1/2}\right)}=\int_\infty^{1/2}-\frac{du}{u^2}\frac{u^{1/3}}{\frac1u+\frac1{u^{1/2}}}=$$
$$=\int_2^\infty\frac{u^{1/3}du}{u+u^{3/2}}\stackrel{\color{red}*}\le\int_2^\infty\frac{du}{u^{7/6}}$$
and this last integral clearly converges since $\;\frac76>1\;$ .
$\;\color{red}*\;$ This inequality follows from
$$\frac{u^{1/3}}{u+u^{3/2}}\le\frac{u^{1/3}}{u^{3/2}}=\frac1{u^{7/6}}\;,\;\;u\in (2,\infty)$$


If the Pearson correlation coefficient is small/weak, can it have criterion validity?

Question: The r value I have obtained is -0.190 and p = 0.410.
As scores on stress increase, scores on eating habits decrease.
I know from my textbook that criterion validity is about whether your measure is correlated with a relevant outcome.
In other words, criterion validity evaluates whether the measures under consideration is related to a concrete outcome, such as a behavior, that it should be related to, according to the theory being tested.
One would expect that if there is more stress, eating habits would turn downhill.
If the Pearson correlation coefficient is small/weak, can it have criterion validity?
Answer: One might consider this from several viewpoints.

(This is a knee-jerk answer, the sort that many of us would give if not thinking through the situation very deeply.)  A correlation of -.19 is far too weak to provide much evidence of criterion validity either for stress scores or eating habits scores.
It's necessary to view a scatterplot of the two variables, because the low linear association might mask a stronger nonlinear relationship.  This would be particularly relevant if theory suggested that such a nonlinear relationship existed, for instance if, beyond a certain level, greater stress were expected to affect eating habits much more strongly than was true at lower stress levels.
The finding does not support the criterion validity being assessed, but this research really hasn't given it much of a chance.  Statistical power in this situation is low; the confidence interval around the point estimate of -.19 is very wide, probably about [-.6, .2].  (From your results I'm guessing N ~ 22 and the standard error of r ~ .2.)  So results from this small sample leave plenty of room for a population correlation of -.5 to -.6.  Would such a result, if obtained via another sample, be sufficient given your knowledge of the two variables?  After all, one would hardly expect stress to explain everything about eating habits.


Is there a better way to connect to multiple BLE devices in Android?

Question: I am working on BLE (bluetooth) in Android. I have found information via Google. It seems Android can be connected to multiple BLE device by using multiple BluetoothGatt like the following pseudo code.
I have multiple BLE devices. I think I need to define multiple BluetoothGatt parameters first.
private BluetoothGatt mBluetoothGattA = null,
     mBluetoothGattB = null , mBluetoothGattC = null;

The First BLE device connection.
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address_A);
mBluetoothGattA = device.connectGatt(this, false, mGattCallback);

Try to connected to the second BLE device.
final BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address_B);
mBluetoothGattB = device.connectGatt(this, false, mGattCallback);

Am I right? If I connect to the 6 BLE devices, should I define 6 BluetoothGatt parameters?
Is there a smart way to connect to multiple BLE  device ?
Comment: Do you find any example for the same. can you guide me how to connect multiple BLE devices
Answer: Is not necesary multiple BluetoothGattCallback. Accidentally I connect two BLE devices using the same BluetoothGattCallback and works fine .
In the BluetoothGattCallback you must to know the address of the device that send data.
For example you can use :
gatt.getDevice().getAddress();

Hope this help
Answer: You are going to handle each BLE device by creating each BluetoothGattCallback for each one (maximum 7 right now). for example like:
private final BluetoothGattCallback oneGattcallback = new BluetoothGattCallback() ...

private final BluetoothGattCallback twoGattcallback = new BluetoothGattCallback() ...
then try to connect
mBluetoothGattA = deviceA.connectGatt(this, false, oneGattcallback );
 and mBluetoothGattB = deviceB.connectGatt(this, false, twoGattcallback ); just like that. you will find a lot examples handle one connection and just develop more for multiple connection.
Comment: Adding multiple callbacks is not a solution. The Android BLE API is designed in a way that a single `BluetoothGattCallback` works for multiple connections. You can handle different devices based on their address in the `BluetoothGattCallback` methods.


Why does binding a DropDownList function differently than manually adding ListItems?

Question: Snippet One
I add list items to my drop down one at a time.
var ddlHour = new DropDownList {ID = "ddlHour" + i};
ddlHour.Items.Add(new ListItem("12 AM", "0:00"));
ddlHour.Items.Add(new ListItem("1 AM", "1:00"));
ddlHour.Items.Add(new ListItem("2 AM", "2:00"));
Console.WriteLine(ddlHour.Items[0].Value);
// Prints 0:00

Snippet Two
I bind my drop down to an array of list items.
var hourItems = new[]
{
    new ListItem("12 AM", "0:00"), // "Text", "Value"
    new ListItem("1 AM", "1:00"),
    new ListItem("2 AM", "2:00")
};
var ddlHour = new DropDownList {ID = "ddlHour" + i, DataSource = hourItems};
ddlHour.DataBind();
Console.WriteLine(ddlHour.Items[0].Value);
// Prints 12 AM

After the first snippet executes, I inspect the values of each item and find "0:00", "1:00", and "2:00". Exactly what I expect.
After the second snippet executes, I inspect the values of each item and find "12 AM", "1 AM", and "2 AM". Not what I expect. What happened to my values?
Comment: OK, have you checked this? http://stackoverflow.com/questions/15292735/databind-a-dropdownlist
Comment: @LasseV.Karlsen I was in the middle of writing an answer based on your finding and Win beat me to it. Thanks for pointing me in the right direction.
Answer: They are same. Only different is that if you use DataSource, you need to specify DataTextField and DataValueField.
...
ddlHour.DataBind();
ddlHour.DataTextField = "Text";
ddlHour.DataValueField = "Value";
Console.WriteLine(ddlHour.Items[0].Value);

Comment: I am surprised that the default value for `DataValueField` is not `"Value"`. I am also surprised that it knew how to bind the Text field, but not the Value field. That seems inconsistent. I appreciate the sources and the correct answer.
Comment: It sure doesn't make sense.   The documentation for ListItem describes text and value: https://msdn.microsoft.com/en-us/library/7f7h2h8h%28v=vs.110%29.aspx


Find $ \lim_{t\to \infty}\int_{\mathbb{R}}|\sum_{j=1}^kf(b_jx+ta_j)|dx.$

Question: Let $\,\mathrm{f}\in L^{1}\left(\,\mathbb{R}\,\right)$, and let $a_{1},\ldots,a_{k} \in \mathbb{R}$ and $b_{1},\ldots,b_{k} \in
\,\mathbb{R} - \left\{\,0\,\right\}$, assume that the numbers $a_{j}/b_{j}$ are all distinct. Determine
$$
\lim_{t \to \infty}\int_{\mathbb{R}}\left\vert\,\sum_{j = 1}^{k}\mathrm{f}\left(b_{j}x + ta_{j}\right)\right\vert
\,\mathrm{d}x
$$
Source: Last question of the real analysis qual. I took last year and barely passed (edit some typos here)
Some thought: If I restrict $\,\mathrm{f}$ to be non-negative the problem can be easily done by change of variable of each individual integration. Then maybe I can use the conditions to partition the real line to finite number of subsets where on each subset we know $\,\mathrm{f}_j = \,\mathrm{f}\left(b_{j}x + ta_{j}\right)$ is positive or negative.
However this is probably on the wrong track because I got $0$ point by writing them down :).
Answer: Hint: 1. It's enough to consider $L^1$ functions with compact support. For such an $f,$ the supports of the functions $f(b_jx+ta_j)$ are pairwise disjoint for large $t.$
Comment: Thank you. This is easier than I thought and I'll try to write a solution base on this later.


What is the logic of create method in ContainerInterface class & its argument when being used and how its related to argument of the construct method?

Question: <?php

namespace Drupal\custom_changes\Plugin\Block;

use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use GuzzleHttp\Client;
/**
 * Block to determine the weather
 * @Block(
 *   id = "weather_block",
 *   admin_label = "Weather Block",
 *   category = @Translation("Hello World"),
 * )
 */
class CustomWeatherBlock extends BlockBase implements ContainerFactoryPluginInterface
{

    /**
     * The HTTP client to fetch the feed data with.
     *
     * @var \GuzzleHttp\Client
     */
      protected $httpClient;

    /**
     * {@inheritdoc}
     */
    public function __construct(array $configuration, $plugin_id, $plugin_definition, Client $http_client) {
       $this->httpClient = $http_client;
    }

    public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition){
       return new static(
         $configuration,
         $plugin_id,
         $plugin_definition,
         $container->get('http_client')
       );
    }

What does return new static() mean inside CustomWeatherBlock class and why do I need to pass all the arguments
 - $configuration
 - $plugin_id
 - $plugin_definition
 as in the construct and how is construct and create related to each other?
because when I tried to pass just $container->get('http_client') inside
return new static(
  $container->get('http_client')
);

whereas when I pass
return new static(
  $configuration,
  $plugin_id,
  $plugin_definition,
  $container->get('http_client')
);

It does not give any error.
I need to understand why is it so ?
Comment: See https://drupal.stackexchange.com/questions/264767/what-is-public-static-function-create-in-plugins-for
Answer: create() is a static method called on this class, before it is instantiated (static methods don't require instantiation of the class). The create() method returns the arguments that are passed to __construct().

Whereas when I pass:
return new static(
  $configuration,
  $plugin_id,
  $plugin_definition,
  $container->get('http_client')
);

It does not give any error. I need to understand why is it so?

Plugins that implement the ContainerAwareInterface pass the additional arguments of $configuration, $plugin_id and $plugin_definition to the create() function. These must be returned, as the __construct() argument will require these values in plugins.
Comment: Plugins that do not implement it will not even call create().
Comment: what is the significance of ContainerAwareInterface here since I see only setContainer() is defined in the Interface ?  how is that connected,sorry if its silly question ?
Comment: I was under impression to call create you need to implement ContainerFactoryPluginInterfaceand to get the container you need to implement ContainerAwareInterface as it has method setContainer() ?
https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Plugin%21ContainerFactoryPluginInterface.php/interface/ContainerFactoryPluginInterface/8.2.x

https://api.drupal.org/api/drupal/vendor%21symfony%21dependency-injection%21ContainerAwareInterface.php/interface/ContainerAwareInterface/8.2.x


JQuery Script, Works in Firefox, not in IE, Chrome

Question: I have the following script which slides a container down and another up, and vice versa depending on the condition of closed/enabled variables.
The script works fine in firefox, however in IE and Chrome, it just doesnt work :(
Can anyone please advise?
Many thanks! heres the script.
(The OCH var takes the height of a continer which elements are loaded into via ajax, so it then knows when to open it again how many px to open to - is this the best way?)
            $(document).ready(function()
            {
                //Grab the height of the container after its loaded with all the calls in...
                var och = $('#calls').height();
                //Are we allowed to close this panel yet?
                var enabled = false;
                //is the panel closed or not?
                var closed = false;
                $(".survey-description").click(function () {
                    if (enabled == true) {
                        if (closed == false) {
                            $(this).closest("#calls").stop().animate({"height": "44px"}, "fast");
                            closed = true;
                        }
                        else {
                            $(this).closest("#calls").stop().animate({"height": och}, "medium");
                            closed = false;
                        }
                    }
                });

                $(".linktoCall").click(function () {
                    if (closed == false) {
                        //Now we can toggle the top panel...
                        enabled = true;
                        $(this).closest("#calls").stop().animate({"height": "44px"}, "fast");
                        closed = true;
                    }
                });

            });

EDIT here is some html of the rendered elements.

59677 tgkn5xabgnivkaf
NOT STARTED - SAVED

Comment: "doesn't work" isn't a great description of a problem - you need to be more specific about *what* is and isn't working.  Are you getting any error messages in the developer console?
Comment: It doesnt slide up and down? That is how it doesnt work. It remains static. Error I get in chrome dev tools is
Comment: "Uncaught TypeError: Cannot read property 'length' of null"
Comment: Where is the element with class `survey-description`?
Comment: Re-editied. its just a div button above all others.
Comment: Well, if that's the html, then `$(".survey-description").closest("#calls")` will not match anything.
Answer: Looking at the HTML snippet I guess it should be

because the selector $('.survey-description') refers to a class, not an id.
Answer: This is mostly a quick guess as I don't know the html structure in question and don't have time to check the rest, but if there are conflicting element ids (such as two elements with the id "calls") different browsers will behave differently. So check do a check for this to make sure that is not the problem.
(Also, use === in comparisons instead of ==)
Answer: it might not work if your html code is not valid... and I bet you didn't close a div or something...
You can check here your page: http://validator.w3.org/
Please also remove just for test the "px" value from
animate({"height": "xxpx"} ...

and let it
animate({"height": 25}...

Comment: Removed the px and the ""'s works in FF perfectly, however still the same in Chrome/IE. :(


Clef with signature keys, entering other notes

Question: I would like to know, suppose a clef with key signature (e.g., G is always sharp), independent of octave, appears at the beginning of the staff.
Then every G that appears must be read sharp.
Then what do I write, to have the reader read a normal G, or a G flat?
Comment: (I don't think you mean [pentagram](https://en.wikipedia.org/wiki/Pentagram)… Though I'm not aware of any English word for five equidistant parallel lines, other than 'staff'/'stave'.)
Comment: Votes are anonymous and downvotes are very rarely acknowledged by the person who casts them. I feel it is unjustified in this case so I will give you a +1 to offset it.
Comment: @gidds In Spanish the word "pentagrama" refers to the music staff. This is probably a translation issue.
Comment: @JohnBelzaguy Ah, that would explain it. (I didn't downvote, BTW.)
Comment: Sorry, I meant stave. Why the downvote?
Comment: This is a legitimate if unresearched question. Why should beginners know the answer? Of course, it may well be a dupe, but doesn't deserve an unexplained dv (as is usual).
Answer: Place a natural or flat sign (an "accidental") immediately to the left of the note to be changed.
The below image shows examples of key signatures with G-sharp where the notes themselves are changed to G-natural or G-flat. Once changed, the G on that line or space will remain natural or flat until the end of the measure. After the end of the measure, the key signature takes over. So if another G-natural or G-flat is desired, then another natural or flat sign will need to be placed.
Accidentals affect only the specific line or space on which they're placed. This is also shown in the image below.
Comment: Anyone who has such an elementary understanding of music theory that they can ask this question and thinks that there is a G flat in a piece they're writing that has a G sharp in the key signature is probably doing something wrong.
Comment: @phoog - that hypothetical Gb is far more likely to be F#. Which would be in the key sig. before G# anyway.
Comment: @phoog I think you're being too literal.
Comment: Can you find an example of a professionally engraved piece where a flat is applied to a pitch that is sharp in the key signature, or vice versa?
Comment: @phoog This happens all the time in late-Romantic music; think Bruckner, etc. Sure, it's advanced stuff, but it definitely happens.
Comment: @phoog OP is just asking how to notate accidentals. However, for a professionally engraved piece with a G-flat in the key signature and a notated G#, take a look at Chopin's [Nocturne in Bb Minor](https://imslp.org/wiki/Nocturnes,_Op.9_(Chopin,_Fr%C3%A9d%C3%A9ric)), Op. 9, No. 1, m. 3.
Comment: @Richard yes, I've found some examples (specifically, Brückner's Symphony in E major, first movement, measure 42, D flat in the bass instruments).  As I suspected, they are written with ♮♭ instead of just with ♭.
Comment: @phoog Also, m. 4 of Chopin's [G minor Ballade](chrome-extension://efaidnbmnnnibpcajpcglclefindmkaj/https://vmirror.imslp.org/files/imglnks/usimg/3/3a/IMSLP64108-PMLP01646-Chopin_Balades_Schirmer_Mikuli_Op_23_scan.pdf) has an E# against a Bb/Eb key signature.
Answer: When there's a sharp in the key signature, say, on the G in the treble clef, it means every G in that piece will be played as a G♯.
To cancel that, there needs to be a natural or flat sign just before the note affected. That will then last until - the end of the bar it's in, or - it's changed by another accidental to say what it'll be next. But regardless, in the very next bar, it will need to be played as G♯ again - unless affected by yet another natural or flat sign.
Those accidentals will only affect notes in the particular octave tey're written in - any other G notes in other octaves will still be G♯.


Optimal estimation of a single parameter given data at different scales

Question: Let $A,B,C,D$ be independent normal random variables distributed according to $\mathcal{N}(0,\sigma^2)$ and $E = A+B+C+D$.
The goal is to provide an optimal estimate of $\sigma^2$ given samples of $A,B,E$ but not $C,D$.
In this case optimal refers to minimising the root-mean square deviation of the estimate $\hat{\sigma}^2$:
$$RMSD(\hat{\sigma}^2) = \sqrt{\mathbb{E}\left[\left(\hat{\sigma}^2-\sigma^2\right)^2\right]}$$
I can think of a simple approach to estimate $\sigma^2$ given samples of $A,B$ which is to simply compute the sample variance. Also I know that the variance of $E$ is $4\sigma^2$ so I could compute the sample variance of $E$ and divide it by 4 to get an estimate of $\sigma^2$. However it should be possible to combine the information from both $E$ and $A,B$ to improve estimation $\sigma^2$. Could you outline the approach to use both sets of information?
Comment: You didn't tell us if A,B,C,D are independent..  The variance you give for E is correct if you are assuming independence.
Comment: Have you looked at the likelihood?
Comment: @MichaelChernick Yes I intend them to be independent.
Answer: Given that the $C+D \sim \mathcal{N}(0,2\sigma^2)$ and we don't get information about C and D individually we'll define a random variable $T=C+D$.
Then
$P(A,B,T,E|\sigma) = N(A|0,\sigma^2)N(B|0,\sigma^2)N(A|0,\sigma^2)N(T|0,2\sigma^2)\delta(E-A-B-T)$, where $\delta()$ is a delta function, N(.|..) is the PDF of the Normal distribution. Therefore the likelihood of A,B,E is
$$P(A,B,E|\sigma) = \frac{1}{(2\pi)^{3/2}2\sigma^3}\exp\left(-\frac{A^2}{2\sigma^2}-\frac{B^2}{2\sigma^2}-\frac{(E-A-B)^2}{4\sigma^2}\right)$$
From this, one can derive the maximum likelihood estimator for $\sigma^2$
which will be:
$$\hat\sigma^2=\frac{1}{3\,N}\sum\limits_{i=1}^{i=N}\left(A_i^2+B_i^2+\frac{1}{2}(E_i-A_i-B_i)^2\right)$$ $N$ here is the number of samples.
This estimator is unbiased and because it is ML it is also a minimum variance estimator.
Comment: Could you explain your notation?
Comment: I thought that I don't use anything non-standard with the exception of maybe of the delta-function.
Comment: Testing in Matlab reveals this is a superior estimator to both of my naive approaches. I believe $N$ is the number of samples of $A, B$ or $E$.
Comment: I've added to the post that N is indeed the number of samples.
Comment: This estimator is *biased*, not unbiased.  Also, you seem implicitly to assume the samples are independent, but it's not evident whether they are or are not.
Comment: The author commented below the post that "Yes I intend them to be independent. "
Comment: I intend A,B,C,D to be independent. However E is dependent on the value of A.


How to find how many items of list B forms list A

Question: I want to find minimum items of list B that forms list A. lets assume A=['abcdef'] and B=['abc','ad','adef','adef','bdf']. Then since items with index 0 and 2 contains all letters of list A, the answer will be 2. I used the combination to find all the possible combination of B. But I am not sure how to continue. It seems most optimized way is Brute Force.
A=['abcdef']
B=['abc','ad','adef','adef','bdf']

for L in range(0, len(B)+1):
    for subset in itertools.combinations(B, L):
        if subset==A:
            print(subset)

Comment: What is the expected behaviour when list A has more than one item in it?
Comment: Always there is a one item in list A
Answer: Here is an extension of your attempt. I have used a rather confusing comprehension to flatten the the list out into a set so I can make use of straightforward set operations to check whether one is a subset of the other.
import itertools

A='abcdef'
B=['abc','ad','adef','adef','bdf']

set_a = set(A)
solved = False

for L in range(0, len(B)+1):
    for subset in itertools.combinations(B, L):
        s = set(item for sublist in subset for item in sublist)
        if set_a.issubset(s):
            print(f'String A can be made from {L} items of list B, specifically: {subset}')
            solved = True
            break
    if solved: break

Comment: The code is not giving correct answer is some cases. I tried to debug is but that was not successful.
Comment: Could you give an example of input for which it doesn't work and how?
Comment: Input has a long list. Can we talk in private chat?


Composing melodies for a song on finger-style guitar

Question: I'm attempting to learn how to create finger-style guitar arrangements of songs. In finger-style arrangements it is very important to include melody, I'm just not quite sure how I should compose a melody for a song, especially since I don't have an ear yet and can't pick out notes easily.
I know some music theory: keys, major and minor scales, pentatonic scales, and chord construction.  How do you suggest I compose melodies for songs? Obviously I could listen to the song over and over again, looping certain portions and play scales of and related to the key of the song to find these notes, but is there a better way?
I'm new to this and am just curious if anyone has any tricks they use to compose melodies for songs.
Answer: First of all it takes a while to develop your ear and some pointed practice definitely helps. The short answer is use the tools at your disposal - usually your ear and maybe notation/tablature if you can find it for free/on the cheap.
With that said it is GREAT practice to transcribe the melody by ear (Using looping software ain't cheating in my book but others may disagree - ultimately our opinions don't matter, it's up to you!). There is very useful (free) software called Audacity that allows you to slow down and loop over parts of music - it won't sound great at lower speeds but you can slow it down without changing the pitch and pick out the notes. Do this enough (with progressively more difficult pieces) and you will develop a very good ear.
Now getting back to my earlier note on pointed practice, check out ear training (just google it, there are a million sites out there). If you already know basic theory (major sixth vs minor sixth, basic chord progressions, inversions etc) then all you have to do as take your theoretical knowledge and put some 'sounds' to it. If not, learn a bit so that you have some labels to stick on the different sounds you discover. Music theory isn't necessary but it can be very helpful.
The goal of ear training (at least for me) is so that when I hear something I:
a) know the relationship of notes
b) know how to play the notes relative to each other right off the bat (ideally in real time)
Some sample questions you can ask your self while you study is "What does a sixth sound like and how do I play it?" (I always think of the NBC jingle or the last 3 notes of the standard "Always"). "How about a fourth" (Heeere comes the bride). "A fifth?" (Crazy train - also flat sixth right after it) etc. Find melodies that really showcase a specific melodic jump and figure out what that jump is. Learn jumps up AND down and then learn to play that jump in a bunch of different places on the guitar neck. This will give you a great reference point for what an interval sounds like and how to play it. That way, when you hear one, you can just say "Oh man, that's a jump of a major seventh!".
Also sing along with it! Learn the melody in your voice (even if it's in a funny range) - if you can sing it, you can play it!
For classical guitar, don't be afraid to transpose - especially if it's your first piece! Why would I transcribe Moonlight Sonata in C# when I could transpose it down to A Minor and have some super-easy open bass strings to work with? (I may get attacked on that front so I will mention that I'm a jazz guy first and foremost and I'm treating this as an exercise in developing your ear, not paying proper homage to the great pieces of music, the likes of whichI could never ever ever do justice).
So to recap
1) Use tools at your disposal (namely your ear and sheet music - try it with your ear first and then go to the sheet music if that doesn't work out)
2) If you aren't satisfied with the tools at your disposal, develop your tools! Transcribe anything you can get your hands on from different styles! This Will increase your ear's power exponentially.
3) Learn how to play more melodies ( I didn't mention this before but I'm already a bit long winded here so I'll tack it onto the end)
4) Finally - learn to play the melody in different places on the neck - maybe think positionally at first but be willing to jump around so that you can put some nice voicings underneath.
You don't have to do this all at once (or any of it for that matter). This is just a road map of how I developed my ear! Pleasant playing!
Answer: Adding to Ben's great answer. Learn the chord shapes all over the neck. An 'E' shape gives you the tonic on the top string. So does a 'G' shape. A 'C' and 'D' shape give you a third on the top, and an 'A' shape will find the 5th on top. Those notes make up the major chord, which will give some of the main notes for most tunes. Playing them on the top string, while strumming or picking the rest of the chord underneath sounds good, as our ears pick up the highest note more easily. The same idea works with the minor, and seventh shapes (all three).
With a chord, or 2 or 3 notes from it held down and being played, often a ring finger or pinky will be available for any other notes needed in the same bar. Start with pieces which aren't too complex and you'll soon get the way you can change chord shape, to allow the melody to sing out over the accompaniment. Often, you'll only need a couple of notes from a chord to do it. For example, a 3 and a 7 will do . (For a seventh, obviously!)
Whilst this answer sounds like it's addressing the chords, the top note of them will, as said before, feature in most melodies.
Comment: Yea, chord shapes are key! So much emphasis is placed on inversions but once you start looking at melodies then the top note is just as important as the bass note. Try playing scales on top with a static chord underneath (changing the voicing of the chord to allow you to move around the neck but keeping the harmony static - don't add/drop any notes from the chord)
Comment: Another word for this is the CAGED system.
Answer: There is only one thing you need. I am also a finger-style guitarist, but believe me, those major or minor scales help a little in finger-style guitar arrangement. What you need to practice is to learn how to play `do, re, me...´. If you are good at this, you can write down the melodies of the songs. In addition, try to read tonic solfa guitar notation a little. It'll help.
Answer: Here is how I learnt to compose Fingerstyle arrangements.
First, choose a song and find the chords for the song, either work them out yourself or google them. You have to then find the root note of each chord.
Second, get used to playing the melody an your guitar without worrying about other parts
Third, this is the step where you put the bass notes and the melody together. You may have to modify the place where the melody is being played and or where the root notes are played so you can play them both at once.
Fourth, when you have practiced the third step a few times, try to find other positions for the original chords where the melody position closer to it. This is where knowledge of the CAGED system and memorising the notes on the guitar neck is useful.
Fifth, try to add in percussive slaps and taps where it will sound good. This will take heaps of time to develop so don't give up fast.
As a first song to try, play hallelujah from Shreck, this song was my first full song and I was able to get to the third step within a week of practice. It truthfully took years to get better and get to the last step but I eventually did it. I first arranged hallelujah at the time when I had just finished learning open chords and was still quite uncoordinated. The sweat and time was well worth it when I was able to play fongerstyle songs start to finish which were fully arranged by me.
Good luck :)
EDIT: don't worry too much about the scales, all you need to know is a really general knowledge of the scales. What is most important for you is the ability to know if a note in the melody is above, below, or right where you are playing. All you have to know is how to find this note.


Program doesn´t stop when asking for turning bluetooth on

Question: I tried to use the dialog BluetoothAdapter.ACTION_REQUEST_ENABLE to ask the user for
turning bluetooth on, but when I used it, the Program didn´t wait for the dialog to end.
I have to know whether the user allows to turn bluetooth on or not, so that I can return to the previous activity if he won´t allow it. Getting the Result even using onActivityResult didn´t work.
How can I get the result of the dialog and how can I make the program wait for the result of the dialog?
The Dialog I tried to use:
private int REQUEST_ENABLE_BT = 100;
...
Intent btEnable = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(btEnable, REQUEST_ENABLE_BT);

After that it just goes on without waiting for the result.
Comment: "Geting the Result with onActivityResult didn´t work too" -- please explain in greater detail what you mean by this sentence. What does "didn't work" mean?
Comment: I just didn´t call the onActivityResult. I wrote it like it worked befor but the activity just goes on and didn´t waited for the result.
Comment: public void onActivitResult(int RequestCode, int ResultCode, Intent Data)
{
 super.onActivityResult(RequestCode, ResultCode, Data);
 if(RequestCode == REQUEST_ENABLE_BT)....
}
This wasn´t called
Answer:
but when I used it, the Programm didn´t wait for the dialog to end

It is not supposed to. startActivity() and startActivityForResult() are asynchronous.

I just didn´t call the onActivityResult.

You don't call onActivityResult(). You implement onActivityResult(). It will be called when the user is done with the activity you started via startActivityForResult(). This is covered in the documentation.

public void onActivitResult(int RequestCode, int ResultCode, Intent Data) { super.onActivityResult(RequestCode, ResultCode, Data); if(RequestCode == REQUEST_ENABLE_BT).... } This wasn´t called

That's because you spelled the method name wrong. It is onActivityResult(), not onActivitResult(). Use the @Override annotation to help detect these sorts of issues.

How can I get the result of the dialog

In onActivityResult(), see if Bluetooth was enabled.

and how can I make the programm wait for the result of the dialog?

You don't. Android is event-driven; you handle the event via onActivityResult().
Comment: Ok thanks a lot. Now it works. I catch the result in the onActivityResult() and if the result is ok then i can start the next dialog in the onActivityResult().

onActivityResult()
Comment: I was to slow to finish this so now here is the rest of it:

//Global
REQUEST_CODE_1 = 0;
REQUEST_CODE_2 = 1;

onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    Intent dialog = new Intent(myclass.this, dialog1.class);
    startActivityForResult(dialog, REQUEST_CODE_1);
}

onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == REQUEST_CODE_1)
{
   if(resultCode == RESULT_OK)
   {
       Intent nextDialog = new Intent(...);
       startActivityForResult(nextDialog, REQUEST_CODE_2);
   }
}

if(requestCode == REQUEST_CODE_2)
{...}
}
Comment: Ok i will post the right thing in 6 hours so that i can do it as an answer and not as an comment...
Answer: So now the right answer in code....
//Global
REQUEST_CODE_1 = 0;
REQUEST_CODE_2 = 1;

onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    Intent dialog = new Intent(myclass.this, dialog1.class);
    startActivityForResult(dialog, REQUEST_CODE_1);
}

onActivityResult(int requestCode, int resultCode, Intent data)
{
if(requestCode == REQUEST_CODE_1)
{
   if(resultCode == RESULT_OK)
   {
       Intent nextDialog = new Intent(myclass.this, nextDialog.class);
       startActivityForResult(nextDialog, REQUEST_CODE_2);
   }
}

if(requestCode == REQUEST_CODE_2)
{...}
}


Prove that the following matrices cannot represent the linear transformation $T$ in ANY basis

Question: $T: \mathbb{R}^3 \rightarrow \mathbb{R}^3$ defined as $T(x,y,z) = (2x,z,y)$ is a linear transformation.
I need to prove that the following matrices cannot represent $T$ in ANY basis:
$$\begin{bmatrix} 2 & 0 & 1 \\
0 & 1 & 0\\
2 & 0 & 1
\end{bmatrix}$$
$$\begin{bmatrix} 1 & 0 & 1 \\
1 & 0 & 0 \\
0 & 2 & 1\end{bmatrix}$$
My attempt for the first matrix was to assume (negatively) existence of a basis in which the given matrix is the representation, and left multiplying it by $(x,y,z)^{T}$ to get $(2x+z,y,2x+z)^{T}$.
Can I conclude that given it is not in the form $(2x,z,y)^{T}$, there is NO such basis?
I want to know if this is correct and, in addition (Or alternatively), learn other ways to solve this exercise.
Thank you.
Answer: In the canonical basis:
$[T]_e= \left( \begin{matrix}
2 & 0 & 0 \\
0 & 0 & 1 \\
0 & 1 & 0 \end{matrix} \right)$
Any other representation of $T$ would be similar to $[T]_e$.
Similar matrices have the same trace, and this rules out the first option.
Similar matrices have the same determinant, and $|[T]_e|=-2$. This rules out the second option (Has determinant $2$).
About the reasoning you tried and asked about: It is not correct. The form you were talking about is just the form of the coordinates (The numbers you multiply some set of basis vectors by) and would certainly not retain It's form, generally, in different basis.
Answer: Determinant and trace of a linear transformation don't depend on the basis. The 1st matrix has wrong determinant, and the other has wrong trace.
Comment: The second matrix has the right trace, but wrong determinant. The first has both trace and determinant wrong.
Comment: Perfect answer; you should consider to make it a bit clearer to the OP.
Comment: This is indeed a remarkable answer.
Comment: @Dror: I agree, the answer was very brief. The reason: I tried to point to the right direction w/out spelling everything out. This looks like a homework question, and it would benefit OP to transform the hint into a detailed answer.
Comment: @Michael first of all, you get the order of the matrices mixed up in your answer. 2nd of all, Linear transformations don't have determinants nor trace. Their matrices representatives have determinant and trace.
Comment: If pointing in the wrong direction twice is like double negation, then yes, you pointed in the right direction..
Comment: @Dror: of course linear transformation has determinant and characteristic polynomial and such: a property of a representation that does not depend on the basis can be defined as the property of the underlying transformation. In particular, determinant of a linear transformation can be defined as the (signed based on orientation change) volume of the image of a unit cube after the transformation.


Show $\{f_n'(x)\}$ is uniformly bounded given that $\{f_n''(x)\}$ is and $f_n \rightarrow 0$ uniformly

Question: Suppose that $f_n : \mathbb{R} \rightarrow \mathbb{R}$, $n=1,2,\dots$ is a sequence of functions with continuous second derivatives. Further, let $f_n \rightarrow 0$ uniformly as $n \rightarrow \infty$ and let $M$ be a constant such that $|f_n '' (x)| \leq M$ for all $n$ and $x \in \mathbb{R}$.
Show that there exists a constant $K$ such that $|f_n '(x)| \leq K$ for all $n$ and $x \in \mathbb{R}$.
I am stuck on how to relate the above information. I know that given $a,b\in \mathbb{R}$, with $a<b$, we have that for some $c,d\in(a,b)$
$$
f_n(b) = f_n(a) + f_n'(a)(b-a) + \frac{f_n''(c)}{2}(b-a)^2 \leq f_n(a) + f_n'(b-a) + \frac{M}{2}(b-a)^2
$$
and
$$
f_n'(b) - f_n'(a) = f''(d)(b-a) \leq M(b-a)
$$
But I can't see how to combine this with the uniform convergence of $\{f_n\}$.
Edit:
After reading Hans' comment below, I think the connection comes from $f_n$ being uniformly bounded. Since $f_n \rightarrow 0$ uniformly, there exists a sequence $L_n \rightarrow 0$ where
$$
L_n = \sup_{x} |f_n(x)|
$$
Thus, if we let $L$ be the LUB of the $L_n$, we can combine this with Hans' trick below to get
$$
|f_n'(x)| \leq |f_n(x+1) - f_n(x)| + M/2 \leq 2L + M/2
$$
Comment: Drop the subscript $n$ as it is irrelevant. Rewrite the first identity as $f'(a) = (f(b) - f(a))/(b-a) + (b-a)f''(c)/2$. At this point you are still free to choose $a$ and $b$. So choose any $a = x$, set $b = x+1$, and look at the result again. What can you conclude, using your assumptions?
Comment: [Related question](http://math.stackexchange.com/q/396707/46120).
Comment: @AnonSubmitter85 - your edit gives a correct solution, and you can conclude more. Using your notation, set $x = a$ (arbitrary) and then choose $b$ such that $b - a = \sqrt{M/(4L_n)}$. The result is now $|f_n'(x)| \le 2 \sqrt{L_n \cdot M}$. This is known as Landau's Inequality. Therefore the $f_n'$ are not only uniformly bounded but go to $0$.
Comment: @HansEngler That $|f'(x)|\leq |f(x+1) - f(x)| + M/2$. But I think this only gets me half way. I am now thinking that the uniform convergence of $\{f_n\}$ shows that it is also uniformly bounded, so that there exists $L$ such that $|f_n(x)| \leq L$ for all $n$ and $x$. Therefore, $|f_n'(x)| \leq 2L + M/2$ for all $n$ and $x\in \mathbb{R}$.
Answer: Suppose that $\|f_n''\|_\infty\le M$. I believe that the only part of $f_n\to0$ uniformly that we need is that for some $N$ and all $n\ge N$, we have $\|f_n\|_\infty\le M$. Let $f=f_n$ for any $n\ge N$.
The Mean Value Theorem says that for any $x,y$ there are $z_1,z_2$ between $x$ and $y$ so that
$$
|f'(z_1)(x-y)|=|f(x)-f(y)|\le2M\tag{1}
$$
and
$$
|f'(x)-f'(y)|=|f''(z_2)(x-y)|\le M|x-y|\tag{2}
$$
Consider $f$ on any interval $[k,k+1]$.
By $(1)$, there is a $z_1\in[k,k+1]$ so that $|f'(z_1)|\le2M$.
By $(2)$, for any $x\in[k,k+1]$, $|f'(x)-f'(z_1)|\le M|x-z_1|\le M$.
The Triangle Inequality then gives
$$
\begin{align}
|f'(x)|
&\le|f'(x)-f'(z_1)|+|f'(z_1)|\\
&\le3M\tag{3}
\end{align}
$$
Since $[k,k+1]$ was arbitrary, we have that, for $n\ge N$, $\|f_n'\|_\infty\le3M$.
Unfortunately, we cannot bound $\|f_1'\|_\infty$ since there is nothing preventing $f_1(x)=x^2$. $\|f_1''\|_\infty=2$; however, the condition $f_n\to0$ only puts limits on the tail of the sequence of functions.


difference between two registry locations for HKLM\SOFTWARE\Microsoft\Windows\ and HKLM\SOFTWARE\Microsoft\Windows NT\

Question: What is the difference between the two registry locations
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon:LegalNoticeText
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System:LegalNoticeText

While my question is asking about the LegalNoticeText i am more interested in the difference between the HKLM\SOFTWARE\Microsoft\Windows NT\ and HKLM\SOFTWARE\Microsoft\Windows\. I have searched online and can't find any solid information to explain why I have duplicate keys in two places and why CIS benchmarks suggest only the HKLM\SOFTWARE\Microsoft\Windows\ over the other one.
Answer: I don't have hard evidence or sources for this, but just my personal experience.
These are not duplicate keys. Yes, they exists in two places, but have different purposes and are both valid and one shouldn't be preferred over the over.
From my experience the Windows NT key was more used in the old days when the OS was actually called Windows NT, so 1993 to 1999, most core OS settings from the time can be found there and never changed after the renaming to Windows 2000. But newer settings were mostly added under the Windows Key, but if a sub-key already existed under Windows NT new values where added here too.
Just think of it as a historical fact, there are two locations for Windows OS settings.
In you specific case I think the LegalNoticeText under Windows NT is the system default, the one under Policies is used for Group Policies to overwrite that default.
Comment: Many strange decisions were made when the Windows NT line merged with the Windows 9x line. First they wanted to stick with the Windows 95 UI design with NT and then keep backwards compatibility with everything in both. Already back then the NT kernel had many good features that weren't implemented in the GUI.


Trouble configuring apache server to proxy an SSL connection

Question: I'm running an application on Tomcat7 with Apache Portable Runtime, I bought an SSL certificate and configured it correctly - when I try to connect through the ip:port combination, it connects fine but warns me the certificate is issued to the domain name, not the IP.
The VPS I'm on doesn't have SELinux (and there's an issue installing), which is AFAIK required to have SSL be configured in apache, so I want to just route the requests to Tomcat, which does it on its end.
I configured apache to proxy the connections, first with port 80 that works perfectly:
NameVirtualHost www.mysite.com:80
<VirtualHost www.mysite.com:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName http://www.mysite.com
ServerAlias http://www.mysite.com
ProxyPass / http://localhost:8180/MYSITE/
ProxyPassReverse / http://localhost:8180/MYSITE/
ProxyPassReverseCookiePath /MYSITE/ /
</VirtualHost>

And then with the SSL port that doesn't want to work for some reason:
NameVirtualHost www.mysite.com:443
<VirtualHost www.mysite.com:443>
        SSLProxyEngine On
        ProxyPreserveHost On
        ProxyRequests Off
        ServerName https://www.mysite.com
        ServerAlias https://www.mysite.com
        ProxyPass / https://localhost:8443/MYSITE/
        ProxyPassReverse / https://localhost:8443/MYSITE/
        ProxyPassReverseCookiePath /MYSITE/ /
        CacheDisable *
</VirtualHost>

EDIT:
I added the
RequestHeader set Front-End-Https "On"

directive to the VirtualHost www.mysite.com:443, as per: http://www.gossamer-threads.com/lists/apache/users/396577
Here is the Tomcat APR Connector as configured in Tomcat's server.xml -
<Connector port="8443" maxHttpHeaderSize="16500"
                 maxThreads="150"
                 enableLookups="false" disableUploadTimeout="true"
                 acceptCount="100" scheme="https" secure="true"
                 SSLEnabled="true"
                 SSLCertificateFile="x509-cert-path"
                 SSLCertificateKeyFile="key-file-path"
 />

There were no errors/warnings enabling the virtual hosts and restarting apache. When I try to https, this is what I see in FFox:
SSL received a record that exceeded the maximum permissible length.

(Error code: ssl_error_rx_record_too_long)

And in Chromium:
Error 107 (net::ERR_SSL_PROTOCOL_ERROR): SSL protocol error.

Apache's error.log shows this warning message:
[warn] [client 188.8.131.52] proxy: no HTTP 0.9 request (with no host line) on incoming request and preserve host set forcing hostname to be www.mysite.com for uri /

I've spent days trying to configure it, and would be very grateful if someone explained what's going on and how to fix it.
Many thanks. Victor.
Answer: The error you're getting is probably due to the fact that your client (Firefox) is trying to use SSL, but you Apache virtual host does not have SSL enabled.
In order for your clients to be able to communicate via SSL with your front-end proxy, you're going to need to do SSL on the front-end, not in Tomcat.  You gain absolutely nothing by using SSL between Apache and Tomcat.
In your <VirtualHost> block, you're going to need at least:
SSLEngine On
SSLCertificateFile ...
SSLCertificateKeyFile ...

Also, note htat SELinux has absolutely nothing to do with SSL, other than the fact that a misconfigured SELinux environment could prevent Apache from being able to read the necessary SSL certificates.
If you're not using Apache as anything other than a simple proxy and you're really not comfortable with Apache configuration you could in theory get rid of it and just have Tomcat listen on port 443 (by modifying the appropriate Connector block).
Comment: Thanks for your answer! I was under the impression the "RequestHeader set Front-End-Https "On"" directive instructed Apache to terminate SSL on the back end of the proxy.
Comment: The `RequestHeader` directive only modifies headers, it doesn't have any operational impact.
Comment: I tried to https locally (wget https://localhost:8443/MYSITE/), and it was refused because the cert was issued for www.mysite.com and not the local ip.. maybe that's the issue? In that case, I'll really have to configure SSL on Apache...
Comment: You have to configure SSL in Apache in any case.  In you current configuration Apache is speaking normal HTTP while your clients are trying to speak SSL.
Comment: I _think_ someone figured it out w/o configuring apache - http://stackoverflow.com/questions/6764852/proxying-with-ssl, but it didn't work for me. Is it possible though?
Comment: They're using SSL in Apache (`GNUTLSEnable On`). It's simply *NOT POSSIBLE* to make this work without configuring SSL in Apache if you expect your clients to be speaking SSL.


Only allow a link to be clickable if checkbox is selected

Question: I'm trying to setup a button/link that is only clickable if a checkbox is selected. So my code so far would be
<form>
<input type="checkbox" name="agreeCheckbox" value="agreeCheckbox">By clicking this you agree that you are adding a subscription/recurring product to your order

</form>

This link is only clickable if checkbox is checked

I'm assuming I will have to do this in javascript although I'm on a beginner when it comes to javascript. Thanks
Comment: can't we expect a beginning from a beginner ?
Comment: What if someone visits your page who **isn't** using Javascript? How are you going to stop them from clicking the link?
Comment: @Kacey What if this is a question regarding progressive enhancement?
Comment: @KevinBowersox It very well could be. I was merely curious.
Answer: This code adds some id attributes to the elements to provide some hooks for the Javascript.  It hides and prevents the default action of the anchor until the checkbox is clicked.
HTML
<form>
<input id="agreement" type="checkbox" name="agreeCheckbox" value="agreeCheckbox">By clicking this you agree that you are adding a subscription/recurring product to your order

</form>

This link is only clickable if checkbox is checked

Javascript
var chk = document.getElementById("agreement");
var anchor = document.getElementById("link");
anchor.style.display = "none";
anchor.onclick = function(e){
  e.preventDefault();
}

chk.onclick = function(){
    if(chk.checked){
        anchor.style.display = "inline";
      anchor.onclick = "";
    }
}

Working Example
http://jsfiddle.net/zVCD7/
Answer: Here's a simple way of doing it using pure javascript, using some ID attributes I added as hooks for the javascript document.getElementById() function.
HTML:
<form>

<input type="checkbox" id="agreeCheckbox" name="agreeCheckbox" value="agreeCheckbox" onchange="toggleLink(this);">By clicking this you agree that you are adding a subscription/recurring product to your order

</form>

This link is only clickable if checkbox is checked

Javascript:
function toggleLink(checkBox)
{
    var link = document.getElementById("agreeLink");

    if (checkBox.checked)
        link.style.display = "inline";
    else
        link.style.display = "none";
}

WORKING EXAMPLE
Answer: <input type="checkbox" name="agreeCheckbox" id="agreeCheckbox" value="agreeCheckbox">By clicking this you agree that you are adding a subscription/recurring product to your order

This link is only clickable if checkbox is checked

var check= document.getElementById('agreeCheckbox');
  if (check.checked){
    document.getElementById('mycheck').style.display='block';
  }
else{
 document.getElementById('mycheck').style.display='none';
}

Answer: There are a variety of ways you could accomplish this.  Most of the newer methods would probably involve jQuery.
First, include jQuery (Google works):

Then, make the link, not a link:

This link is only clickable if checkbox is checked

Next, if the box is clicked, make it clickable:

Comment: So you recommend adding 30kb+ to the request to toggle an anchor?
Comment: Yes and no.  Odds are, it will help in the long run if writing a lot of javascript, and using the Google hosting, most people already have the library cached.  But you are correct that it's not the most space efficient solution.
Comment: Good point about the CDN.  It depends on the circumstances, usually when some tags JS as the question they are looking for a Native solution.  I would also recommend considering the original posters comfort with the technology, if they are having issues toggling a checkbox, jquery may be out of their technical abilities at this time.
Comment: Good to know.  New to StackOverflow (answering anyway), so I'll keep that in mind.  Thanks.


The product of limit point compact spaces is limit point compact?

Question: Assuming the Tychonoff theorem that arbitrary product of compact spaces is compact, is it true that the product of limit point compact spaces is limit point compact? If not, are there any counterexamples?
I've read The product of limit point compact Hausdorff spaces is not limit point compact, If $X$ and $Y$ are Lindelöf's (respectively countably compact) spaces so that $X\times Y$ is a Lindelöf's (respectively countably compact) space?, and the second link in the second one. But the link says something different with what I know(for example, 'The Cartesian product of two compact regular spaces need not be compact', Theorem 4 in the link).
Answer: The paper by J. Novák in my second link at your second link uses an older terminology: what he calls compact is our countably compact, and for our compact he uses the term bicompact. The example in his Theorem $4$ is an example of two countably compact Tikhonov spaces whose product is not countably compact. It is also an example of two Tikhonov limit point compact spaces whose product is not limit point compact.
Comment: @Sphere the last holds as for $T_1$ spaces (which these examples are, as they are  Tikhonov even) "limit point compact" = "countably compact".


Issue in adding 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:+' plugin in root level in Android Studio Electric Eel - 2022.1.1?

Question: Trying to integrate the AppLoving MAX SDK in Android Studio Electric Eel - 2022.1.1, but unable to integrate it. Try to add 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:+' plugin in root level it shows following error
org.gradle.api.plugins.UnknownPluginException
settings.gradle file
pluginManagement {
    repositories {
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        maven { url 'https://artifacts.applovin.com/android' }
    }
}
rootProject.name = "AppLovinMaxSample"
include ':app'

Root level build.gradle file
plugins {
    id 'com.android.application' version '7.4.0' apply false
    id 'com.android.library' version '7.4.0' apply false
    id 'com.google.gms.google-services' version '4.3.4' apply false
    id 'com.google.firebase.crashlytics' version '2.9.2' apply false
    id 'com.applovin.applovin-quality-service' version '+' apply false
}

App Level build.gradle files
plugins {
    id 'com.android.application'
    id 'com.google.firebase.crashlytics'
    id 'applovin-quality-service'
}

applovin {
    apiKey "kdlksi980"
}

dependencies {
    implementation 'com.applovin:applovin-sdk:11.8.0'
}

How add 'com.applovin.quality:AppLovinQualityServiceGradlePlugin:+' pugin in root level in Android Studio Electric Eel - 2022.1.1?
Comment: Try by providing version in this library    id 'com.applovin.applovin-quality-service' version '+' and replace with (plus symbol) +
Comment: @MaveňツTried still faceing the same issue
Comment: in my case `applovin{ apikey = "key"}` not adding so how to add this can you please share
Answer: You can add the AppLovin SDK to your Android project in the following way.
buildscript {
    dependencies {
        classpath "com.applovin.quality:AppLovinQualityServiceGradlePlugin:4.10.0"
    }
}
plugins {
    id 'com.android.application' version '8.0.1' apply false
    id 'com.android.library' version '8.0.1' apply false
}


String based filtering in dplyr - NSE

Question: I'd like to use dplyr's new NSE notations (version >= 0.6) for a dynamic filter on my data. Let's say I have the following dummy dataset:
df = data_frame(x = 1:10, y = 10:1, z = 10 * runif(10))

If now I want to filter column tofilter = "x" for values greater than 5 I know I can do:
df %>%
  filter((!!rlang::sym(tofilter)) >= 5)

Question 1
What if I want to dynamically change the operator of the filtering too (let's say I have a Shiny App in which the user can dynamically selectInput if to filter the data for values greater than 5, equal to 5 or lower than 5?
What I'd like to do is something on the line of:
op = ">="
val = 5
filt_expr = paste("x", op, val)
df %>%
  filter(filt_expr)

Obviously, this does not work and I have played a bit with the rlang quosore/symbols, etc but didn't quite find the right way to "quote" my inputs.
Question 2
Bonus question is, what if I want to apply multiple filters? Do I need to loop or I can create a list of filtering expressions and apply them all in one go?
An example of this is a Shiny App where the user can type multiple conditions he/she wants to apply to the data so that we have a dynamically changing list of the format:
filt_expr_list = list("x >= 5", "y <= 10", "z >= 2")

and we want to dynamically apply them all, so that the output is equivalent to:
df %>%
  filter(x >= 5, y <= 10, z >= 2)

I guess this is in a certain sense a subset of question 1 since when I know how to correctly quote the arguments I think I could do something like:
filt_expr = paste0(unlist(filt_expr_list), collapse = ", ")
df %>%
  filter(filt_expr)

but would be nice to see if there is any nicer cleaner way
Answer:
What if I want to dynamically change the operator of the filtering too

You can do it with tidy eval by unquoting a symbol representing the operator (note that I use expr() to illustrate the result of the unquoting):
lhs <- "foo"

# Storing the symbol `<` in `op`
op <- quote(`<`)

expr(`!!`(op)(!!sym(lhs), 5))
#> foo < 5

However it is cleaner to do it outside tidy eval with regular R code. Unquoting is only necessary when the symbol you unquote represents a column from the data frame, i.e. something that's not in the context. Here you can just store the operator in a variable and then call that variable in your filtering expression:
# Storing the function `<` in `op`
op <- `<`

expr(op(!!sym(lhs), 5))
#> op(foo, 5)

what if I want to apply multiple filters?

You save the expressions in a list and then you splice them in a call with !!!:
filters <- list(
  quote(x >= 5),
  quote(y <= 10),
  quote(z >= 2)
)

expr(df %>% filter(!!!filters))
#> df %>% filter(x >= 5, y <= 10, z >= 2)`

Note: I said above that it is not necessary to unquote variable from the context, but it is still often a good idea to do so if you're writing a function that has the data frame as input. Since the data frame is variable, you don't know in advance what columns it contains. The columns will always have precedence over the objects you have defined in the environment. In the case here, this is not an issue because we are talking about a function and R will keep looking for a function if it finds a similarly named object in the data frame.
Comment: You are totally right! Great solution, thank you!! Just summarizing it, it is possible to run multiple dynamic filtering creating a list like `filt_expr = list(
  quo(\`>=\`(!!sym("x"), 5)),
  quo(\`<=\`(!!sym("y"), 10)),
  quo(\`>=\`(!!sym("z"), 2))
)` and then applying the `!!!` operator `df %>%
  filter(!!!filt_expr)`.
Comment: @lionel-henry in your list example, it seems that `rlang::quo` would do the same as `quote`. In this case, is there any difference or a preference for one over the other?
Comment: Actually it's almost never useful to use `quo()` over `quote()` or `expr()`. Quosures are only important for foreign expressions, not local ones. This is why you should almost always use `enquo()`, but don't have to use `quo()`. You can build raw expressions in your own context and pass them over via `!!`. If that function uses `enquo()`, the raw expression will be wrapped in a quosure appropriately.
Answer: You can actually do this:
    df = data_frame(x = 1:10, y = 10:1, z = 10 * runif(10))
    op = ">="
    val = 5
    filt_expr = paste("x", op, val)

    df %>% filter(eval(parse(filt_expr)))

Comment: You need to specify `parse(text = filt_expr)` then

String based filtering in dplyr - NSE


Fetching Views 3 implementation from code

Question: I am using Drupal 7. What I want to do is to fetch the View 3 implementation from code, rather than from database, so that I can export my view, and put it in a function that would be available to all my team members w/o the need of importing the database script.
Answer: There are quite some different ways to achieve this

Use the ctools bulk export module, this will provide you some example code to use
use the features module, which gives you a full module
Answer: Take a look at hook_views_default_views().
Remember to implement hook_views_api() in mymodule.module file, so that views can find your views stored in code using hook_views_default_views().


Makefile - Just make install (copy files), no target to build

Question: I have a simple makefile project where I just want make install to copy files to a target folder, ie:
all:
   @echo "Nothing to build"

install:
   cp ./*.wav /usr/share/snd

my_custom_target:
   @echo "For testing purposes"

However, whenever I try to build any targets (ie: clean, all, install, my_custom_target, etc), every single one just echos "Nothing to be done for 'clean'", "Nothing to be done for 'all'", etc. My guess is that a makefile project is expecting at least something being built (ie: C/C++ file, etc).
Does anyone have any suggestions on how to proceed with this?
Thank you.
Answer: This seems to indicate that make is not able to find, or not able to correctly parse, your Makefile. What is the file named?
Also, ensure that the commands in each rule (like the cp ./*.wav /usr/share/snd) are prefixed by an actual tab character, not spaces. In the sample that you pasted in, they are prefixed simply by three spaces, but for make to parse it properly, they need to be prefixed by an actual tab character.
One more thing to check is whether there are files named all, install, or my_custom_target. Make does not care about whether some C or C++ file is built; the rules can do anything that you want. But it does check to see if there is a file named the same as the rule, and whether it is newer than the dependencies of the rule. If there is a file, and it is newer than all dependencies (or there are no dependencies, like in this example), then it will decide that there is nothing to do. In order to avoid this, add a .PHONY declaration to indicate that these are phony targets and don't correspond to actual files to be built; then make will always run these recipes, whether or not there is an up-to-date file with the same name.
.PHONY: all install my_custom_target


Nested object type definition

Question: I have a nested object and I would like to write a type definition for it. Here is the object:
const colors = {
  grayscale: {
    black: '#141414',
    darkGray: '#303030',
    white: '#F0F0F0',
  },
  green1: '#1DB954',
  green2: '#1ED760',
}

And here is how I tried to write the type definition:
interface ObjectOf<V> {
  [_: string]: V
}

type ColorObject = ObjectOf<string> | string
type Colors = ObjectOf<ColorObject>

const colors: Colors = {
  ... (same object as above)
}

I used ObjectOf<V> to have an object that can have any key that's a string, but only values of type V. This seems to work for objects that aren't nested.
When I try to use this object like so: colors.grayscale.black, the typescript compiler gives me this error:
Property 'black' does not exist on type 'ColorObject'.
  Property 'black' does not exist on type 'string'.  TS2339

  > 82 |     backgroundColor: colors.grayscale.black,
       |                                       ^

It seems like typescript is ignoring the fact that a ColorObject can be an ObjectOf<>, meaning any string should be a valid key. Instead it thinks it can only be a string, so getting the black key of the grayscale object fails. Why is this, and/or how can I fix the type definition so I can use my colors object as it is?
Comment: It's not ignoring that it *can* be an `ObjectOf`.  It's worried that it *might* be a `string`, and in that case it will not have a property named `black`.  You're only allowed to access properties of a union that exist in all members of the union.  Or you have to eliminate members of the union by testing, such as  `if (typeof colors.grayscale === "string") throw new Error();` and then accessing `colors.grayscale.black`.  Why annotate `colors` as `Colors` at all?  It's a fairly wide type that intentionally forgets the structure of `colors`.  What's your use case?
Comment: I see, that makes sense. My use case is using the colors object and another similar object for styles in React components. Typescript was giving me errors when I used strings like "row" for properties that can only accept certain strings like flexDirection, even though "row" is one of those valid values. I thought I would specify the types of all these objects to avoid this, but I guess that's not the best solution.
Comment: I got rid of the type definition for colors and I might post a different question on the actual problem I'm having (right now I'm using a type cast to appease the compiler but idk if that's the best solution). Thanks for the guidance!
Comment: What about the following:
```ts
const colors = {
  grayscale: {
    black: '#141414',
    darkGray: '#303030',
    white: '#F0F0F0',
  },
  green1: '#1DB954',
  green2: '#1ED760',
} as const

type Colors = typeof colors
```

I tend to use this where a have some concrete structure and I want to build a strong contract from it. I can export only the type and the source of truth over the app will be the `colors` object. When you add remove something in it the type updates automatically.
There are few drawbacks, but still useful I believe.
Comment: @rusev Thank you, this is exactly what I need! Would you like to submit this as an answer so I can accept it? If not, I will post it as my own answer just so other people can see it.
Comment: @NoamBendelac Sure! I'm glad that it helps. And sorry for the bad formatting in the previous comment.
Answer: What about the following:
const colors = {
  grayscale: {
    black: '#141414',
    darkGray: '#303030',
    white: '#F0F0F0',
  },
  green1: '#1DB954',
  green2: '#1ED760',
} as const

type Colors = typeof colors

I tend to use this where I have some concrete structure and I want to build a strong contract from it. I can export only the type and the source of truth over the app will be the colors object. When you add remove something in it the type updates automatically. There are few drawbacks, but still useful I believe.
Comment: I'm pretty sure I don't need `type Colors = typeof colors` because I export `colors` and typescript is aware of its type throughout the project

Nested object type definition


Finding the perimeter for a triangle $ABC$ given a side, angle, and the area

Question: Given a triangle $ABC$, $\angle C$ is $65$ degrees, side $C$ is 10. The area of the triangle is $20.$ What is the perimeter?
Comment: Can I assume size c is adjacent to angle C?  Is it the hypotenuse?
Comment: size c is opposite angle C, it is not a right triangle
Answer: Hint: the area of a non-right triangle is given by:
$$A = \dfrac{1}{2} ab \sin C$$
where $a$ and $b$ are the side lengths and $C$ is $\angle C$.
Hint 2: Law of Cosines which is given by:
$c^2 = a^2 + b^2 -2 ab \cdot \cos C$
Answer: We can grind it out. We have $\frac{1}{2}ab\sin(65^\circ)=10$, so $ab$ is known. But from the Cosine Law, $a^2+b^2-2ab\cos(65^\circ)=100$, so $a^2+b^2$ is known. Thus $a^2+2ab+b^2$ is known, and now we know $a+b$.
Answer: Hints:
You need to find $a+b+c$
You know c, and now you need to find $a+b$
Couple of formulas you could use:
Area = $\dfrac{1}{2} ab \sin C$
$c^2 = a^2 + b^2 -2 ab \cdot \cos C$
You know $c$, $\sin C$, and $\cos C$,
Can you find $a+b$?
One way is to solve for $a$, $b$ and take the sum
Another way is to use $(a+b)^2 = a^2 + b^2 + 2ab$ to find $a+b$ directly from these two above formulas
Answer: The area tells us that the height from $C$ must be $4$. To get from that information to the lengths of the other sides, draw the circumcircle, with center $O$:

What is the radius of the circumcircle?
Because of the Central Angle Theorem, $\angle AOB$ must be $2\times 65^\circ$, so $|AM|=|MB|=5$ must be $R\cdot \sin(65^\circ)$, or in other words $R$ is $\frac{5}{\sin(65^\circ)}$.
Now to find the exact position of $C$, we look for $\angle COM$. It must be such that
$$R(\cos(65^\circ)-\cos(\angle COM)) = 4$$
and a bit of algebra then allows us to find $\angle COM$ as an arccosine. Adding and subtracting 65° gives us $\angle COA$ and $\angle COB$, and then the total perimeter becomes
$$ R\left(2\sin 65^\circ+2\sin \frac{\angle COA}{2} +2\sin\frac{\angle COB}2 \right) $$
Comment: +1: I had (nearly) the same idea but your picture is nicer! :-)


Box2D How to stop Player (Box) from rotating

Question: So I have a player (Box2D box) that can be moved horizontally with 'A' and 'D' using:
 SetLinearVelocity(b2Vec2(speed,  object.getB2Object()->GetLinearVelocity().y));

But when I move the box the player doesn't slide but roles on the corners like so:

I figured out that decreasing the friction of the box and the ground prevents this to some extent but still happens fairly regulary and also makes the player slide further when stopping. I have tried the function SetFixedRotation(true) but this seems to make the player stop moving all together, presumably at the points where it was going to rotate. I also tried SetAngularVelocity(0) but this still makes the box rotate, although very slowly. Is there another way to prevent the player from rotating when moving on a surface? Thanks
[Edit]
After doing what pingul suggested by setting the friction to zero the box hardly rotated. It looked like it was tripping on something every so often so, instead of 10 individual tiles for the floor I removed them and created a wide tile and the problem stopped! Therefore I think the box was tripping on the next tile along. My next problem then is why is this happening as I know the tiles all have the same height, width and position as shown here:
//the number of tiles
const unsigned int MAX_TILES = 10;
for(int i = 0; i < MAX_TILES; i++){
                                 //position                       ,size           ,density    ,linear_damping ,friction ,isdynamic,b2World
    tiles.push_back(new GameObject(vec3(6+i-(MAX_TILES/2), -10, 1),  vec3(1, 1, 0),   1.0f    ,1.0f           ,0.5f      ,false   ,world_b2));
    tiles[tiles.size()-1]->Init(); //Some OpenGL stuff for rendering
    tiles[tiles.size()-1]->getMesh()->setTexture(test_sheet.getTexture(2,0)); //gets a texture from sprite sheet class
}

[Edit 2]
Math Library Using: GLM
Overlapping the tiles in the horizontal direction does nothing but I think it have something to do with this but in the vertical axis. When the player goes on to another tile, rotating or not, the y value changes slightly. This can be either up or down and only changing by +-0.003~. When jumping though it will go back to the very first value when the game starts on any of the floor tiles.
Comment: So what happens if you put the friction to 0?
Comment: please check my edit :)
Answer: There is two function in the body class (Box2D) that might help you with the undesirable rotation your getting
The first one is :
void SetFixedRotation(bool flag)

Wish allow you to fix the rotation
And the other one is:
void SetAngularDamping(float32 angularDamping)

wish will set an amount of angular resistance that depend on the argument you pass to the function
I recommend reading the official Box2D documentation, 'Chapter 6 :Bodies' will give you more information about the position and angle (check page 29 and 30 Damping and Fixed Rotation) section or at least a quick look at box2d b2Body class
I hope this is helpful for you
Answer: I do not know what kind of vector library you use, but I would assume vec3 takes floats or doubles as arguments. Converting vec3(6+i-(MAX_TILES/2) to a floating point number could lead to a small gap between the objects.
Can the objects overlap a small amount? What happens if you change the size to vec3(1.0001, 1, 0)?
Comment: Thanks for being patient. Added an Edit 2
Comment: @MajesticHey Hmm... Your tile code shouldn't be responsible for that discrepancy. What happens if you draw the bounding boxes of the different objects instead of the bitmaps? E.g. make the objects some very apparent colour and draw those instead. Also, could you show the code for moving your character?
Comment: @MajesticHey Did you find a solution to the problem?
Comment: In a way yes. Instead of using a box collider I created a function to add a capsule collider (2 circles with a square in the middle) and this fixed the problem. Sorry I took so long to reply, I haven't logged in in a while.  I saw this and thoughtIi needed to reply so people in the future could have a solution if they had the same problem.


Autoscale a matplotlib Axes to make room for legend

Question: I am plotting a 2D view of a spacecraft orbit using matplotlib. On this orbit, I identify and mark certain events, and then list these events and the corresponding dates in a legend. Before saving the figure to a file, I autozoom on my orbit plot, which causes the legend to be printed directly on top of my plot. What I would like to do is, after autoscaling, somehow find out the width of my legend, and then expand my xaxis to "make room" for the legend on the right side of the plot. Conceptually, something like this;
# ... code that generates my plot up here, then:
ax.autoscale_view()
leg = ax.get_legend()
leg_width = # Somehow get the width of legend in units that I can use to modify my axes
xlims = ax.get_xlim()
ax.set_xlim( [xlims[0], xlims[1] + leg_width] )
fig.savefig('myplot.ps',format='ps')

The main problem I'm having is that ax.set_xlim() takes "data" specific values, whereas leg.get_window_extent reports in window pixels (I think), and even that only after the canvas has been drawn, so I'm not sure how I can get the legend "width" in a way that I can use similar to above.
Answer: You can save the figure once to get the real legend location, and then use transData.inverted() to transform screen coordinate to data coordinate.
import pylab as pl
ax = pl.subplot(111)
pl.plot(pl.randn(1000), pl.randn(1000), label="ok")
leg = pl.legend()

pl.savefig("test.png") # save once to get the legend location

x,y,w,h = leg.get_window_extent().bounds

# transform from screen coordinate to screen coordinate
tmp1, tmp2 = ax.transData.inverted().transform([0, w])
print abs(tmp1-tmp2) # this is the with of legend in data coordinate

pl.savefig("test.png")


How to animate n curves in a plot using matplotlib's animation?

Question: I have n curves that I want to draw using matplotlib's animation (each curve corresponds to a gpx file recorded with a fitness tracker or a smartphone). It works well when using only one track or two tracks. But as soon as I want to adapt it to using n curves, I am lost. Here is my code:
import matplotlib.animation as anim
import matplotlib.pyplot as plt
import numpy as np

tracks  = {}
xdata   = {}
ydata   = {}

# in my case n_tracks would rather correspond to a couple of 100
n_tracks    = 2
n_waypts    = 100

for ii in range(n_tracks):
    # generate fake data
    lat_pts = np.linspace(10+ii*1,20+ii*1,n_waypts)
    lon_pts = np.linspace(10+ii*1,20+ii*1,n_waypts)

    tracks[str(ii)] = np.array( [lat_pts, lon_pts] )

    xdata[str(ii)]  = []
    ydata[str(ii)]  = []

fig = plt.figure()
ax1 = fig.add_subplot( 1,1,1, aspect='equal', xlim=(0,30), ylim=(0,30) )

plt_tracks  = [ax1.plot([], [], marker=',', linewidth=1)[0] for _ in range(n_tracks)]
plt_lastPos = [ax1.plot([], [], marker='o', linestyle='none')[0] for _ in range(n_tracks)]

def animate(i):
    # x and y values to be plotted
    for jj in range(n_tracks):
        xdata[str(jj)].append( tracks[str(jj)][0,i] )
        ydata[str(jj)].append( tracks[str(jj)][1,i] )

    # update x and y data
    for jj in range(n_tracks):
        plt_tracks[jj].set_data(  xdata[str(jj)][:],  ydata[str(jj)][:] )
        plt_lastPos[jj].set_data( xdata[str(jj)][-1], ydata[str(jj)][-1] )

    return plt_tracks, plt_lastPos

anim    = anim.FuncAnimation( fig, animate, frames=n_waypts, interval=20, blit=True )
plt.show()

The dictionary tracks contains the tracks, where for each track we have an array with longitude and an array with latitude data. The dictionary xdata and ydata is used for plotting purposes.
I have two lists with plotting objects, plt_tracks and plt_lastPos, where the first is used for successively plotting the track and the latter to indicate the latest position.
The error message reads RuntimeError: The animation function must return a sequence of Artist objects. So, my mistake seems to be the return statement, but simply adding a , at the end does not help here. Any hint on what I am missing would be greatly appreciated.
Answer: Your are supposed to return an iterable of "artists" (that is of things to draw, that is of result of a "plot" call for example.
plt_tracks is such an iterable.
plt_lastPos also is.
But (plt_tracks, plt_lastPos) (with implicit parenthesis here) is a pair of such iterable. So an iterable of iterable of artists
So, simply put all them in a list. Replace
    return plt_tracks, plt_lastPos

by
    return plt_tracks + plt_lastPos

Comment: @Alf. Same way. Initiate, indeed, with `plt_text = ax1.text(10,10,'')`. Then in your `animate` function, update the text with whatever you want. `plt_text.set_text("i="+str(i))` for example. And add `plt_text` to the list of artists `animate` returns. Note that `plt_text` is a single artist, whereas `plt_tracks` and `plt_lastPost` are list of artist. So it would go `return plt_tracks + plt_lastPos + [plt_text]`
Comment: probably worth its own question, but how would I add a changing text, corresponding to a third artist here, which I would initiate with `plt_text = ax1.text(10,10,'')` ?


Why I get a nullPointerExeption?

Question: I hope you can help me. I get an NullPointerExeption when I want to Put the NodeList / Node to my Map:
Map <String, NodeList> config = null;

public void loadConfiguration() {
    helper helper = new helper();
    NodeList nodes = null;
    nodes = helper.getXPathFromFile("/root/*", "conf/config.xml");

    if (nodes.getLength() > 0) {
        for (int i = 0; i < nodes.getLength(); i++) {
            String NodeName = nodes.item(i).getNodeName();
            NodeList NodeItem = (NodeList) nodes.item(i);
            System.out.println(NodeName); // Here the right Name puts out
            System.out.println(helper.nodelistToString(NodeItem)); // here right inside XML-Code put out
            config.put(NodeName, NodeItem); // Here comes the NullPointerEx.
        }
    }
}

Comment: Debugging always helps! :)
Answer: Your map config is null, that's why you get the NullPointerException. You should initialize it e.g. Map <String, NodeList> config = new HashMap <String, NodeList>();
Answer: It looks like you never initialize your config map.
Change
Map <String, NodeList> config = null;

to
Map <String, NodeList> config = new HashMap<String, NodeList>;

Comment: Is that kind of question worth to be answered ?

Why I get a nullPointerExeption?


Trabalhar com  para otimizar JQuery

Question: Quero estudar mais sobre as

  etc, para otimizar meus projetos.
Exemplo: Tenho 4
 com 2  cada, ao aplicar uma formula em jQuery por exemplo, que some o primeiro  com o segundo  de cada
 utilizando pouca formula. Quero saber como referenciar o primeiro com o segundo de cada linha.
Alguma idéia?
Comment: O primeiro `` de cada `` é dado por `$("tr").children().first()`. É isso que queria saber? Ou até mesmo tudo no seletor, com `$("tr td:first-child")`. Neste ultimo caso é puramente CSS o Jquery nem é relevante
Comment: A forma mais apropriada de fazer depende do objetivo, assim como da estrutura html que está a utilizar. Tente ser mais especifico nesses dois pontos
Comment: Meu único objetivo é estudar a estrutura, porem não sei por o que procurar no google para esse estudo.
Comment: Não ficou muito claro. Vc quer que suma os dois tds de cada linha?
Comment: Se cada linha tem 2 td, vai sumir a table toda.
Comment: Subscrevo o que o @DvD disse, não ficou de fato claro. O que quis dizer com esta ultima afirmação "Quero saber como referenciar o primeiro com o segundo de cada linha" ?
Comment: Não consegui ser claro na pergunta, desculpe-me, o objetivo é estudar o referenciamento da estrutura.. para otimizar os projetos em jQuery, a soma é só um exemplo para o caso de eu ter 150  e 20  em cada , ai imagina o tamanho do jQuery se for fazer soma por soma em cada , entende?
Comment: a ideia é por assim.. jQuery -> some a primeira  com a segunda  de cada  e retorne o resultado no terceiro  de cada  ===>> lembrando, esse é somente um exemplo
Comment: Vc diz somar valores numéricos de uma td a outra?
Comment: o objetivo acho que ficou claro, somente o estudo da estrutura, como navegar pelas tables do html e fazer os referenciamentos pelos  e ... nao encontro nada disso no google
Comment: nao DvD, quero saber como fazer o jQuery entender o que é a primeira  de cada .. a soma é só um exemplo para tentar deixar a pergunta mais clara (sem sucesso) kk...
Comment: isso!, é essa a ideia, tem alguma documentação, ou algum nome especifico para que eu possa me aprofundar nesse referenciamento??
Answer: Para referenciar a primeira td de cada tr, você pode usar duas maneiras:
1ª: com first-child:
$("tbody tr td:first-child").css("color","red");

:first-child é uma pseudo-classe que, neste caso, referencia
  toda primeira td filha de uma tr na tbody.

2ª: com nth-child(1):
$("tbody tr td:nth-child(1)").css("color","red");

Para referenciar a segunda td de cada tr, você pode usar nth-child(2):
$("tbody tr td:nth-child(2)").css("color","red");

Para referenciar a terceira td em diante, basta trocar o index para 3, 4 em diante:
$("tbody tr td:nth-child(index)").css("color","red");

Lembrado que o index de nth-child() no jQuery começa com 1.
Comment: @ThiagoKoller Sim. Estude pseudo-classes e pseudo-elementos e também seletores CSS: https://developer.mozilla.org/pt-BR/docs/Web/CSS/Pseudo-classes e http://www.maujor.com/tutorial/guia-completo-seletores-css3.php
Comment: @ThiagoKoller Interessante também esta resposta: https://pt.stackoverflow.com/a/250488/8063
Comment: isso mesmo!! existe algum nome para eu poder me aprofundar, estudar esses referenciamentos? Para eu saber se ele só funciona com , ou se funciona com  também..
Comment: @ThiagoKoller Funciona com qualquer elemento.

Trabalhar com  para otimizar JQuery


Is this 2d five-fold Venn Diagram original and valid?

Question: Venn diagrams captured my attention a few years ago. One night I decided to see if I could come up with some new Venn Diagrams. After a few hours, this is what I came up with. I'm a web developer not a mathematician, so I'm quite proud of this little creation. I've searched the internet and several books to confirm that this construction is unique. Lastly, I wanted to post it here because I know that the this crowd has more resources and knowledge than are available to me.
Comment: I inserted the image into the post. I hope you do not mind.
Comment: Thank you so much! I like that much better :)
Comment: Looks ok, just a small typo: you have AEC written twice (once as "AEC" and once as "ACE") , one of them is actually ACD.
Answer: It seems okay to me.
You might want to take a look at a very nice paper that appeard in the Notices of the American Mathematical Society in 2006 about Venn diagrams:

Ruskey, Frank; Savage, Carla D.; Wagon, Stan.
The search for simple symmetric Venn diagrams.
Notices Amer. Math. Soc. 53 (2006), no. 11, 1304–1312.

At least I (an AMS member) can access it in PDF format on the web. I don't know if the link will work for someone who is not a member, though.
Comment: There's also the survey by Ruskey and Weston at http://www.combinatorics.org/Surveys/ds5/VennEJC.html
Comment: This is excellent! The link works fine. The paper looks wonderfully interesting. I cant thank you enough.


How to evaluate the following summation

Question: I am trying to find the definite integral of $a^x$ between $b$ and $c$ as the limit of a Riemann sum (where $a > 0$):
$I = \displaystyle\int_b^c \! a^{x} \, \mathrm{d}x.$
However, I'm currently stuck in the following part, in order to find S:
$S = \displaystyle\sum\limits_{i=1}^n \displaystyle{a^{\displaystyle\frac{i(c-b)}{n}}}$
Is there a formula for this kind of expression? Thank you for your help.
Comment: Your series, BTW, is a geometric one.
Answer: Yes, there is a formula. notice that $$a^{i(c-b)/n}=(a^{(c-b)/n})^i.$$ So, your sum is just a sum of a geometric progression.
Answer: Note that:
$$\begin{align}
S &= \sum\limits_{i=1}^n \displaystyle{a^{\displaystyle\frac{i(c-b)}{n}}} \\
&= \sum\limits_{i=1}^n \left(a^{\left(\dfrac{(c-b)}{n}\right)}\right)^i
\end{align}$$
Now, we can use the finite form of the geometric series formula:
$$S = \frac{\left(a^{\left(\dfrac{(c-b)}{n}\right)}\right)-\left(a^{\left(\dfrac{(c-b)}{n}\right)}\right)^{n+1}}{1-a^{\left(\dfrac{(c-b)}{n}\right)}}$$
...and that limit will be pretty nasty, but do-able.  (I think.)
Answer: This might help.  Suppose $y = a^x$. Then $\ln(y) = x\ln(a)$. Differentiating you get
$${y'\over y} = \ln(a),$$
so $$ y' = y\ln(a) = a^x \ln(a).$$
Hence
$$\int a^x\, dx = {a^x\over \ln(a)} + C.$$
Answer: Correct me if I'm wrong, but it looks like $a,b,c$ and $n$ are all constants inside that sum.  So
$$
S = \sum_{i=1}^n a^{\frac{i(c - b)}{n}} = \sum_{i=1}^n \left(a^{\frac{c - b}{n}}\right)^i
$$
which is just a finite geometric sum.  Letting $r = a^{\frac{c - b}{n}}$, this sums to $\frac{1 - r^{n+1}}{1 - r} - 1$.

How to evaluate the following summation


Flip animation between two views on iOS

Question: I have an app that uses the built-in flip animation to switch between the various views.  Everything works, except when I'm flipping back to a view that was a scroll view and it was NOT on the first page.  Meaning:

My scroll view has three pages
User swipes to the third page
User taps the button on the third page to proceed to the next view
when user tries to return to the scroll view the flip animation shows the first page during the flip and then snaps to the correct page after the flip is done.

I'm using [scrollView setContentOffset] to the set the correct page BEFORE the flip animation but that doesn't seem to be enough.  Is there a way to do this?
Comment: you could provide some code... there are many ways you can be doing what you describe...
Answer: One possibility you could check is using setContentOffset:
[scrollView setContentOffset:CGPointMake(pageWidth * pageNumber, 0)];

to move the scrollView origin so that it display page number pageNumber (raging from 0 to N). Or you could try with:
- (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated

but since you do not specify how you do the flip animation, I don't know which one will work for you.
Comment: Thank you.  Let me elaborate: I do use setContentOffset to jump to the correct page, BUT, that doesn't do the trick.  Right now, the views flip and I see the first page of the scrollView during the flip -- as soon as the flip is finished, the scrollView snaps to the correct page.  I'm trying to see if there is a way to see the correct page during the flip.  I'll update my original post to reflect this issue (thank you again).
Comment: where do you call `setContentOffset`? possibly you have to call it in the `viewWillAppear` method of the controller that manages the scroll view...
Comment: Initially in viewDidLoad.  Then I did it in viewDidAppear and I also tried to do it in both place.  It seems like it should work: viewDidLoad and viewDidAppear are called in order before the flip begins and the page offset is set correctly.  But the flip itself still shows the first page.  Then at the end of the flip viewDidAppear gets called again which again sets the page number and at that point the view snaps to the correct page.
Answer: Use
[scrollView setContentOffset:theOffset animated:NO];

You want to suppress animations, since you are performing an animation yourself. You also want to be sure that you set the content offset BEFORE you begin specifying the flip animation, since the animation transforms everything from the current state to whatever new values you provide in the animation block.
Calling it in viewDidLoad or viewWillAppear: should work.
Comment: Thanks.  The issue was indeed starting the animation before the view was set -- I just moved the animation start code and everything fell into place.

Flip animation between two views on iOS


How to understand the compactification of the upper half plane as motivation for Gromov compactification of an arbitrary $\delta$-hyperbolic space??

Question: Let $X$ be a $\delta$-hyperbolic space. Let us define an equivalence relation on geodesic rays $\gamma_1, \gamma_2 :[0,\infty) \rightarrow X$ by {$\gamma_1 \sim \gamma_2\,\, \iff d(\gamma_1(t),\gamma_2(t)) < \infty\}$. The Gromov boundary $\partial X$ is defined as the set of all equivalence classes of geodesic rays in $X$.
Consider the upper half plane $\mathbb{H} = \{z \in \mathbb{C} : im(z)>0\}$ equipped with the hyperbolic metric. I have to first show that its Gromov boundary $\partial \mathbb{H}$ is homemorphic to the unit circle $\mathbb{S}^1$, and also show that we can impose a topology on $\bar{\mathbb{H}} = \mathbb{H} \cup \partial \mathbb{H}$ such that $\bar{\mathbb{H}}$ is compact under this topology.
In the textbook, Geometric Group Theory, by Cornelia Druţu and Michael Kapovich, the basis for the topology on $\bar{X} = X \cup \partial X$, where $X$ is a $\delta$-hyperbolic geodesic space is defined as consisting of metric balls $B(z,r)$ for $z \in X$, and neighbourhoods $U_{x,y}(\xi)=\{z \in \bar{X} : [xz] \cap B(y,k) \neq \phi\}$, where $[xz]$ is any geodesic ray joining $x$ to $z$, $y$ is a point on a geodesic ray joining $x$ to $\xi$, $k > 3\delta$, and $\xi \in \partial X$.
In the textbook A Primer on Mapping Class Groups, $\bar{\mathbb{H}}$ is topologized by the basis consisting of: the usual open sets of ${\mathbb{H}}$ plus one open set $U_P$ for each open half-plane $P$ in ${\mathbb{H}}$. A point of ${\mathbb{H}}$ lies in $U_P$ if it lies in $P$ and a point of $\bar{\mathbb{H}}$ lies in $U_P$ if every representative ray $\gamma(t)$ eventually lies in $P$.
I have understood how the Gromov boundary of $\mathbb{H}$ is homeomorphic to $\mathbb{S}^1$, and also understood how an arbitrary hyperbolic space $X$ can be compactified to get $\bar{X}$ with the topology defined above, but I cannot understand the compactification of $\bar{\mathbb{H}}$ with the respective topology and also how this serves as motivation for the general case.
Would appreciate some ideas to push me in the right direction.
Comment: "I cannot understand" is not a question but a statement. Did you try to work out a homeomorpism from the Gromov compactification of the hyperbolic plane to the closed unit disk? Did you at least get a bijection?
Comment: The hyperbolic upper half plane is homeomorphic to the open unit disk, and this can be shown by using a suitable Mobius transformation, but I am not able to find a mapping that shows the closure of the upper half plane is homemorphic to the closed unit disk with respect to the Up topology mentioned above.
Comment: Well, there is an obvious map sending each hyperbolic geodesic ray to its "end-point" in the boundary circle (assuming that you are working in the unit disk model). Try to analyze this map and see how it goes.
Answer: You are leaving out one very important feature of $\mathbb H$, namely the Morse lemma, which says (with quantifiers inserted properly): every quasigeodesic has finite Hausdorff distance from a geodesic.
This applies in particular to quasigeodesic rays: every quasigeodesic ray in $\mathbb H$ has finite Hausdorff distance from a geodesic ray. Furthermore, two geodesic rays in $\mathbb H$ that have finite Hausdorff distance are equivalent and hence represent the same point in $\partial\mathbb H$.
It follows that the equivalence relation on geodesic rays that defines $\partial\mathbb H$ can be widened to obtain an equivalence relation on quasigeodesic rays --- namely, finite Hausdorff distance --- which still defines $\partial\mathbb H$.
This fact is useful in studying the large scale geometry of $\mathbb H$. For example, you can use geodesic rays to prove that an isometry of $\mathbb H$ induces a homeomorphism of $\partial\mathbb H$. But in the proof of Mostow rigidity you need more: in one of the first steps of that proof, one uses the quasigeodesic ray definition of $\partial\mathbb H$ and the Morse Lemma to prove that a quasi-isometry of $\mathbb H$ induces a homeomorphism of $\partial\mathbb H$. One might summarize this by saying that Gromov's definition of $\partial\mathbb H$ --- namely, the quasigeodesic ray definition --- is more robust, i.e. it is applicable in broader situations than the geodesic ray definition.
And in the general study of $\delta$-hyperbolic spaces $X$, the Morse lemma is still true, providing a robust, "quasigeodesic ray" definition of $\partial X$, which is behind pretty much everything in our understanding of $\partial X$.


Cloud based server for PHP

Question: I plan to open a subscription based website that will be video and image heavy. I have the video and image hosting sorted using Amazons S3 and CDN. now, I will still need a main server to host php/html files and the mysql database.
My question is, is there a scalable solution (that has redundancy incase of spikes) to replace my main server so that I can still server my php and sql processes, but have it's resources increase on demand like the Amazon S3 service does for static files?
Thank you!
Answer: Yes, they are called VPS; virtual private servers. At our company, HostGator's VPS serve us well, and they're cheaper than alternatives.
http://www.hostgator.com/vps-hosting/
Edit: You can change resources on demand, increasing and decreasing, without any modification from your part.
Oh, and by the way, if you need a really good service, there's Rackspace Cloud Servers. They're not exactly cheap though ;). However, if you can afford them, you won't regret this.
Comment: Linode.com have servers based in London.
Comment: Are there any Europe based services?
Comment: Both HostGator and Rackspace have data centers around the world to tackle latency. I think Rackspace are better than HostGator about this.
Answer: VPSes aren't going to scale in the same way that you're thinking of (hand-off). VPSes are just virtualized servers... you still have to manage them like any other server.
If you want a managed server, those are expensive, but will be more hands-off.
I recommend you evaluate this service though: http://phpfog.com/. If you've heard of Heroku in the Ruby webapps world, it's like that but for PHP.
Answer: On AWS you can also find scalable cloud hosting solutions. But on such a IaaS (Infastructure as a Service) provider you have to take care of some sysadmin stuff yourself. You might be better advised with a PaaS (Platform as a Service). This is a kind of abstraction layer on top of cloud technology – simplifying things for you.
We are currently developing such a service for developers in Europe ourselves. We have just posted a comparison of different providers here:

http://blog.fortrabbit.com/comparing-cloud-hosting-platforms/
Comment: Hi, Frank. We don't mind people promoting their products but it does say in the FaQ that you dislose your link to any product mentioned as the community will likely flag it as spam.

Cloud based server for PHP


Wirtinger inequality with nule integral

Question: If $f \in {\mathcal{C}}^1([- \pi , \pi])$, with $f(- \pi) = f(\pi)$, such that $\int_{- \pi}^{\pi} f(t) \, dt = 0$, how can I prove that
$$
\int_{- \pi}^{\pi} {|f(t)|}^2 \, dt \leq \int_{- \pi}^{\pi} {|f'(t)|}^2 \, dt\mbox{?}
$$
Answer: Let $a_0,a_1,a_2,....$ and $b_1, b_2, b_3,....$ the Fourier coefficients of $f$. From $\int_{- \pi}^{\pi} f(t) \, dt = 0$ we get $a_0=0$ and then, by Parseval's identity:
$\int_{- \pi}^{\pi} {|f(t)|}^2 dt=\sum _{n=1}^{\infty}(a_n^2+b_n^2)$
and
$\int_{- \pi}^{\pi} {|f'(t)|}^2 dt=\sum _{n=1}^{\infty}n^2(a_n^2+b_n^2)$.
Comment: Thank you by the observation that $a_0 = 0$, but how can you deduce the Wirtinger inequaliry now?
Comment: $\sum _{n=1}^{\infty}(a_n^2+b_n^2) \le \sum _{n=1}^{\infty}n^2(a_n^2+b_n^2)$
Comment: And how can I prove these inequality?
Comment: This inequality is trivial because $n^2\geq 1$ for all $n\in\mathbb{N}$ and $a_n^2+b_n^2$ is positive
Comment: But if $f(\mathbb{R}) \subset \mathbb{C} \setminus \mathbb{R}$, can I obtain the same with ${|a_n|}^2 + {|b_n|}^2$ instead of ${a_n}^2 + {b_n}^2$?
Comment: I think this should be the real resp. the imaginary part of the coefficient ($c_n=a_n+b_ni \Rightarrow |c_n|^2=a_n^2+b_n^2$) and thus they are always real.
Comment: Ok I understand. Thank you.
Answer: It is a more or less direct consequence of Parseval's identity: We have $$f(x)=\sum_{k\in\mathbb{Z}}\hat{f}(k)e^{ikx}$$
with the fourier coefficients defined as $\hat{f}(\xi):=\frac{1}{2\pi}\int_{-\pi}^\pi f(x)e^{-ix\xi}dx$
and
$$f'(x)=\sum_{k\in\mathbb{Z}}\widehat{f'} (k)e^{ikx}.$$
Let's calculate the coefficients $\widehat{f'} (k)$:
For $\xi=0$ we get $\widehat{f'}(0) = \frac{1}{2\pi}\int_{-\pi}^\pi f'(x)dx=0$ by the presumption. Note that presumption gives us $\widehat{f}(0)=0$, too. Thus we will omit the summand for $k=0$ in the series later. Now for $\xi\neq 0$ with partial integration we obtain
\begin{align}
\widehat{f'}(\xi) &= \frac{1}{2\pi}\int_{-\pi}^\pi f'(x)e^{-ix\xi}dx
= \frac{1}{2\pi}\left(\underbrace{f(x)e^{-ix\xi}|_{-\pi}^\pi}_{0} + i\xi\int_{-\pi}^\pi f(x)e^{-ix\xi}dx\right)\\
&= i\xi\frac{1}{2\pi}\int_{-\pi}^\pi f(x)e^{-ix\xi}dx = i\xi\hat{f}(\xi).
\end{align}
With this calculation and Parseval's identity follows
\begin{align}
\frac{1}{2\pi}&\int_{-\pi}^\pi |f'(x)|^2dx =: \|f'\|_2^2 = \sum_{k\neq 0}|\widehat{f'} (k)|^2\\
&= \sum_{k\neq 0}k^2|\hat{f} (k)|^2
\geq \sum_{k\neq 0}|\hat{f} (k)|^2 \\
&= \|f\|_2^2 := \frac{1}{2\pi}\int_{-\pi}^\pi |f(x)|^2dx.
\end{align}
Multiplying with $2\pi$ gives the statement.

Wirtinger inequality with nule integral