What is the replacement for menu_link_load()?

Drupal 7 has menu_link_load() to load a single menu item. What is the Drupal 8 equivalent?

replacement – Pattern matching involving a sum of wildcards

I am trying to implement the following substitution to an expression in Mathematica:

ti den(a-ti) -> -1 + a den(a-ti) 

where ti can be t1, t2, …, and den is an undefined function. The variable ti can also be a sum of t1, t2, …. The expression is part of a larger expression.

Now, it works when one variable is involved:

t1 den(s1 + s2 - t1) /. t_ den(q_ - t_) -> (-1 + q den(q - t))

returns

-1 + (s1 + s2) den(s1 + s2 - t1)

However, if ti is a sum of multiple terms, e.g. (t1-t2), the replacement breaks down. I’ve tried to implement a rule with the combination of ReplaceRepeated.

rule = {t_ den(q_ - t_) :> (-1 + q den(q - t))}
(t1 - t2) den(s1 - s12 + s2 - t1 + t2) //. rule

but that doesn’t seem to work, because it just returns

(t1 - t2) den(s1 - s12 + s2 - t1 + t2)

My guess is that Mathematica cannot recognize den(s1 - s12 + s2 - t1 + t2) as den(s1 - s12 + s2 - (t1 - t2)) and that my substitution rule is wrongly formulated.

Does anybody know how to fix this?

Replace Condition in Replacement Rules

In finding an answer to my other question, I’m finding myself needing to manipulate the conditions imposed on replacement rules, but this is proving to be a little difficult. In particular, how should I go about removing instances of Condition and PatternTest?

Using the code from my other answer (slightly adjusted):

f(x_?InexactNumberQ) := x^2;
g(x_) /; FooQ(x) := x^3;

Attributes(ExpandValues) = {HoldAll};
ExpandValues(symbol_) := Join @@ Through(
  {OwnValues, DownValues, UpValues, SubValues, DefaultValues, NValues}(symbol)
);
ExpandValues(symbol_, symbols__) := Join(ExpandValues(symbol), ExpandValues(symbols));

then the replacement rules that need to be modified are:

{
  HoldPattern(f((x_)?InexactNumberQ)) :> x^2,
  HoldPattern(g(x_) /; FooQ(x)) :> x^3
}

I would like these to be modified to not have any conditions on the arguments, but trying to replace the condition and pattern test is proving difficult. This for example does not work:

{
  HoldPattern(Condition(p_, q_)) :> p,
  HoldPattern(PatternTest(p_, q_)) :> p
}

I’ve also tried using Verbatim which the documentation suggests is useful to transform other transformation rules, but I have not gotten them to work. I’m also thinking that the use of Verbatim won’t work generally because it is too literal.

I’ve had partial success with

{
  Condition -> (#1 &),
  Patterntest -> (#1 &)
}

but when the replacement appears within a HoldPattern, the resulting rule after replacement does not work.

macbook pro – Fresh battery replacement already showing degradation

I have a 2019 MacBook Pro 15 inch running MacOS Catalina (10.15.6) which had the top case (battery) replaced in July 2020 due to significant battery degredation over the 1 year I had owned it. The battery health went from 100 % to 84% in just over 12 months.

Since having that replaced, I noticed that the battery health of the new battery had decreased from 100% to 89% over just 53 charge cycles. I called apple support since it still has apple care and they ran their diagnostics on it (Shut Down Mac, power on, hold option + D). The agent said the diagnostic report showed my battery was at 97% health which was within spec. I am just curious why system report would be saying my max charge capacity was at 6502/7336 (89%) yet his diagnostic (which apparently bypasses any operating system measurements) is saying 97%?

I thought this might be an SMC issue and reset that earlier this week but no improvements. Is there some other system that needs calibrating?

sed read multiple lines for a regex replacement

I need to get this PCRE regular expression working on sed:

();s)(INSERT INTO )`(.*)` VALUES (

Working example available here

Thanks,

replacement – When numbers plugged in – this expression evaluates to zero, but otherwise will not evaluate to zero

I have the following code:

COV1 = {{a1,0},{0,a2}}; COV2 = {{b1,0},{0,b2}};
T = MatrixPower(MatrixPower(COV1,1/2),-1)*MatrixPower(MatrixPower(COV1,1/2)*COV2*MatrixPower(COV1,1/2),1/2)*MatrixPower(MatrixPower(COV1,1/2),-1);
Thalf = 1/2*{{1,0},{0,1}} + 1/2*T;
COV3 = Thalf*COV1*Transpose(Thalf)+{{0,t},{t,0}}
d1 = Sqrt(Tr(COV1 + COV2 - 2*MatrixPower(MatrixPower(COV1,1/2)*COV2*MatrixPower(COV1,1/2),1/2)))
d2 =Sqrt(Tr(COV1 + COV3 - 2*MatrixPower(MatrixPower(COV1,1/2)*COV3*MatrixPower(COV1,1/2),1/2)))*2
Simplify(d2 - d1)

When I plug in numbers such as

a1 = 5, a2 = 7, b1 = 9, b2 = 45

The last expression evaluates to zero. However when I leave everything as variable, the expresssion doesn’t reduce to zero. However, it should. What is going on?

My guess is I need to impose conditions like a1, a2, b1, b2 are strictly positive reals — but I don’t know how to do this.

Also I tried this powerExpand trick I found — it didn’t work (perhaps I used it incorrectly?)

Replacement for _drush_file_private_path() in Drush 9

I’m trying to get File Permissions working in Drupal 8.9 with Drush 9. The old code calls _drush_file_private_path(), which doesn’t exist anymore, and _drush_file_public_path() is probably a no-go as well.

What is the proper way to do the following in Drush 9?

define('DS', DIRECTORY_SEPARATOR);

// Define default paths and variables.
$default = 'sites' . DS . 'default';
$private = $default . DS . 'private';
$files = $default . DS . 'files';
$directories = array();

// Check for Private Files subdirectory.
$private_directory = _drush_file_private_path();
if (empty($private_directory)) {
  $private_directory = $private;
}
$directories() = $private_directory;

// Check for Public Files subdirectory.
$public_directory = _drush_file_public_path();
if (empty($public_directory)) {
  $public_directory = $files;
}
$directories() = $public_directory;

As an additional note, it would be amazing if a resource existed to see all deprecated/removed functions and their equivalent replacements. I can’t even get decent results when using a search engine and the function name.

adsterra replacement that pay with bitcoin?

i am looking for a adsterra replacement that pay with bitcoin, any ads network

command line – How To Use ‘`launchctl print`’ as a Replacement for ‘`launchctl bslist`?’

     ‘man launchctl‘ remarks that:

⋮

LEGACY SUBCOMMANDS
     Subcommands from the previous implementation of launchd are generally available, though some may be
     unimplemented. Unimplemented subcommands are documented as such.

⋮

     bslist (PID | ..) (-j)
              This subcommand is not implemented and has been superseded by the print subcommand, which pro-
              vides much richer information.

⋮

at least as of OS X v10.11.x ‘El Capitan.’ (Presumably, this was also the case in v10.10.x ‘Yosemite,’ as that was the OS release that first included ‘launchd 2.0,’ if I’m reading/recalling my history correctly.) What arguments, then, would one pass to ‘launchctl print‘ to get output like what the ‘bslist‘ sub-command used to provide? Would you need to filter it any (using grep, sed, awk, etc.) to get the desired result(s)?
     (‘launchctl print system‘ spews a bunch of data out, but I’m not clear on whether that includes the same information the ‘bslist‘ sub-command would have output in the past or, if so, where in the former’s output said information might be. It contains a list similar to the example provided in Listing 1 in the ‘Mach Bootstrap Basics’ section of this old, outdated Apple documentation on ‘Daemons and Agents,’ but I’m uncertain if that’s what I’m looking for.)

dnd 5e – Is the DMG’s Disarm option an entire action, or a replacement for a single weapon attack?

My confusion comes from the somewhat ambiguous wording of the Disarm action as described in the Dungeon Master’s Guide (p. 271):

A creature can use a weapon attack to knock a weapon or another item from a target’s grasp. The attacker makes an attack roll contested by the target’s Strength (Athletics) check or Dexterity (Acrobatics) check. If the attacker wins the contest, the attack causes no damage or other ill effect, but the defender drops the item.

Two things stand out to me:

A creature can use a weapon attack

One way to interpret this is to mean that this is replacing a normal weapon attack, disarming the target instead of dealing damage. The other way to interpret this is that this weapon attack is special; that despite being called an attack, it’s intended to be its own action type.

If the attacker wins the contest, the attack causes no damage or other ill effect

This also stands out to me. If this were its own action, and not a replacement for a regular attack, then it wouldn’t be necessary to specify that damage is negated; it would simply be presumed to deal no damage.

What is the correct way to interpret this action? Is it its own action, or a replacement for a single attack as part of the Attack action? If a character gets the Extra Attack feature, can Disarm replace every attack they’re otherwise allowed to make?