In general, how does a DFA know how to successfully process a string the intended way?

Suppose we have:

$ $ A\text{ }\colon=\{x, y, z\}$ $

$ $ M\text{ }\colon=\text{some DFA using A}$ $

$ $ S\text{ }\colon=xyzxyzxyz$ $

Intuitively, one might say $ S$ is fed to $ M$ on a per-character basis.

This means that somehow we have an undisclosed mechanism that can tell where a symbol starts and ends.

One might say, simply use the maximum valid substring similar to how Lexers tokenise plaintext. To that I say, suppose instead that we defined $ A$ as: $ $ A\text{}\colon= \{x, xx, xxx\}$ $

Now we have 3 unique symbols, that, as it so happens, using the maximum valid substring will yield in a restriction to what our our $ M$ can actually process, because any string longer than 2 characters will always be assumed to start with $ xxx$ rather than perhaps, $ x$ and $ xx$ .

One way I see around this is to actually have a character synonymous to a symbol. That is, $ x$ and $ xxx$ (from $ A$ ) are both a single character each.


[ General – Australia ] Open Question : Who would you say is the most embarrassing Australian?

I would nominate Belle Delphine for the English: This is what we have become. My, how the mighty have fallen. She made an absolute killing selling her bathwater for US$ 30 to people around the world. Who the fvck is buying that sh1t? Loads of people apparently because she is a millionaire now. It’s so embarrassing that we produce people like her.

General guidance on pricing goods, services, and balancing economy

As I’m making my way through a campaign, I’m beginning to realize that I don’t know what to do about money. My tier 2 (out of 6) players have 200 shins (gold in Numenera terms) between 5 of them, we don’t know if that’s a lot or a little, and we stopped caring about money altogether – finding monetary rewards is not exciting, and money is not a motivator. I’m trying to price and offer some goods and services — which will create the desire for players to spend (and acquire) wealth.

Is there some generic guideline against which I can use to price things? I think I just don’t have a good gut feeling how to price hiring a group of guards or a spy for a month vs a sack of grain or price of a sword.

How do I begin to estimate price of goods and services? Are there good resources to help me?

Complexity of numerical derivation for general nonlinear functions

In classical optimization literature numerical derivation of functions is often mentioned to be a computationally expensive step. For example Quasi-Newton methods are presented as a method to avoid the computation of first and/or second derivatives when these are “too expensive” to compute.

What are the state of the art approaches to computing derivatives, and what is their time complexity? If this is heavily problem-dependent, I am particularly interested in the computation of first and second order derivatives for Nonlinear Least Squares problems, specifically the part concerning first order derivatives (Jacobians).

Best practice for modeling data that is both general (default) and entity-specific

I have tried searching for good guidance on this already, but without much luck. Still, apologies in advance if this is duplicated elsewhere.

The Problem

In a nutshell, we have external contractors that work on cases for our clients. We already have tables with contractor and client information in our SQL Server database. Going forward we’d like to store billing info in there too. Billing rates can differ for each client and contractor, but usually each client has a general “default” pay rate that applies to most contractors.

Option A

The initial proposal was to create a new table with the following basic design:


  • clientID – foreign key to client table
  • contractorID – foreign key to contractor table
  • basePay – pay rate for this client-contractor combination
  • ... – several more (10+ and likely to grow) columns with supplemental pay rate details
  • A unique index to help optimize lookup and also prevent multiple rows for a given client-contractor combination.

Contractor-specific pay rates would naturally be linked to the relevant contractor (and client). General (default) pay for a client would be stored in a row where contractorID is NULL. This is to avoid having to duplicate the same default pay for all contractors that don’t have specific exceptions.

Option B

However, one of our senior devs has strong reservations about Option A. Their main argument is that using NULL in the contractorID column to mean “this is the default pay rate row” is unintuitive and/or confusing. In other words, it’s bad to assign meaning to NULL values.

Their counter proposal was to duplicate these new pay rate columns in the client table. The data stored there would indicate the default pay for each client, while contractor-specific exceptions would still live in the new table above.

What To Do?

It seems clear both proposals would work just fine, but I have my own reservations about the second. Mainly it seems wrong to store the same type of data (client-contractor pay rate details) in multiple places, not to mention more complex logic to read/write this data. I also don’t like duplicating these new columns in both tables, since it would force us to add any future pay rate columns to both tables.

However, I can see my colleague’s point about potentially misusing NULL in this case. At the very least, it’s not immediately obvious that rows with a NULL contractorID contain default pay rates.

It’s been far too long since my database programming courses, so I’m not sure what the current best practice for this type of entity relationship is? I’m open to whatever is best long term, and would appreciate any expert guidance, especially with links to additional resources.

Thank you in advance!

What are the general security implications behind using a web app vs its equivalent desktop app?

In 2020, there are a lot of applications which have a web interface as well as “desktop apps.” Such applications are either the same in functionality or very close. Three examples of this situation are the Slack, Discord, and Keeper Security applications. As a user, I am often left with a choice: Do I use the webapp in the browser, or do I download and install the desktop app?

In order to not be too vague, I’m not going to ask the question “which is more secure?” As this may not be possible to answer without a specific reference. However, there is truth to the fact that many of these applications are running on top of runtimes like Chrome, V8, Electron, Mono, etc…. For the purposes of this question, please assume that the app is of this style and not a “fully native” compiled app written directly in C or C++.

Ignoring any functionality differences (such as, I need the desktop app in order to do livestreaming), please list the general security implications of using the browser app vs desktop app.

For security reasons, why might I prefer to run the web in-browser version of the app rather than the desktop app and vice versa? One such implication could be, “exploitation in a browser-run web app would be limited to the tab’s process, whereas in a desktop app, it could potentially access a greater scope” for example.

General error: 2006 MySQL server has gone away while adding a thread

error while adding a thread to database showing this errors

Warning: Error while sending QUERY packet. PID=138803 in /home/u758467727/domains/ on line 673  Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away in /home/u758467727/domains/ Stack trace: #0 /home/u758467727/domains/ PDO->exec('CREATE TABLE IF...') #1 {main} thrown in /home/u758467727/domains/ on line 673 

and code where this error is


Is there a general rule that covers interaction between effects that cause death at 0 hit points and features that prevent death at 0 hit points?

There are a large number of questions on this site and online regarding the interaction between effects that cause death at 0 hit points and features that prevent death at 0 hit points.

Effects that cause death if they reduce a character to 0 hit points include:

  • Disintegrate spell (original): “If this damage reduces the target to 0 hit points, it is disintegrated.”
  • Disintegrate spell (PH Errata 2.0): “The target is disintegrated if this damage leaves it with 0 hit points.”
  • Beholder’s Disintegration Ray: “If this damage reduces the target to 0 hit points, its body becomes a pile of fine gray dust.”
  • Beholder’s Death Ray: “The target dies if the ray reduces it to 0 hit points.”
  • A published adventure* contains a large number of effects with language like “If this damage reduces the creature’s hit points to 0, it is crushed to a pulp.”
  • Instant Death: “When damage reduces you to 0 hit points and there is damage remaining, you die if the remaining damage equals or exceeds your high point maximum.”

Effects that can prevent character death when a character is reduced to 0 hit points include (HT to this question for some of these):

  • Half-orc’s Relentless Endurance: “When you are reduced to 0 hit points but not killed outright, you can drop to 1 hit point instead.”
  • Barbarian’s Relentless Rage: “If you drop to 0 hit points while you’re raging and don’t die outright, you can make a DC 10 Constitution saving throw. If you succeed, you drop to 1 hit point instead.”
  • Druid’s Wild Shape: “You automatically revert if you fall unconscious, drop to 0 hit points, or die. […] When you revert to your normal form, you return to the number of hit points you had before you transformed.”
  • Death Ward spell: “The first time the target would drop to 0 hit points as a result of taking damage, the target instead drops to 1 hit point, and the spell ends.”
  • Polymorph spell: “The transformation lasts for the duration, or until the target drops to 0 hit points or dies. […] When it reverts to its normal form, the creature returns to the number of hit points it had before it transformed.”

The interaction between these effects has been a persistent question. Sage Advice used to have the following ruling:

If the damage from disintegrate reduces a half-orc to 0 hit points, can Relentless Endurance prevent the orc from turning to ash? If disintegrate reduces you to 0 hit points, you’re killed outright, as you turn to dust. If you’re a half-orc, Relentless Endurance can’t save you.

What happens if a druid using Wild Shape is reduced to 0 hit points by disintegrate? Does the druid simply leave beast form? The druid turns to dust, since the spell disintegrates you the instant you drop to 0 hit points.

But then the wording of the disintegrate spell changed, and in Sage Advice 2.0, the following ruling appeared:

[NEW] If the damage from disintegrate reduces a half- orc to 0 hit points, can Relentless Endurance prevent the orc from turning to ash? Yes. The disintegrate spell turns you into dust only if the spell’s damage leaves you with 0 hit points. If you’re a half-orc, Relentless Endurance can turn the 0 into a 1 before the spell can disintegrate you.

[NEW] What happens if a druid using Wild Shape is reduced to 0 hit points by disintegrate? Does the druid simply leave beast form? The druid leaves beast form. As usual, any leftover damage then applies to the druid’s normal hit points. If the leftover damage leaves the druid with 0 hit points, the druid is disintegrated.

The problem, as I see it, is an IF condition that generates two contrary effects. With the half-orc’s Relentless Endurance it seems clear(er) that it won’t protect you (because of the “and doesn’t kill you outright” stipulation) while the issue of polymorph and wild shape is logically mud.

The change to the wording of disintegrate seems to clarify polymorph and wild shape while giving a free boost to the half-orc. But the “reduces the target to 0 hit points” language has another problem. As pointed out in an answer to this question, the it has the strange effect that “the spell would not disintegrate creatures that were already at 0 HP before being hit by the spell”. This applies equally to disintegrate ray, death ray, falling stone blocks that crush creatures to a pulp, or any effect that has the wording “reduces the target to 0 hit points”.

Furthermore—and this is not so much a rules question as a metarules issue—I find it irritating that the beholder’s disintegration ray would work so differently from the disintegrate spell (assuming the old Sage Advice answer applies, since the wording has of disintegration ray has not changed). While there nothing requiring logical consistency in a fantasy game, there are benefits (in terms of rule clarity and player sense of fairness) to having effects that use virtually the same name operate in the same way.

So the question is whether there is a general rule that can govern interaction between these effects, or if it can only be resolved on a case-by-case basis.

* Not saying which one due to potential spoilers, but it is a WotC-published hardcover.