evaluation – Define the interleaving function and then evaluate its arguments

I want to define a function interleaveWithX[statements__] with behavior such as evaluation, for example,

interleaveWithX[a, b, c, d]

produces the same results as the evaluation

a; x; b; x; c; x; d

Getting interleaved arguments is not a problem; something like

interleaveWithX[statements__] := Riffle[List@statements, x]

does the job well. But assuming the statements and x are already defined, I'm having trouble understanding which combination of SetAttribute, Hold, Unevaluated, ReleaseHold, Evaluate, etc. I need to integrate into my function definition, and where, in order to delay the evaluation of the arguments until I have interleaved them in the desired order.

7 – How to define the granularity to an end date value used as a sorting criterion in the views?

I have a Date field with start and end dates (mm-dd-yy).

I need to build a view listing the nodes grouped by end date year and sorted first by decreasing end date year and then by ascending title.

Grouping is OK, I can set the date field to End only and define a custom format (Y).

Unfortunately, the nodes are sorted by full end date, including month and day, and therefore the second sort does not work (the ascending title is applied only for nodes with the same exact end date and not all of it. 39; year).

If I could define the granularity of the sorting criteria for the end date (year, obviously), I suppose it would work, but this option is not available, to my knowledge, for a range of dates.

I tried to sort with a short custom module, using views_query_alter (How can I sort on several levels in the views?) But the result is the same and I don't know how to define the granularity (another function? In the same?).

Any idea here?

magento2 – how to define a label like Sale and new on product supports in magento 2?

Battery exchange network

The Stack Exchange network includes 175 question and answer communities, including Stack Overflow, the largest and most reliable online community for developers who want to learn, share knowledge and develop their careers.

Visit Stack Exchange

Integration ux – How to collaborate and define a new style guide for an existing business design?

As a naïve designer, I have a hard time defining a style guide. There is a style guide created with Adobe XD. As a team effort, we would like to improve and manage the style guide. A reasonable and productive solution is to use Frontify. Unfortunately, the company is running out of budget and we have to look for an alternative that can provide the same functionality as Frontify.

Anyone facing the same problem?

Define the notation of a grammar

Let's say I have a grammar, for example,

$$ begin {align} S & à AB mid abc \
A & à aAb mid lambda \
B & à bBa mid ba
end {align} $$

Now it's obvious that the notation for this would be something like,
$$ L (G) = {a ^ {i} b ^ {i} b ^ {k} a ^ {k} | i ge 0, k> 0 } $$

My question is how do I report the starting state going to abc. How can I represent this in overall notation? My only thought would be to add $ (abc) ^ {m} $ to the statement, then say something like i, k == 0 then m = 1. Although I'm not sure if this is allowed?

equation solving – How to define an intermediate variable

I want to find the relationship between several parameters. But I don't know how to define an intermediate variable.
For example:
I want to know the relation between x and {y, z} which will satisfy the constraints with the variables {q1, q2}. How should I define {q1, q2} to make them only intermediate variables and ensure that they will not appear in the final results.

Reduce[x q1 + y q2 + 3 z > 0 && q1 + q2 == x - y && z q1 + y q2 == 0,

How to define the following function in Mathematica?

How to define the following function in Mathematica?

enter description of image here

kubernetes – Why do I have to explicitly define labels multiple times?

Why is it necessary to define the deployment labels several times? Just to explain my question quickly, I will give an example.

apiVersion: apps/v1
kind: Deployment
# 1st Time
    name: app
    tier: backend
# 2nd Time
      app: app
      tier: backend
# 3rd time
        app: app
        tier: backend

My first problem is that I really didn't find a good reason spec.selector.matchlabels exist at all. spec.selector.matchlabels must match spec.template.metadata.labels right?


Pod selector. Existing ReplicaSets whose pods are selected by
they will be the ones who will be affected by this deployment. It must match the pod
model labels.

So why do you have to define them explicitly, if they have to be set to a specific value that kubernetes knows anyway and will generate an error anyway if one doesn't match another?

My second problem, which might have a more reasonable answer, is: why do you need to explicitly define deployment labels and model labels? Aren't they supposed to match equally, or are there cases where they might not match each other?

In case I could do or understand something wrong, please mention it! :RE

magento2.2.3 How do I define the scope of js knockout when using data-mage-init?

I am working on Magento2.2.3.
I replace the products in the list page. I add exactly Already added qty for each product next to add to cart button in the list page.
To show this qty, I have created a custom phtml file. Let's call it custom.phtml
In the custom.phtml file, I add qty_change.js get qty of each product in minicart.

This is the part of qty_change.js

    ), function (ko, Component,$,customerData) { 
        'use strict';
        return Component.extend({

        initialize: function () {
            //initialize parent Component
            this.cart = customerData.get('cart');
            var self = this;
            console.log('loaded------------'+ this.productId);
         * Retrieves product data by Id.
         * @param {Number} productId - product Id
         * @returns {Object|undefined}
         * @private
        _getProductById: function (productId) {
            return _.find(customerData.get('cart')().items, function (item) {
                return productId === Number(item('product_id'));
        getQty: function(){
                this.qty = this._getProductById(this.productId)('qty');    
            }else this.qty = 0;
            return this.qty;

And this is the custom.phtml file. I call this phtml file in the foreach loop of the product collection in the list page. So this makes for each product.

getProduct ();
$ qtyIncrementBy = $ _product-> getQtyIncrementBy ();
$ stockRegistry = $ block-> getLayout () -> createBlock (& ​​# 39; Vendor  Module  Block  Catalog  Stock & # 39;);
$ defaultQty = $ stockRegistry-> getProductMinAllowedQty ($ _ product-> getId ());
<div class = "input-text qty" data-bind = "scope: & # 39; qty_change_getId ();?> & # 39; ">
<input id = "qty_getId ()?> "
name = "qty"
read only
data-bind = "value: getQty ()"
type = "number"
read only
size = "4"
style = "width: 50px; display: none;"
title = "escapeHtml (__ (& # 39; Qty & # 39;))?> "
class = "input text"

If I use this, it works fine. But in the list page, I use load more button to display more products. So, for products loaded after clicking load more button, knockoutjs does not apply.
I just did a lot of research on Google and I found this.


So i changed custom.phtml using data-mage-init.
It looks like this.

$qtyIncrementBy = $_product->getQtyIncrementBy();
$stockRegistry= $block->getLayout()->createBlock('VendorModuleBlockCatalogStock');
$defaultQty = $stockRegistry->getProductMinAllowedQty($_product->getId());

But when I ran this code, I had a problem.

knockout.js:3012 Uncaught ReferenceError: Unable to process binding "value: function(){return getQty() }"
Message: getQty is not defined
    at value (eval at createBindingsStringEvaluator (knockout.js:2624), :3:58)
    at updateFromModel (knockout.js:4517)
    at evaluateImmediate (knockout.js:1737)
    at Object.ko.computed.ko.dependentObservable (knockout.js:1946)
    at init (knockout.js:4551)
    at knockout.js:2989
    at Object.ignore (knockout.js:1249)
    at knockout.js:2988
    at Object.arrayForEach (knockout.js:151)
    at applyBindingsToNodeInternal (knockout.js:2974)

I think it's because I haven't defined scope.
But how do you dynamically define scope? As you can see, I replace each product in the list page.
So I pass different productId to qty_change.js file and show different qty according to the current added in the minicart.

Any help should really appreciate.
I've asked some developers, but haven't gotten an answer yet.

We look forward to receiving your advice soon.
Thank you.