I have an input...
<input type="text">
How do I block the commands (control+c and control+v) and right click, copy or paste?
I have an input...
<input type="text">
How do I block the commands (control+c and control+v) and right click, copy or paste?
Learning Scala as a programming language I came across the term tail-recursion, which is supposed to be better than normal recursion. What does this mean?
The query is as follows, there are 2 tables:
Pagos
-idPago
-idCliente
-fechaEnQuePaga
-fechaVencimiento
Cliente
-idCliente
-nombre
-apellidoPaterno
-apellidoMaterno
-correo
idCliente
is a foreign key. Assuming the tables have the following data:
Payment Table:
1 | 1 | 2018-02-23 | 2018-03-23
2 | 2 | 2018-02-23 | 2018-05-23
3 | 2 | 2018-02-23 | 2018-06-23
4 | 1 | 2018-04-23 | 2018-07-23
Clients table:
1 | Daniel | Sosa | Estrada | [email protected]
2 | Juan | Casas | Sola | [email protected]
And I want to get the customer data, followed by their payment data but, with the most distant due date, expecting to get:
1 | Daniel | Sosa | Estrada | 2018-04-23 | 2018-07-23
2 | Juan | Casas | Sola | 2018-02-23 | 2018-06-23
I have a query, which is similar but does not give me the expected results:
SELECT
cliente.idcliente,
nombre,
apellidoPaterno,
apellidoMaterno,
fechaEnQuePaga,
fechavencimiento
FROM cliente, pagos
WHERE (cliente.idcliente = pagos.idcliente)
GROUP BY idcliente;
Result:
1 | Daniel | Sosa | Estrada | 2018-02-23 | 2018-03-25
2 | Juan | Casas | Sola | 2018-02-23 | 2018-05-23
I noticed that if I add MAX()
it, it locates the furthest due date, but it does not show its corresponding payment date:
SELECT
cliente.idcliente,
nombre,
apellidoPaterno,
apellidoMaterno,
fechaEnQuePaga,
MAX(fechavencimiento)
FROM cliente, pagos
WHERE (cliente.idcliente = pagos.idcliente)
GROUP BY idcliente;
Result:
1 | Daniel | Sosa | Estrada | 2018-02-23 | 2018-07-25
2 | Juan | Casas | Sola | 2018-02-23 | 2018-06-23
The payment date does not correspond to the one in the row.
Thank you for your answer.
I have an alias to a static size array, it's very simple to use:
using triplet_t = std::uint8_t[3];
// vvvvvvvvvvvvvvvvvv <--- más fácil que std::uint8_t(&triplet)[3]
void f(const triplet_t &triplet) { /* whatever */ }
triplet_t t{}; // Tan bueno como std::uint8_t t[3]{};
t[0] = '0';
t[1] = '1';
t[2] = '2';
for (auto &v : t) std::cout << v << ' ';
std::cout << '\n';
// Todo correcto...
triplet_t t3[3]{};
for (auto &r : t3)
for(auto &v : r)
v = 42;
I can even use the alias in containers:
std::vector<triplet_t> vt;
Or so I thought, because the moment you use it vt
fails:
vt.push_back({});
GCC 8.0.0 201711
error: parenthesized initializer in array new [-fpermissive] { ::new((void *)__p) _Up(std::forward<_Args>(__args)...); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: request for member '~unsigned char [3]' in '* __p', which is of non-class type 'unsigned char [3]' destroy(_Up* __p) { __p->~_Up(); } ~~~~~~^~~
The problem seems to be that after unrolling all the template wizardry a placement-new is called which is passed the parameters in parentheses, and this is obviously not the way to initialize a statically sized array.
Also, somehow the container thinks it triplet_t
's an object and so asks for a destructor, again failing to compile. The problem obviously persists without the alias:
std::vector<std::uint8_t[3]> vt;
vt.push_back({}); // Mal!
vt.push_back({255, 0, 0}); // Error!
But there is no problem if an object with the same memory representation is used:
struct rgb { std::uint8_t r, g, b; };
std::vector<rgb> vt;
vt.push_back({}); // Bien!
vt.push_back({255, 0, 0}); // Genial!
I wonder why this happens. Is there a way to save statically sized arrays in containers?
Many times I find code difficult to read, since it is poorly structured or without indentation. In SOes we can find multiple examples of this.
Searching the site for a question that addresses this issue, I came across this one from @A.Cedano , PHP Naming Convention , but it doesn't really address style or best practices. I also did not find any questions that address PSR 1 and 2.
If I could find another similar one referencing html, css and js. Official style guides for HTML, CSS and Javascript
That's why I ask this question:
What are the tips or recommendations regarding the style and order of the code that should be taken into account when developing with PHP?