## asynchronous – Syntax for TypeScript Arrow Functions With Generics

I don’t know if this is done properly or not, but I posted an answer in StackOverflow back in Sept. 2020 about implementing generics in TypeScript. I got downvoted 3 times, and I was wondering if the following piece of code was problematic:

This is how I defined an async generic function expression in TypeScript

const request = async <T>(param1: string, param2: number) => {
const res = await func();
return res.response() as T;
}

And a more complex pattern, in case you’d like to wrap your function inside a generic counterpart, such as memoization (Example uses fast-memoize):

const request = memoize(
async <T>(
url: string,
token?: string
) => {
}
);

See how you define the generic after the memoizing function.

This function has worked well for me, so I don’t see any issues.

This is the original SO question.

## docker – Cannot gather stats and Invalid template file after installing Porto theme

After setting up Magento 2 in developer mode, I am getting a couple of errors:

(2021-04-19 21:39:09) report.INFO: Broken reference: the 'yotpo_bottomline' tries to reorder itself towards 'product.info.addto', but their parents are different: 'product.info.main' and '' respectively. () ()
(2021-04-19 21:39:09) report.CRITICAL: Cannot gather stats! Warning!stat(): stat failed for /app/pub/static/frontend/Magento/luma/en_US/mage/requirejs/mixins.js {"exception":"(object) (Magento\Framework\Exception\FileSystemException(code: 0): Cannot gather stats! Warning!stat(): stat failed for /app/pub/static/frontend/Magento/luma/en_US/mage/requirejs/mixins.js at /app/vendor/magento/framework/Filesystem/Driver/File.php:95)"} ()
(2021-04-19 21:39:10) report.CRITICAL: Invalid template file: 'owl_list.phtml' in module: 'Smartwave_Filterproducts' block's name: 'homefeaturedlist_0' {"exception":"(object) (Magento\Framework\Exception\ValidatorException(code: 0): Invalid template file: 'owl_list.phtml' in module: 'Smartwave_Filterproducts' block's name: 'home\featuredlist_0' at /app/vendor/magento/framework/View/Element/Template.php:280)"} ()
(2021-04-19 21:39:10) report.CRITICAL: Invalid template file: 'grid.phtml' in module: 'Smartwave_Filterproducts' block's name: 'homefeaturedlist_1' {"exception":"(object) (Magento\Framework\Exception\ValidatorException(code: 0): Invalid template file: 'grid.phtml' in module: 'Smartwave_Filterproducts' block's name: 'home\featuredlist_1' at /app/vendor/magento/framework/View/Element/Template.php:280)"} ()

I followed the Magento 2 documentation to install Magento in docker. Then, in an attempt to follow the Porto docs, I copied the Porto theme files, the theme patch for Magento 2.2.x, theme patch for Magento 2.3.x, and the theme patch for Magento 2.4.1.

Any help on resolving the above errors would be appreciated.

## android – Erro com Nav Controller

Estou enfrentando problemas ao rodar meu app pois ele nao abre a main, o problema esta no meu nav controler mas nao sei como solucioná-lo.

Log:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.pokedex, PID: 19404
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.pokedex/com.example.pokedex.ui.main.MainActivity}: java.lang.IllegalStateException: Activity com.example.pokedex.ui.main.MainActivity@17e9680 does not have a NavController set on 2131230964
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:169)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit\$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.IllegalStateException: Activity com.example.pokedex.ui.main.MainActivity@17e9680 does not have a NavController set on 2131230964
at com.example.pokedex.ui.main.MainActivity.configNavDrawer(MainActivity.kt:69)
at com.example.pokedex.ui.main.MainActivity.onCreate(MainActivity.kt:46)
at android.app.Activity.performCreate(Activity.java:7051)
at android.app.Activity.performCreate(Activity.java:7042)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:169)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit\$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)

Main Activity:

class MainActivity : AppCompatActivity() {

private lateinit var toggle: ActionBarDrawerToggle
var currentPath: String? = null
val TAKE_PICTURE = 1
val SELECT_PICTURE = 2

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.main_activity)
configBottomNavegacao()
configNavDrawer()

(pokemons_activity_nav_host.findNavController())

toggle = ActionBarDrawerToggle(this, drawerLayout, R.string.open, R.string.close )
toggle.syncState()

supportActionBar?.setDisplayHomeAsUpEnabled(true)

when(it.itemId){
R.id.drawer_camera -> dispatchCameraIntent()
R.id.drawer_fav -> dispatchFavoritosIntent()
}
true
}
}

private fun dispatchFavoritosIntent() {
}

private fun configNavDrawer() {
.setupWithNavController(navController)

// verifica onde vai ou nao mostrar o drawer
navController.addOnDestinationChangedListener { controller, destination, arguments ->
when(destination.id){
R.id.listaPokemons -> mostraNavDrawer()
R.id.listaFavPokemons -> mostraNavDrawer()
R.id.search -> mostraNavDrawer()
R.id.detalhesPokemons -> mostraNavDrawer()
else -> ocultaNavDrawer()
}
}
}

private fun mostraNavDrawer() {
navView.visibility = View.VISIBLE
}
private fun ocultaNavDrawer(){
navView.visibility = View.GONE
}

private fun configBottomNavegacao() {
val navHostFragment = supportFragmentManager
.findFragmentById(R.id.pokemons_activity_nav_host) as NavHostFragment
val navController = navHostFragment.navController

// verifica onde vai ou nao mostrar o bottom navigation
navController.addOnDestinationChangedListener { controller, destination, arguments ->
when(destination.id){
R.id.listaPokemons -> mostraBottomNav()
R.id.listaFavPokemons -> mostraBottomNav()
R.id.search -> mostraBottomNav()
R.id.detalhesPokemons -> mostraBottomNav()
}

}

}

//oculta o botao de navegaçao
}

// exibe o botao de navegaçao
private fun mostraBottomNav() {
}

activity main:

<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".ui.main.MainActivity">

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

</androidx.constraintlayout.widget.ConstraintLayout>

<androidx.fragment.app.FragmentContainerView
android:id="@+id/pokemons_activity_nav_host"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"

<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"

</androidx.constraintlayout.widget.ConstraintLayout>

android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/navView"
android:layout_gravity="start"
android:fitsSystemWindows="true"/>

</androidx.drawerlayout.widget.DrawerLayout>

## dnd 5e – As a Warlock, can I cast Vampiric Touch on myself to grant my pact weapon an extra 3d6 necrotic damage?

### No, you can’t improve an existing melee attack with the Vampiric Touch

The Vampiric Touch spell states:

The touch of your shadow-wreathed hand can siphon life force from others to heal your wounds. Make a melee spell attack against a creature within your reach. On a hit, the target takes 3d6 necrotic damage, and you regain hit points equal to half the amount of necrotic damage dealt. Until the spell ends, you can make the attack again on each of your turns as an action.

So, firstly you take the Cast A Spell action and expend a 3rd level spell slot. Then you deal 3d6 necrotic damage, if you succeed with the melee spell attack. This melee spell attack is a part of the spell — you literally have to touch the target with “your shadow-wreathed hand” to apply the spell effect.

Within 1 minute, you can repeat this action without expending more spell slots, providing you maintain the concentration. So you have to choose — either you make a weapon attack with your pact weapon, or you make a spell attack with the Vampiric Touch.

See also Can you apply the Vampiric Touch and Shocking Grasp damage together in one attack?

## design – elementor no-repeat css value works randomly on unique single post template

I’m working on our WP website with elementor pro template builder. I have one single post template that I’m using for all the posts. The background “hero” image of the header section is the featured image of the post.

In the following post (with firefox/Chrome Mac) no-repeat value doesn’t work:
https://dev.mkorke.net/patagonie/centolla/

In the following post (with firefox/Chrome Mac) no-repeat value does work:

Both examples supposedly use the same single post template with background values as:
…background-image: url(“photograph.jpg”);
min-height: 60%;
background-position: center;
background-repeat: no-repeat;
background-size: cover;…

In the single post template, if I change the value to default then back to no-repeat, it works again, … until it doesn’t.

What am I missing. Thanks for the help

## D&D 3.5e — “Mettle”

In D&D 3.5e, evasion allowed someone to take no damage on a successful Reflex save against something that usually had halved damage on a successful save. This feature was originally available to monks and rogues, and became available to other classes via supplemental content.

Later in the same edition, additional classes were introduced that had a feature called “mettle,” which worked the same way, except instead of Reflex saves, it worked on both Fortitude and Will saves.

Note that D&D 3.5e only had these three saving throw types—Fortitude based on Constitution, Reflex based on Dexterity, and Will based on Wisdom. There were no saving throws associated with Strength, Intelligence, or Charisma. (These associations were only defaults, however, so special features could and occasionally did change the ability score associated with a given type of save.)

Mettle covered both Fortitude and Will because it was (and, I believe, continues to be, in 5e) relatively rare for those types of saving throws to still have some reduced effect on a successful save. Usually, those kinds of saves just negated whatever the effect was entirely.

To my knowledge, there was no “half-mettle” feature that covered only Fortitude saving throws.

## D&D 4e — “Mettle” again

In D&D 4e, we still have Fortitude, Reflex, and Will, but now they are no longer saving throws, they are “defenses” and work the same way that AC does—certain powers had you roll your attack against these defenses instead of AC. (Saving throws were an entirely separate mechanic and there was only the one type, “saving throw.”) Also, Fortitude was based on Strength or Constitution, Reflex was based on Dexterity or Intelligence, and Will was based on Wisdom or Charisma, whichever was higher out of each pair.

But evasion and mettle remained effectively the same—evasion caused attacks that targeted your Reflex to do nothing on a miss, even if they usually did something on a miss, and mettle did likewise for attacks that targeted Fortitude or Will.

## D&D 5e — none, I believe

As far as I can tell, D&D 5e doesn’t have mettle, or anything similar to it. It might be hard to make in 5e, since Dexterity remains the saving throw associated most strongly with partial or reduced effect on a successful save, but “everything but Dexterity” is now five separate saving throws, instead of just two, which makes having mettle cover all of those seem a fair bit more imbalanced. At any rate, Wizards of the Coast has yet to cover it in their publications.

## Mathematica Assist. \$yx=qxy\$

In Mathematica program, How to define a product of two elements $$x$$ and $$y$$ such that $$yx=qxy$$ with $$q$$ is a number commuting with both $$x$$ and $$y$$.

## soft fork – Is there network split risk for Taproot activation with two releases (Bitcoin Core and Bitcoin Taproot)?

Every soft fork or consensus change involves a (very small) non-zero risk of a network split. That risk is considerably lower for a soft fork than say a hard fork (where all nodes need to upgrade). That’s why soft forks aren’t attempted every month or year. All you can do is minimize that risk.

Aaron lays out some scenarios that are theoretically possible. Any incompatibility between “Bitcoin Core” and “Bitcoin Taproot” during the Speedy Trial deployment is in my view highly unlikely. If Speedy Trial fails to activate and we reach November 2022 (please note 2022 not 2021) without miners activating then we are in a similar scenario to the UASF in 2017 where it depends on what the economic majority is running. I can’t predict what the economic majority would be running in November 2022 but I highly suspect the delaying of Taproot activation would be at the top of everyone’s minds.

You do have to weigh up these risks of a network split with miners deliberately blocking Taproot activation potentially forever. If we were to say no more UASFs ever again because we don’t want to take any network split risk that would be handing miners a permanent veto to block the activations of soft forks that have community consensus. So you have to weigh up the risk of the latter which would be just as concerning (if not more concerning) to people.

So in summary these are subtle trade-offs. A number of developers have worked hard to minimize the risk of a network split. But it doesn’t get to zero unless you literally never try a soft fork again. And that would mean that Bitcoin would never seriously improve again.

## c# – Why does CreateProcess ignore STARTUPINFO window size values?

I am trying to use CreateProcess to start Notepad at a specific window size to avoid the flashing that occurs when it appears somewhere for a split second before I can resize it and move it.

CreateProcess starts Notepad but CreateProcess and Notepad both ignore the window dimensions in the STARTUPINFO structure. Notepad appears in the normal place at the normal size where it was last closed.

No combination of dwFlags that I tried worked. Notepad either does not appear at all or ignores my settings and appears in a place and size determined by the operating system.

Why is CreateProcess ignoring the values I set in STARTUPINFO? Am I missing something?

(TestMethod())
public void CreateProcessTest() {
const uint NORMAL_PRIORITY_CLASS = 0x0020;
const uint STARTF_USESHOWWINDOW = 0x0001;

// create structures needed by CreateProcess
var pInfo = new Kernel32.PROCESS_INFORMATION();
var pSec = new Kernel32.SECURITY_ATTRIBUTES();
var tSec = new Kernel32.SECURITY_ATTRIBUTES();
pSec.nLength = Marshal.SizeOf(pSec);
tSec.nLength = Marshal.SizeOf(tSec);

// set the app and a file to open
var app = Environment.GetEnvironmentVariable("windir") + @"notepad.exe";
var arguments = @" C:somefile.txt";

// the started app window does not use these values
var sInfo = new Kernel32.STARTUPINFO();
sInfo.dwX = 800;  // desired x-y position of the window
sInfo.dwY = 400;
sInfo.dwXSize = 200; // desired size of the window
sInfo.dwYSize = 400;

// no combination of these flags that I tried makes any difference
// Notepad always appears as normal and ignores the size settings above
sInfo.dwFlags = STARTF_USESHOWWINDOW;
sInfo.wShowWindow = (short) Win32.SW_SHOW;

// create the process
var result = Kernel32.CreateProcess(app, arguments,
ref pSec, ref tSec, false, NORMAL_PRIORITY_CLASS,
IntPtr.Zero, null, ref sInfo, out pInfo);
}