Resgatar dados BD apenas preechidos

Question: Estou com um problema quando tenho de mostrar os dados da Base de dados e eles estão vazios Porque aparece o nome e fica o espaço em branco.
Nome: Pedro
Nome: Ricardo
Nome:
Nome:
Nome:

e queria saber se era possível alterar isso para so mostrar os dados Preenchidos

Nome : '.$exibe["Nome1"].'          Função :   '.$exibe["Funcao1"].'

Nome : '.$exibe["Nome2"].'          Função :  '.$exibe["Funcao2"].'

Nome : '.$exibe["Nome3"].'          Função :  '.$exibe["Funcao3"].'

Nome : '.$exibe["Nome4"].'          Função :  '.$exibe["Funcao4"].'

Nome : '.$exibe["Nome5"].'          Função :  '.$exibe["Funcao5"].'

Nome : '.$exibe["Nome6"].'          Função :  '.$exibe["Funcao6"].'

Nome : '.$exibe["Nome7"].'          Função :  '.$exibe["Funcao7"].'

Nome : '.$exibe["Nome8"].'          Função :  '.$exibe["Funcao8"].'

Comment: Poderia colocar o cógido com problema? já tentou um `trim()` ?
Comment: alterei na pergunta. São varios nomes que podem não estar preenchidos
Comment: Creio que seja seu loop mal controlado. Posta o código aqui para podermos visualizar o problema.
Answer: Isso não funciona?
while($exibe = mysql_fetch_array($resultadoQuery) {
     if($exibe[nome] != NULL) {
          echo "
Nome: $mostrar[nome] -- $mostrar[funcao]

     }

EDIT:
Você não consegue fazer isso (igual postou no comentário):

      <?php if($exibe['nome6'] != NULL) {
            echo '
Nome: '.$exibe['nome6'].'   Função: '.$exibe['funcao6'];
           }
      ?>

<
Comment: Estou com um pequeno problema ao colocar esse IF dentro do php.'
   if($exibe["Nome6"] != NULL) {
   echo 'Nome: '.$exibe["Nome6"].'     Função : '.$exibe["Funcao6"].
     }'
Comment: Vou editar a resposta e mostrar pra você como faz.
Comment: Olhe a resposta editada e veja se foi isso, caso não tenha sido, especifique o erro que acontece.
Comment: Eu estava a ter um erro mas era porque me faltava um ; antes. e não utilizei o <?php
Answer: Você pode modificar a query para
    SELECT * FROM tabela WHERE `nome` != NULL

Comment: Sim claro. Mas antes de aparecer o nome está texto a dizer "Nome:"
Comment: A dica do brhvitor6 pode resolver se seu banco estiver com este tipo de buraco (campos vazios). Caso não seja, o problema poderá estar em seu loop. Está aparecendo "Nome:" porque não é dado do banco mas sim html que você está inserindo na mão.
Comment: Mas não faço nenhum loop. mostro apenas os dados do BD por ordem
Comment: E como você está resgatando os N registros do banco? Só postando o código para termos uma idéia do que ocorre.

Resgatar dados BD apenas preechidos


A way to forcefully close modal QFileDialog on Mac

Question: I have a Qt application which at some point calls QFileDialog::getOpenFileName. However, at any point my application can get an event which will make this file dialog irrelevant, so I want to forcefully close it.
This is my way of trying to close this dialog:
QWidget *modalWidget = QApplication::activeModalWidget();
if (modalWidget)
    modalWidget->close();

This works on Windows, but I get strange behavior on Mac. Instead of closing, it hides the dialog instead. Execution never leaves QFileDialog::getOpenFileName call and since it's a modal dialog, underlying app becomes permanently frozen.
Comment: You may need to avoid calling QFileDialog::getOpenFileName() and instead manually create a QFileDialog object and show() it.
Answer: For the sake of closure, I ended up closing the dialog by calling native [NSApp abortModal].
Note that this workaround might not be needed if this issue was fixed in the recent Qt releases (haven't checked since Qt 5.8).


Recording practice jams with a cell phone: reduce input clipping

Question: I have been recording our practices with a cell phone for several months now.  I have successfully recorded nearly every week, producing signals with waves which are captured entirely within my recording app.
For the last couple of weeks, my recordings have been clipped almost 100%.  I believe I know the reasons (we are playing louder; our singer has come into his own and he is belting now).
What I wonder, is if anyone has a method to reduce the signal when recording with a cell phone, in such a way that the integrity is not lost (sure you could wrap the cell phone with a towel, but then you would lose all of your treble).
Comment: Simple answer, without prejudice - revert to the volume previously used. Never understood why rehearsals need to be as loud as a gig ! Singer can still belt out, farther from mic, or at even less amp volume. It'll save ears too!!
Comment: Have you tried with another phone? Unless you are playing **much** higher, it shouldn't go from clean to total clippage. The phone could have broken in some way.
Comment: Good points, all.  Actually, I am using a new phone.  I had to trade in my older one for moneys-type benefits.  In retrospect, the rebate was not worth trading in what was a solid recorder.  I once recorded a sludge metal concert with it.  It was a keeper.
Comment: So that explains it then. Different phone means different levels of accepted noise. (Unless it's the same model, but even then there could be something wrong with the new one.)
Comment: Well, not so fast.  The practice before was my old phone.  Actually, I did some woodshedding last night and found that the direction of the mic on the phone makes a difference.
Comment: I have the same problem on my phone and dictaphone, especially when the bass player kicks in!
Answer: Put the phone further away.
Next step: pack it in soft foam (like slipping it in a sponge).
But all that's pretty much piling on the bad.  The sane thing is to just buy some roughly phone-sized recording device actually intended for the job.
They are pretty affordable and will provide good practice feedback.  They are no replacement for professional recording equipment but will go a long way for non-professional purposes and are much easier to drag around.
Comment: My bassist brings his 8-track.  I do think I will invest in a handheld recorder though.
Answer: I agree with the answer above. In high school, my band recorded using a digital camera, and we put it in the closet. It was a bit muffled, but we could still pick out our parts.
If you all plug into a mixer, I highly recommend that you plug in, line-in into a tablet or laptop.
Now days, I use a usb condensor mic, plugged into my microsoft surface tablet. I record using Audacity. The quality is actually really good, for it being as loud as it is! And it was only $80. Those handheld recording devices can be expensive and aren't as versatile.
http://performermag.com/audio-technica-at2020-usb-condenser-microphone/


Adicionar espaço após encontrar um caractere

Question: Possuo o seguinte código que adiciona o conteúdo de um botão e um espaço após clicado
   procedure TForm3.Button1Click(Sender: TObject);
      begin
        if count = 0 then
          Edit1.Text := Edit1.Text + TLabel(Sender).caption+ ' ';

        if count = 1 then
          begin
            Edit2.Text := Edit2.Text + TLabel(Sender).caption+ ' ';
          end;
      end;

Saida: Dose = Max + Min

e uma outra situação para numero, que não aplica os espaços:
    procedure TForm3.Button29Click(Sender: TObject);
    begin
         if count = 0 then
          Edit1.Text := Edit1.Text + TLabel(Sender).caption;

        if count = 1 then
          begin
            Edit2.Text := Edit2.Text + TLabel(Sender).caption;
          end;

    end;
Saida: Dose = 10

Porem estava pensando que após o numero poderia encontrar um texto
e do jeito que eu faria o caracter após o numero sairia assim
Saida: Dose = 10AND 20

Onde o correto seria:
Saida: Dose = 10 AND 20

Como tratar a função para que quando o próximo caracter após o numero seja um a letra, ele adicione um espaço?
Comment: você poderia sempre adicionar espaço, e no final da operação usar o trim() ?
Comment: Poderia até faço isso numa função, mas caso haja um AND após o numero, não iria adiantar nada.
Comment: quero dizer, tanto para numero quanto para texto, você adiciona espaço, no seu exemplo, você só adiciona para texto, ai no final, você usa o trim()
Answer: Você poderia criar uma função nos seguintes moldes, onde SetOfChar é uma constante declarada:
SetOfChar = set of 'A'..'z';

function Concatena(const TextoEdit, Caption: String): String;
begin
  if TextoEdit = '' then
    Result := Caption
  else if TextoEdit in SetOfChar then
    Result := TextoEdit + ' ' + Caption
  else
    Result := TextoEdit + Caption;
end;


Is there a way to default sort by date when no search keywords have been used, but default sort by relevance for all searches?

Question: At present, my project has default search pages for sections of the site. They are per-content type. When the user goes the "search page" for the content type, they see a views-generated search result page unfiltered by any keywords. In other words, it displays all the items for that content type. The view:
has expose form in a block enabled
settings on the exposed form has 'input required' disabled
What I want to happen...
I'd like users to

see the unfiltered search result page sorted by newest first. At
present, this page, if set to relevance, shows old content first.
automatically switch to relevance sorting when they enter keywords
and execute a search. At present, I've set the first sort to date, to
solve the 'old content first' problem, so users have to manually
change the sort to relevance when doing a search.

Some options...
I could separate the list pages from the search result pages. My question is, is there a way to make an unfiltered "search result" views page show the newest content first, while having the default sort actually set to relevance, so nobody has to manually change it?
How does that sort really work when there aren't any keywords to supply "relevance"?
My config basics...

Drupal 9.3.7
search_api
facets
search_api_solr
Answer: I think I have one solution. I remain interested in knowing if there is a better way.
Here's what seems to be working so far:
In the sort section of the view, I have these fields, in this order:

Relevance (descending): exposed
Date field (descending): exposed
Date field (same one, descending): not exposed

After clearing caches (important), the result seems to be that navigating to the search result page without doing a search, lists all the content (as filtered) by 'Date field' descending, but the search form and its exposed sort indicates Relevance.
When I key in terms and launch the search, it comes back relevance sorted.
I'm not sure why this is working though. On the views config page the query without keywords looks like this:
<code>Index: main_index
Keys: NULL
Conditions:
  [
    status = 1
  AND
    type IN array (
          'resource' => 'resource',
        )
  ]
Sorting: search_api_relevance DESC, field_display_date DESC
Options: array (
    'search_api_view' => 'object (Drupal\\views\\ViewExecutable)',
    'search_api_base_path' => 'search/resources',
  )
</code>
I may learn more from the mysql query log, but I admit: I'm never sure I understand what I'm seeing there.
Comment: At least with Elasticsearch (may be true for other server types as well), it skips sorting in the case where the sort is `search_api_relevance` and there is no fulltext search, and falls back on the subsequent sort criteria. (See `elasticsearch_connector/src/ElasticSearch/Parameters/Builder/SearchBuilder.php`.)
Comment: I have one content type where the above configuration is not having the same result. No idea yet why.


Interpretation in histogram of empirical posterior distribution

Question: I'm having trouble to understand the following histograms

I know that the posterior distribution in this case is just the empirical cumulative
$$P(\rho\leq c)=\frac{1}{n}\sum_{i=1}^n \mathbb{1}_{0\leq\rho\leq c}$$
where $n$ is the number of simulations of Gibbs sampling.
What mean the curve of $\pi(\rho)$ and $\pi(\rho|data)$ ?
Comment: What exactly is unclear for you? Could your provide reference for those diagrams?
Comment: @Tim The histogram shows the frequencies of values of $\rho$. I think, the curves of $\pi(\rho)$ and $\pi(\rho|data)$ shows the fit of the prior and posterior distribution to this data(frequencies of $\rho$)? In fact I was a bit confused with the y axis, I don't understand well what $density(\rho)$ mean.
Comment: Density here means the same as anywhere else. It might help you to read: [Can a probability distribution value exceeding 1 be OK?](http://stats.stackexchange.com/q/4220/7290)
Comment: This question seems clear enough to me.
Comment: @gung Now I understood that density in this case means probability density (pdf), and this can be bigger than 1 and the area under the curve need to sum 1. Taking the example of first histogram $Beta(2,2)$, this density is bigger in the range $[0.6;0.8]$, what is actually mean?
Answer: As we are in a Bayesian paradigm, the Bayesian interpretation of probability may be a good candidate.
Meaning of the curves:

$\pi(\rho)$ is the prior density i.e. a prior characterisation on belief (or abscence of belief) about the parameter $\rho$ value (independently from the data).
$\pi(\rho|data)$ is the posterior density i.e. the updated state of knowledge on $\rho$ after having account for the data.

Having say that, in a continuous setting, we must be cautious about interpreting density in a point-wise basis (e.g. as you state $p(\rho)>1$ is allowed, see also What's an intuitive explanation for why MAP is variant under parameterization?)
Then regarding your last comment $\pi(\rho \in [0.6,0.8] | data)$ represents the belief $\rho$ is in $[0.6,0.8]$ after having observed the data. Conversely the highest posterior density (HPD) interval (which will be something close to [0.6,0.8] in your case), gives you the smallest interval covering a given subset (typical 95%) of the belief and can be interpreted as a reasonable range for the actual value of $\rho$ (when the posterior in unimodal).
Comment: The curve of prior $\pi(\rho)$ in this case have no meaning?
Comment: @PRAGAKHAM sorry, what do you mean by "in this case" ?
Comment: For the first case $Beta(2,2)$ the curve of $\pi(\rho)$ just represents density $\pi(\rho)=6\rho(1-\rho)$?What you mean by "represents the belief $\rho$...".  ?
Comment: @PRAGAKHAM Well there are two answers to this question: i) either it is an informative prior and thus represents (approximatively) the belief about $\rho$ (for example the mean and variance could match with what it is expected) or ii) either it is a default/non informative prior and then, it is much difficult to interpret per se, but it is known/shown to have a limited impact on the posterior with regards to the data (see e.g. jeffreys prior). Is it okay to you ?


php regex function and unable to convert JavaScript argument

Question: I created a simple test for a function to grab the video id from a youtube url and echo it out. It works fine as is but when I introduce jQuery code in the mix I receive this error NS_ERROR_XPC_BAD_CONVERT_JS: Could not convert JavaScript argument. The error is commenting the jquery.js file on line 7071. I have no idea what to do or what is exactly causing this. The code is below.
First File

<input type="text" id="url" />

<input type="button" id="press" value="click" />

Here is the ajax_youtube.php file
<?php

function get_youtube_url($text) {

$text = preg_replace('~https?://(?:[0-9A-Z-]+\.)?(?:youtu\.be/| youtube\.com\S*[^\w
\-\s])([\w\-]{11})(?=[^\w\-]|$)(?![?=&+%\w]*(?:[\'"][^<>]*>| ))[?=&+%\w-]*~ix',
'$1', $text);

echo $text;

}

$url = $_POST['url'];

get_youtube_url($url);

?>

Comment: I think this `$('#url').val();` should be `var url = $('#url').val();`
Comment: Thanks. I feel silly. Post it as the answer since you were the first one to answer and I'll give you credit.
Answer: You forgot to assign url to a value, $('#url').val(); should be var url = $('#url').val();


MCMC autocorrelation convergence diagnostic

Question: I use MCMC (Metropolis-Hastings) to sample posterior distributions of three parameters using a nonlinear least-squares objective function to calculate the likelihood of a parameter sets.
I want posteriors for about 500 different conditions, each time I calculate a posterior with MCMC.
Since it is hard to check all 500 runs by hand for convergence, I would like to have a simple rule based on autocorrelation which indicates for each run if the chain converged or not, checking all conditions individually would be very cumbersome.
Each chain has length 40000 (burn-in already removed) and I calculated autocorrelations for lags 1 to 10000.
I then calculated the autocorrelation time as the time constant for the autocorrelation series (the first lag when the autocorrelation drops below 1/exp(1)).
I get autocorrelation times between 16 and about 7000.
I suppose that with an autocorrelation time of 16 I can be sure that the Markov chain converged, but is there maybe some "rule of thumb" which tells me, given a chain of length 40000, which autocorrelation time is still "acceptable"?
I searched and looked for instance here, however, the approaches I found  require a visual investigation.
Comment: I believe what most people do (if the algorithms are fast enough and time is no issue) is to take the highest boundry, that is, judge the worst-behaving draw (in terms of autocorrelation) by visual inspection, multiply the resulting burn-in by 2, and apply that to all chains.
Comment: Does this mean I calculate the new burn-in time using the autocorrelation and then calculate my chains again? Time is an issue for me, so I would like to assess convergence from the chains that I have now...
Answer: Have you looked at the standard tests for convergence?
The Geweke's convergence diagnostic works with a single chain and provides a z-score. There is also the Heidelberger and Welch's convergence diagnostic, which also works with a single chain and gives a p-value of the null hypothesis that the sampled values come from a stationary distribution. If you run multiple chains, there's Gelman and Rubin's convergence diagnostic. If you use R, all of these are implemented in the coda package.
Comment: Thanks for the quick answer, I looked into Geweke's convergence diagnostic in `coda` and calculated the z-scores. Then I calculated p-values using `2*pnorm(-abs(z))`
Comment: I calculated the pvalues using Heidelberger and Welch as well and they differ quite substantially from the pvalues I calculated from the z-score from Geweke's diagnostic. Also, I see that if the autocorrelation time is very low (<100), the p-values are very high. I must still be missing something...


Ordernar tabela por valor contido

Question: Quero ordenar tal tabela por um valor contido nela. Ex:
tabela = {
{pessoa="Joao", idade=20},
{pessoa="Pedro", idade=22},
{pessoa="Lucas", idade=19},
{pessoa="Derp", idade=25}
}

Quero ordenar a tabela pela idade.
Algo como:
table.sort(tabela, function(table, value1, value2) return table.value1 < table.value2 end)
for x=1, table.maxn(tabela) do
print(tabela[x].idade)
end

Retornaria:
25
22
20
19

Answer: Você chegou perto. Mas tem três erros.

Você está recebendo os parâmetros de forma indevida. Esta lambda que o table.sort espera recebe apenas dois parâmetros que representam os dois items a serem comparados. Estes itens são valores independentes, você não precisa e nem pode receber a tabela. Da maneira como fez você está recebendo a tabela e pegando os itens dela. Desta forma, em tese, você nem precisaria dos parâmetros subsequentes. Mas é justamente o contrário do que você precisa. Esta lambda não pode ter a assinatura que você quiser porque ela será chamada pelo table.sort. Ela precisa estar de acordo com a especificação estabelecida.

Você está pegando o item todo para comparar ao invés do item específico, ou seja, você precisa pegar a idade da tabela e não a tabela que a função recebe. Não sei se você percebeu você tem uma tabela aninhada. Então sua função anônima passada para o table.sort está recebendo uma tabela com os itens pessoa e idade. Até aí tudo certo. Mas você está tentando comparar a tabela e não dá (não confundir com a tabela principal, é a tabela interior, ex.: {pessoa="Joao", idade=20}). Você precisa comparar um item da tabela. Este item é a idade.

E você mostrou que quer a ordenação decrescente o que obrigaria a comparação ser com sinal de "maior que". Você provavelmente iria perceber isto quando resolvesse o problema anterior.

Então ficaria algo assim:
tabela = {
    {pessoa = "Joao", idade = 20},
    {pessoa = "Pedro", idade = 22},
    {pessoa = "Lucas", idade = 19},
    {pessoa = "Derp", idade = 25}
}
table.sort(tabela, function(value1, value2) return value1.idade > value2.idade end)
for x = 1, table.maxn(tabela) do
    print(tabela[x].idade)
end

Veja funcionando no ideone. E no repl.it. Também coloquei no GitHub para referência futura.
Comment: Perfeito, melhor explicação, impossível. Funcionou aqui.
Comment: +1 Isso é uma bíblia pra quem está aprendendo

Ordernar tabela por valor contido


How to reproduce a case where daemonset failed with no pod is ready

Question: How to reproduce no pod is ready when deploying a daemonset?
I try a small example:
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: logging
  labels:
    app: fluentd-logging
spec:
  selector:
    matchLabels:
      name: fluentd
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      containers:
      - name: fluentd-elasticsearch
        image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log

A follow-up question is how to use field-selector to get events for daemonset error?
involvedObject.kind=Daemonset,involvedObject.name="{daemonset-name}"
Answer: To set to a not ready pod of your DaemonSet, you can simply add a readiness probe that will never be ready.
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: fluentd
  namespace: default
  labels:
    app: fluentd-logging
spec:
  selector:
    matchLabels:
      name: fluentd
  template:
    metadata:
      labels:
        name: fluentd
    spec:
      containers:
      - name: fluentd-elasticsearch
        image: quay.io/fluentd_elasticsearch/fluentd:v2.5.2
        # here the readinessProbe
        readinessProbe:
          initialDelaySeconds: 5
          httpGet:
            host: www.dominiochenonesiste.com
            port: 80
        resources:
          limits:
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        volumeMounts:
        - name: varlog
          mountPath: /var/log
      terminationGracePeriodSeconds: 30
      volumes:
      - name: varlog
        hostPath:
          path: /var/log

To check the pod status, you can use the kubetcl describe pod <nameofyourdaemonsetpodcreated>
Within the output you will have:
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True

Hope it helps!
Cose belle!
Comment: When PodScheduled=False, it means the daemonset is not deployment successfully. Correct?
Comment: @susanna Yes, there is a problem on pod creation. It's not the same as Ready: False. a tipical case of Scheduled False (pening state) is when the image does not exists.


Transverse a single point

Question: I got very confused with understanding this theorem. So $\{y\}$ is a point, how could it be transversed by $f$?

Proof: Given any $y \in Y.$ alter $f$ homotopically to make it transversal to $\{y\}$.
Thank you for your help~~
Answer: The tangent space to a point is trivial, so to say that $f$ is transverse to $\{y\}$ is just to say that $y$ is a regular value of $f$, i.e. that $f'(x):T_xX\to T_yY$ is surjective for all $x\in f^{-1}(y)$.
Comment: Aha! So that's just the image of $df_x$ needs to equal to $T_yY$. That is to say $\{y\}$ is a regular value! Thanks a lot Zev!
Comment: No problem, glad to help :)
Comment: So I guess when $f$ does not pass through $y$, it is transversal and $I_2(f,\{y\}) = 0$; when $f$ pass through $y$, it is transversal when $y$ is a regular value, and $I_2(f,\{y\}) = 1$  right? Then, how come $I_2(f,\{y\})$ is the same for all $y \in Y$? (I'm happy to open a new question for this if you think that is better, and thanks in advance!)
Comment: Could you explain what you mean by $I_2$?
Comment: Thanks a lot Zev! $I_2(f,Z)$ is the mod 2 intersection number of the map $f$.
Comment: Oh, it is the number of points $f^{-1}(Z)$ modulo 2.
Comment: Then it makes sense to me.. But why it has to do with transversality - just use the strong condition of transversality to show $y$ is a regular value...?
Comment: @Jellyfish: It's the same for all $y$ because $Y$ is connected and the number is *locally constant* by the Stack of Records Theorem. G&P use the transversality language so that this is defined even when $y$ is not a regular value by making a small wiggle of the map.
Comment: Oh, got it. I know the locally constant by the stack of records theorem implies globally constant for connected space, but  thanks so much @TedShifrin for clearing that $y$ can be wiggled into transversality. =)

Transverse a single point


Bijection between the reals and the set of permutations of the natural numbers?

Question: In analysis today we talked about re-arrangements of sequences, and one student asked how many re-arrangements there are of a given sequence. We were able to very quickly create a one-to-one function from the reals to the set of permutations on $\mathbb{N}$ by simply noting that for any real number, there is a re-arrangement of a conditionally convergent series that converges to that number.
What we were not easily able to do was either prove that function was onto, or create an injection from the permutations on $\mathbb{N}$ back to the reals. So we know the number of re-arrangements is at least the cardinality of the reals, can we show it is exactly the same as the cardinality of the reals?
Comment: You don't just know that the number of rearrangements is "at least uncountable", you know it is at least the cardinality of the reals. For some reason a lot of people seem to say one when they mean the other.
Comment: Oh, I just learned that it's not yet proved whether the reals have the "smallest" uncountable cardinality or not. I've edited the question accordingly. In the defense of all those who mix up the two phrases: I could swear someone equated the two in the past, but maybe I misinterpreted a statement like the reals are the smallest uncountable field or something like that.
Answer: Here you'll find a proof that the infinite continued fractions with $0$ integer part are precisely the irrationals in $(0,1)$. The map
$$\left(\Bbb Z^+\right)^{\Bbb Z^+}\to(0,1):a\mapsto[0;a_1,a_2,a_3,\dots]$$
is therefore an injection.
Comment: I'm not advanced enough to firmly link that with my question - but let me take a shot at it: $(\mathbb{Z}^+)^{\mathbb{Z}^+}$ is the set of all functions from $\mathbb{N}$ to $\mathbb{N}$? Then.. ummm.. $a$ is a particular function? And... I'm not used to seeing a semicolon in math. Is that supposed to be interval notation on the far right? I can't tell if my question is too easy or too complex to get an answer that I can understand.
Comment: @Todd: My $\Bbb N$ includes $0$, which is why I used $\Bbb Z^+$, but yes, $\left(\Bbb Z^+\right)^{\Bbb Z^+}$ is the set of functions from $\Bbb Z^+$ to $\Bbb Z^+$. Yes, $a$ is a particular function, though I'm writing $a(k)$ as $a_k$. No, that's not interval notation; that's standard notation for a [continued fraction](http://en.wikipedia.org/wiki/Continued_fraction), as used at the link that I gave.
Comment: I think I'm very close. $a\in (\mathbb{Z}^+)^{\mathbb{Z}^+}$ and $a_1, a_2, a_3,\ldots$ is an explicit list of the range of $a$. Then we have $\phi:(\mathbb{Z}^+)^{\mathbb{Z}^+} \rightarrow (0,1)$ where $\phi(a)=[0;a_1,a_2,a_3,\ldots]$. And $\phi$ is an injection because if $\phi(a)$ and $\phi(b)$ represent the same continued fraction, then $a=b$ must be true. So the cardinality of the permutations on $\mathbb{N}$ must be both greater than or equal to and less than or equal to the cardinality of the reals, and therefore they are equal. Did I understand correctly?
Comment: @Todd: Close. $\langle a_1,a_2,\dots\rangle$ **is** the function $a$: a function with domain $\Bbb Z^+$ is just a sequence. I did not require the functions to be permutations, so there may be repetitions. However, the set of permutations of $\Bbb Z^+$ is a subset of $\left(\Bbb Z^+\right)^{\Bbb Z^+}$, so an injection from $\left(\Bbb Z^+\right)^{\Bbb Z^+}$ to $\Bbb R$ automatically gives one from the set of permutations of $\Bbb Z^+$ to $\Bbb R$. The map $\varphi$ is injective because every irrational in $(0,1)$ has a **unique** continued fraction expansion, so two different sequences ...
Comment: ... give two different continued fractions which must represent different irrationals. The rest is fine: this gives an injection from permutations of $\Bbb Z^+$ to $\Bbb R$, and you already had one in the other direction. The result now follows from the [Schröder-Bernstein theorem](http://en.wikipedia.org/wiki/Cantor%E2%80%93Bernstein%E2%80%93Schroeder_theorem).
Comment: I think we are saying the same thing. I knew that $a$ were not permutations and also that permutations are a subset of overall functions (if I didn't know before now, Chris' answer would have lead me to that). I think whether you call a sequence the range of a function with domain $\mathbb{Z}^+$ (or $\mathbb{N}$) or the function itself is just a matter of point of view or word choice. I also worded the justification of the injective nature of $\phi$ with different words but I don't see it as being fundamentally different. And I know S-B well. :) Thanks!
Comment: @Todd: You're welcome! (My comment about $a$ being the function was prompted by your statement that $a_1,a_2,\dots$ was an explicit list of the range: your use of *list* left a little bit worried that you were thinking of it as a $1$-$1$ enumeration of the range, when in fact all of the $a_k$'s might have been identical. I thought that I'd better play safe by being very explicit.)
Comment: The link to the proof gives me a 404 error.
Comment: @Galen: I *think* that [this](https://sites.millersville.edu/bikenaga/number-theory/infinite-continued-fractions/infinite-continued-fractions.html) is the same PDF.
Answer: The number of permutations of $\Bbb{N}$ is at most the number of functions from $\Bbb N$ to $\Bbb N$, which is $\aleph_0^{\aleph_0}$. But $\aleph_0^{\aleph_0} \le (2^{\aleph_0})^{\aleph_0}=2^{\aleph_0 \cdot \aleph_0}=2^{\aleph_0}$.
Comment: Thanks. I know $\aleph_0$ is the cardinality of the natural numbers, otherwise I don't know that notation. Also, can you direct me to a proof of your answer?
Comment: Ok, I understand your cardinal arithmetic now. But I have one question: $2^{\aleph_0}=\mathfrak{c}$ or $2^{\aleph_0}=\aleph_1$ or $2^{\aleph_0}=\mathfrak{c}=\aleph_1$?
Comment: $2^{\aleph_0}$ is the cardinality of the powerset of $\Bbb N$, which is the same as the cardinality of the reals, and is also called $\mathfrak{c}$.
Comment: Ok, Wikipedia confusingly says in one place that $2^{\aleph_0}=\mathfrak{c}$ and in another place it says $2^{\aleph_0}=\aleph_1$. I'm going to upvote your answer since it was certainly educational and wait to see if I can get a more straightforward answer about an actual bijection before I accept anything.
Comment: Where does Wikipedia claim that $2^{\aleph_0}=\aleph_1$?
Comment: http://en.wikipedia.org/wiki/Cardinal_numbers - but that is actually about the Continuum Hypothesis, it's just confusingly worded. Also, is the fact that $2^{\aleph_0}=\mathfrak{c}$ another way of what I'm asking for a proof of? It doesn't seem like a big leap to say the number of permutations on $\mathbb{N}$ is less than or equal to the size of the power set of $\mathbb{N}$. It doesn't seem as straighforward to me that the power set of $\mathbb{N}$ has the same cardinality as the reals.
Comment: This question links my question and your answer, I think: http://math.stackexchange.com/questions/86650/proof-that-the-power-set-of-mathbbn-is-uncountable-and-that-the-compositio
Comment: Is $\aleph_0^{\aleph_0}<2^{2^ {\aleph_0}}$?  This is my motivation: https://math.stackexchange.com/questions/4773529/ .  It looks like the answer is "yes".
Answer: I have just done this as an exercise in my introductory Set Theory text.
Let $( a_1, a_2, \dots )$ be a permutation of $\mathbb N$.
For each $a_i$, form a string of $(a_i-1)$ zeros followed by a $1$.  Call this string $s_i$.  For example, if $a_i = 5$, then $s_i = 00001$.
Define a mapping $f : (a_1, a_2, \dots ) \mapsto 0.s_1s_2s_3\dots$, where $0.s_1s_2\dots$ is the concatenation of the strings $s_i$.
Then $f$ gives the desired injection when $0.s_1s_2\dots$ is read as the binary expansion of $x \in [0,1]$.  The injection going the other way can be obtained as per your OP.
Edit : Come to think of it, you don't need to view the image as a binary expansion.  It works equally well as a decimal expansion.


Continued fraction $[0;0,0,0,\ldots] = \pm 1$

Question: I would like to represent each $x\in\mathbb{R}_{>0}$ as a unique continued fraction. We represent each $x$ with $[a_{0};a_{1},a_{2},\ldots]$ as usual for the continued fraction. for irrational numbers, we know the sequence is infinite. For rational numbers we have a finite sequence. To have a unique representation in this notation I would like to extend the sequence with zero's. For example, $\frac{415}{93} = [4;2,6,7]$ would be extended to $[4;2,6,6,0,0,\ldots]$. We compute $$0+\frac{1}{0+\frac{1}{0+\ddots}},$$
$x_{n+1}=0+\frac{1}{x_{n}}\Rightarrow x^{2}=1\Rightarrow x=\pm 1.$
Would this be a unique representation for $x\in\mathbb{R}_{>0}$, or would this give a problem since the continued fraction of $[0;0,0,\ldots]$ is also $-1$. Possible way to work around this problem?
Comment: Is $0+\frac{1}{0+\frac{1}{0+\ddots}}$ even well defined as a limit?
Comment: Usually, zeros do not occur in a (simple) continued fraction, apart from the first entry.
Comment: We cannot truncate $[0,0,0,\cdots]$ at any point since we would divide by $0$, so I do not think that this expression is valid.
Comment: A rational number has a terminating simple continued fraction. No need to add trailing zeros (which is harmless for a real terminating number, but apparently not here). If you avoid the "trailing zeros", you have the desired uniqueness.
Comment: @Peter, indeed no zeros occur in a (simple) continued fraction since the classic algorithm to make them would stop if we have a zero at some point. Avoiding the zeros would give a better uniqueness. Thank you! (also @Henry)
Answer: My gut feeling is that you should not proceed in this direction at all, unless this new notation buys you something really big (some result that is impossible or very hard to get otherwise) - which is very unlikely, as it would be a result, essentially, about rational numbers.

I will elaborate.
This is because, with ordinary continued fractions, even if they are infinite, the resulting irrational number is the limit (in the ordinary calculus sense) of the sequence of the truncated (finite) continued fractions. However, once you start the tail of zeros, truncation is impossible. You will not be able to obtain the value of $0+\frac{1}{0+\frac{1}{0+\ldots}}$ using standard analytic limit. Your technique ("$x=0+\frac{1}{x}$") is useful to calculate limits that already exist, but here you don't even have a sequence that should converge to anything, because any finite truncation results in division by zero!
Of course, you may neglect all that and say "let me introduce some new notation, in which $0+\frac{1}{0+\frac{1}{0+\ldots}}$ has the value (say, $1$), and let me develop the mathematics that proves some rules about that new notation. It might be possible (although my guess is that it is very unlikely you will get to something that you cannot prove without using this notation).
A few last remarks:

Introducing zeros will make the continued fractions ambiguous. Say, $[1;1,1,1,1,1,\ldots]=\varphi$ but if you introduce zeros, $[1;0,0,1,1,0,0,1,1,0,0,1,1,\ldots]$ would be $\varphi$ too.
Also, what is $[1;0,1,0,1,0,1,\ldots]$? (It's got to be a number $x$ such that $x=x+1$.)

Altogether, I think by adding the possibility that some numbers in the continued fraction expansion are zeros, you lose some important properties of continued fractions - do you gain enough that would justify that loss?
Comment: Thank you very much for you answer. My question is answered now :)
Answer: The value of the continued fraction is, by definition, $\lim r_n$ where the $r_n$ are the convergents
$$
r_0 = 0,\\
r_1 = 0 + \frac{1}{0},\\
r_2 = 0 + \frac{1}{0+\frac{1}{0}},\\
\vdots\\
r_{n+1} = 0+\frac{1}{r_n}\\
\vdots
$$
Because of the zeros in the denominator, we cannot do this in the real numbers. So let's do it in the Riemann sphere (a.k.a. projective line).  Then
$$
r_0 = 0\\
r_1 = 0+\frac{1}{0} = \infty\\
r_2 = 0+\frac{1}{\infty} = 0\\
r_3 = 0+\frac{1}{0} = \infty
$$
alternating between $0$ and $\infty$.  So, in the Riemann sphere, this sequence does not converge.

In the conventional theory of continued fractions with real entries, there is a theorem that if $b_k \ge c$ for some $c>0$, then
$$
b_0 + \frac{1}{b_1+\frac{1}{\displaystyle b_2+\ddots}}
\tag1$$
converges.  Even if the $b_k$ are positive but converge to $0$ we could get divergence for the continued fraction $(1)$.


How to prove that $\operatorname{Cov}(\cdot, \cdot)$ is symmetric and bilinear, where $(\cdot,\cdot)$ represents the dot product of two vectors

Question: How can one prove that $\operatorname{Cov}(\cdot, \cdot)$ is symmetric and bilinear, where $(\cdot,\cdot)$ represents the dot product of two vectors?
I tried searching for it but couldn't find the answer. I need to prove that the covariance operator is symmetric & bilinear.
Answer: Show that $Cov(X,Y) = Cov(Y,X)$ -- symmetric
$Cov(aX,Y) = a Cov(X,Y)$ -- Linear
and if it is linear and symmetric it will be bi-linear.
$Cov(X,aY) = a Cov(X,Y)$ -- bi-linear
Now you can refer to the definition of co-variance, $E[(X- E[X])(Y-E[Y])]$
Now you can refer to the definition of co-variance, $E[(Y-E[Y])(X- E[X])]$ by the commutitivity of multiplication.
$E[X]$ is linear.
$E[aX] = a E[X]$
$Cov(aX,Y) = E[(aX- E[aX])(Y-E[Y])] = E[a(X- E[X])(Y-E[Y])] = aE[(X- E[X])(Y-E[Y])]$
Or you can say that Cov meets the definition of an inner product space, which must be symmetric (for vectors over the real numbers, conjugate symmetric for complex vector spaces).  And linear (in the first term for complex vector spaces, bi-linear for real spaces).
Comment: You should homogeneity but not additivity


Convergence of a symmetric Matrix

Question: I am kind of stuck trying to write down a mathematical proof. Since i am a Computer Sience person, I know some maths terms more and some less. There are terms which i don't know about and thus can't form the equation the way i want in order to have the proof that i want.
Yes this is homework, but by writing it i hope to get more insight and hopefully answers that can help me solve it.
And here comes the proof question:
Given Matrix $M = \begin{pmatrix} 1&0 \\ 0&-1 \end{pmatrix}$ and vector $x_{0}=\begin{pmatrix} a \\ b \end{pmatrix}$. Show that the sequence of numbers $(x_{k}
|k \geq 0)$ with $x_{0}=\begin{pmatrix} a \\ b \end{pmatrix}$  (where $b \neq 0$) does not converge.
What i have done so far:
I have written out the sequence of numbers.
$(x_{0}\,\,\, x_{1}\,\,\, x_{2}\,\,\, x_{3})$
Furthermore one can write this as:
$\left(x_{0}\,\,\,\frac{K*x_{0}}{K*x_{0}}\,\,\,\frac{K*\frac{K*x_{0}}{||K*x_{0}||}}{||K*\frac{K*x_{0}}{||K*x_{0}||}||}\,\,\,\frac{K*\frac{K*\frac{K*x_{0}}{||K*x_{0}||}}{||K*\frac{K*x_{0}}{||K*x_{0}||}||}}{K*\frac{K*\frac{K*x_{0}}{||K*x_{0}||}}{||K*\frac{K*x_{0}}{||K*x_{0}||}||}}\,\,\, ...\right)$
I do understand that this is some kind of recusrion happening here. As a next step i tried to factor out the $K$'s in each element of the sequence, so the sequence becomes:
$\left(x_{0}\,\,\,\frac{K*x_{0}}{K*x_{0}}\,\,\,\frac{K^{2}*\frac{x_{0}}{||K*x_{0}||}}{||K^{2}*\frac{x_{0}}{||K*x_{0}||}||}\,\,\,\frac{K^{3}*\frac{\frac{x_{0}}{||K*x_{0}||}}{||K^{2}*\frac{x_{0}}{||K*x_{0}||}||}}{K^{3}*\frac{\frac{x_{0}}{||K*x_{0}||}}{||K^{2}*\frac{x_{0}}{||K*x_{0}||}||}}\,\,\,\right)$
But now i am stuck because i dont know how to simplify the elements in the sequence further and end up with something that proofs the statement above.
Answer: Presumably $x_k=Mx_{k-1}$. If this is the case, then you are overthinking. It's easy to see that $x_k=\pmatrix{a\\ (-1)^kb}$. Therefore, if $b\ne0$, the second entry of $x_k$ keeps oscillating between $b$ and $-b$ and it doesn't converge as $k\to\infty$.

Convergence of a symmetric Matrix


Access playbook variables from custom module in Ansible

Question: I'm writing a custom module in Ansible, specific to a Playbook. Is it possible to directly access a playbook variable, without needing to pass it to the task as a parameter?
Answer: It is not possible, because the module is executed remotely and all the variables are not available unless explicitly passed.
I had the same question a while ago and Pruce P offered an interesting workaround in his answer.
Though I had another idea in the meantime, but this is only theoretical and never tested: Beside normal modules, Ansible has a special kind of module: action plugins. (...not documented) They are used exactly like modules but are executed locally. Since they run locally they do have access to Ansibles runner object which holds all the group/host vars etc.
The cool thing is, you can call a module programmatically from the action plugin. So you could have a small wrapper action plugin which then calls the actual module and passes all (required) vars to it. Since it is undocumented you need to look at the available plugins. For instance here is one which calls a module: assemble.
I have written something here which interacts with vars from the runner object.


How should I add multiple markers using geofield module?

Question: Whenever I set the module with unlimited values there are more the one maps with location. However they show the location which I want, but in two or more different maps.
My problem is I want to integrate multiple location with a single map. My project is kind of setting the route for people.
How do I do that? Should I create a hook for the Geofield module?
Comment: Merci for the accept (+ upvote). Next question?
Answer: Have a look at the IP Geolocation Views & Maps module. Partial quote from its project page:

Despite what the name may suggest, IP Geolocation Views & Maps (IPGV&M) is first and foremost a mapping engine.
The module makes it very easy to create Views-based mapping solutions using the map renderer of your choice (Google, OpenLayers or Leaflet) with any location storage module of your choice, e.g.:

Get Locations,
Geofield,
Geolocation Field
Location.

This allows you to bring together modules and feature sets that without IPGV&M you would not be able to combine.
Like beautiful animated marker clustering on Google or Bing or Mapbox ... any of various map providers.
But more importantly IPGV&M adds some features you won't find as conveniently packaged elsewhere.
These include marker differentiation based on field values or ranges (2nd screenshot) with or without font icons, various centering options, super-imposing the current visitor's location, allowing multiple content types to be displayed on the same map, full screen button and mini-map inset (bottom screenshot), polygon support (Geofield), marker tags and tool tips and cross-highlighting of associated content on the page when markers are hovered (and vice versa).

Head over to its (impressive) project page for even more information about it (it would be way too long to include a quote of it all here). That project page also includes various screenshots.
Note: Uploading custom markers should be possible also, similar to what you can see in the screenprint in the feature request about Custom markers.
PS: I'm assuming this question is about D7 ...
Comment: My reputation is below 15 so i cant even cast vote for your answer. however i can say its was helpful. and thanks for sharing.
Comment: Done Sir.. Thank you for your time .... Can i ask one more question?? It is really important for me... As i m new to drupal i am facing a little problem in integrating maps with Entityform..Actually i have to add multiple locations in of form of a route and show it after the submit button in a single map...  how do i do that??? i am using drupal 7 in this case.... thanks
Comment: @AnirbanNeogi : no need for "sir" (just Pierre is fine). I suggest you post that new question in your previous comment as a NEW question. That way it allows anybody to post an actual answer (instead of trying to squeeze it in a few comments or so). OK? PS: now that "this" question is answered, and according to the rules of this site, it is not allowed to "change" the question here anymore (or add a new question to it). Just to avoid that it would invalidate existing answers.
Comment: Okay @Pierre.Vriens


Separate values by commas and add a column indicating the order of those values

Question: I have a column with values separated by commas, I'm looking to separate them and create a row for each value group by store and region. Then create a column indicating the order each value was in:
Input:

Store
Region
Product_ID

1
A
1C,18

1
B
6,B6

2
A
20,A9

2
C
L0

Output:

Store
Region
Product_ID
SPLIT
ORDER_SPLIT

1
A
1C,18
1C
1

1
A
1C,18
18
2

1
B
6,B6
6
1

1
B
6,B6
B6
2

2
A
20,A9
20
1

2
A
20,A9
A9
2

2
C
L0
L0
1

I managed to separate the columns, using:
from pyspark.sql.functions import split, explode

SELECT *, explode(split(Product_ID, ',')) AS SPLIT
FROM _mytable_ GROUP BY store, region

While it seems to sort them in order, I didn't find anything indicating that the explode function would split them in order for me (so I could then create a rank, relying on the order returned).
If anyone can assure me that it will always split in order, or know any other function/way that will serve the purpose to help me create the "order_split" column, I would appreciate it.
I'm on databricks and in this case use pyspark.sql.
Thanks
Comment: why do you want split order  and in new row ? can you please complete logic what are you going to do after split ?
Answer: Try with posexplode function.
Example:
from pyspark.sql.functions import *

df.select("*",posexplode(split(col("product_id"),",")).alias('ORDER_SPLIT','SPLIT')).\
  withColumn("ORDER_SPLIT",col("ORDER_SPLIT")+1).\
    show()
#+-----+------+----------+-----------+-----+
#|store|region|product_id|ORDER_SPLIT|SPLIT|
#+-----+------+----------+-----------+-----+
#|    1|     A|     1c,18|          1|   1c|
#|    1|     A|     1c,18|          2|   18|
#|    1|     B|      6,B6|          1|    6|
#|    1|     B|      6,B6|          2|   B6|
#|    2|     C|        L0|          1|   L0|
#+-----+------+----------+-----------+-----+


Are parametric tests on rank transformed data equivalent to non-parametric test on raw data?

Question:
Many non-parametric tests are identical to their parametric equivalent on ranked data. At least, that's what I learned from this blog post on Friedman's test and skimming this 1981 article.. This seems immensely practical, especially for paedagogical purposes. But I couldn't find any demonstrations of this equivalence, so I decided to try it out myself.
However, although they match closely, they don't match exactly and for paired samples, the difference is large. Am I missing something or is this "equivalence" imperfect? Here're a few examples:
# generate two dependent samples.
set.seed(42)
x1 = rnorm(20)
x2 = x1 + rnorm(20, 1, 4)
x = data.frame(score=c(x1,x2), time=rep(c('pre', 'post'), each=20))

# Correlation of ranks. Exact correlation.
# p_spearman=0.0074, p_pearson=0.0064
cor.test(x1, x2, method='spearman')
cor.test(rank(x1), rank(x2), method='pearson')

# Unpaired samples between-subjects-difference test.
# p_wilcox=0.718, p_t-test=0.711
wilcox.test(x$score ~ x$time)
t.test(rank(x$score) ~ x$time)

# Paired samples within-subject-difference test. Bad p-value?
# p_mann-whitney=0.927, p_t-test=1.00
wilcox.test(x1, x2, paired=T)
t.test(rank(x1), rank(x2), paired=T)

Comment: I suspect "identical to" is meant in the sense of "uses the same test statistic, but with data replaced by their ranks."  *Of course* that will change the statistical characteristics of a test, so comparing p-values won't tell you much about how such tests are related. In fact, most of the work involved in proposing and developing such a test involves (1) figuring out the null distribution of the test statistic, (2) determining its power, and (3) measuring its robustness to changes in distribution.
Comment: Everything here is on ranks. No raw data. As I understood it, these nonparametric tests are actually parametric tests of ranks. Thus a parametric test of ranks should be identical to the nonparametric tests. I'm asking if this is true.
Comment: My point is that the tests will differ, *at the very least*, in how they compute p-values.  That means that applying a parametric test, *with its assumptions about the null distribution,* to the ranks is rarely the same as the comparable nonparametric test that is derived from it. (Indeed, that process would automatically invalidate most parametric tests.) You will often also get different values for the test statistics simply because the nonparametric tests may choose to standardize or otherwise re-express the statistic in a mathematically equivalent way.
Answer: I think it's important to clearly distinguish between
a. using a parametric statistic on the ranks as the basis for a nonparametric test
b. using a parametric test as is, on the ranks
(we might also consider a third option -- like "b." but in some way scaling or adjusting the statistic to get a better approximation to the "true" p-value from ordinary tables. I'll ignore this possibility for now, but it may be a fruitful endeavour.)
In the first case, we would compute the statistic as usual, but when finding the p-value we'd look at the distribution of that test statistic under the null. In particular, the non-parametric rank-based tests are permutation tests (which - because the set of ranks is fixed for each sample size, for continuous distributions - don't depend on the specific observed values). So we would compute the permutation distribution of the parametric test applied to the ranks.
When we do that we do indeed sometimes get a test that's equivalent to a well-known non-parametric test (equivalent in this case means that it "orders" the set of possible samples in the same way, so it will always give the same p-values)
In the second case, we simply ignore that we have ranks and treat the ranks as if they were independent samples from whatever the assumed distribution was. That won't give the same p-values as the nonparametric test. Indeed, in small samples the distribution can't be right. However, for some tests, at larger sample sizes it can become fairly close, and then the tests will have about the right significance levels. When that happens, p-values may be quite similar to what they were in the first case.
We can see this with the ordinary equal variance two-sample t-test vs the Wilcoxon test:

The first plot shows us that indeed in this example the p-values for each of the samples are in the same order (the monotonicity indicates that the "equivalent tests" under part a was holding up -- as is already known for this pair of tests). It is also encouraging because it looks like the p-vaue pairs are quite close to the $y=x$ line. The second plot shows the difference in p-values. Now we can see that the t-test applied directly to ranks as if they were i.i.d normal data gives p-values that are nearly always lower than the Wilcoxon-Mann-Whitney (and indeed, typically too low).
[Other sample sizes show similar patterns - at equal sample sizes the broad shape of the pattern of differences remains, but the scale on the y-axis of the second plot gets smaller as sample size goes up; at unequal sample sizes the shape of the second plot changes but the lower p-values for the t remains.]
So if we use the test as in "b.", we reject too often at any significance level.
However, since that difference grows smaller as sample size increases, if both samples are large, this may not bother us much.
(Note that this discussion hasn't investigated power yet, nor any other tests than this simple comparison, but many of the points I made will carry over to other tests.)
Oh, I guess people will want code. I did that in R:
n1=40;n=n1+n1
res=replicate(1000,{v=sample(n);
                    c(t.test(v[1:n1],v[(n1+1):n],var.equal=TRUE)$p.value,
                      wilcox.test(v[1:n1],v[(n1+1):n])$p.value)
                    })

note that v contains the current random permutation of ranks under the null
Takes about a second on my laptop. Note that the t-test p-values are in the first row of res and the WMW p-values are in the second row.
Comment: Could you explain what you mean by "...as the basis for...?" Also, For a specific system, is there a way to tell if either approach (a) or (b) is good enough? See https://stats.stackexchange.com/questions/421481/can-i-use-multiple-regression-on-a-ranked-response-variable-as-a-significance-te
Comment: Sorry, don't know how I missed this before. "As the basis for" is already explained in the paragraph that begins "In the first case...".  The second question -- sure, as long as you specify enough things (like what, exactly constitutes 'good enough' and what circumstances you're checking), but details don't fit here.
Comment: Thank you @Glen_b.


Twig define dynamic generate variable

Question: I have field names:

field_en_image
field_sv_image

node_lang is set as a variable in the .theme file under _preprocess_node hook.
I want to print the field dynamically in the twig template file based on the current language.
<code>{{ node.["field_"~node_lang~"image"]|view }}
</code>
but this seems to be not working.
Comment: I think this is a general Twig question and as such off-topic. What you're looking for are [dynamic variable names in Twig](https://stackoverflow.com/questions/40177195/dynamic-variable-in-twig-example)
Comment: {% set fieldName = "field_" ~ node_lang ~ "_title" %}
{{ fieldName.value }}
{{ fieldName.view }} is not working as well
Answer: Try the following
<code>{% set field_name = "field_"~node_lang~"image" %}
{{ attribute(node,field_name) | view }}
</code>
or
<code>{% set field_name = "field_"~node_lang~"image" %}
{{ attribute(content,field_name) }}
</code>

If you want to access a dynamic attribute of a variable, use the
  attribute function instead.
The attribute function is also useful when the attribute contains
  special characters (like - that would be interpreted as the minus
  operator):
<code>{# equivalent to the non-working foo.data-foo #}
{{ attribute(foo, 'data-foo') }}
</code>
Answer: You should be using the _context variable instead, which represent the whole accessibles variables, you can find some informations about that variable under Macros documentation.
That snippet may help :
<code>{% set language = 'fr' %}

{% set foobar = _context["field_" ~ language ~ "_foobar"] is defined ? _context["field_" ~ language ~ "_foobar"] : null %}

{{ foobar }}
</code>
I've wrote to you a little TwigFiddle, check it out :)
Comment: I tried below, but its not displaying anything.

{% set language = 'fi' %}
{% set foobar = _context["field_" ~ language ~ "_title"] is defined ? _context["field_" ~ language ~ "_title"] : null %}
{{ foobar }}
Comment: Those fields `field_fi_title` and every "languages related" ones exists in the database ?

Twig define dynamic generate variable


Get the name of an index in an array

Question:
Possible Duplicate:
Get first key in a [possibly] associative array?

I have this array:
Array
(
    ['foobar'] => Array
        (
            [key1] => value1
            [key2] => value2
        )

)

I want to get to name of the first index (foobar). How can I do it?
Answer: Other way is,
$keys = array_keys($array);

echo $keys[0];

Comment: maybe shorten it     $firstKey = array_keys($array)[0];    ?
Answer: Assuming that you haven't used each(), next(), prev() or in any other manner have you advanced the array pointer:
key($array);

Get the name of an index in an array


Run Nuxt 3 programmatically

Question: I am trying to run Nuxt 3 programmatically. This is what I got so far:
import { loadNuxt, build } from 'nuxt';

const options = {
    rootDir: '../nuxt.config.ts',
    dev: false,
};

async function main(){
    const nuxt = await loadNuxt(options);
    await build(nuxt);
}

main();

And this is what I get in the logs:
ℹ Client built in 897ms
ℹ Building server...
✔ Server built in 922ms
✔ Generated public .output/public
ℹ Initializing prerenderer
ℹ Prerendering 3 routes
  ├─ / (6ms)
  ├─ /200 (0ms)
  ├─ /404 (1ms)
start Building server...
start Writing server bundle...
✔ Server built
  ├─ .output/server/package.json (307 B) (183 B gzip)
  ├─ .output/server/index.mjs (458 B) (257 B gzip)
  ├─ .output/server/chunks/nitro/node-server.mjs.map (58.1 kB) (4.44 kB gzip)
  ├─ .output/server/chunks/nitro/node-server.mjs (18.7 kB) (5.74 kB gzip)
  ├─ .output/server/chunks/handlers/renderer.mjs.map (15.5 kB) (2.73 kB gzip)
  ├─ .output/server/chunks/handlers/renderer.mjs (11.8 kB) (3.83 kB gzip)
  ├─ .output/server/chunks/app/client.manifest.mjs.map (2.77 kB) (505 B gzip)
  └─ .output/server/chunks/app/client.manifest.mjs (3.8 kB) (651 B gzip)
Σ Total size: 651 kB (150 kB gzip)
✔ You can preview this build using node .output/server/index.mjs

So it seems to me that is building and generating the files.
When I run:
node .output/server/index.mjs

The server is loading but it is broken, it cannot find what it seems the main js file:
GET http://locahost:3000/_nuxt/entry.a5f4ac90.mjs net::ERR_ABORTED 404 (Cannot find static asset /_nuxt/entry.a5f4ac90.mjs)

I was able to run Nuxt 2 programmatically with no problem, I am wondering if it is possible also for Nuxt 3.
Edit
Something I figured out is that the nuxt.config.ts must have ssr: true.
This is my nuxt.config.ts now:
import { defineNuxtConfig } from 'nuxt'

export default defineNuxtConfig({
        srcDir: './src/nuxt',
        target: 'static',
        typescript: {
                typeCheck: false
        },
        buildDir: './.nuxt',
        components: [
                {
                        path: '~/components/',
                        extensions: ['vue']
                }
        ],
        generate: {
                dir: './dist/admin',
                fallback: '404.html',
                subFolders: false,
                exclude: ['/urn-admin'],
        }
})

// my page directory structure
pages/
- index.vue
- about.vue

And now I am getting this error:
GET http://locahost:3000/_nuxt/entry.c132761b.mjs net::ERR_ABORTED 404 (Cannot find static asset /_nuxt/entry.c132761b.mjs)
GET http://locahost:3000/_nuxt/index.50f3e684.mjs net::ERR_ABORTED 404 (Cannot find static asset /_nuxt/index.50f3e684.mjs)
GET http://locahost:3000/_nuxt/about.2286c269.mjs net::ERR_ABORTED 404 (Cannot find static asset /_nuxt/about.2286c269.mjs)
GET http://locahost:3000/_nuxt/error-component.17941a7e.mjs net::ERR_ABORTED 404 (Cannot find static asset /_nuxt/error-component.17941a7e.mjs)

It should be good to have a documentation for this.
Answer: First of all, I recommend using @nuxt/kit for this purpose as nuxt 3 is not providing the same way as nuxt 2 in this matter. And i think your code may have compatibility issues with nuxt 3. Also, try checking nuxt 3 documentation to create the nuxt.config.ts file the proper way, as your config file may have issues with nuxt 3. As you are overriding buildDir and Generate directory, In normal situations, this error would be a sign of different 'buildDir' and 'PublicPathDir'.
By the way, the following may help you bypass these errors but won't solve the possible root causes.

Try running npm cache clean --force or npx nuxi clean before building. Your error may be the consequence of changing publicPathDir or other hard coded directories at the runtime. this will clean the cache and rule out this possible cause.

Try your code in development mode and if the problem resolved, try using something like the following in your nuxt.config.js after installing @nuxtjs/proxy:

modules:[['@nuxtjs/proxy',{"/_nuxt/":{target:'http://localhost:3000/_nuxt'}}]]

This comment may be helpful as it's similar to the way you seek to use nuxt 3.

Run Nuxt 3 programmatically


Folland ordinals exercise

Question: Consider following exercise from Folland's book:
I succesfully proved (a),(b),(c) and now I want to prove (d).

Attempt (outline):
Put $E:= \bigcap_1^\infty E_n$. We may assume $E \subseteq \Omega$ by removing the element $\omega_1$ (this modified is uncountable iff the original set is uncountable). We use (c) to prove that $E$ is uncountable.
So, let $x \in \Omega$. Define a sequence $(x_n)_n$ by a diagonal argument:
Define $x_0:= x+1$
$x_1 \in E_1, x_2 \in E_2, x_3 \in E_1, x_4 \in E_2, x_5 \in E_3, x_6 \in E_1, x_7 \in E_2, x_8 \in E_3, x_9 \in E_4, x_{10}\in E_1$ and continue. We can also arrange that $x_1 < x_2 < x_3 <\dots$, again using (c).
Following the hint, $(x_n)_n$ converges. I proved that $\lim_n x_n = \sup_n x_n = \bigcup_n x_n$. By construction thus $y:=\lim_n x_n \geq x_0 =x+1> x $. Also, all subsequences of $(x_n)$ converge to $x$ so  since $(x_n)_n$ contains subsequences consisting entirely from terms of each $E_n$, we see that $y=\lim_n x_n \in \overline{E_n} = E_n$ for all $n$ and hence $y \in E$, as desired.
Does the above proof outline look correct?
Answer: Yes, it's correct. Another way is to show that the intersection of two uncountable closed sets is uncountable by using the same basic argument but simply alternating between the two sets. It immediately follows that the intersection of finitely many uncountable closed sets is uncountable, so you can let $F_n=\bigcap_{k=1}^nE_n$, choose $x_1>x$ in $F_1$, and for $n>1$ choose $x_n>x_{n-1}$ in $F_n$. This way you automatically get a sequence with subsequences — tails, in fact — in each $E_n$.
Answer: Yes, your proof is fine. Perhaps a neater way of defining the sequence is by requiring that:

$(x_n)$ is increasing, and
if $k$ is the largest such that $2^k\mid n$, then $x_n\in E_{k+1}$.

This way it is slightly clearer than "and continue", and more formal as to how to continue. Then it's also very easy to point at a subsequence in $E_{k+1}$ by simply taking $x_{2^k(2m+1)}$ for $m\in\Bbb N$.

Folland ordinals exercise


Undefined function json_decode()

Question: When attempting to update a Drupal 7 site through the UI or Drush, I get Error: Call to undefined function json_decode() in home/xxxxx/drush/includes/output.inc, line 403 , code: 255)
The server is running PHP 7.3 with json enabled - I've verified this with phpinfo(). I'm at a loss here, and even if I apply updates by ftp, I still can't run database updates. Shared hosting without root access.

PHP 7.3.13
Drush 5.9
Drupal 7.x
Comment: Doesn't the same happen in a local copy of the site? Does the same happen on the live server when you call `json_decode` in a completely unrelated bare PHP script? Then this probably has nothing to do with Drupal, but with the hosting.
Comment: I have not made a local copy of the site, however it does occur on the production and staging site on the same server. json_decode does work from a script called from the web root. I spent an hour with hosting support to be told it's not a server issue. The only common denominator is drush, since both sites use that same install. So I'll try reinstalling drush and see if that changes anything.
Answer: So I finally found the culprit. A php symlink in the bin directory linking to an old version of php. I guess even though drush showed it was using version 7.3, those scripts used that symlink and was pulling in an older php version. Error is gone and I can finally update through drush.

Undefined function json_decode()


How to add multi nodes on a single page without using an iFrame?

Question: I came up with the Multi Node Add module to add multiple nodes to single page. But the nodes are shown on iframe.
Is there another way with which we can add multiple node on single page without iframe?
Answer: Consider using the Rules module, to insert a message with a clickable link in the Drupal Message area, whereas that link points to "/node/add" each time a node is saved.
Here is a summary of the rule to implement this:
Events: After saving new content
Actions: Show a message on the site, whereas the "value" of the message to be displayed should be something like so: Click to add another node.
This assumes you want to do this for all possible content types. If you'd want to limit it to specific types only, you'd have to add appropriate
Conditions (for the desired content types) also.
Answer: I would recommend the Advanced Form Block:

Welcome to Advanced Form Block Module. With this module you can do the
  following:
1) Create any number of blocks with a particular node edit form. 2)
  create any number of blocks with a particular node add form of a
  content type. 3) Create as many blocks as you like of each kind. 4)
  From the content type choose which fields to display on a per block
  basis.However required fields will be automatically displayed. 5) All
  forms will be saved through ajax. So multiple node forms can be
  independently placed on a single page and worked with simultaneously.

With this, you can add any number of node add/edit forms (each with their own submit controls)


Why $a^2+b^2=c^2$ is named after Pythagoras? It is known by earlier generations before him such as the Chinese.

Question: Why $a^2+b^2=c^2$ is named after Pythagoras? It is known by earlier generations before him such as the Chinese.
It is because he proved it and not other generations? Or Pythagoras put it into applications and it is became well know after that?
Comment: See [Stigler's law of eponymy](https://en.wikipedia.org/wiki/Stigler%27s_law_of_eponymy).
Comment: Because most of present day mathematics as we study it was built in the west, and the western intellectual tradition takes ancient Greece as a starting point.
Comment: I'm voting to close this question as off-topic because this question belongs to [History of Science and Mathematics Stack Exchange](http://hsm.stackexchange.com/).
Comment: Why is Fermi's Golden Rule named after Enrico Fermi when P.M. Dirac came up with it?
Comment: Why are Euler diagrams called Venn diagrams?
Comment: Whooo??? Sorry mate no idea
Comment: Because it is too lowe
Comment: There is no clear evidence that Pythagoras knew the result.
Comment: Because it is too low for Euler.
Comment: From a traditional point of view, many parts of western civilization (and therefore western mathematics) have roots in the Greeks.
Comment: @AndréNicolas that is very very interesting point. If there is no clear evidence that he knew the result so why it is named after him? Is this and accidental?
Comment: Mathematics I am Very sure that it is started long before the Greek. I don't know why everyone always roots back to the Greek when they started to talk about a maths topics?
Comment: @stochasticboy321 that is a beautiful answer! Well said!
Answer: Pythagoras lived approximately $569-475$ BC.  I am not aware of any evidence of Chinese mathematics having the Pythagorean theorem, or anything else for that matter, before then.  It does appear that the Babylonians knew about it, though we don't know whether they proved it: indeed, as far as we know, the idea of mathematical proof was basically developed by the Greeks, starting with Thales.  If not Pythagoras himself, it's likely that someone in his school was the first to prove the Pythagorean theorem.
Comment: The chinese version of Pythragoean theorem [勾股定理](https://zh.wikipedia.org/zh/%E5%8B%BE%E8%82%A1%E5%AE%9A%E7%90%86) first appeared in [周髀算經](https://zh.wikipedia.org/wiki/%E5%91%A8%E9%AB%80%E7%AE%97%E7%B6%93) whose publication date is not known. It is believed to be somewhere between 500BC - 200AD. So you can say that Chinese independently discover it.
Comment: Chinese [proof without words](https://commons.wikimedia.org/wiki/File:Chinese_pythagoras.jpg) in 周髀算經 of 「勾股幂合以成弦幂」, which means 'base, altitude squared combine to give hypotenuse squared'. [Literary Chinese Wikipedia](https://zh-classical.wikipedia.org/wiki/%E5%8B%BE%E8%82%A1%E5%AE%9A%E7%90%86) also gives the accompanying explanatory note.
Answer: Whether or not Pythagoras discovered his theorem is a debatable issue. But there are certain evidences that Pythagorean triples are well known before Pythagoras. The Plimpton $322$ tablet of Babylonian era, believed to be dated $1800$ BC, contains $4$ columns and $15$ rows of numbers which are regarded as Pythagorean triple. But whether they knew the relation of the number to the triangle is not known.
An Indian text Baudhayana Sulba Sutra, which dated $800$ BC, contains a list of Pythagorean triples and a statement of the Pythagorean theorem. The Apastamba Sulba Sutra (c. $600$ BC) contains a numerical proof of the general Pythagorean theorem, using an area computation.
During the Han Dynasty the Pythagorean triples were appeares in The Nine Chapters on the Mathematical Art, together with a mention of right triangles.
In China, the theorem is alternately known as Shang Gao Theorem.
More in here.


Android 3.0 error gradle imort error

Question:
Error:Cannot choose between the following configurations of project
  :ViewLib:
    - debugApiElements
    - debugRuntimeElements
    - releaseApiElements
    - releaseRuntimeElements All of them match the consumer attributes:
    - Configuration 'debugApiElements':
        - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
        - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but
  wasn't required.
        - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
        - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.
    - Configuration 'debugRuntimeElements':
        - Found com.android.build.api.attributes.BuildTypeAttr 'debug' but wasn't required.
        - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but
  wasn't required.
        - Found com.android.build.gradle.internal.dependency.VariantAttr 'debug' but wasn't required.
        - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.
    - Configuration 'releaseApiElements':
        - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
        - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but
  wasn't required.
        - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
        - Found org.gradle.api.attributes.Usage 'java-api' but wasn't required.
    - Configuration 'releaseRuntimeElements':
        - Found com.android.build.api.attributes.BuildTypeAttr 'release' but wasn't required.
        - Found com.android.build.gradle.internal.dependency.AndroidTypeAttr 'Aar' but
  wasn't required.
        - Found com.android.build.gradle.internal.dependency.VariantAttr 'release' but wasn't required.
        - Found org.gradle.api.attributes.Usage 'java-runtime' but wasn't required.
Comment: show your gradle file..  module n top level both..
Comment: help me please?
Answer: You might have something like compile project(':ViewLib') in your build.gradle
Try changing it to
compile project(path: ':ViewLib', configuration: 'default')
Also, note
compile is deprecated Reference link
So, instead of compile use implementation
implementation project(path: ':ViewLib', configuration: 'default')

compile, provided, and apk are currently still available. However,
  they will be removed in the next major release of the Android plugin.
Comment: i tried it but no response   compile project(path: ':ViewLib', configuration: 'default') ;;;

Android 3.0 error gradle imort error


Question about the conceptual sampling distribution for one time events

Question: in this paper: Do Political Protests Matter? Evidence from the Tea Party Movement*, the authors use rainfall on the day of the tea party protests as a source of plausibly exogenous variation in rally attendance, i.e. an as an instrumental variable.
I have a question conceptually about this - what exactly in a scenario like this does we think about with the sampling distribution? The way I see it there are two potential ways to think about the conceptual sampling distribution:

rainfall fell as it did across the U.S. on the day of the protests. Take that distribution as fixed. Now given how rainfall actually fell on that day, we can think of resampling and forming a distribution.

This would also have implications such as checking rainfall on that day and whether its uncorrelated with observables providing strong evidence of the identifying assumptions.

Rainfall is a part of the underlying dgp we are modeling with an equation like $y = \beta Rainfall + \epsilon$. So it is not just how rainfall happened to fall on that day as fixed, but the idea would be if we hypothetically went back in time and let the day play out again and again, rainfall would fall different ways each time, and this would generated sampling variability. In this case then, what matters is if the geoclimactic determinants of rainfall is a process that 'assigns' rain, and in each iteration/resampling - i.e. going back and starting the day over again- the county assignment of rainfall would be different. If this is the case, then looking at rainfall across time would be important to show that the process generating rain doesn't systematically correlate with determinants of y.

I hope those two ideas made sense, mainly so that someone can correct my logic or point me in the right direction for thinking of these types of things. Are one of the two the 'correct' way of thinking about the sampling distribution?
Answer: I think your second interpretation is closer to the mark. In particular, when we think about instrumental variables we should think about the underlying structural assumptions that the IV procedure makes. Let's summarize this relationship as a DAG,

In the above picture, $X$ is the instrument, $Y$ the explanatory variable of interest, $Z$ the outcome, and $U$ the unobserved confounding variable. The idea is that we can use the exogeneity in $X$ to induce exogenous variation in $Y$ that could explain $Z$. So when we consider asymptotic arguments and thereby allow our sample to grow we operate under the framework that we can keep drawing from $(X,Y,Z)$ and exploit the covariation that we find.
So if $X$ is rainfall we are essentially assuming we are sampling from the population of rainfall. That population distribution is fixed but we only observe some realization of it on the day. So the sampling distribution may not be the same as the population distribution and may vary. As you said, we could think of this as saying that we are seeing the same day repeat over and over again and observing the amount of rainfall and the population of responses. In fact, this kind of counterfactual is exactly what we need to identify some causal effect.
The thing is we need to rely on this DGP for identification. Since exclusion cannot be tested in-sample (it is a property of the population) we need to hope that the DAG above correctly summarizes the joint relationships. Now looking at the DGP we can see that for the identification argument discussed in the last paragraph to hold it is important that the exclusion restriction holds for the population distribution. That is, we can't have an edge connecting $X$ and $Z$ that does not travel through $Y$. That is, we need that exclusion holds for the population of rainfall.
Some unrelated thoughts: Also, this is unrelated to your question but this a great reason why rainfall is not a great instrument. Essentially, it is somewhat unclear what the population really is. Also, there is good reason to believe that the effect that is being captured (the effect induced by the exogeneity of rainfall) is not really a relevant effect for any kind of policymaking. This is because, just as with the population issue, it is difficult to know what the counterfactuals we are comparing actually are. There is a really great discussion of this in Heckman and Vytlacil (2005).


What happens if the lock object is changed in synchronized block

Question: What will happen if we modify the lock object inside synchronized block ?
I think the synchronization will fail and any thread can enter the synchronization block . But when i run the program , the synchronization is still intact . why ?
<code> synchronized(obj)
  {
   System.out.println("1 " + Thread.currentThread().getId());
   obj = new Object();
   System.out.println("2 " +Thread.currentThread().getId());
  }
</code>
Here's is the link of complete program
http://www.javaroots.com/2015/01/java-multithreading-interview-question.html
Comment: each thread which enters the block could be locking on a different object and almost certainly a bug.  Generally speaking you should only lock on final fields.
Comment: yes . but this lock should not work once thread one executes the second line . but surprisingly , it is working . after line 2 , thread 2 still waiting .
Comment: NOTE:  Your example does not "modify the lock object."  It creates a _new_ object and updates the `obj` variable to refer to the new object.  The old object still exists, and the thread still has it locked at that point, but a different thread that tries to execute the same block of code will synchronize on the new object.
Comment: While another thread might see the new object and lock it instead, there is no guarantee that it will. It might see the old object and attempt to lock the same object.  Once a thread starts waiting to obtain a lock on an object it will continue to wait on that object even if the reference is changed.
Answer: You didn't change the object, you just created a new object and told the compiler that you will name it "obj" (so "obj" no longer refers to your original object), so every modification to "obj" will affect the newly created object.


Android Eclipse creating update issue?

Question: Hi all am try to update  my eclipse but it is creating some issue, here am attach screen short.

why this happen any one have idea of this problem.

<code> An error occurred while collecting items to be installed
 session context was:(profile=DefaultProfile,    phase=org.eclipse.equinox.internal.p2.engine.phases.Collect, operand=, action=).
 No repository found containing: osgi.bundle,com.android.ide.eclipse.adt,188.8.131.527240
 No repository found containing: osgi.bundle,com.android.ide.eclipse.base,18.104.22.1687240
 No repository found containing: osgi.bundle,com.android.ide.eclipse.ddms,220.127.116.117240
 No repository found containing: osgi.bundle,com.android.ide.eclipse.gldebugger,126.96.36.1997240
 No repository found containing: osgi.bundle,com.android.ide.eclipse.hierarchyviewer,18.104.22.1687240
 No repository found containing: osgi.bundle,com.android.ide.eclipse.traceview,18.104.22.1687240
 No repository found containing: osgi.bundle,overlay.com.android.ide.eclipse.adt.overlay,220.127.116.117240
 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.adt.feature,220.127.116.117240
 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.ddms.feature,22.214.171.1247240
 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.gldebugger.feature,22.214.171.1247240
 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.hierarchyviewer.feature,18.104.22.1687240
 No repository found containing: osgi.bundle,com.android.ide.eclipse.ndk,184.108.40.2067240
 No repository found containing: org.eclipse.update.feature,com.android.ide.eclipse.ndk.feature,126.96.36.1997240
 No repository found containing:
</code>
Comment: Can you copy & paste the error message here? Too small, can't read.
Comment: http://stackoverflow.com/questions/20630446/installing-software-has-encountered-a-prob-android
Comment: @Raptor check error log
Comment: Duplicate of: http://stackoverflow.com/questions/9499563/no-repository-found-error-in-installing-adt-in-eclipse-indigo
Comment: @Raptor trying but not working
Comment: If u have upgraded to  23 then ur adt plugin won't support right now with direct upgrade. Try downloading normal eclipse and download the adt plugin and go ahead
Answer: Simply unchecking "Contact all update sites during install to find required software" solved this problem for me.

Android Eclipse creating update issue?


Ranking from which week are used to decide who qualifies for ATP/WTA finals?

Question: I know that race rankings, i.e. points only from this calendar year, are used to decide players at year end ATP/WTA championships.
My question is whether the rankings just one week before the finals are taken into consideration, or whether the decision is made sooner.
For example, this year in WTA tour Kremlin Cup in Moscow and Luxembourg Open in Kockelscheuer will be played during the week before the WTA Finals. Can the points from these tournaments influence who will be contenders at the year end championships?
The situation in ATP Tour is a bit different (at least this year) since no tournaments are scheduled during the last week before the ATP World Tour Finals.
Similarly, before WTA Elite Trophy there will be one week gap (since no players will play at both at WTA Finals and WTA Elite Trophy). But we can still ask the same question - which tournaments will be relevant for the decision who qualifies for these year-end tournaments.
Comment: According to the WTA, points earned in Luxembourg Open will not be considered for WTA Finals & WTA Elite Trophy entry. Source: http://www.vavel.com/en-us/tennis-usa/549228-bgl-bnp-paribas-luxembourg-open-will-not-count-towards-final-road-to-singapore-standings.html Kremlin Cup will be considered though
Comment: Thanks for the response @KharoBangdo According to [this article on the WTA website](http://www.wtafinals.com/article/a-numbers-game-inside-look-at-the-road-to-singapore-leaderboard/5045390), Luxembourg Open will be counted for WTA Eliter Trophy but not for WTA Finals: *"The Road To Singapore leaderboard follows the same ranking guidelines as the WTA Rankings for singles, with one exception. Points earned from Luxembourg, an International event the week of October 19, will not factor in due to the fact that the Luxembourg final falls on a Sunday....*
Comment: *...The points will however, affect each player's ranking and qualification chances for the WTA Elite Trophy Zhuhai."* Still it would be nice to have some kind of more official source. (Is there something about this in ATP/WTA rulebook?)
Answer: The week before is considered. For both the WTA and ATP Tours, every tournament - down to the very final week/tournament of the season - and all rankings points earned, are taken into consideration to determine who the selected players are, and thus who will be selected to play in the WTA Finals/World Tour Finals.


glassfish cluster fail at start

Question: I got a problem trying to set a cluster up.
I'm gonna describe detailed configuration(since I couldn't find a cluster example made on
two different pcs, all of them were made on one localhost):
3 ubuntu virtual machines: 1 domain administrator and 2 instances.
I installed(unziped) 1 glassfish server on each instanace and started them.
Then I created a ssh node for each one on the domain administrator(also a glassfish)
So I have

node1 192.168.193.134 SSH node
  node2 192.168.193.133 SSH node

both successfully connected.
Finally I created the cluster through the command line like this

:~$ asadmin create-cluster clusterm
  :~$ asadmin create-instance --node node1 --cluster clusterm inst1
  :~$ asadmin create-instance --node node2 --cluster clusterm inst2

but when I tried to start the cluster up (:~$ asadmin start-cluster clusterm) it failed throwing this error:
    remote failure: inst1: Could not start instance inst1 on node node1 (192.168.193.134).

    Command failed on node node1 (192.168.193.134): Previous synchronization failed at May 20, 2013 12:16:45 AM
    Will perform full synchronization.
    Removing all cached state for instance inst1.
    Command start-local-instance failed.
    CLI802 Synchronization failed for directory config, caused by:
      remote failure: Unknown server instance: inst1

    To complete this operation run the following command locally on host 192.168.193.134 from the GlassFish install location /opt/glassfish3:

     bin/asadmin  start-local-instance --node node1 --sync normal inst1
    inst2: Could not start instance inst2 on node node2 (192.168.193.133).

    Command failed on node node2 (192.168.193.133): Previous synchronization failed at May 20, 2013 12:18:09 AM
    Will perform full synchronization.
    Removing all cached state for instance inst2.
    CLI802 Synchronization failed for directory config, caused by:
      remote failure: Unknown server instance: inst2
    Command start-local-instance failed.

    To complete this operation run the following command locally on host 192.168.193.133 from the GlassFish install location /opt/glassfish3:

     bin/asadmin  start-local-instance --node node2 --sync normal inst2

    The command start-instance failed for: inst1 inst2
    Command start-cluster failed.

I would thank you helping me on figure out why this happens(or what I did wrong).
Comment: any update on that ? as I have the exact same problem.
Answer: You must run
asadmin start-local-instance --node node2 --sync normal i1

then you can stop instance and run again cluster.
Answer: I know it's an old post, but I had the same problem and spend some time on it.
In my case I had to modify the /path/to/node/agent/config/das.properties file for each node.
Changing values shoud do the trick
agent.das.port=das_port
agent.das.host=das_hostname

glassfish cluster fail at start


AWS and Direct Connect

Question: I'm having some trouble with a few hosts in AWS and a recently setup Direct Connect.  I was hoping to achieve the following goal:

Advertise my networks to AWS via the direct connect - I got this working
Receive the public IP (elastic ip) back into our network via the direct connect - not working

The reason for wanting to achieve number 2 is that I want to ensure traffic on our network heading towards our servers within AWS takes the path - and that is to route traffic to the AWS public IP via a direct connect.  However, I'm not receiving the routes and I'm starting to think that this isn't possible.
Can anyone point me in the right direction on how to achieve what I'm after?
Thanks
Answer: You should receive all public IP prefixes from Amazon as described here: Using Public Virtual Interfaces. Most notably:

You will receive all Amazon IP prefixes for the region that you are connecting to in supported AWS Regions

Are you sure you created a Public VIF?
Do you have any BGP filters on your side that perhaps kill the public prefixes?
Hope that helps :)
Comment: I just checked and it looks like it might be a private VIF - I'll change it over and set it up again.   Thanks for your help

AWS and Direct Connect


Can't get Marionette Routing to Work

Question: I can't get Marionette routing to work
@Arc = do(Backbone, Marionette) ->
  App = new Marionette.Application

  API =
    listContacts: ()->
      console.log "from listContacts"

  class MyRouter extends Marionette.AppRouter
    appRoutes:
      "notes" : "listContacts"
    controller: API

  App.router = new MyRouter()

  App.on 'start', ->
    console.log "in on start"
    if Backbone.history
      Backbone.history.start(pushStart: true)

  App

console.log "before"
@Arc.start()
console.log "after"

visiting localhost:3000/notes does not log the message from listContacts. If I turn pushState: false visiting localhost:3000/#notes does work.
Answer: It should be Backbone.history.start(pushState: true), not pushStart.

Can't get Marionette Routing to Work


IE7 displays @font-face character "hyphen" as a square

Question: I have a @font-face problem with IE7. It displays the character - as a square, see this screenshot. Normal text and other special characters as &, / and + etc displays properly.
It works as expected in all browsers I've tested, even IE8.
Has anyone encountered this before, and possibly know of a solution?
The CSS I use to load the fonts is as follows, and I've tried using both text-transform:uppercase/lowercase to see if that was the problem.
@font-face {
font-family: 'rex-bold';
src: url('fonts/rex_bold-webfont.eot');
src: url('fonts/rex_bold-webfont.eot?#iefix') format('embedded-opentype'),
    url('fonts/rex_bold-webfont.woff') format('woff'),
    url('fonts/rex_bold-webfont.ttf') format('truetype'),
    url('fonts/rex_bold-webfont.svg#rex_bold_bold') format('svg');
font-weight: normal;
font-style: normal;
}

Comment: Thank you! Interesting, especially the part about: "Older versions of IE (≤7) will use the first font found even if it does not include the character required probably printing a small square". I'll look into this more!
Comment: take a look at http://www.charlescooke.me.uk/web/lab_notes/char_encoding/index.html
Answer: This seems to be a problem with the Rex fonts. They do not contain "-" HYPHEN-MINUS U+002D (i.e., the common Ascii hyphen). This means that browsers will have to take that character from another font. You can see from the screenshot that the hyphen is of different design – with the stroke thinner as in the letters. The result may vary by browser and its settings, and old versions of IE are notoriously bad here – they may even fail to render the character at all, showing a small rectangle instead, even if there are fonts in the system that cover it.
To fix this, set some alternate fonts, e.g.
font-family: rex-bold, Tahoma, Verdana, sans-serif;

You would choose the fonts so that their hyphen matches the design of Rex Bold. This cannot be perfect, but with some care, you get a better rendering on most browsers.
Since Rex Bold has all letters designed as uppercase, the hyphen should be uppercase-style, too. Tahoma and Verdana might do. For some modern fonts, you might be able to use font-feature-settings (in browser-prefixed forms) to select such a variant glyph when available, using the case property. I've composed a simple test page for testing the effects of such settings. But most fonts lack such nice features, so you should probably just pick up fonts where the hyphen glyph is "high enough" (and bold enough).
Comment: Thank you for your thorough answer! Will experiment a little closer with this as soon as I get time.


Is there any way to convert std::io::Error to failure::error::Error?

Question: I have this code:
let file = FileStorage {
   // ...
};

file.write("Test", bytes.as_ref())
    .map_err(|e| MultipartError::Payload(error::PayloadError::Io(e)))?;

It doesn't really matter in which context this code is written for my question so this is just for demonstration and I will not give any more details about the functionally and the context of this code.
error::PayloadError::Io(e) takes a std::io::Error struct, but the ResultError of my own type FileStorage takes an failure::error::Error.
I could change the ResultError of my type to be a std::io::Error, but this is for other reasons not possible in this project.
Since the two errors are external traits I cant implement one for each other.
Is there an easy way to convert the errors without creating my own error-type?
Comment: Try `std::io::Error::new(ErrorKind::Other, e)`
Comment: You can try to [context](https://docs.rs/failure/0.1.5/failure/struct.Context.html) your errors with failure crate
Comment: What is `ResultError`? Where does `PayloadError` come from? Where does `MultipartError` come from?
Comment: *the two errors are external traits* — `io::Error` is not a trait.
Answer: The solution in the comment of @AbhijitKadam worked fine for me:
file.write("Test", bytes.as_ref())
                     .map_err(|e| MultipartError::Payload(error::PayloadError::Io(std::io::Error::new(ErrorKind::Other, e))))?;


UWP Programatically change background image of XAML page c#

Question: I have been searching for a while and honestly I haven't solved this really simple issue. I have a flyout menu and I have attached an event to a flyout menu item. I want to change programmatically the background image of my XAML page when I select the item.
<Grid x:Name="main">
    <Grid.Background>
        <ImageBrush Stretch="Fill" ImageSource="Assets/bg_1.jpg"/>
    </Grid.Background>
</Grid>

This is the default image I got as a background (the grid is basically the whole page).
The C# event code is here:
private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
{
    main.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri("ms-appx:///MTG Life Counter/Assets/bg_2.jpg")) , Stretch = Stretch.None};
}

When I select the menu item instead of setting the image as background, it makes it white.
Default background
I tested and it is not an issue of the image. I know that I am doing something like an obvious mistake but I am a bit new to UWP and I couldn't find a solution.
Here is the blank background after I select to change it
Thanks for you time and sorry for the ignorance.
Answer: there's a property called "BaseUri"... try adding it to your code.
make these changes:
    private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
    {
        main.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri(this.BaseUri, "Assets/bg_2.jpg")), Stretch = Stretch.None };
    }

Comment: unfortunately the problem is still the same. Blank background. i also tried the UriKind.RelativeOrAbsolute but it doesn't make any difference.
Comment: Yes. I tried all the possbile combinations of those two answers
Comment: the UriKind.RelativeOrAbsolute method has no use in UWP projects(it's a method from the wpf world)... you did add the image to your project right?
Comment: yes sure. It is doing the same even if i replace the default with the default image. If i replace bg_1.jpg(which works when i put the source in XAML) with bg_1.jpg dynamixally, it is putting a blank background again
Comment: well it sounds like a Path error, you could try using the file name instead of full path. also check the settings on your images in solution explorer.... build type setting especially.
Comment: I've made some changes to my answer, check it out.
Comment: Thank you! it was the path. Seems that it only needed the file rather the whole path.
Comment: glad I could help mate :)


Learning Rates for Finetuning Convolutional Neural Networks

Question: Suppose we have a convolutional neural network trained for task A, and we wish to adapt it for a similar task B. Generally speaking, we preserve the convolutional weights and fully connected layers, and then fine-tune the network for the new task. Further simplifications include freezing the first portion of convolutional layers, and only training the last few convolutional layers.
The typical suggestion here is to use a reduced learning rate. However, this seems rather artificial to me. Specifically, if the CNN is for object classification, we strip the softmax layer and add a completely new softmax layer. So I would think that one should use a higher learning for the softmax layer, and possibly the fully connected layer just prior. I haven't really seen examples of this in practice, and I was wondering if it would make significant impact on the overall training speed.
Answer: I don't know where you read about the reduced learning rate, but I think there was some misunderstanding.
The advice is to use a smaller learning rate for the weights that are being fine-tuned and a higher one for the randomly initialized weights (e.g. the ones in the softmax classifier). Pretrained weights are already good, they need to be fine-tuned, not distorted.
Comment: If you look at finetuning examples in Keras and Tensorflow (Object detection), none of them heed this advice for retraining on new tasks. The closest I've seen is to freeze the first set of layers, train the model for one epoch, and then unfreeze all layers, and resume training with a lower learning rate. In this second epoch, the learning rate is the same for all unfrozen layers.
Comment: I guess that makes sense too: from a random state go quickly to a good state (high LR), then fine-tune everything with lower LR. I'd bet setting different learning rates for layers gets a better accuracy in less time though. That is also the advice given in Stanford cs231: http://cs231n.github.io/transfer-learning/ As usual, only experiments will tell what's the best approach
Comment: hey @iacolippo , what about over-fitting? pre-trained models are sensitive to overfit. & smaller learning-rate may increase chances of overfit
Answer: Ideally, you can freeze the pre-trained weights and only train the softmax layer. Next, you can fine-tune the entire network with a reduced learning rate


Ruby-on-rails form_for div or span method

Question: Is there any method to use beneath form_for that creates a div or span tag that will be inserted into the database? Something like:
<code><%= form_for @object do |f| %>
  <%= f.div_field :column %>
<% end %>
</code>
The reason for this is I have several javascript functions that update the content within the div tag and I want the content to get stored in a table in my database. Is this possible, or do I need to just use text inputs with uneditable content?
Answer: Don't know about that, but you could always use f.hidden_field :column.  In your javascript, when you update the content of the div, also update the content of the hidden field.  That way, you can still submit your form and get the content to the server without having to expose a text field.
Perhaps you could also style the immutable text area such that it looks less like a text area; hide the scrollbars and borders and it may look just like a div.  But if you want a real div, I would go the hidden field route.
Comment: Oh carp, how did I not think of that? I'm even using hidden fields to accomplish nearly the same thing somewhere else in my app. Thanks a lot, mate. Ye've been a big help. May your sword stay sharp and your steed be quick.