table – How can I create a list that always ends in with two 1’s but starts with a variable amount of 0’s

I want to create a variable list like this:

{0, 0, ..., 0, 0, 1, 1}

This list would grow list this, starting with no 0’s, but then gaining more 0’s to the left the larger you want it.

f[0]:={1,1}

f[1]:={0,1,1}

f[2]:={0,0,1,1}

f[3]:={0,0,0,1,1}

f[4]:={0,0,0,0,1,1}

I know that I can create Table[] to create ten 0 by doing

Table[0, 10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

but not an efficient way to have it so that the last two digits are 1.

Is the focus point a variable or absolute size?

In illustrations of the focus point of a sense, it looks to me to be infinitely small and as a result the resulting convergence of light would not yield an image. If the focus point is NOT infinitely small at what size is it determined to be optimal from a perspective of focus?

Icon for fixed vs variable / floating intervals

(Let me know if this should be posted elsewhere)

What kind of icon would you use to show a fixed vs. variable/floating schedule? I’m working on something for preventative maintenance specifically, but it could be used for scheduling as well.

  • Fixed: happens on a schedule. For example, maintenance every 1000 miles is scheduled for 1000 miles, 2000 miles, 3000 miles, etc. Even if you weren’t able to get the maintenance until the odometer was at 1800 miles, you’ve got another maintenance at 2000 miles.
  • Variable/floating: happens in intervals, based on what has actually happened. For example, if maintenance is scheduled every 1000 miles: you get maintenance done at 1800 miles, and your next maintenance is for 2800 miles. If you missed that maintenance and got it done at 2900 miles, your next maintenance is for 3900 miles.

What kind of icon idea would be best for this? Would an icon even work for a concept as abstract as this?

Ideas:

  • Timeline with equal ticks or space between ticks
  • Hourglass / clock (variable)
  • Calendar (fixed)

Elliptic problem in one variable vanishes?

Let $g$ be real-analytic functions on some open domain $Omega subset mathbb R^2$ and $f$ a non-zero real analytic function on $mathbb R^2$ such that

$$Lg(x,y):=f(x,y)frac{partial }{partial x} left(f(x,y)cdot frac{partial}{partial x}right)g(x,y) = g(x,y)$$

is satisfied for $x,y in Omega.$

Now, assume that $g(x_0,y_0)$ and $frac{partial }{partial x}g(x_0,y_0)=0.$ From iteratively applying the above differential operator $L$ we find that $frac{partial^n }{partial x^n}g(x_0,y_0)=0$ for all $n.$

I ask: Do there exist sufficient conditions on $f$ such that $g$ has to be zero on $Omega$?

I also observe that $g$ cannot have any terms in its power series that depend only on $y$, i.e. $partial_y^n g(x_0,y_0)=0.$ This also follows iteratively, as in that case, if we write $g(x,y)= h(x,y)+alpha y$ for $h$ such that $partial_y h(x_0,y_0)=0$ then

$$partial_y Lg(x_0,y_0)= 0$$ since $partial_x^n g(x_0,y_0)=0$ and $partial_x partial_y (alpha y)=0.$

Thus, knowing that $partial_y g(x_0,y_0)=0$ we can conclude that $partial_y^2 g(x_0,y_0)=0$ and so on.

scripting – Variable depth of nesting inside Table

If I understand your ultimate goal, to produce those $s_1 s_2 … s_n$ products, try the following instead, which should be equivalent to $s_i$ for $i=1$ to $3$:

n = 3;
Times @@@ Tuples@Table[Range[5], n]

{1, 2, 3, 4, 5, 2, 4, 6, 8, 10, 3, 6, 9, 12, 15, 4, 8, 12, 16, 20, 5, 10, 15, 20, 25, 2, 4, 6, 8, 10, 4, 8, 12, 16, 20, 6, 12, 18, 24, 30, 8, 16, 24, 32, 40, 10, 20, 30, 40, 50, 3, 6, 9, 12, 15, 6, 12, 18, 24, 30, 9, 18, 27, 36, 45, 12, 24, 36, 48, 60, 15, 30, 45, 60, 75, 4, 8, 12, 16, 20, 8, 16, 24, 32, 40, 12, 24, 36, 48, 60, 16, 32, 48, 64, 80, 20, 40, 60, 80, 100, 5, 10, 15, 20, 25, 10, 20, 30, 40, 50, 15, 30, 45, 60, 75, 20, 40, 60, 80, 100, 25, 50, 75, 100, 125}


If you want the same list structure that would be generated by Table, then try

ArrayReshape[Times @@@ Tuples@Table[Range[5], n], ConstantArray[5, n]]

{{{1, 2, 3, 4, 5}, {2, 4, 6, 8, 10}, {3, 6, 9, 12, 15}, {4, 8, 12, 16, 20}, {5, 10, 15, 20, 25}}, {{2, 4, 6, 8, 10}, {4, 8, 12, 16, 20}, {6, 12, 18, 24, 30}, {8, 16, 24, 32, 40}, {10, 20, 30, 40, 50}}, {{3, 6, 9, 12, 15}, {6, 12, 18, 24, 30}, {9, 18, 27, 36, 45}, {12, 24, 36, 48, 60}, {15, 30, 45, 60, 75}}, {{4, 8, 12, 16, 20}, {8, 16, 24, 32, 40}, {12, 24, 36, 48, 60}, {16, 32, 48, 64, 80}, {20, 40, 60, 80, 100}}, {{5, 10, 15, 20, 25}, {10, 20, 30, 40,50}, {15, 30, 45, 60, 75}, {20, 40, 60, 80, 100}, {25, 50, 75, 100, 125}}}

java – ¿Cómo paso el valor de una variable (O el objeto completo) desde una clase a otra para trabajar con él?

Tengo una clase DAO en el que haciendo: PruebaDAO pruebaDAO tengo acceso a un método String Id = pruebaDAO.getID();
Debuggeando consigo ver que este Id se me rellena en esa clase.

Lo que no sé es cómo puedo acceder a ese dato desde otra clase exterior que no está en ese package, concretamente a ese dato ya rellenado, o en su defecto enviar un objeto con todos los datos que contiene, o un ArrayList de objetos con todos los datos. Ya que si lo declaro como estático y lo llamo desde otra clase el Id me aparece como null.

7 – save views->execute result as a static variable

Does it make sense (performancewise) to store view->execute() as a static variable in order to avoid running same view multiple times?

And then call view->render() wherewer I want to print the view? Does it make any sense? Or are there better options? Thank you

python – Passing the iterating variable inside loop body

I’m new to Python and am confronted with the following (hopefully simple) problem.

I want to check some condition with an iterator over a list and would like to get the element for which this is fulfilled.

str = "abab"
symbols = ("a", "b")
while any(letter in str for letter in symbols):
        #print or do something else with the letter

Naturally, after attempting to use the loop variable in the body, it doesn’t exist anymore and the compiler throws an error. So, how can I pass the current element of symbols inside the while-loop?

Thanks in advance.

Magento2: Notice: Undefined variable: _product

I use product slider from mageplaza.

Above product name I try display brand name from attribute: newbrand_name

to file productslider.phtml I add below code:

<?php
$optionText = '';
$attr = $_product->getResource()->getAttribute('newbrand_name');
if ($attr->usesSource()) {
    $optionText = $attr->getSource()->getOptionText($_product->getNewbrandName());
}
?>
<?php if ($optionText) { ?>
    <div class="brand-name"><?php echo $optionText ?></div><br />
<?php } ?>

In frontend I get issue:

Notice: Undefined variable: _product in /home/shop/domains/domain.com/public_html/app/code/Mageplaza/Productslider/view/frontend/templates/productslider.phtml on line 50

Here is full file code:

<?php
/**
 * Mageplaza
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Mageplaza.com license that is
 * available through the world-wide-web at this URL:
 * https://www.mageplaza.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Mageplaza
 * @package     Mageplaza_Productslider
 * @copyright   Copyright (c) Mageplaza (https://www.mageplaza.com/)
 * @license     https://www.mageplaza.com/LICENSE.txt
 */

use MageplazaProductsliderBlockAbstractSlider;
use MagentoFrameworkAppActionAction;

/** @var AbstractSlider $block */
$mode = 'grid';
$title = $block->getTitle();
$blockId = $block->getSliderId() . uniqid('-', false);
$items = $block->getProductCollection();
if ($items && $items->getSize()) : ?>
    <div class="mp-product-slider-block block widget block-products-list <?= /** @noEscape */ $mode ?>">
        <h2 class="mp-product-slider-title"><?= $block->escapeHtml($title) ?></h2>
        <p class="mp-ps-info"><?= $block->escapeHtml($block->getDescription()) ?></p>
    </div>
    <div class="block-content mp-product-slider-content">
        <div class="products-<?= /** @noEscape */  $mode ?> <?= /** @noEscape */  $mode ?>">
            <ol class="product-items widget-viewed-grid">
                <?php $iterator = 1; ?>
                <div id="mp-list-items-<?= /** @noEscape */ $blockId ?>" class="owl-carousel owl-theme">
                    <?php foreach ($items as $_item) : ?>
                        <?= ($iterator++ == 1) ? '<li class="product-item product-slider"">' : '</li><li class="product-item product-slider"">' ?>
                        <div class="slider-product-item-info">
                            <a href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>"
                               class="product photo slider-product-item-photo">
                                <?= $block->getImage($_item, 'recently_viewed_products_grid_content_widget')->toHtml(); ?>
                            </a>
                            <div class="product details slider-product-item-details">
                            <?php 
                                        $optionText = '';
                                        $attr = $_product->getResource()->getAttribute('newbrand_name');
                                        if ($attr->usesSource()) {
                                           $optionText = $attr->getSource()->getOptionText($_product->getNewbrandName());
                                        }
                                    ?>
                                    <?php if($optionText){ ?>
                                        <div class="brand-name"><?php echo $optionText ?></div><br />
                                    <?php } ?>
                                <strong class="product name product-item-name">
                                    <a title="<?= $block->escapeHtml($_item->getCustomName()) ?>"
                                       href="<?= $block->escapeUrl($block->getProductUrl($_item)) ?>">
                                        <?= $block->escapeHtml($_item->getCustomName()) ?>
                                    </a>
                                </strong>

                                <?php if ($block->canShowReview()) : ?>
                                    <?= $block->getReviewsSummaryHtml($_item, 'short', true) ?>
                                <?php endif; ?>

                                <?php if ($block->canShowPrice()) : ?>
                                    <?= /** @noEscape */ $block->getProductPrice($_item) ?>
                                <?php endif; ?>

                                <div class="product actions slider-product-item-actions product-item-actions">
                                    <?php if ($block->canShowAddToCart()) : ?>
                                        <div class="actions-primary">
                                            <?php if ($_item->isSaleable()) : ?>
                                                <?php $postParams = $block->getAddToCartPostParams($_item); ?>
                                                <form data-role="tocart-form" data-product-sku="<?= $block->escapeHtml($_item->getSku()) ?>" action="<?= /* @NoEscape */ $postParams('action') ?>" method="post">
                                                    <input type="hidden" name="product" value="<?= /* @escapeNotVerified */ $postParams('data')('product') ?>">
                                                    <input type="hidden" name="<?= /* @escapeNotVerified */ Action::PARAM_NAME_URL_ENCODED ?>" value="<?= /* @escapeNotVerified */ $postParams('data')(Action::PARAM_NAME_URL_ENCODED) ?>">
                                                    <?= $block->getBlockHtml('formkey') ?>
                                                    <button type="submit"
                                                            title="<?= $block->escapeHtml(__('Add to Cart')) ?>"
                                                            class="action tocart primary">
                                                        <span><?= /** @noEscape */ __('Add to Cart') ?></span>
                                                    </button>
                                                </form>
                                            <?php else : ?>
                                                <?php if ($_item->getIsSalable()) : ?>
                                                    <div class="stock available"><span><?= $block->escapeHtml(__('In stock')) ?></span></div>
                                                <?php else : ?>
                                                    <div class="stock unavailable"><span><?= $block->escapeHtml(__('Out of stock')) ?></span></div>
                                                <?php endif; ?>
                                            <?php endif; ?>
                                        </div>
                                        <div class="secondary-addto-links actions-secondary"
                                             data-role="add-to-links">
                                            <?php if ($this->helper('MagentoWishlistHelperData')->isAllow()) : ?>
                                                <a href="#"
                                                   data-post='<?= /** @noEscape */ $block->getAddToWishlistParams($_item); ?>'
                                                   class="action towishlist" data-action="add-to-wishlist"
                                                   title="<?= /** @noEscape */ __('Add to Wish List') ?>">
                                                    <span><?= /** @noEscape */ __('Add to Wish List') ?></span>
                                                </a>
                                            <?php endif; ?>
                                            <?php if ($block->getAddToCompareUrl()) : ?>
                                                <?php $compareHelper = $this->helper('MagentoCatalogHelperProductCompare'); ?>
                                                <a href="#" class="action tocompare"
                                                   data-post='<?= /** @noEscape */ $compareHelper->getPostDataParams($_item); ?>'
                                                   data-role="add-to-links"
                                                   title="<?= /** @noEscape */ __('Add to Compare') ?>">
                                                    <span><?= /** @noEscape */ __('Add to Compare') ?></span>
                                                </a>
                                            <?php endif; ?>
                                        </div>
                                    <?php endif; ?>
                                </div>
                            </div>
                        </div>
                        <?= ($iterator === count($items) + 1) ? '</li>' : '' ?>
                    <?php endforeach ?>
                </div>
            </ol>
        </div>
        <?= $block->getPagerHtml() ?>
    </div>
    <script>
        require(('jquery', 'mageplaza/core/owl.carousel'), function ($) {
            $('#mp-list-items-<?= /** @noEscape */ $blockId ?>').owlCarousel(<?= /** @noEscape */ $block->getAllOptions()?>);
        });
    </script>
<?php endif; ?>

java – Duda sobre variable compartida volatile int

bueno tengo una duda con respecto al funcionamiento de volatile en Java.
si por ejemplo tenemos una variable “volatile int x = 0” y tenemos este código.

for(int i = 0; i<3; i++){
x++;
}

Si este bucle for lo ejecutan 5 procesos utilizando la variable compartida volatile, cuál sería el valor final de x y por qué?
Yo pienso que es 15 porque x es volatile pero un amigo me dice es 3.