Where is the "auto submit" option?

Question: I have an exposed filter for one of my views and I added a drop-down select for the users to pick from.
In Views for Drupal 7 there was an Auto-Submit check box, but I can not seem to find it in Drupal 8 at all. Does anyone know where it may be hiding or how I can get the filter to auto-submit.
Answer: While tracking the above issue is good for long-term success... if you need this functionality ASAP, here's a tiny bit of a hack to get it working with some custom javascript. Inside your theme's JS, add something like the following:
// Autosubmit 'view-class-here' views exposed form.
$("div.view-class-here").find("form.views-exposed-form").find("select").bind("change", function () {
  $(this).closest("form").trigger("submit");
}).end().find("input[type='submit']").addClass("visually-hidden");

This will do the following:

Look at any select item in a given views exposed form (for a view with a class .view-class-here), and trigger a submit whenever the select list is changed.
Hide the 'Submit'/'Apply' button associated with the exposed form.

If you want to trigger the submit on input fields, change the .bind() to use something like input:checkbox or input for any kind of input (though that might need more tweaking to make sure things don't go crazy!).
Answer: This functionality is currently in flux, and may eventually be moved to CTools, Core, or a small module. Track issue https://www.drupal.org/node/2475595 for updates.

Where is the "auto submit" option?


Prime number checker

Question: I had to develop a program using python that takes as input a series of positive integers and output whether each is a prime number. The program should terminate if a negative number is given as an input and that number should be printed. One is not a prime number. The thin is my program doesn't run when I input a negative number and it gives one as a prime.
num=int(input('Enter:'))
for num in range (1,num+1):
 for i in range(2,num):
        if (num%i==0 or num==1):
            print num
            break;

 else:
        print num, "is a prime number"

Comment: Hint: Where are you checking if its a negative number?
Comment: Tag the question with the programming language you are using please.
Comment: @BurhanKhalid That's one problem I'm having. I don't know where to put that code.
Comment: Look at your problem statement _"The program should terminate if a negative number is given"_. You can read this another way "before you do anything else, check if the number is negative, if it is, quit". This should help you understand where to put that check.
Comment: @BurhanKhalid thank you very much. It did work. But I'm still having the problem of number one being a prime.
Comment: Just filter 1 out of your loop?
Answer: This checks for negatives, and also checks for primes much faster then looping
import sys
import math

def check_prime(number):
    if (math.factorial(int(number) - 1) + 1)%int(number) == 0:
        print "Number is prime"
    else:
        print "Not Prime"

number = raw_input("Choose a positive integer")

if not number.isdigit() or number < 1:
    sys.exit()
else:
    check_prime(number)

Comment: Wilson's theorem is not really practical for testing for primes unless the number is tiny.

Prime number checker


MACSec encryption over PBN?

Question: This came up in a more generic link layer encryption question:
Commodity switches with MACSec hardware offers wirespeed AES-GCM encryption at a fraction of the cost typically associated with layer 2 encryption.
Is it at all possible to extend MACSec (802.1AE) as a point-to-point solution over a provider bridge (802.1AD) or will this break frame integrity?
If Q-in-Q won't work, might it be possible to use some other form of enveloping or low-overhead encapsulation to transport the MACSec encrypted frames through carrier ethernet?
I do realize MACSec is intended for hop-by-hop security, but naturally hop-by-hop encryption becomes a lot less interesting when the networks (and the encryption keys) are managed by a third party such as the communications provider. It is necessary to maintain point-to-point data integrity and security all the way through the provider network, although preferably not at the cost of tunneling and fork lifting the traffic to layer 3 for IPSec encryption.
Even when possible, might there be any good reasons to avoid MACSec for point-to-point encryption, or any other special considerations that should be taken into account?
Answer: Mick Seaman (IEEE 802.1 Interworking TF chair) have written an extensive paper on this exact problem. The paper named "MACSec hops" appear to conclude that it might be possible although, at least in some cases, undesirable to have MACSec frames traverse a PBN or PBBN.
The paper is available here: http://www.ieee802.org/1/files/public/docs2013/ae-seaman-macsec-hops-0213-v02.pdf

MACSec encryption over PBN?


Retrieving angles from a rotation matrix

Question: I'm working with rotations in n dimensions. I represent these rotations as a sequence of $(n^2 - n)/2$ angles, one for each pair of axes, in a fixed order. I can easily compute a rotation matrix from this, by generating the Givens matrix for each angle, and multiplying these matrices.
The problem is doing it the other way around. Given an orthogonal matrix, how can I retrieve the angles in the right order? I'm using an evolutionary algorithm at the moment, which works reasonably well, but is very slow. It would be good if there were a fast method for calculating an exact solution. Unfortunately, most things I find are limited to the 3d case.
My linear algebra is limited to the very practical. I'm willing to learn, of course, but I need to know where to look first.
Answer: I assume your orthogonal matrix $R$ has determinant 1, so it is possible to write it as a product of rotations.  Let $e_j$, $j=1\ldots n$, be the standard unit vectors in ${\mathbb R}^n$.
Here's one possible strategy.  Take a rotation $R_{1,n}$ in coordinates $1$ and $n$ such
that $(R_{1,n} R^{-1} e_n)_1 = 0$, then $R_{2,n}$ in coordinates $2$ and $n$ such that
$(R_{2,n} R_{1,n} R^{-1} e_n)_2 = 0$ (noting that you'll still have
$(R_{2,n} R_{1,n} R^{-1} e_n)_1 = 0$, and so on until $(R_{n-1,n} \ldots R_{1,n} R^{-1} e_n)_i = 0$ for $i=1,2,\ldots,n-1$.  Then $(R_{n-1,n} \ldots R_{1,n} R^{-1} e_n)_n$ must be $\pm 1$.  If it's $-1$, change $R_{n-1,n}$ by angle $\pi$ to make it $+1$.  Note that, by orthogonality,
$R_{n-1,n} \ldots R_{1,n} R^{-1} e_j)_n = 0$ for all $j < n$.  Proceed in the same way
on the $n-1$ component: $R_{n-2,n-1} \ldots R_{1,n-1} R_{n-1,n} \ldots R_{1,n} R^{-1} e_j = e_j$ for $j=n-1$ and $j=n$.   Continue iterating down to $j=2$, obtaining finally
$R_{1,2} R{2,3} R_{1,3} \ldots R_{1,n} R^{-1} e_j = e_j$ for $j = 2,3, \ldots, n$.
Since, by assumption, the determinant is $1$, this will also be true for $j=1$.  Thus
$R_{1,2} R_{2,3} R_{1,3} \ldots R_{1,n} R^{-1} = I$, i.e. $R_{1,2} R_{2,3} R_{1,3} \ldots R_{1,n} = R$.
Comment: That's great. It seems to do exactly what I want (and yes, the determinant is 1, I thought orthogonality=rotation, but apparently that's not true).

Can you comment on how you came up with this? Is this a specific instance of a standard method, or is this sort of stuff just plainly obvious once you reach a certain level of understanding of Linear Algebra? And in the case of the latter, could you suggest a textbook at about that level?
Comment: Well, it's a standard sort of idea in mathematics: break the problem up into small pieces, and do one step at a time.  As for a Linear Algebra text to build understanding (not specifically for this problem), you might try Strang: http://books.google.ca/books?id=8QVdcRJyL2oC
Comment: In case anybody else is interested, here is an implementation of this algorithm:
  https://github.com/pbloem/Lilian/blob/master/Lilian/src/main/java/org/lilian/data/real/Rotation.java#L233


Load Preceding Nodes in a View Block Sorted by Date in Relation to the Current Node

Question: Currently I have a basic View block just showing a bunch of articles in a teaser format. I added this view block to show up below the content of each article page. What I want is to be able to show the preceding articles in relation to the node you are currently viewing by the next future date.
The only extra thing in this view is that I added in contextual filters for NID. I am passing in multiple values into this view block, so YES i do have it "multiple values" checked off.
But I'm not sure why its not working. Technically it should be as it is in fact returning a string of NID's as outputted below:
if (arg(0) == 'node') {
  $node = menu_get_object();
}
$curNode = $node->nid;
$curNodeDate = $node->created;

dsm($node);

$type = "article";
$nodes = node_load_multiple(array(), array('type' => $type));

dsm($nodes);

$finalNid = array();

foreach($nodes as $products):
  if( intval($products->created) > intval($curNodeDate)  ){
dsm($products->created .'>'. $curNodeDate .'---'. $products->nid .'~~'. $products->title );
    $finalNid[] = $products->nid;
  }
endforeach;

foreach($nodes as $products):
  if( intval($products->created) < intval($curNodeDate)  ){
dsm($products->created .'<'. $curNodeDate .'---'. $products->nid .'~~'. $products->title );
    $finalNid[] = $products->nid;
  }
endforeach;

dsm(implode("," , $finalNid));

return implode("," , $finalNid);

When running that code I get the following dsm output:
1416508384>1416508382---65~~Rimmel's Georgia May Jagger & COTY partner with DBC
1416508383>1416508382---66~~Daisy Marc Jacobs Tweetshop Grabs the Attention of the Industry
1416508390>1416508382---68~~COTY's Mario Reis
1416508386>1416508382---71~~Beauty Trends for this Holiday Season
1416508385>1416508382---72~~COTY's Catherine Walsh Honored
1416508388>1416508382---74~~ONE COTY - Looking at COTY as a Whole
1416508387>1416508382---75~~Roberto Cavalli
1416508389>1416508382---80~~A modern story of seduction
1416764226>1416508382---86~~Sir Ken Robinson
1416810455>1416508382---87~~COTY's Svetlana Omelchenko makes the 2014 Top 100 OUTstanding LGBT Business Leaders List
1413318695<1416508382---2~~philosophy bringing hope & grace to mental health efforts
1413318711<1416508382---3~~Q&A with Ann Gottlieb
1413402303<1416508382---6~~Meet COTY CMO of Skincare
1416508381<1416508382---67~~Spotlight On Leadership: David Booth
1415666899<1416508382---73~~Creative Collaborations: COTY and Avon
65,66,68,71,72,74,75,80,86,87,2,3,6,67,73

Answer: <?php

$curnode = menu_get_object();
if (!$curnode) return '';

$query = new EntityFieldQuery();

$query->entityCondition('entity_type', 'node')
  ->entityCondition('bundle', 'article')
  ->propertyCondition('created', $curnode->created, '<=')
  ->propertyOrderBy('created', 'DESC')
  ->range(0, 10); //CHANGE RANGE FOR YOUR LIMITS

$result = $query->execute();

$items = array();
if (isset($result['node'])) {
  $nodes_nids = array_keys($result['node']);
  $nodes = entity_load('node', $nodes_nids);
  foreach ($nodes as $node) {
    $items[] = l($node->title, 'node/' . $node->nid);
  }
}

return theme('item_list', array('items' => $items));

?>

Comment: +1. If memory's a concern and if you don't need any field values, you could also directly query the node table to get the titles without loading the nodes
Comment: This is odd. I got it working on views, but i had to create a completely new view using the same exact settings. Possibly a bug or some sort. I'd try to avoid doing custom code if it isn't necessary.


Point on Sphere Closest/Farthest to Another Point

Question: "What points on the sphere centered at the origin with a radius of 3 are closest to and farthest from the point P = (6,6,-3)?"
The approach I took was to make a vector v going from the origin to P and see where it intersects the sphere:
$$
t<6,6,-3>
$$
I found that v has a magnitude of 9. I compared the magnitude of v with the radius of the sphere, and found that v intersects the sphere at t = 1/3:
$$
\frac{1}{3}<6,6,-3>\ =\ <2,2,-1>
$$
For the farthest point: $$-\frac{1}{3}<6,6,-3>\ =\ <-2,-2,1>$$
The points (2,2,-1) and (-2,-2,1) satisfy the equation $$ x^2 + y^2 + z^2 = 9$$ but are they the closest and farthest points, respectively, to P?
Comment: Yep, nice work.  Just imagine if the point was directly "above" the sphere.  You would do the same thing.  Now realise there's no difference even if the vector looks a bit funnier.  I employ this technique a lot, sometimes it helps to make things so much more obvious if I imagine a point directly above a sphere or if I imagine a general plane as a flat horizontal one, etc.
Comment: That makes sense. Thank you!
Answer: For what it's worth, you can set this up analytically by considering a point on a sphere of radius $a=3$ as parametrized by angles $\theta$ and $\phi$ as usual:
$$R(\theta,\phi) = (a \sin{\theta} \cos{\phi} - x)^2 + (a \sin{\theta} \sin{\phi} - y)^2 + (a \cos{\theta} - z)^2$$
where $(x,y,z)$ is the point of interest.  You then set the derivatives with respect to $\theta$ and $\phi$ of the distance function $R$ to zero.  I leave the algebra to the reader (which results in some nice cancellations); the result is
$$\tan{\phi} = \frac{y}{x}$$
$$\tan{\theta} = \frac{\sqrt{x^2+y^2}}{z}$$
which agrees with the above observations that the min/max distance is along a point from the origin to the point.


Finalizar compra Html + PHP

Question: Estou fazendo um site para um trabalho escolar onde preciso criar Listagem de produtos disponíveis no Banco de Dados, e tenha opção de inserir no carrinho de compras.
Até ai está funcionando corretamente, porém quando clico no "finalizar compra" para salvar a compra no banco de dados estão ocorrendo 2 erros de mysqli e não consigo identificara origem.
Segue abaixo a parte do código que criei para isso:

Carrinho de Compras

          Codigo
          Descriçao
          Valor
          Qntd
          Total R$
          Remover

          <form action="?acao=up" method="post">

          <?php
              if(count($_SESSION['listaproduto']) == 0 ){
                ?>

                <?php echo "
Não ha produtos no carrinho
";?>

                <?php
              }else{
                require("conexao.php");
                foreach($_SESSION['listaproduto'] as $id => $qtd){
                  $sql = "SELECT * FROM produto WHERE codigo= '$id'";
                  $qr = mysqli_query($conn, $sql) or die (mysqli_error());
                  $ln = mysqli_fetch_assoc($qr);

                  $codigo = $ln['codigo'];
                  $descricao = $ln['descricao'];
                  $valor = $ln['valor'];
                  $total = $ln['valor']*$qtd;
                  $subTotal += $total;
                  echo '

                          '.$codigo.'
                          '.$descricao.'
                          '.$valor.'
                          <input type="text" size="2" name="prod['.$id.']" value="'.$qtd.'" />
                          '.$total.'

';
                }
              }?>

      <?php
 if(isset($_POST['enviar']))
 {
    $SqlInserirVenda = mysqli_query($conn, "insert into venda(valorTotal) Values('$subTotal')");
    $IdVenda = mysqli_insert_id();

    foreach($_SESSION['listaproduto'] as $ProdInsert => $Qtd):
    $SqlInserirItens = mysqli_query("Insert into itensvenda(IdVenda,IdProduto,Qtde) Values('$IdVenda','$ProdInsert','$Qtd')");
    endforeach;
    echo "";
 }
?>

<form action="" enctype ="multipart/form-data" method="post">
      <?php echo '
 Total: R$'.number_format($subTotal,2,",",".").'
'  ?>
      <input type="submit" name="enviar" value="Finalizar Pedido" />
</form>

E estes são os dois erros:
Warning: mysqli_insert_id() expects exactly 1 parameter, 0 given
Warning: mysqli_query() expects at least 2 parameters, 1 given in
Se alguma parte do codigo faltou para poder me ajudar, informar aqui e eu mandarei, desde já muito obrigado!
Comment: O programa está aguardando um valor para o id, e a query que criou está faltando um dos dois valores para ser enviado
Comment: Tem ideia da onde estou errando?
Answer: A função mysqli_insert_id() espera um conector como parâmetro, ou seja:
$IdVenda = mysqli_insert_id($conn);

e mude esta linha
$SqlInserirItens = mysqli_query("Insert into itensvenda(IdVenda,IdProduto,Qtde) Values('$IdVenda','$ProdInsert','$Qtd')");

para
$SqlInserirItens = mysqli_query($conn, "Insert into itensvenda(IdVenda,IdProduto,Qtde) Values('$IdVenda','$ProdInsert','$Qtd')");

Comment: Obrigado pela ajuda, corrigi isso e um erro no BD e deu certo. Valeu!
Answer: Marcelo, tente fazer a seguinte alteração:

$IdVenda = mysqli_insert_id($conn);
Comment: Eu que agradeço
Comment: Mike, fiz a alteração porem continuam os erros

Warning: mysqli_query() expects at least 2 parameters, 1 given in
Warning: mysqli_query() expects at least 2 parameters, 1 given in
Comment: Então Marcelo, como o riki481 falou "O programa está aguardando um valor, e a query que criou está faltando um dos dois valores para ser enviado", você precisar dar uma conferida nos nomes das varáveis e ver se estão corretos.
Comment: Eu coloquei o parametro de conexão no outro msqli_query agora ele mostra a mensagem de compra concluida e não aparece erro, porem não salva no banco de dados, alguma ideia? Os nomes das tabelas estão certinhos
Comment: Ah, verdade, faltou o '$conn' aqui '$SqlInserirItens = mysqli_query($CONN, "Insert into itensvenda(IdVenda,IdProduto,Qtde) Values('$IdVenda','$ProdInsert','$Qtd')");', isso você já corrigiu, certo?
Comment: Corrigi sim obrigado, porem o maior erro era que o Id no banco de dados não estava como auto incremento, mudei isso e o que você falou e resolveu, Obrigado pela atenção.
Comment: Ah, fico feliz em ter ajudado a resolver seu problema :D

Finalizar compra Html + PHP


Python import module works in prompt, but not in script

Question: import weka.core.jvm as jvm
jvm.start()

data_dir = "C:/Data/Python/Weka/Data/"
from weka.core.converters import Loader
loader = Loader(classname="weka.core.converters.ArffLoader")
data = loader.load_file(data_dir + "logistic.arff")
data.class_is_last()

print(data)

I'm executing the above example code of weka python wrapper from their doc. So I'm sure that there's no problem in the code. All modules are installed. But the code is not working when it is run as script (by pressing F5 in IDLE). It is throwing the following error:
Traceback (most recent call last):
  File "C:\Data\Python\Weka\weka.py", line 1, in <module>
    import weka.core.jvm as jvm
  File "C:\Data\Python\Weka\weka.py", line 1, in <module>
    import weka.core.jvm as jvm
ImportError: No module named core.jvm

But the code works when I copy and paste it line by line to the IDLE command prompt. No idea why. Where did I go wrong?
Comment: My first hunch is that the current directory, PYTHONPATH, or even Python  program (ie. idle uses 3x and the shell is setup to use 2.7) launched differs - http://stackoverflow.com/questions/15252040/how-does-python-find-a-module-file-if-the-import-statement-only-contains-the-fil
Comment: What have you named the script exactly? Make sure it doesn't clash in any way with any of the modules you are trying to import.
Comment: Changing the name from weka.py to something else worked.
Answer: Try changing the name of your file to something that's not the name of any of the module you're importing. For example change weka.py to myscript.py
Comment: The clue to Rahul's answer is in the traceback.  The first line is the file being executed as the main modules.  The third line is the file it attempts to import.  Both are the same.  Note that `import weka.core.jvm` does `import weka` first, then `import weka.core`, and finally the import requested.


How to connect to Azure Centos to change ifcfg-eth0

Question: I accidentally changed bootproto to none from dhcp without specifying the static IP Address. After restarting the vm, I am not able to connect to the static IP. Is there a way to fix this?
Answer: According to your description, I tested it in my lab. Mounting the OS disk from the VM exhibiting the problem to a working VM could solve this problem.
Please refer to the steps below.
1.Create a new VM A in the same VNet.
2.Stop the problem VM B and copy the OS VHD.
More information about copy OS VHD please refer to the following article:
https://azure.microsoft.com/en-us/documentation/articles/storage-use-azcopy/
3.Delete VM B and keep the attached disks.
4.Once the lease is cleared, "Attach disk" from VM A to VM B via the Azure Portal
5.Mount the disk on VM A

mkdir -p /mountpoint
mount /dev/sdc /mountpoint

6.Modify ifcfg-eth0

sed -i "s/BOOTPROTO=none/BOOTPROTO=dhcp/g"
  /mountpoint/etc/sysconfig/network-scripts/ifcfg-eth0

7.Umount the disk on VM A

umount /mountpoint

8.Detach disk from VM  B via the management portal
9.Recreate the original VM by using templates
https://github.com/Azure/azure-quickstart-templates/tree/master/201-vm-from-specialized-vhd
If you still have questions, welcome to post back here. Thanks.
Regards,
Walter


Functional equation $f(x^2+y)=f(x)+f(y^2)$ from Olympiad

Question: Let $f: \mathbb{R} \to \mathbb{R}$
$$f(x^2+y)=f(x)+f(y^2)$$
How do I find all functions that fulfill this equation?
I tried to just write many equalities but it just doesnt help.
Comment: What are the domain and codomain of your function?
Comment: And what is the question about that equation?
Comment: You might get a more complete response at $$ $$ http://www.artofproblemsolving.com/Forum/viewforum.php?f=721 $$ $$ where they specialize in contest type problems $$ $$
Comment: Hi Vadiklk, By enclosing LaTeX in `$`-signs (e.g. writing `$x^2$`) you get the formulas typeset (e.g. $x^2$). I edited both your questions in that respect and made the title a little bit more descriptive. I hope that's fine with you. If not, you can click on edited xx secs/mins/hours ago above my name and roll back to your original version.
Answer: You can solve this pretty immediately by looking at the cases $x=0$, $y=0$, and $x^2+y=0$.  (The only possibility is the constant zero function.)
Comment: thanks alot, you helped me really much!
Answer: I would try to see how it behaves at "special points" like +-1, 0 and some others, and see how it can behave.
For example, if you let $y=0$ this becomes $f(x^2) = f(x)$.
Then for $x=y=1$ you get $f(2) = 2f(1)$.
For $x=1, y=-1$ you get $f(0) = 2f(1)$ also...
Try a few more combinations and you'll get enough constraints to define $f$, or reach a contradiction.


Create Drupal Commerce stores as a Service

Question: I'd like to leverage the power of Drupal Commerce to sell completely unrelated products and thus would like to create 2 different stores and brands. I could of course create a Drupal multisite but this is overkill and I really want to have only one site and one Drupal Commerce setup. If tomorrow I want to create new stores, I'd be able to do so with this layout without having to go through the headache of managing different installs.
My idea is thus to try and set up Drupal Commerce as a service with the following in mind:

Each store would be completely isolated from the others (products,
clients...)
Provisioning a new store would only be a matter of assigning a role to a new user
Say the root domain is mysite.com, I'd like to have one
store at mysite.com/store1 and the other at mysite.com/store2 (using
subdomain would be pretty much the same)

I've been thinking about using Organic groups but it's not obvious to me if a) it is the right tool and b) how to achieve that with the module.
Any pointer or feedback would be very much appreciated.
Thanks!
Answer: This is known as the "marketplace" use case.
There is a 250-comment discussion on this in the Drupal Commerce issue queue:
http://drupal.org/node/990204
See http://drupal.org/node/990204#comment-5880498 for a fairly simple implementation plan.
Of course, it goes into details that your project might not need, but you can just ignore those.
Quoting the relevant part about the basics needed:

1) An entity that represents the store. That can either be the user, a store entity clicked together through the ECK module, or a store entity provided by a module.
2) Entityreference. Then a bunch of entityreference fields that point to the "store" entity (or user). One on products, one on product displays, one on orders.
3) Form alters that hide the entityreference fields on product displays and products (or just use a "hidden" widget) and fill it in with the known value (you always know which store the user has. If not, give him a dropdown...).
4) A custom submit handler for the add to cart form (replacing the existing submit handler) that adds a product to an appropriate order (since there's an order per store for each customer), and if the order doesn't exist yet, creates it and sets the value of the entityreference field.
5) Custom view for cart/ that shows all active carts to a customer.
6) Custom views filtered by the entityreference field that show the merchant the products and orders for his store.

Organic Groups fits neatly on top. You then need to figure out how you're handling payments, see the linked issue for various approaches.
Comment: Thanks so much for this! I missed these issues on d.o and think I have a great path to move forward.
Answer: I have implemented a marketplace feature in my site. I used the below path.

2 type of order type/bundle  main_order , vendor_order.
On checkout (main_order) a list of vendor_orders gets created for each store through rules and little bit of coding.
Each vendor will have permissions for vendor_orders only. so this limits their of useage.
on front-end  it user doesn't see different stores, just like amazon or ebay


Existence of Positive Solutions to Constrained Linear Elliptic Second-Order PDE

Question: Consider the elliptic second-order PDE on some bounded domain $D$ (in any dimension)
$-\Delta_D u + \alpha u = 0$
subject to the constraint
$\gamma^i \nabla_i u + \beta u = 0$,
where $\Delta_D$ is the Laplacian on $D$ (with respect to some metric), and $\alpha$, $\beta$, and $\gamma^i$ are real smooth functions on $D$.
A zeroth question, to address user254433's comment below, is what compatibility conditions on $\alpha$, $\beta$, $\gamma^i$, and presumably the metric on $D$ are required to ensure that the system above has solutions?  user254433 derived such a condition in one dimension.
Now my main question.  Assume the system satisfies the above compatibility conditions so that it admits solutions, and say if any (real) solution to the above system is positive on the boundary $\partial D$, it must be positive everywhere in $D$.  What does this imply on the coefficients $\alpha$, $\beta$, and $\gamma^i$?
Note that here I'm asking for necessary conditions on the coefficients.  Indeed, I do know of a sufficient condition: if $\alpha \geq 0$ everywhere, this ensures by standard minimum principles that $u$ cannot have any negative local minima (since otherwise at the minimum we'd have $-\Delta_D u + \alpha u < 0$), and so if it's positive on $\partial D$ it must be positive everywhere.  However, if necessary conditions on the coefficients are unknown, I'm also interested in learning about sufficient conditions that are weaker than $\alpha \geq 0$ everywhere.
Note that these conditions (necessary or sufficient) need not be local; for instance I'm happy to have conditions on integrals of these coefficients over $D$, etc.
Answer: This is a long comment, not an answer.  I just want to mention a technicality that suggests your problem might need to be rephrased.  You will want to assume that the system itself is compatible.  Let me illustrate with $n=1$ dimensions.
If $n=1$, we can write your system as
\begin{align}
u''+\Gamma(x)u'+\alpha(x)u=0,\\
u'+\beta(x)u=0,
\end{align}
where, using the low dimensional structure, we set some coefficients equal to 1.  The problem then becomes: if $u|_{\partial D}>0\to u|_D>0$, does this imply anything on $\Gamma,\alpha,\beta$?
Here's my observation: if no positive solutions exist, then the answer must be negative.  So the problem is only interesting in the case when the system is compatible.  In higher dimensions, the precise conditions are unclear to me, but for $n=1$, it is clear:
To test for compatibility, we differentiate the second equation and substitute $u'$ terms:
\begin{align}
0=u''+\beta u'+\beta' u=u''+(\beta'-\beta^2)u.
\end{align}
Let us also eliminate $u'$ from the "main" equation:
\begin{align}
u''+(\alpha-\Gamma\beta)u=0.
\end{align}
Solving both equations for $u''$, we get
\begin{align}
[\alpha-\Gamma\beta-(\beta'-\beta^2)]u=0.
\end{align}
For nontrivial solutions, we thus need
\begin{align}
\alpha=\Gamma\beta+\beta'-\beta^2.
\end{align}
So before even addressing your question about positive solutions, we need conditions on $\alpha,\beta,\Gamma$.
Comment: This is a very good point; indeed, for the particular case I have in mind I'm assuming that the coefficients satisfy whatever compatibility conditions they must for the problem to have solutions.  I'll add this to the question.


Moving an SSL certificate

Question: We are developing a site for a client who already has an SSL certificate and already has a website and domain name that uses it. We will be hosting the new site on our server running Apache that has other sites on it with the same IP. The domain name for the website will have its A record changed to our server. The existing certificate was granted by Comodo. Another possibly important fact is the company where their existing site is hosted will not get back to us in regards to the certificate. I have asked for them to give me an "exported copy of the SSL certificate and private key" but have been ignored.
Having asked Comodo and the company who hosts our other sites for help I am really confused! I've never really dealt with SSLs before.
So my questions are:

Is the only way of transfering this certificate to get it exported by the current hosting provider?
If they don't respond, what are my next steps?
Can a domain name have two certificates (if we buy a new one)?

I apologise if I am using incorrect terminology but thanks in advance!
Answer:
Yes, you need a copy of the private key and the certificate.
Buy a new certificate.
The direct answer is yes, but only one of them will be active depending on which server the A-record points to.

Depending on your budget, it is probably cheaper to just buy a new certificate than to use hours to get the existing key+certificate from your current hosting provider.
Comment: If I were beingalex, I'd really really want to revoke the old certificate. As long as it's out there and not under your control, your old hostingcompany (or somebody working there) could use it e.g. for a MITM attack or to otherwise harm your company.
Comment: Yes, they could do that. That's why you need to revoke the old cert.
Comment: As we are not in a total rush, I am going to wait and see if I can get it exported (if that's the right word). Thanks.
Comment: If we go down the getting it exported route: The other company has control of domain name and A record, what happens if they (after changing it to ours) change the A record back and forge the site? Is there not still a copy of the certificate on their server?

Moving an SSL certificate


bias estimating the proportion in pooled population

Question: Assuming we want to estimate the proportion of success and there are two stages. We will move to stage 2 only when the number of success is greater than equal to a threshold (say 5) in stage 1. And we want to use stage 1 and 2's information to estimate the proportion of success.
If we observe 3 successes out of 30 in stage 1 and 14 successes out of 100 in stage 2, can we simply say the estimated proportion is 17/130=?
I suspect there would be bias upward or downward as we include the stage 1's result knowing its success.
Any suggestions to address this bias and estimate the proportion?
Thanks in advance.
Comment: Seems garbled, maybe with typos. Please clarify: Exactly what is Stage 1? Under what circumstances do we move to Stage 2? If we move to Stage 2, exactly what is it? If we have only Stage 1, how do we estimate P(Success); if we have both stages, how do we estimate P(Success).
Comment: Sorry for the typo. In stage 1, for samples 30 if we observe greater or equal to 5 success then move to stage 2 where we will collect larger sample 100.
Answer: If I understand the situation, I think you are right that there will be
bias, and for the reason you give. If you start off with an estimate that
is 'large' you try again, possibly substituting a smaller estimate based on results from more trials.
Simulation with Phases 1 & 2: I simulated the experiment a million times for each of three success
probabilities $p = 1/10, 1/6, 3/10,$ respectively. The event cond occurs if
we go on to Stage 2. The estimate ext is the average of results based on
30 trials if only Stage 1 is used, and the average of results based on 130 trials
if both stages are used. [Notice that if $p = 1/6,$ then the average count at
Phase 1 is $5.]$
set.seed(1118);  m = 10^6; p = .1
x1 = rbinom(m, 30, p);  x2 = rbinom(m, 100, p)
cond = (x1 >= 5)
est = x1/30;  est[cond] = (x1[cond]+x2[cond])/130
mean(est);  mean(cond)
[1] 0.08819467  # est seems < 0.1
[1] 0.175508    # aprx P(Go to Stage 2)

p = 1/6
x1 = rbinom(m, 30, p);  x2 = rbinom(m, 100, p)
cond = (x1 >= 5)
est = x1/30;  est[cond] = (x1[cond]+x2[cond])/130
mean(est);  mean(cond)
[1] 0.1461873   # est seems < 1/6
[1] 0.57612     # aprx P(Go to Stage 2)

p =.4
x1 = rbinom(m, 30, p);  x2 = rbinom(m, 100, p)
cond = (x1 >= 5)
est = x1/30;  est[cond] = (x1[cond]+x2[cond])/130
mean(est);  mean(cond)
[1] 0.3996667   # est seems near 0.4
[1] 0.998444    # aprx P(Go to State 2)

Straightforward simulation with 130 trials: If you just go ahead and use $n = 130$ trials from the start (with no Phase 1 or Phase 2 contingencies), you get very good estimates with a million iterations:
mean(rbinom(10^6, 130, .1)/130)
[1] 0.1000389  # aprx .1
mean(rbinom(10^6, 130, 1/6)/130)
[1] 0.1666442  # aprx 1/6
mean(rbinom(10^6, 130, .4)/130)
[1] 0.3999704  # aprx .4

Toward a general analytic solution: To find a general analytic solution for any $p,$ you need to start by figuring out such things as: (a) the probability of going on to Stage 2, (b) the expected
value of the estimate $E(\hat p_1)$ for Stage 1 only, (c) the estimate $E(\hat p_1 | \text{Stop at Phase 1})$, and (d) the estimate
$E(\hat p_b)$ if both stages are used.


Union on one column in SQL

Question: I have scenario where I need to union results based on one column
Table 1
Name   Rank
------------
A1     1
A2     6

Table 2
Name    Rank
------------
A1      3
A3      4

Now I need the union of distinct names sorted based on ranks.
Result should be
Name
-----
A1
A3
A2

Could you help me with the SQL query to get this result?
Comment: Also, what DBMS are you using?
Comment: Which [DBMS product](https://en.wikipedia.org/wiki/DBMS) are you using? "SQL" is just a query language, not the name of a specific database product. Please add a [tag](https://stackoverflow.com/help/tagging) for the database product you are using `postgresql`, `oracle`, `sql-server`, `db2`, ...
Comment: And what do you do if same name appears in 2 tables? How do you rank them in that case? Take lowest, highest, or?
Comment: A1 apears twice and take lowest one
Answer: I guess you want to order by max rank.
Select Name from (
    Select Name,Rank
    From Table1
    Union
    Select Name,Rank
    From Table2
) T
group by Name
order by max(Rank)

DEMO TEST LINK

Result:
Name
-----
A1
A3
A2

Comment: I have tried this.But this gives the duplicate rows. I need the unique rows
Comment: try again . I group by name , it'll get unique rows

Union on one column in SQL


How to check whether the relation between ordinal variable and scale variable is monotonic?

Question: I am wondering what correlation measure to use for calculating the relation between ordinal and scale (interval) variable. For using Spearman's rho the relation must be monotonic. I created a scatterplot, but I am not sure how to interpret it. It shows four vertical lines of similar height. I then created a boxplot, from which I would conclude that it is monotonic, but I am not sure whether it is a correct conclusion? Is there another way to check it and justify that it's monotonic(if it is). I'm not sure if it's relevant here, but the sample is big, N=1500.
Comment: The box plot has vices opposite to its virtues. If half of the values lie inside each box, then half lie outside; and in this case (with one exception) there is little detail in the box plots about where the other half lies in each case within each tail. So, I would plot selected quantiles (Tukeyish letter values if you prefer) for every distribution, say 95, 90, 75, 50, 25, 10, 5% points.
Comment: +1 I like the question--but please note (in the title) that "monotonous" means "dull, tedious, repetitious, boring."
Comment: @Nick In this case I think the boxplots are perfect for the question: they show the medians--a strongly resistant measure of location--conditional on the regressor, as well as displaying information about the conditional distributions themselves.  They suffice to conduct a robust analysis of the data.  If the "monotonic" hypothesis is that the medians of the conditional distributions are always non-decreasing or always non-increasing, then the equality of the rightmost two medians shows the p-value of this test must be close to $0.5$.
Comment: Joanxm, could you please elaborate on what you mean by "calculating the relation"? What is it you ultimately want to know?
Comment: @whuber Quite so, but it may be also be of interest to see if other quantiles are changing systematically, regardless of the apparent lack of relationship in the middle of the distribution.
Comment: @whuber The monotony was getting to me, so I edited it out of the title.
Answer:
For using Spearman's rho the relation must be monotonic.

This is not quite correct. Spearman's $\rho$ is a nonparametric correlation coefficient that assesses monotonicity. It is +1 or -1 if your data are perfectly monotonic. As such, it asks exactly the question you have.
The alternative that comes to mind is Kendall's $\tau$, which is also a rank correlation coefficient.
This earlier question may be helpful in deciding between Spearman and Kendall.
Both Spearman and Kendall have problems with ties, and you have lots of ties. The Wikipedia page for Kendall's $\tau$ has more info on possible ways of dealing with ties than does the page for Spearman's $\rho$. Looking at your data - 1500 data points in just four classes - your findings will quite probably be dominated by how the method you choose deals with ties.
Finally, $N=1500$ is quite a lot. There really doesn't seem to be a lot of structure in your data. If you run an ANOVA and look at $R^2$, I don't think you will be able to explain a lot of variance in your scale variable just from the ordinal variable. However, with a pretty large $N$, both Spearman's and Kendall's correlation coefficient may well be significantly different from zero. Which shows that you shouldn't trust the $p$ value overmuch here. (Of course, there also is the problem about dealing with ties.)


Trying to figure out coordinates of isoscleles triangle

Question:
I'm programming some application, which heavily depends of geometry. Let's say, in 2D coordinates system I have i.e. :
Bxy = (5,-2)
Cxy = (2,-5)
ABlength = 5.5

Now I need (x,y) of an A (vertex) point. I'm not mathematician, so please, be gentle. Thank you.
Comment: You can do this with the Pythagorean theorem. Note that with only this information there are two places where A could be (one mirrored across BC relative to the other)
Answer: HINT:
We have
$$(A_x-5)^2+(A_y+2)^2=(A_x-2)^2+(A_y+5)^2=(5.5)^2$$
From $$(A_x-5)^2+(A_y+2)^2=(A_x-2)^2+(A_y+5)^2$$, we can express $A_x$ in terms of $A_y$ linearly.
Put this value in  $$(A_x-2)^2+(A_y+5)^2=(5.5)^2$$ to find $A_y$
Comment: How can I express depth of my stupidity about all that equation stuff... I could build Anschütz gyrocompass easier. Please be kind and show me the expression which I can use without brain :(
Comment: You don't need to use your brain. It's Pythagorean theorem.


Android reconnect internet issue

Question: In my app i manage to determine is there connection or not, but i want that application itself try to reconnect 5 times, and every time to increase the interval between to reconnects m i did some code, but its not working, he give me response immediate.
Here is my reconnect class:
<code>    public class ReestablishConnection {
    Application APP = new Application();
    boolean status;
    int reconnectInterval = 1000;
    int i;

    public boolean reconnect(String URL){
        Thread timer = new Thread(){
            public void run(){
                    for(i=1;i<6;i++){
                        if(APP.testConnection(APP.defaultUrl()) == 0){
                            status = false;
                        }else if(APP.testConnection(APP.defaultUrl()) == 1){
                            status = true;
                        }
                        try {
                            sleep(reconnectInterval * i);
                        } catch (InterruptedException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }

            }
        };
        return status;
    }

}
</code>
Answer: You create a new thread, which sleeps for a while, but the method which spawned it (reconnect) will return immediately.  You should be using a Handler with postDelayed().
Take a look at the answer here:
How to run a Runnable thread in Android?
Sleep is used too often.  The correct design is to implement a listener for when a connection is available and respond to listener callback in your UI.

Android reconnect internet issue


Motivation behind local trivializations in vector bundles

Question: I am self studying smooth manifolds and I have encountered the notion of a vector bundle. My current intuition for these objects is that they somehow generalize what we encountered when studying tangent bundles, which is each point in the base space is in some way associated with a vector space. However, looking at the formal definition of a vector bundle I do not understand the role of a local trivialization and why we need it. For reference, Lee's Introduction to Smooth Manifolds defines vector bundles as follows:

Let $M$ be a topological space. A (real) vector bundle of rank $k$ over $M$ is a topological space $E$ together with a surjective continuous map $\pi: E \rightarrow M$ satisfying the following conditions:

For each $p \in M$, the fiber $E_p = \pi^{-1}(p)$ over $p$ is endowed with the structure of a $k$-dimensional real vector space.
For each $p \in M$, there exist a neighorhood $U$ of $p$ in $M$ and a homeomorphism $\phi: \pi^{-1}(U) \rightarrow U \times \mathbb{R}^k$ (called a local trivialization of $E$ over $U$) satisfying the following conditions:

$\pi_U \circ \phi = \pi$ (where $\pi_U: U \times \mathbb{R}^k \rightarrow U$ is the projection);
for each $q \in U$, the restriction of $\phi$ to $E_q$ is a vector space isomorphism from $E_q$ to $\{q\} \times \mathbb{R}^k \cong \mathbb{R}^k$.

I do not have a good feel for what a local trivialization is. More specifically, my confusion is regarding the second item in the definition. What is this conditions saying exactly and why do we need it? I must be missing something, but what extra information does it give us that first item in the defintion does not?
I took a look at the following question:
Redundancy in the definition of vector bundles?
but I still do not understand what the second item in the definition (and specifically local trivializations) is saying on an intuitive level.
Comment: Lee wrote an extraordinarily great book which is, among other things, a way to convince you of the sense of those definitions. You will have noticed that one thing the book is not is *short*. You did not learn to walk in your first day, either!
Comment: Let me add that differential geometry is the part of mathematics where you only have one recipe, which is gluing trivial things together, and you are looking at how many dishes you can make with this recipe by just switching the ingredients (what you consider as trivial). Sometimes you end up with a very good meal
Comment: You are looking at this backwards. Vector bundles pre exist the definition of vector bundles, and that definition is designed to capture the salient features of a whole class of objects. We define vector bundles to be locally trivial because vector bundles are locally trivial.
Comment: The definition incorporates the features of vector bundles that are needed to do what people down with them — what they already did with them even before anyone gave a definition. And that is why you question is best resolved by learning more about vector bundles and seeing what people do with them.
Comment: Just as you learned to walk by walking, you'll get a feel of why local triviality is useful by seeing it being used to prove things. I am not going to go *o tempora o mores* but really, this expectation of having an intuitive feeling for why things are in the way they are upon first encounter is only a source of frustration.
Comment: @MarianoSuárez-Álvarez Thank you for your comment, when you say that vector bundles are locally trivial do you mean locally they resemble trivial bundles? I suppose I need to take the definition for what it is for the time being and move on.
Comment: At this gluing point, you just choose another local cover. The point of local trivializations is exactly that you can "locally unflip" these vectors but not globally.
Comment: @MarianoSuárez-Álvarez I am still not 100% clear on the definition, but I will take your advice and move on in the book. Hopefully things will become clear with more exposure to them.
Comment: Locally trivial essentially means: its section locally look like vector-valued functions, so we can develop differential calculus for these objects.
Comment: @QuaereVerum I have not gotten to sections yet, so perhaps this is what I am missing.
Comment: Roughly speaking, finding a local trivialization means being able to "flatten your vector bundle out locally".  The point is that at a local level, everything is trivial; you'll only get nontrivial behavior globally. A good example of this to keep in mind is the mobius band vs cylinder as bundles over the circle.
Comment: @ZackFox By local do you mean homeomorphic to $\mathbb{R}^n$? I suppose what is confusing me is if the vector bundle already requires the surjective map $pi$ to be such that $\pi_{-1}(\{p\})$ is a vector space, isn't a trivialization $\phi$ saying the same thing? What does part 2 of the definition say that 1 already doesn't?
Comment: I mean that your vector bundle is locally homeomorphic to $U\times \mathbb{R}^n$ where $U$ is some open set in your base space. The first condition tells you that the fiber of every point is a vector space. The second condition describes the local picture (i.e. in an open neighborhood of a point).
Comment: I encourage you to, as others in this thread are, to not think too much about the technical definition yet in a vacuum. Think of the mobius band vs the cylinder; you want to say both these are vector bundles over the circle. Draw some pictures and identify what the axioms are saying in these two specific instances, and you'll start to get a feel for these technical definitions.
Comment: @ZackFox That example is very helpful and may have given me the intuition I am looking for. In the case of a cylinder, it trivially holds that every fiber looks like $\mathbb{R}^n$ and things vary in a continuous fashion. For a mobius band the same cannot be said globally as once we reach the end points there is a "jump" in vector spaces as we vary the point around the circle. The only question I have about this situation is what would a trivializing open set around the end point $0 \sim 1$ look like, as one side the vector spaces are "flipped" whereas the other side they are not.
Comment: @ZackFox I think I have a good intuition as to why we need local trivialization now, thanks a lot for your help!
Answer: The linked question Redundancy in the definition of vector bundles? and your statement

However, looking at the formal definition of a vector bundle I do not understand the role of a local trivialization and why we need it.

plus your comment including the question

What does part 2 of the definition say that 1 already doesn't?

indicate that you do not understand the purpose of requiring the existence of local trivializations or that you even think that this requirement could be redundant.
I think when you begin to learn new concepts and start with reading definitions quite often the purpose of all requirements occurring in the definitions is not really clear. Usually this undergoes a change when you learn the theory based on the definitions and an "aha" experience arises.
Anyway, let me make some remarks.
Remark 1.
There is the concept of a pre-vector bundle (or a family of vector spaces) which is defined via Lee's condition 1.
Unfortunately pre-vector bundles may look completely erratic - both topologically and algebraically.
As an example consider $M = [0,1]$. Then the projection $\pi : M  \times \mathbb R^2 \to M$ gives us a nice trivial vector bundle. Now consider a function $f$ assigning to each point $p \in M$ a one-dimensional subspace $f(p)$ of $\mathbb R^2$. Define $E_f = \bigcup_{p \in M} \{p\} \times f(p) \subset M  \times \mathbb R^2$. Then $\pi_f = \pi \mid{E_f} : E_f \to M$ is a one-dimensional pre-vector bundle. Now consider the function $f(p) = \mathbb R \times \{0\}$ for rational $p$ and $f(p) = \{0\} \times \mathbb R$ for irrational $p$. Then $E_f$ is not locally trivial; indeed no open $U \subset [0,1]$ admits any homeomorphism $\phi : \pi_f^{-1}(U) \to U \times \mathbb R$ (even if we drop both bullet points in condition 2.).
Another example is this: Take again $M = [0,1]$ and $\pi : E = M \times \mathbb R \to M$. Now consider a function $h$ assigning to each point $p \in M$ a homeomorphism $h(p) : \mathbb R \to \mathbb R$. Let $\mathbb R_{h(p)}$ be the real vector space with addition $x + y = h^{-1}(h(x) + h(y))$ and scalar multiplication $\alpha x = h^{-1}(\alpha h(x))$. Let $E_h$ be the space $M \times \mathbb R$, but give each $\{p\} \times \mathbb R$  the vector space structure $\{p\} \times \mathbb R_{h(p)}$. Now consider the function $h(p)(x) = x$ for rational $p$ and $h(p)(x) = x+1$ for irrational $p$. Then $E_h$ is topologically locally trivial, but not algebraically. Indeed no open $U \subset [0,1]$ admits any homeomorphism $\phi : \pi^{-1}(U) \to U \times \mathbb R$ such that $\pi_U  \circ \phi = \phi_U$  and $\phi_q : \{q\} \times \mathbb R_{h(q)} \to \{q\} \times \mathbb R$ being a vector space isomorphism for all $q \in U$.
Remark 2.
The "naturally occurring" vector bundles like the tangent bundle of a smooth manifold are locally trivial. This suggests that local triviality is an important property distingishing "interesting bundles" from general pre-vector bundles.
Remark 3.
There are a number of related questions in this forum, for example

Why do we need the local triviality condition when working with vector bundles?

Alternative characterization of local triviality of vector bundles?

Where is the compatibility condition in the definition of a vector bundle?
Comment: @CBBAM Yes, the "jumping" of $f(p)$ makes $E_f$ a space which is not locally compact. But trivial vector bundles over locally compact spaces are locally compact which proves my assertion of the non-existence of any homeomorphism. There are uncountably many functions $f$ with an even more erratic behavior, and all these give erratic pre-vector bundles. See the second of my links if you want to understand in what sense such functions are non-continuous (this is not elementary and perhaps comes too early for you).
Comment: Thank you for your reply! You are exactly right that the trivialization condition is what is the source of my confusion, I suppose I need to read further ahead to get a better feel for it. In your first example, what makes the vector bundle $\pi_f: E_f \rightarrow M$ erratic and fail the trivialization condition? Is it because as we vary $p$ the corresponding subspace jumps around in a possibly non-continuous way? Since we are working with $k < \infty$, aren't all all non-trivial vector (sub) spaces isomorphic to $\mathbb{R}^k$, and so how does continuity fail here?
Comment: Thank you again, I think I have a good feeling for the local trivialization condition now and why we need it. I hope the rigorous details come with time.


How to include pagination in a Wordpress Custom Post Type Query

Question: I have the code below:
<?php $the_query = new WP_Query( 'posts_per_page=30&post_type=phcl' ); ?>

<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

    <a href="<?php echo $file; ?>" class="file-title" target="_blank">

        <?php echo get_the_title(); ?>

        <?php the_content(); ?>

<?php endwhile; wp_reset_postdata(); ?>

I am trying to use paginate_links Wordpress function but no matter where I put it, I can't make it work. Can someone help me with this?
Answer: Try the code below:
    $the_query = new WP_Query( array('posts_per_page'=>30,
                                 'post_type'=>'phcl',
                                 'paged' => get_query_var('paged') ? get_query_var('paged') : 1)
                            );
                            ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>

<a href="<?php the_permalink(); ?>" class="file-title" target="_blank">
 <?php echo get_the_title(); ?>

<?php the_content(); ?>

<?php
endwhile;

$big = 999999999; // need an unlikely integer
 echo paginate_links( array(
    'base' => str_replace( $big, '%#%', get_pagenum_link( $big ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'total' => $the_query->max_num_pages
) );

wp_reset_postdata();

Comment: There's a small error in this solution. The code 'paged' => get_query_var('paged') ? get_query_var('paged') : 1) should not have a final parenthesis. In order for the pagination to run correctly remove the closing parenthesis from after the number 1.
Comment: query for pagination doesn't work, when i click the second page t returns the first page posts
Comment: Use  in place of
Comment: @Jay no it didnt
Answer: When querying a loop with new WP_Query set the 'total' parameter to the max_num_pages property of the WP_Query object.
Example of a custom query:
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$args = array(
    'post_type'=>'post', // Your post type name
    'posts_per_page' => 6,
    'paged' => $paged,
);

$loop = new WP_Query( $args );
if ( $loop->have_posts() ) {
    while ( $loop->have_posts() ) : $loop->the_post();

             // YOUR CODE

    endwhile;

    $total_pages = $loop->max_num_pages;

    if ($total_pages > 1){

        $current_page = max(1, get_query_var('paged'));

        echo paginate_links(array(
            'base' => get_pagenum_link(1) . '%_%',
            'format' => '/page/%#%',
            'current' => $current_page,
            'total' => $total_pages,
            'prev_text'    => __('« prev'),
            'next_text'    => __('next »'),
        ));
    }
}
wp_reset_postdata();
?>

Example of paginate_links parameters adapted to the custom query above:
For more reference please visit this link
Comment: @KhomNazid You are following this permalink structure https://www.screencast.com/t/IeYH7bxY3 Right?
Comment: Thank you for sharing this. It does show me the pagination. But when I click on the URL for Page 2, it still shows me the same content as Page 1. Any ideas?
Comment: This is perfect!! @PurvikDhorajiya
Comment: @PurvikDhorajiya, no. I'm following `%category%/%postname%`, which we do need for our blog section outside the custom posts. For custom posts, we rely on the "Permalink Manager Lite" plugin. Our specific case is detailed here (and now our page 2 gives a 404, actually): https://stackoverflow.com/questions/57301662/wordpress-pagination-issues-with-custom-post-type-and-custom-rewrite-rule
Comment: This works well for me thank you, however, it always takes you to the top of the page like you are navigating between different pages, where as  I would like it to stay in the same position and just appear to paginate through the post section. Any ideas? Thanks
Answer:       Try This one, it worked for  me!

    <?php
                 $paged = get_query_var('paged');

                $args = array(
                    'post_type' => 'blogs',
                    'paged' => $paged,
                    'orderby' => 'date',
                    'order' => 'ASC',
                    'posts_per_page' => 1,
                    'post_status' => 'publish',
                );
                $the_query = new WP_Query($args);
                if ($the_query->have_posts()) {
                    while ($the_query->have_posts()) {
                        $the_query->the_post();
            ?>

             Your code...
        <?php
                        }

                    }

     wp_reset_query();
  ?>

<?php
                echo "
" . paginate_links(array(
                    'total' => $the_query->max_num_pages,
                    'prev_text' => __('
Prev
'),
                    'next_text' => __('
Next
')
                )) . "
";
            ?>


How to read Meteor settings from a build plugin

Question: I'm currently working on a package for Meteor that includes a build plugin. I need to access configurations from the settings file.
However Meteor.settings doesn't work (Meteor is not defined) and process.env.METEOR_SETTINGS also doesn't exist.
Is there any way for my plugin to access the settings file?
Comment: Are you importing Meteor? `import { Meteor } from 'meteor/meteor';`
Comment: I wasn't, but once I import Meteor, the value of `Meteor.settings` is `{ public: {} }`, so plugins must run before Meteor loads settings.
Answer: It appears that despite the documentation discussing the use of --settings, it doesn't work in a production environment, as often command line options are not available.
So the solution is to use environment variables, which are available only on the server.
server code, meteor methods:
eor methods
Meteor.methods({
    getPJS: function() {
        return process.env.PEERJS_SERVER;
    },

client code
var PJS = Meteor.call("getPJS");

So you can make those environment variables available on the client if you need them.


Google Maps Delete Marker with it's id

Question: I have a Google map with a lot of of Markers and their Circles. I have Successfully added Markers and Circles and saved their id. But Deleting Marker is easy but deleting circle is making a problem even though i have the id of Circle what's the method to find that Circle ?
<code>   like **googlemap.getCircle(id).remove();**
</code>
But there is no method like this so how can i do that?? I am thinking on Clearing the map and adding All the markers and Circles again,
EDIT- here is my code.
<code>         String mid =  marker.getId();
            DataBaseOperations hell = new DataBaseOperations(getContext());
            SQLiteDatabase db = hell.getReadableDatabase();
            Cursor c = db.query(mDatabase.Table, new String[]{mDatabase.ID}, mDatabase.ID, new String[]{mid}, null, null, null);
            while(c.moveToNext()){
                String cid = c.getString(c.getColumnIndex(mDatabase.cid));
            }
            marker.remove();
            hell.close();
            db.close();
            c.close();
</code>
cid is the id of Circle, added previously now how can i delete this circle using it's id.
Answer: Try to delete your circle with your circle_function object, like this:
<code>Circle mapCircle{
//your circle method,
//**example**
}

/* to remove your cirlce call remove() method**/
mapCircle.remove();
</code>
Comment: Couldn't understand bro.
Comment: Try to delete your circle using remove() method.
Comment: yo are not understanding dude.

Google Maps Delete Marker with it's id


My timer won't count correctly in Java

Question: So i'm making a game using Java and want to use a timer to countdown from 3 on the game screen after the user presses "play" on the menu screen.
Here's my code:
int seconds = 3;

private void countdown(Graphics g) {

    Timer timer = new Timer();

    TimerTask task = new TimerTask() {
        public void run() {
            if(seconds >= 0) {
                System.out.println(seconds);
                seconds--;
            }
            if(seconds == -1) {

                timer.cancel();
            }
        }
    };

    timer.schedule(task, 1000, 1000);
}

I use countdown in the draw method of my game here:
public void draw(Graphics g) {

    //background
    g.setColor(Color.BLACK);
    g.fillRect(0, 0, WIDTH, HEIGHT);

    //count
    countdown(g);
}

I'm using the console to print the numbers however I will change this to use drawString() later to draw the countdown on screen.
After pressing "play" on my menu screen there is a one second pause on my game screen and then the numbers all print to the console. The problem is that there is no one second delay between the numbers printing, they just print all at the same time. Any help?
Comment: Works fine for me. Please post a [mcve].
Comment: Did you use a draw method and did the seconds decrement with 1 second intervals?
Comment: I just did the `countdown()` method and it counted down to 0 in 1-second intervals. I don't see how the `draw()` method is relevant to the question.
Comment: the draw function is calling the countdown function which makes it relevant in this case
Comment: Well what I initially intended to do was use graphics to draw a string on the screen that displayed the countdown, and not use the console. The console was just for testing purposes.
Comment: You're using the *wrong* Timer, the java.util.Timer and java.util.TimerTask. Instead since this appears to be an AWT or Swing program, you should a javax.swing.Timer or "Swing Timer". This plays much nicer with the Swing event thread.
Comment: Also your Timer should not be started from the drawing code, but rather the other way around -- the Timer should change the state of the counting variable, and then a repaint request should be called. The drawing code should then obtain the counting variable's value and display it in the GUI.
Comment: ................... hello?
Answer: If draw gets called repeatedly, then multiple timers will be created, so you will get print outs from each timer, which will also be decrementing the seconds count.
You could try creating a single timer rather than creating in each countdown function and just have the countdown function set the seconds value.
Comment: How would I fix this so it doesn't get called repeatedly but still draws the timer to the screen?
Comment: Do you mean something like                                                                this?
`private int seconds = 3;
 private Timer timer = new Timer();

 private void countdown(Graphics g) {

  TimerTask task = new TimerTask() {
   public void run() {
    if(seconds >= 0) {
     System.out.println(seconds);
     seconds--;
    }
    if(seconds == -1) {
     timer.cancel();
    }
   }
  };

  timer.schedule(task, 1000, 1000);
 }`
Comment: I apologize, I didn't know how to format that last one.
Answer: Your program appears to be a Swing or AWT GUI program, and if so, you're using the wrong type of Timer, here a java.util.Timer and java.util.TimerTask, both of which are not Swing thread safe. This can cause your GUI to freeze, and the numbers not show up, just as you're seeing. Instead use a timer built specifically for these GUI's, a Swing Timer (click on this link for the tutorial).  You're also calling the timer from the drawing code which is the exact opposite of what you should be doing. Instead the Timer should change the state of your counting variable and then call repaint(). The drawing code then gets the value of the counting variable and displays it within the GUI.
For example, your Swing Timer could use an ActionListener whose actionPerformed method looks something like this:
public void actionPerformed(ActionEvent e) {
    if (counter != 0) {
        // if the counter hasn't reached the end
        counter--;  // reduce counter by one
        repaint();  // tell the GUI to repaint
    } else {
        timer.stop();  // otherwise at the end, so stop the timer
        countDownAction.setEnabled(true); // and re-enable the button
    }
}

A complete GUI example could look like this:
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

@SuppressWarnings("serial")
public class CountDown extends JPanel {
    public static final int TIMER_DLEAY = 1000;
    private static final Font COUNTER_FONT = new Font(Font.SANS_SERIF, Font.BOLD, 400);
    private static final int TEXT_X = 200;
    private static final int TEXT_Y = 500;
    private int counter;
    private JSpinner spinner = new JSpinner(new SpinnerNumberModel(5, 0, 20, 1));
    private CountDownAction countDownAction = new CountDownAction("Count Down");
    private JButton countDownButton = new JButton(countDownAction);
    private Timer timer;

    public CountDown() {
        setPreferredSize(new Dimension(800, 600));
        add(new JLabel("Starting Value:"));
        add(spinner);
        add(countDownButton);
    }

    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
        Graphics2D g2 = (Graphics2D) g;
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
                RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g.setFont(COUNTER_FONT);
        String text = String.format("%02d", counter);
        g.drawString(text, TEXT_X, TEXT_Y);
    }

    private class CountDownAction extends AbstractAction {
        public CountDownAction(String name) {
            super(name);
            int mnemonic = (int) name.charAt(0);
            putValue(MNEMONIC_KEY, mnemonic);
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            // inactivate the button/action
            countDownAction.setEnabled(false);
            counter = (int) spinner.getValue();
            repaint();
            timer = new Timer(TIMER_DLEAY, new TimerListener());
            timer.start();
        }
    }

    private class TimerListener implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (counter != 0) {
                // if the counter hasn't reached the end
                counter--;  // reduce counter by one
                repaint();  // tell the GUI to repaint
            } else {
                timer.stop();  // otherwise at the end, so stop the timer
                countDownAction.setEnabled(true); // and re-enable the button
            }
        }
    }

    private static void createAndShowGui() {
        JFrame frame = new JFrame("CountDown");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new CountDown());
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(() -> createAndShowGui());
    }
}

Answer: You must reset your seconds variable when you are creating and/or cancelling the timer
        Timer timer = new Timer();
        seconds = 3; //Reset here
        ..........
        ..........

        if(seconds == -1) {
            timer.cancel();
            seconds = 3; // Reset here
        }

Comment: When I do that it just repeats the countdown from 3 to 0 very fast and doesn't stop.
Comment: This means you have multiple tasks created.. Is this what you intended to do?
Comment: I intended initially to have a countdown show on screen using _drawString()_ and I just wanted the timer to count from 3 down to 0. I initially just wanted one task.

My timer won't count correctly in Java


What is the difference between 'same' and 'half' border mode in Convolutional neural networks?

Question: What is the difference between 'same' and 'half' border mode in Convolutional neural networks? I see it implemented differently in Theano and TF.
Answer:
full means apply filter wherever it partly overlaps with the input, i.e. padding of dimension (filter rows - 1, filter columns - 1)
half means that there is a padding of (filter rows // 2 rows, filter columns // 2 columns)
same means there are some padding around input or feature map, making the output feature map's size same as the input's.
valid means there is no padding around input or feature map, i.e. padding of dimension (0,0).

Some sources if interested:

How does border_mode work? #1984
border_mode='same' and/or custom zero padding for convolutions #2118
Ops for convolutional neural nets
TensorFlow - Convolution
What is the difference between 'SAME' and 'VALID' padding in tf.nn.max_pool of tensorflow?
Comment: Why would one want `half` padding? If I understand it right, the output feature map is by exactly 1 smaller than the input feature map?
Answer: The half padding is the same padding when the kernel size is odd and the stride is 1. In TensorFlow, we only have 'same' for the option for padding instead of 'half.' They are treated the same, and they work as the half.


Find the shortest distance between the plane with equation x-y+2z = 2 and a line with parametric equations:

Question: Find the shortest distance between the plane P with equation x-y+2z = 2 and a line  L with parametric equations:
$L:\frac{x-1}{1}=\frac{y-1}{-1}=\frac{z-3}{-1}=t$
L: { x = 1 + t }
   { y = 1 - t }
   { z = 3 - t }
From the equation of the plane, I found the normal vector to be <1, -1, 2>.
From the parametric equations I identified a point on the line, B (1,1,3).
I also found a point on the plane, A (2,0,0).
I found the vector AB (going from point A to B) as <-1,1,3>.
I know in order to find the shortest distance between the plane and the line I need to do a projection of AB onto the normal vector.
I know from doing the dot product of AB and the normal vector, that the numerator for the projection will be 4 (-1 + -1 + 6).
I keep coming up with the wrong answer and am looking for some help in figuring out the equation for this projection, as I simply cannot figure out how the solution manual got to that answer.
Thank you in advance!
Answer: In your question line is $$\frac{x-1}{1}=\frac{y-1}{-1}=\frac{z-3}{-1}=t$$
Hence one of Direction Ratio of line is (1,-1,-1) and direction ratio of normal to plane is (1,-1,2) Hence dot product of line and plane is zero.
Line is parallel to plane . Shortest distance will be distance of any one point on line from plane . One of the point is (1,1,3).
$$Shortest \,distance=\vert \frac{1-1+2×3-2}{\sqrt{1+1+2}} \vert$$
$$=\frac{4}{\sqrt{6}}$$


Is $|a-b|\geq |b|-|a|$ always true?

Question:
I am trying to understand this part of a proof. My question is why is the inequality only true for sufficiently large $|z|$?
Is $|a-b|\geq |b|-|a|$ only true for sufficiently large $|b|$? because it seems to work for $b=0$.
Also shouldn't $|\gamma^\prime(t)|$ disappear because it is in $L_\gamma$?
Comment: I think the placement of "whenever $z$ is sufficiently large" is confusing: it really applies to line (2.21) to avoid dividing by zero and also to make the denominator arbitrarily large.
Comment: @gbd $|\gamma(t) - z| \geq |z| - |\gamma(t)|$ is always true. However, the step going from the second inequality to the third inequality **also** requires $|z|$ to be large: at least you also need $|z| > |\gamma(t)|$.
Comment: The statement never said it was true *only* for sufficiently large values.  Only that it *is* true for sufficiently large values.  As it is true for *all* values it is true for sufficiently large values.  It emphasis sufficiently large values as that is all they are interested in.  If $|b| < |a|$ then noting that $|a-b| > 0 > |b| -|a|$ is not really useful (it's a no brainer; positives are *always* bigger than negatives!).  But if $|b| > |a| $ then noting that $|a-b| \ge |b| -|a| > 0$.... that *is* useful.
Comment: @fleablood, so the author means that the inequality remains true even if $|z|$ is very large.
Comment: Note:  If $a$ and $b$ are the same sign and $|b| \ge |a|$ then $|a-b|=|\pm(|a|-|b|)|=||a|-|b|| = |b|-|a|$.  If $a$ and $b$ are the same sign and $|b| < |a|$ then $|a-b|> 0 > |b|-|a|$.  And if $a$ and $b$ are different signs then $|a-b|= |\pm(|a|+|b|) = |b| + |a|\ge |b| \ge |b| -|a|$. So, yes, it is *always* true.
Comment: maybe he means "even if" by "whenever".
Comment: I think you *do* have a valid point.  There really was no *need* to say "whenever z is sufficiently large".  I wouldn't say the authors point is that it remains true "even" if $|z|$ is large, but more that "we are concerned with cases where $z$ is sufficiently large, in which case it is true (as it is *always* true)"
Comment: @Cj, Also shouldn't $|\gamma^\prime(t)|$ disappear because it is in $L_\gamma$?
Comment: @gbd $|\gamma'(t)|$ is the speed of the contour $\gamma$ parametrized by $t$, so it's not going to be zero all the time (unless $\gamma(t)$ is constant). Also, I think $L_\gamma$ refers to the length of $\gamma$, not a set.
Comment: The integral of the derivative of gamma is the definition of $L_\gamma$ in the textbook
Answer: It always holds. Perhaps that what the author had in mind was this: we always have $\bigl|\gamma(t)-z\bigr|\geqslant\bigl|\bigl|\gamma(t)\bigr|-|z|\bigr|$ and, if $|z|$ is large enough, we also have $\bigl|\bigl|\gamma(t)\bigr|-|z|\bigr|=|z|-\bigl|\gamma(t)\bigr|$.
Comment: I always thought of the inequality $|b-a| \ge |b| - |a|$ as "two no-brainers and one aha".  If $|b| \le |a|$ then $|b-a| \ge 0 \ge |b|-|a|$ (no brainer).  If $b$ and $a$ are opposite signs then $|b-a| = ||b| + |a|| =|b| + |a| \ge |b| \ge |b| -|a|$ (no brainer).  And if $b$ and $a$ are the same sign and $|b| > |a|$ then $|b-a| = |\pm(|b|-|a|)|=||b|-|a|| =|b|-|a|$ (an aha... okay, it's kind of a no-brainer aha but still....)
Comment: Shouldn't $|\gamma^\prime(t)|$ disappear because it is in $L_\gamma$?
Comment: What do you mean? $L_\gamma$ is a number (the length of $\gamma$), not a set.
Comment: In the textbook, we have this proposition https://i.imgur.com/Px3kcdT.png . $\gamma^\prime$ dispears in $L_\gamma$.
Comment: That's because $L_\gamma=\int_a^b|\gamma'(t)|\,\mathrm dt$.
Comment: @Yes, so the numerator of the first $\sup$ should be $1$ not $\gamma^\prime$.
Comment: No, it should not.
Comment: Then where did the $L_\gamma$ come from?
Comment: I cannot answer in a comment. That textbook seems to be a piece of trash, since even that short extract has several issues.
Comment: My only problem is how we got the first inequality. If you compare with  https://i.imgur.com/Px3kcdT.png you see the $\gamma^\prime$ shouldn't be there. I mean that's how get $L_\gamma$ from $\gamma^\prime$. It is done in previous examples in the textbook too.
Comment: That inequality should be$$\leqslant L_\gamma\sup\left\{\frac1{|\gamma(t)-z|}\,\middle|\,t\in[a,b]\right\}.$$
Comment: You forgot $2\pi$. But that is correct. This is what I meant. $\gamma^\prime$ is a mistake.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/133116/discussion-between-jose-carlos-santos-and-gbd).

Is $|a-b|\geq |b|-|a|$ always true?


How would I go about finding a closed form solution for $g(x,n) = f(f(f(...(x))))$, $n$ times?

Question: A friend of mine mentioned that given the functions $g(x, n)$ and $f(x)$ such that:
$$g(x,n)=\overbrace{f(f(f(...f(x))}^\text{n}$$
For example:
$$g(x,1)= f(x)\\g(x,2) = f(f(x))$$
and that there is a closed form solution. I don't know exactly where I would begin, but any help or pointers would be very much appreciated. I am also not sure if I denoted the function $g(x,n)$ using the correct notation.
Thank you in advance.
Comment: What exactly is your question? It is standard to write $f^n(x) = f(f(f(\dots(f(x))\dots )))$.
Comment: It seems like generating functions would help you out if you have a specific function $f$.
Answer: Surely, for a function $f(x) = K + ax$ the iteration has a tractable form. Often the iteration is written as $f°^h(x)$ where the tiny circle indicates that the superscripted $h$ means the iteration-"height". For iterates of this $f(x)$ we iterate the insertion of $f(x)$ for $x$ such that we get
$$  \begin{array} {rlllll}
f°^0(x) =& x & \qquad & \\
f°^1(x) =& f(x) & = K + ax \qquad & \\
f°^2(x) =& f(f(x)) & = K + a\cdot f(x) &= K + aK + a^2x \qquad & \\
f°^3(x) =& f(f°^2(x)) & = K + a\cdot f°^2(x) &= K + aK + a^2K + a^3x \qquad & \\
\ldots \\ \\
f°^h(x) =& f(f°^{h-1}(x)) &  &= K(1+a+a^2+...+a^{h-1}) + a^h x \qquad & \\ \\ \\
 =&  K \cdot h+  x && \text{ for }a  = 1 \\
 =&  K { a^h-1\over a-1} + a^h x && \text{ for }a  \ne 1
 \end{array} $$
The key for the first shot here is to insert the function at the place of $x$ (and accordingly at its powers if they occur) and then collect coefficients at like powers of $x$.
While the expression in the above linear function is surely tractable, polynomials of higher degree require much more complicated expressions when iterated and functions, which are given in terms of power series might be very complex or completely intractable when expressed depending on an indeterminate symbol for the iteration-height.

I've found the access to that problem using "matrix-operators" or "Carleman-matrices", which "convert function composition into matrix-multiplication". That is -for the beginning- simply a notational framework for manipulation of formal power series, namely composition and self-composition (aka iteration). And later it gives an indication for iteration to fractional heights by fractional powers of matrices, as far as that can actually be done.
The -perhaps- simplest one of the Carleman-matrices is the Pascal-matrix, which due to the binomial-theorem "implements" the "inc-" function, the mapping of $x^k \to (x+1)^k$  and $h$'s powers of it $x^k \to (x+h)^k$ which for the case of exponent 1 means iteration of the function $f(x) = x+1$ . I write this $ V(x) \cdot P = V(x+1) $ and     $ V(x) \cdot P^h = V(x+h) $ .   Here $V(x)$ means a rowvector of consecutive powers of its argument $x$ of the appropriate dimension (usually infinite), so $V(x)=[1,x,x^2,x^3,...]$ . Then a matrix-multiplication with the Pascal-matrix $$V(x) \cdot P = V(y) = V(f(x))= V(x+1) $$ looks like
$$ \small \begin{array} {rrrrr|r|rr}
  &  &  &  &  & & & 1 & 1 & 1 & 1 & 1 & \cdots \\
  &  &  &  &  & & &. & 1 & 2 & 3 & 4 & \cdots\\
  &  &  &  &  & & &. & . & 1 & 3 & 6 & \cdots\\
  &  &  &  &  &* & & . & . & . & 1 & 4 & \cdots\\
  &  &  &  &  & & & . & . & . & . & 1 & \cdots\\
  &  &  &  &  & & & \vdots & \vdots & \vdots & \vdots & \vdots & \ddots \\
 \hline \\
 [1 & x & x^2 & x^3 & x^4 \ldots] & =& [& 1 & y & y^2 & y^3 & y^4 &\ldots ]
 \end{array}  \\ \  \\ \  \\
 \text {where } y = f(x) = 1+x
$$
Because the result is of the same form as the argument (namely a $V(x)$-vector having the form of consecutive powers of its argument, I call this "Vandermondevector") we see immediately, that this operation can be iterated, and multiple uses of the Carleman-matrix is then simply expressed by its powers and perform iterations of the associated function $f(x)$.
Another convenient example is the Carleman-matrix $S_2$ for the exponential-function $f(x)=\exp(x)-1$ by $$V(x) \cdot S_2 = V(\exp(x)-1) $$ Here the Stirlingnumbers 2nd kind are involved and in the second column of the Carlemanmatrix we recognize the coefficients of the exponential function $f(x)$:
$$ \small \begin{array} {rrrrr|r|rr}
  &  &  &  &  & & & 1 & . & . & . & . & \cdots \\
  &  &  &  &  & & &. & 1 & . & . & . & \cdots\\
  &  &  &  &  & & &. & 1/2 & 1 & . & . & \cdots\\
  &  &  &  &  &* & & . & 1/6 & 1 & 1 & . & \cdots\\
  &  &  &  &  & & & . & 1/24 & 7/12 & 3/2 & 1 & \cdots\\
  &  &  &  &  & & & \vdots & \vdots & \vdots & \vdots & \vdots & \ddots \\
 \hline \\
 [1 & x & x^2 & x^3 & x^4 \ldots] & =& [& 1 & y & y^2 & y^3 & y^4 &\ldots ]
 \end{array}  \\ \  \\ \  \\
 \text {where } y = f(x)= \exp(x)-1
$$
When I began to explore that field I wrote a small treatize, which is still very amateurish and should be updated, but possibly has motivating/orientating power.
If you have access to a library you might look out for the "advanced combinatorics" of L. Comtet; around the pages 140-150 he explains the same thing under the notion of "Bell-polynomials"
A nice article online is "Continuous Iterations of Dynamical Maps" of Aldrovandi/Freitas at arXiv  and for the most general version of Carleman-matrices you might consider articles of Eri Jabotinsky from the 40ties and 50ties of the previous century, which can be found online, too.
Comment: A further nice article with an exposition of the Carleman-matrix-method is by Gralewicz/Kowalski [2000] http://arxiv.org/abs/math-ph/0002044
Answer: $$g(x,n)=\overbrace{f(f(f(...f(x))}^\text{n}$$
You can express $g(x,n)$ in Abel equation.
http://en.wikipedia.org/wiki/Abel_equation
Let's define $h(f(x))=h(x)+1$
$h(f(f(x)))=h(f(x))+1=h(x)+1+1=h(x)+2$
$h(f(f(f(x))))=h(f(x))+2=h(x)+1+2=h(x)+3$
If you continue in that way
$h(\overbrace{f(f(f(...f(x))}^\text{n})=h(g(x,n))=h(x)+n$
If you can find $h(x)$  , you can easily  find $g(x,n)$
$h^{-1}(h(g(x,n))=h^{-1}(h(x)+n)$
$g(x,n)=\overbrace{f(f(f(...f(x))}^\text{n}=h^{-1}(h(x)+n)$
Let's try to find $h(x)$

$$\cfrac{\partial}{\partial n }(h(g(x,n)))=\cfrac{\partial}{\partial n }(h(x)+n)$$
$$h'(g(x,n))\cfrac{\partial(g(x,n))}{\partial n }=1  \tag1$$

$$\cfrac{\partial}{\partial x }(h(g(x,n)))=\cfrac{\partial}{\partial x }(h(x)+n)$$
$$h'(g(x,n))\cfrac{\partial(g(x,n))}{\partial x }=h'(x) \tag2$$

If we divide two equations (1) and (2) then $h'(g(x,n))$ dissapears
$$\cfrac{\partial(g(x,n))}{\partial n }=\frac{1}{h'(x)}\cfrac{\partial(g(x,n))}{\partial x }$$
$$\cfrac{\partial^2(g(x,n))}{\partial n^2 }=\frac{1}{h'(x)}\cfrac{\partial}{\partial x }(\cfrac{\partial(g(x,n))}{\partial n })=\frac{1}{h'(x)}\cfrac{\partial}{\partial x }(\frac{1}{h'(x)}\cfrac{\partial(g(x,n))}{\partial x })$$
$$\cfrac{\partial^3(g(x,n))}{\partial n^3 }=\frac{1}{h'(x)}\cfrac{\partial}{\partial x }(\cfrac{\partial(g(x,n))}{\partial n })=\frac{1}{h'(x)}\cfrac{\partial}{\partial x }(\frac{1}{h'(x)}\cfrac{\partial}{\partial x }(\frac{1}{h'(x)}\cfrac{\partial(g(x,n))}{\partial x }))$$
Taylor series method.
$g(x,n)=f(g(x,n-1))$
$g(x,1)=f(x)=f(g(x,0))$
$g(x,0)=x$
$\cfrac{\partial(g(x,n))}{\partial n }|_{n=0}=\cfrac{1}{h'(x)}\cfrac{\partial(x+n.u(x)+n^2.p(x,n)))}{\partial x }|_{n=0}=\cfrac{1}{h'(x)}(1+nu'(x)+n^2\cfrac{\partial(p(x,n)))}{\partial x }|_{n=0}=\cfrac{1}{h'(x)}$
$\cfrac{\partial^2(g(x,n))}{\partial n^2 }|_{n=0}=\cfrac{1}{h'(x)}(\cfrac{1}{h'(x)})'$
$\cfrac{\partial^3(g(x,n))}{\partial n^3 }|_{n=0}=\cfrac{1}{h'(x)}(\cfrac{1}{h'(x)}(\cfrac{1}{h'(x)})')'$
$$g(x,n)= g(x,0)+n\cfrac{\partial(g(x,n))}{\partial n }|_{n=0}+\frac{n^2}{2!}\cfrac{\partial^2(g(x,n))}{\partial n^2 }|_{n=0}+...$$
$$g(x,n)= x+n\cfrac{1}{h'(x)}+\frac{n^2}{2!}\cfrac{1}{h'(x)}(\cfrac{1}{h'(x)})'+\frac{n^3}{3!}\cfrac{1}{h'(x)}(\cfrac{1}{h'(x)}(\cfrac{1}{h'(x)})')'...$$
If $\cfrac{1}{h'(x)}=w(x)$ then
$$g(x,n)= x+nw(x)+\frac{n^2}{2!}w(x)w'(x)+\frac{n^3}{3!}w(x)(w(x)w'(x))'...$$
$g(x,1)=f(x)=x+w(x)+\frac{1}{2!}w(x)w'(x)+\frac{1}{3!}w(x)(w(x)w'(x))'+...$
$g(x,-1)=f^{-1}(x)=x-w(x)+\frac{1}{2!}w(x)w'(x)-\frac{1}{3!}w(x)(w(x)w'(x))'+...$

To show how it works  in easy example:
If $h(x)=\ln(x)$
$$w(x)=\frac{1}{h'(x)}=x$$
$h(f(x))=h(x)+1$
$$\ln(f(x))=ln(x)+1$$
$$f(x)=e^{ln(x)+1}=ex$$
$$g(x,n)=e^n x$$
$$g(x,n)= x+nw(x)+\frac{n^2}{2!}w(x)w'(x)+\frac{n^3}{3!}w(x)(w(x)w'(x))'...$$
$$g(x,n)= x+nx+\frac{n^2}{2!}x (x)'+\frac{n^3}{3!}x (x)'+...=x(1+n+\frac{n^2}{2!}+\frac{n^3}{3!}+...)=e^n x$$

$$g(x,n)= x+nw(x)+\frac{n^2}{2!}w(x)w'(x)+\frac{n^3}{3!}w(x)(w(x)w'(x))'...$$
$$g(x,-n)= x-nw(x)+\frac{n^2}{2!}w(x)w'(x)-\frac{n^3}{3!}w(x)(w(x)w'(x))'+...$$
$$\frac{g(x,n)-g(x,-n)}{2}= nw(x)+\frac{n^3}{3!}w(x)(w(x)w'(x))'+...$$
$$\lim_{n=0}\frac{g(x,n)-g(x,-n)}{2n}= w(x)=\frac{1}{h'(x)}$$
$$h(x)=\lim_{n\to 0}\int\frac{2n}{g(x,n)-g(x,-n)} dx$$
or
$$h(x)=\lim_{n\to 0}\int\frac{n}{g(x,n)-x} dx$$
It is still hard problem to find $h(x)$.
There can be approximation for $h(x)$
$$g(x,1)=f(x)= x+w(x)+\frac{1}{2!}w(x)w'(x)+\frac{1}{3!}w(x)(w(x)w'(x))'...$$
$$g(x,-1)=f^{-1}(x)= x-w(x)+\frac{1}{2!}w(x)w'(x)-\frac{1}{3!}w(x)(w(x)w'(x))'+...$$
After 3rd terms , If we have small values and so we can write
$$f(x)+f^{-1}(x)-2x \approx w(x)w'(x)$$
$$2\int f(x)+f^{-1}(x)-2x dx \approx w^2(x)+c$$
I still do not know how to write $h(x)$ exactly as series of $f(x)$.


Difference between languages (spoken)?

Question: I'm trying to perform a hierarchical clustering, to aggregate some "zones" or neighborhoods of a city, based on the language that is used most in that zone
In order to do so, I have at hand a dataset provided by Twitter that gives me the coordinates (long and lat) where a tweet was posted and the language in which it is written
So I need an operative definition of distance between two languages!
Any ideas?
EDIT
I actually found this:
https://alternativetransport.wordpress.com/2015/05/05/34/
It just doesn't come with a numerical table of distances, but I'll try to ask for one :)
Comment: I'm afraid that this question would be more on-topic on some kind of linguistic site rather than here...
Comment: Maybe what you need is not a distance between languages, but a classification method to identify the language from the twitter text.
Comment: Twitter already provides it! My task is to see if the neighborhoods that are in a city, actually represent the people that live there from a linguistical point of view
Comment: @Tim: I think a question on how to define & construct a distance metric - rather than on where to find one - would be on-topic, if perhaps a little broad.
Answer: The simplest option might be to ignore distances between languages themselves. You could construct a vector for each neighborhood, where each element corresponds to a language, and the its value corresponds to the number of tweets in that language. The distance function on these vectors would only take into account differences per element, but have no notion of the topology of the elements themselves (e.g. standard $l_2$/cosine/etc. distances).
Adding information about similarity between languages is interesting. Historical linguists have reconstructed trees specifying which languages derived from which others, including reconstructed historical languages like Proto-Indo-European. It's fun to consider measuring distance along these trees, but I have no idea if it would be practically useful.
Maybe it would be possible to do something like look at the extent to which the languages co-occur or are geographically clustered in other parts of the (modern) world. Two languages would be similar if they tend to both be spoken in some other country (or nearby countries).
Comment: Thank you this is an option, but what if I want to see if the neighborhoods, that are set by the city hall, actually represent the people that live inside them from a linguistical point of view?
Comment: It seems like spoken language is a proxy for recent country or region of origin - but earlier immigration - or worse colonisation trends - could see languages that are not linguistically related spoken in the same location, such as in India or Singapore's choices of official languages.

Difference between languages (spoken)?


Existence of solution to Fredholm integral equation of the second kind under a condition on the spectral radius

Question: Consider the Fredholm integral equation of the second kind given by
$$
f(x)=g(x)+\int_a^bk(x,y)f(y)\ \mathrm dy.
$$
In any source I could find online, including some more advanced ones, existence of solutions (and also, uniqueness, and continuous dependence on initial conditions) is proven under conditions like $\|k\|_{\infty}< 1$ or $\sup_{x\in[a,b]}\int_a^b|k(x,y)|\ \mathrm dy<1$. In the textbook Volterrra Integral and Functional equations by Gripenberg, Londen and Steffans, when working on $L^p[a,b]$, this is proven (pages 227 and 235) under the condition that
$$
\|k\|_{p}:=\sup_{\substack{\phi\in L^q[a,b]\\\psi\in L^p[a,b]}}\int_a^b\int_a^b|\phi(x)k(x,y)\psi(y)|\ \mathrm dx\ \mathrm dy<1,
$$
where $p $ and $q$ are conjugate, i.e. $\frac1p+\frac1q=1$. I intend to work on $L^1[a,b]$, with a positive kernel $k$, in which case the condition simplifies to
$$
\sup_{\psi\in L^1[a,b]}\int_a^b\int_a^b|k(x,y)\psi(y)|\ \mathrm dx\ \mathrm dy<1,
$$
i.e. the operator norm $\|T\|_{op}$ of $$T:L^1[a,b]\to L^1[a,b]:f(\cdot)\mapsto \int_a^bk(\cdot,y)f(y)\ \mathrm dy$$ should be bounded by $1$.
My question: to me, it makes sense that essentially we want the operator $T$ to be a contraction. To me, this seems to be the case whenever $\rho(T)<1$, i.e. the spectral radius is bounded by $1$. By Gelfand's formula, this condition is weaker than $\|T\|_{op}<1$. Are there any results on existence (and uniqueness, continuous dependence on initial conditions) under this condition on the spectral radius?
Answer: Im not 100% sure if this is what you are looking for, but it seems like a standard application of the Neumann series to me:
Let $X$ be a Banach space and $T:X \to X$ continuous. So in your special case $X=L^1[a,b]$ and $T$ the integral operator in your question.
Given $g \in X$ we are trying to find $f\in X$ that solves:
$$ g  = (I- T ) f .$$
Now if $ \rho(T) <1$, then the following series converges absolutely (in operator norm) by the root test (geometric series):
$$
(I-T)^{-1} = \sum_{n=0}^\infty T^n.
$$
Therefore
$f = (I-T)^{-1}g $ is the unique solution to the problem and the solution depends continuously on the input $g$, since $(I-T)^{-1}$ is continuous.
Comment: Thank you! It seems that I have been focusing too much on the details of my particular problem instead of on the underlying structure..


What is the Krull dimension of a polynomial ring over a PID?

Question: Recently, I proved this statement:
Proposition: Let $R$ be a PID. The prime ideals of $R[y]$ are precisely the ideals of the following form:

$(0)$,
$(f(y))$ where $f$ is an irreducible polynomial in $R[Y]$
$(p, f(y))$ where $p \in R$ is prime and $f(y)$ is irreducible in $R[y]$ and its image is irreducible in $(R/p)[y]$.

Note: Maximal ideals are of the third form and vice versa.
Using this statement I would like to show that the Krull dimension of $k[x,y]$ is 2 where $k$ is a field. However, I'm stuck at showing that there can't be a chain of prime ideals of the form $\{0\}\subsetneq (f)\subsetneq (p,g)$ i.e a chain involving every ideal of the types shown above.
Any ideas? In the case when R is a general PID would the Krull dimension be 2 or 3?
Comment: These sorts of chains can certainly exist when $R$ is a PID! For example, $(0) \subset (2) \subset (2,x)$ in $\mathbb{Z}[x,y]$. Geometrically, a PID can be either $0$-dimensional (if it is a field) or $1$-dimensional (otherwise), and adjoining a polynomial indeterminate increases the dimension by $1$. So $R[x,y]$ might have dimension $2$ or $3$ in general, and here you need to use the fact that $k$ is a field.
Comment: Oh right sorry my mistake I mistook the length as the length as the number of prime ideals and not the "links"
Comment: More to the point, chains of the form $(0) \subset (f) \subset (p,g)$ tell you that the Krull dimension is at least 2, not at least 3! For example, $k[x,y]$ (which has dimension $2$) contains the chain $(0) \subset (x) \subset (x,y)$. You need to show that there do not exist any chains of the form $0 \subset p_1 \subset p_2 \subset p_3$.
Comment: It's an easy mistake to make! I try to remember that fields have dimension $0$ and a unique prime ideal, so in general the dimension ought to be one less than the number of prime ideals in a maximal chain.
Comment: @JhonDoe You have everything in front of you, and there is no need to invoke general results on Krull dimension of polynomial rings in order to conclude that $\dim R[y]=2$. The ideals of height one are principal, that is, those from 2. The maximal ideals from 3. have height two since $(0)\subsetneq (p)\subsetneq(p,f(y))$ is a maximal chain: if $P$ is a prime containing $p$ and contained in $(p,f(y))$, then $P/(p)$ is a prime in $R/(p)[y]$, so it is generated by a polynomial which is irreducible modulo $p$, and this is necessarily $f(y)$.
Comment: @user26857 i think you also need to argue why there cannot be any other prime ideal between $(0)$ and $(p,f(y))$ (Kaplanski's Lemma gives you that there has to be a principal prime ideal, but I'm not sure why it has to be generated by $p$, or am I missing something?)
Comment: It doesn't matter which primes are in between. We are trying here to find out the maximum length of a chain of prime ideals between $(0)$ and $(p,f(y))$, and the right question is if there are *two* primes $P\subsetneq Q$. Are there?
Answer: Every PID which is not a field has Krull dimension $1$. Also, every PID is Noetherian, and if $R$ is Noetherian whose Krull dimension is $n$, then $R[x]$ has Krull dimension $n+1$. Therefore the answer to your question is that that Krull dimension of $R[y]$ is $2$.
Comment: This requires that the definition of PID excludes fields (which have dimension $0$, but also the property that all of their ideals are principal)
Comment: @diracdeltafunk right, corrected.


Someone Downvoting my answer Without any reason

Question: i just saw in my reputations that someone has down voted  my answers simultaneously with any reason
I there any way that we can restrict that user have to write a proper reason before downvote
Comment: I have also come across this behavior. without any reason, a person downvoted my answer and then gives some what similar answer.
Answer: There is no sign of serial downvoting reported by the admin tools.
I guess someone just didn't like your answers.
For more details you can look on this similar question: Serial Downvoting


Transition functions on invertible sheaves

Question: I'm studying "Foundations of algebraic geometry" by Ravi Vakil. Chapter 14.1 is about invertible sheaves on $\mathbb{P}^1_k$. It says between two affine subsets $\operatorname{Spec}k[x_{1/0}]=U_0$ and $\operatorname{Spec}k[x_{0/1}]=U_1 $ there must be transition functions. I don't completely understand if it means transition functions as vector bundles or it's something else;
So far what I think I have understood is that for a locally free sheaf to be invertible, it must be covered with affine open subsets that are of rank 1; Which means here we have $k[x_{0/1}]$ and $k[x_{1/0}]$ as sections of $U_1$ and $U_0$. Their intersection is $k[x_{0/1},x_{1/0}]$ considering $x_{0/1}\sim \dfrac{1}{x_{1/0}}$. And that from a vector bundle and its sheaf of sections, a locally free sheaf can be obtained.
Sorry if it's a very basic question I couldn't figure it out.
Comment: You might find [this answer](https://math.stackexchange.com/questions/3460771/line-bundles-over-bbb-p1-k/3460918#3460918) helpful.
Answer: $\newcommand{\F}{\mathscr{F}}$$\newcommand{\O}{\mathcal{O}}$The terminology does come from vector bundles but it is more general; transition functions can be thought of as gluing data (cf. Hartshorne exercise II.1.22). In the case of locally free sheaves on a ringed space, we're essentially realizing the sheaf as being a bunch of free sheaves glued together.
Let $\F$ be locally free of rank $n$ on $(X, \O_X)$, where $\{U_i\}$ is a trivializing open cover of $X$. That is, we have an isomorphism $\varphi_i: \O_{U_i}^{\oplus n} \to \F|_{U_i}$ for each $i$. Now, given indices $i, j$ we have composite isomorphisms $$\psi_{ij}: \O_{U_i \cap U_j}^{\oplus n} \stackrel{\phi_i|_{U_i \cap U_j}}\to \F|_{U_i \cap U_j} \stackrel{\phi_j|_{U_i \cap U_j}^{-1}}\to \O_{U_i \cap U_j}^{\oplus n}.$$ These $\{\psi_{ij}\}$ are called the transition functions of $\mathscr{F}$. If you're bored, you can check that the collection $\{\O_{U_i}^{\oplus n}, \psi_{ij}\}$ satisfies the gluing criteria in the quoted exercise, and they glue to form $\F$.


Is there a way to add a function to Odoo kanban cards to have the option to open in a new tab (Odoo 10)

Question: I have a client who loves opening new records in multiple tabs.  Is there a way to modify the kanban open method to include a link to have the option to open in a new tab?
Answer: I realized that I can just wrap some element in an a tag with a custom function to open the record in a new tab. Somewhat of a work around, but I think it will be acceptable for now.
<record id="product_template_kanban_custom" model="ir.ui.view">
        <field name="name">product.template.kanban.custom</field>
        <field name="model">product.template</field>
        <field name="inherit_id" ref="product.product_template_kanban_view" />
        <field name="arch" type="xml">
            <field name="name" position="after">

            </field>
            <xpath expr="//div[1]/div[2]/div[2]" position="after">

<field name="pc_product_name"/>

            </xpath>
        </field>
    </record>

    @api.multi
    def open_kanban_new_tab(self):
        self.ensure_one()
        act_id = self.env.ref('product.product_template_action').id
        menu_id = self.env.ref('pos_custom.custom_search_product_template').id
        return {
            'name': 'Sales Quotation',
            'type': 'ir.actions.act_url',
            'target': 'new',
            'url': '/web?#id=%s&view_type=form&model=product.template&action=%s&menu_id=%s' % (self.id, act_id, menu_id)
        }