## mysql – Can we use proxysql 2.x for load balancing multiple Galera clusters?

We have recently introduced proxysql 2.x for loadbalancing a galera cluster in production environment. It is working great so far.

I have been tasked to separate staging cluster which is currently in same production instance.

Can I use the same proxysql instance to load balance staging cluster to avoid redundancy ?

I am bit hesitant at the same time considering proxysql 2.x does not really know anything about the cluster.

Has anyone of you used the same proxysql 2.x instance for multiple clusters? Are there any risks?

## mysql – How to store multiple data types for same column (for many columns)

To preface, similar questions have been asked, but I have not found any that address a table that has a large number of columns affected by this issue. All the similar seem to address a table that has a small number of columns affected by this issue…

…but I have a MySQL database table that has many (e.g., 30) columns currently setup as the data type `decimal(5,2)`.

Now, a new scenario has arisen where I need to enter a `decimal(5,2)` OR a `char(2)` (i.e., one or the other, but never both) for each of those 30 columns. To give you context, I am entering the quantity of elements detected in a sample and, if the quantity of an element is not detected, then I must be able to identify that an element was tested, but not detected, such as “ND”.

So, my initial thought was to change the change columns’ type to a `varchar`, in order for the columns to be able to store either a `char(2)` or `decimal(5,2)` value, but that seems be a dangerous path called `Entity-Attribute_Value`, which may require me to build the application layer more to accommodate the limitations caused by it.

So, I read chapter 6 of the book “SQL Antipatterns: Avoiding the Pitfalls of Database Programming” (http://rads.stackoverflow.com/amzn/click/1934356557) and several other related posts, and the two most common answers seem to be:

1. Use a design that is based on the type of query you want to perform.

In my case, I want to perform multiple types of queries that compare column values of different rows, determine averages, and possibly unforeseen more.

2. Use the `Class Table Inheritance` design.

I would like to implement the `Class Table Inheritance` design, but that would require many more tables to be created for each column. It seems like an overly complex solution, given the many columns that need only one of two types of data.

For example, if my understanding about `Class Table Inheritance` is correct, then for each of the 30 columns in my base table, I must create a single table for each subtype and make their primary key also serve as a foreign key to the base table, which means that I must create 60 tables. It seems excessive to create 60 tables in order to deal with 30 columns that might have one of two data types. Also, it seems that I would need to figure a way to manage those 30 pairs of tables so they refer to the same column, possibly in the application layer.

One possible solution that comes to mind before I end this post is: Use the `Class Table Inheritance` design, but instead of creating 30 pairs of tables for my two data types, create just 2 tables for the 2 data types and add a column that stores a value that relates each pair, such as the name of the base table column that they would relate to. But this does not seem like good practice either.

Any suggestions?

## dnd 5e – Can I choose which damage type my Sneak Attack does if my weapon does multiple types?

Contrary to the answer in the linked question, allow me to propose that Sneak Attack doesn’t have a damage type because there is no type specifically mentioned in the text.

### Not all damage needs to be typed

See this answer on the damage type caused by blood loss, as well as some in-universe examples of untyped damage: the Stirge’s Blood drain, the Bearded Devil’s Glaive, and the Horned Devil’s Tail. Some types of damage in D&D is untyped and does not fit with the default types.

### Sneak Attack only says you deal extra damage, without a type mentioned

The text for Sneak Attack says only this:

Beginning at 1st level, you know how to strike subtly and exploit a foe’s distraction. Once per turn, you can deal an extra 1d6 damage to one creature you hit with an attack if you have advantage on the attack roll. The attack must use a finesse or a ranged weapon.

You can reason out that, just as the blood loss over time does not have a well-defined type of damage, you can argue that the extra SA damage comes from the exploitation of the target’s distractions and weak spots — which is itself not a kind of well-defined damage.

This tweet claims that all damage has a type, given by Jeremy Crawford himself. This clearly shows the intent behind damage types. However, his tweet is directly contradicted by the Monster Manual, a core rulebook, by showing instances of damage that do not have a damage type.

Note that these instances are not mistakes because they are not in the errata. We are left with the designer stating design intentions that is contradicted by a core rulebook. The core rulebook is more authoritative than a tweet — that’s why it’s a core rulebook.

Without JC’s statement about all damage having a type, the viewpoint that some damage does not have a type is stronger.

You don’t get to choose the damage type of Sneak Attack as it is an untyped damage on top of your normal weapon damage dice.

## artificial intelligence – A* search tree version – Can a node be in the frontier multiple times

I took an exam today and it had a question on A* tree search version, we only briefly skimmed over this on the material, focusing more on the graph search version.

In the example in the question text it showed a node being expanded and then a node already in the frontier being added again, due to the expansion, so it was listed twice in the frontier.

I did know about this, and so in my answers, when I needed to show the state of the frontier, and expanding a node meant a node already in the frontier was shown I added it again.

This meant in my answer I had a node in the frontier twice, but I am not sure if this was correct, as the question was long and involved showing the frontier multiple times, and I had the node in there twice, if it is wrong I likely got most of the question wrong.

Could someone tell me if this is something that happens with the tree search version, where there is no explored set, I am wondering if it was just a typo in the question text now.

## typescript – How to pick query data out of an object that can be of multiple types?

I’m trying to run either a `projectQuery` or `itemQuery` hook that returns either `{ projects }` or `{ items }` respectively in a variable called `data`. When I look at the type of `data` it shows up as `ProjectsQuery | ItemsQuery` which is correct.

``````  const isProject = type === RootTypes.ProjectType;
const { loading, error, data } = isProject ? useProjectsQuery({}) : useItemsQuery({});
const { projects, items } = data || {};
const thingList = isProject ? projects : items;
``````

How can I selectively pull either `projects` or `items` out of my data object while preserving the type? The TypeScript error I get with the code below is that the `ProjectsQuery` type does not have `items` and vice versa, which is obviously correct. Is there an elegant way to handle this? The way that I was shying away from was running the query for both and then selecting which data I’d use based on the `isProject` enum.

I know one elegant way is to do type-checking like this:

``````export const isProject = (thing: Project | Item): thing is Project => {
return (thing as Project).__typename === 'Project';
};
``````

but the problem is that I need to have the object to actually run this function on it and I’m using an enum to determine what type I have so I only have the object within the `data` object and that’s exactly what I’m trying to extract out of it.

## DNS Cache Poisoning With Multiple Requests

I am trying to understand this DNS cache poisoning from a textbook.

Is it the case that the server does not check any pending requests for a given domain and will send all of the n “same” requests to the DNS Lookup?

If the attacker manages to guess one Query ID and poison the cache why don’t the other legitimate DNS replies overwrite the poisoned cache when they come back?

## 8 – How to override nid filter to accept multiple values on views

I have read a dozen of open tickets on this issue, but none of them explains how to solve this.
Lets say I have a raw array of nids and wanting to override the query in a hook for the nid filter.
The nid filter allows only 1 value or some of the operators given in the image below.

There isnt an operator “is one of” as in the taxonomy reference filter. So how could this be overriden and allow multiple values for the nids?
Is this possible perhaps within the hook_views_query_alter()?

## mathematical modeling – Finding the design matrix of a multiple linear regression

I’m looking for the design matrix $$X$$ for the following problem:

Suppose the relationship between the variables $$x$$ and $$y$$ is linear:

$$y = f(x) =beta_0f(x_0) + beta_1f(x_1) + … + beta_nf(x_n)$$.

Find the matrix $$X$$ for a set of data consisting of $$n$$ data points $$(x_1,y_1),…,(x_n,y_n)$$.

My initial thought was that it should be:

$$X = begin{bmatrix} f(x_0) & f(x_1) & … & f(x_n) \ downarrow & downarrow & downarrow & downarrow\ f(x_0) & f(x_1) & … & f(x_n) \ end{bmatrix}$$

but I don’t love that that would produce identical values for all $$(y_1, …, y_n)$$.

Any suggestions would be appreciated!

## encryption – How to send a fixed size encrypted message to be broadcast to multiple (known) recipients without letting the broadcaster decrypt the message

I am creating a network with three layers. A sender layer, A gateway layer, and a Receiver layer; each having different platforms. See diagram below

All platforms have published their public keys on a trusted public database server (not shown on the diagram).

A sender S wants to send a message to the receiver layer but it can only send the message via one of the platforms in the Gateway layer. Let’s call it G.

The message contains a public section that can be accessed by anyone and a private section that should be accessible only by the receiver layer. Something like below

``````{
"public"  : { <public data>  },
"private" : { <private data - encrypted> }
}
``````

Every time S sends a message to G; G uses the public section of the message to verify the authenticity of the sender and to identify a subset of Receivers { R1, R2 … Rp } where p <= n; and broadcasts the message to the “p” receivers.

How does S encrypt the message such that only {R1, R2 … Rp} are able to decrypt the message and not G?

Some additional forces that exist are as follows:

• Sender platforms layer can have 1-100000000 independent devices each having its own key pair
• The gateway platforms could range from a 1-500 platforms
• The receiver layer could have 1-10000000 platforms each having its own key pair

Any ideas on how to achieve this? I can do this using two Gateways, G1 and G2 where one G1 broadcasts the public key of S and G2 broadcasts the message. The receiver can check if the broadcaster of the key is different from the broadcaster of the message and return an “INSECURE_TRANSACTION” error of sorts. But is there a way to make it work using only one Gateway? Any help would be appreciated.