real analysis – Subtract equations: Confusion about what is meant here

I am referring to
this document on Backlund transformations.

In this paper, one has equations (50),
$$
begin{align*}
(w_1+w_0)_x&=2lambda_1+frac{1}{2}(w_1-w_0)^2\
(w_2+w_0)_x&=2lambda_2+frac{1}{2}(w_2-w_0)^2
end{align*},
$$

and equations (51),
$$
begin{align*}
(w_{12}+w_1)_x&=2lambda_1+frac{1}{2}(w_{12}-w_1)^2\
(w_{21}+w_2)_x&=2lambda_2+frac{1}{2}(w_{21}-w_2)^2
end{align*},
$$

Then it is said:

subtract the difference of eqns (50) from the difference of eqns (51) to give
$$
0=4(lambda_2-lambda_1)+frac{1}{2}((w_{12}-w_1)^2-(w_{21}-w_2)^2-(w_1-w_0)^2+(w_2-w_0)^2)
$$

I do not understand what is meant.
What do I have to subtract from what?
I am confused.

Hello I’ve created this db in postresql and every time I update it shows:Perhaps you meant to reference the column "product.id". pls help

drop table if exists product;
create table product(
id serial ,
name varchar(30),
price varchar(30),
qty varchar(30)

);
update product set name=’amir’, price=’dds’, qty=’eee’ where id =1;

security – How to setup Mysql master-slave replication with the slave meant for testing where divergence is OK

Problem:

I have a staging DB server on which functionality is tested before pushing it to the production environment. Now, we want to start doing VA/PT (Vulnerability Analysis and Penetration Testing) on our application, but since that can be destructive on the staging DB server, we want to make a separate Testing environment with a VAPT web+DB server.

Requirements:

  1. The data from the staging DB server must be replicated onto the VAPT DB server automatically so that specific new use cases, features, etc can be tested for vulnerabilities.

  2. Due to VAPT activities (testing data, SQL Injection, possibly DROP TABLE exploits, etc) the VAPT DB server itself will also have its own data changes, i.e. divergence from Staging DB (Master)

So, if I use simple Master-Slave replication as below I am assured of #1:
Staging DB (Master) -> VAPT DB (Slave)

But if I do #2, the slave will eventually diverge, which is fine for the testing environment, but, will it interrupt or mess with the Master-Slave replication as per #1?

An obvious example where divergence will cause errors is a VA/PT activity that causes DROP TABLE users so that the Staging DB (Master) users table trying to INSERT/UPDATE data will cause replication errors. Some UPDATEs/DELETEs might cause errors too.
In particular,
If I use ROW-based replication divergence will happen quickly causing frequent errors.
If I use STATEMENT-based replication, since ids will not match, it is possible that some data will break because ids are essential to link data in related tables even though we do not use foreign keys.

Alternatively, instead of replication, I could manually dump the Staging DB into the VAPT DB daily, which would be cumbersome to automate.
OR,
I could make copy DBs and setup various partial copy operations, but that would complicate matters too much, given that I am not a developer and that my developers often make and revert changes of various sizes randomly.

Surely someone has come across this problem in their work so far and there might be a set of best practices for this situation i.e. maintaining a match between staging and testing environments in real-time while allowing testing freedom to play with the data.
I tried googling for a while but the right phrasing for google escapes me. All I get is howtos for master slave replication, handling unwanted drift/divergence and so on. Nothing much about desired/accepted drift and divergence or partial replication.

Thanks in advance.

c++ – “observer pointer” meant to stay updated when the pointed object is moved in memory

I wasn’t sure about how to name it, maybe “follow_ptr”, “self_updating_ptr”, or “stalking_ptr” or something on those lines. For now it’s called Identifier.

What I’m trying to achieve is a pointer wrapper which will always refer to the same object even when that object is moved in memory (vector resizes is a quite frequent example, also algorithms like std::remove_if that can move elements around).


EDIT:
One requirement is to allow storing objects in sequential containers (like vector and deque) without losing sequential storage as one would by using unique_ptr or shared_ptr. This whole system is not meant to take care about ownership.

It’s my bad for using the term “smart pointer in the original title”, it’s smart in the sense that it follows the pointed object as opposed to an observer pointer which wouldn’t do that.


A requirement is that the object is stored within an “Identified” class. That class is necessary to keep all the Identifiers updated.

The trick is having a double indirection, where a raw pointer living in the heap will point to the object to be stalked:

#include <memory>
#include <stdexcept>

template <typename T>
class Identifier;
template <typename T>
class Identified;

// A pointer to an identified object. This object lives in the heap and is used to share information with all identifiers about the object moving in memory.
template <typename T>
class Inner_identifier
    {
    public:
        Inner_identifier() = default;
        Inner_identifier(T* identified) noexcept : identified{identified} {}

        Inner_identifier(const Inner_identifier& copy) = delete;
        Inner_identifier& operator=(const Inner_identifier& copy) = delete;

        Inner_identifier(Inner_identifier&& move) = delete;
        Inner_identifier& operator=(Inner_identifier&& move) = delete;

        T* identified{nullptr};
    };

The Identifier, or stalker, acts as an in-between a smart pointer and an optional. The idea is that if Identifiers outlive an object, they’re still valid (assuming the user checks with has_value before using them, like with an optional).

I’m unsure if I should just delete the default constructor, so that it’s always certain that an Identifier’s pointer to the Inner_identifier is always valid, and I can get rid of some checks. For now I’ve left it just to make writing the example simpler.

template <typename T>
class Identifier
    {
    public:
        Identifier() = default;
        Identifier(Identified<T>& identified) : inner_identifier{identified.inner_identifier} {}
        Identifier& operator=(Identified<T>& identified) { inner_identifier = identified.inner_identifier; return *this; }

        Identifier(const Identifier& copy) = default;
        Identifier& operator=(const Identifier& copy) = default;

        Identifier(Identifier&& move) = default;
        Identifier& operator=(Identifier&& move) = default;


        const T& operator* () const { check_all(); return *inner_identifier->identified; }
              T& operator* ()       { check_all(); return *inner_identifier->identified; }
        const T* operator->() const { check_all(); return  inner_identifier->identified; }
              T* operator->()       { check_all(); return  inner_identifier->identified; }

        const T* get() const { check_initialized(); return inner_identifier->identified; }
              T* get()       { check_initialized(); return inner_identifier->identified; }

        bool has_value() const noexcept { return inner_identifier && inner_identifier->identified != nullptr; }
        explicit operator bool() const noexcept { return has_value(); }

    private:
        std::shared_ptr<Inner_identifier<T>> inner_identifier{nullptr};

        void check_initialized() const
            {
#ifndef NDEBUG
            if (!inner_identifier) { throw std::runtime_error{"Trying to use an uninitialized Identifier."}; }
#endif
            }

        void check_has_value() const
            {
#ifndef NDEBUG
            if (inner_identifier->identified == nullptr) { throw std::runtime_error{"Trying to retrive object from an identifier which identified object had already been destroyed."}; }
#endif
            }

        void check_all() const { check_initialized(); check_has_value(); }
    };

Finally the Identified class, which holds the instance of the object to be pointed to by one or more Identifiers. It is responsible for updating the Inner_identifier whenever it is moved around in memory with either move constructor or move assignment. On the opposite the copy constructor makes sure that the new copy has its own new Inner_identifier and all the existing Identifiers still work with the instance being copied from. Upon destruction, the Inner_identifier is nullified but it will keep existing for reference as long as at least one Identifier to the now defunct object still exists (hence the internal shared_ptrs)

template <typename T>
class Identified
    {
    friend class Identifier<T>;
    public:
        template <typename ...Args>
        Identified(Args&&... args) : object{std::forward<Args>(args)...}, inner_identifier{std::make_shared<Inner_identifier<T>>(&object)} {}
        
        Identified(Identified& copy) : Identified{static_cast<const Identified&>(copy)} {}

        Identified(const Identified& copy) : object{copy.object}, inner_identifier{std::make_shared<Inner_identifier<T>>(&object)} {}
        Identified& operator=(const Identified& copy) { object = copy.object; return *this; } //Note: no need to reassign the pointer, already points to current instance

        Identified(Identified&& move) noexcept : object{std::move(move.object)}, inner_identifier{std::move(move.inner_identifier)} { inner_identifier->identified = &object; }
        Identified& operator=(Identified&& move) noexcept { object = std::move(move.object); inner_identifier = std::move(move.inner_identifier); inner_identifier->identified = &object; return *this; }

        ~Identified() { if (inner_identifier) { inner_identifier->identified = nullptr; } }
        
        const T& operator* () const { return *get(); }
              T& operator* ()       { return *get(); }
        const T* operator->() const { return  get(); }
              T* operator->()       { return  get(); }

        const T* get() const
            {
#ifndef NDEBUG
            if (!inner_identifier || inner_identifier->identified == nullptr) { throw std::runtime_error{"Attempting to retrive object from an identifier which identified object had already been destroyed."}; }
#endif
            return &object;
            }

        T* get()
            {
#ifndef NDEBUG
            if (!inner_identifier || inner_identifier->identified == nullptr) { throw std::runtime_error{"Attempting to retrive object from an identifier which identified object had already been destroyed."}; }
#endif
            return &object;
            }

        T object;
    private:
        std::shared_ptr<Inner_identifier<T>> inner_identifier;
    };

On top of criticisms, I’d like some advice on naming. If I were to call the Identifier “follow_ptr”, “self_updating_ptr”, or “stalking_ptr”, I’ve no idea how to call the other two classes.

Aside for the first capital letter of the classes, does the interface feel “standard” enough?

Here is an usage example, compile in debug mode for the exceptions:

#include <stdexcept>
#include <iostream>
#include <vector>
#include <algorithm>

struct Base
    {
    int tmp; bool enabled = true; bool alive = true;
    Base(int tmp) : tmp(tmp) {}
    virtual volatile void f() { std::cout << "Base::f" << tmp << std::endl; };
    void g() { std::cout << "Base::g" << tmp << std::endl; };
    };
struct TmpA : public Base
    {
    TmpA(int tmp) : Base(tmp) {}
    virtual volatile void f() override { std::cout << "TmpA::f" << tmp << std::endl; };
    void g() { std::cout << "TmpA::g" << tmp << std::endl;/**/ };
    };
 
int main()
    {
    //Create empty identifiers
    Identifier<TmpA> idn;
    Identifier<TmpA> id1;
    Identifier<TmpA> id5;

    std::vector<Identified<TmpA>> vec;

    if (true)
        {
        //Create some data and assign iit to identifiers
        Identified<TmpA> identified_a1{1};
        Identified<TmpA> identified_will_die{0};

        idn = identified_will_die;
        id1 = identified_a1;
        id5 = vec.emplace_back(5);

        //Move some identified objects around, this also causes the vector to grow, moving the object Identified by id5.
        vec.emplace_back(std::move(identified_a1));
        }

    std::cout << " _______________________________________________ " << std::endl;
    std::cout << "vec(0): " << " "; try { vec(0)->f(); } catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "vec(1): " << " "; try { vec(1)->f(); } catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "id1:    " << " "; try { id1->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "id5:    " << " "; try { id5->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "null:   " << " "; try { idn->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }

    //Move some identified objects around
    std::partition(vec.begin(), vec.end(), ()(Identified<TmpA>& idobj) { return idobj->tmp > 2; });
    
    std::cout << " _______________________________________________ " << std::endl;
    std::cout << "vec(0): " << " "; try { vec(0)->f(); } catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "vec(1): " << " "; try { vec(1)->f(); } catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "id1:    " << " "; try { id1->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "id5:    " << " "; try { id5->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "null:   " << " "; try { idn->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    }

c++ – “Smart pointer” meant to stay updated when the pointed object is moved in memory

I wasn’t sure about how to name it, maybe “follow_ptr”, “self_updating_ptr”, or “stalking_ptr” or something on those lines. For now it’s called Identifier.

What I’m trying to achieve is a pointer wrapper which will always refer to the same object even when that object is moved in memory (vector resizes is a quite frequent example, also algorithms like std::remove_if that can move elements around).

A requirement is that the object is stored within an “Identified” class. That class is necessary to keep all the Identifiers updated.

The trick is having a double indirection, where a raw pointer living in the heap will point to the object to be stalked:

#include <memory>
#include <stdexcept>

template <typename T>
class Identifier;
template <typename T>
class Identified;

// A pointer to an identified object. This object lives in the heap and is used to share information with all identifiers about the object moving in memory.
template <typename T>
class Inner_identifier
    {
    public:
        Inner_identifier() = default;
        Inner_identifier(T* identified) noexcept : identified{identified} {}

        Inner_identifier(const Inner_identifier& copy) = delete;
        Inner_identifier& operator=(const Inner_identifier& copy) = delete;

        Inner_identifier(Inner_identifier&& move) = delete;
        Inner_identifier& operator=(Inner_identifier&& move) = delete;

        T* identified{nullptr};
    };

The Identifier, or stalker, acts as an in-between a smart pointer and an optional. The idea is that if Identifiers outlive an object, they’re still valid (assuming the user checks with has_value before using them, like with an optional).

I’m unsure if I should just delete the default constructor, so that it’s always certain that an Identifier’s pointer to the Inner_identifier is always valid, and I can get rid of some checks. For now I’ve left it just to make writing the example simpler.

template <typename T>
class Identifier
    {
    public:
        Identifier() = default;
        Identifier(Identified<T>& identified) : inner_identifier{identified.inner_identifier} {}
        Identifier& operator=(Identified<T>& identified) { inner_identifier = identified.inner_identifier; return *this; }

        Identifier(const Identifier& copy) = default;
        Identifier& operator=(const Identifier& copy) = default;

        Identifier(Identifier&& move) = default;
        Identifier& operator=(Identifier&& move) = default;


        const T& operator* () const { check_all(); return *inner_identifier->identified; }
              T& operator* ()       { check_all(); return *inner_identifier->identified; }
        const T* operator->() const { check_all(); return  inner_identifier->identified; }
              T* operator->()       { check_all(); return  inner_identifier->identified; }

        const T* get() const { check_initialized(); return inner_identifier->identified; }
              T* get()       { check_initialized(); return inner_identifier->identified; }

        bool has_value() const noexcept { return inner_identifier && inner_identifier->identified != nullptr; }
        explicit operator bool() const noexcept { return has_value(); }

    private:
        std::shared_ptr<Inner_identifier<T>> inner_identifier{nullptr};

        void check_initialized() const
            {
#ifndef NDEBUG
            if (!inner_identifier) { throw std::runtime_error{"Trying to use an uninitialized Identifier."}; }
#endif
            }

        void check_has_value() const
            {
#ifndef NDEBUG
            if (inner_identifier->identified == nullptr) { throw std::runtime_error{"Trying to retrive object from an identifier which identified object had already been destroyed."}; }
#endif
            }

        void check_all() const { check_initialized(); check_has_value(); }
    };

Finally the Identified class, which holds the instance of the object to be pointed to by one or more Identifiers. It is responsible for updating the Inner_identifier whenever it is moved around in memory with either move constructor or move assignment. On the opposite the copy constructor makes sure that the new copy has its own new Inner_identifier and all the existing Identifiers still work with the instance being copied from. Upon destruction, the Inner_identifier is nullified but it will keep existing for reference as long as at least one Identifier to the now defunct object still exists (hence the internal shared_ptrs)

template <typename T>
class Identified
    {
    friend class Identifier<T>;
    public:
        template <typename ...Args>
        Identified(Args&&... args) : object{std::forward<Args>(args)...}, inner_identifier{std::make_shared<Inner_identifier<T>>(&object)} {}
        
        Identified(Identified& copy) : Identified{static_cast<const Identified&>(copy)} {}

        Identified(const Identified& copy) : object{copy.object}, inner_identifier{std::make_shared<Inner_identifier<T>>(&object)} {}
        Identified& operator=(const Identified& copy) { object = copy.object; return *this; } //Note: no need to reassign the pointer, already points to current instance

        Identified(Identified&& move) noexcept : object{std::move(move.object)}, inner_identifier{std::move(move.inner_identifier)} { inner_identifier->identified = &object; }
        Identified& operator=(Identified&& move) noexcept { object = std::move(move.object); inner_identifier = std::move(move.inner_identifier); inner_identifier->identified = &object; return *this; }

        ~Identified() { if (inner_identifier) { inner_identifier->identified = nullptr; } }
        
        const T& operator* () const { return *get(); }
              T& operator* ()       { return *get(); }
        const T* operator->() const { return  get(); }
              T* operator->()       { return  get(); }

        const T* get() const
            {
#ifndef NDEBUG
            if (!inner_identifier || inner_identifier->identified == nullptr) { throw std::runtime_error{"Attempting to retrive object from an identifier which identified object had already been destroyed."}; }
#endif
            return &object;
            }

        T* get()
            {
#ifndef NDEBUG
            if (!inner_identifier || inner_identifier->identified == nullptr) { throw std::runtime_error{"Attempting to retrive object from an identifier which identified object had already been destroyed."}; }
#endif
            return &object;
            }

        T object;
    private:
        std::shared_ptr<Inner_identifier<T>> inner_identifier;
    };

On top of criticisms, I’d like some advice on naming. If I were to call the Identifier “follow_ptr”, “self_updating_ptr”, or “stalking_ptr”, I’ve no idea how to call the other two classes.

Aside for the first capital letter of the classes, does the interface feel “standard” enough?

Here is an usage example, compile in debug mode for the exceptions:

int main()
    {
    //Create empty identifiers
    Identifier<TmpA> idn;
    Identifier<TmpA> id1;
    Identifier<TmpA> id5;

    std::vector<Identified<TmpA>> vec;

    if (true)
        {
        //Create some data and assign iit to identifiers
        Identified<TmpA> identified_a1{1};
        Identified<TmpA> identified_will_die{0};

        idn = identified_will_die;
        id1 = identified_a1;
        id5 = vec.emplace_back(5);

        //Move some identified objects around, this also causes the vector to grow, moving the object Identified by id5.
        vec.emplace_back(std::move(identified_a1));
        }

    std::cout << " _______________________________________________ " << std::endl;
    std::cout << "vec(0): " << " "; try { vec(0)->f(); } catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "vec(1): " << " "; try { vec(1)->f(); } catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "id1:    " << " "; try { id1->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "id5:    " << " "; try { id5->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "null:   " << " "; try { idn->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }

    //Move some identified objects around
    std::partition(vec.begin(), vec.end(), ()(Identified<TmpA>& idobj) { return idobj->tmp > 2; });
    
    std::cout << " _______________________________________________ " << std::endl;
    std::cout << "vec(0): " << " "; try { vec(0)->f(); } catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "vec(1): " << " "; try { vec(1)->f(); } catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "id1:    " << " "; try { id1->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "id5:    " << " "; try { id5->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    std::cout << "null:   " << " "; try { idn->f(); }    catch (std::exception& e) { std::cout << e.what() << std::endl; }
    }

wallet – How can I trade cryptocurrency the way it meant to be fees-free, unidentified, and secure?

My first post here and my first time to look for cryptocurrencies

My understanding of cryptocurrency that it is uncontrolled and no mediators and no fees for exchange

Today I registered at coinbase and it asked for my ID and veridication

and when i wanted to purchase coins I got 10% going for fees !!

How can I trade cryptocurrency the way it meant to be fees-free, unidentified, and secure?

unity – Effective solution for showing the outline of the player sprite when behind objects or tiles that are meant to be in foreground

I’m very new to Unity and I’m now experimenting with possible ways to show the player outline when he/she is behind object or tiles. This is what I came up with:

enter image description here

The idea I came up with is as follow:

  • Create a Sprite GameObject (let’s call it OutlineSprite) with the same sprite used by the player and assign it as child of the PlayerSprite
  • Assign, to the OutlineSprite, a “Order in Layer” greater than anything else.
  • Assign, to the OutlineSprite, the same animator used for the Player sprite (and modify the c# script that sends notification to the animation controller whenever the player moves so that it sends notification to the OutlineSprite animation controller too)
  • Assign, to the OutlineSprite, a material which uses a shader able to render the outline of a given sprite (I just copy/pasted a shader I found online which does more or less what I wanted, I’m not anywhere near to understand how to write a shader right now)
  • Modify the player Sprite outline so that it exactly match the shape of the sprite
  • Put a Sprite Mask in every place you need to create this effect (in the screenshot is just over the house roof)
  • Configure the Player sprite to be “Visible outside mask” and the OutlineSprite to be “Visible inside mask”

This solution seems to do what I need but has many cons that I’d like to address, if possible.

Pro:

  • simple solution that doesn’t require extensive knowledge of advanced concepts

Cons:

  • the player animation runs twice
  • tedious to manually configure the outline of all the animation sprites
  • tedious to manually place the sprite mask where needed

My question is: is there a better to achieve the same effect which can mitigate the cons of the solution above?

Since my experience with Unity and game dev in general is pretty much zero, I’d also like to know if there are other possible problems of my solution that I’m not anticipating.

drivers – start /wait doesn’t wait. How to workaround without using pause in script (Script is meant to be unattended)

I have a script that is run after windows is installed and performs a vast number of tasks, including installation of drivers and various programs. The intent is that the script is run unattended.

I am adding code to install printer drivers, in this case the Canon TS8300 series.

I think the problem is that that the installer runs in several parts. The first step is to extract the drivers and various utilities that come with the installer. I notice that once the extraction has completed the script continues.

If I understand the /wait parameter on the start command (and please correct me if I’m wrong), this is expected behavior. That certainly seems to be the consensus from the searches I’ve done.

The command is;

start /wait "TS8300 Installation" /d "%SRC%PostInstallCanon" "win-ts8300-1_02-ea34_2.exe"

I’ve also tried with start /b /wait (apparently /wait /b is also known to not work).

As the next step in the code is to stop and delete a service that is installed, that fails because it’s executing before the service has been installed as the script does not wait. So I’ve temporarily added a pause but that means I have to be there to press the any key.

I thought about simply using ping x.x.x.x -n yy >nul and it might work if I get the value of yy right (which will probably vary depending on the PC). It’s better than using pause, but I was hoping there might be something a bit more elegant and fool proof.

Thoughts?