## vue.js – Cargar variables y data con pusher laravel en tiempo real

Actualmente estaba haciendo pruebas con websockets en php puro y me gusto demasiado estaba haciendo una conexion externa y guardaba la conexion en una variable algo asi
este seria mi index.html

``````<html>
<style>
input, button { padding: 10px; }
</style>
<body>
<input type="text" id="message" />
<button onclick="transmitMessage()">Send</button>
<script>
// Create a new WebSocket.
var socket  = new WebSocket('ws://localhost:8080/2020/rachet');

// Define the
var message = document.getElementById('message');

function transmitMessage() {
var dataSend = {"consulta":{
'texto':message.value
}
};
socket.send( JSON.stringify(dataSend));
}

socket.onopen = function(e){
}
socket.onmessage = function(e) {
}
</script>
</body>
``````

y este seria mi servidor

``````    <?php

namespace MyApp;

use RatchetMessageComponentInterface;
use RatchetConnectionInterface;
use phpseclibNetSFTP;

class Socket implements MessageComponentInterface {
private \$id_sockets;
protected \$connection;
protected \$shell;
protected \$ruta;
public function __construct()
{
\$this->clients = new SplObjectStorage;
}

public function onOpen(ConnectionInterface \$conn) {

// Store the new connection in \$this->clients
\$this->clients->attach(\$conn);
\$this->id_sockets = 'conectado a la red o consola de ssh2';

\$this->connection(\$conn->resourceId) = \$this->connectSSH();

\$this->ruta(\$conn->resourceId) = \$this->connection(\$conn->resourceId)->pwd();
echo "New connection! ({\$conn->resourceId})n";
}
public function connectSSH(){
\$sftp = new SFTP('pruebas');

}
return \$sftp;
}
public function onMessage(ConnectionInterface \$from, \$msg) {
\$data = json_decode(\$msg,true);
switch (key(\$data)) {

case 'mensajes':
\$connect = \$this->connection(\$from->resourceId)->pwd();
\$from->send( "Entramos en la seccion mensajes hola como estas  \$connect  " );
//echo \$this->connection(\$from->resourceId)->pwd(); // show that we're in the 'test' directory

break;
case 'consulta':
\$ruta_actual = 'cd /home;';
if (\$data == 'cd') {
#
}

\$this->shell(\$from->resourceId) = \$this->connection(\$from->resourceId)->exec(\$ruta_actual.\$data('consulta')('texto'));
\$connect = \$this->shell(\$from->resourceId);

\$from->send( " \$connect  " );

break;
default:
foreach ( \$this->clients as \$client ) {

if ( \$from->resourceId == \$client->resourceId ) {
\$from->send( "\$this->id_sockets ---- \$msg" );
//continue;
}
//\$client->send( "Client \$from->resourceId said \$msg" );
}
break;
}

}

public function onClose(ConnectionInterface \$conn) {
}

public function onError(ConnectionInterface \$conn, Exception \$e) {
}
}
``````

Eso funciona bien me guarda la conexion de un ssh y todo bien para los exec en esta mini prueba que realice ahora bien, intente pasar esto a laravel y vi que estaba mejor usar pusher

Pero en pusher veo que el canal de comunicacion lo manejamos como un evento y solo le enviamos mensajes seguidamente afuera solo esperamos el llamado del mismo y que responda algo como esto

``````Echo.channel('message').listen('MessageSend', (e) => {
});
``````

con eso cuando se envie un mensaje solo responde y si intento cargar variables en el canal no lo haria como lo hace pusher, quisiera saber si algo relacionado con pusher para hacer algo asi como el websocket he invetigado y siempre me topo con lo mismo , mas bien como que es mas complicado todo con pusher :s , de antemano gracias, disculpen las molestias y bueno aun soy novato

## calculus and analysis – Multiply Taylor expanded matrices with multiple variables and different order

I want to multiply rotation matrices (Eulermatrix) that are expanded in Taylor series to a different order. When I use Series on the separate matrix, the multi-variable already gives an unwanted result since it does not recognize multiplications of variables as a higher order. This can be solved as described in Multivariable Taylor expansion does not work as expected.

But I cannot get this to work if I want to expand the different matrix to a different order, because again terms of the 3rd order are introduced. Whereas I would like the output to be of the order 2 in the following example.

``````(Series(EulerMatrix({(Alpha)*t, (Beta)*t, (Gamma)*t}, {1, 2,
3}).EulerMatrix({(Theta)*s, (Phi)*s, (Eta)*s}, {1, 2,
3}), {t, 0, 1}, {s, 0, 2})) // Normal // MatrixForm
``````

## cv.complex variables – Image of transcendental meromorphic functions

Let $$f$$ be a trancendental meromorphic function such that $$f'(z) ne 0$$ for all $$z in mathbb{C}$$. Let $$Pi$$ be the stereoprojection map from the north pole on the unit sphere. My question is the following:

For any two points $$P,Q in mathbb{C}$$, can we find a curve $$gamma$$ connecting $$P$$ and $$Q$$, such that $$Pi^{-1}(f(gamma))$$ lies in a great circle on the unit sphere, and that $$Pi^{-1}(f(gamma))$$ cover the circle at most once as points go from $$P$$ to $$Q$$ along the curve $$gamma$$?

Any ideas or comments are really appreciated!

## cv.complex variables – Cauchy’s Integral with quadratic exponential term

As I was studying the Cauchy’s integral formula, I tried to do the integral:

$$begin{equation} I(x) = int_{-infty}^{infty} frac{1}{x – a} e^{(i A x^2 + i B x)} dx end{equation}$$
with $$A>0, B>0$$ and $$a > 0$$.

Consider an integral on a complex plan:
$$begin{equation} J(z) = int_{C + C_R} frac{1}{z – a} e^{(i A z^2 + i B z)} dz end{equation}$$
where $$C$$ is along the real axis $$-infty rightarrow +infty$$ and $$C_R$$ is the upper half circle $$z = Re^{itheta}$$ with $$R rightarrow infty$$ and $$theta in (0, 2pi)$$.

Naively, I would expect $$C_R$$ part of the integral gives zero and $$C$$ part of the integral gives $$I(x)$$, then the $$I(x)$$ can be derived by Cauchy’s integral formula.

However, as I tried to check the $$C_R$$ part of the integral, I found that:
$$begin{array} I_R(z = Re^{itheta}) &=& int_0^{pi} dtheta frac{iRe^{itheta}}{Re^{itheta} – a} exp(iAR^2e^{2itheta}+iBRe^{itheta}) end{array}$$

$$begin{array} |I_R| &leq & int_0^{pi} dtheta |frac{iRe^{itheta}}{Re^{itheta} – a}| |exp(iAR^2e^{2itheta}+iBRe^{itheta})| end{array}$$
where the first term

$$begin{equation} |frac{iRe^{itheta}}{Re^{itheta} – a}| leq frac{R}{R-a} rightarrow 1 as R rightarrow infty end{equation}$$

and the second term
$$begin{equation} |exp(iAR^2e^{2itheta}+iBRe^{itheta})| leq e^{-AR^2sin(2theta) – BRsin(theta)} end{equation}$$
will not approach to zero because of $$e^{-AR^2sin(2theta)}$$.

Is there anything wrong in my approach? And is there any other way I can perform this integral I(x)?

## command line – Bash doesn’t expand variables when pressing Tab key

In the previous versions of Ubuntu 18.04, the variables in bash are expanded when I press the Tab key. But in Ubuntu 20.04 (using bash 5.0.16), the variables are not expanded, instead the dollar sign \$ before the variable gets proceeded by a backward slash.

For example, let’s say, I have a variable `MY_DIRECTORY`:

``````export MY_DIRECTORY=/path/to/a/folder
``````

Now when I write something like this:

``````ls \$MY_DIRECTORY<Tab key>
``````

I get:

``````ls \$MY_DIRECTORY
``````

As you can see, the variable don’t expand to the desired path. What is wrong with that?

Thanks

## python – Usar variables ciclicas en Random Forest machine learning

He transformado una variable predictora de mi modelo de machine learning en una variable ciclica mediante senos y cosenos. Por lo que entiendo al aplica el Random Forest las variables predictoras son escogidas aleatoriamente para construir cada uno de los árboles. Al suceder esto es muy probable que no haya árboles dentro del modelo que tengan solo el cosenos y otras solo el seno. Esto podría resultar un problema?

Pasaría lo mismo si he codificado variables categóricas en dummievariables?

Gracias!

## calculus and analysis – Can you force Integrate[] to find a complete symbolic solution for all variables?

(As I’ve asked on the Math StackExchange and on a related previous question), I am interested in getting a complete symbolic solution to the integral of an expression with a lot of unassigned variables. If you combine some of the variables, the integral can be reduced to the form:

$$int_{-infty}^infty frac{text{A} Delta +text{B}}{left(Delta ^2+W^2right) left(text{C}+text{D}Delta +text{E}Delta ^2 right)}dDelta$$

Mathematica claims that the solution to this integral is:

$$frac{pi (text{B}-i text{A} W)}{W (text{C}-W (text{E} W+i text{D}))} text{if: } Imleft(frac{Epmsqrt{E^2-4 C E}}{E}right)<0$$

Shown as code:

``````Integrate(
(A1 Δ + B1)/((W^2 + Δ^2) (C1 + D1 Δ + E1 Δ^2)),
{Δ, -∞, ∞}, Assumptions -> {W > 0})
``````

Which returns:

``````ConditionalExpression((π (B1 - I A1 W))/(
W (C1 - W (I D1 + E1 W))),
Im((D1 - Sqrt(D1^2 - 4 C1 E1))/E1) < 0 &&
Im((D1 + Sqrt(D1^2 - 4 C1 E1))/E1) < 0 && Re(W) > 0)
``````

Mathematica generates a conditional-expression, but doesn’t specify if this is a “full” answer. For instance what if we consider the integral under the domain of parameters with the opposite inequalities: $$Imleft(frac{Epmsqrt{E^2-4 C E}}{E}right)>0$$? Is there a solution in this domain of parameters?

I can try to force Mathematica to spit out an answer under different conditions. For example:

``````Integrate(
(A1 Δ + B1)/((W^2 + Δ^2) (C1 + D1 Δ + E1 Δ^2)),
{Δ, -∞, ∞},
Assumptions -> {W > 0, Im((D1 - Sqrt(D1^2 - 4 C1 E1))/E1) > 0,
Im((D1 + Sqrt(D1^2 - 4 C1 E1))/E1) < 0})
``````

I can get another symbolic answer for this new parameter space:

$$frac{i pi left(text{A1} D W+(-i) text{B1} sqrt{D^2-4 C E}-2 text{B1} E Wright)}{W sqrt{D^2-4 C E} left(C+W left(E W+i sqrt{D^2-4 C E}right)right)}$$

Is there an option to do this automatically and generate a solution for the entire set of possible combinations in the domain space? I’m honestly pretty surprised that it does not automatically return a combined piece-wise function with these different integrated results.

## deprecation – MySQL 8 – user variables within expressions is deprecated [UDF calls with lot of parameters]

I have this:

``````SELECT
@foo1 := UDF1(0, a, b, c, d) AS Foo1,
@foo2 := UDF1(1, a, b, c, d) AS Foo2,
@foo3 := UDF1(2, a, b, c, d) AS Foo3,
@foo4 := UDF1(3, a, b, c, d) AS Foo4,
@foo5 := UDF2( @foo1, @foo2, @foo3, @foo4) AS Foo5,
@foo6 := UDF3( @foo1, @foo2, @foo3, @foo4) AS Foo6,
@foo8 := UDF4( @foo5, @foo7, x, y, z) AS Foo8
FROM MyTable;
``````

As you can see it’s quite complicated and `a`, `b`, `c`, `d`, `x`, `y` and `z` are field names which are quite long (The names express their functionality).

I receive now this error message on MySQL 8.0.20:

X Setting user variables within expressions is deprecated and will be
removed in a future release. Consider alternatives: ‘SET
variable=expression, …’, or ‘SELECT expression(s) INTO
variables(s)’.

OK, this is the wrong place to discuss if it makes sense that `@var := value` is deprecated, so I have to move on and I want to assure that the program doesn’t stop working if the next MySQL update is installed.

I could solve it like this:

``````SELECT
@foo1 := UDF1(0, a, b, c, d) AS Foo1,
@foo2 := UDF1(1, a, b, c, d) AS Foo2,
@foo3 := UDF1(2, a, b, c, d) AS Foo3,
@foo4 := UDF1(3, a, b, c, d) AS Foo4,
@foo5 := UDF2(UDF1(0, a, b, c, d), UDF1(1, a, b, c, d), UDF1(2, a, b, c, d), UDF1(3, a, b, c, d)) AS Foo5,
@foo6 := UDF3(UDF1(0, a, b, c, d), UDF1(1, a, b, c, d), UDF1(2, a, b, c, d), UDF1(3, a, b, c, d) ) AS Foo5,
@foo6 := UDF3(UDF2(UDF1(0, a, b, c, d) , UDF1(1, a, b, c, d) , UDF1(2, a, b, c, d) , UDF1(3, a, b, c, d) ) ,
UDF3(UDF1(0, a, b, c, d), UDF1(1, a, b, c, d), UDF1(2, a, b, c, d), UDF1(3, a, b, c, d) ), x, y, z) AS Foo6
FROM MyTable;
``````

Honestly, doesn’t this hurt and, what I find worst, it becomes so unreadable and changing any call I have to maintain many times –> buggy.

Also, in the current version the length of the SELECT grows from 2’334 bytes to 3’504 bytes.

I am trying to work with a temporary table but to fill the table is a quite long and (useless) complicated SELECT using `LEFT JOIN` as `@foo5` depends on `@foo1-4` and `@foo6` depends on `@foo5`.

This works, but I am wondering if there may be another solution I am not capable to see. The suggested `SELECT expression(s) INTO variables(s)` I don’t understand how this should help in my case.

As I wrote in the beginning, I don’t understand why this feature is deprecated as it apparently can solve lot of troubles and makes complicated SELECT statements simpler…

Any suggestions?

## pr.probability – Probability distribution of sum of squares of sum/difference of uniform random variables

If we pick $$k$$ uniformly random integers $$x_1,dots,x_kin{0,1,dots,2^t-2,2^t-1}$$ then what is the probability distribution of the quantities
$$sum_{substack{i,j=1\ileq k}}^n(x_i-x_j)^2$$
$$sum_{substack{i,j=1\ileq k}}^n(x_i+x_j)^2$$ when $$k=t^alpha$$ at some $$alphain(0,infty)$$?

For reference sum of squares of normally distributed variables is given by $$chi^2$$-distribution while sum of uniform random variables is given by Irwin–Hall distribution.

## pr.probability – Minimum mean over all random variables subject to logarithm constraint

Does the following problem have a solution?
$$min_X mathbb{E} X quadtext{subject to}quad mathbb{E} log X = C.$$

Here, the minimization is with respect to all integrable random variables $$X$$ and $$C$$ is some constant. Alternatively, instead of minimizing over random variables, one may equivalently view this as optimizing over the space of probability measures.