command line – /bin/bash shell (macOS) throwing `-bash: declare: -A: invalid option` error message at shell start

I briefly changed my default shell on macOS Catalina (10.15.1) to Fish, following the steps in Fish’s documentation.

First, I executed > echo /usr/local/bin/fish | sudo tee -a /etc/shells followed by > chsh -s /usr/local/bin/fish. After, I realized I only needed to use one of these commands, not both, but oh well. What’s done is done.

Later, I decided to switch back to bash, so I ran the commands in reverse (according to Fish’s instructions for reverting) First, > echo /bin/bash | sudo tee -a /etc/shells followed by > chsh -s /bin/bash

When I reloaded the shell using Bash, I received the following error.

-bash: declare: -A: invalid option
declare: usage: declare (-afFirtx) (-p) (name(=value) ...)
-bash: complete: -D: invalid option
complete: usage: complete (-abcdefgjksuv) (-pr) (-o option) (-A action) (-G globpat) (-W wordlist) (-P prefix) (-S suffix) (-X filterpat) (-F function) (-C command) (name ...)

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.

This error did not appear before changing the shell to Fish and then back to Bash, and I didn’t edit any .bashrc or .bash_profile files before changing the shell back to Bash. Can someone help me resolve this?

networking – How to send a custom ICMP reply message for a ICMP request message using Scapy tool?

I am using two ubuntu VM’s and I am trying to send one ICMP request packet from one VM to other and I got a reply which is automatically generated by the system.

Now I want to generate a custom reply for that received ICMP request message using scapy.

I know we can sniff or receive the request message by using sniff/receive commands, But after sniffing that packet, How can I send a custom reply for that ICMP request packet?

Is it possible to do that? If so, How?

edit:-
I want that process to be automatic. Lets say that if I got 5 request packets consecutively I want to send 5 reply messages automatically.

How do I delete a message sent in messenger that has not yet been delivered?

Suppose I wanted to delete a message that has been sent, but hasn’t been delivered yet, like the one in the screenshot.
When I click on it and then click ‘Remove’, I only get the ‘Remove for You’ button.
If I delete the message for me, is it still possible for the message to get delivered to the person?

message sent but not delivered'Remove for Everyone' button is missing

woocommerce – Show a popup message before redirect

i just wrote this functions:

       add_action('woocommerce_before_single_product', 'product_out_of_stock_redirect');
function product_out_of_stock_redirect(){
  global $post;
  global $product;

  $terms = get_the_terms( $post->ID, 'product_cat' );

  foreach ( $terms as $term ) {
    $product_cat_id = $term->term_id;
    break;
  }  
  $terms1 = get_the_terms( $post->ID, 'pa_marca' );

  foreach ( $terms1 as $term1 ) {
    $marca = $term1->name;
    break;
  }  
    $marca = str_replace(".","-",$marca);
    $marca = str_replace("https://wordpress.stackexchange.com/","-",$marca);
    $marca = str_replace("'","",$marca);
  if (!$marca) { 
    $link = get_term_link( (int)$product_cat_id, 'product_cat' );
  }
  else { $link = get_term_link( (int)$product_cat_id, 'product_cat' ); $link= $link . "?filter_marca=" . $marca;  }

    if (!$product->is_in_stock()){   
       wp_redirect( $link, 301 );
       exit(); // Always after wp_redirect() to avoid an error
    }
}

as you can see this simply functions redirects all user that visit an outofstock products to another page.
But i need to add an alert to keep user informated of that…how can i add a simply popup that alerts an user?

message queue – Architecture suggestion for designing realtime video transformation platform

I have a requirement where user’s video stream should be captured, transformed and this transformed stream should be returned back to user in real time.

Here is a oversimplified (in context of transformation) example:

  1. User turn on the portal and user’s video stream start.

  2. Video stream should go to server.

  3. Server should transform (let’s say turn colored images in stream to black and white) and return back to user.

  4. User sees the transformed stream in UI.

I have tried to build a design which is here. Problem I can see with this design is:

  1. Creation of per user topic in outgoing Kinesis/Kafka stream.

  2. User need to directly access the stream infrastructure which I believe should not be exposed.

gui design – Why do modern GUIs tend to have buttons on the side of message boxes?

Ruslan, if you look at older — dare I say, “historical?” 😉 — screenshots, you can see that button placement differs considerably between OS platforms.

The Guidebook GUI Gallery website is an awesome resource to compare such details.

I haven’t seen any research yet on the impact of left/center/right alignment of buttons in dialogs, but the general rule of striving for consistency applies to button placement as well, of course.

Placing key widgets in the same relative location in every context makes it easier for users to find them, and it reduces error rate. In particular, this applies to the key Cancel/Confirmation button pair.

Both macOS and Windows have defined simple principles on where to place those buttons, and which order they need to be in: you’ll typically find those buttons in the botton right corner of a dialog on both OSs. This convention dates back to Mac OS 7 from 1991 and to Window 95/NT4 from 1995/1996. (As seen, e.g., in Open File dialogs or Time and Date Settings.)

So I wonder: have you observed changing button placements for dialogs (or, rather, alerts) that contain more than one button, Ruslan? If not, maybe it was a purely aesthetic consideration for that particular one-button case?

numerics – How to solve this compilation error message?

I compiled the following Mathematica code

m = 40;
eea = Integrate((x - y)^(-((Alpha) - 1) - 
     1) ((Sum((z^(s))*(Cos(((b)^(s))*((Pi))*(y))), {s, 0, m})* 
        Sum((((Lambda))^((d - 2)*k))*(Sin(((Lambda)^k)*(y))), {k, 1,
           m})) - (Sum((z^(s))*(Cos(((b)^(s))*((Pi))*(0))), {s, 0, 
          m})* Sum((((Lambda))^((d - 2)*
              k))*(Sin(((Lambda)^k)*(0))), {k, 1, m}))), {y, 0, x});
sa = D(eea/ Gamma(-((Alpha) - 1)), {x, 1})

And for the resulting output i gave the following substitution

% /. x -> 1 /. (Lambda) -> 3 /. d -> 15/10 /. 
   z -> 1/10 /. (Alpha) -> 2/10 /. b -> 35

Then for the resulting output i calculated the numerical value using the code

N(%)

So for the above numerical compilation i got the following error message

General::ovfl: Overflow occurred in computation.
General::stop: Further output of General::ovfl will be suppressed during this calculation.

Could anyone please suggest any answer to solve this issue.

Thank You

forms – What is a better way to indicate an optional message reminder when food order is ready

I’m designing a mobile website for a food ordering service. There is a feature at the last step of the ordering flow where the user can choose to be messaged once their order is ready. This is optional and the user can ignore it if they want.

How can i improve the following design to let the user know that entering their number is optional. However if they don’t enter their number they will need to check the collection counter display to know when their number shows up.

enter image description here

forms – How is a better way to indicate an optional message reminder when food order is ready

I’m designing a mobile website for a food ordering service. There is a feature at the last step of the ordering flow where the user can choose to be messaged once their order is ready. This is optional and the user can ignore it if they want.

How can i improve the following design to let the user know that entering their number is optional. However if they don’t enter their number they will need to check the collection counter display to know when their number shows up.

enter image description here

magento2.3 – How add file to email message in Magento 2.3.5?

I’m trying to do so

Create di.xml file at app/code/vendor/module/etc/

<preference for="MagentoFrameworkMailTemplateTransportBuilder" type="VendorModuleModelMailTemplateTransportBuilder" />

In my VendorModuleModelMailTemplateTransportBuilder.php

<?php
declare(strict_types=1);

namespace VendorModuleModelMailTemplate;

use MagentoFrameworkAppTemplateTypesInterface;
use MagentoFrameworkExceptionLocalizedException;
use MagentoFrameworkExceptionMailException;
use MagentoFrameworkMailEmailMessageInterface;
use MagentoFrameworkMailEmailMessageInterfaceFactory;
use MagentoFrameworkMailAddressConverter;
use MagentoFrameworkMailExceptionInvalidArgumentException;
use MagentoFrameworkMailMessageInterface;
use MagentoFrameworkMailMessageInterfaceFactory;
use MagentoFrameworkMailMimeInterface;
use MagentoFrameworkMailMimeMessageInterfaceFactory;
use MagentoFrameworkMailMimePartInterfaceFactory;
use MagentoFrameworkMailTemplateFactoryInterface;
use MagentoFrameworkMailTemplateSenderResolverInterface;
use MagentoFrameworkMailTemplateInterface;
use MagentoFrameworkMailTransportInterface;
use MagentoFrameworkMailTransportInterfaceFactory;
use MagentoFrameworkObjectManagerInterface;
use MagentoFrameworkPhrase;
use ZendMimeMime;
use ZendMimePartFactory;

/**
 * TransportBuilder
 *
 * @api
 * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
 * @since 100.0.2
 */
class TransportBuilder extends MagentoFrameworkMailTemplateTransportBuilder
{
    /**
     * Template Identifier
     *
     * @var string
     */
    protected $templateIdentifier;

    /**
     * Template Model
     *
     * @var string
     */
    protected $templateModel;

    /**
     * Template Variables
     *
     * @var array
     */
    protected $templateVars;

    /**
     * Template Options
     *
     * @var array
     */
    protected $templateOptions;

    /**
     * Mail Transport
     *
     * @var TransportInterface
     */
    protected $transport;

    /**
     * Template Factory
     *
     * @var FactoryInterface
     */
    protected $templateFactory;

    /**
     * Object Manager
     *
     * @var ObjectManagerInterface
     */
    protected $objectManager;

    /**
     * Message
     *
     * @var EmailMessageInterface
     */
    protected $message;

    /**
     * Sender resolver
     *
     * @var SenderResolverInterface
     */
    protected $_senderResolver;

    /**
     * @var TransportInterfaceFactory
     */
    protected $mailTransportFactory;

    /**
     * Param that used for storing all message data until it will be used
     *
     * @var array
     */
    private $messageData = ();

    /**
     * @var EmailMessageInterfaceFactory
     */
    private $emailMessageInterfaceFactory;

    /**
     * @var MimeMessageInterfaceFactory
     */
    private $mimeMessageInterfaceFactory;

    /**
     * @var MimePartInterfaceFactory
     */
    private $mimePartInterfaceFactory;

    /**
     * @var AddressConverter|null
     */
    private $addressConverter;

    protected $attachments = ();

    protected $partFactory;

    /**
     * TransportBuilder constructor
     *
     * @param FactoryInterface $templateFactory
     * @param MessageInterface $message
     * @param SenderResolverInterface $senderResolver
     * @param ObjectManagerInterface $objectManager
     * @param TransportInterfaceFactory $mailTransportFactory
     * @param MessageInterfaceFactory|null $messageFactory
     * @param EmailMessageInterfaceFactory|null $emailMessageInterfaceFactory
     * @param MimeMessageInterfaceFactory|null $mimeMessageInterfaceFactory
     * @param MimePartInterfaceFactory|null $mimePartInterfaceFactory
     * @param addressConverter|null $addressConverter
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
     */
    public function __construct(
        FactoryInterface $templateFactory,
        MessageInterface $message,
        SenderResolverInterface $senderResolver,
        ObjectManagerInterface $objectManager,
        TransportInterfaceFactory $mailTransportFactory,
        MessageInterfaceFactory $messageFactory = null,
        EmailMessageInterfaceFactory $emailMessageInterfaceFactory = null,
        MimeMessageInterfaceFactory $mimeMessageInterfaceFactory = null,
        MimePartInterfaceFactory $mimePartInterfaceFactory = null,
        AddressConverter $addressConverter = null
    ) {
        $this->templateFactory = $templateFactory;
        $this->objectManager = $objectManager;
        $this->_senderResolver = $senderResolver;
        $this->mailTransportFactory = $mailTransportFactory;
        $this->emailMessageInterfaceFactory = $emailMessageInterfaceFactory ?: $this->objectManager
            ->get(EmailMessageInterfaceFactory::class);
        $this->mimeMessageInterfaceFactory = $mimeMessageInterfaceFactory ?: $this->objectManager
            ->get(MimeMessageInterfaceFactory::class);
        $this->mimePartInterfaceFactory = $mimePartInterfaceFactory ?: $this->objectManager
            ->get(MimePartInterfaceFactory::class);
        $this->addressConverter = $addressConverter ?: $this->objectManager
            ->get(AddressConverter::class);
        $this->partFactory = $objectManager->get(PartFactory::class);
        parent::__construct($templateFactory, $message, $senderResolver, $objectManager, $mailTransportFactory, $messageFactory, $emailMessageInterfaceFactory, $mimeMessageInterfaceFactory,
            $mimePartInterfaceFactory, $addressConverter);
    }
    /**
     * Handles possible incoming types of email (string or array)
     *
     * @param string $addressType
     * @param string|array $email
     * @param string|null $name
     *
     * @return void
     * @throws InvalidArgumentException
     */
    private function addAddressByType(string $addressType, $email, ?string $name = null): void
    {
        if (is_string($email)) {
            $this->messageData($addressType)() = $this->addressConverter->convert($email, $name);
            return;
        }
        $convertedAddressArray = $this->addressConverter->convertMany($email);
        if (isset($this->messageData($addressType))) {
            $this->messageData($addressType) = array_merge(
                $this->messageData($addressType),
                $convertedAddressArray
            );
        }
    }

    /**
     * @param string|null $content
     * @param string|null $fileName
     * @param string|null $fileType
     * @return TransportBuilder
     */
    public function addAttachment(?string $content, ?string $fileName, ?string $fileType)
    {
        $attachmentPart = $this->partFactory->create();
        $attachmentPart->setContent($content)
            ->setType($fileType)
            ->setFileName($fileName)
            ->setDisposition(Mime::DISPOSITION_ATTACHMENT)
            ->setEncoding(Mime::ENCODING_BASE64);
        $this->attachments() = $attachmentPart;

        return $this;
    }
}

Add attachment in email like :

$this->transportBuilder->addAttachment($content, $fileName, 'application/pdf');

But it does not work

After

use ZendMimeMime;
use ZendMimePartFactory;

I get this message: Undefined class

Please tell me how can I add a file to an email message?