dnd 5e – If I use the Shapechange spell to turn into a phoenix, can I use its legendary resistances to pass Con saves to maintain concentration?

Legendary Resistances are available to you while Shape Changed

The appropriate part of the spell description says:

Your game Statistics are replaced by the Statistics of the chosen creature, though you retain your Alignment and Intelligence, Wisdom, and Charisma scores You also retain all of your skill and saving throw Proficiencies, in addition to gaining those of the creature, If the creature has the same proficiency as you, and the bonus listed in its Statistics is higher than yours, use the creature’s bonus in place of yours. You can’t use any legendary Actions or Lair Actions of the new form.

Legendary resistances are not mentioned anywhere as being unavailable or altered in anyway.

This is backed up by a (unofficial Tweet) tweet from Jeremy Crawford:

So you get Legendary Resistances?…

No rule says you don’t.

javascript – I want to pass my validation results to handlebar views. How to do that?

I have validated a form using npm’s validator module and now I want to display the errors into my handlebar views. I have tried to passing the error variable using res.render() function in the post method. But, it’s not working as I expected.

router.post('/place-order',

(
  check('pincode').isLength({min:5}),
  check('mobile').isLength({min:10})
),
async (req, res) => {
const errors = validationResult(req)
if(!errors.isEmpty()){
  console.log(errors)
  res.render('/place-order',{errors})
}

I tried to pass the errors value through the render function but it’s not providing result. My handlebars code is given below.

{{#each errors}}
<h1 class="mt-5">{{this.msg}}</h1>
{{/each}}

Can anyone help me please to solve this issue ?

magento2 – Magento 2 Pass array data to Custom Email template

I’m a beginner in magento and I have a custom email template as follows

wishlist_email_template.html

{{template config_path="design/email/header_template"}}
<table cellspacing="0" cellpadding="0" border="0" width="100%">
    <tr>
        <td align="center" valign="top" style="padding:20px 0 20px 0">
            <table bgcolor="#FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
                <tr>
                    <td valign="top">
                        <h1 style="font-size:22px;font-weight:normal;line-height:22px;margin:0 0 11px 0;">{{var heading}}</h1>
                    </td>
                </tr>
                <tr>
                    <td>
                        {{var feedback}}
                    </td>
                </tr>
                {{layout handle="wishlist_email_products" products=$products area="frontend"}}

                <tr>
                    <td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA;text-align:center;">
                        <center>
                            <p style="font-size:12px;margin:0;">
                                <strong> Thank you</strong>
                            </p>
                        </center>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
{{template config_path="design/email/footer_template"}}

SendWishlistEmail.php

   foreach ($toEmail as $receiver) {
            $receiverMail = $receiver;
            try {
                // template variables pass here
                $templateVars = (
                    'heading' => 'Wishlist',
                    'msg' => 'test',
                    'msg1' => 'test1',
                    'products'=> $products,
                    'images'=> $images,
                    'feedback' =>$feedback
                );

                $storeId = $this->storeManager->getStore()->getId();

                $from = ('email' => $fromEmail, 'name' => $fromName);
                $this->inlineTranslation->suspend();

                $storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;
                $templateOptions = (
                    'area' => MagentoFrameworkAppArea::AREA_FRONTEND,
                    'store' => $storeId
                );
                $transport = $this->transportBuilder->setTemplateIdentifier($templateId)
                    ->setTemplateOptions($templateOptions)
                    ->setTemplateVars($templateVars)
                    ->setFrom($from)
                    ->addTo($receiverMail)
                    ->getTransport();
                $transport->sendMessage();
                $this->inlineTranslation->resume();
            } catch (Exception $e) {
                $this->_logger->info($e->getMessage());
            }
        }

$products is my array,
I’m trying to get my product data from product array using {{layout handle=”wishlist_email_products” products=$products area=”frontend”}}.

wishlist_email_products.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Product List" design_abstraction="custom">
    <body>
        <block class="MagentoFrameworkViewElementTemplate" name="additional.product.info" template="email/product.phtml"/>
    </body>
</page>

product.html

<?php
/**
 * @var $block MagentoFrameworkViewElementTemplate
 */
$products = $block->getProducts();
?>
<?php foreach ($products as $product): ?>
    <tr>
        <td><?php echo $product->getSku() ?></td>
        <td><?= $product->getName() ?></td>
    </tr>
<?php endforeach; ?>

I get the error Error

filtering template: Invalid template file: 'app/code/NeoSolax/Custom/view/frontend/templates/email/product.phtml' in module: '' block's name: 'additional.product.info'

in my sent email
Please help.

drush – Drupal root not found. Pass –root or a @siteAlias in order to see Drupal-specific commands

I have multiple sites inside the same htdocs directory. In one, I removed all the folders except vendor under Web. Now drush will not work (it worked before I moved the folders). But now, it cannot find the database, which is correctly defined in web/sites/default/settings.php

/srv/www/htdocs/jar/drupal # ./drush status
 PHP binary    : /usr/bin/php
 PHP config    : /srv/www/php.ini
 PHP OS        : Linux
 Drush script  : /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush
 Drush version : 10.3.6
 Drush temp    : /tmp
 Drush configs : /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.yml
 Drupal root   : /srv/www/htdocs/jar/drupal

I am running Drupal 9.0.8 and drush 10.3.6 (in /srv/www/htdocs/jar/drupal). I have removed drush using composer (2.0.3) and reinstalled it (recreating vendor in the process).

/srv/www/htdocs/jar/drupal # ./drush -vvv cr
 (preflight) Config paths: /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.yml
 (preflight) Alias paths: /srv/www/htdocs/jar/drupal/drush/sites,/srv/www/htdocs/jar/drush/sites
 (preflight) Commandfile search paths: /srv/www/htdocs/jar/drupal/vendor/drush/drush/src
 (debug) Starting bootstrap to site (0.04 sec, 8.17 MB)

In BootstrapHook.php line 32:
  (Exception)
  Bootstrap failed. Run your command with -vvv for more information.
Exception trace:
  at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Boot/BootstrapHook.php:32
 DrushBootBootstrapHook->initialize() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:44
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->doInitializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:36
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->callInitializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:29
 ConsolidationAnnotatedCommandHooksDispatchersInitializeHookDispatcher->initialize() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 ConsolidationAnnotatedCommandCommandProcessor->initializeHook() at /srv/www/htdocs/jar/drupal/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:296
 ConsolidationAnnotatedCommandAnnotatedCommand->initialize() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Command/Command.php:221
 SymfonyComponentConsoleCommandCommand->run() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:1018
 SymfonyComponentConsoleApplication->doRunCommand() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:271
 SymfonyComponentConsoleApplication->doRun() at /srv/www/htdocs/jar/drupal/vendor/symfony/console/Application.php:147
 SymfonyComponentConsoleApplication->run() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Runtime/Runtime.php:118
 DrushRuntimeRuntime->doRun() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/src/Runtime/Runtime.php:49
 DrushRuntimeRuntime->run() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush.php:72
 require() at /srv/www/htdocs/jar/drupal/vendor/drush/drush/drush:4

I looked at all the above suggestions, but am stuck. Drush works perfectly on my other 5 sites…

php – Python3 + MYSQL8.0 – Beginner coding help needed — Query string from serial and pass through MYSQL before executing if/else

I am trying to get this code to pass a string received through serial and formatted to Ascii to MySQL to see if it and associated information are present. The database is part of a PHP application and needs to work with Python unchanged.

I am a beginner at Python and MySql so any help to get me moving forward would be appreciated.

import serial
import mysql.connector
import codecs

rfid = serial.Serial(port = "/dev/ttyUSB0", baudrate=9600) 

while True:
    if (rfid.in_waiting > 0):
            UID = rfid.readline()
            UID = UID.decode('Ascii')
            mydb = mysql.connector.connect(
            host="localhost",
            user="****",
            password="****",
            database="****")
            getUID = "SELECT * FROM table_mkaccess WHERE id = '%s'"
            mycursor = mydb.cursor()
            mycursor.execute(getUID,'name')
            result = mycursor.fetchone()
            
            if result != 0:
                print('1')
            else:
                print('0')

This is the working PHP code for a similar function that returns a 0 or 1 based on if there is a name registered with the incoming UID/id

 $pdo = Database::connect();
    $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = "SELECT * FROM table_mkaccess  where id = ?";
    $q = $pdo->prepare($sql);
    $q->execute(array($UIDresult));
    $data = $q->fetch(PDO::FETCH_ASSOC);
    Database::disconnect();
    $msg = null;
    if (null==$data('name')) {
            $msg = "bad";
            $data('id')=$UIDresult;
    } else {
            $msg = "good";
    }
    echo $msg;

android – How to pass data between fragments with setFragmentResultListener?

I have a Parent Fragment & Dialog Fragment in my App. When an action happens in the Dialog then I need to refresh the Parent Fragment with FragmentResultListener. I’m following this method launched in Jetpack.

But the onFragmentResult is not getting triggered from the Dialog Fragment. Please guide me…

Parent Fragment

public class HomeFragment extends Fragment {

    HomeViewModel mViewModel;
    HomeViewModel.HomeViewModelFactory mFactory;

    RendererRecyclerViewAdapter mDiscoverRVAdapter;
    RendererRecyclerViewAdapter mYourRVAdapter;
    RendererRecyclerViewAdapter mFrndRVAdapter;
    HashMap<String, RequestBody> partMap = new HashMap<>();

    User mUser;
    private NavController navController;
    FragmentHomeBinding mBind;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {

        mBind = FragmentHomeBinding.inflate(inflater);
        mUser = PrefUtils.getUserPrefs(getActivity());

        mBind.stk.setOnClickListener(view -> launchstk());

        mBind.loader.retry.setOnClickListener(view -> {
            mBind.loader.progress.show();
            handleData();
        });

        mDiscoverRVAdapter = new RendererRecyclerViewAdapter();
        mDiscoverRVAdapter.registerRenderer(new RayViewRenderer(getActivity(), Constants.HOME, R.layout.item_ray, false));

        mBind.rvEntity.setLayoutManager(new LinearLayoutManager(getActivity(), RecyclerView.HORIZONTAL, false));
        mBind.rvEntity.setAdapter(mDiscoverRVAdapter);
        return mBind.getRoot();
    }


    private void fetchDashboard() {

        partMap.put("user_id", Utils.createPartFromString(mUser.getUserID()));

        mViewModel.getStickers(partMap).observe(getActivity(), apiResponse -> {
            if (apiResponse.getError() == null) {
                mBind.loader.main.setVisibility(View.GONE);
                mBind.main.setVisibility(View.VISIBLE);

                Dashboard mDash = apiResponse.getDash();

                if (Utils.isNullOrEmpty(mDash.getEntityStickers()))
                    mBind.emptyDisc.setVisibility(View.VISIBLE);
                else {
                    mDiscoverRVAdapter.setItems(mDash.getEntityStickers());
                    mDiscoverRVAdapter.notifyDataSetChanged();
                    mBind.emptyDisc.setVisibility(View.GONE);
                }

            } else {
                Log.e("SHOW ALERT", apiResponse.getError().getLocalizedMessage());
                mBind.loader.main.setVisibility(View.VISIBLE);
                mBind.loader.retry.setVisibility(View.VISIBLE);
            }

        });
    }


    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        getChildFragmentManager().setFragmentResultListener("key", this, new FragmentResultListener() {
            @Override
            public void onFragmentResult(@NonNull String key, @NonNull Bundle bundle) {
                Log.e("onFragment > ", "REFRESH UI HERE!");
                // Do something with the result...
            }
        });

        mFactory = InjectorUtils.provideHomeFactory(getActivity());
        mViewModel = new ViewModelProvider(this, mFactory).get(HomeViewModel.class);

    }

    private void handleData() {
        if (Utils.isNetworkAvailable(getActivity()))
            fetchDashboard();
        else {
            mBind.loader.progress.hide();
            mBind.loader.retry.setVisibility(View.VISIBLE);
            mBind.loader.loaderText.setText("PLEASE CHECK YOUR INTERNET");
        }
    }

    @Override
    public void onResume() {
        super.onResume();
        Log.e("onResume: ", "LOADING AGAIN ON WAKE UP");
        handleData();
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        getChildFragmentManager().setFragmentResultListener("key", this, new FragmentResultListener() {
            @Override
            public void onFragmentResult(@NonNull String key, @NonNull Bundle bundle) {
                // We use a String here, but any type that can be put in a Bundle is supported
                Log.e("onFragmentResult: ", "REFRESH UI HERE!");
                // Do something with the result...
            }
        });
    }
}

Dialog Fragment

public class RayDialog extends DialogFragment {

    private static RayDialog rayDialog;
    RayDialogBinding mBind;
    private static Context mCon;
    private static Boolean viaEntity;
    private String mLink, mShareTags;
    Ray mStk;
    private View stkView;
    private Window stkWindow;
    private User mUser;

    public RayDialog() {
    }

    public static RayDialog newInstance(Context context, Ray mStk, Boolean entityOnclick) {
        rayDialog = new RayDialog();
        mCon = context;
        viaEntity = entityOnclick;
        Bundle args = new Bundle();
        args.putSerializable("STK", mStk);
        rayDialog.setArguments(args);
        return rayDialog;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mBind = RayDialogBinding.inflate(inflater);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
        mStk = (Ray) getArguments().getSerializable("STK");

        mUser = PrefUtils.getUserPrefs(getActivity());

        if (mStk != null) {
            mBind.name.setText(mStk.getStkName());
            Glide.with(mCon).load(mStk.getStkCategoryImage()).into(mBind.categoryIcon);

            mBind.tag.setText(mStk.getStkHashtag());
            mBind.date.setText(mStk.getStkDate());

            mBind.logo.setOnClickListener(view -> {
                if (!viaEntity && !RayUtils.isIDEAStk(mStk.getStkType()) && !RayUtils.isIDEAStk(mStk.getStkSegment())) {
                    dismiss();
                    NavHostFragment navHostFragment = (NavHostFragment) ((FragmentActivity) mCon).getSupportFragmentManager().findFragmentById(R.id.nav_host_fragment);
                    NavController navController = navHostFragment.getNavController();
                    Bundle mBundle = new Bundle();

                    if (RayUtils.isCHARITY(mStk.getStkOrigin())) {
                        mBundle.putString("ENTITY_NAME", mStk.getStkName());
                        mBundle.putString("ORIGIN", mStk.getStkOrigin());
                        mBundle.putBoolean("PRELOADED", true);
                    } else {
                        mBundle.putString("ENTITY_NAME", mStk.getStkName());
                    }
                    navController.navigate(R.id.nav_home_to_entityProfile, mBundle);
                }
            });

            if (Utils.isStringAvail(mLink))
                mBind.link.setVisibility(View.VISIBLE);

            mBind.link.setOnClickListener(view -> {
                if (Utils.isStringAvail(mLink)) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(mLink));
                    startActivity(intent);
                }
            });

            mBind.delete.setVisibility(enableDelete() ? View.VISIBLE : View.GONE);

            mBind.delete.setOnClickListener(view -> {
               deleteAlert();
            });

        }

        return mBind.getRoot();
    }

    private void deleteAlert() {
        MaterialAlertDialogBuilder alert = new MaterialAlertDialogBuilder(getActivity());
        alert.setTitle("Delete STKYR");
        alert.setMessage("Do you want to delete this Ray?");
        alert.setNegativeButton("NO", (dialog, i) -> dialog.dismiss());
        alert.setPositiveButton("YES", (dialog, i) -> {
            dialog.dismiss();
            dismiss();
            Log.e("deleteAlert: ", "> >" + getTag());

            Bundle mBundle = new Bundle();
            mBundle.putString("DELETE", "TRUE");
            getParentFragmentManager().setFragmentResult("key", mBundle);

//            deleteStk();
        });
        alert.show();
    }

}

RayRenderer (RV Adapter)

public class RayViewRenderer extends ViewRenderer<ray, ViewFinder> {

    public RayViewRenderer(Context mCon, String mSrc, final int layoutID, Boolean entityOnclick) {
        super(layoutID, ray.class, (mRay, finder, payloads) -> finder
                .setText(R.id.name, mRay.getRayName()).setText(R.id.tag, mRay.getRayHashtag())
                .find(R.id.image, (ViewProvider<ImageView>) imageView ->
                {
                    if (rayUtils.isINVITERay(mRay.getRayType())) {
                        imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
                    } else {
                        imageView.setScaleType(ImageView.ScaleType.FIT_XY);
                    }
                    Glide.with(mCon).load(mRay.getRayImage()).into(imageView);
                })
                .setOnClickListener(() -> {
                    rayDialog(mCon, mSrc, entityOnclick, mRay);
                }));

    }

    private static void rayDialog(Context mCon, String mSrc, Boolean entityOnclick, ray mRay) {
        FragmentManager fm = ((FragmentActivity) mCon).getSupportFragmentManager();
        rayDialog mRayDialog= RayDialog.newInstance(mCon, mRay, entityOnclick);
        mRayDialog.show(fm, mSrc);
    }

}

Does bit.ly pass info about referrer?

So that I will be able to see where people that used my bit.ly link come from?

I already checked it with Chrome dev tool in Network tab but there is no info.

mysql – Is it possible to pass boolean true/false (as opposed to 1/0) into MariaDB with STRICT_TRANS_TABLES?

I’ve recently done a new server install, and it seems on the old one I had sql_mode='' in my my.cnf file. I’ve removed that now, so I have the default STRICT_TRANS_TABLES and the other default options.

Sadly though, that STT declaration is breaking my php PDO code where I explicity force type on my booleans, and send true/false through to the database.

I guess before these were being silently converted to 1/0.

Are these my only options:

  1. change my PHP variables ($isArchived etc) from the semantic niceness of true/false to 1/0.

  2. reinstate sql_mode = ''

Or am I missing something? My columns are defined as tinyint(1) – that used to be the best we could do with MySQL, and I don’t THINK there’s a boolean type, even now. What’s the best practice? Thank you!

edit:

I realise now it’s just false it fails on. It happily converts true to 1, but for some reason sees false as '' and balks. Could this be a problem in my PHP code rather than MySQL…

c++ – Pass char* to function and overwrite it in memory

I want to pass a string (char *) to a function inside a dll to overwrite it with another string.

File dll.cpp

__declspec(dllexport) void getString(char *name, char *buffer, int len) {

    std::string str = getString(); 
    char *cstr = new char(str.length() + 1);
    strcpy(cstr, str.c_str());
    strncpy(buffer, cstr, len);

}

File main.cpp

char *buffer;
getString("z", buffer, 128);      
printf("%s", buffer);

I dont know how to correctly pass the buffer to overwrite it.

linux – Best password manager: Unix PASS or .KDBX with KeepassXC?

Since I have been focusing on leaving some proprietary password managers I have paid for years, I am taking a more independent approach and I would like to know your input about this matter. I use Linux extensively and using a KDBX file with KeepassXC felt (and still does) like a good option. However, after finding out the Unix password manager called “pass”. I have given it a try and it’s been quite useful to my workflow. It is even integrated with GIT for version control.

What are your pieces of advice about these options? What would be considered good practice in terms of best security?

Thanks in advance.