Erros ao compilar programa usando recursos do MySql

Question: Estou aprendendo a usar o MySql, mas tive alguns problemas ao compilar um programa, em C, utilizando os recuros do MySql. Segue erros abaixo:
gcc: error: Usage:: No such file or directory
gcc: error: [OPTIONS]: No such file or directory
gcc: error: Options:: No such file or directory
gcc: error: [-I/usr/include/mysql: No such file or directory
gcc: error: [-I/usr/include/mysql: No such file or directory
gcc: error: [-L/usr/lib/x86_64-linux-gnu: No such file or directory
gcc: error: [-L/usr/lib/x86_64-linux-gnu: No such file or directory
gcc: error: [/usr/lib/mysql/plugin]: No such file or directory
gcc: error: [/var/run/mysqld/mysqld.sock]: No such file or directory
gcc: error: [0]: No such file or directory
gcc: error: [5.7.13]: No such file or directory
gcc: error: [-L/usr/lib/x86_64-linux-gnu: No such file or directory
gcc: error: VAR: No such file or directory
gcc: error: is: No such file or directory
gcc: error: one: No such file or directory
gcc: error: of:: No such file or directory
gcc: error: pkgincludedir: No such file or directory
gcc: error: [/usr/include/mysql]: No such file or directory
gcc: error: pkglibdir: No such file or directory
gcc: error: [/usr/lib/x86_64-linux-gnu]: No such file or directory
gcc: error: plugindir: No such file or directory
gcc: error: [/usr/lib/mysql/plugin]: No such file or directory
gcc: error: unrecognized command line option '--cflags'
gcc: error: unrecognized command line option '-fno-omit-frame-pointer]'
gcc: error: unrecognized command line option '--cxxflags'
gcc: error: unrecognized command line option '-fno-omit-frame-pointer]'
gcc: error: unrecognized command line option '--libs'
gcc: error: unrecognized command line option '--libs_r'
gcc: error: unrecognized command line option '--plugindir'
gcc: error: unrecognized command line option '--socket'
gcc: error: unrecognized command line option '--port'
gcc: error: unrecognized command line option '--libmysqld-libs'
gcc: error: unrecognized command line option '--variable=VAR'

Esses erros apareceram no terminal, do ubuntu, após eu dar o comando para compilar o programa:
~$ gcc teste.c -o teste $(mysql_config -libs)

Para usar o MySql eu instalei o mysql-server e o mysql-client:
~$ sudo apt-get install mysql-server mysql-client

A instalação correu bem e com sucesso. Para testar eu criei tabelas e inseri elementos, na mesma, usando comandos diretos pelo terminal e não tive problemas, então, tenho certeza q a instalação ocorreu de acordo.
Para poder usar os recursos do mysql em C, eu instalei as libs a partir do seguinte comando:
apt-get install libmysqlclient-dev

Aparentemente essa instalação também ocorreu com sucesso, porém, quando compilo o programa de teste, ocorrem os erros que citei acima. Segue abaixo o programa:
#include "stdio.h"
#include "stdlib.h"
#include <mysql/mysql.h>

void main(void)
{
    MYSQL *hMsql = null;
    mysql_init(hMsql);
}

O primeiro erro indica que o compilador não está encontrando os diretórios do mysql, porém, não sei como fazê-lo incluir os diretórios corretamente.
Como faço para incluir corretamente os diretórios do mysql?
Answer: Isso é erro de digitação nesta linha:
~$ gcc teste.c -o teste $(mysql_config -libs)

É --libs e não -libs
Veja a diferença digitando certo:
[user@server ~]$ mysql_config --libs
-rdynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto

E errado:
[user@server ~]$ mysql_config -libs
Usage: /usr/lib/mysql/mysql_config [OPTIONS]
Options:
        --cflags         [-I/usr/include/mysql  -g -m32 -fasynchronous-unwind-tables -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv -fPIC   -DUNIV_LINUX -DUNIV_LINUX]
        --include        [-I/usr/include/mysql]
        --libs           [-rdynamic -L/usr/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm -lssl -lcrypto]
        --libs_r         [-rdynamic -L/usr/lib/mysql -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -lssl -lcrypto]
        --plugindir      [/usr/lib/mysql/plugin]
        --socket         [/var/lib/mysql/mysql.sock]
        --port           [0]
        --version        [5.1.58]
        --libmysqld-libs [-rdynamic -L/usr/lib/mysql -lmysqld -ldl -lz -lpthread -lcrypt -lnsl -lm -lpthread -lrt -lssl -lcrypto]

No caso, pode notar que todos os erros que estão na sua pergunta são causados pelo help retornado no lugar do caminho esperado.
Comment: Entendi! Consegui compilar, com sua dica. Obrigado pelo esclarecimento.


Inequality on sum and difference of two unimodular complex numbers

Question:
Given two complex numbers $z,w$  with unit modulus (i.e., $ |z|=|w|=1$), which of the following statements will always be correct?
a.) $|z+w|\lt\sqrt2$ and $|z-w|\lt\sqrt2$
b.) $|z+w|\le\sqrt2$ and $|z-w|\ge\sqrt2$
c.)  $|z+w|\ge\sqrt2$ or $|z-w|\ge\sqrt2$
d.) $|z+w|\lt\sqrt2$ or $|z-w|\lt\sqrt2$
Source [ISI entrance examination]

It is a multiple choice question and only one option is correct.
My approach: As modulus of $z$ and $w$ is 1. Let $z=e^{i\alpha_1}$ and  $w=e^{i\alpha_2}$. Now,
$$|z+w|= |e^{i\alpha_1}+e^{i\alpha_2}|$$
$$|z+w|=|2 cos(\frac{\alpha_1-\alpha_2}{2})e^{\frac{i(\alpha_1+\alpha_2)}{2}}|$$
$$|z+w|=2 |cos(\frac{\alpha_1-\alpha_2}{2})|$$
I don't know how to proceed after this. Any help would be appreciated.
Comment: @MartinR I have cross verified with the original question paper and edited the question. I think there is a printing mistake in my book.
Comment: @MartinR You are right, but these are the options given in the question.
Comment: @user376343 yeah, by using triangle inequality we know that this is the range of $|z+w|$. But these are the same options as given in the original paper and the answer is given as option C.
Comment: Could there be a typo and it is c.)  $|z+w|\ge\sqrt2$ **or**  $|z-w|\ge\sqrt2$ ?
Comment: @MartinR Yeah the answer is given as C. maybe there is some typo, i don't know.
Answer: (C) holds as a consequence of the parallelogram law:
$$
 |z+w|^2 + |z-w|^2 = 2(|z|^2+|w|^2) = 4
$$
so that at least one of  $|z+w|^2$ or $|z-w|^2$ must be $\ge 2$.
I leave it to you to find counterexamples for (A), (B), and (D). These can easily be found by choosing $z, w$ from $-1, 1, i$.
Comment: @Buraian: No problem! I don't think that this can be solved with the triangle inequality alone, because it becomes wrong with other norms which are not induced by an inner product. Try it with $\Vert x+iy \Vert = (x^4+y^4)^{1/4}$.
Comment: Thank you for correcting me
Comment: I am having difficulty understanding this part of your comment : "because it becomes wrong with other norms which are not induced by an inner product.". Could you explain in a bit more detail? If I understood correctly, those concepts you mentioned are from linear algebra, are those necessary for speaking of length of complex numbers?/ How do they help us here?
Comment: @Buraian: The parallelogram law does not hold for arbitrary norms, but only if the norm is related to an inner product. See https://en.wikipedia.org/wiki/Parallelogram_law#The_parallelogram_law_in_inner_product_spaces


Jquery drop down menu offset help

Question: This is my third jquery script, and parts of this have been taken from other scripts. I'm trying to implement the following feature:
I've spent 4 hours trying to figure out how to get the submenu to display left if the browser window is too small. Currently it only works on large resolutions too. I found one script on here, but it only detected it on page load. This script used offset(), and this caused my marquee to fail on firefox. I'd like to avoid this if possible.
The menu is running here: http://www.mantisclan.com/beta/dropdown/
I'd like to use .addClass and .removeClass to set the left: position of the submenu.
Thanks for the help, I will learn from this.
Answer: So it seems to work here: http://jsfiddle.net/JLUqH/2/. However I don't like this effect because it is quite impossible to control the menu, it pops up, collapses very fast.
Try changing the event from hover to click.
There are a lot of jQuery plugins that handle drop down menu creation for you: 38 jQuery And CSS Drop Down Multi Level Menu Solutions
Comment: Haha wow I actually had my first request working, I actually didn't test my last bit of code before coming here. Thanks for clarifying that xD. I only need help with detecting the window size, thanks!
Comment: document.body.clientHeight/Width gives you browser window height/width http://www.howtocreate.co.uk/tutorials/javascript/browserwindow

Jquery drop down menu offset help


playframework select helper filtering options or setting options based on another select

Question: I have two select dropdowns,
The options in "waypointname" should be based on the current selection in "regionname,
When I code this not using the PF helpers (raw html), I set the optiosn in
waypoints to include the full list of options for all regions, then filter using javascript based on value element.
For example, if region value 2 is selected, all waypoints whos value == 2 gets filtered and shown.
This approach is not working with the helpers which I would like to use.
Mostly because the Maps which I am providing don't allow
duplicate keys.
Is it possible?,  or is there another approach,
thanks ,
@select(
    insForm("regionname"),
    options(ComboBoxOpts.regionsMap),
    'id -> "region_field",
    '_label -> "Region Selection",
    '_showConstraints -> false
)

@select(
    insForm("waypointname"),
    options(ComboBoxOpts.waypointsMap),
    'id -> "waypoint_field",
    '_label -> "WayPoint Selection",
    '_showConstraints -> false
)

Answer: Other approach is JavaScript (probably jQuery), in your controller you need to create JSON representation of your waypoints grouped by regions and use it in view as JS variable, so after changing regionname value you can just fetch them from collection and render waypointname select using JavaScript.
It's fast, efficient and popular solution.
Comment: Thanks,  I figured that is really the only practical solution at this point,


how to create a service in python in windows?

Question: I want to run a service in windows which will keep running in background and will run a cron with specific time.
how i can do that in windows using python?
Comment: See {Creating a python win32 service}(http://stackoverflow.com/questions/263296/creating-a-python-win32-service).
Answer: Use pywin32. A tutorial was written (in 2005 mind you) here about how one might do that.
Answer: Make sure win32 api is installed. Basically, you subclass the BasicNTService. The win32 package docs has some more information. I also have a working example in some code I wrote that does this.
WindowsServer.py that also mixes in Pyro for a Python remote control agent.
Answer: A combination of cx_freeze and srvany could do the job.
See this for srvany usage (replace dropbox with your exe)


Receiving http status code with grails

Question: I'm trying to receive status code with url calls.(Using grails)
def http = new HttpResponseDecorator(url)
    // Authentication header
    http.auth.basic(username, password)
    // Http request method. Pulls out json file
    http.request(Method.GET) {
        response.success = {
            render "Success!"
        }
        response.failure = { resp ->;
            render resp
        }
    }

Trying this code snippet to receive make url calls, but I can't figure out how to pull out status code from this.
What I want to do is sending error messages depending on what status code I'm getting.(for example, 400 prints forbidden message of my choice)
Any suggestions for a class to receive status code of the GET calls?
Answer: The resp argument to your response.failure closure has a status you can check.
response.failiure = { resp ->
    if (resp.status == 400) {
        // render forbidden message
    }
}

See the Response Handlers section of the httpbuilder docs for more information and examples.

Receiving http status code with grails


Are pictures of human faces linear in high dimensional space?

Question: As I understand it, PCA can pick out structure if the data is linear. Given that it works on pictures of human faces to produce so called eigenfaces, does this mean these pictures of human faces are linear in the high dimensional space? If so, why?
Answer: Essentially, yes.
Pictures of human faces are closely approximated by 9-dimensional linear subspaces under varying lighting conditions. The paper referenced below shows this under the assumptions that light reflects off of faces according to the Lambertian model and the fact that human faces can be approximated by a convex surface. The approximation is quite good, as the paper shows that the 9-dimensional model captures about 98% of the energy of the actual images. The "why" is the subject of the paper. It's been a while since I've read it, but if you have questions about the paper I can do my best to answer them.
Reference: R. Basri and D. Jacobs, "Lambertian reflection and linear subspaces" IEEE Transactions on Pattern Analysis and Machine Intelligence, vol. 25, no. 3,pp. 218–233, 2003.


Qual número máximo de itens que eu posso por dentro de uma List no C#?

Question: Estou com diversas dúvidas de performance na minha aplicação. Qual o número máximo de itens que eu posso por dentro da minha List<T> e qual o "aceitável" dentro das boas práticas.
Comment: https://stackoverflow.com/questions/2009217/whats-the-max-items-in-a-listt
Comment: O limite tá na resposta do bigown. Agora, quanto a boas práticas: em geral quando se deseja melhorar performance o primeiro ponto a atacar é a complexidade dos algoritmos que você usa, não o tamanho das suas estruturas. Se o problema for algoritmo inadequado, aí sim você pode pensar em trocar a estrutura para poder usar outro algoritmo.
Answer: Já que o tipo do índice de acesso ao objeto do List é um int (.NET Core) o limite teórico é 2 elevado a 31 ou 2.147.483.648.
Mas isso é mais complicado do que parece. Em geral cada objeto pode ter só 2GB de tamanho total alocado. Então a quantidade de itens que realmente pode ter depende do tipo T. Quanto maior ele for, menos itens pode alocar. Lembrando que se T é um tipo por referência seu tamanho é sempre 4 ou 8 bytes dependendo da arquitetura.
Tem mais um detalhe. Em 64 bits é possível ligar a capacidade de aumentar o tamanho do objeto com a diretiva do framework <gcAllowVeryLargeObjects> (disponível no 4.5 pra frente, e claro, no Core), aí em tese é possível trabalhar com todos os itens que o índice suporta. Só acho que será prático com objetos pequenos ou referência, e de preferência se tiver muita memória RAM.
Se precisar de mais itens que 2 bilhões, precisa de uma estrutura diferente, pode ser até usado o List como referência e mudar o índice para um long que fica virtualmente impossível estourar.
Lembre-se que qualquer coisa que faça a memória virtual agir para ficar trocando páginas da memória RAM para armazenamento secundário como HDD ou SSD pode tornar a aplicação em tragédia de performance. E como esse negócio de boas práticas é conversa mole, não tem como saber quando passou do limite assim. Tem que medir, tem que analisar, simular, tem que especificar onde sua aplicação pode rodar bem e deixar a pessoa aceitar a degradação se rodar com menos RAM do que você especificou.
Coloquei no GitHub para referência futura.
Comment: @LeonardoBonetti não é algo tão simples, em código só dá para saber aproximado (https://pt.stackoverflow.com/q/199618/101). Tem ferramentas de perfilamento: https://pt.stackoverflow.com/q/108239/101.
Comment: você sabe alguma ferramenta ou comando para eu saber quanto de memória(RAM) X objeto está utilizando?


Is this inheritance, and if not what is it?

Question: So, I've always learned that inheritance is about extending existing classes in Java and Python. This involves calling the constructor of the parent class through super in Python, or extends in Java.
Today, I wanted to make a custom implementation of scikit-learn's OneHotEncoder object that just works on strings. It encodes them to sparse vectors or decodes sparse vectors back to strings:
ALL_LETTERS = string.ascii_letters + ".,;'"
ALL_LETTERS_ARRAY = np.array(list(ALL_LETTERS))

class WordEncoder:
    def __init__(self):
        self.encoder = OneHotEncoder(sparse=False).fit(ALL_LETTERS_ARRAY.reshape(-1, 1))

    def transform(self, word):
        word = np.array(list(word)).reshape(-1, 1)
        return self.encoder.transform(word)

    def inverse_transform(self, X):
        word_arr = self.encoder.inverse_transform(X).reshape(-1,)
        return ''.join(word_arr)

So, this class doesn't inherit all of the OneHotEncoder class attributes or methods.
Is this good OOP design? I often see the word "wrapper" in various docs, is that what this is? So yeah, just trying to write good, clean code and wondering all these things.
Comment: I'm not really sure what you are asking here... "So, this class doesn't inherit all of the" there is no inheritance here, it doesn't inherit *any* `OneHotEncoder` attributes/methods. This is composition. That's fine, if that's what you are asking. There are people of the opinion that you should *never* use inheritance and just stick with composition.
Comment: OK, then no, this isn't inheritance. Inheritance from `OneHotEncoder` would require something like `class MyEncoder(OneHotEncoder): ...`
Comment: I was asking if this counts as inheritance (I thought the title was clear, sorry). I was also asking what this is called if not inheritance, and whether it's good practice. I will clarify the question even though someone else correctly interpreted it and answered it.
Answer: Seeing that WordEncoder has a OneHotEncoder instance, I would say what you have done is an example of composition, rather than inheritance. And your design is perfectly fine. This article may be useful for understanding the difference between inheritance and composition.
Comment: Awesome, thank you. Reading the article now.


Banco de dados não aparece as informações

Question: Bom eu criei um banco de dados no PhpMyAdmin com nome alunos uma tabela chamada informacoes e coloquei os dados nela...
Daí fui adicionar ela no meu site quando adiciono aparece o código, em vez das informações da tabela...
Segue meu código abaixo:
< ?php
$tabela = msql_query("SELECT * FROM `informacoes`") ;
    while($resultado = mysql_fetch_array($tabela)){

    }

    $host = "localhost";
    $bd = "alunos";
    $user = "root";
    $senha = "";

    $conexao = mysql_connect ($host, $user, $senha) or die (mysq_error());
    mysql_select_db($bd, $conexao);

    echo"informacoes $alunoid
$nome
$email
$turno
$UF
";

? >

Answer: Faça a conexão primeiro e depois a pesquisa, tenta assim:
< ?php

$host = "localhost";
$bd = "alunos";
$user = "root";
$senha = "";

$conexao = mysql_connect ($host, $user, $senha) or die (mysq_error());
mysql_select_db($bd, $conexao);

$tabela = msql_query("SELECT * FROM informacoes") ;
    while($resultado = mysql_fetch_array($tabela)){
       echo "Informações: " . $resultado['idaluno'] . "
" . resultado['nomealuno'] ."
". resultado['email'] . "
". resultado['turno'] . "
" . resultado['uf'] . "
";
    }

? >


Proving that the partial order for adding a dominant real is weakly homogeneous

Question: I am trying to prove that the partial order that adds a dominant real is weakly homogeneous. This is listed as exercise IV.4.17 of Kunen's Set Theory (the "new" one).
The details are as follows:

Two elements $p, q$ of a partial order $(\mathbb P, \leq)$ are said to be compatible if there exists $r\leq p, q$ in $\mathbb P$.
A partial order $\mathbb P$ is said to be weakly homogeneous if for every $p, q \in \mathbb P$ there exists an automorphism $\phi$ of $\mathbb P$ such that $\phi(p)$ and $q$ are compatible.
The partial order in question is the set $\mathbb P$ of all pairs $(p, F)$ where $p$ is a function into $\mathbb N$ whose domain is a finite subset of $\mathbb N$ (that is, $p \in \text{Fn}(\mathbb N, \mathbb N)$) and $F$ is a finite set of sequences of natural numbers (that is, $F \in [\mathbb N^{\mathbb N}]^{<\omega}$). We say that $(p, F)\leq (q, K)$ iff $p$ extends $q$ as a function, if $K\subseteq F$ and if for all $i \in \text{dom } p\setminus \text{dom } q$ and for all $f \in K$, $p(i)>f(i)$. It is easy to verify that $\mathbb P$ is a partial ordered set whose maximum element is $(\emptyset, \emptyset)$.

I am trying to prove that $\mathbb P$ is weakly homogeneous. I noticed that given $(p, F)$, $(q, K)$, in order to show that $\phi$ exists it is enough to consider the case $\text{dom }p=\text{dom }q$. I tried to "swap" $p$ by $q$ within the whole set (including within the functions $f$'s in the $F$'S). The function $\phi$ that I obtained this way a bijection whose inverse is itself and it carries $(p, F)$ in something compatible with $(q, K)$, but I believe that it is not increasing.
Can someone point me out how to construct such $\phi$?
Comment: Note that any two conditions with the same stem (the $p$ part) are compatible.
Comment: @AsafKaragila I believe this is what I tried to work with in my idea of "swapping" $p$ by $q$. My problem is: Imagine $p=\{(0, 0)\}$, $q=\{(0, 2)\}$ and $F=\{f\}$ with $f(0)=1$. Then $(p, F)\leq (\emptyset, F)$, so we need $\phi(p, F)=(q, F')$ for some $F'$. We are probably going to have that $F'=\{f'\}$ for some $f'$, so $\phi(\emptyset, F)$ will be either $(\emptyset, F')$ or $(\emptyset, \emptyset)$. But neither options work since $\phi(\emptyset, \emptyset)=(\emptyset, \emptyset)$ and $(\{(0, 0)\}, \{f''\})\not\leq(\emptyset, \{f'\})$ no matter what $f'$ is so I'm stuck.
Answer: I don't think this is correct, and in fact, if $\pi$ is an automorphism of $\mathbb{P}$ then $\pi(p)\leq p\leq\pi(p)$ for all $p$, so it couldn't achieve what is desired.
To see this,  let's first replace $\mathbb{P}$ with the forcing-equivalent version $\mathbb{P}'$, given by modding out by the equivalence relation $p\approx q\iff p\leq q\leq p$; if we had an automorphism $\pi$ of $\mathbb{P}$ and $p$ such that $\pi(p)\not\leq p$ or $p\not\leq\pi(p)$, then $\pi$ would induce a non-trivial automorphism of $\mathbb{P}'$. So it suffices to see there are no non-trivial automorphisms of $\mathbb{P}'$. Note that $\mathbb{P}'$ is isomorphic to the forcing $\mathbb{Q}$ with conditions $(f,F)$ where for some $n<\omega$, we have $f:n\to\omega$ and $F:[n,\omega)\to\omega$,
and ordering $(f,F)\leq(g,G)$ iff $f\supseteq g$ and $f(i)\geq G(i)$ for all $i\in\mathrm{dom}(f)\cap\mathrm{dom}(G)$ and $F(i)\geq G(i)$ for all $i\in\mathrm{dom}(F)$.
(Here is a little further explanation as to the isomorphism between
$\mathbb{P}'$ and $\mathbb{Q}$: Given a condition $p=(f,K)\in\mathbb{P}$,
where $f:n\to\omega$ and $K$ is a finite set of functions,
if $K=\emptyset$, then send $p$ to $(f,F_0)\in\mathbb{Q}$, where $F_0$ is the constantly $0$ function (with domain $[n,\omega)$), and if $K=\{g_1,\ldots,g_m\}$ where $m\geq 1$,
send  $p$ to $(f,F)$ where $F:[n,\omega)\to\omega$ and $$F(i)=1+\max(g_1(i),\ldots,g_m(i))$$ for $i\in[n,\omega)$. I have used ``$1+$'' here, and the lower bound function $F_0$, since in the definition of the ordering of $\mathbb{Q}$ I only demand $f(i)\geq G(i)$, not $f(i)>G(i)$, whereas in your definition of $\mathbb{P}$, you use $>$ at the analogous point. It is more convenient for me to have a function always there, so I am forced to use $\geq$ instead of $>$.)
So suppose $\pi:\mathbb{Q}\to\mathbb{Q}$ is an automorphism. We want to see that $\pi=\mathrm{id}$. The plan is to figure out various features
of conditions which must be preserved by $\pi$, until we eventually see that $\pi=\mathrm{id}$. Note that since $\pi$ is an automorphism,
it certainly preserves $\leq$ and compatibility.
Let $\mathbb{Q}_n$ be the set of conditions $(f,F)\in\mathbb{Q}$ such that $\mathrm{dom}(f)=n$.
Claim 1: $\pi``\mathbb{Q}_0=\mathbb{Q}_0$.
Proof: Just note that $p\in\mathbb{Q}_0$ iff $p$ is compatible with every other
condition in $\mathbb{Q}$. Since this property must be preserved by $\pi$, the claim follows.
Claim 2: Let $p=(f,F)\in\mathbb{Q}_{n+1}$. Then $(\emptyset,f\cup F)$
is the $\leq$-least element $p_0\in\mathbb{Q}_0$ such that $p\leq p_0$.
Proof: Easily $(f,F)\leq(\emptyset,f\cup F)$. But if $(\emptyset,g\cup G)\in\mathbb{Q}_0$ where $g:n\to\omega$ and $G:[n,\omega)\to\omega$,
and if $(f,F)\leq(\emptyset,g\cup G)$, then just note that $(\emptyset,f\cup F)\leq(\emptyset,g\cup G)$.
So define $p_0$ from $p$ in this manner for each $p\in\mathbb{Q}$.
By the two claims, the operation $p\mapsto p_0$
is preserved by $\pi$, i.e. $\pi(p_0)=\pi(p)_0$.
Claim 3: Let $p=(f,F)\in\mathbb{Q}_{n+1}$. Then there are exactly
$n$ elements $q\in\mathbb{Q}$ such that $p<q<p_0$.
Proof: If $n=0$, so $\mathrm{dom}(f)=\{0\}$, this just says there are no elements $q\in\mathbb{Q}$
such that $p<q<p_0$, i.e. no $(g,G)$ such that $$(f,F)<(g,G)<(\emptyset,f\cup F).$$
This is straightforward to see. (If $(\emptyset,h\cup H)<(\emptyset,f\cup F)$
where $\mathrm{dom}(h)=\{0\}$ and $H:[1,\omega)\to\omega$, then either $h(0)>f(0)$, or there is some $i\in[1,\omega)$ such that $H(i)>F(i)$, but in either case, then $(f,F)\not\leq(\emptyset,h\cup H)$.
If $n=1$, so $\mathrm{dom}(f)=\{0,1\}$, it says there is exactly one $q\in\mathbb{Q}$ such that $p<q<p_0$, i.e. exactly one $(g,G)$ such that $$(f,F)<(g,G)<(\emptyset,f\cup F).$$
This unique $(g,G)$ is just $g=f\upharpoonright\{0\}$ and $G:[1,\omega)\to\omega$ is $G(1)=f(1)$ and $g(i)=F(i)$ for $i>1$. It is straightforward to see that $(g,G)$ is unique such.
If $n>1$, it is similar; we get the conditions of the form $(g,G)$
where $g=f\upharpoonright\{0,\ldots,i\}$ where $i<n-1$ and $G$ agrees appropriatley with $f$ and $F$.
Claim 4: $\pi``\mathbb{Q}_{n}=\mathbb{Q}_{n}$ for each $n<\omega$.
Proof: This is an immediate consequence of the preceding claims.
Given $p=(f,F)\in\mathbb{Q}$, let $C_{np}=\{q\in\mathbb{Q}_n\bigm|q\text{ is compatible with }p\}$. Since $\pi``\mathbb{Q}_n=\mathbb{Q}_n$,
we get:
Claim 5: $\pi``C_{np}=C_{n\pi(p)}$.
Claim 6: Let $p,q\in\mathbb{Q}_{n+1}$ with $p=(f,F)$ and $q=(f,G)$ (the same first stem $f$). Then $\pi(p),\pi(q)\in\mathbb{Q}_{n+1}$ have a common stem $f'$.
Proof: This follows immediately from the fact that $\pi``\mathbb{Q}_{n+1}=\mathbb{Q}_{n+1}$ and the fact that
$p_0,p_1\in\mathbb{Q}_{n+1}$ are compatible iff the have the same stem. QED (Claim 6).
Since $\pi$ is also surjective, this means that for each $n$,
there is a bijection $\sigma_n:\omega^n\to\omega^n$
which specifies the action of $\pi$ on the stems
of elements of $\mathbb{Q}_n$, i.e. if $(f,F)\in\mathbb{Q}_n$ then $\pi(f,F)=(\sigma_n(f),F')$ for some $F'$.
Claim 7: $\sigma_n=\mathrm{id}$ for each $n$.
Proof: Suppose not and let $n$ be least such that $\sigma_n\neq\mathrm{id}$.
Let $i<n$ be least such that for some $f\in\omega^n$, we have $\sigma_n(f)(i)\neq f(i)$. Let $m<\omega$ be the least possible value of $f(i)$ where $f$ is such.
Now suppose $i=n-1$. Since $\sigma_n$ is a bijection, we can find $g\in\omega^n$ such that $\sigma_n(g)=f$. By the minimalities, $g\upharpoonright n-1=f\upharpoonright n-1$ and $g(n-1)\geq f(n-1)$. Suppose $g(n-1)>f(n-1)$. Let $p\in\mathbb{Q}_n$ with $p=(f,F)$ and $q\in\mathbb{Q}_n$ with $q=(g,G)$ (for some $F,G$).
So $\pi(p)=(\sigma_n(f),F')$ and $\pi(q)=(\sigma_n(g),G')$ for some $F',G'$.
Note that because $g\upharpoonright n-1=f\upharpoonright n-1$ and $g(n-1)>f(n-1)$,
we have $C_{0p}\subsetneq C_{0q}$. Therefore by Claim 5, $C_{0\pi(p)}\subsetneq C_{0\pi(q)}$.
But because $\sigma_n(f)\upharpoonright n-1=f\upharpoonright n-1=\sigma_n(g)\upharpoonright n-1$
and $$\sigma_n(f)(n-1)>f(n-1)=\sigma_n(g)(n-1),$$ we actually have
$C_{0\pi(q)}\subsetneq C_{0\pi(p)}$, contradiction. So $g(n-1)=f(n-1)$.
But then with $p,q$ as before, we have $C_{0p}=C_{0q}$, so again by Claim 5,
$C_{0\pi(p)}=C_{0\pi(q)}$, but this gives a contradiction much like before.
So $i<n-1$.
Let's define, for $k<\omega$ and $p\in\mathbb{Q}$,
$$D_{kp}=\{q\in\mathbb{Q}_k\bigm|\exists q'\in\mathbb{Q}_k\ [q,q'\text{ have the same stem and }q'\text{ is compatible with }p]\}.$$
We know that  $q,q'\in\mathbb{Q}_k$ have the same stem iff $\pi(q),\pi(q')$ have the same stem. So $\pi``D_{kp}=D_{k\pi(p)}$.
Now by minimality of $n$, $\sigma_{i+1}(f')=f'$ for all $f'\in\omega^{i+1}$.
Let $p=(f,F)\in\mathbb{Q}_n$ be such that $\sigma_n(f)(i)\neq f(i)$. We have $\sigma_{i+1}(f\upharpoonright(i+1))=f\upharpoonright(i+1)$. Note that
for $q\in\mathbb{Q}_{i+1}$, there is $q'\in\mathbb{Q}_{i+1}$
with the same stem as $q$ and with $q'$ compatible with $p$,
iff the stem of $q$ is $f\upharpoonright(i+1)$. That is, with the notation just introduced above, $$D_{i+1,p}=\{(f',F')\in\mathbb{Q}_{i+1}\bigm|
f'=f\upharpoonright(i+1)\}.$$ So $D_{i+1,\pi(p)}=\pi``D_{i+1,p}=D_{i+1,p}$,
since $\sigma_{i+1}=\mathrm{id}$. But since $\sigma_n(f)(i)\neq f(i)$,
this is impossible, i.e. in fact $$D_{i+1,\pi(p)}=\{(f',F')\in\mathbb{Q}_{i+1}\bigm|f'=\sigma_n(f)\upharpoonright(i+1)\}\neq D_{i+1,p}.$$
Contradiction. QED (Claim 7)
Claim 8: $\pi=\mathrm{id}$.
Suppose not and let $n$ be least such that $\pi\upharpoonright\mathbb{Q}_n\neq\mathrm{id}$. Since $\sigma_n=\mathrm{id}$, for each $(f,F)\in\mathbb{Q}_n$ we have $\pi((f,F))=(f,F')$
for some $F'$. Let $m$ be least such that for some $p=(f,F)\in\mathbb{Q}_n$,
letting $p'=(f,F')=\pi((f,F))$, we have $F'(m)\neq F(m)$.
Note that (since $F'(m)\neq F(m)$) we have $C_{m+1,p}\neq C_{m+1,p'}$, and in fact the set of stems
of conditions in $C_{m+1,p}$ is distinct from the set of stems of conditions in $C_{m+1,p'}$. But $\pi``C_{m+1,p}=C_{m+1,p'}$ and since $\sigma_{m+1}=\mathrm{id}$,
$\pi\upharpoonright\mathbb{Q}_{m+1}$ preserves stems, and therefore
the set of stems in elements of $C_{m+1,p}$ is the same as those in $C_{m+1,p'}$,
contradiction. QED.

Edit: However, a weaker but related condition does hold for $\mathbb{Q}$:
Below every condition $p\in\mathbb{Q}$, the forcing below $p$,
i.e. the suborder with conditions $\{q\in\mathbb{Q}\bigm|q\leq p\}$, is isomorphic to $\mathbb{Q}$. This is enough to get, for example, that statements about elements of the ground model are all decided by the top condition.


how do i check load on a xen host

Question: I have just started to play ariund with xen virtualization. I want to know stuff like how high the load is on the host system, how can i rind out this sort of information from when logged in to the dom0
Answer: Try xm top and other xm commands as xm list.
Comment: or xl top if you're using the new xl toolstack.  It actually just calls xentop though.
Answer: Some versions of virt-manager give you a sum of all loads as the load of the Dom0.
What exactly do you want to know?
Comment: I dont think i can use virt manager, i do not have any gui installed on the host. it is a pretty clean debian install. What i want to find out primarily is how much cpu is used. Running htop on the host machine would do.
Comment: htop and top will only show the load of the Dom0 system. This is propably not what you want, since your running DomUs add to the load on your real CPUs. So do you want to see the total load on your real cpus or just the Dom0 load of its virtual cpus?
Comment: I want to se the total load of my real cpus
Comment: @Matt propably `xentop`. But is seems like Joelbitar has lost the interest in his own question.
Comment: then maybe top is what you're after?
Answer: xentop and xenmon.py are good tools for a general view

how do i check load on a xen host


Discrete or Continuous Variables

Question: I am having a hard time determining if these are either discrete or continuous.
The number of visits to a website in a particular week.

I said this was discrete because it is finite.

The height of the ocean's tide at a given location.

I said this was continuous because it is not always finite.

The time to complete a questionnaire.

I said this was continuous because it is not always finite.

The number of consumers in a poll of 1000 who agree with the poll question.

I said this was continuous because it is not always finite.

The rainfall total for a city in a year.

I said this was continuous because this is not always finite.

The number of heads occurring in 3 tosses of a single coin.

I said this was discrete because it is a finite.

I am not 100% sure of my answers.
Comment: I, personally, always take issue with these sorts of questions--the idea that the height of an ocean's tide being continuous ignores that the world is made of discrete particles (atoms)...  (at least, IMO.)
Answer: Discrete does not mean nor imply finite: it means that there is a minimum "gap" between the values the variable can take.
E.g.:

The number of visits to a website in a particular week.

must be an integer, so two values are always separated by at least 1: it is discrete.

The height of the ocean's tide at a given location.

as a first approximation, it can take absolutely any value within a range, say $[0, 10^6]$: there is no "granularity" here (if you give two possible values $a$ and $b$, $\frac{a+b}{2}$ is also a possible value).

The number of consumers in a poll of 1000 who agree with the poll question.

it is again an integer: discrete. You cannot have $2.46477655\dots{}$ people agreeing.
Comment: As a further remark: continuous implies infinite by definition.
So if your variable can only take a finite number of values, it has to be discrete.
Answer: Most of your answers are right. However, I think you have a slightly wrong idea of what's the difference between discrete and continuous.
A nice way to think of it is: if given one value, you exactly what comes next (its successor), then the value is discrete.
For instance, if we're counting people and we have 15 people, we know the next number is $16$ people. However, if I'm $175$cm tall and we're allowed to be very precise, what comes next? $176$? $175.1$? $175.000001$?
If you're pooling $1000$ people, then definitely there cannot be for instance $45.0001$ voters, so the variable is discrete.

Discrete or Continuous Variables


Does handicapping really do what it claims?

Question: I have heard many times that the idea of horse race handicapping is that the handicapper aims to arrange that all the horses cross the finish line at the same time. But I am a little bit sceptical that this is really what is going on. If it were really true then you would expect certain behaviours that I simply do not see. Take for example the Grand National (which has around 40 entrants). If handicapping really worked then you would expect:

Nobody would have any clue whatsoever about who might win until after the handicapper had chosen the weights.
All the discussion around who might win would revolve around the handicap and the idea of talking about a horses abilities without reference to the handicap would be plain silly.
It would be every bit as likely that a really slow donkey of a horse would win as a superstar.
The chances that the previous winner would be favourite to win would be very slim (approx 1 in 40).
The chances of a horse ever winning three times (i.e. Red Rum) would be incredibly small (approx 1 in 40x40x40 which is 1 in 64,000).

Now I'm not really a horse racing buff, so maybe I haven't been paying enough attention, but I haven't really seen that these things have been happening. Can anyone clarify what is going on?
Comment: When you say that you haven't really seen that these things have been happening, can you provide some examples that led you to that conclusion?
Comment: As I said, I may not have been paying attention, but with regard 1, if handicapping was critical then with a race as big as the grand national you may expect the handicap weights to be announced with a little fanfare (like the draw for the football world cup) but I have never seen the GN handicap announcement ceremony. With regard 2, I have never heard any TV punter even talk about the handicap weights in the GN. After Red Rum won a third time I don't remember people going round saying "my goodness, that handicapper did a lousy job".
Answer: Just found this blog post containing the sentence: "There is convincing evidence that superior horses are not always penalised enough in UK racing."
I guess the whole idea of handicapping is to marginally reduce the gap between first and last but not to eliminate it altogether.
Comment: I don't have arguments...just observing from the outside looking in. I suggest to list this *"convincing evidence,"* even if it is "F = m * a" and/or "its feasible one horse is handicapped significantly more compared to others, but not enough based on its ability." I find it weird I can't find anything on the "fastest horses" to fully see your point.
Comment: What is this "convincing evidence"? Doing a quick look into your question (not enough knowledge to form an answer), although the aim of handicapping is to "even out" the field, there are many factors to consider. However, the most important factors (cited in multiple sources), are [speed and pace](https://en.wikipedia.org/wiki/Handicapping#Predicting_the_outcome_of_races). From an outsider's, unbiased standpoint, no matter how handicapped the horse is from its speed and pace, it is more likely to overcome because of its supreme capability in those areas. That said, I could be wrong...
Comment: "Other factors affecting the outcome of a race are track condition, weather, weight that the horses have to carry, daily bias of the racing surface, and many more factors that the handicapper cannot know." If this statement from Wikipedia (in lieu of a more appropriate source) is true, then handicapping is based on controlled variables (or controlled in the sense that it's objectively measurable and handled accordingly) and the uncontrolled variables are the reason why your expectations are not met.
Comment: @mastermind_ed: your arguments do not explain why the (inherently) fastest horse is still so prone to winning. I suggest you read the article linked to in my answer.


Why did Miles Davis put his finger under his ear when he stopped playing?

Question: Watching films of Miles Davis performing in the 50's and 60's I noticed that whenever his solo was done he would take his index finger and press it beneath his right ear. Sometimes he would also shake his head as if it were painful to do so. I'm not sure if he did this later in his career or not. He acted very differently on stage in the 70's and later.
Is the pressure from blowing the horn forcing air into someplace it shouldn't? Why only his right ear? Is this common among trumpet players?
Here are a few stills of him doing this:
Answer: The best I found via lmgtfy was these:
From reddit

I always heard Miles would cover his ears to hear the other soloist
  better.

OTOH, an interview side note suggests it's purely a habit:

"Had to drink some water 'cause I get dehydrated," Miles explained.
  "Loretta knows. Sometimes I'll say, 'Loretta, something's funny about
  me. What is it?' And she'll look at me and say, 'Fix your hair. It's
  sticking out over there.'"
Miles touches his hair behind the right ear.
"You know, Sy, chicks just know about you. Cicely [Tyson] knows when I
  don't feel good, and she'll call me up and say, 'What's the matter,
  Miles?'"

As does this review:

Every gesture seems choreographed but effortless, the way he
  nonchalantly walks onstage, rubs just behind his ear, puts his
  impeccably manicured fingers to his lips just before bringing the horn
  to his mouth.
Answer: Watching the Tonight Show from 1964, it seems he was angry about some aspect of the sound balance. When he does it during the blues, he changes where he's playing on the mic, putting his bell way past it, so maybe he thought he was way too hot and not balanced with the rest of the band. During So What, when he does it, he completely walks away from the mic and plays without any amplification.
Answer: I believe it was to complaint to the band of some other aspect of the performance(intonation,rhythm, etc)  he did not like. I do not have any specific source to back this at the moment, though I know that he was extremely sensitive of musicians playing slightly out of tune.
Comment: It doesn't appear to be anything having to do with the other musicians. He was usually walking off the stage when he did it and he would shake his head like something was hurting him
Comment: Regarding the main question, note that he also touched his hear in the middle of his own playing and stop the solo with a face of displease and then go back to it. Also the other answer support that the gesture is related with the band. That said it was probably an habit of some sort so he may have done it sometimes for no reason.
Answer: I've seen him do this countless times and I believe it's either some tick, OR it's something he consciously does on purpose simply to add to the mysteriousness that of which is... Miles Davis.
Answer: I always interpreted it as he was asking the band to "listen" - pay close attention to what is happening.
Answer: I would suspect that he had temporo-mandibular joint dysfunction and pain below the ear. It's only a guess, but common to press or rub the muscles around that joint where the lower jaw (mandible) articulates with upper jaw.
Comment: This kind of answer needs a reliable source to back it up.
Comment: An interesting theory, but better left as a comment if it's just a guess.


Hide language for anonymous users

Question: How do I hide a language from anonymous users while I'm working on the translation?
I want the language only to be displayed in the language switcher block and the links to be active, while you are logged in as an administrator, so that they can check the translation while they are working on it.
Comment: Would simply hiding the language switcher block solve your problem?
Comment: As long as there are only two languages - yes. But if they want to add a third language thats no longer an option.
Answer: On our site, we're using the Language Dropdown module to display translation links.
When we want a language to be accessible to authenticated users only, so that they can translate the contents before showing them to site visitors, we hack the module this way, in lang_dropdown.module, line 192 :
<code>  // @TODO TEMPORARY FIX TO DISABLE ITALIAN TO ANONYMOUS USERS
  global $user;
    if ($user->uid == 0) {
    unset($languages->links['it']);
  }
  // ENDTODO
  //
  // Now we iterate on $languages to build the needed options for the select element.
  foreach ($languages->links as $lang_code => $lang_options) {
</code>
Be aware that in this case, the italian contents are not really hidden for someone who would know their paths, but it's sufficient for us.
Comment: My fear is that the content gets indexed by accident before they are finished...
Comment: It depends on your site architecture. If there isn't any entry point, no homepage, nothing in sitemap.xml, Google, acting as an anonymous user, won't see anything. That's what we do, we have a hidden language on a production site since 2 months now, and nothing has been indexed...
Answer: There is also 2 modules that can help with this
language_access
which gives permissions per language
hidden_language
which give permissions as to what roles can access hidden languages
They are both working in Drupal 7 and 8 and they are able to hide those pages from anonymous and bots.

Hide language for anonymous users


Reading dynamically characters in C with a scanf in a loop

Question: I'm new to C and I'm trying to read dynamically characters. I want to save them into an array to be able to use it later. What I have gotten for now is this and I don't understand why it's not working. My issue is that I have to press enter twice and it will only save one character.
char temp;
char tempOld;
int i = 0;
char string[80];

while(scanf("%c", &temp) == 1 && tempOld != '\n')
{
    string[i] = temp;
    tempOld = temp;
    i++;
}

string[i] = '\0';

The point of my exercise is to not use string.h or scanf("%80s", string)...
Thanks !
Comment: because your loop condition `while(scanf("%c", &temp) == 1 && tempOld != '\n')` first reads a character and then afterwards checks if the previous character was a newline.  You you have to read one extra character after the newline for your loop to terminate.
Comment: "it's not working" is not a helpful problem description.
Comment: Yes, I'm sorry. Just edited my post !
Comment: I see... I really don't know what went through my head. It works fine now, thanks ! I'll post the code to eventually help others.
Comment: BTW: With `char string[80];`, code should not use `scanf("%80s", string)`.  Perhaps  `scanf("%79s", string)` or even better `fgets(string, sizeof string, stdin)`
Answer: Your loop condition while(scanf("%c", &temp) == 1 && tempOld != '\n') first reads a character and then afterwards checks if the previous character was a newline.  Additionally, the value tempOld is not initialized so the behavior at the first loop iteration is actually undefined.
You need to check if the current character read was a newline, and if so, then terminate the loop.  Something like:
int temp;
while (i < 79 && (temp = getc(stdin)) != EOF && temp != '\n')
{
    string[i++] = temp;
}
string[i] = '\0';

Answer: Don't call scanf to read keyboard input. This code suggests
while(EOF != (temp = getc(stdin)) && tmpOld != '\n')

Also, initialize tmpOld to something or the compiler might happily remove the whole loop.
Anyway I found scanf() to be a sufficient pain in the behind that I stopped ever using it and only ever using sscanf() with strings that I've already verified are in the right format.
Comment: OP updated the post -- so this answer doesn't answer his question: *My issue is that I have to press enter twice*
Comment: @MFisherKDX: I think it still applies. `scanf` does dumb things reading from keyboard like drop the rest of the line.


OkHttp - Android get Data from MySQL database

Question: Hey Im fairly new to android developing and Im currently trying to establish a connection to my database so I can work with the data on my phone.
Im using OkHttp and mysqli with php.
I wrote a handler which accesses the .php pages and makes the database calls.
public class OkHttpHandler extends AsyncTask<String, Void, String> {

private OkHttpClient client = null;

public String latestMessage = "";

public OkHttpHandler(){

    client = new OkHttpClient();
}

@Override
protected String doInBackground(String... params) {
    Request.Builder builder = new Request.Builder();
    builder.url(params[0].toString());
    Request request = builder.build();

    try{
        Response response = client.newCall(request).execute();
        latestMessage = response.body().string();
        return response.body().string();
    } catch(Exception e){
        e.printStackTrace();
    }

    //latestMessage = "failed";
    return null;
}

And I want to do something like this:
    public int getSongwriterId(String songwriter) {
    OkHttpHandler okHttpHandler = new OkHttpHandler();
    okHttpHandler.execute(url_get_songwriter_id + "?songwriter=" + songwriter);
    String responseString = "";
    while(responseString == "") {
        responseString = okHttpHandler.latestMessage;
    }
    okHttpHandler.cancel(true);
    Songwriter s = getSongwriterFromJSON(responseString);

    return s.getId();
    }

Now, I know that this ugly while(true) is a shitty solution. But how should I do it so Im 100% certain I got my responseString before passing it into "getSongwriterFromJSON"?
I really don't get how that is supposed to work.
The code works all fine when i debug it step by step, but the application just blackscreens from time to time without debug. I guess thats due to the while(true) loop and that probably just runs and runs and clocks up the thread so that my background thread just dies - I really don't know anymore.
Please if you provide help, explain what Im doing wrong, and how I should do it right. Thanks.
Edit php file used:
<?php
$response = array();

$con = @mysqli_connect("XXX", "XXX", "XXX", "XXX");

if (mysqli_connect_errno())
{
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

$sql = "Select * FROM songwriter ";
$sql .= "where composerName = '";
$sql .= $_GET["songwriter"];
$sql .= "'";

$query = mysqli_query($con,$sql);

// looping through all results
$response["songwriter"] = array();

while ($row = mysqli_fetch_array($query)) {
    $songwriter = array();
    $songwriter["id"] = $row["id"];
    $songwriter["composerName"] = $row["composerName"];
    $songwriter["arrangerName"] = $row["arrangerName"];

    // push single product into final response array
    array_push($response["songwriter"], $songwriter);
}

// echoing JSON response
echo json_encode($response);
?>

Comment: Does your PHP script give a response? Add your PHP script as well
Comment: I just added my php file - yes it does give a response. It works well in debug mode. But wont do its job if i let it run normaly.
Answer: I may be wrong, but you are not supposed to write a @ in front of mysqli_connect:
$con = @mysqli_connect("XXX", "XXX", "XXX", "XXX");

Try to replace it with:
$con = mysqli_connect("XXX", "XXX", "XXX", "XXX");

And obviously replace the X'es with your credentials.
If this does not work(or having a @ in front of mysqli_connect is allowed in php, and you have tried testing after removing it) please run the PHP script from your computer, showing it as a website. Make sure you get any errors visible.
If there is nothing wrong with the PHP script, add Log.e tags with a fixed tag into your Java code. Try to see if there is anything wrong there. Make sure the connection actually succeeds as well.
Comment: You do - else you get an networkonmainthreadexception...
Thats the main Reason I need to do all of this async stuff.
Comment: Ignore that part(just removed it too): do the other things
Comment: I did - still wont work.
As I said - everything works fine when i debug and go threw it slowly.
I had a look at every method in my code and all the calls.
As long as I debug it will work step by step.

But when i let my App run without debug it just locks up and doesnt work.
Imo. the problem is the "while(responseString == "") " .
Answer: You're using the sync API of OkHttp while there is an async one, that you should use:
That while is a serious bottleneck, you should remove it asap. Try something like this:
Request.java
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.RequestBody;
import okhttp3.Response;

/** Very basic Request helper **/
public class Request {

    public static OkHttpClient client = null;

    /**
      * Get the current OkHttpClient or creates a new one if it doesn't exists
      * @return OkHttpClient
      */

   public static OkHttpClient getClient(){

        if(client == null)
            client = new OkHttpClient();

        return client;
   }

    public Call get(String url, Callback callback) {

       okhttp3.Request request = new okhttp3.Request.Builder()
          .url(url)
          .get()
          .build();

       Call call = getClient().newCall(request);
       call.enqueue(callback);

       return call;

    }
}

Activity
//...
public interface MyCallback {
   void run(Object data); //Generic callback
}

public void getSongwriterId(String songwriter, MyCallback myCallback) {

   Request.get(url_get_songwriter_id + "?songwriter=" + songwriter, new Callback() {
      @Override
      public void onFailure(Call call, IOException e) {
        //Handle error
      }

      @Override
      public void onResponse(Call call, final Response response) throws IOException {

         final String body = response.body().string(); //Get API response

         final Songwriter s = getSongwriterFromJSON(body);

         //Remove it if you just need to show the ID in the UI
         myCallback.run(s.getId())

         //OKHttp callback isn't in the main thread,
         //UI operations need to be run in the main thread
         //That's why you should use runOnUiThread
         MyActivity.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                //Handle UI here if needed
                ((TextView) findViewById(R.id.myTextView)).setText(s.getId());

            }
         });
      }
   });
}
//...


Porque o WebBrowser não mostra reCaptchas?

Question: Coloquei pra navegar normalmente nesse site. Porém ele além de deformar as Textbox do site, ele ainda não exibe os reCaptchas. O site da ScriptErros. Porém outros sites também dão, mas não fica igual isso.
O que pode ser?
FORM

CHROME
Comment: está relacionado com a versão do IE, da uma olhada aqui: https://www.cyotek.com/blog/configuring-the-emulation-mode-of-an-internet-explorer-webbrowser-control
Answer: Você precisa definir a versão do Webbrowser para 11, para isso implemente a o método abaixo no seu form principal:

Não esqueça do using Microsoft.Win32;

    public void VerifyVersion(WebBrowser webbrowser)
    {
        string appName = "";
        try
        {
            appName = System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe";

            RegistryKey fbeKey = null;
            ////For 64 bit Machine
            fbeKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
            if (fbeKey == null)
                fbeKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION");
            using (fbeKey)
            {
                fbeKey.SetValue(appName, 11000, RegistryValueKind.DWord);
            }

            //For 32 bit Machine
            fbeKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
            if (fbeKey == null)
                fbeKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION");
            using (fbeKey)
            {
                fbeKey.SetValue(appName, 11000, RegistryValueKind.DWord);
            }
        }

        catch (Exception ex)
        {
            MessageBox.Show(appName + "\n" + ex.ToString(), "Unexpected error setting browser mode!");
        }
    }

Modo de uso:
VerifyVersion(webbrowser1);

No seu caso
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.Win32;

namespace Fast_Bitcoin
{
    public partial class freeBitcoinForm : Form
    {
        public freeBitcoinForm()
        {
            InitializeComponent();
            VerifyVersion(webbrowser1);
        }

        private void freeBitcoinForm_Load(object sender, EventArgs e)
        {

        }
        public void VerifyVersion(WebBrowser webbrowser)
        {
            string appName = "";
            try
            {
                appName = System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe";

                RegistryKey fbeKey = null;
                ////For 64 bit Machine
                fbeKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
                if (fbeKey == null)
                    fbeKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\\Wow6432Node\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION");
                using (fbeKey)
                {
                    fbeKey.SetValue(appName, 11000, RegistryValueKind.DWord);
                }

                //For 32 bit Machine
                fbeKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
                if (fbeKey == null)
                    fbeKey = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\FEATURE_BROWSER_EMULATION");
                using (fbeKey)
                {
                    fbeKey.SetValue(appName, 11000, RegistryValueKind.DWord);
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(appName + "\n" + ex.ToString(), "Unexpected error setting browser mode!");
            }
        }

    }
}

Explicação:
Você precisa alterar o registro do windows para que o seu sistema entenda que o seu webbrowser tem que executar na versão 11.
Você tem que alterar o registro FEATURE_BROWSER_EMULATION
fbeKey.SetValue(appName, 11000, RegistryValueKind.DWord);

Acima estamos definindo a versão para 11, se quisermos outras versão segue a tabela a abaixo
Versão do IE    | Número para registro
    7           |   7000
    8           |   8000
    8 Standards |   8888
    9           |   9000
    9 Standards |   9999
    10          |  10000
    10 Standards|  10001
    11          |  11000
    11 Edge     |  11001


Does the identity theorem hold when both functions have an essential singularity at an accumulation point?

Question: The classical identity theorem is the following:

Theorem: Let $f,g:D\to\mathbb{C}$ be holomorphic on the domain $D$. If $f=g$ on a non-discrete subset of $D$, then $f=g$ on $D$.

For concreteness, let's suppose that $f$ and $g$ are both holomorphic on the punctured unit disk $\mathbb{D}\setminus\{0\}$, and that $f=g$ on the set $\{1/n:n\in\mathbb{N},n\geq2\}$. Further suppose that $f$ and $g$ both have an essential singularity at $0$. Does it follow that $f=g$ on $\mathbb{D}$?
Note that if we change "essential singularity" to "pole of order $m$", then the answer is affirmative - apply the identity theorem to the holomorphic functions $z^mf(z)$ and $z^mg(z)$.
Answer: The answer is negative. Consider the following two functions:
$$f(z)=\sin\left(\frac{\pi}{z}\right)e^{1/z},\,g(z)=z\sin\left(\frac{\pi}{z}\right)e^{1/z}.$$
We have that $f=g$ on $\{1/n:n\in\mathbb{N},n\geq2\}$ since both functions vanish on this set. Further, both functions have an essential singularity at $0$ due to the presence of the $e^{1/z}$ term; however, $f\neq g$ on $\mathbb{D}$.


Does strict monotonicity imply image variable is dependent with domain variable?

Question: Suppose a random variable $X$ and a strictly monotone (and measurable) function $f$ in which $f(X)$ is always defined.
Does it necessarily hold that $f(X)$ is statistically dependent with X?

I should emphasize that the random variable is not necessarily equipped with addition, or multiplication, but can be considered an $(E, \mathcal{E})$-valued random variable. The strict monotonicity $u < v \implies f(u) < f(v)$ is from a perspective of order theory where an arbitrary partial order $\leq$ is assumed over the domain/range of $f$. Assume the domain and range of $f$ are the same set.
Comment: @whuber OP clearly stated that $f$ is "strictly" monotone.
Comment: What happens when $f$ is constant on the support of $X$? That extreme and degenerate case provides essential insight I believe.
Comment: @Zhanxiong *Exactly.*  That's the entire point!
Comment: @whuber If $f$ were constant on the support of $X$, then $f(X)$ and $X$ would be independent. I thought about the contrapositive of this and didn't get anywhere. Is the converse true? If the converse is true, then that would answer my question.
Comment: The edit leaves some things to be assumed. What is the partial order on $E$?  Any partial order at all?  What is the range of $f$?  Any set with a partial order?
Answer: No -- there are simple counterexamples.
I take it that $X:(\Omega,\mathfrak F, \mathbb P)\to (E,\mathcal E)$ is a (generalized) random variable, that $E$ is endowed with a partial order $\le,$ and that $f:(E,\le)\to(E,\le)$ is strictly monotone.
As an example, let $\Omega = \{a,b\},$ $\mathfrak F=\mathcal P(\Omega) = \{\emptyset, \{a\},\{b\},\Omega\}$ is the discrete algebra, and $\mathbb P(\{a\})=1/2$ determines the uniform probability distribution.  Let $E = \mathcal P(\{0,1\}) = \{\emptyset, \{0\}, \{1\}, \{0,1\}\}$ and let $\le = \subseteq$ be the subset relation.  In this partial order $\{0\}$ and $\{1\}$ are incomparable: neither is a subset of the other.
Let the random variable $X:\Omega\to E$ be given by
$$X(a)=\{0\},\ X(b) = \{1\}.$$
The sigma-algebra $\sigma(X)$ is $\mathfrak F$ itself.
We only need to define $f$ on the image of $X.$ (But see the remarks below for why even this is not necessary to make the counterexample work.) To this end, let $f:E\to E$ be the constant function $f(y)=\{0,1\}.$  It is vacuously strictly monotone, because there are no strict inequalities to check (due to the incomparability of all the elements of $X(\Omega)$).
Define the random variable $Y = f\circ X.$  It is constant,  making it trivial to check the independence of $(X,Y).$
Thus, although neither $X$ nor $f$ are constant, all the conditions hold yet $X$ and $f\circ X$ are independent.

If you intended $f$ to be defined on all of $E$ and to be strictly monotone there, simply extend this example. For instance, let $E$ be the integers with $0$ doubled:  $$E = \{(n,i)\in \mathbb Z\times \{0,1\} \mid n\ne 0 \implies i=0\}.$$
The usual order $\le$ on $\mathbb Z$ induces an order on $E.$ We use the usual order on the first components but we make $(0,0)$ and $(0,1)$ incomparable.  This extends the previous example, which is isomorphic to the order on $\{(-1,0),(0,0),(0,1),(1,0)\}.$  The pairs $(0,0)$ and $(0,1)$ play the roles of $\{0\}$ and $\{1\}.$  Define $f$ as
$$f((n,i)) = (n+1,0)$$
for all $n\in\mathbb Z$ and $i\in\{0,1\}.$
Answer: Your idea of using proof by contrapositive is correct (I assume $X$ is non-degenerate, otherwise for any $f$, $X$ and $f(X)$ are trivially independent).  The key argument appears in proving Kolmogorov's $0$-$1$ law as well.
Suppose $X$ and $f(X)$ are independent, then as a measurable function of $X$, $f(X)$ and $f(X)$ would be independent, which implies that
\begin{align}
E[f(X)^2] = E[f(X) \cdot f(X)] = E[f(X)]E[f(X)].
\end{align}
But this would be equivalent to say $\operatorname{Var}(f(X)) = 0$, hence $Y := f(X)$ is degenerate.  Because $f$ is strictly monotone, $X = f^{-1}(Y)$ is well defined and must be degenerate as well, which contradicts with that $X$ is non-degenerate.  This proves your conjecture.
Comment: Your answer covers a strong majority of cases (+1), and it made me realize I made a mistake in communication. Implicit in my question is the possibility of random variables that are not equipped with scalar/vector/matrix addition. A lot of statistics doesn't involve such variables, of course, but I deal with them often. My apologies if I ignored a social norm. I'll update my question.


Using Circle of Fifths to compose in Minor keys

Question: I know that working with Circle of Fifths is instrumental for composing and working thru progressions. I have mainly used it for major key composition because of how its laid out. The seven degrees of each scale are within a small area close to the key you choose to use.
However, I'm not sure how to use it for the natural minor scale. Or, any other minor scale such as, melodic, harmonic etc.
Could someone shed some light on using circle for minor keys?
Thank you in advance. I would like to thank all how have helped me in the past.
Comment: That's not how composition works.
Answer: When doing basic composition in a major key (with no modulations etc.) you tend to just stick to the notes of the major scale, and choose your chords based on that.
With a minor key, it's worth noting that it's very rare to do the same thing.  Even music with no modulations or chromaticism thrown in for effect will not be based around 1 "scale" quite in the way that major songs are.  Pick up any piece of bach in a minor key, and you'll see this for example.  And the same is even more true for modern music, you will rarely if ever find a minor song that sticks solidly to one of the minor scales (whereas sometimes it seems like half of chart music these days is strict major with nothing interesting added).
So, while learning what the scales "natural minor", "melodic minor" and "harmonic minor" are is useful, it's sometimes more helpful just think of minor in general; and know what your note options are within that framework.
To summarise the scales, you have
natural minor (rarely used in classical music, more common in pop music):
C D Eb F G Ab Bb C
harmonic minor (the same but with a sharpened 7th degree)
C D Eb F G Ab B C
melodic minor (both the 6th and 7th sharpened.  Notice that this is only 1 note different from a major scale)
C D Eb F G A B C
So what you really have is this (General minor):
C D Eb F G, Ab or A, Bb or B C
So when do you use each note? Generally, the reason that the 7th is sharpened, is because the V-I (perfect cadence) chord progression sound a lot stronger with a major (or dom 7) 5 chord than with a minor one.  The 7th note is the third of the V chord, so it changes (in C minor) G minor to G major (or G7).
Compare these 2 progressions.  Try playing some arpeggios around these chords:
| Cm | Fm | Gm7 | Cm |   (or in A)     | Am | Dm | Em7 | Am |
and
| Cm | Fm | G7  | Cm |   (or in A)     | Am | Dm | E7  | Am |
The second one probably sounds quite familiar as the "resolution" of a minor song.  The first is also nice, but is certainly a more "modern" sound, and is less "functional" in that the chords don't have too much of a strong "pull" to each other.  You can imagine hanging out on the Gm for quite a while, and writing some melodic material there.* In the second one though, when you play the G7, you can feel that it wants to go back the the Cm.
Raising the 7th to get this major chord results in a scale that has a big gap in it; (3 semitones!).  The top half of the harmonic minor scale can sound quite "middle eastern" or flamenco-y.  Personally, I love the sound***, but often we want our melodies to have a "gentler" sound without that big jump, this is basically what the (appropriately named) melodic minor scale is for.  It has the sharp 7 to let you have a major V chord, and the sharp 6 to make the melodies sound a little softer**.  It rarely affects the harmony, more the melody you play over the chords.  You have to be careful though, that if you are currently using a chord with the minor 6th in it (like Fm or Ab major in C) that you don't write a clash between your melody and the chords by using the melodic minor scale at the wrong moment (an A natural over an F minor will sound pretty horrible usually).
Circle of Fifths
So, armed with the information that you have choices with minor in a way you don't with major, how do you decide which "choice" to use when building your chords.  In Major, it's easy, you just build the chords starting from the root note and pick the notes that are in the major scale.  In the minor, where you get a choice, you can basically pick the one that works best for your purpose.  Sure, it's a little complicated, but if you use your ears, you'll land on something that works.
A really common way one is the below*****
| Cm | Fm | Bb | Eb | Ab | G7 | Cm |
That might look a little intimidating, so let's look at it in A minor.
| Am | Dm | G  | C  | F  | E7 | Am |
You can see how it follows the fifths from A until F, and then moves chromatically down until the E7.
Now, why did we choose G and not G#dim (which can be built from the notes available)?  Why did we choose E7 and not Em7?  Why C and not C augmented?  Well, you try it, and see what you think sounds better!  When writing in minor, the key thing you have is choices.  Now, there are some good choices and bad choices, but those calls are really up to you, the composer!  (And probably some theory rules too, but unless you're writing for an ABRSM theory exam, it's really fine to use your ears!!)
Also, notice how when moving up the circle of fifths in a minor key, you quite quickly get to its relative major!.  So in Am, when playing around with circle of fifths progressions you will often find you reach C.  At that point, all your knowledge of progressions in C major will be useful to you too!
Another very common fifths thing you hear (especially in jazz and latin music) is to use the diminished chord on the ii to lead to the V.  So in A minor, you can build a diminished triad (or even better, a four note chord called a half-diminished chord) on the second degree (B D F A in A minor or D F Ab C in C minor).  This is usually written ø in jazz (although sometimes it's written as m7b5 which makes it look a lot scarier than it is!)****
| Bø | E7 | Am |  or   | Dø  |  G7  |  Cm  |
This little 3 chord snippet can be used almost anywhere (and jazz composers use it this way).  But in a more "traditional context, take a look at this circle or fifths progression.  If you left it at C then F, you could believe that you are now in fact in C major.  But the Bø E7 Am at the end tells you, no, you're in A minor.
| Am | Dm | G  | C  | F  | Bø  | E7  |  Am  |
You can hear what this sounds like here shortchord.org/BTxRx.  Ignore the names of the chords on that website, they are wrong.  Some of the chords here have added notes, but then don't need them; I just wanted to show some possibilities for the future.  Also I love 6 chords at the moment; so playful sounding!
| Cm | Fm7 | Bb6 | Eb | Ab6 | Dø | G7 | Cm |
which is really the below but with a bit of flavour:
| Cm | Fm | Bb  | Eb  | Ab | Dø (or just Ddim) | G7 (or just G) | Cm |
Pure circle of fifths.
footnotes
*In fact, some modern music does this very thing. Street Spirit by Radiohead and ain't no sunshine when she's gone, both use the minor 5 in that way; it doesn't pull anywhere particularly strongly, it just hangs out where it is.  This device isn't in classical works much at all.
**For example, look at "ne me quitte pas" also "if you go away" in English. The ascending line melodic line just before the chorus comes in ("but if you stay" in English, but the Jacque brel version is better haha) pretty much outlines how the melodic minor notes can be used to great effect. These notes lead up to the tonic minor chord; the melody would sound very different if the harmonic minor were used.
***A more extreme version of this has the big jump at both ends of the scale.  C Db E F G Ab B C .   Used a lot in Arabic music, and also in that song from pulp fiction.  Huh, huh haaaaaaaaaa.
****You probably know that jazz progressions tend to go all over the place and end up in strange keys.  This little progression has such a strong pull, that it can be used to to pull back to the minor key, and tell the listener where "home" is again, even after you've been lost somewhere else. In fact, bossa nova composers love it so much that they sprinkle it throughout their songs to lead into minor chords; even outside of its "proper" context.
***** Off the top of my head, muse's "unintended" basically uses this progression in E minor, except the E minor is substituted for E major (but the other chords are taken from the minor.  It's pop music; you can break the rules if you want).
Comment: Thanks for the deep lesson. Appreciate you taking yyuor time to break this down for me. Doug.
Comment: @Dougpip No problem, hope it's helpful.  Any questions or issues feel free to ask
Answer: You're talking natural minor, which uses exactly the same notes as the relative major. Thus, use the notes/chords the same. In C for example, C=I, F=IV, G=V. in its relative minor, Am=i, Dm=iv and Em=v. You may find that when using minors, the E=V, E major/E7.
Answer: A simple approach could be thinking of the circle of fifth for two purposes: closely related keys and harmonic sequences.
For closely related keys let's use c minor as an example. At the fifth above you have the minor dominant - g minor -  and the at the fifth below is the sub-dominant - f minor.
For harmonic sequences in minor keys you can use the circle of fifths similar to major keys. But I would add these two considerations: 1) Major key compositions commonly move to the dominant as the first key change, but minor key composition commonly move to their relative majors as a first key change. (This isn't a rule, but a generalization.) 2) harmonic sequences in minor moving to the relative major will use the natural minor scale for the chord roots.
It may be better to say that in major/minor harmony harmonic sequences use the diatonic pitches of the key you are moving into as chord roots. Someone correct me if I'm wrong or if there is a better way to say it.
Answer: For minor keys, it works exactly the same way as for major.
For example the two "nearest 5ths" either side of C minor are just G minor and F minor.
Of course the correspondence between the key signatures and the key names is different - it's your choice whether you want to draw a separate diagram for the minor keys.

I know that working with Circle of Fifths is instrumental for
  composing and working thru progressions.

Well, it's only "instrumental" for working through some progressions. There are plenty of other good ways to skin a musical cat - for example modulating by either a major or a minor third...
Comment: To continue on the "modulating by either a major or a minor third" possible key change in a piece, the "truck driver's gear change" (referred to in http://tvtropes.org/pmwiki/pmwiki.php/Main/TruckDriversGearChange) modulates by a minor second or a major second. I've often found it in pop music such as Josh Groban's "You Raise Me Up".
Answer: Circle of fifths works best in an enviroment containing dominant 7th chords and leading notes.  That is, in major and harmonic minor keys.  Harmonies based around ii, V, I progressions.  Music that has a firm idea of where the tonic is at any given time.
There is a reason why Common Practice harmony was used in so much music for so long (and still is).  It encourages tonal structure rather than aimless meandering.


Piano: Ring finger goes down with pinky

Question: I'm a beginner to Piano and when I'm playing the C chord, I'm placing my thumb on C, middle finger on E, and my pinky on G. Only thing is, whenever I bring my pinky down, my ring finger comes down with it on F.
Will this just improve with practice or am I just putting my fingers on the wrong keys.
Thank in advance!
Comment: you can practice this exercices (*s. my answer*) also on your knees or on your your left hand, (or on your head) someone may think your crazy or tell you: "stop beeing nervous!" - that's what my wife tells me when we are in the train or when going  to see friends and waiting for the dessert when I use the time to do my exercises.
Answer: The motion of pressing a piano key is driven by the flexor tendon on the inside of the finger.  The flexor tendons for the ring and little fingers join together in the palm of the hand, which makes it harder to move these fingers independently.
But independence is certainly possible.  As an exercise, place your hand on a flat surface with your fingers curled in playing position, and try lifting just your ring finger off the surface.  Over time you'll get better at it.
Comment: I would add "do it very slowly and with complete control" to this otherwise fine answer. Its also something to conquer in bass playing. Do it slowly and you will get better results long term. Do it fast and you will not learn control, only mask your _lack_ of control.
Answer: This is a hand anatomy issue as @TomSerb described.
Read up on finger independence exercises. They are an important part of piano training.
Also, playing in C major - all white keys - is very common for beginner lessons, but sometimes it is more difficult than playing with some black keys. Try also playing other simple chords like D, A, or E major, or Cm, Gm, or Fm. With those chords you can put your finger 3 (middle finger) on the black key in the middle of the chord. You may find this fits the hand better and helps you get the feel of playing the chord without finger 4 (ring finger) pressing down the other key.
Answer: This is absolutely normal and a question of isolation.
You can practice this independency of fingers everywhere you are:

Hold all fingers on the table and lift each single and tip it down many times: first the pinky finger, then the 4th etc. trying to lift the finger always higher
Then tip the fingers by changing (like a triller or a tremolo454545. 34343434. 353535, 2525252, 242424 etc, the other fingers are set fixed on the table
Answer: With all due respect to my colleagues, I'm going to try to clarify the other answers here. As they've rightly identified, you're experiencing simple anatomy -- the muscles that move those two fingers are joined.
However, seeing as this is human anatomy, you should not try to fight it. In my opinion, performing the above exercises as described, especially as a beginner, will lead to tension, which is something pianists should avoid at all costs.
Tension is caused when muscles are fighting against one another -- pulling in opposite directions. Doing the exercises above without a proper understanding will simply exacerbate this. They can definitely be a help, but the way they are worded and described above may lead to some erroneous ideas which I address below.
That being said, your problem CAN be solved -- however, in my opinion it's not a matter of finger independence, but instead a matter of position and attack.
By position, I mean that you should rest your hands on the keys so that the fingers are relaxed and naturally curled downward, pointing at the keys.
Here's a crucial point on attack: whenever a finger is not currently depressing a key, it should be comfortably relaxed. The exercises above, though not entirely wrong, may lead to the erroneous idea that when you play with your pinky, you must force your ring finger to stay up. This is not correct.
Instead, when you play with your pinky, your ring finger should be completely relaxed. So if you do the exercises above, don't try to force the other fingers not to move -- instead, focus on simply moving that one finger and completely relaxing the others. It's OK if they move together -- as long as the other is relaxed, it should not move with enough force to depress an extra key.
Also, pressing the keys should not be a fingers-only action. The above exercises also may lead to the erroneous concept that you need to "freeze" your hand and only move the finger muscles. This is also false. Allow the wrist and hand to have full range of motion when playing, but simply extend the fingers being used and relax the others.
I could go on, but hopefully this is a help.
Comment: I think I see your point. My advice was to_not push down the key with finger 4_. When I play that is accomplished with a kind of relaxed slackness in fingers 2 and 4 and not from actively lifting those finger up and away from the keys.
Comment: I still think 5 finger type independence exercises should help develop the sense of controlling that firmness/relaxed touch in each finger, but it really needs to be done at the piano rather than any flat surface.
Comment: @MichaelCurtis I see your point. If done with a focus on just that finger while keeping the others relaxed, and done at the piano, they can indeed be beneficial. I just wanted to make sure OP understood that distinction. The term "finger independence" could be misleading. Good insights!
Comment: I posting a new spin-off question about gravity drop and scales to delve a little deeper. I think I understand the principle 'don't play from the fingers' but then it seems counter-intuitive for scales.
Comment: Just read your other question. You're correct that my explanation doesn't hold true in every scenario. I hadn't thought through that aspect. I would qualify, however, by saying that for the scenario OP is asking about here, gravity drop definitely applies, and also by saying that even fast tempo scales should be full arm movements where the hands and fingers are kept loose and relaxed. But yes, you make a valid point, thanks for your correction!
Comment: Also, the way some of the above exercises were worded, I could specifically see a beginner thinking that the goal was to freeze the hands and lift each individual finger. I thought that needed clarification.
Comment: Kevin's answer is really important especially for beginners without a teacher. There are researches showing some practices ignorant of the anatomy of human hands can lead to serious injuries.

Piano: Ring finger goes down with pinky


output streams buffered output streams appending

Question: I know how to create / write/ close buffered output stream. How do I reopen the stream and append data to end of the file.
Answer: You can't reopen a stream... but you can create a new stream which will append:
FileOutputStream output = new FileOutputStream(file, true);

See the constructor list for FileOutputStream for the various options.
(Of course, you can then wrap that FileOutputStream with a BufferedOutputStream.)


Find the derivative of a function with new variable

Question:
Suppose $f(x-3)=(x-2)^2$ and find the $f'(x^2+5)$

When I solve this problem, I first find $f(x)$ by substitute $x=x+3$, i.e. $f(x)=(x+3-2)^2 \implies f(x)=(x+1)^2$. Then I convert $f(x)$ to be $f(x^2+5)$ i.e.  $f(x^2+5)=(x^2+5+1)^2=(x^2+6)^2$. Then I calculate the derivative of $f(x^2+5)=(x^2+6)^2$ $f'(x^2+5)=2(x^2+6)·2x$.
However, this is wrong, and the correct solution is first to find the derivative of $f(x)$ then evaluate the derivative at $x^2+5$ i.e.$f'(x)=2(x+1)$ and $f'(x^2+5)=2(x^2+5+1)=2(x^2+6)$.
My question is why my solution is wrong, and what is the difference between the correct answer and my answer. Thanks in advance.
Answer: You calculated the derivative of the composite function $x\mapsto f(x^2+5)$, and evaluated it at $x$, rather than calculating the derivative of the function $t\mapsto f(t)$, and evaluating it at $x^2+5$. Note that by definition
$$
\left(x\mapsto f(x^2+5)\right)'(x)=\lim_{h\to0}\frac{f((x+h)^2+5)-f(x^2+5)}{h} \, ,
$$
whereas
$$
(t\mapsto f(t))'(x^2+5)=\lim_{h\to0}\frac{f(t+h)-f(t)}{h}\bigg\rvert_{t=x^2+5}=\lim_{h\to0}\frac{f(x^2+5+h)-f(x^2+5)}{h} \, .
$$
Comment: I slightly understand this. Then is there a notation for what I should regard as the independent variable? Just like $f'(x^2+5)$. I interpret this to take the derivative of $f(g(x))$ where $f(x)=(x+1)^2$ and $g(x)=x^2+5$ and the independent variable is $x$, However the question let me take the derivative of $f(g(x))$ and the independent variable is $g(x)$. Is there a way to tell this?
Comment: @Yink: Actually, $f'(x^2+5)$ is just the value of the function $f'$ at a point which we happen to call $x^2+5$. If you want to measure the change to $f(x^2+5)$ as you change the $x$-coordinate, then you should consider the derivative of the function $x\mapsto f(x^2+5)$ at the point $x$, which is not the same thing as $f'(x^2+5)$.
Comment: @Yink: To answer your second question, the idea of treating the output of a function (in this case, $g(x)$) as an independent variable is a little dubious, but it can be done. Generally speaking, by definition $$\frac{df(g(x))}{dg(x)}=\frac{df(u)}{du}\bigg\rvert_{u=g(x)}=f'(g(x)) \, .$$The idea behind this definiton is that we "forget" the fact that $g(x)$ is dependent on $x$, and instead treat it as an independent variable.
Answer: As a method to proceed: $f(g(x))'=g'(x)f'(g(x))$. Set $g(x)=x^2+5$. So, $g'(x)=2x$. For $x$ non zero, $f'(x^2+5)=\frac{f(g(x))}{2x}$


How to generate `getter/setter` for ZF2 and Doctrine using a command line tool?

Question: How can I generate getter/setter for ZF2 and Doctrine using a command line tool? Like $myEntity->getUsername() and $myEntity->setUsername('foo');
I'm using this to generate entities:
./vendor/bin/doctrine-module orm:convert-mapping --force --from-database annotation ./Entity/

Answer: I use this script http://mostafa.info/~NKIBl0
Its really helpful for me. Use it like this:
php generateGettersAndSetters.php file.php > generatedFile.php

Comment: Thanks Mostafa! It worked flawlessly. (Note to myfelf: some day I will regret executing command line instructions I see on stackoverflow).
Answer: You don't need to utilize a 3rd party script since you're using DoctrineORMModule. Doctrine's native ConvertMapping command already provides required options to us.
All you need is passing true as generate-methods parameter value to CLI like below:
$ cd /path/to/your/project
$ php public/index.php orm:convert-mapping --from-database annotation ./Entity/ --update-entities="true" --generate-methods="true"


Any way to customize Chrome or Firefox Speed Dial thumbs?

Question: For a fun project, I've been implementing a small thumbnail page on a website that provides a specially catered view for the small site previews on New Tab pages. The end goal being to present the relevant information to the user before they ever need to visit the site. (Example: a weather site frequently visited, having a thumbnail page showing today's weather, so that the user can see the relevant information at a glance).

Opera this is by detecting
X-Purpose: preview

Likewise, Safari uses the same header, but requires additional JS to maintain a consistent thumbnail.
//On primary page
if (window.navigator.loadPurpose === 'preview') { /* go to thumbnail page */ }

//On thumbnail page
if (window.navigator.loadPurpose !== 'preview') { /* return to main page */ }

I'm curious if it's possible to duplicate this effect in Chrome or Firefox (the new speed dial available in the Aurora builds)?
Note: The X-Purpose: preview header in Chrome about 2 releases ago was a bug that was intended to be X-Purpose: instant and does not serve this purpose.
Comment: I didn't know you could do that! I have to look this up.
Comment: Btw, actually in Opera, you can make extensions on speed dial, which can enable you to do exactly this and more. http://dev.opera.com/articles/view/creating-opera-speed-dial-extensions/ (apologies if you knew this already)
Comment: Old Opera (12 and below) use apple-touch-icon as a thumbnail (if available). I wonder if something like this ever becomes a standard...
Answer: As far as I can tell, both Chrome and Firefox Speed-dial thumbnails are only populated when you visit a page - i.e. they're taken from the normal browsing context, with normal headers, rather than being independently queries in their own right.
You can test this a number of ways - I haven't spent long testing it, and you may have different version(s) of Firefox/Chrome than I do so you may see different results.

In Chrome - pin a tab or two in Speed-dial and then empty your browser history. The thumbnails should disappear until you re-visit the pinned page.
In Firefox - the above works, but you can also try out thumbnail generation directly using the moz-page-thumb:// URL protocol:
moz-page-thumb://thumbnail?url=http%3A%2F%2Fstackoverflow.com%2Fq%2F10369905%2F210865"

(please do test in whatever versions you're running as I'm curious about this question too - my research sofar is disappointing, but possibly in future ...)
Other references:

Original bugzilla entry for adding thumbnails to FF Speed-dial
Another bugzilla entry on fixing thumbnail protocol security issues
Related Super User question
Answer: Try using the speed Dial addon on Firefox, works really well.
It has features like bookmarks back-up and you can add a large number of bookmarks customizing each bookmark-tab.
link to speed dial for firefox
link to speed dial for chrome
Comment: This question was about a website presenting a custom icon on the frequently visited site list most browsers provide, not a speed dial extension.


WordPress Loop Post Types as List und inset sub-posts in  ->

Question: I'm stuck a little. I need to output a List of CPTypes with custom links. Everything is working so far. But I can't get the Subpages to be in a sub-list.
This is my code:
<? php
function theme_name_book_show_children($post) {
$my_query = new WP_Query( 'post_type=dokumentation', 'posts_per_page=>-1', 'post_parent=>$post_parent' );

while ( $my_query->have_posts() ) :
    $my_query->the_post();

echo '
' . get_the_title() . '
';

endwhile;
}

Any solitions for this? As far as I know list pages is only giving the permalink. But since it is a huge One-Pager i need to have it linked to the #ID.
Thank you for reading!
Mike
Comment: if the WP_Query is working that way? because an argument shall be an array()
Comment: yes - working flawless
Comment: Got this code now:

function theme_name_book_show_children($post_parent) {
$my_query = new WP_Query( array( 'post_type'=>'dokumentation', 'posts_per_page'=>-1, 'post_parent' => $post_parent ) );

if ($my_query->have_posts()) {
while ( $my_query->have_posts() ) :
$my_query->the_post();

echo '' . $my_query->post->post_title . '';

endwhile;
} else {
// no results, maybe echo a message
}
wp_reset_postdata();
}

only the hierarchy is missing… Any idea?
Comment: sorry, i can't understand what exactly is not working? don't you gen an  echoed? doesn't wp loops through the query? does the query return nothing?
Comment: $my_query->post->ID this is completely incorrect
Comment: shall be $post->ID and global $post variable has to be defined. I will write an answer
Answer: function theme_name_book_show_children($parent_id) {
  global $post;
  $my_query = new WP_Query( array(
    'post_type'=>'dokumentation',
    'posts_per_page'=>-1,
    'post_parent'=>$parent_id
  ) );

  while ( $my_query->have_posts() ) : $my_query->the_post();
    echo '
ID . '">' . get_the_title() . '
';
  endwhile;
  wp_reset_postdata();

}

Comment: Thank you very much for your solution! Works.


Survey questionnaire rebasing after removal of a selection

Question: Suppose that I have a market research survey with the question "What brand of television are you planning on buying" and then also have a choice that is "I don't plan on buying a television."  Respondents may choose more than one brand, but they may not make any other choices if they select that they do not plan on buying a television.
If I wanted to do an analysis of television brands among only those people who said they were going to buy a television, can I remove all of the respondents that said they would not buy a television, then recalculate the proportions for each brand with the new base number of observations?
If this skews the demographic distribution of my sample, is that okay? (e.g. the full sample has 30% Caucasians and 10% Asians, but the sample of people who say they will buy televisions is 30% Asians and 10% Caucasians.  It seems like this should be okay, since we would not expect the two populations (TV buyers and people in general) to be the same.
Answer: The short answer: what you propose to do sounds reasonable.
It often occurs in survey research that a question only applies to a subset of the population.
In such situations you typically want to say:

"Of American/Australian/French/etc. adults where this question is applicable, $X\%$ believes/intends to do/thinks/etc. ..."

Representative: As you say, in survey research you are often concerned with your findings being representative of a target population. If we assume that your initial sample is representative, then taking just the subset that intend to buy a television will be a representative sample of your population that intends to buy a television. This is true even if the subset that intends to buy a television is different to the subset that does not intend to buy a television in terms of demographics or some other factor in addition
to television purchasing intention.
In addition, you may want to produce cross-tabulations of purchase intention with demographics.
Split Question: I suppose you also need to think about what is the best split-question. Consumers vary in the degree to which they are intending to purchase a television and the degree to which they have thought about brands. Thus, you need to think about your research question. For example, you might ask the question: "if you were going to purchase a television, which brand would you consider?" This would be good for assessing longer term  brand purchasing intentions. Your structure focuses on the subset of consumers who are planning to purhcase.
Comment: I would put it: "Of the X% American/Australian/French/etc. adults who intend to buy a television, Y% intends to buy brand A, Z% intend to buy brand B,..." So you immediately see both information in one sentence.
Comment: @Henrik. Thanks. I agree. I guess I was trying to put it in slightly more general terms.
Comment: He should make sure the sample size from the new group is not too small however
Comment: @Neil. Good point.


monit not able to monitor mysql with sock

Question: Just in case if you are using Monit version 5.1.1 and try to monitor mysql with sock it will always fail with "Connection failed"
my monit configuration file is:
<code>check process mysql with pidfile /var/lib/mysql/mysql.pid
   group database
   start program = "/etc/init.d/mysql start"
   stop program = "/etc/init.d/mysql stop"
   if failed unixsocket /var/lib/mysql/mysql.sock protocol MYSQL then restart
   if 5 restarts within 5 cycles then timeout
</code>
The logs was not showing any clear error and all posts in internet was about using TCP to mysql.
The solution that I found was to upgrade monit to 5.6, after the upgrade monit will be able to monitor mysql sock without any issue.
Using:
CentoOS 6
Monit 5.1.1-4.el6 from repository epel
Comment: BTW: this is not a question, I just want to post the issue and the solution for any CentOS user, it seems I will not be able to mark it as answered, I have to wait for 10 hours :(
Comment: Are you using MySQL 5.5? That would make sense since the monit changelog states for 5.2.3: `* Mysql protocol test supports mysql 5.5.x and newer now.`
Comment: Yes I'm using MySQL 5.5
Answer: The solution that I found was to upgrade monit to 5.6, after the upgrade monit will be able to monitor mysql sock without any issue.
Note: Also please check Yoonix comment regarding Monit support for MySQL 5.5


Como limitar um relacionamento 1 para muitos JPA?

Question: Estou usando JPA com Spring Framework em um projeto, eu gostaria de limitar um relacionamento 1:n, quero fazer 1:5, como faço isso?
O relacionamento é esse:
@ManyToOne
private Task task;

Answer: Infelizmente não tem como fazer isso dessa maneira. Mas como você utiliza java, você pode usar o orientação a objetos para encapsular essa lógica dentro da sua entidade. Por exemplo:
@Entity
public class Item {

    @ManyToOne
    private Produto produto;
}

@Entity
public class Produto {

    @OneToMany(mappedBy = "produto", cascade = CascadeType.ALL, orphanRemoval = true)
    private List<Item> itens = new LinkedList<>();

    public List<Item> getItens() {
        return Collections.unmodifiableList(itens);
    }

    public void addItem(Item item) {
        if (itens.size() == 5) {
            throw new IllegalStateException("Não é possível adicionar mais itens!");
        }
        itens.add(item);
    }

    public void removeItem(Item item) {
        itens.remove(item);
    }
}

Nesse caso você só teria o repository para a sua entidade de produto. A persistência da entidade Item fica toda a cargo do JPA, você só precisa adicionar os itens no produto e salvar o mesmo. Por exemplo:
...
produto.addItem(item);
produtoRepository.save(produto);
...

E da mesma forma para remover os itens.
...
produto.removeItem(item);
produtoRepository.save(produto);
...

Claro que dessa forma você tem que tratar a exception para mostrar uma mensagem mais amigável ao seu usuário.


Rectify the error caused due to non-boolean type specified in a context where a condition is expected, near ','

Question: An expression of non-boolean type specified in a context where a condition is expected, near ','.
SELECT *
FROM product
WHERE (description, price) IN (SELECT description, price FROM product
                               WHERE name = 'Colgate Active Salt');

Hi all just trying to work with multiple column sub query which pops up with the above error,the same code seems to work perfect with the oracle but not with the MS SQL.
Solutions please.
Answer: You can simplify your query as it involves only one table.
Select a.name, a.description from product
where name = 'Colgate Active Salt'

As your question you should use the IN as shown here.
Another way is to use inner join to retrieve records which have have the same description and price as of Colgate Active Salt.
SELECT a.*
FROM (
    SELECT *
    FROM product
    WHERE name = 'Colgate Active Salt'
    ) a
INNER JOIN (
    SELECT *
    FROM product
    ) b ON a.description = b.description
    AND a.price = b.price
    -- AND a.name = b.name

Comment: I'm just trying to retrieve records which have have the same description and price of 'Colgate Active Salt'
Comment: @Irfan In your question you have not given what you want rather than only technical error.
Comment: Requesting to retract the down vote as per the updated answer. Thanks.
Answer: SQL Server does not support this tuple syntax (which is however supported on other databases such as MySQL).  As a workaround, you may use an EXISTS clause:
SELECT *
FROM product p1
WHERE EXISTS
    (SELECT 1 FROM product p2 WHERE p2.description = p1.description AND
                                    p2.price = p1.price AND
                                    p2.name = 'Colgate Active Salt');