Why am i getting PDO exception while running the following test from console?

Question: I am writing a module to return common parent of 2 revision in a linear entity. For example : After editing a node 5 times, we get a graph similar to 1->2->3->4->5 where 1 is the actual node and 5 is the last revision. I wrote a function which would return the common parent of 2 revision ID. It would return 3 for (4,5) and 2 for (3,4). The code is the following one.
namespace Drupal\conflict;

use Drupal\conflict\ConflictManagerInterface;
use Drupal\conflict\ConflictAncestorResolverInterface;

class ConflictManager implements ConflictManagerInterface {

    protected $resolvers = [];

    public function applies() {
        return TRUE;
    }

    public function addAncestorResolver(ConflictAncestorResolverInterface $resolver)
    {
        $this->resolvers[] = $resolver;
    }

    public function resolveLowestCommonAncestor($revision1, $revision2)
    {
        foreach ($this->resolvers as $resolver) {
            if ($resolver->applies()) {
                return $resolver->resolve($revision1, $revision2);
            }
        }
        echo "No revision found";
        return -1;
    }

    public function resolve($revision1, $revision2) {
        if ($revision1 < $revision2) {
            return $revision1-1;
        }
        return $revision2-1;
    }
}

To test the above written code, I have written a test case:
namespace Drupal\conflict\Tests;

use Drupal\Tests\UnitTestCase;
use Drupal\Core\Entity\Entity;
use Drupal\conflict;

class SimpleLcaTest extends UnitTestCase {

    public function basicTest() {
        $entity = EntityTest::create(['label' => 'revision 1']);
        $entity->save();
        $entity->label = 'revision 2';
        $entity->save();
        $entity->label = 'revision 3';
        $entity->save();

        $revision2 = entity_revision_load('entity_test', 2);
        $revision3 = entity_revision_load('entity_test', 3);

        $manager = Drupal::service('conflict.manager');
        $revisionLca = $manager->resolveLowestCommonAncestor($revision2, $revision3);
        $this->assertTrue($revisionLca->label() == 'revision 1');
     }
}

When I try to run test via console using run-test.sh, I get the following error:

Exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'file' cannot be null
Answer: You can't create and save entities in a unit test.
That's what kernel tests are for. You will also need to install the necessary entity schema then, make sure the necessary modules are enabled. One way to do that is to extend from EntityKernelTestBase.
Also, I strongly recommend to run the phpunit tests directly with phpunit, the error reporting is much better and it's faster as well.


Conferir elementos de Listas dentro de outras listas Python

Question: Boas,
Tenho duas listas
lista1 = [0,1,2,3]
lista2 = [0,1,2,3,4,5]

Como é que eu confirmo se todos os elementos da lista1 estão dentro da lista2 ?
Por exemplo :
lista1 = [0,1,2]
lista2 = [1,2,3,4]

lista3 = [0,1,2,3]
lista4 = [0,1,2,3,4]

Todos os elementos da lista1 não estão dentro da lista2 mas todos os elementos da lista3 estão dentro da lista4!
Já tentei fazer isto simplesmente fazendo :
if lista1 in lista2 :
    print('todos dentro')

Mas não funciona !
Alguém me ajuda?
Comment: talvez este [material](http://excript.com/python/for-loop-python.html) possa te dar um ajuda
Comment: Você está querendo aplicar teoria de conjunto em listas, já pensou em utilizar [conjuntos](https://docs.python.org/3.7/library/stdtypes.html#set)? Assim daria para fazer `{0, 1, 2, 3} <= {0, 1, 2, 3, 4, 5} == True`
Comment: Primeiro, precisamos definir um detalhe. A lista `[1, 1]` está na lista `[1, 2]`? Isto é, quando houverem elementos repetidos, deverão ser considerados o mesmo elemento ou distintos?
Comment: @AndersonCarlosWoss Sim, consideramos o mesmo elemento
Answer: if lista1 in lista2 :
    print('todos dentro')

O que você comparou aqui não é se uma lista contém todos os elementos da outra, mas sim se uma lista contém a outra. São coisas distintas.

a = [1, 2], b = [1, 2, 3] (a in b => False)
a = [1, 2], b = [[1, 2], 3] (a in b => True)

Na situação (1) a lista b contém todos os elementos de a; na situação (2) a lista b contém a lista a. Você precisa verificar a situação (1), mas verificou a situação (2).
O que você pode fazer para verificar é fazer um laço percorrendo os elementos da primeira lista e verificar um a um se estão também na segunda lista. Em Python, a maneira mais simples de fazer isso seria:
if all(i in b for i in a):
    print('Todos dentro')

Isto é, verifica se i está em b para todo i que pertence a a.
Ou, como comentado, você pode utilizar teorias de conjuntos. No Python, você pode criar um conjunto a partir de uma lista a partir da estrutura set:
a = set([1, 2])
b = set([1, 2, 3])

E assim utilizar o método set.issubset para verificar se um conjunto é sub-conjunto de outro:
if a.issubset(b):
    print('Todos dentro')

Ou pelo operador <=, que faz a mesma coisa:
if a <= b:
    print('Todos dentro')


C Floating Point to Fixed Point conversion

Question: Hi I am trying to make a converter between floating points and fixed point representation without using any library function to do it. So far, the fixed point representation is 16 bits with 10 for the whole number part and 6 for the fractional part. I have been googling and found a possible solution.
inline fixed_point_t double_to_fixed(double input)
{
    return (fixed_point_t)(input * (1 << FIXED_POINT_FRACTIONAL_BITS));
}

inline double fixed_to_double(fixed_point_t input)
{
    return ((double)input / (double)(1 << FIXED_POINT_FRACTIONAL_BITS));
}

I am struggling to understand the logic behind it. Could someone help explain? And in this case how would the fractional bits be truncated by C down to just 6 bits
Answer: How's this:
Sample number = 123.4567890 (base 10)
Still in base 10, convey that same number with "3 fixed point decimals".
To form that value, multiply by 10^3 and drop the remaining decimals.
123.456789 * 1000 => integer == 123457 (or 123_457 where '_' represents the "fixed decimal point".)
This is a base 10 example of the conversion to fixed decimal.
It should be apparent that it can be reversed by dividing by 1000. (The lost precision is lost and cannot be restored.
Now, instead of operating in base 10, do the same thing(s) with a floating point value (float or double) expressed in base 2.
It's that simple. It's just a matter of degree...
Answer: Lets say you want a fixed point type using 2 fractional bits. The bit pattern
000...0000111  (7 decimal)

would then represent the value
1 + 0.5 + 0.25 = 1.75

Now consider the floating point calculation
7 / (1 << 2) = 7 / (2^2) = 7 / 4 = 1.75  (where ^ is power-of)

This is exactly how it works.
You get from the full integer representation of your fixed point variable to the floating point value by dividing by "2 to the power of NUMBER-OF-FRACTIONAL-BITS"
Comment: thank you for the response! could you help explain the double_to_fixed? when you have time
Answer:
to understand the logic behind it.

It is roughly:
fixed_point_t double_to_fixed(double input): multiply input by 26 and convert to an integer.
double fixed_to_double(fixed_point_t input): convert to a double and divide by 26.

found a possible solution.

The following has some weaknesses:
inline fixed_point_t double_to_fixed(double input)
{
    return (fixed_point_t)(input * (1 << FIXED_POINT_FRACTIONAL_BITS));
}

"And in this case how would the fractional bits be truncated by C down to just 6 bits" --> Yes, bits in input with values less than 2-6 are silently discarded.  Consider rounding.

Cast of (fixed_point_t), some integer type, risk undefined behavior should input be much outside the (fixed_point_t) range.

1 << FIXED_POINT_FRACTIONAL_BITS is a problem starting when FIXED_POINT_FRACTIONAL_BITS > 15.  Use a right-sized type for the 1.

With additional code to handle above, perhaps drop the inline.

Example:
#include <errno.h>
#include <stdint.h>

#define FIXED_POINT_FRACTIONAL_BITS 6
typedef int16_t fixed_point_t;
#define FIXED_POINT_I_MAX INT16_MAX
#define FIXED_POINT_I_MIN INT16_MIN
// Use the right width type for forming constants.
#define FIXED_POINT_C INT16_C

fixed_point_t double_to_fixed(double input) {
  input *= FIXED_POINT_C(1) << FIXED_POINT_FRACTIONAL_BITS;
  // Round ties away from zero by adding 0.5. (Other rounding modes possible.)
  // Works OK when the sum is exact.
  input += (input < 0) ? -0.5 : 0.5;

  // Avoid this form as FIXED_POINT_I_MAX + 1 may wrap
  // if (input >= (FIXED_POINT_I_MAX + 1)) {
  if (input >= (FIXED_POINT_I_MAX/2 + 1)*2.0) {
    errno = ERANGE;
    return FIXED_POINT_I_MAX;
  }

  // Avoid this form as FIXED_POINT_I_MIN - 1 as a FP may be inexact
  // if (input <= (FIXED_POINT_I_MIN - 1)) {
  if (input - FIXED_POINT_I_MIN <= -1) {
    errno = ERANGE;
    return FIXED_POINT_I_MIN;
  }

  return (fixed_point_t)input;
}

double fixed_to_double(fixed_point_t input) is mostly OK.  When the precision of the fixed point (6 in OP's case) exceeds a double (53) is that a concern.


$_POST retorna Undefined index

Question: Bom, eu estou tentando fazer um sistema de login, porém o meu $_POST retorna erro "Undefined index" e em todo lugar eu encontro a mesma coisa e mesmo assim da erro.
Html:
<form action="submit.php" method="post">

        Email
        <input tabindex="2" type="text" name="credentials.username" id="credentials-email" value="">

        Senha
        <input tabindex="3" type="password" name="credentials.password" id="credentials-password">

        <input type="submit" value="Login">
        Login

...

E o php: echo $_POST['credentials.username'];
pra mim não tem nenhum erro, só que mesmo assim ele não retorna o valor da input
Comment: Nunca vi um ponto sendo usado como separador nesse tipo de situação... e se trocar por `credentials-username`?
Comment: Ele troca automaticamente o ponto pra underscore
Comment: Para pegar o valor faça como @ZebraDoMal falou use `$_POST['credentials_username']` pode testar no submit.php dando um `print_r($_POST);` assim verá as chaves do array.
Comment: Cara, tu tem duas opções, ou faz o que te disse com foreach, ou usa credentials_username.
Comment: No Post eu tive que por _ porém no Input continuou . assim como o ZebraDoMal e o perdeu falou
Comment: Testa aí fazer um foreach criando um novo array onde você substitui (pode ser com str_replace) o underscore por um ponto. E depois coloca $_GET = $seu_novo_array.
Comment: Não entendi, como assim usar o foreach pra converter o . em _?
Comment: Funcionou :D Vlw.
Comment: Como eu escrevi lá em cima, o php converte o ponto logo pra underscore. Você pode continuar usando o ponto lá no get, mas aí você precisa fazer um novo array onde você substitua o underscore por um ponto e depois atribua ao $_GET o valor do seu novo array.
Answer: Isso funciona:
 <form action="go2.php" method="post">
 <input type=text name="valor.test.op" value="" />
 <input type="submit" value="Login">
 </form>

E no lado do PHP
 <?php

 echo $_POST['valor_test_op'];

?>

Mas mesmo se esta certo, acho o melhor e evitar os pontos no nome, em HTML
Comment: Peter, eu já consegui porém não entendo o porque de ter que se evitar o . (ponto) no Html?

$_POST retorna Undefined index


WebGrid - Sorting by navigation property's field when null reference

Question: I'm using System.Web.Helpers.WebGrid to display an IEnumerable<Request>. Requests have some navigation properties.
Whenever I sort by clicking in the title by any of those's field, exception Object reference not set to an instance of an object. rises.
I code this type of columns this way:
grid = new WebGrid(Model.Requests);

// things

@grid.GetHtml(columns: new[]{
    //[...] columns
    SDMs.Column("User.Name", "User", format: p => p.User != null ? p.User.Name : ""),
    //[...] more columns
})

Note that I'm using the format parameter to set a custom result on grid loading.
I think this happens because of the rows that don't have an User associated, but I don't know how to customize the behaviour on these cases.
I found out this on the web, but I don't seem to have this method in my version of the assembly. I don't know how to get it either. I tryed installing NuGet packages but didn't help.
Any ideas?
Comment: You can pass to the view only that item which having user not null for example.
Comment: I need the rows that have no user to appear too; as blanks.
Comment: Please check my anwer, is this makes sense for you?
Answer: Add an extension method/ partial class's property for the Request, like ActualOrEmptyUserName.
And in the Getter, you can check the User is populated or not, if so return user.name else return "".
And in your grigview, you tie the column to the ActualOrEmptyUserName insetad of user.name
public partial class Request
    {
        public string ActualOrEmptyUserName
        {
            get
            {
                var username = "";
                if (Request.User != null && Request.User.Name != null)
                    username = Request.User.Name;

                return username;
            }
        }
    }

...

SDMs.Column("ActualOrEmptyUserName", "User")

Another option:
Itarete (or linq) trough your list, and check the value of user, if it is null, then create an empty user to that value and fill the Name with string.empty or "".
This itaration can be in you controller or the upper part of the view. this is up to you.
But i guess you cannot use the format like as you tried.
Comment: I like the looks of that first option. I will be trying this soon. If it works fine, I will accept it. Thanks!


Select condicional que pega valor de outra tabela

Question: Preciso fazer um select condicional que verifica uma soma realizada dessa forma:
select round(sum((`gin`.`Caixa_9L` / 1000)),1) AS `total` from `gin`

Se essa soma acima for = 0, preciso pegar um valor de um campo em uma outra tabela (chamada asterisco) e exibir como total.
Estou iniciando em sql e estou com um pouco de dificuldade pra definir essa lógica.
Answer: select case CAIXA_9L when ( round(sum((Caixa_9L / 1000)),1)  = 0 ) then
     ( select outrocampo from asterico ) /* não pode retornar mais de um registro esse subselect */
else
     ( round(sum((Caixa_9L / 1000)),1)  = 0 )
end as total from gin

Comment: Você referenciou no from só a tabela gin, a tabela asterisco não precisa? Quando eu rodo aqui, ele me diz que gin.asterico não existe.
Comment: Amigo, testei o código com algumas adaptações e esta ocorrendo o seguinte: Quando o campo Caixa_9l tem um valor registrado como zero, a query não acrescenta * mas 0.0, quando o campo Caixa_9l contem pelo menos 1 (uma unidade), ele coloca o *. O que pode ser isso?
Comment: `select
marca,
case
 gin.Caixa_9L when (round(sum(caixa_9l/1000),1)= 0) then (select asterisco.asterisco from asterisco)
else
 (round(sum((Caixa_9L/1000)),1))
end
as valor
from gin
where sales_channel = 'duty paid' or sales_channel = 'travel retail'
group by marca` Minha query ficou assim.


Program to check if Magic Square python

Question: I am trying to use python to create a program that will decide based on a text file if a square is a magic square.

def getRowsAndColumns(user2DimensionalList):
  numberOfRows = len(user2DimensionalList)
  numberOfColumns = len(user2DimensionalList[0])

  return numberOfRows, numberOfColumns

def getFirstRowSum(user2DimensionalList, numberOfColumns):
  firstRowSum = 0

  for currentRowIndex in range(1):
    for currentColumnIndex in range(numberOfColumns):
      firstRowSum = firstRowSum + user2DimensionalList[currentRowIndex][currentColumnIndex]

    return firstRowSum

def hasEqualRowSums(user2DimensionalList, firstRowSum, numberOfRows, numberOfColumns):
  rowSum = 0

  for currentRowIndex in range(numberOfRows):
    for currentColumnIndex in range(numberOfColumns):
      rowSum = rowSum + user2DimensionalList[currentRowIndex][currentColumnIndex]
    if rowSum != firstRowSum:
      return False
    rowSum = 0

  return True

def hasEqualColumnSums(user2DimensionalList, firstRowSum, numberOfRows, numberOfColumns):
    columnSum = 0
    for currentColumnIndex in range(numberOfColumns):
      for currentRowIndex in range(numberOfRows):
          columnSum = columnSum + user2DimensionalList[currentRowIndex][currentColumnIndex]
      if columnSum != firstRowSum:
          return False
      columnSum = 0

    return True

def hasEqualRowAndColumnSums(user2DimensionalList, firstRowSum, numberOfRows, numberOfColumns):
  if hasEqualRowSums(user2DimensionalList, firstRowSum, numberOfRows, numberOfColumns) and hasEqualColumnSums(user2DimensionalList, firstRowSum, numberOfRows, numberOfColumns):
       return True
  else:
       return False

def hasFromLeftEqualDiagonalSum(user2DimensionalList, lengthOfAnyRowOrColumn, firstRowSum):
  fromLeftDiagonalSum = 0

  for currentDiagonalNumberIndex in range(lengthOfAnyRowOrColumn):
    fromLeftDiagonalSum = fromLeftDiagonalSum + user2DimensionalList[currentDiagonalNumberIndex][currentDiagonalNumberIndex]

  if fromLeftDiagonalSum != firstRowSum:
    return False
  else:
    return True

def hasFromRightEqualDiagonalSum(user2DimensionalList, lengthOfAnyRowOrColumn, firstRowSum):
    fromRightDiagonalSum = 0
    currentDiagonalNumberColumnIndex = lengthOfAnyRowOrColumn - 1

    for currentDiagonalNumberRowIndex in range(lengthOfAnyRowOrColumn):
        fromRightDiagonalSum = fromRightDiagonalSum + user2DimensionalList[currentDiagonalNumberRowIndex][currentDiagonalNumberColumnIndex]
        currentDiagonalNumberColumnIndex = currentDiagonalNumberColumnIndex - 1
    if fromRightDiagonalSum != firstRowSum:
        return False
    else:
        return True
def hasEqualDiagonalSums(user2DimensionalList, lengthOfAnyRowOrColumn, firstRowSum):
    if hasFromLeftEqualDiagonalSum(user2DimensionalList, lengthOfAnyRowOrColumn, firstRowSum) and hasFromRightEqualDiagonalSum(user2DimensionalList, lengthOfAnyRowOrColumn, firstRowSum):
        return True
    else:
        return False

def isLoShuMagicSquare(user2DimensionalList, firstRowSum, numberOfRows, numberOfColumns, lengthOfAnyRowOrColumn):
    if hasEqualRowAndColumnSums(user2DimensionalList, firstRowSum, numberOfRows, numberOfColumns) and hasEqualDiagonalSums(user2DimensionalList, lengthOfAnyRowOrColumn, firstRowSum):
        return True
    else:
        return False

def main():
    user2DimensionalList = open("input.txt", "r")
    user2DimensionalList = user2DimensionalList.read()

    numberOfRows, numberOfColumns = getRowsAndColumns(user2DimensionalList)

    lengthOfAnyRowOrColumn = numberOfRows

    firstRowSum = getFirstRowSum(user2DimensionalList, numberOfColumns)

    if isLoShuMagicSquare(user2DimensionalList, firstRowSum, numberOfRows, numberOfColumns, lengthOfAnyRowOrColumn):
        print("VALID")
    else:
        print("INVALID")

main()

Here is what is in my txt file:

4 3 8 9 5 1 2 7 6
8 3 4 1 5 9 6 7 2
6 1 8 7 5 3 2 9 4
6 9 8 7 5 3 2 1 4
6 1 8 7 5 3 2 1 4
6 1 3 2 9 4 8 7 5
5 5 5 5 5 5 5 5 5

I can't figure out what I am doing wrong I get this error:

Traceback (most recent call last):
  File "/Users/noahhenkle/Desktop/MagicSquare2.py", line 98, in <module>
    main()
  File "/Users/noahhenkle/Desktop/MagicSquare2.py", line 91, in main
    firstRowSum = getFirstRowSum(user2DimensionalList, numberOfColumns)
  File "/Users/noahhenkle/Desktop/MagicSquare2.py", line 12, in getFirstRowSum
    firstRowSum = firstRowSum + user2DimensionalList[currentRowIndex][currentColumnIndex]
TypeError: unsupported operand type(s) for +: 'int' and 'str'

I am almost certain the code is right but that the txt file is messing everything up.
I included the traceback below.
Comment: Post the whole error message with traceback please.
Comment: I added what you need
Answer: Very simply, you read in a bunch of character data, without ever converting to integer.  Then you try to perform arithmetic on the data, starting with an integer value of 0.
At some point, you have to convert your values.  At the moment, you have a 126x1 "2Dim list".  Your attempt to sum the row starts with trying to add 0 + "4".
I strongly recommend that you revert to incremental programming.  You posted 100 lines of code without testing the input that feeds the rest of the program.

Program to check if Magic Square python


delete words between specified characters with sed

Question: i have a file this format :
Word1 : "Word2" Word3
I want to remove "Word2"
Then file must be like this :
Word1 : Word3
How can i do this with sed?
Note : Word2 is changeable
Answer: If there is no extra stuff in the input_file, just substitute every quoted phrase with empty string:
sed 's/"[^"]*"//' input_file

Comment: +1, but: strictly speaking, sed is supposed to use Basic Regular Expressions, so \+ should not be valid (but is accepted by many sed implementations).  I think it is probably better to use `*` here, though, since the quoted string may be empty.
Answer: From the command line try
$ sed -i 's/\"Word2\"//g' /path/to/file.txt

Answer: If test is your file, try:
# cat test | sed -r 's/\".+\"\ //'

Answer: If file.txt is your file, you can try this from command line:
sed -e "s_: \"[a-zA-Z0-9]*\" _: _g" -i file.txt

Comment: if i have non-latin characters? :) like "Версия"
Comment: try with: `sed -e "s_: \"[^\"]*\" _: _g" -i file.txt` ;)
Answer: based on the given input. say, Word2 could be anything, but Word1 and Word3 are fixed. sed/awk oneliner could do the job 4 u:
kent$  echo 'Word1 : "Word2" Word3'|sed -r 's/(Word1 :) "[^"]*"( Word3)/\1\2/g'
Word1 : Word3

kent$  echo 'Word1 : "Word2" Word3'|awk -F"\"" '{print $1,$3}'
Word1 :   Word3


Simple ODE Analytical Solution Question: $\frac{dx}{dt} = ax + bu$

Question: my question is in regards to the following formula:
\begin{align}
\frac{dx}{dt}=ax+bu
\end{align}
where x(0)=0 & u=constant and a & b are scalar
The answer to this or at least what I was given as the answer is the following:
\begin{align}
x=-\frac{bu}{a}(1-e^{at)}
\end{align}
Now I understand that I need to manipulate the formula and integrate both sides. Utilizing the integration table I perform the following:
Since u=constant we can then say bu=b therefore:
\begin{align}
\frac {dx}{ax+b}= {dt}
\end{align}
\begin{align}
\int \frac {dx}{ax+b}= \int{dt}
\end{align}
\begin{align}
\frac{1}{a}ln|ax+b| = t + C
\end{align}
\begin{align}
e^{ln|ax+b|} = e^{(t + C)a}
\end{align}
\begin{align}
ax+b = e^{at+Ct}
\end{align}
\begin{align}
x = -\frac{b}{a} \frac{e^{at}e^{Ct}}{a}
\end{align}
I do not see where I am going wrong in the calcs above. I would appreciate any help in identifying where I went wrong.
Thank you
Comment: Actually you should have $ax+b=\pm e^{a(t+C)}$ after you remove the absolute value signs. (Unless it's given that $b>0$.) Then with $x(0)=0$ you get $b=\pm e^{aC}$. I would recommend solving such an equation using the method of integrating factor instead, then there are no pitfalls like this.
Answer: $$\begin{align}
x = -\frac{b}{a} \frac{e^{at}e^{Ct}}{a}
\end{align}$$
This line isn't correct, it should be:
$$\begin{align}
x = -\frac{b}{a} +\frac{e^{(t+C)a}}{a}
\end{align}$$
Comment: Thank you much appreciated.
Comment: yw @cylus hop it helped you...
Answer: You reached upto
$$ax+B = e^{at+\color{red}{Ca}} \implies ax=e^{(t+C)a}-B \implies x=\frac{1}{a}\left(e^{(t+C)a}-B\right)$$
Now you need to use the given information : when $x=0, t=0$ too.
$$0=\frac{1}{a}\left(e^{(0+C)a}-B\right) \implies e^{aC}=B$$
Now put this back into your equation to get
$$x=\frac{1}{a}\left(e^{aC}\cdot e^{at}-B\right)=\frac{1}{a}\left(B\cdot e^{at}-B\right)$$
And replace$B$ with $bu$, to get
$$x=-\frac{bu}{a}\left(1-e^{at} \right)$$
Comment: Thank you. Mistake seemed to have snowballed.
Comment: Welcome @cylus. Glad to help!
Answer: It is right up to the third-to-last step, so you did the calculus correctly and slipped up on the algebra (it happens to everyone :D):
$$e^{\ln{|ax+b|}}=e^{(t+C)a}$$
Then you accidentally distributed the wrong letter in the exponent on the RHS, so the next step should be:
$$ax+b=e^{at+Ca}$$
Of course, $e^{Ca}$ is just a constant, so replace it by $c$:
$$ax+b=e^{at+Ca}=e^{at}e^{Ca}=ce^{at}$$
Then, solve for $x$:
$$x=\frac{ce^{at}-b}{a}=\frac{ce^{at}}{a}-\frac{b}{a}$$
To bring it into the required form, first factor out $-\frac{b}{a}$:
$$x=-\frac{b}{a}\left(1-bce^{at}\right)$$
Then replace $b$ back with $bu$:
$$x=-\frac{bu}{a}\left(1-buce^{at}\right)$$
Then use $x(0)=0$ to conclude that $buc=1$, and you're done.
Comment: Thank you for the reply. Was looking at the problem for some time and didn't see the mistake which ended up snow balling. Thx.
Comment: No problem, happy to help.


How to get if question is really edited or not by some one?

Question: I was asked below question on magentoSE but after some times someone edited it, And when i see there is nothing changes in it. So when a question edited, the portion of editing should be marked as edit OR a note should be bottom of questions automatically added what is edit.
magento-2-block-ordering-moving
Comment: And what is your question here?
Comment: @Marius: as labeled discussion. Please read description...
Answer: I think there is no need of explanation for that edit. user delete only 2 character you can see it here.
https://magento.stackexchange.com/posts/151893/revisions
Comment: Thanks buddy. To show me this which actually don't konws.


Apache2 uses http instead of https, despite LetsEncrypt

Question: Background
I have an Ubuntu 16.04 server running Apache/2.4.18 (Ubuntu). I installed lets-encrypt from github and ran ./letsencrypt-auto --apache, choosing the second option from the following dialog:
Please choose whether HTTPS access is required or optional.
------------------------------------------------------------------
1: Easy - Allow both HTTP and HTTPS access to these sites
2: Secure - Make all requests redirect to secure HTTPS access
------------------------------------------------------------------

which resulted in the message
Congratulations! You have successfully enabled
my.own.server.tld

and an auto-generate virtual host file. Then I restarted the server.
The Problem
I tried to access my site, which worked with http (no problems), but not with https (Firefox and Chrome tried to load the page and timed out after two minutes). I expected the site to be available exclusively via https, or at least via https at all.
Configuration
There is only one file in /etc/apache2/sites-enabled/:
my.own.server.tld-le-ssl.conf
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName my.own.server.tld

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLCertificateFile /etc/letsencrypt/live/my.own.server.tld/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/my.own.server.tld/privkey.pem
        Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

where /etc/letsencrypt/options-ssl-apache.conf was also auto-generate by lets-encrypt and looks like
SSLEngine on

# Intermediate configuration, tweak to your needs
SSLProtocol             all -SSLv2 -SSLv3
SSLCipherSuite          ECDHE-RSA-AES128-GCM-SHA256:...
SSLHonorCipherOrder     on
SSLCompression          off

SSLOptions +StrictRequire

# Add vhost name to log entries:
LogFormat "..." vhost_combined
LogFormat "..." vhost_common

The ... parts are not literally in the file – I just omitted these parts to make this question more readable.
What I Tried

Reloading/Restarting apache.
Restarting the complete server.
a2enmod ssl (prints Module ssl already enabled).
Writing <Directory /> SSLRequireSSL </Directory> inside the VirtualHost configuration. (Did not change anything. Website was still accessible using http, but not accessible using https.)
Writing SSLRequireSSL into /var/www/html/.htaccess. (Did not change anything. Website was still accessible using http, but not accessible using https.)

Additional Information
The server my.own.server.tld is running at my university. I only control the my part and have neither knowledge nor control over the underlying system, but I guess my server is an OpenStack instance. The server should have just one IP.
apache2ctl -S prints

VirtualHost configuration:
*:443                  my.own.server.tld (/etc/apache2/sites-enabled/my.own.server.tld-le-sll.conf:2)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

netstat -pant | grep apache2 prints
tcp6    0    0 :::80     :::*    LISTEN    8592/apache2
tcp6    0    0 :::443    :::*    LISTEN    8592/apache2

netstat -l46n prints
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp        0      0 0.0.0.0:22    0.0.0.0:*       LISTEN
tcp6       0      0 :::80         :::*            LISTEN
tcp6       0      0 :::22         :::*            LISTEN
tcp6       0      0 :::443        :::*            LISTEN
udp        0      0 0.0.0.0:68    0.0.0.0:*

telnet localhost 443 prints the expected output.
iptables -L -n prints
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
f2b-sshd   tcp  --  0.0.0.0/0            0.0.0.0/0            multiport dports 22

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain f2b-sshd (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

There are no errors in /var/log/apache2/error.log.
Answer:
Did https ever work before or stopped working once you switched to Let's Encrypt?
Is your server an Amazon EC2 instance? (Potential issue with security groups)
This similar question gives some ideas worth trying Why is https not working?:

Try connecting to the https port via telnet to see if it is reachable from the server itself. It should look like the following:
    $ telnet localhost 443
    Trying 127.0.0.1...
    Connected to localhost.localdomain (127.0.0.1).
    Escape character is '^]'.

What do your firewall rules look like? (iptables -L -n)
Is the https virtualhost pointing to the same folder as the http one? (Permission issue)
Anything in the in the apache error log? (/var/logs/apache2/error.log by default)
Does your server have multiple IPs configured?
Run netstat -pant | grep apache2 to see if apache is listening on port 80 and 443

By the way: If you want users to access your site only via https you need to configure something like this in the http Virtualhost to redirect them to https:
<VirtualHost *:80>
        ServerName my.own.server.tld
        ServerAlias www.my.own.server.tld
        RewriteEngine On
        RewriteCond %{SERVER_PORT} !443
        RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}/$1 [R=301,L]
        RewriteCond %{SERVER_NAME} =www.my.own.server.tld
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

Comment: `openssl` also times out. A port scan with `nmap` shows that only port 22 (ssh) and 80 (http) are opened. I try to contact the person in charge and ask if they block port 443.
Comment: Thank you for your answer. I updated the question with the wanted information. Regarding the question »*Is the https virtualhost pointing to the same folder as the http one?*«: There is only one virtualhost (https). The paths and permissions seem to be right.
Comment: Time to dig deeper. Try running **openssl s_client -connect my.own.server.tld:443** from your PC (If you got OpenSSL downloaded / installed) to see if the SSL handshake works or gives any clues. Try a portscan from your PC to see if port 443 is reachable (If allowed by your university). Alternatively try with telnet (or putty) to reach port 443. You could also capture the network traffic with Wireshark / Netmon to look for clues.
Comment: Thanks to your comments I found out, that the hoster blocked port 443. I contacted the hoster and asked him to open port 443. Now everything works.
Answer: I got my cert w/ LE via the certonly option.  Then modify your apache site definition to be:
<VirtualHost _DEFAULT_:443>
    ServerName example.com
    ServerAlias www.example.com
    ServerAdmin firstname.lastname@example.com
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
    CustomLog ${APACHE_LOG_DIR}/ssl_request_log "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    DocumentRoot /var/www-example.com
    <directory /var/www-example.com>
        Options All
                AllowOverride All
                Require all granted
    </directory>
    ErrorLog ${APACHE_LOG_DIR}/ssl-example.com-error.log
    CustomLog ${APACHE_LOG_DIR}/ssl-example.com-access.log combined
</VirtualHost>

Then enable SSL in apache - a2enmod ssl - and then restart apache2.
The output of apache2ctl -S you show looks like it is correct - if you (re)start apache2 does it show as listening if you look via netstat -l46n ?
Comment: Thank you for the answer. I copied your config, adapted the paths and domains, enabled mod_ssl (which was already enabled) and restartet the server. Sadly nothing did change. `service apache2 restart` does not print anything – it just restarts the server.
Comment: What is output of `netstat -l46n`  ?  Do you see 443 listed?
Comment: The question was edited to include the output of `netstat -l46n` (So far I thought `netstat -pant | grep apache2` already gave the required information). Port 443 is listed.
Answer: SSLCertificateFile /etc/letsencrypt/live/my.own.server.tld/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/my.own.server.tld/privkey.pem

The pem file is just a container file and is not a certificate in itself. You will need a CRT file.
Comment: Thank you for your answer. Are you sure that I have to use a CRT file? It seemed like [ivanivan](https://serverfault.com/a/846127/411978) had no problems using the PEM files on his server; lets-enrypts's auto-generated config worked for me on another server; and the [official manual](http://letsencrypt.readthedocs.io/en/latest/using.html#where-are-my-certificates) says to use the PEM files. Which files should I convert to CRT, `fullchain` and `privkey` or just one of them?
Comment: Thats the way I have used SSL with apache. I usually generate a CSR (Certificate Signing Request) then generate the CRT (Certificate). Never used a PEM file or KEY file to establish SSL.
Comment: Convert the fullchain.pem that is likely to contain the chain of certificates from the ROOT Certificate.
Comment: I checked the Apache documentation. Your configuration seems right. Just wondering if you are using a version of apache that supports those directives. You should be on Apache 2.4.8
Comment: I'm using the Ubuntu version of Apache 2.4.18, as stated in the question. The problem is now resolved. Thank you for your inputs.
Comment: Using .pem files is the way Let's Encrypt deploys the certificates. They are valid certificates with a different file ending.


Find the derivative of $f$ if it exists, else, prove it doesn't exist

Question: Let $f:  \mathbb R^+ \to  \mathbb R $
$$f=\mathop{\vcenter{\LARGE\mathrm K}}\limits_{j=1}^{+\infty}\frac{x}{x^j}=\cfrac{x}{x^1+\cfrac{x}{x^2+\cfrac{x}{x^3+\ddots}}}$$
I saw this problem in a math challenges magazine, I have no idea how this would be solved but thought it seemed really interesting.
Comment: @Math1000: it is a shorthand notation for a (generalized) continued fraction.
Comment: What exactly is meant by $\LARGE\mathrm K$? I haven't seen that notation before.
Comment: This is just a variant of the [Rogers-Ramanujan continued fraction](http://en.wikipedia.org/wiki/Rogers%E2%80%93Ramanujan_continued_fraction)
Answer: We have:
$$ f(x) = \cfrac{x}{x^1+\cfrac{x}{x^2+\cfrac{}{}}}=\cfrac{1}{1+\cfrac{1/x^2}{1+\cfrac{1/x^4}{1+\ldots}}}=x^{2/5}\,R\left(\frac{1}{x^2}\right)\tag{1}$$
where $R(q)$ is the Rogers-Ramanujan continued fraction, so:
$$ f(x) = \prod_{k\geq 0}\frac{(1-\frac{1}{x^{10k+2}})(1-\frac{1}{x^{10k+8}})}{(1-\frac{1}{x^{10k+4}})(1-\frac{1}{x^{10k+6}})}\tag{2}$$
and $f'(x)$ can be computed as $f(x)\cdot\frac{d}{dx}\log f(x)$, where the logarithmic derivative of $f(x)$ is given by a nice series. It is also interesting to recall that by setting $u=R(q)$ and $v=R(q^2)$ we have:
$$ v-u^2 = (v+u^2) uv^2. \tag{3}$$
Since $R(q)$ is an analytic function over the unit ball, $f(x)$ is an analytic function over $(1,+\infty)$.


How to find specific frequency of a codon?

Question: I am trying to make a function in R which could calculate the frequency of each codon.
We know that methionine is an amino acid which could be formed by only one set of codon ATG so its percentage in every set of sequence is 1. Where as Glycine could be formed by GGT, GGC, GGA, GGG hence the percentage of occurring of each codon will be 0.25.
The input would be in a DNA sequence like-ATGGGTGGCGGAGGG and with the help of codon table it could calculate the percentage of each occurrence in an input.
please help me by suggesting ways to make this function.
for example,
if my argument is ATGTGTTGCTGG
then, my result would be
ATG=1
TGT=0.5
TGC=0.5
TGG=1

Data for R:
codon <- list(ATA = "I", ATC = "I", ATT = "I", ATG = "M", ACA = "T",
    ACC = "T", ACG = "T", ACT = "T", AAC = "N", AAT = "N", AAA = "K",
    AAG = "K", AGC = "S", AGT = "S", AGA = "R", AGG = "R", CTA = "L",
    CTC = "L", CTG = "L", CTT = "L", CCA = "P", CCC = "P", CCG = "P",
    CCT = "P", CAC = "H", CAT = "H", CAA = "Q", CAG = "Q", CGA = "R",
    CGC = "R", CGG = "R", CGT = "R", GTA = "V", GTC = "V", GTG = "V",
    GTT = "V", GCA = "A", GCC = "A", GCG = "A", GCT = "A", GAC = "D",
    GAT = "D", GAA = "E", GAG = "E", GGA = "G", GGC = "G", GGG = "G",
    GGT = "G", TCA = "S", TCC = "S", TCG = "S", TCT = "S", TTC = "F",
    TTT = "F", TTA = "L", TTG = "L", TAC = "Y", TAT = "Y", TAA = "stop",
    TAG = "stop", TGC = "C", TGT = "C", TGA = "stop", TGG = "W")

Comment: It looks like your sample data is for python. Did you mean to tag that instead of R? Or (based on the text of your question) did you forget to provide an R structure for sample data?
Comment: I've suggested an edit that includes an R structure. If that is not desired, my apologies, I can remove it.
Comment: Thank you for this edit, sorry for that.
Comment: It isn't clear what the `"C"` for `"TGT"` is supposed to mean, and how this is supposed to know that you're trying to make Glycine meaning 0.25. It might help to spell-out how you calculated `TGT=0.5` (and the others) based on the structure you provided.
Comment: TGT  and TGC codes for C in DNA sequence hence probability of formation of C by TGC is 50% and for TGT is also 50%. This is same for the rest of the amino acids. This problem is based on codon usage
Comment: Do you mean that because there are two `"C"` within `codon`, that both `TGC` and `TGT` are required to make Glycine? (How the heck am I supposed to know that Glycine corresponds to `"C"`?) Does this mean that four things are needed to make `"A"`: `GCA`, `GCC`, `GCG`, and `GCT`?
Comment: Assuming that is the case, then you have two "problems" to solve: (1) translate from `list(TGT="A")` to `list(TGT=0.5)`; and (2) split a string into substrings of length 3, *assuming it is always a perfect multiple of 3*. After that, you have a perfect look-up table.
Comment: @r2evans not in a full term.
Answer: A slightly different path leads to this solution:
f0 <- function(dna, weight) {
    codons <- regmatches(dna, gregexpr("[ATGC]{3}", dna))
    tibble(id = seq_along(codons), codons = codons) %>%
        unnest() %>%
        mutate(weight = as.vector(wt[codons]))
}

First, codon is just a named vector, not list; here are the weights
codon <- unlist(codon)
weight <- setNames(1 / table(codon)[codon], names(codon))

Second, probably there is a vector of DNA sequences, rather than one.
dna <- c("ATGTGTTGCTGG", "GGTCGTTGTGTA")

To develop the solution, codons can be found by searching for any nucleotide [ACGT] repeated {3} times
codons <- regmatches(dna, gregexpr("[ATGC]{3}", dna))

It seems like it is then convenient to do operations in the tidyverse, creating a tibble (data.frame) where id indicates which sequence the codon is from
library(tidyverse)
tbl <- tibble(id = seq_along(codons), codon = codons) %>% unnest()

and then add the weights
tbl <- mutate(tbl, weight = as.vector(weight[codon]))

so we have
> tbl
# A tibble: 8 x 3
     id codon weight
  <int> <chr>  <dbl>
1     1 ATG    1
2     1 TGT    0.5
3     1 TGC    0.5
4     1 TGG    1
5     2 GGT    0.25
6     2 CGT    0.167
7     2 TGT    0.5
8     2 GTA    0.25

Standard tidyverse operations could be used for further summary, in particular when the same codon appears multiple times
tbl %>% group_by(id, codon) %>%
    summarize(wt = sum(weight))

Answer: First, I get my lookup list and sequence.
codon <- list(ATA = "I", ATC = "I", ATT = "I", ATG = "M", ACA = "T",
              ACC = "T", ACG = "T", ACT = "T", AAC = "N", AAT = "N", AAA = "K",
              AAG = "K", AGC = "S", AGT = "S", AGA = "R", AGG = "R", CTA = "L",
              CTC = "L", CTG = "L", CTT = "L", CCA = "P", CCC = "P", CCG = "P",
              CCT = "P", CAC = "H", CAT = "H", CAA = "Q", CAG = "Q", CGA = "R",
              CGC = "R", CGG = "R", CGT = "R", GTA = "V", GTC = "V", GTG = "V",
              GTT = "V", GCA = "A", GCC = "A", GCG = "A", GCT = "A", GAC = "D",
              GAT = "D", GAA = "E", GAG = "E", GGA = "G", GGC = "G", GGG = "G",
              GGT = "G", TCA = "S", TCC = "S", TCG = "S", TCT = "S", TTC = "F",
              TTT = "F", TTA = "L", TTG = "L", TAC = "Y", TAT = "Y", TAA = "stop",
              TAG = "stop", TGC = "C", TGT = "C", TGA = "stop", TGG = "W")

MySeq <- "ATGTGTTGCTGG"

Next, I load the stringi library and break the sequence into chunks of three characters.
# Load library
library(stringi)

# Break into 3 bases
seq_split <- stri_sub(MySeq, seq(1, stri_length(MySeq), by=3), length=3)

Then, I count the letters that these three base chunks correspond to using table.
# Get associated letters
letter_count <- table(unlist(codon[seq_split]))

Finally, I bind the sequences together with the reciprocal of the count and rename my data frame columns.
# Bind into a data frame
res <- data.frame(seq_split,
                  1/letter_count[match(unlist(codon[seq_split]), names(letter_count))])

# Rename columns
colnames(res) <- c("Sequence", "Letter", "Percentage")

#  Sequence Letter Percentage
#1      ATG      M        1.0
#2      TGT      C        0.5
#3      TGC      C        0.5
#4      TGG      W        1.0

Comment: How to get answer like you got?
Comment: @MayankSinghRajput I'm sure I understand your question. You run the code and the answer is stored in the variable `res`.
Comment: yes sir i got that, but i want to find the percentage of 64 codons only, i mean if there are 900 codons which codes for C alone than it could conclude percentage among that
Comment: @MayankSinghRajput `i want to find the percentage of 64 codons only` If you only want to consider 64 codons, then only use a list with 64 codons (like above). Or do you mean you want to get the percentage of all 64 codons even if the percentage is zero?
Comment: Yes sir i want exactly what you have said.
Answer: Two things to solve here:

convert codon to the fractions for each letter
( fracs <- 1/table(unlist(codon)) )
#         A         C         D         E         F         G         H         I
# 0.2500000 0.5000000 0.5000000 0.5000000 0.5000000 0.2500000 0.5000000 0.3333333
#         K         L         M         N         P         Q         R         S
# 0.5000000 0.1666667 1.0000000 0.5000000 0.2500000 0.5000000 0.1666667 0.1666667
#      stop         T         V         W         Y
# 0.3333333 0.2500000 0.2500000 1.0000000 0.5000000
codonfracs <- setNames(lapply(codon, function(x) unname(fracs[x])), names(codon))
str(head(codonfracs))
# List of 6
#  $ ATA: num 0.333
#  $ ATC: num 0.333
#  $ ATT: num 0.333
#  $ ATG: num 1
#  $ ACA: num 0.25
#  $ ACC: num 0.25

convert the sequence string to a vector of length-3 substrings
s <- 'ATGTGTTGCTGG'

strsplit3 <- function(s, k=3) {
  starts <- seq.int(1, nchar(s), by=k)
  stops <- c(starts[-1] - 1, nchar(s))
  mapply(substr, s, starts, stops, USE.NAMES=FALSE)
}
strsplit3(s)
# [1] "ATG" "TGT" "TGC" "TGG"

From here, it's just a lookup:
codonfracs[ strsplit3(s) ]
# $ATG
# [1] 1
# $TGT
# [1] 0.5
# $TGC
# [1] 0.5
# $TGG
# [1] 1

EDIT
Since you want the status of the other codons, try this:
x <- codonfracs
x[ ! names(x) %in% strsplit3(s) ] <- 0
str(x)
# List of 64
#  $ ATA: num 0
#  $ ATC: num 0
#  $ ATT: num 0
#  $ ATG: num 1
#  $ ACA: num 0
#  $ ACC: num 0
#  $ ACG: num 0
# ...snip...
#  $ TAT: num 0
#  $ TAA: num 0
#  $ TAG: num 0
#  $ TGC: num 0.5
#  $ TGT: num 0.5
#  $ TGA: num 0
#  $ TGG: num 1

Comment: Thank you for this help, but what should i do to get answer for just 64 codons. I want to get the percentage among that 64 codons only
Comment: Also suppose there is no TCC codon in an argument then, i want it will show that TCC=0
Comment: For TCC=0, just do `res[is.na(res)]<-0` (if `res` is holding the results). "Just 64 codons", no idea what you're talking about.
Comment: Sir for example if we have our argument like ATGATAATCATT then we get a table which says thats ATG codes for M and percentage is ! and ATA, ATC, ATT codes for I and its percentage is  0.3 percent and rest of the 64 lists of codons shows 0 because there is no other codons in an argument
Comment: sir, if my argument contains 1000 to 10k characters and i want to calculate the count of each 64 codons and then check its percentage and get output in a table of this four column(codons, amino acids for which it codes for and count and percentage) then how can i proceed this problem please guide me in this.
Comment: How could i proceed in solving this?
Comment: Mayank, you asked a question, it was answered in three ways. Now you have another question, and though it is related to the first (because to you it is the next problem you must overcome), it is still different enough from the original to warrant [a new question](https://stackoverflow.com/questions/ask). I suggest you start the next question with the `codon` and frequency-finding method you choose (a link to here *plus* the literal values/functions), and then include what you've tried so far to get `table` or `xtabs` (etc) to give you what you need.
Comment: Thank you for your suggestion. Also thank you for your efforts


IIS ARR pass-through Windows authentication does not work

Question: I have a similar problem as described here: ARR 3 IIS 7.5 Windows Authentication not working
Unfortunately that solution does not work on our servers.
In our test environment we have an ARR server (Win 2012, IIS 8.0) and a web server (Win 2008R2).
The web application on the webserver requires Windows authentication and it already works when the client is using NTLM as a response to the negotiate request.
But when the client sends a Kerberos ticket the request is not forwarded to the webserver but instead answered by the ARR server with a HTTP 401 message.
I already tried a lot of recommendations without success.
Either the authentication fails on the ARR or the webserver.
We had ARR 2.5 running but I also already tested with ARR 3.0 without success.
I also configured the SPN entries for the ARR and the web server (http://blogs.iis.net/brian-murphy-booth/archive/2007/03/09/the-biggest-mistake-serviceprincipalname-s.aspx).
And tried to use the same user accounts for the app pool on the ARR and web server.
------- EDIT-------

I tried the whole approach from the other working solution (ARR 3 IIS 7.5 Windows Authentication not working)
Disable Kerberos on the ARR and Web (separatly) so that only NTLM is supported (fails on ARR)
App pool with app pool identity and real account (same on ARR and web) with different SPN approaches
Upgrade to ARR 3.0 and repeat all tries

The problem is always that the ARR server is reacting on the negotiate header even if the ARR is configured for anonymous.
BTW: KB 2732764 was installed long time ago
Comment: Can you list the things you have tried, please?
Answer: I finally found a solution for us:
Since we don't have the requirement for "multi-hop" authentication (=kerberos) I was able to force NTLM.
On the web server under auhtentication (site) I changed the providers for Windows Authentication and removed everything but NTLM. So NTLM is the only available way for authentication.
On the ARR I changed everything back to the original settings and enabled anonymous access only.
Then ARR is able to pass-through the authentication to the web server.
In my opinion Microsoft has a bug in the Kerberos handling and it does not depend on whether the authentication is proceeded in ther Kernel or by the ARR.


Proxy sends multiply requests from ExtJs store

Question: My app send multiply request to server each time I insert new item to store. When the first item inserted it calls POST once, one more item ... twice and so on.
Im new at ExtJs, so can you help me in solving some qustions:

First of all what the sync method do, why (GET, POST, PUT, DELETE) methods are not called without store.sync() method invok?
Why my post method multiply requests?
Why store.remove() (DELETE) method throws 400 error (Bad request) when the PUT method works fine?

Thank you in advance
my edit controller:
Ext.define('MVC.controller.Edit', {
extend: 'Ext.app.Controller',

init: function () {
    this.control({
        'editForm > button#SaveRecord': {
            click: this.onSaveButtonClick
        },
        'editForm > button#DeleteButton': {
            click: this.onDeleteButtonClick
        }
    });
},

onSaveButtonClick: function (btn) {
    //get reference to the form
    var detailView = btn.up('editForm');

    //get the form inputs
    var data = detailView.getValues();

    //see if the record exists
    var store = Ext.getStore('TestStore');
    console.log(data.id);
    var record = store.getById(data.id);

    if (!record) {
        record = Ext.create('MVC.model.Note', {
            title: data.title,
            created: new Date(),
            updated: new Date(),
            text: data.text
        });

        store.insert(0, record);
        store.sync();
        Ext.MessageBox.alert('Created', record.id);
        return;
    }

    record.set(data);

    store.sync();
    //manually update the record
    detailView.updateRecord();
},

onDeleteButtonClick: function (btn) {

    //get reference to the form
    var detailView = btn.up('editForm');

    //get the form inputs
    var data = detailView.getValues();

    var store = Ext.getStore('TestStore');
    var record = store.getById(data.id);
    store.remove(record);
    store.sync();
}
});

Store :
Ext.define('MVC.store.TestStore', {
extend  : 'Ext.data.Store',

requires : [
    'MVC.model.Note'
],

storeId : 'TestStore',
model   : 'MVC.model.Note',
autoLoad: false,
proxy: {
    type : 'rest',
    url: 'rest/notes',
    actionMethods : {
        create  : 'POST',
        read    : 'GET',
        update  : 'PUT',
        destroy : 'DELETE'
    },
    reader: {
        type: 'json',
        rootProperty: 'data'
    },
    writer: {
        type: 'json'
    }
}
});

And model:
Ext.define('MVC.model.Note', {
extend: 'Ext.data.Model',

fields: [
    {
        name: 'id',
        type: 'string'
    },
    {
        name: 'title',
        type: 'string'
    },
    {
        name: 'created',
        type: 'date'
    },
    {
        name: 'updated',
        type: 'date'
    },
    {
        name: 'text',
        type: 'string'
    }
]
});

Answer: Try to use record's methods:
1)Add proxy to you'r model like this:
Ext.define('MVC.model.Note',{
extend: 'Ext.data.Model',

fields: [
{
    name: 'id',
    type: 'string'
},
{
    name: 'title',
    type: 'string'
},
{
    name: 'created',
    type: 'date'
},
{
    name: 'updated',
    type: 'date'
},
{
    name: 'text',
    type: 'string'
}],

proxy:
{
    type: 'rest',
    url: 'rest/notes',
    reader:
    {
        type: 'json'
    }
}
});

2)Now you can use methods: record.save() - will send PUT if it was loaded to store from server and record have id, or POST if this record was created with record.create();
record.destroy() - will send DELETE to server with id of record;
You can use Ext.ModelManager.getModel('Model_name').load(id) to send GET request to server for single record.
3)Use store.load() to GET array of records from server


I find a weird issue about lists of list in Python

Question: Here is my code, i cannot figure out the difference between these two lists of list:
cow = 1
column = 1
size = 3
board1=[[0,0,0],[0,0,0],[0,0,0]]
print board1
board2=[[0] * size] * size
print board2

if board1==board2: print 'same'

board1[cow][column] =1
board2[1][2] =1
print "Board 1 is :", board1
print "Board 2 is :", board2

Result:
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
same
Board 1 is : [[0, 0, 0], [0, 1, 0], [0, 0, 0]]
Board 2 is : [[0, 1, 0], [0, 1, 0], [0, 1, 0]]

Comment: What is the particular difference that you don't understand?
Comment: If you found my answer satisfactory, could you mark it as accepted please? Cheers.
Answer: board2=[[0] * size] * size

The inner list gets made and points to a position in memory.
The outer list is made by putting three references to the inner list in a list.
A change to the inner list changes it for all other inner lists as they point to the same data in memory.
To show this put this after you create the lists
print(
    board1[0] is board1[1],    #False
    board2[0] is board2[1],    #True
    )

The is operator returns true if both objects are same object in memory.


Look for substring in a string with at most one different character-javascript

Question: I am new in programing and right now I am working on one program. Program need to find the substring in a string and return the index where the chain starts to be the same. I know that for that I can use "indexOf". Is not so easy. I want to find out substrings with at moste one different char.
I was thinking about regular expresion... but not really know how to use it because I need to use regular expresion for every element of the string. Here some code wich propably will clarify what I want to do:
var A= "abbab";
var B= "ba";
var tb=[];

console.log(A.indexOf(B));

  for (var i=0;i<B.length; i++){
    var D=B.replace(B[i],"[a-z]");
    tb.push(A.indexOf(D));
  }
console.log(tb);

I know that the substring B and string A are the lowercase letters. Will be nice to get any advice how to make it using regular expresions. Thx
Simple Input:
A B
1) abbab ba
2) hello world
3) banana nan
Expected Output:
1) 1 2
2) No Match!
3) 0 2

Comment: please add the information to the question.
Comment: *output:1 2* - still unclear. How's `ba` is matched here `abbab ba` at `1` and `2` indexes
Comment: please explain *I want to find out substrings with at moste one different char.*
Comment: it means that the substring not need to be exactly te same as a sample but can be differen with at mose one char I hope an example help you to get it
Comment: @RomanPerekhrest: one letter can be different in substring. In this case ba we will find on index 2 but if we gonna replace "a" in ba with b we will find also bb at index 1 as needed substring.
Comment: `3) banana nan` -> `3) 0 2`. By this logic it should be `0 2 4 7`
Comment: I think the title should say "character" instead of "charter".
Answer: While probably theoretically possible, I think it would very complicated to try this kind of search while attempting to incorporate all possible search query options in one long complex regular expression. I think a better approach is to use JavaScript to dynamically create various simpler options and then search with each separately.
The following code sequentially replaces each character in the initial query string with a regular expression wild card (i.e. a period, '.') and then searches the target string with that. For example, if the initial query string is 'nan', it will search with '.an', 'n.n' and 'na.'. It will only add the position of the hit to the list of hits if that position has not already been hit on a previous search. i.e. It ensures that the list of hits contains only unique values, even if multiple query variations found a hit at the same location. (This could be implemented even better with ES6 sets, but I couldn't get the Stack Overflow code snippet tool to cooperate with me while trying to use a set, even with the Babel option checked.) Finally, it sorts the hits in ascending order.
Update: The search algorithm has been updated/corrected. Originally, some hits were missed because the exec search for any query variation would only iterate as per the JavaScript default, i.e. after finding a match, it would start the next search at the next character after the end of the previous match, e.g. it would find 'aa' in 'aaaa' at positions 0 and 2. Now it starts the next search at the next character after the start of the previous match, e.g. it now finds 'aa' in 'aaaa' at positions 0, 1 and 2.

const findAllowingOneMismatch = (target, query) => {
  const numLetters = query.length;
  const queryVariations = [];
  for (let variationNum = 0; variationNum < numLetters; variationNum += 1) {
    queryVariations.push(query.slice(0, variationNum) + "." + query.slice(variationNum + 1));
  };
  let hits = [];
  queryVariations.forEach(queryVariation => {
    const re = new RegExp(queryVariation, "g");
    let myArray;
    while ((searchResult = re.exec(target)) !== null) {
      re.lastIndex = searchResult.index + 1;
      const hit = searchResult.index;
      // console.log('found a hit with ' + queryVariation + ' at position ' + hit);
      if (hits.indexOf(hit) === -1) {
        hits.push(searchResult.index);
      }
    }
  });
  hits = hits.sort((a,b)=>(a-b));
  console.log('Found "' + query + '" in "' + target + '" at positions:', JSON.stringify(hits));
};

[
  ['abbab', 'ba'],
  ['hello', 'world'],
  ['banana', 'nan'],
  ['abcde abcxe abxxe xbcde', 'abcd'],
  ['--xx-xxx--x----x-x-xxx--x--x-x-xx-', '----']
].forEach(pair => {findAllowingOneMismatch(pair[0], pair[1])});


From whom did The Beatles steal the extra beat in "Don't Let Me Down?"

Question: It's well known that The Beatles made good use of every existing musical idiom in their work, a side-effect of talent borne from constant live performance.  In this case, I'm curious if anyone can help me identify a musical precursor to one of their idiosyncrasies.
One unusual feature is an extra beat in the tune "Don't Let Me Down" that breaks the prevailing 4/4 signature in a lead-up to the chorus.
The five beat bar precedes the word "does" in the chorus line "like she does."

1____2___3___4_______5______1
( )"Nobody ever loved me like she does..."
1_____2_____3____4______5______1
( )"And if somebody loved me like she does..."

Is this five-beat-bar in a 4/4 song a Beatles innovation?  My inclination is to doubt it, and I'm curious if there are examples of popular music earlier than this tune that use a similar extended bar that the Beatles may have borrowed this style from.
Comment: @ToddWilcox Also, Dave Brubeck's Take Five was a huge hit in 1961 in both the USA and the UK, and  probably inescapable on the radio even if you were not a jazz fan. But that is 5/4 throughout, whereas Don't Let Me Down and some Bacharach songs establish a meter and then interject odd bars here and there; e.g. the two ways in which the title is sung in "I'll Never Fall In Love Again" from 1963.
Comment: It's just a "bit of a 60s thing" imo. They first did sig changes in We Can Work it Out, in 65 [but 4/4 to 3/4]. By 69, everybody had had a go. All You Need is Love [67] was probably a completely world-wide ground-breaker in the pop genre.
Comment: Rolf Harris had an extra beat in 'Two Little Boys', probably later.
Comment: Burt Bacharach used a lot of meter changes, and the Beatles covered Baby It's You, so they knew his music. Have a listen to "Anyone Who Had A Heart" from 1963, which most sources notate in 5/4 + 4/4 time (although you can find the weirdest versions online).
Comment: Even if 5/4 time was firmly planted in popular culture, this particular extended measure seems different to me than classic examples, especially *Mission Impossible* which has something of a 3/4 // 2/4 split, as opposed to a 4/4 + 1/4 vibe.
Comment: @YourUncleBob  - I agree there's a huge difference between a whole piece being in, say, 5/4 against a 4/4 piece with an odd (?) 5/4 bar somewhere. For  a real crazy one, see 'Closest Thing to Crazy'.
Comment: 5/4 time was firmly planted into the popular culture by 1966 at the latest because that's when *Mission Impossible* with its iconic 5/4 theme music debuted.
Comment: Btw, why not go straight to the source? We know what Lennon was listening to because of the jukebox he took with him on tour. There's a BBC documentary (only available on bootleg DVD) and a compilation double-CD and a lot of information online. https://en.wikipedia.org/wiki/John_Lennon%27s_jukebox
Answer: There are innumerable examples of this sort of thing in 16th and 17th century hymn tunes, though most of them were edited out in the 19th century by tidy-minded pedants who preferred their music to have the same number of beats in all the bars.
Another early example is the final variation (the "quodlibet") of Bach's Goldberg Variations, where he is imitating a bunch of singers simultaneously performing two or three different popular songs of the day. At the end of the penultimate line, one of the singers needs an extra beat to get to the end of the line of his song. Bach fudges the notation using short note values to squash all the notes in to one beat, but (especially since the whole set of variations is full of musical in-jokes) it seems clear enough that what he wrote was not exactly what he meant.
Comment: Please could you point me at a source which has examples? (There are no doubt dozens of old hymn-books on IMSLP but it's not just any old 17th-C hymn tune I'd like to see,  but irregular hymn-tunes which have newer tidied versions.)


How to make a ComboBox with fulltext search autocomplete support in C++Builder?

Question: I try to make a ComboBox with full search autocomplete in C++Builder.
I found a solution in Delphi, but when I try to rewrite it in C++ I get some access error:
How to make a combo box with fulltext search autocomplete support?
Here's my code:
My header file:
class PACKAGE TSmartComboBox : public TComboBox
{
private:
    TStringList* FStoredItems;
    bool dofilter;
    int storeditemindex;
    void FilterItems();
    void __fastcall StoredItemsChange(TObject* Sender);
    void CNCommand(TWMCommand AMessage);
protected:
    DYNAMIC void __fastcall KeyPress(System::WideChar &Key);
    DYNAMIC void __fastcall CloseUp(void);
    DYNAMIC void __fastcall Click(void);
public:
    __fastcall TSmartComboBox(TComponent* Owner);
    __fastcall ~TSmartComboBox();
    void InitSmartCombo();

__published:
    void __fastcall SetStoredItems(TStringList* Value);
    __property TStringList* StoredItems =
    {read = FStoredItems, write = SetStoredItems};
};

And cpp file:
static inline void ValidCtrCheck(TSmartComboBox *)
{
    new TSmartComboBox(NULL);
}
//---------------------------------------------------------------------------
__fastcall TSmartComboBox::TSmartComboBox(TComponent* Owner)
    : TComboBox(Owner)
{
    FStoredItems = new TStringList();
    dofilter = false;
}

__fastcall TSmartComboBox::~TSmartComboBox()
{
    delete FStoredItems;
}

void _fastcall TSmartComboBox::SetStoredItems(TStringList* Value)
{
    if(FStoredItems)
    {
        FStoredItems->Assign(Value);
    } else {
        FStoredItems = Value;
    }
}

void __fastcall TSmartComboBox::KeyPress(System::WideChar &Key)
{
    if(dofilter && (Key >= 13 & Key <= 27))
    {
        if(Items->Count != 0 && DroppedDown)
        {
            SendMessage(Handle, CB_SHOWDROPDOWN, 1, 0);
        }
    }
}

void __fastcall TSmartComboBox::CloseUp(void)
{
    AnsiString x;

    if(dofilter)
    {
        if(Items->Count == 1 && ItemIndex == 0)
        {
            Text = Items->operator [](ItemIndex);
        } else if((Text == "" && ItemIndex != -1 && Text != Items->operator [](ItemIndex)) || (Text == "" && ItemIndex == 0))
        {
            storeditemindex = ItemIndex;
            x = Text;
            ItemIndex = Items->IndexOf(Text);
            if(ItemIndex == -1)
            {
                Text = x;
            }
        } else
        {
            storeditemindex = -1;
        }
    }
}

void __fastcall TSmartComboBox::Click(void)
{
    if(dofilter)
    {
        if(storeditemindex != -1)
        {
            ItemIndex = storeditemindex;
        }
        storeditemindex = -1;
    }
}

void TSmartComboBox::InitSmartCombo()
{
    FStoredItems->OnChange = NULL;
    StoredItems->Assign(Items);
    AutoComplete = false;
    FStoredItems->OnChange = StoredItemsChange;
    dofilter = true;
    storeditemindex = -1;
}

void __fastcall TSmartComboBox::StoredItemsChange(TObject* Sender)
{
    if(FStoredItems)
    {
        FilterItems();
    }
}

void TSmartComboBox::FilterItems()
{
    int i;
    TSelection Selection;

    SendMessage(Handle, CB_GETEDITSEL, WPARAM(Selection.StartPos), LPARAM(Selection.EndPos));

    Items->BeginUpdate();

    if (Text != "")
    {
        Items->Clear();

        for (i = 0; i < FStoredItems->Count - 1; i++)
        {
            if(Pos(UpperCase(Text), UpperCase(FStoredItems->Strings[i])) > 0)
            {
                Items->Add(FStoredItems->Strings[i]);
            }
        }
    } else
    {
        Items->Assign(FStoredItems);
    }

    Items->EndUpdate();

    //SendMessage(Handle, CB_SETEDITSEL, 0, MakeLParam(Selection.StartPos, Selection.EndPos));
}

void TSmartComboBox::CNCommand(TWMCommand AMessage)
{
    if(AMessage.NotifyCode == CBN_EDITUPDATE && dofilter)
    {
        FilterItems();
    }
}

//---------------------------------------------------------------------------
namespace Comboboxsmart
{
    void __fastcall PACKAGE Register()
    {
         TComponentClass classes[1] = {__classid(TSmartComboBox)};
         RegisterComponents(L"polpress", classes, 0);
    }
}

Comment: "*I get some access error*" - can you be more specific? What does the error actually say?  Which line does it happen on exactly?
Answer: I see a number of issues with your translation:

CNCommand() is not calling the inherited handler. And it is declared wrong anyway, as it needs to take the TWMCommand by reference instead of by value. Also, you are missing a MESSAGE_MAP to even invoke CNCommand() in the first place.

SetStoredItems() should not be trying to take ownership of the passed TStringList* at all.  Not that it matters, since FStoredItems should never be NULL to begin with.

In KeyPress(), you are not calling the inherited handler. Also, you need to use && instead of & when testing 2 separate conditions.  In C++, && is LOGICAL AND, whereas & is BITWISE AND.  However, you are not actually checking the Key parameter in the same manner that the original Delphi code is.

in fact, a lot of your comparisons are doing the opposite of what the original Delphi code does.

In CloseUp(), you are not calling the inherited handler. Also, you should use (Unicode)String instead of AnsiString. Also, use (*Items)[...] or Items->Strings[...] instead of using Items->operator[](...) explicitly.

In Click(), you are not calling the inherited handler.

In FilterItems(), your parameter values for CB_GETEDITSEL are wrong. They need to be passed by pointer, not by value.  Also, your for loop is skipping the last string in FStoredItems.  Also, you are missing a try..finally block that is in the original Delphi code.

I would suggest changing the StoredItems property to use TStrings* instead of TStringList*. That will make it more flexible for accepting non-TStringList lists. And SetStoredItems() should not be declared __published.  For that matter, does it really make sense to expose the StoredItems property to the Object Inspector at design-time?  StoredItems is public in the original Delphi code, not __published.

With that said, try this instead:
class PACKAGE TSmartComboBox : public TComboBox
{
    typedef TComboBox inherited;

private:
    TStrings* FStoredItems;
    bool dofilter;
    int storeditemindex;
    void __fastcall FilterItems();
    void __fastcall StoredItemsChange(TObject* Sender);
    void __fastcall SetStoredItems(TStrings* Value);
    void __fastcall CNCommand(TWMCommand& AMessage);
protected:
    DYNAMIC void __fastcall KeyPress(WideChar &Key);
    DYNAMIC void __fastcall CloseUp();
    DYNAMIC void __fastcall Click();
public:
    __fastcall TSmartComboBox(TComponent* Owner);
    __fastcall ~TSmartComboBox();
    void __fastcall InitSmartCombo();

    BEGIN_MESSAGE_MAP
        VCL_MESSAGE_HANDLER(CN_COMMAND, TWMCommand, CNCommand)
    END_MESSAGE_MAP(TComboBox)

__published:
    __property TStrings* StoredItems = {read = FStoredItems, write = SetStoredItems};
};

static inline void ValidCtrCheck(TSmartComboBox *)
{
    new TSmartComboBox(NULL);
}
//---------------------------------------------------------------------------
__fastcall TSmartComboBox::TSmartComboBox(TComponent* Owner)
    : TComboBox(Owner)
{
    FStoredItems = new TStringList;
    dofilter = false;
}

__fastcall TSmartComboBox::~TSmartComboBox()
{
    delete FStoredItems;
}

void _fastcall TSmartComboBox::SetStoredItems(TStrings* Value)
{
    FStoredItems->Assign(Value);
}

void __fastcall TSmartComboBox::KeyPress(WideChar &Key)
{
    inherited::KeyPress(Key);
    if (dofilter && (Key != 13 && Key != 27))
    {
        if (Items->Count != 0 && !DroppedDown)
        {
            SendMessage(Handle, CB_SHOWDROPDOWN, 1, 0);
        }
    }
}

void __fastcall TSmartComboBox::CloseUp()
{
    if (dofilter)
    {
        if(Items->Count == 1 && ItemIndex == 0)
        {
            Text = Items->Strings[ItemIndex];
        }
        else if ((Text != _D("") && ItemIndex != -1 && Text != Items->Strings[ItemIndex]) || (Text == _D("") && ItemIndex == 0))
        {
            storeditemindex = ItemIndex;
            String x = Text;
            ItemIndex = Items->IndexOf(Text);
            if(ItemIndex == -1)
            {
                Text = x;
            }
        }
        else
        {
            storeditemindex = -1;
        }
    }
    inherited::CloseUp();
}

void __fastcall TSmartComboBox::Click()
{
    if (dofilter)
    {
        if (storeditemindex != -1)
        {
            ItemIndex = storeditemindex;
            storeditemindex = -1;
        }
    }
    inherited::Click();
}

void __fastcall TSmartComboBox::InitSmartCombo()
{
    static_cast<TStringList*>(FStoredItems)->OnChange = NULL;
    FStoredItems->Assign(Items);
    AutoComplete = false;
    static_cast<TStringList*>(FStoredItems)->OnChange = &StoredItemsChange;
    dofilter = true;
    storeditemindex = -1;
}

void __fastcall TSmartComboBox::StoredItemsChange(TObject* Sender)
{
    FilterItems();
}

void TSmartComboBox::FilterItems()
{
    DWORD StartPos, EndPos;

    SendMessage(Handle, CB_GETEDITSEL, reinterpret_cast<WPARAM>(&StartPos), reinterpret_cast<LPARAM>(&EndPos));

    Items->BeginUpdate();
    try
    {
        if (Text != _D(""))
        {
            Items->Clear();

            for (int i = 0; i < FStoredItems->Count; ++i)
            {
                if (UpperCase(Text).Pos(UpperCase(FStoredItems->Strings[i])) > 0)
                {
                    Items->Add(FStoredItems->Strings[i]);
                }
            }
        }
        else
        {
            Items->Assign(FStoredItems);
        }
    }
    __finally
    {
        Items->EndUpdate();
    }

    SendMessage(Handle, CB_SETEDITSEL, 0, MAKELPARAM(StartPos, EndPos));
}

void TSmartComboBox::CNCommand(TWMCommand AMessage)
{
    TComboBox::Dispatch(&AMessage);
    if (AMessage.NotifyCode == CBN_EDITUPDATE && dofilter)
    {
        FilterItems();
    }
}

//---------------------------------------------------------------------------
namespace Comboboxsmart
{
    void __fastcall PACKAGE Register()
    {
         TComponentClass classes[1] = {__classid(TSmartComboBox)};
         RegisterComponents(L"polpress", classes, 0);
    }
}

You appear to be basing your C++ code on this Delphi code, but you have not incorporated any of the additional fixes provided by this Delphi code.  Just saying...


Asymptotic power

Question: I have found the term "asymptotic power of a statistical test" only related to the Kolmogorov-Smirnov test (to be precise: asyptotic power = 1). What does this term acctually mean? In my opinion it should be someting like this: "if the alternative hypothesis is true, than for every significance level alpha there exists a sample size n that the selected test would reject the null hypothesis". Is "my" definition correct? According to "my defintion" the majority of classical tests (t-tset, ...) should have the asymptotic power 1, not only KS test. Am I right? ;)
Comment: Kolmogorov test is for distributions hence object lying in infinite dimensional space... not obvious to get asymptotic power=1. t-test is about testing the mean of a real valued random variable?
Comment: I haven't claimed that it is obvious, I just said that I have found this statement. So the natural question for me would be: what about other statistical tests - no matter what they are designed for.
Answer: The definition above (a fixed alternative, sample size going to infinity) is more precisely related to the consistency (or not) of a hypothesis test.  That is, a test is consistent against a fixed alternative if the power function approaches 1 at that alternative.
Asymptotic power is something different.  As Joris remarked, with asymptotic power the alternatives $\theta_n$ are changing, are converging to the null value $\theta_0$ (on the order of $\sqrt n$, say) while the sample size marches to infinity.
Under some regularity conditions (for example, the test statistic has a monotone likelihood ratio, is asymptotically normal, has asymptotic variance $\tau$ continuous in $\theta$, yada yada yada) if $\sqrt n(\theta_n - \theta_0)$ goes to $\delta$ then the power function goes to $\Phi(\delta/\tau - z_\alpha)$, where  $\Phi$ is the standard normal CDF.  This last quantity is called the asymptotic power of just such a test.
See Lehmann's $\underline{\mbox{Elements of Large Sample Theory}}$ for discussion and worked out examples.
By the way, yes, the majority of classical tests are consistent.
Comment: I don't thing consistency can have any sense in a goodness of fit test (such as KS test).  You said "with asymptotic power the alternatives are changing" do you have an idea of how they change (different way of changing them will lead to different conclusions)? "Under some regularity conditions" is it easy to meet these regularity conditions in the case of Kolmogorov Smirnov test ? Did you find something about that in Lehmann's book ?
Comment: 1) Sure, it can.  Let H0: X ~ N(0,1), suppose X1,...Xn ~ N(1,1), and let n go to infinity.  That's consistency for the alternative $N(1,1)$.  The KS-test is nonparametric so I bet it would be lots of fun to show consistency for all possible alternatives.  2) Yes, they change on the order of $\sqrt n$, say.  3) I'm not quite clear on the question(s): are you wanting to show the asymptotic power of the KS-test is 1?  The first step would be to find a definition of asymp power that makes sense for a nonparametric test.  I don't happen to know of one, in Lehmann's book or elsewhere.
Answer: As I understood it, the asymptotic power is the hypothetical power when the effect size goes to zero and the sample size to infinity. Basically it should be 0 or 1, indicating whether the test cannot or can distinguish an arbitrary small deviation from the null hypothesis when the sample size is sufficiently large.
Comment: Thank you, Joris. So "my definition" was just partially correct. ;) Do you probably know the asyptotic power of Friedman test (non-parametric repeated measures ANOVA)?
Answer: Yes, you are right. I would only replace "there exists a sample size n that the selected test would reject the null hypothesis" with "for every e>0 there exists a sample size n_0 such that the probability to reject the null hypothesis is greater than 1-e for all n>n_0".

Asymptotic power


Nginx+PHP-FPM: Let php handle file extensions

Question: I am trying to serve a PHP script that handles some RESTful URIs and to know which format end user needs data, I handled that as the extension in the URI, eg.:
example.com/foo/bar.json?q=x&a=y --> data in ajax format
example.org/foo/bar.xml?q=x&a=y  --> data in xml format

I use Apache httpd + modphp in my development machine and it works just fine, but the stage server uses CentOS + Nginx + PHP. There, the nginx intercepts and tries handling an static json file and returns 404.
How can I prevent Nginx from handling certain file types (eg. json, xml) and let PHP handle those?
My Nginx config:
server {

  # listen [::]:443 ssl http2 accept_filter=dataready;  # for FreeBSD
  # listen 443 ssl http2 accept_filter=dataready;  # for FreeBSD
  # listen [::]:443 ssl http2 deferred;  # for Linux
  # listen 443 ssl http2 deferred;  # for Linux
  listen [::]:443 ssl http2;
  listen 443 ssl http2;

  # The host name to respond to
  server_name example.com;

  include h5bp/directive-only/ssl.conf;
  include ssl/conf/example.com;

  # Path for static files
  root /var/www/example.com/app/public;
  index index.php index.html index.htm;

  #Specify a charset
  charset utf-8;

  # Custom 404 page
  error_page 404 /404.html;

  # Include the basic h5bp config set
  include h5bp/basic.conf;

  # log settings
  access_log off;
  error_log  /var/log/www/example.com/nginx/error/error.log error;

  # turn off access logs and prevents logging
  # an error if robots.txt and favicon.ico are not found
  location = /favicon.ico { access_log off; log_not_found off; }
  location = /robots.txt  { access_log off; log_not_found off; }

  # check if a file or directory index file exists,
  # else pass the request to the index.php as a query parameter.
  location / {
    try_files $uri $uri/ /index.php?$query_string;
  }

  # handle execution of PHP files
  # set php5-fpm socket
  # tell NGINX to proxy requests to PHP FPM via the FCGI protocol
  location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass localhost:9003;
    fastcgi_index index.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_intercept_errors off;
    fastcgi_buffer_size 16k;
    fastcgi_buffers 4 16k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
  }

  # block access to .htaccess files
  location ~ /\.ht {
    deny all;
  }

}

Update: It did work finally, I put the json-related location inside the main / location and changed the $script_file_name for the json-related location to a static script name. Thanks to Tim.
Answer: Tell PHP to pass requests for json files to the PHP interpreter. You can make more precise path matches if required, for example only json files in the "/api/scripts" directory, you just need to work out the regular expression.
Change your PHP location to this
location ~ \.(php|json)$ {

Comment: I tried many combinations of location but they're not working.

the most acceptable one was `location ~ \.json$ { try_files /index.php?$query_string; }` before (and one time after) the main `location / {...}` block.
Comment: "not working" and "most acceptable" is too vague to be useful, and code in comments isn't readable. Please edit your question to show what you tried, and precisely describe why they didn't work, including for each case access log, error log, and curl, as appropriate.
Comment: It did work finally, I put the json-related location inside the main `/` location and changed the `$script_file_name` for the json-related location to a static script name. Thanks.
Comment: Great :) Perhaps you could edit your question to add the final configuration, to help others in future.


Programmatic list of Webform elements?

Question: I am building a D8 module that, for configuration, needs a list of webforms and their fields (just the entity reference fields, but I am not picky)
I can get the webforms with this:
<code>  $webforms = \Drupal::entityTypeManager()->getStorage('webform')->loadMultiple(null);
</code>
But once I get the returned elements <code>(Drupal\webform\Entity\Webform::__set_state)</code>, how can I fetch the elements in the webform referenced?
Comment: Are you trying to get the values a user entered? or just the field names the form contains?
Comment: Thanks, I was looking for the form's field names, and found the result myself.... eventually.  Posted below.
Answer: By trawling through the code, I found this handy function in the Entity code, and it works perfectly:
<code> $elements = $webform->getElementsDecodedAndFlattened();
</code>
This gives a nice array of the elements in the webform itself.
If you want the results of a submission, grab that entity and use:
<code>$data = $entity->getData();
</code>
I hope this helps
Answer: The complete code for fetching the webform elements are listed below:
<code>  $webform = Webform::load('webform_id'); //replace webform_id with the webform id
  if ($webform) {
    $view_builder = \Drupal::entityTypeManager()->getViewBuilder('webform');
    $elements = $webform->getElementsDecodedAndFlattened();
  }
</code>

Programmatic list of Webform elements?


Linear regression - date as dummy variable

Question: I have a doubt about including the date - year, month as dummy 'X' variables in linear regression in Python.  The issue I encounter is when forecasting 'y' variable on a date where the 'year' is new.  How do I proceed on this?
E.g. Suppose I have only Y variable - sales and X as 'date'.  when X is dummified to 'year' and 'month' (from 2016 to 2018) and I am predicting for 1 year that include 2019 as well, then how do I choose the dummy coding for Year when it didn't appear earlier in the data?
My question is also to understand whether it is a good practise to dummify the date to categorical binary variable or convert it to some cubic spline
Comment: Dummy-coding the date means you are unwilling to use past information to model future data, making it impossible to forecast.
Comment: See [what type of data are dates](https://stats.stackexchange.com/questions/332688/what-type-of-data-are-dates/332715#332715).
Answer: Don't use the date or the year as a dummy variable. Don't, don't, don't.
Dummy coding is used for categorical data, e.g., car brands or hair colors. Dates and years aren't. They are interval scaled. Interval scaled data should be translated into a single predictor that counts the number of days, years (or seconds) since an arbitrary origin. (The choice of origin will influence your intercept parameter estimate.)
In forecasting out, it is often good practice to not extrapolate this predictor linearly, but to dampen it. This has the effect of dampening any trend your model fits.
Even better, take a look at a standard forecasting textbook, like this one.
Comment: @mkt: I do see your point. With only two or three different dates in the training sample, I would be careful about using trends (or seasonality) in forecasting, anyway.
Comment: Thank you.  Do you know any implementation examples?
Comment: Sorry, no, I don't speak Python. It should be a pretty straightforward use case, and findable in some Data Science teaching materials.
Comment: This is generally true, but there are some cases where treating date/year as dummies should be okay. Suppose you are interested in some relationship that you have measured on 2 or 3 irregularly spaced dates or years (not ideal, but unfortunately common in my field). You aim to draw inferences about the relationship but are not interested in the time aspect or in forecasting. You need to account for the different sampling dates, though. I imagine using dummies for date should work fine in this case.
Comment: @StephanKolassa I posted a follow up question in `R` [here](https://stats.stackexchange.com/questions/427307/linear-regression-approaching-models-with-date-as-variable)  If you have any suggestions on that, would be appreciated.  @mkt  Could you also check the question


Counterexamples $\overset{\circ}{E} \cup \overset{\circ}{F} = \overset{\circ}{E \cup F}$

Question: I couldn't fit my question in, but I'm trying to find counter examples for $\overset{\circ}{E} \cup \overset{\circ}{E} = \overset{\circ}{E \cup F}$
My professor was talking about this in class, and I think she mentioned that one could find counter examples for  $\overset{\circ}{E} \cup \overset{\circ}{F} = \overset{\circ}{E \cup F}$ and $\overline{E \cap F} \subset \overline{E} \cap \overline{F}$. I'm not sure if I misheard her, but I can't come up with any counter examples where the above equality fails.
Any help would be much appreciated!
Comment: Hint: Sometimes $E^\circ = \emptyset$...
Comment: Does http://math.stackexchange.com/questions/1776861/a-circ-cup-b-circ-subset-a-cup-b-circ-counterexample-for-instead-of?rq=1 answer part of this question?
Comment: @QthePlatypus Thank you so much! It answers the first one.
Comment: For the second one, you wrote that you want a counterexample for $\overline{E \cap F} \subseteq \overline{E} \cap \overline{F}$. But this is the inclusion that always holds, as $\overline{E\cap F} \subseteq \overline{E}$ and $\overline{E\cap F} \subseteq \overline{F}$. It is the other inclusion that is false: take something like $E = [-1,1]\setminus \{ 0 \}$ and $F = \{ 0 \}$ on the real line.
Comment: ...and this also gives a counterexample for $(E\cup F)^\circ \subseteq E^\circ \cup F^\circ$.
Comment: @Nikitau: maybe  $A^\circ$ ans $A^-$ is a better notation. $\overline A$ is often used for the set complement.
Answer: I think what your professor might have said:
We know that $\overline{E \cup F} = \overline{E} \cup \overline{F}$, and because $X \setminus A^{\circ} = \overline{X \setminus A}$ and $X \setminus \overline{A} = (X \setminus A)^{\circ}$ for all $A \subseteq X$, so in particular $A^{\circ} = X \setminus \overline{(X \setminus A)}$, and something similar for closure. We can express closures in interiors and vice versa using complements in $X$.
So we can use de Morgan twice to see that
\begin{multline}(E \cap F)^{\circ} = X \setminus \overline{(X \setminus (E \cap F)} =
X \setminus \overline{(X\setminus E) \cup (X\setminus F)} =
X \setminus (\overline{(X\setminus E)} \cup \overline{(X\setminus F)}) = \\
(X \setminus \overline{(X \setminus E)}) \cap (X \setminus \overline{(X \setminus F)}) =
 E^{\circ} \cap F^{\circ}\end{multline}
showing that the $\cup$-equality for closures gives us the $\cap$-equality for interiors.
Now we also know (presumably) that for the intersection of closures we only have $\overline{E \cap F} \subseteq \overline{E} \cap \overline{F}$, and the reverse inclusion fails in general. So there we don't have equality.
So a similar computation shows that for interiors we thus have that $(A \cup B)^{\circ} \supseteq A^{\circ} \cap B^{\circ}$ and the reverse inclusion fails in general. And if $A,B$ form a counterexample for equality for closures (for intersection), then their complements are one for the interior equality (for unions).
A nice symmetric counterexample (where $A$ and $B$ are eqach other's complement) is $X$ the set of reals in the usual topology and $A = \mathbb{Q}$ and $B = \mathbb{R \setminus Q}$, and the same example then works (by symmetry) for interior as well (both sets have empty interior and closure equal to $X$).
But working in $X = (0,2)$ we can also take $A = (0,1), B = (1,2)$ for the closures and then $A = [1,2), B = (0,1]$ works for the interiors, as expected.


Why are the degrees of freedom for the distribution of the t-test "n-1" and not "n-2" when both the sample mean and variance are estimated?

Question: The common way to determine the degrees of freedom is to subtract 1 from n for each parameter that has been estimated.
$$
T_{n} = \sqrt{n} \frac{x̄-\mu}{s}
$$
Here I estimate both the mean and the sd to calculate T.
Assuming that the distribution of the data is normal, why do we get n-1 and not n-2 df?
(I understand the process to demonstrate that the distribution with n-1 is correct, I just can't grasp why the rule doesn't seem to hold here, maybe I'm getting something wrong)
Answer: In some sense this is just the definition: a $t_{n-1}$ variable was defined as one where the denominator is the square root of a $\chi^2_{n-1}$.
More helpfully, it's the denominator degrees of freedom that we're talking about, ie, degrees of freedom for estimating $s$, and there we do have just one previously estimated parameter to account for, with $n-1$ df left for estimating $s$.


On an identity about integrals

Question: Suppose you have two finite Borel measures $\mu$ and $\nu$ on $(0,\infty)$. I would like to show that there exists a finite Borel measure $\omega$ such that
$$\int_0^{\infty} f(z) d\omega(z) = \int_0^{\infty}\int_0^{\infty} f(st) d\mu(s)d\nu(t).$$
I could try to use a change of variable formula, but the two integration domains are not diffeomorphic. So I really don't know how to start. Any help would be appreciated! This is not an homework, I am currently practising for an exam.
Thanks!
Comment: By the way, the change of variable formula you are referring to (the one with the Jacobian) is proper of the Lebesgue measure. It does not hold with other measures. Take for example a Dirac delta concentrated at the origin. If you apply a dilation to the space, the measure stays the same regardless of the magnitude of the dilation.
Comment: I see. Thank you, I did not realize that!
Answer: When we have no idea about the problem, the question we have to ask ourselves is: "if a measure $\omega$ works, what should it have to satisfy?".
We know that for a Borel measure that it's important to know them on intervals of the form $(0,a]$, $a>0$ (because we can deduce their value on $(a,b]$ for $a<b$, and on finite unions of these intervals). So we are tempted to define
$$\omega((0,a]):=\int_{(0,+\infty)^2}\chi_{(0,a]}(st)d\mu(s)d\nu(t)=\int_{(0,+\infty)}\mu(0,At^{-1}])d\nu(t).$$
Note that if the collection $\{(a_i,b_i]\}_{i=1}^N\}$ consists of pairwise disjoint elements, so are for each $t$ the $(a_it^{-1},b_it^{-1}]$, which allows us to define $\omega$ over the ring which consists of finite disjoint unions of elements of the form $(a,b]$, $0<a<b<+\infty$. Then we extend it to Borel sets by Caratheodory's extension theorem.
As the involved measures are finite, $\omega$ is actually uniquely determined.
Comment: Thanks! The way you put it is really intuitive!
Answer: This operation on measures is called convolution for measures on the locally compact abelian group $(0,+\infty)$ under multiplication.
Using exp and log we may convert this to the usual convolution on the LCA group $(-\infty,+\infty)$ under addition.  In that case, the convolution $\omega = \mu \ast \nu$ satisfies
$$
\int_{-\infty}^{+\infty} f(z)\; \omega(dz) = \int_{-\infty}^{+\infty}\int_{-\infty}^{+\infty} f(x+y) \;\mu(dx)\;\nu(dy)
$$

On an identity about integrals


Node.js Nodemailer working locally but not when hosted A2hosting

Question: When sending emails through my form in my React frontend it works as it should locally in development, but when I host the webapp on A2hosting in production no emails are being sent or received and I am not getting any errors, on the contrary I am getting an ok status request. Anyone know what the issue and solution might be?
Server.js:
const transport = nodemailer.createTransport({
  host: "nl1-ss102.a2hosting.com",
  port: 465,
  secure: true,
  auth: {
    user: process.env.USER_SENDER,
    pass: process.env.PASS
  },
  tls: {
    rejectUnauthorized: true
  }
});

app.post("/send", cors(), async (req, res) => {
  let {
    name,
    //etc...
  } = req.body;

  await transport.sendMail({
    from: `${name}`,
    to: process.env.USER_RECEIVER,
    subject: "Subject",
    html: `

    `
  }, (err) => {
    if (err) {
      console.log(err);
      res.status(400).send('Error');
    } else {
      res.status(200).send('Success');
    }
  })
});

Comment: can you share error logs in production?
Answer: I had a similar problem when I setup @sendGrid/mail. I would recieve the emails, but the values in the email would all be undefined. Then I saw [that] ("https://www.a2hosting.com/kb/getting-started-guide/setting-up-e-mail/using-external-smtp-servers-to-send-e-mail") a2hosting blocks external SMTP servers for clients who aren't paying for managed account's


Limit of a recurrence relation when n approaches infinity

Question: I'm stuck on a problem in my calculus-class. My first task is to find the general solution to the recurrence relation: $\ x_{n+2}-5x_{n+1}-36x_n$ = 0
This I've found to be: $x_n = C9^n+D(-4)^n$.
But then the next task is:
Let $(x_n)^\infty_1$ be an arbitrary solution to the recurrence relation above, that isn't the solution $x_n = 0$. Find the limit:
$\lim_{n\to\infty} (x_{n+1}/x_n)$
for the different possibilities you have found above.
And this is where I'm stuck. I have no idea how to approach this problem, so any pointers would be very much appreciated. If something is unclear it is probably because I've translated this from another language, so please ask if something doesn't make sense to you.
Comment: Well, you have a fairly explicit form for $x_n$, so you can just evaluate more or less directly.  Granted, if $C$ or $D$ is $0$ then you might get a different answer, but still.
Answer: Okay, so you have $x_n = C9^n+D(-4)^n$ where $C$ and $D$ are not both $0$. We can put this directly in the limit:
$$\lim_{n\to\infty}\frac{x_{n+1}}{x_n} = \lim_{n\to\infty}\frac{C9^{n+1}+D(-4)^{n+1}}{C9^n+D(-4)^n}.$$
If $C \neq 0$, then you can see that the $9^n$ will dominate; try dividing the top and bottom by $9^n$. On the other hand, if $C=0$, then the fraction will simplify by itself and you'll get a different result.


How do I remove the header background image in Pixture Reloaded theme?

Question: I'm not sure why this is difficult, but how do I remove the default background image in the Pixture Reloaded theme?
Answer: For Pixture Reloaded 3.x, I made a subtheme and I added this CSS:
<code>#header, #header .header-inner {
    background: mycolor;
    background-color: mycolor; }
</code>
Comment: To what CSS file?  When I change the colors.css file, the changes don't take effect.
Comment: If you made a subtheme, you should add this line to the subtheme.css file in the css directory of the subtheme.
Comment: I'm using the Pixture Reloaded theme.
Comment: Ok.  In that case you can add/modify the pixture_reloaded.css file in the CSS directory.  However, since you're not using a subtheme, you will have to make this change every time you update the theme to a new version.
Comment: I did that originally, and that doesn't work.
Comment: Did you clear the cache after saving changes?
Comment: Religiously.  The file ends up in sites/default/files/color/pixture_reloaded-(some unique val)/colors.css.
Comment: Any ideas how I remove it??
Answer: I deleted the temp directories and css cache files, selected the theme color again, and it worked.


the value of "User.Identity.Name" on asp.net mvc 3

Question: i work on web app using asp.net mvc 3 , the problem is with the variable "User.Identity.Name" taht return name and not UserId . have you already this problem ?
Answer:
have you already this problem ?

That's not a problem. It is by design. Inside the forms authentication cookie only the username is stored. You could have an index on your database on the username column and efficiently retrieve the user details given this unique username.
Answer: User.Identity.Name property contains the string, that was passed to FormsAuthentication.SetAuthCookie(thisString) during authentication.
If you want this property to contain an userId, change the authentication code to
FormsAuthentication.SetAuthCookie(userId);

Comment: It was the simple issue , thanks Mr Juraj and thank you all for your answers !!
Answer: As Darin said, its by design.
In your forms authentication cookie creation method, just save your UserID in the Name property


Find new polynomial coefficients using Vieta's formulas

Question:
$p(x)=x^3+ax^2+bx+c$ has roots $x_1,x_2,x_3$. Find $a,b,c$ for $q(x)$ which has roots at $x_1+x_2$, $x_1+x_3$ and $x_2+x_3$.

I know that I'm supposed to use Vieta's formulas where
$$x_1+x_2+x_3=-a$$
$$x_1x_2+x_1x_3+x_2x_3=b$$
$$x_1x_2x_3=-c$$
but I do not know how to tackle this problem. Any solutions or tips?
Answer: Given that $x_1,x_2,x_3$ are the roots of the polynomial $$x^3+ax^2+bx+c$$
then by Vieta's formulas
$$x_1+x_2+x_3=-a,\;x_1x_2+x_2x_3+x_1x_3=b,\;x_1x_2x_3=-c.$$
Again by Vieta's formulas the polynomial with roots $x_1+x_2$, $x_2+x_3$, $x_3+x_1$ is equal to
$$x^3+Ax^2+Bx+C$$
where
\begin{align*}
-A&=(x_1+x_2)+(x_2+x_3)+(x_3+x_1)=2(x_1+x_2+x_3)=-2a\\
B&=(x_1+x_2)(x_2+x_3)+(x_2+x_3)(x_3+x_1)+(x_3+x_1)(x_1+x_2)=a^2+b\\
-C&=(x_1+x_2)(x_2+x_3)(x_3+x_1)=c-ab.
\end{align*}
Comment: Just to clarify: -2c/a will in this case be -2b as a=1 and c=b in p(x)?
Comment: Yes, let me edit my answer.
Answer: First I want to mention that you should obtain that $a$ is the component of your second order term, hier $a$ should be replaced by the third order term, which is $1$, so you should obtain that
\begin{align}
&x_1+x_2+x_3=-a,\\
&x_1x_2+x_2x_3+x_3x_1=b,\\
&x_1x_2x_3=-c.
\end{align}
Now let us suppose that $q(x)=x^3+a'x^2+b'x+c'$, which has roots $x_1+x_2,x_2+x_3,x_3+x_1$. Then again from Vieta's formula
\begin{align}
-a'&=2(x_1+x_2+x_3)=-2a,\\
b'&=(x_1+x_2)(x_2+x_3)+(x_2+x_3)(x_3+x_1)+(x_3+x_1)(x_1+x_2)\\
&=(x_1x_2+x_2x_3+x_3x_1)+(x_1+x_2+x_3)^2,\\
&=b+a^2,\\
-c'&=(x_1+x_2)(x_2+x_3)(x_3+x_1)\\
&=-(a+x_1)(a+x_2)(a+x_3)\\
&=-(a^3+(x_1+x_2+x_3)a^2+(x_1x_2+x_2x_3+x_3x_1)a+x_1x_2x_3)\\
&=c-ab.
\end{align}
So the new polynimil is $q(x)=x^3+2ax^2+(b+a^2)x+ab-c$.
Comment: I do not really get the first step in -c'. How do you include a in that part?
Comment: Since $x_1+x_2+x_3=-a$, you can replace $x_1+x_2=-a-x_3$ and so on.
Comment: @Winther yes, thanks^^
Comment: And hence, $-2ax^2$
Answer: Since $x_1+x_2+x_3=-a$ by Vieta's formulas, the new roots can be written as: $$y_1=x_2+x_3=-a-x_1\,,\quad y_2=-a-x_2\,,\quad y_3=-a-x_3\,$$
With the subsitution $y=-a-x \iff x = -y-a$ the equation satisfied by $y_{1,2,3}$ is:
$$0=p(x)=p(-a-y)=-(y+a)^3+a(y+a)^2-b(y+a)+c=-y^3-2ay^2-(a^2+b)y+c$$
Comment: This is my way.(+1)