text:
Q: How do I get rid of a 'settle blur' CSS effect I currently have a tile on which I hover is initially blurred. After the image is zoomed out, this blur sort of settles down and produces an undesired effect on the tile. Please have a look at the code I have pasted. It should give you a fair idea of what I'm talking about.
I tried messing around with the CSS after and before the image is hovered upon but that doesn't change anything.

.tiles {
    display: -moz-flex;
    display: -webkit-flex;
    display: -ms-flex;
    display: flex;
    -moz-flex-wrap: wrap;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    postiion: relative;
    margin: -2.5em 0 0 -2.5em;
}

.tiles article {
    -moz-transition: -moz-transform 0.5s ease, opacity 0.5s ease;
    -webkit-transition: -webkit-transform 0.5s ease, opacity 0.5s ease;
    -ms-transition: -ms-transform 0.5s ease, opacity 0.5s ease;
    transition: transform 0.5s ease, opacity 0.5s ease;
    position: relative;
    width: calc(33.33333% - 2.5em);
    margin: 2.5em 0 0 2.5em;
}

.tiles article > .image {
    -moz-transition: -moz-transform 0.5s ease;
    -webkit-transition: -webkit-transform 0.5s ease;
    -ms-transition: -ms-transform 0.5s ease;
    transition: transform 0.5s ease;
    position: relative;
    display: block;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
}

.tiles article > .image img {
    display: block;
    width: 100%;
}

.tiles article > .image:before {
    -moz-pointer-events: none;
    -webkit-pointer-events: none;
    -ms-pointer-events: none;
    pointer-events: none;
    -moz-transition: background-color 0.5s ease, opacity 0.5s ease;
    -webkit-transition: background-color 0.5s ease, opacity 0.5s ease;
    -ms-transition: background-color 0.5s ease, opacity 0.5s ease;
    transition: background-color 0.5s ease, opacity 0.5s ease;
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 1.0;
    z-index: 1;
    opacity: 0.8;
}

.tiles article > .image:after {
    -moz-pointer-events: none;
    -webkit-pointer-events: none;
    -ms-pointer-events: none;
    pointer-events: none;
    -moz-transition: opacity 0.5s ease;
    -webkit-transition: opacity 0.5s ease;
    -ms-transition: opacity 0.5s ease;
    transition: opacity 0.5s ease;
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    opacity: 0.25;
    z-index: 2;
}

.tiles article > a {
    display: -moz-flex;
    display: -webkit-flex;
    display: -ms-flex;
    display: flex;
    -moz-flex-direction: column;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    -moz-align-items: center;
    -webkit-align-items: center;
    -ms-align-items: center;
    align-items: center;
    -moz-justify-content: center;
    -webkit-justify-content: center;
    -ms-justify-content: center;
    justify-content: center;
    -moz-transition: background-color 0.5s ease, -moz-transform 0.5s ease;
    -webkit-transition: background-color 0.5s ease, -webkit-transform 0.5s ease;
    -ms-transition: background-color 0.5s ease, -ms-transform 0.5s ease;
    transition: background-color 0.5s ease, transform 0.5s ease;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1em;
    border-radius: 4px;
    border-bottom: 0;
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    z-index: 3;
}

    .tiles article > a > :last-child {
        margin: 0;
    }

    .tiles article > a:hover {
        color: #ffffff !important;
    }

    .tiles article > a h2 {
        margin: 0;
    }

    .tiles article > a .content {
        -moz-transition: max-height 0.5s ease, opacity 0.5s ease;
        -webkit-transition: max-height 0.5s ease, opacity 0.5s ease;
        -ms-transition: max-height 0.5s ease, opacity 0.5s ease;
        transition: max-height 0.5s ease, opacity 0.5s ease;
        width: 100%;
        max-height: 0;
        line-height: 1.5;
        margin-top: 0.35em;
        opacity: 0;
    }

        .tiles article > a .content > :last-child {
            margin-bottom: 0;
        }

body:not(.is-touch) .tiles article:hover > .image {
    -webkit-filter: blur(5px);
    -moz-transform: scale(1.1);
    -webkit-transform: scale(1.1);
    -ms-transform: scale(1.1);
    transform: scale(1.1);
}

    body:not(.is-touch) .tiles article:hover > .image:before {
        background-color: #333333;
        opacity: 0.35;
    }

    body:not(.is-touch) .tiles article:hover > .image:after {
        opacity: 0;
    }

body:not(.is-touch) .tiles article:hover .content {
    max-height: 15em;
    opacity: 1;
}

* + .tiles {
margin-top: 2em;
}

body.is-loading .tiles article {
-moz-transform: scale(0.9);
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
opacity: 0.8;
}

body.is-touch .tiles article .content {
max-height: 15em;
opacity: 1;
}

@media screen and (max-width: 1280px) {

.tiles {
    margin: -1.25em 0 0 -1.25em;
}

    .tiles article {
        width: calc(33.33333% - 1.25em);
        margin: 1.25em 0 0 1.25em;
    }

}

@media screen and (max-width: 980px) {

.tiles {
    margin: -2.5em 0 0 -2.5em;
}

    .tiles article {
        width: calc(50% - 2.5em);
        margin: 2.5em 0 0 2.5em;
    }

}

@media screen and (max-width: 736px) {

.tiles {
    margin: -1.25em 0 0 -1.25em;
}

    .tiles article {
        width: calc(50% - 1.25em);
        margin: 1.25em 0 0 1.25em;
    }

        .tiles article:hover > .image {
            -moz-transform: scale(1.0);
            -webkit-transform: scale(1.0);
            -ms-transform: scale(1.0);
            transform: scale(1.0);
        }

}

@media screen and (max-width: 480px) {

.tiles {
    margin: 0;
}

    .tiles article {
        width: 100%;
        margin: 1.25em 0 0 0;
    }

}

IrackBot

Featured on the official Slack website, IrackBot is built for for Efficient and Manageable Open Source communication across Slack and IRC

Do you notice the slight unblurring/settling down of the image after it is hovered upon and zoomed? I wish to get rid of that and keep it blurred.

A: To get the blur on Firefox just add filter: blur(5px); along with the -webkit-filter:, and blur will work of FF35+ as well.

As for the unblurring that appears there, is actually a bug which happens on Chrome (and probably every other webkit browser). This doesn't happen on Firefox though.
So to fix it you need to add: transform: translateZ(0);, this will not cause any visual differences and will take care of the problem on Chrome.

.tiles {
    display: -moz-flex;
    display: -webkit-flex;
    display: -ms-flex;
    display: flex;
    -moz-flex-wrap: wrap;
    -webkit-flex-wrap: wrap;
    -ms-flex-wrap: wrap;
    flex-wrap: wrap;
    postiion: relative;
    margin: -2.5em 0 0 -2.5em;
}

.tiles article {
    -moz-transition: -moz-transform 0.5s ease, opacity 0.5s ease;
    -webkit-transition: -webkit-transform 0.5s ease, opacity 0.5s ease;
    -ms-transition: -ms-transform 0.5s ease, opacity 0.5s ease;
    transition: transform 0.5s ease, opacity 0.5s ease;
    position: relative;
    width: calc(33.33333% - 2.5em);
    margin: 2.5em 0 0 2.5em;
}

.tiles article > .image {
    -moz-transition: -moz-transform 0.5s ease;
    -webkit-transition: -webkit-transform 0.5s ease;
    -ms-transition: -ms-transform 0.5s ease;
    transition: transform 0.5s ease;
    position: relative;
    display: block;
    width: 100%;
    border-radius: 4px;
    overflow: hidden;
}

.tiles article > .image img {
    display: block;
    width: 100%;
}

.tiles article > .image:before {
    -moz-pointer-events: none;
    -webkit-pointer-events: none;
    -ms-pointer-events: none;
    pointer-events: none;
    -moz-transition: background-color 0.5s ease, opacity 0.5s ease;
    -webkit-transition: background-color 0.5s ease, opacity 0.5s ease;
    -ms-transition: background-color 0.5s ease, opacity 0.5s ease;
    transition: background-color 0.5s ease, opacity 0.5s ease;
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 1.0;
    z-index: 1;
    opacity: 0.8;
}

.tiles article > .image:after {
    -moz-pointer-events: none;
    -webkit-pointer-events: none;
    -ms-pointer-events: none;
    pointer-events: none;
    -moz-transition: opacity 0.5s ease;
    -webkit-transition: opacity 0.5s ease;
    -ms-transition: opacity 0.5s ease;
    transition: opacity 0.5s ease;
    content: '';
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100% 100%;
    opacity: 0.25;
    z-index: 2;
}

.tiles article > a {
    display: -moz-flex;
    display: -webkit-flex;
    display: -ms-flex;
    display: flex;
    -moz-flex-direction: column;
    -webkit-flex-direction: column;
    -ms-flex-direction: column;
    flex-direction: column;
    -moz-align-items: center;
    -webkit-align-items: center;
    -ms-align-items: center;
    align-items: center;
    -moz-justify-content: center;
    -webkit-justify-content: center;
    -ms-justify-content: center;
    justify-content: center;
    -moz-transition: background-color 0.5s ease, -moz-transform 0.5s ease;
    -webkit-transition: background-color 0.5s ease, -webkit-transform 0.5s ease;
    -ms-transition: background-color 0.5s ease, -ms-transform 0.5s ease;
    transition: background-color 0.5s ease, transform 0.5s ease;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1em;
    border-radius: 4px;
    border-bottom: 0;
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    z-index: 3;
}

    .tiles article > a > :last-child {
        margin: 0;
    }

    .tiles article > a:hover {
        color: #ffffff !important;
    }

    .tiles article > a h2 {
        margin: 0;
    }

    .tiles article > a .content {
        -moz-transition: max-height 0.5s ease, opacity 0.5s ease;
        -webkit-transition: max-height 0.5s ease, opacity 0.5s ease;
        -ms-transition: max-height 0.5s ease, opacity 0.5s ease;
        transition: max-height 0.5s ease, opacity 0.5s ease;
        width: 100%;
        max-height: 0;
        line-height: 1.5;
        margin-top: 0.35em;
        opacity: 0;
    }

        .tiles article > a .content > :last-child {
            margin-bottom: 0;
        }

body:not(.is-touch) .tiles article:hover > .image {
    -webkit-filter: blur(5px);
    filter: blur(5px); /* firefox 35+ */
    -moz-transform: scale(1.1);
    -webkit-transform: translateZ(0) scale(1.1); /* Chrome fix - add translateZ */
    -ms-transform: scale(1.1);
    transform: translateZ(0) scale(1.1); /* Here as well */
}

    body:not(.is-touch) .tiles article:hover > .image:before {
        background-color: #333333;
        opacity: 0.35;
    }

    body:not(.is-touch) .tiles article:hover > .image:after {
        opacity: 0;
    }

body:not(.is-touch) .tiles article:hover .content {
    max-height: 15em;
    opacity: 1;
}

* + .tiles {
margin-top: 2em;
}

body.is-loading .tiles article {
-moz-transform: scale(0.9);
-webkit-transform: scale(0.9);
-ms-transform: scale(0.9);
transform: scale(0.9);
opacity: 0.8;
}

body.is-touch .tiles article .content {
max-height: 15em;
opacity: 1;
}

@media screen and (max-width: 1280px) {

.tiles {
    margin: -1.25em 0 0 -1.25em;
}

    .tiles article {
        width: calc(33.33333% - 1.25em);
        margin: 1.25em 0 0 1.25em;
    }

}

@media screen and (max-width: 980px) {

.tiles {
    margin: -2.5em 0 0 -2.5em;
}

    .tiles article {
        width: calc(50% - 2.5em);
        margin: 2.5em 0 0 2.5em;
    }

}

@media screen and (max-width: 736px) {

.tiles {
    margin: -1.25em 0 0 -1.25em;
}

    .tiles article {
        width: calc(50% - 1.25em);
        margin: 1.25em 0 0 1.25em;
    }

        .tiles article:hover > .image {
            -moz-transform: scale(1.0);
            -webkit-transform: scale(1.0);
            -ms-transform: scale(1.0);
            transform: scale(1.0);
        }

}

@media screen and (max-width: 480px) {

.tiles {
    margin: 0;
}

    .tiles article {
        width: 100%;
        margin: 1.25em 0 0 0;
    }

}

IrackBot

Featured on the official Slack website, IrackBot is built for for Efficient and Manageable Open Source communication across Slack and IRC


text:
Q: jQuery UI 1.11.1 - dynamic dialog positioning not working With jQuery UI 1.10.4 its working fine, but with jQuery UI 1.11.1 it´s not working.
Dialog positioning with jQuery UI:
http://jsfiddle.net/avpbsnx3/
# working with 1.10.4

$(document).on('click', '.recenter', function () {
    $('#myDialog').dialog("option", "position", { my: 'center', at: 'center' });
});

http://jsfiddle.net/6kkn9oqj/
# not working with 1.11.1

$(document).on('click', '.recenter', function () {
    $('#myDialog').dialog("option", "position", { my: 'center', at: 'center' });
});

Is this a bug in the new version, or am I using it wrong?
Edit:
$(document).on('click', '.recenter', function () {
    $('#myDialog').dialog("option", "position", { my: 'center', at: 'center', of: window });
});

It seems that there is a default-reference problem. Its working fine with the code above.

A: It appears that some "unofficial" values for position that used to work now no longer work.  There are lots of examples on the net of using position: "center", for example, and this works on 1.10.4 (whether it works because it actually works or is being ignored and using the default).  The documentation states that the default is position: { my: "center", at: "center", of: window }.  It seems that specifying "center" or an incomplete definition now defaults to top left positioning when used during creation of the dialog, or is ignored when attempting to reposition.
http://api.jqueryui.com/dialog/#option-position

redpajama_set_name: RedPajamaStackExchange


text:
Q: How to open save dialog box for saving pdf I truly appreciate your suggestions. I am using MVC3 and I want user to save to his own path by opening a dialog with password protected. Can you guys please help me on this.
Below is my code:
mydoc.GenerateLetter(PdfData);

string WorkingFolder = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

using (MemoryStream m = new MemoryStream())
{
   m.Write(mydoc.DocumentBytes, 0, mydoc.DocumentBytes.Length);
   m.Seek(0, SeekOrigin.Begin);
   string OutputFile = Path.Combine(WorkingFolder, PdfData.Name + ".pdf");

   using (Stream output = new FileStream(OutputFile, FileMode.Create, FileAccess.Write, FileShare.None))
   {
      PdfReader reader = new PdfReader(m);
      PdfEncryptor.Encrypt(reader, output, true, "abc123", "secret", PdfWriter.ALLOW_SCREENREADERS);
   }
}

A: If you want to show a Save As dialog so that the user can choose the location to save the PDF file on his computer you could use the Content-Disposition HTTP header and set it to attachment. Also in an ASP.NET MVC application instead of saving the file to the server (which is what your code currently does), you should stream it to the client:
public ActionResult DownloadPdf()
{
    var mydoc = ...
    mydoc.GenerateLetter(PdfData);
    byte[] pdf = mydoc.DocumentBytes;
    var reader = new PdfReader(pdf);
    using (var encrypted = new MemoryStream())
    {
        PdfEncryptor.Encrypt(reader, encrypted, true, "abc123", "secret", PdfWriter.ALLOW_SCREENREADERS);
        return File(encrypted.ToArray(), "application/pdf", PdfData.Name + ".pdf");
    }
}

Now when a user navigates to this controller action /SomeController/DownloadPdf he will be presented with a Save As dialog allowing him to download the encrypted PDF file and store it in a chosen location on his computer.


text:
Q: Javascript inheritance and method with same name I have a basic question on prototype. I need to call a method of diferent object.
The 2 objects have the same named methods:
QuadForm.setdml()
QuadTable.setdml()
the question is how can i call setdml() of QuadTable on an instance of QuadForm.
when i do
window[o].wherePk = QuadTable.prototype.setDML(dataCopy, false, true);

then inside the method
var whereQ = obj.where_str;
obj.where_str = whereQ.replace(" AND ", "");

obj is not a quadForm type.
The methods have the same name...i am confused.
Thanks

A: Solved
**window[o]['setDMLFromTable']=QuadTable.prototype.setDML;**
  window[o].wherePk=window[o].setDMLFromTable(dataCopy, false, true);


text:
Q: Does the mean of an iid random sample lie between minima/maxima almost surely or with large probability for large enough sample size? Let  $n \in \mathbb{N},$ and $\{ X_1 \dots X_n\}$ be iid random variables, each following the distribution of $X.$ For each $n$, consider the minima and maxima of $X_i$'s, i.e. $m_n:= min_{1 \le i \le n}X_i, M_n:=max_{1 \le i \le n}X_i.$ Note that $m_n, M_n$ are random variables for each fixed $n.$
My question is: can we say, if $\mathbb{E}[X]$ exists, then there exists an $N \in \mathbb{N}, $ so that $ \forall n \ge N:$
$$ m_n \le \mathbb{E}[X] \le M_n  \hspace{2mm}a.s. ?$$
This is rather intuitive, but a proof of it, if true, would be nice to have. If it's not true, then can we say that it's true for a large enough subset, i.e. $\forall \epsilon > 0, $ there exists $N \in \mathbb{N}, $ so that $ \forall n \ge N:$
$$P[ m_n \le \mathbb{E}[X] \le M_n] > 1 - \epsilon ?$$
$$$$

A: The answer is NO for the first question and YES for the second.
Let $(X_i)$ be i.i.d. $N(0,1)$. Then $P(M_n <EX)=P(M_n <0)>0$ for each $n$ since $X_i<0$ for $1 \leq i \leq n$ with probability $\frac  1{2^{n}}$.
Note that $P(X_1 <EX) <1$. Hence $P(M_n <EX)= [P(X_1 <EX)]^{n} \to 0$. This gives $P(EX \leq M_n) \to 1$. Similarly $P(m_n\leq EX) \to 1$. Hence  the assertion in your second part is true.


text:
Q: how to match a string in whole array element I have a array in javascript
var arr = ["12","22","33","42"];

*

*If I search for 1 it should not match because it is not a complete array element.

*If I search for 12 it should match because it is a complete array
element.

I have searched web for this but found
var match = arr.indexOf('1');

But this does not solve my problem
Anybody can help?

A: So indexOf returns the position the element you are searching for is at. If no element is found, it returns -1. This is the way you can check it.
var arr = ["12","22","33","42"];
var match = arr.indexOf("12");
if(match > -1) {
    // Found match, at position "match"
    var element = arr[match]; // = "12"
} else {
    // Element not in array
}

A: Try This:
var a = ["12","22","33","42"];
if(a.indexOf('12')!= '-1')
{
    alert("success")
}
else
{
    alert("failure")
}

A: please refer this, I think this will help you,
The $.inArray() method is similar to JavaScript's native .indexOf() method in that it returns -1when it doesn't find a match. If the first element within the array matches value, $.inArray() returns 0.  so try this. $.inArray(1,arr) > -1


text:
Q: add product search field in woo-commerce product page right now i am using  below code
// Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fields' );
 function woo_add_custom_general_fields() {

  global $woocommerce, $post;

  echo '
';

  // Custom fields will be created here...

// Product Select
?>

<?php _e( 'Product Select', 'woocommerce' ); ?>
<select style="width:100%" id="product_field_type" name="product_field_type[]" class="ajax_chosen_select_products" multiple="multiple" data-placeholder="<?php _e( 'Search for a product…', 'woocommerce' ); ?>">
    <?php
        $product_field_type_ids = get_post_meta( $post->ID, '_product_field_type_ids', true );
        $product_ids = ! empty( $product_field_type_ids ) ? array_map( 'absint',  $product_field_type_ids ) : null;
        if ( $product_ids ) {
            foreach ( $product_ids as $product_id ) {

                $product      = get_product( $product_id );
                $product_name = woocommerce_get_formatted_product_name( $product );

                echo '<option value="' . esc_attr( $product_id ) . '" selected="selected">' . esc_html( $product_name ) . '</option>';
            }
        }
    ?>
</select> <img class="help_tip" data-tip='<?php _e( 'Your description here', 'woocommerce' ) ?>' src="<?php echo $woocommerce->plugin_url(); ?>/assets/images/help.png" height="16" width="16" />

<?php

  echo '
';

}

which shows below product field but not working properly

but i wants product search like  below pic

I am using below website for code
http://www.remicorson.com/mastering-woocommerce-products-custom-fields/

A: I was trying to figure out the same problem for a client of mine recently. I had originally used that same tutorial to add a custom product search input field for him on the back end and it broke when we got him updated to WooCommerce 2.5+.
To add the product search widget/field to the backend:
?>

    <?php _e( 'Component Products:', 'woocommerce' ); ?>

        <input type="hidden" class="wc-product-search" style="width: 50%;" id="product_field_type_ids" name="product_field_type_ids" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products" data-multiple="true" data-exclude="<?php echo intval( $post->ID ); ?>" data-selected="<?php
                        $product_ids = array_filter( array_map( 'absint', (array) get_post_meta( $post->ID, '_product_field_type_ids', true ) ) );
                        $json_ids    = array();

                        foreach ( $product_ids as $product_id ) {
                            $product = wc_get_product( $product_id );
                            if ( is_object( $product ) ) {
                                $json_ids[ $product_id ] = wp_kses_post( html_entity_decode( $product->get_formatted_name(), ENT_QUOTES, get_bloginfo( 'charset' ) ) );
                            }
                        }

                        echo esc_attr( json_encode( $json_ids ) );
                    ?>" value="<?php echo implode( ',', array_keys( $json_ids ) ); ?>" /> <?php echo wc_help_tip( __( 'Select component parts to display on the product page.', 'woocommerce' ) ); ?>

    <?php

To Save: (saved in the same id int array format as the existing field so  you don't have to start from scratch with your existing database entries)
$my_product_ids    = isset( $_POST['product_field_type_ids'] ) ? array_filter( array_map( 'intval', explode( ',', $_POST['product_field_type_ids'] ) ) ) : array();
    update_post_meta( $post_id, '_product_field_type_ids', $my_product_ids  );

To display on the front end: (same as before)
global $post;
$items = get_post_meta($post->ID, '_product_field_type_ids', true);
if (! empty($items)) {
        foreach ( $items as $product_id ) {
            echo '
'.get_the_title($product_id).'
';
        }
    }

A: I copied this code from up-sells. This is only the search form.

        <?php _e( 'Up-sells', 'woocommerce' ); ?>
        <select class="wc-product-search" multiple="multiple" style="width: 50%;" id="upsell_ids" name="upsell_ids[]" data-placeholder="<?php esc_attr_e( 'Search for a product…', 'woocommerce' ); ?>" data-action="woocommerce_json_search_products_and_variations" data-exclude="<?php echo intval( $post->ID ); ?>">
            <?php
            $product_object = new WC_Product($post->ID);
            $product_ids = $product_object->get_upsell_ids( 'edit' );

            foreach ( $product_ids as $product_id ) {
                $product = wc_get_product( $product_id );
                if ( is_object( $product ) ) {
                    echo '<option value="' . esc_attr( $product_id ) . '"' . selected( true, true, false ) . '>' . wp_kses_post( $product->get_formatted_name() ) . '</option>';
                }
            }
            ?>
        </select> <?php echo wc_help_tip( __( 'Up-sells are products which you recommend instead of the currently viewed product, for example, products that are more profitable or better quality or more expensive.', 'woocommerce' ) ); ?>

A: This answer is a great starting point but there are some changes required to make this work with the latest WooCommerce releases where the product search field has changed from a input with type=hidden to a select with a multiple attribute.
Backend input field
You can use the backend HTML of the WooCommerce upsells field, which you can find here on GitHub, as a template for your own backend field.
Saving the backend input field
You can use the following code to retrieve the selected items and save there ids as post meta.
$my_product_ids = isset($_POST['product_field_type_ids']) ? array_map('intval', explode(',', (array) $_POST['product_field_type_ids'])) : array();
update_post_meta($post_id, '_product_field_type_ids', $my_product_ids);

A: A more general solution (not only on product page but also on all other pages) is described here: https://www.binarycarpenter.com/create-woocommerce-products-search-input-for-your-plugins/
and the code is here:
https://github.com/datmt/WooCommerce-Ajax-Product-Search
Minimum working example based on the above mentioned code:
1.Append the jquerys select2 script and your own my_product_search_script.js like this. Put this next to your function:
class BC_AJAX_Product_Search {
    public function __construct() {
        add_action('admin_enqueue_scripts', array($this, 'enqueue_admin'));
    }
    public function enqueue_admin() {
        wp_register_style('my-plugin-select2-style', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.10/css/select2.min.css');
        wp_enqueue_style('my-plugin-select2-style');
        wp_register_script('my-plugin-select2-script', 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.10/js/select2.min.js', array('jquery'));
        wp_register_script('my-plugin-script', plugins_url('my_product_search_script.js', __FILE__), array('jquery'));
        wp_enqueue_script('my-plugin-select2-script');
        wp_enqueue_script('my-plugin-script');
    }
}
new BC_AJAX_Product_Search();

2.Add your own js file called my_product_search_script.js next to the php file you are working in with this code:
(function ($) {
    $(function(){
        $('.bc-product-search').select2({
            ajax: {
                url: ajaxurl,
                data: function (params) {
                    return {
                        term         : params.term,
                        action       : 'woocommerce_json_search_products_and_variations',
                        security: $(this).attr('data-security'),
                    };
                },
                processResults: function( data ) {
                    var terms = [];
                    if ( data ) {
                        $.each( data, function( id, text ) {
                            terms.push( { id: id, text: text } );
                        });
                    }
                    return {
                        results: terms
                    };
                },
                cache: true
            }
        });
    });
})(jQuery)

3.Finally, you can use in your php function this code which creates the products search select fields:
<select data-security="<?php echo wp_create_nonce( 'search-products' ); ?>" multiple style="width: 300px;" class="bc-product-search"></select>

3.1including presetting the field, and retrieving the value after form submition the select can be included in your php function like this:
// use the selected product here
if (isset($_POST["my_product_search"])) {
    $product_id = $_POST["my_product_search"];
    // TODO: do somthing with the product
}
?>
<form name='my_product_search_form' id='my_product_search_form' method='post' action='' class='my_product_search_form'>

        Produkt:

        <select id="my_product_search" name="my_product_search" data-security="<?php echo wp_create_nonce( 'search-products' ); ?>" style="width: 300px;" class="bc-product-search"></select>

    <input type='submit' class='button' name='save_products' value='Save' />

</form>

<?php

A: You are using woocommerce plugin. To filter the products with price range, color, size and other fields you can use another woocommerce plugin 'woocommerce products filter'. You can user yith plugin to search the products. If you want to provide a search works for whole site not only for products only user dave's live search plugin.
Dave's live search plugin
Yith products search plugin


text:
Q: Add data to Django form class using modelformset_factory I have a problem where I need to display a lot of forms for detail data for a hierarchical data set.  I want to display some relational fields as labels for the forms and I'm struggling with a way to do this in a more robust way.  Here is the code...
class Category(models.Model):
  name = models.CharField(max_length=160)

class Item(models.Model):
  category = models.ForeignKey('Category')
  name = models.CharField(max_length=160)
  weight = models.IntegerField(default=0)

  class Meta:
    ordering = ('category','weight','name')

class BudgetValue(models.Model):
  value = models.IntegerField()
  plan = models.ForeignKey('Plan')
  item = models.ForeignKey('Item')

I use the modelformset_factory to create a formset of budgetvalue forms for a particular plan. What I'd like is item name and category name for each BudgetValue. When I iterate through the forms each one will be labeled properly.
class BudgetValueForm(forms.ModelForm):
item = forms.ModelChoiceField(queryset=Item.objects.all(),widget=forms.HiddenInput())
plan = forms.ModelChoiceField(queryset=Plan.objects.all(),widget=forms.HiddenInput())

category = "" < assign dynamically on form creation >
item = "" < assign dynamically on form creation >
class Meta:
    model = BudgetValue
    fields = ('item','plan','value')

What I started out with is just creating a dictionary of budgetvalue.item.category.name, budgetvalue.item.name, and the form for each budget value.  This gets passed to the template and I render it as I intended.   I'm assuming that the ordering of the forms in the formset and the querset used to genererate the formset keep the budgetvalues in the same order and the dictionary is created correctly.  That is the budgetvalue.item.name is associated with the correct form.   This scares me and I'm thinking there has to be a better way.  Any help would be greatly appreciated.

A: Well, I figured out the answer to my own question.   I've overridden the init class on the form and accessed the instance of the model form.  Works exactly as I wanted and it was easy.
class BudgetValueForm(forms.ModelForm):
  item = forms.ModelChoiceField(queryset=Item.objects.all(),widget=forms.HiddenInput())
  plan = forms.ModelChoiceField(queryset=Plan.objects.all(),widget=forms.HiddenInput())

  def __init__(self, *args, **kwargs):
    super(BudgetValueForm, self).__init__(*args, **kwargs)
    self.itemname = self.instance.item.name
    self.categoryname = self.instance.item.category.name

  class Meta:
    model = BudgetValue
    fields = ('item','plan','value')


text:
Q: Passing a template function as a parameter in C++ I have a generic list container that has a function find defined as follows:
template <class T>
typename List<T>::Iterator List<T>:: find(void * f, T data) {
    Iterator iterator;
    for (iterator = begin() ; iterator != end() ; iterator++) {
        if (f(*iterator, data)) {
            break;
        }
    }
    return iterator;
}

So it takes a function f and an instance of type T and then iterates over the nodes in a list whose nodes 'contain' an instance of type T until one of them causes f(*iterator,data) to evaluate to true.
The dereference operator for iterator returns the data in the node so the types for iterator and data will be the same.
I'm trying to pass a function that would check if an object is in the list:
template <class T>
bool findByUnique(T compare, T data) {
    if (compare == data) {
        return true;
    }
    else {
        return false;
    }
}

I'm trying to pass the function as follows, but get the errors:
store.cpp:28:14: error: cannot resolve overloaded function âfindByUniqueâ based on conversion to type âvoid*â
store.cpp:29:56: error: expected primary-expression before â>â token
store.cpp:29:60: error: left operand of comma operator has no effect [-Werror=unused-value]

lines 27-29 (passing the function):
Album album(barcode,price,year,numPurchased,title,artist);
void * f = &findByUnique<Album>;
List<Album>::Iterator found = this->Albums->find<Album>(f,album);

What am I doing wrong here?
Searching on google indicates I have to apply static_cast to findByUnique but I'm not sure how it applies here.
Thanks.

A: @Taylor Flores is right. You aren't declaring your function pointer correctly in the declaration of find or for variable f. See (for example):
http://www.cprogramming.com/tutorial/function-pointers.html


text:
Q: How to remove class of element has not img tag using jquery? I want to remove the class description when no  tag is found in all the divs with .box1:

Preis pro Person, nur Mehrbettzimmerbelegung. Sie teilen sich Hotelzimmer im Großraum Reykjavik und 2-4-Bett-Zimmer mit bezogenen Betten während der Tour.

....

I tried this, but that is not working:
$(".accomodation-radio").find(".box1 img").each( function(){
    if ($(this).length === 0){
        $(this).find("div").removeClass(".description");
    }
});

A: You can use combination of :not() and :has() selector
$(".accomodation-radio .box1:not(:has(img)) div").removeClass("description")

$(".accomodation-radio .box1:not(:has(img)) div").removeClass("description")
.box1 .description{color:green}

Preis pro Person, nur Mehrbettzimmerbelegung. Sie teilen sich Hotelzimmer im Großraum Reykjavik und 2-4-Bett-Zimmer mit bezogenen Betten während der Tour.

A: Your .each() is trying to run on elemnts that don't exist - you need to pass the .find inside the loop like this:
$(".accomodation-radio").each(function() {
    if ($(this).find(".box1 img").length === 0)
    {
        $(this).find("div").removeClass("description");
    }
});

A: Try this :
$(document).ready(function(){

    $(".accomodation-radio .box1").each(function(){

        if($(this).find("img").length === 0)

            $(this).find(".description").removeClass("description");

    })

})


text:
Q: FormView::getName() support in symfony2.3 Ive been asked to upgrade an application to 2.3 (part of a multistage upgrade) from 2.1 and Im having a problem where FormView::getName() is called
error
Fatal error: Call to undefined method Symfony\Component\Form\FormView::getName() in ...

code calling the method
public function helper( $form )
{
    $tooltip = $this->help_service->getTooltip( $form->getName() )
}

Ive searched [documentation] and indeed its not there so its obviously deprecated.  I cannot find any documentation on an alternative.1
Can anyone help please?
update
it looks like lots gone from Symfony\Component\Form\FormView, including getVars() which is in use in the application as well.   Ive searched for some support documents but havent come up with anything.

A: I´m not sure but maybe you mean this: ?
if you use a FormType to create a Form like:
 $form = $this->createForm('company',$company);

and your formType implements a getName() function
class CompanyType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder
            ->add('name', 'text')
            ->add('description', 'textarea')
            ->add('adresses','collection', array('type' => 'adress','allow_add' => true, 'by_reference' => false,'allow_delete'=>true) )
            ->add('save', 'submit');
    }

    public function setDefaultOptions(OptionsResolverInterface $resolver)
    {
        $resolver->setDefaults(array(
            'data_class' => 'Foo\CoreBundle\Entity\Company',
        ));
    }

    public function getName()
    {
        return 'company';
    }
}

so this way
 $form->getName()

will return company


text:
Q: Power Query File Count function I am trying to come up with a small function that will update my main query.  There is one line in my code that is currently static, and I would like it to update as I add files to my folder.  The number is based off the files in the folder, 1 - "Files in the Folder".  Currently there are 14 files in my folder, so the line looks like so:
= Table.RenameColumns(#"Added LAST_FIRST_MID NAME",{{"1", "Report Count"}, {"-13", "Index"}})
So, the bold number needs to be a function of 1 - Count(Files in Folder).  The problem lies in the fact that I have no idea how to create a function from scratch. I tried creating a file with the following code and creating a function from that table.
let
    Source = Folder.Files("P:\CREDIT DEPT\Credit Bureau - Analysis\BOSP CC DataFiles"),
    #"Added Index" = Table.AddIndexColumn(Source, "Index", 0, -1)
in
    #"Added Index"

This is my first attempt at trying to create a function, I think that I'm on the right path, but I'm not sure where to go from here.  Thanks in advance for your help.

A: If you are trying to count number of files and then use that variable, try below
Use Home...Advanced Editor... to paste in the first row above where you intend to reference the result
FileCount = Text.From(1 - Table.RowCount(Folder.Files("P:\CREDIT DEPT\Credit Bureau - Analysis\BOSP CC DataFiles"))),
#"Rename" = Table.RenameColumns(#"Added LAST_FIRST_MID NAME",{{"1", "Report Count"}, {FileCount, "Index"}})


text:
Q: value doesn't match format of datetime python I'm trying to convert a series in datetime in python, however it is giving me this error

ValueError: time data '5/8/2018' does not match format '%d, %m, %Y' (match)

The code I'm using is
date = pd.to_datetime(df.created_at, format='%d, %m, %Y').dt.date

A: Hard to say exactly without your data, but try this
date = pd.to_datetime(df.created_at, format='%d/%m/%Y').dt.date

You're format has date as 5/8/2018 instead of 5, 8, 2018. For reference, I used this code to test.
df = pd.DataFrame(columns = ['created_at'])
df = df.append({'created_at':'5/8/2018'}, ignore_index = True)
date = pd.to_datetime(df.created_at, format='%d/%m/%Y').dt.date


text:
Q: How to set desktop background color for all users for domain Windows machines? I have some Windows Server machines joined to a Active Directory domain. How can I set the desktop background color for all users on selected machines, so that the background color reminds them that this is a production server?

A: The desktop background color may be set by forcing Registry values in GPO.

*

*Create new OU and put computer objects in it.

*Associate a new GPO to the OU.

*Under Computer Configuration / Policies / Administrative Templates / System / Group Policy, set User Group Policy loopback processing mode to Enabled and set Mode to Replace. This will cause the GPO to override any user-specific GPO settings.

*Set Turn off Local Group Policy objects to Enabled. This will enforce the domain-based GPO.

*In HKCU/Control Panel/Colors, set Background to the RGB background color.

*In HKCU/Control Panel/Desktop, set Wallpaper to empty string.

Run gpupdate /force, then logout and login to see the effect.


text:
Q: Sub-light speeds and momentum conservation law Let's imagine a boat on a lake. Observer A is sitting on the shore. Observer B is sitting in the boat on the bow. Observer B has a ball attached to the end of a string which he holds in his hand.
Observer A sees that the boat is not moving. Boat B has some mass. So does the ball. Let's ignore water/air friction.
Then observer B slowly moves towards stern. The boat moves appropriately in the opposite direction, as A can see. Then observer B stops, so does the boat.
Finally, the observer B goes back to the bow. Because of the law of conservation of momentum, in the end observer A sees the situation exactly as it was in the beginning.
Now let's repeat the situation, but before Observer B is coming back from the stern to the bow he starts spinning the ball on the string with sub-light speed.
Because of the speed, according to the special relativity, both observers should observe increased mass of the ball.
For observer A on the shore it would be like the observer in the boat carries a lightweight ball in one direction and then a heavy ball in the other direction.
In result, he would observe that the boat moved as compared to the initial position. This in turn would violate the momentum conservation law, so I conclude it is not going to happen.
Why? Isn't the increased mass of the spinning ball be perceived by observer A and B?

A: The extra mass-energy that goes into the spinning ball has to come from somewhere. If it comes from observer B, then his mass decreases by the same amount that the mass of the ball+string increased.
Incidentally, observer A seems irrelevant here. Lorentz invariance means that you can pick a single reference frame and use that. You don't need more than one unless it somehow makes solving the problem simpler, or you're trying to show an inconsistency in special relativity by showing a difference between the frames, but there doesn't seem to be a difference here. The (time-averaged) mass of the ball increases in both frames, as you said.


text:
Q: Are private channel states or blocks added to the main ledger? I'm trying to understand how data is stored for private channels on Hyperledger fabric. I've read some of the documentation and watched a couple of videos but, I think either data is on the main ledger or it isn't and it kind of  defeats the purpose of ledgers. I've two questions
If a private channel's state changes, is that state change stored in the main ledger's blocks?
If they aren't, is consensus still a thing for channels with few users?

A: I don't know what do you refer with "main ledger".
There is one ledger per channel. Each ledger consist on a blockchain and a world state. The blockchain stores all the transactions of the channel organized in blocks. The world state is stored in a DB (SQLite or CouchDB). The world state is the state of the channel resulting from valid chaincode transactions in the blockchain. All peers joined to a channel keep the same ledger for that channel.
The ordering service maintain its own blockchain related to network configuration (ordering service, organizations, etc.). Orderers also keep a copy of every ledger's blockchain (only the blockchain, not the state).

A: The private data is stored only in the private data collections of the peers that have access to those private data collections, and is replicated directly between those peers so is not visible to anyone else. A hash of the private data is stored in the main ledger (channel state) as part of the transaction that updated the private data. See here for details:
https://hyperledger-fabric.readthedocs.io/en/release-2.2/private-data/private-data.html


text:
Q: Global variable not being referenced for inner scope declaration in Python Python is declaring a variable that is already in the global scope. The code below creates an exception: "local variable 'OLDTOTALNUMPASSED' referenced before assignment"
#THIS CREATES AN EXCEPTION
class Main():
    global OLDTOTALNUMPASSED
    global OLDTOTALNUMFAILED
    global OLDRUNNINGCONSECUTIVEFAILURES
    OLDTOTALNUMPASSED = 0
    OLDTOTALNUMFAILED = 0
    OLDRUNNINGCONSECUTIVEFAILURES = 0

    def foo_bar():
        if(not(OLDTOTALNUMPASSED == 0 and OLDTOTALNUMFAILED == 0 and OLDRUNNINGCONSECUTIVEFAILURES == 0)):
            **OLDTOTALNUMPASSED** = myHMI.total_num_passed
            **OLDTOTALNUMFAILED** = myHMI.total_num_failed
            **OLDRUNNINGCONSECUTIVEFAILURES** = myHMI.running_consecutive_failures

But if I take the references out of the conditional body, it passes. Obviously python looks ahead and declares a new variable even though there is already a global variable.
#THIS PASSES
class Main():
    global OLDTOTALNUMPASSED
    global OLDTOTALNUMFAILED
    global OLDRUNNINGCONSECUTIVEFAILURES
    OLDTOTALNUMPASSED = 0
    OLDTOTALNUMFAILED = 0
    OLDRUNNINGCONSECUTIVEFAILURES = 0

    def foo_bar():
        if(not(OLDTOTALNUMPASSED == 0 and OLDTOTALNUMFAILED == 0 and OLDRUNNINGCONSECUTIVEFAILURES == 0)):
            **a** = myHMI.total_num_passed
            **b** = myHMI.total_num_failed
            **c** = myHMI.running_consecutive_failures

I have three questions:
A: Is it Python or is it the Interpreter that looks ahead into the conditional body before the conditional statement.
B: Why does Python declare a new variable when that variable is already in the global scope
C: How do I get python to refer to the global variable. I can't use self. because

A: Turns out, the variable Needs to be global in both the foo_bar() as well as the class. If it is not global in either the class or the function it does not work.
#THIS PASSES
class Main():
global OLDTOTALNUMPASSED
global OLDTOTALNUMFAILED
global OLDRUNNINGCONSECUTIVEFAILURES
OLDTOTALNUMPASSED = 0
OLDTOTALNUMFAILED = 0
OLDRUNNINGCONSECUTIVEFAILURES = 0

def foo_bar():
    global OLDTOTALNUMPASSEDLNUMPASSED
    global OLDTOTALNUMPASSEDLNUMFAILED
    global OLDRUNNINGCONSECUTIVEFAILURES
    if(not(OLDTOTALNUMPASSED == 0 and OLDTOTALNUMFAILED == 0 and OLDRUNNINGCONSECUTIVEFAILURES == 0)):
        OLDTOTALNUMPASSED = myHMI.total_num_passed
        OLDTOTALNUMFAILED = myHMI.total_num_failed
        OLDRUNNINGCONSECUTIVEFAILURES = myHMI.running_consecutive_failures

A: Actually, the best answer to this problem may be to use self.
You can pass the class itself as a parameter to the function and call self.variable
#THIS PASSES
class Main():
OLDTOTALNUMPASSED = 0
OLDTOTALNUMFAILED = 0
OLDRUNNINGCONSECUTIVEFAILURES = 0

def foo_bar(self):
    if(not(self.OLDTOTALNUMPASSED == 0 and self.OLDTOTALNUMFAILED == 0 and self.OLDRUNNINGCONSECUTIVEFAILURES == 0)):
        self.OLDTOTALNUMPASSED = myHMI.total_num_passed
        self.OLDTOTALNUMFAILED = myHMI.total_num_failed
        self.OLDRUNNINGCONSECUTIVEFAILURES = myHMI.running_consecutive_failures

Main.foo_bar(Main)


text:
Q: UWP RfComm - StreamSocketListener.BindServiceNameAsync throws exception I am trying to create a UWP app that listens for Bluetooth serial port connections. When I set up the listener in the application (via a button click) I get an exception at the line:
await socketListener.BindServiceNameAsync(
      rfcommProvider.ServiceId.ToString(),
      SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);`

The exception message is:
System.ArgumentException: 'The parameter is incorrect.
'protectionLevel': Only plain sockets are allowed for IP StreamSocketListeners.'
Here is the code:
private async void btnBluetoothServerClick(object sender, RoutedEventArgs e)
{
   var rfcommProvider =
   await RfcommServiceProvider.CreateAsync(RfcommServiceId.SerialPort);

   var socketListener = new StreamSocketListener();

   socketListener.ConnectionReceived += OnConnectionReceived;

   await socketListener.BindServiceNameAsync(
      rfcommProvider.ServiceId.ToString(),
      SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication);

   rfcommProvider.StartAdvertising(socketListener);
}

When the protectionLevel parameter SocketProtectionLevel.BluetoothEncryptionAllowNullAuthentication, is changed to, SocketProtectionLevel.PlainSocketas the exception indicates, the new exception message is: System.Exception: 'The specified class was not found. (Exception from HRESULT: 0x8007277D)'.
The application manifest file includes:
<Capabilities>
   <Capability Name="internetClient" />
   <DeviceCapability Name="bluetooth" />
   <DeviceCapability Name="proximity" />
   <DeviceCapability Name="serialcommunication">
     <Device Id="any">
        <Function Type="name:serialPort" />
     </Device>
   </DeviceCapability>
   <DeviceCapability Name="bluetooth.rfcomm">
      <Device Id="any">
         <Function Type="name:serialPort" />
      </Device>
   </DeviceCapability>
   <DeviceCapability Name="wifiControl" />
</Capabilities>

It seems that this code should work according to the documentation at:
https://learn.microsoft.com/en-us/uwp/api/windows.networking.sockets.streamsocketlistener#Windows_Networking_Sockets_StreamSocketListener_BindServiceNameAsync_System_String_Windows_Networking_Sockets_SocketProtectionLevel_Windows_Networking_Connectivity_NetworkAdapter_
What am I doing wrong?

A: Just change parameter of the BindServiceNameAsync method,
rfcommProvider.ServiceId.ToString()

to
rfcommProvider.ServiceId.AsString()

then your code snippet will work.
The AsString() method of RfcommServiceId will convert the RfcommServiceId to a string.ToString will return the type which is not the correct parameter for BindServiceNameAsync.
More details please reference the official sample.


text:
Q: VueJS: filter select lists I have a VueJS application. I have two lists: A, B

*

*A contains all elements

*B contains some elements from A

I have <select> tags. Each select tag must hold the value of a B element, and should have the option to select other values of A which are not contained in B.
Question: how can I properly filter the elements of A which don't exist in B, with exception for the element the tag has selected at that point? A generic solution is to iterate over each element and unset the undesired ones from lists. The problem is Vue has reactive properties, which means when I change the list for a custom select, change is propagated to other selects as well.
I've wrapped my head for over an hour. I believe I'm building scenarios for a simple question which has a simple solution, but I can't find it. Please assist me.

const app = new Vue({
  el: '#app',
  data() {
    return {
      b: [],
      a: [
        1, 2, 3, 4, 5
      ],
    }
  },
  methods: {
    filterElements() {
      return this.a.filter((a, a_index) => {
        return !this.b.find((b, b_index) => {
          return a === b
        })
      })
    }
  }

})

  <template v-for="i in b.length">
 <select v-model="b[i-1]">
     <option value="0" disabled>Select a value</option>

     <option v-for="(item, index) in a" :value="item">{{ item }}</option>
 </select>

  </template>

  <button @click="b.push(0)">+</button>

Selected elements: {{ b.join(', ') }}

A: You can simply use a computed property to contained the filtered version of A
To track changes in B you have to use $set to update the elements in B.
Otherwise B will not be reactive. More information here, https://v2.vuejs.org/v2/guide/reactivity.html#For-Arrays

const app = new Vue({
  el: '#app',
  data() {
    return {
      b: [],
      a: [
        1, 2, 3, 4, 5
      ],
    }
  },
  computed: {
    filteredA() {
      return this.a.filter((a, a_index) => {
        return !this.b.find((b, b_index) => {
          return a === b
        })
      })
    }
  },
  methods: {
    updateB(e, i) {
      // use $set to update array elements to maintain reactivity
      this.$set(this.b, i, +e);
    }
   }
})

  <template v-for="i in b.length">
    <select :value="b[i-1]" @input="updateB($event.target.value, i-1)">
            <option :value="b[i-1]">{{b[i-1] || "Select a value"}}</option>

        <option v-for="(item, index) in filteredA" :value="item" :key="`${item}-${index}`">{{ item }}</option>
    </select>

  </template>

  <button @click="b.push(0)">+</button>

Selected elements: {{ b.join(', ') }}

A: No need to manually filter. Here is a solution with looping your a array, and binding the selected values to b:
https://stackoverflow.com/a/50648659/13602136

A: If I understand correctly you want to do an array substraction (element in A that are not in B):

function aNotInB(a, b) {
  return a.filter(aElement => {
    // .find() returns undefined if nothing is found
    // (b.find(element) === undefined) returns true if a element is not found in b
    return b.find(bElement => aElement === bElement) === undefined
  })
}

a = [1, 2, 3, 4, 5]
b = [2, 3, 4]

console.log(aNotInB(a,b))    // [1, 5]


text:
Q: Fastlane doesn't work for Apple id with two factor authentication on continuous integration working with Gitlab My appleid has two factor authentication turned on. For continuous integration we use Fastlane tool.
Available session is not valid any more. Continuing with normal login.
Two-factor Authentication (6 digits code) is enabled for account 'my.account@gmail.com'

What can I do to fix that?

A: *

*On yout machine when CI is running, go to the terminal and type the following command:
fastlane spaceauth -u my.account@gmail.com

*Then fastlane will ask you about the code: Please enter 6 digits code:. Get it from another trusted device and type it here.

*You will receive FASTLANE_SESSION key. Just copy and paste it.

*Login to your gitlab account that is used along with your CI and go to Settings > CI/CD > Variables. Then define FASTLANE_SESSION variable, type the value and save.

*Run your job again.

A: from fastlane 2.173.0 - just use SPACESHIP_SKIP_2FA_UPGRADE=1  https://github.com/fastlane/fastlane/releases/tag/2.173.0


text:
Q: Select2 returns TypeError: data is undefined I'm trying to get Select2 working with Rails. I have the API endpoint working but I get a TypeError: data is undefined message in my console, so the select fields aren't being populated.
My code looks like this:
$(document).ready(function() {
  return $('#form_emails').select2({
    placeholder: 'User list',
    minimumInputLength: 3,
    ajax: {
      url: '/api/s/users',
      dataType: 'json',
      quietMillis: 250,
      data: function(term) {
        return { q: term };
      },
      results: function(data) {
        var results;
        results = [];
        $.each(data, function(idx, item) {
          results.push({
            'id': item.id,
            'text': item.first_name + ' ' + item.last_name
          });
        });
        return { results: results };
      }
    }
  });
});

Any idea why I might be getting the aforementioned error? Thanks in advance!

A: According to Select2 documentation the function where you can transform data from Ajax request is named processResults, not results.
See: https://select2.org/data-sources/ajax#transforming-response-data
So the correct code should be:
$(document).ready(function() {
  return $('#form_emails').select2({
    placeholder: 'User list',
    minimumInputLength: 3,
    ajax: {
      url: '/api/s/users',
      dataType: 'json',
      quietMillis: 250,
      data: function(term) {
        return { q: term };
      },
      processResults: function(data) {
        var results;
        results = [];
        $.each(data, function(idx, item) {
          results.push({
            'id': item.id,
            'text': item.first_name + ' ' + item.last_name
          });
        });
        return { results: results };
      }
    }
  });
});


text:
Q: How do I make sure a task run only once in a dockerized environment? I have a task that I need to make sure it only runs once in my dockerized environment (managed by k8s), running the post-upgrade script is one example.
Because each dockerized app can run the task and the docker containers may restart, I believe I need to store a state that indicating whether the task has run or not in a database, not just in memory. I also need to provide some locking mechanism to prevent multiple docker containers from running the task more than once.
The simple way is to use row lock to serialize access, only one dockerized app can read/write the record. For example just use sql SELECT ... FOR UPDATE, so the first docker container who gets the lock will check and run the task if necessary. All the other docker containers will just wait and get the set record later.
But I fell I can better than just serialize access. For example for the database supports SELECT ... FOR UPDATE NOWAIT I can use NOWAIT, so if a docker instance fails to get the lock that means one docker instance has got the lock and maybe have run the task, so it can just return, no need to wait for the lock then.
But not every database supports NOWAIT so I am thinking about how to implement a homemade solution to do that. The goal to make sure running the task only once.
Any suggestion ?

A: Assuming this is a "full" SQL database (i.e. with all the ACID guarantees), why not just use it as designed to get the lock?
UPDATE your_table
SET running_update = 1
WHERE running_update = 0

and then check the count of rows updated - the first run of the UPDATE statement (from any source) will actually update the row, while all subsequent statements will not make any change because running_update will already be 1. Every SQL database I'm aware of has the ability to get the count of rows affected by the previous UPDATE statement, although there's no standard for it - just read the fine manual for your database.
Once one task and one task only, the problem is trivial (ignoring the possibility of the update task failing) and you can just update some other data somewhere when it's completed.

A: A variant of Phil's answer: a three-state machine. NOT_YET_RUN -> RUNNING -> COMPLETE.
This is a little tricky to do properly, because you also need to record which instance is the one RUNNING, and have something check periodically to see if it has crashed and set it back to NOT_YET_RUN so that another runner can have a go.

A: You need a good way to implement a binary Semaphore or a Mutex. It's basically a safe way to say, "I've got this."  There are lots of ways to do this. Perhaps the simplest is have a row in the table that gets changed when one of the instances takes the job.
(pardon my pseudocode)
UPDATE JOBS SET OWNER="MY_ID" WHERE ID=$ AND OWNER=NULL

This update must be careful to only take the semaphore if the job is not already taken-- and database can easily serialize these requests. So check that you actually got the lock before proceeding:
SELECT OWNER FROM JOBS WHERE ID=$

The other important consideration is expiring the lock. Since docker containers can be ephemeral, consider the case where a container takes the job but then is shut down before actually doing this. It's probably easiest to incorporate a timestamp in the lock you are creating: (More pseudocode)
UPDATE JOBS
SET OWNER="MY_ID", OWNED_AT=NOW()
WHERE ID=$ AND OWNER=NULL OR OWNED_AT < (NOW()-1.minute)

Databases like Postgres actually have nice tools to address problems like this, but these basic examples should get you started.


text:
Q: android:gravity="start" in RTL aligns the text to left not right While testing my layout on a device with RTL language (Arabic) I found that TextView with gravity:start keeps aligning the text to the left instead of right ! I tried android:textAlignment="viewStart" and it works correctly but due to API reqs I didn't depend on it.
my code (I mean the first textview in my code) :
<LinearLayout
android:orientation="horizontal"
android:gravity="center_vertical"
>

<TextView
    android:text="Size"
    android:gravity="start"
    android:layout_weight="1"
    android:layout_width="0dp"
    android:layout_height="wrap_content"/>

<LinearLayout android:gravity="center" android:orientation="vertical" android:layout_width="wrap_content" android:layout_height="wrap_content">
    <TextView
        android:text="000"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="subtext"/>
</LinearLayout></LinearLayout>

A: For Full support or RTL you have to target api 17

If you are targeting your app to Android 4.2 (the app's
targetSdkVersion or minSdkVersion is 17 or higher), then you should
use "start" and "end" instead of "left" and "right". For example

Native RTL support in Android 4.2

A: My current workaround for this if any one is interested in the future is adding an empty view between the two elements and making it fill the empty space between them (weight = 1) so they get aligned properly. Still I don't understand that abnormal behavior of gravity="start"


text:
Q: Are Past Participles Non Finite Verbs? I'm currently reading a book on syntax and it states the following:
"Be careful not to confuse the past participle with the past tense...They differ, however in that the past tense form is finite, while the past participle form is non finite"
The verb dance was used as an example e.g. I often danced vs He has often danced.
What I am wondering is, of course the simple past tense is finite, but isn't the past participle also finite? In the sense that it has tense about an action that occurred in the past? In this case the act of dancing? Or is one to assume it's acting as an adjective?
Appreciate any help.
Thanks.

A: The past participle can be used in lots of situations that have nothing to do with the past. In particular it is used when a passive meaning is required.

The apple will be eaten.  (future in passive voice)
The weather will be mostly fine but interrupted by occasional showers (the main verb is in the future, the participle clause uses the past participle only to indicate a passive sense. The participle clause refers to future events.)

So the past particple clause can refer to future events. It doesn't indicate tense at all (so "past" is a bad name for it). It is not a finite verb form.

A: Finite v non-finite verb forms
A finite verb is a tensed verb.  A non-finite verb is an untensed verb such as a participle or an infinitive.
A finite verb can also be defined as follows:

Finite verbs can function on their own as the core of an independent sentence, whereas nonfinite verbs cannot.

As James K stated, participles (including "past" and "present" participles) are non-tensed (despite their conventional names).  (Some grammars call them the -ed and -ing participles instead.)
Tenses
Most learners (and EFL/ESL teaching materials) see constructions such as the present perfect as "tenses".  This might lead you to look upon both verb forms as finite, when actually only the auxiliary is.  (But the clause as a whole is also finite.)
Most linguists would say that English has only two tenses (although Huddleston and Pullum would prefer to say two primary tenses) - the present and past.  (There is no inflection for the future; "will" is a modal verb.)  The auxiliary (often tensed) can be followed by a participle to form a progressive, perfect, or progressive perfect.  (The auxiliary can also be untensed, as in "to have taken".)
Auxiliaries (even when finite) are followed by non-finite forms.
In "I do take" or "I will take", the verb "take" is non-finite (specifically a bare infinitive), and in "I have taken", "taken" is also non-finite.
Note: modals are counted as finite even though they don't have visible tense markings,  so "will" is finite (in fact, the modals have no infinitives nor participles).
Finite v non-finite clauses
Having said that, although the participle is non-finite, it may be part of a finite clause:

Finiteness is a property not only of verbs, but also of clauses. The finiteness of a clause is determined by the finiteness of its head.

So, although "I have taken" combines a finite and non-finite verb form, the clause as a whole is finite.
You may also be interested in my answer on the English language & usage stack here.


text:
Q: How do I find the center of mass of a region given by a function using integration So I'm currently working on a project where i want to find the center of mass of a given region. To be exact, i want to find the center of mass (using moments and all of that) of this region
the plane i want to find
Its a circle with a radius of 3 and is cut as you can see in the picture at x=5.3
How do i find the center of mass of such a plane (do i have to cut into seperate functions or do i have to use another equation please help

A: I didn't realize that its a wolfram-mathematica related problem initially.
Getting the general idea from this page
https://mathematica.stackexchange.com/questions/146618/center-of-mass-of-2d-region/146619
This is how you can solve.
reg = ImplicitRegion[{0 <= x <= 5.3,(x-3)^2+(y-3)^2<=9, 0 <= z <= 1}, {x, y, z}];
RegionCentroid[reg]//Most


text:
Q: Spring MVC - How to set return media type when handling HttpMediaTypeNotAcceptableException? I have a Spring 3.2 MVC REST service, which implements error handling by extending ResponseEntityExceptionHandler. This handles the standard Spring exceptions, and will respond with the appropriate HTTP status and custom "Error" ResponseEntity object in XML or JSON as requested by the client. This works great for all of the standard exceptions except HttpMediaTypeNotAcceptableException.
The problem I have with this exception is that the reason its thrown in the first place is because the response media type (application/xml, application/json, etc.) could not be determined from the request. If I try to return an "Error" ResponseEntity object for this exception it will fail because the response media type couldn't be determined (which is why this exception is being handled in the first place)...and basically get another HttpMediaTypeNotAcceptableException thrown from my ExceptionHandler.
I need to figure out a way when handling HttpMediaTypeNotAcceptableException to specify a valid response media type, so the ResponseEntity makes it to the client. Since requested media type can't be determined, this would probably just be the default for my service (application/xml)
Any ideas?

A: I found same problem in my development, to so solve this issue you need specify in the reponsebody of your error message present in your all method annoted @ExceptionHandler of your controllerAdvicer the contentType:
for exemple: your receive header Accept: application/pdf but your application produce application/json.
class GlobalExceptionHandler  annoted with @ControllerAdvice to manage specific body response:
    package com.obs.sfu.exception;

import javax.validation.ConstraintViolationException;

import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.HttpMediaTypeNotSupportedException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.NoHandlerFoundException;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
import org.springframework.ws.soap.client.SoapFaultClientException;

@ControllerAdvice
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {

    private static final String SIZE_MUST_BE_FROM_1_TO_15_CHARACTERS = "Size must be from 1 to 15 characters";
    private static final int CODE_INTERNAL_SERVER_ERROR = 1;
    private static final String MESSAGE_INTERNAL_SERVER_ERROR = "Internal error";
    private static final String DESCRIPTION_INTERNAL_SERVER_ERROR = "Generic failure message";

    private static final int CODE_SERVICE_UNAVAILABLE = 5;
    private static final String MESSAGE_SERVICE_UNAVAILABLE = "The service is temporarily unavailable";
    private static final String DESCRIPTION_SERVICE_UNAVAILABLE = "The service can not handle the call.";

    private static final int CODE_UNSUPPORTED_MEDIA_TYPE = 68;
    private static final String MESSAGE_UNSUPPORTED_MEDIA_TYPE = "Unsupported Media Type";
    private static final String DESCRIPTION_UNSUPPORTED_MEDIA_TYPE = "The format of the posted body is not supported by the endpoint.";

    private static final int CODE_NOT_FOUND = 60;
    private static final String MESSAGE_NOT_FOUND = "Resource not found";
    private static final String DESCRIPTION_NOT_FOUND = "The Requested URI or the requested resource does not exist.";

    private static final int CODE_METHOD_NOT_ALLOWED = 61;
    private static final String MESSAGE_METHOD_NOT_ALLOWED = "Method not allowed";
    private static final String DESCRIPTION_METHOD_NOT_ALLOWED = "The URI does not support the requested method. The available methods should be set in the response header 'Allow'";

    private static final int CODE_NOT_ACCEPTABLE = 62;
    private static final String MESSAGE_NOT_ACCEPTABLE = "Not acceptable";
    private static final String DESCRIPTION_NOT_ACCEPTABLE = "The Accept incoming header does not match any available content-type.";

    private static final int CODE_CONSTRAINT_VIOLATION_FIELD = 20;
    private static final String MESSAGE_INVALID_BODY_FIELD = "Invalid Via field";

    private static final String HEADER_ALLOW = "Allow";
    private static final String HEADER_ALLOW_VALUE = "GET, OPTIONS";

    @Override
    protected ResponseEntity<Object> handleNoHandlerFoundException(NoHandlerFoundException ex, HttpHeaders headers,
            HttpStatus status, WebRequest request) {
        ErrorDetails errorDetails = new ErrorDetails(request.getContextPath(), MESSAGE_NOT_FOUND, DESCRIPTION_NOT_FOUND,
                CODE_NOT_FOUND);
        return ResponseEntity.status(status).contentType(MediaType.APPLICATION_JSON).body(errorDetails);
    }

    @Override
    protected ResponseEntity<Object> handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException ex,
            HttpHeaders headers, HttpStatus status, WebRequest request) {
        ErrorDetails errorDetails = new ErrorDetails(request.getContextPath(), MESSAGE_METHOD_NOT_ALLOWED,
                DESCRIPTION_METHOD_NOT_ALLOWED, CODE_METHOD_NOT_ALLOWED);
        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.set(HEADER_ALLOW, HEADER_ALLOW_VALUE);
        return ResponseEntity.status(status).headers(responseHeaders).contentType(MediaType.APPLICATION_JSON)
                .body(errorDetails);
    }

    @Override
    protected ResponseEntity<Object> handleHttpMediaTypeNotSupported(HttpMediaTypeNotSupportedException ex,
            HttpHeaders headers, HttpStatus status, WebRequest request) {
        ErrorDetails errorDetails = new ErrorDetails(request.getContextPath(), MESSAGE_UNSUPPORTED_MEDIA_TYPE,
                DESCRIPTION_UNSUPPORTED_MEDIA_TYPE, CODE_UNSUPPORTED_MEDIA_TYPE);
        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.set("Accept", MediaType.APPLICATION_JSON_VALUE);
        return ResponseEntity.status(status).headers(responseHeaders).contentType(MediaType.APPLICATION_JSON)
                .body(errorDetails);
    }

    @Override
    protected ResponseEntity<Object> handleHttpMediaTypeNotAcceptable(HttpMediaTypeNotAcceptableException ex,
            HttpHeaders headers, HttpStatus status, WebRequest request) {
        ErrorDetails errorDetails = new ErrorDetails(request.getContextPath(), MESSAGE_NOT_ACCEPTABLE,
                DESCRIPTION_NOT_ACCEPTABLE, CODE_NOT_ACCEPTABLE);
        return ResponseEntity.status(status).contentType(MediaType.APPLICATION_JSON).body(errorDetails);
    }

    @ExceptionHandler(ConstraintViolationException.class)
    public ResponseEntity<Object> handleConstraintViolation(ConstraintViolationException ex, WebRequest request) {
        ErrorDetails errorDetails = new ErrorDetails(request.getContextPath(), MESSAGE_INVALID_BODY_FIELD,
                SIZE_MUST_BE_FROM_1_TO_15_CHARACTERS, CODE_CONSTRAINT_VIOLATION_FIELD);
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).contentType(MediaType.APPLICATION_JSON).body(errorDetails);
    }

    @ExceptionHandler(SoapFaultClientException.class)
    public ResponseEntity<Object> handleSoapFaultClient(Exception ex, WebRequest request) {
        ErrorDetails errorDetails = new ErrorDetails(request.getContextPath(), MESSAGE_SERVICE_UNAVAILABLE,
                DESCRIPTION_SERVICE_UNAVAILABLE, CODE_SERVICE_UNAVAILABLE);
        return ResponseEntity.status(HttpStatus.SERVICE_UNAVAILABLE).contentType(MediaType.APPLICATION_JSON)
                .body(errorDetails);
    }

    @ExceptionHandler(Exception.class)
    public ResponseEntity<Object> handleGlobalException(Exception ex, WebRequest request) {
        ErrorDetails errorDetails = new ErrorDetails(request.getContextPath(), MESSAGE_INTERNAL_SERVER_ERROR,
                DESCRIPTION_INTERNAL_SERVER_ERROR, CODE_INTERNAL_SERVER_ERROR);
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).contentType(MediaType.APPLICATION_JSON)
                .body(errorDetails);
    }
}

file application.properties need these properties to manage NoHandlerFoundException (throwExceptionIfNoHandlerFound):
spring:
  mvc:
    throw-exception-if-no-handler-found: true
    static-path-pattern: /swagger* # to available swagger-ui.html

A: Edit: this answer is pretty useless, see comment below. Sorry.
As in this case the communication is pretty messed up anyway, maybe it is enough to set the status code to 400 - Bad Request and hope the client does not really expect a machine readable answer in a format that is not known to the server anyway. If a response body is send, maybe use Content-Type: text/plain - that will be of no use for the client, but maybe the person debugging the situation ;) Well, or whatever fits your mood.
Update: a better fitting solution might be to use the method explained in the manual; at: http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-ann-customer-servlet-container-error-page however I have to admit I did not really try if that works.


text:
Q: Intercepting methods called by the Startable facility with Castle Windsor 3.0 I'm using Castle Windsor 3.0.
I have a component that should be started automatically after the registration phase.
I would also like to intercept exceptions coming from it's Start/Stop methods and log their details.
To make my component startable, I used the Startable facility that comes with Windsor:
container.AddFacility<StartableFacility>(f => f.DeferredStart());

I created a custom interceptor like this:
class ExceptionLoggerInterceptor : IInterceptor
{
    IExceptionLogger m_ExceptionLogger;

    public ExceptionLoggerInterceptor(IExceptionLogger exceptionLogger)
    {
        if (exceptionLogger == null)
            throw new ArgumentNullException("exceptionLogger");

        m_ExceptionLogger = exceptionLogger;
    }

    public void Intercept(IInvocation invocation)
    {
        try
        {
            invocation.Proceed();
        }
        catch (Exception ex)
        {
            m_ExceptionLogger.Write(ex, invocation.Method.Name, invocation.TargetType.Name);
        }
    }
}

and I registered the component like this:
Component.For<IExceptionLogger>()
 .ImplementedBy<EnterpriseLibraryExceptionLogger>()
 .LifeStyle.Singleton,

Component.For<ExceptionLoggerInterceptor>()
 .LifeStyle.Singleton,

Component.For<IWorkflowService>()
 .ImplementedBy<WorkflowService>()
 .LifeStyle.Singleton
 .StartUsingMethod(c => c.Start)
 .StopUsingMethod(c => c.Stop)
 .Interceptors(InterceptorReference.ForType<ExceptionLoggerInterceptor>()).Anywhere

To make a test, I coded a dirty
throw new Exception();

in the implementation of the Start method of the component. At registration phase, when Windsor automatically calls the Start method on the component, the exception is thrown, but never intercepted by my custom interceptor.
I made another test, this time without using the Startable facility but rather calling the Start method manually. The exception got thrown and was intercepted by my custom interceptor.
So, as the title of this post asks, is there a way to intercept methods called by the Startable facility with Windsor?
Regards
Louis-Pierre Beaumont

A: I'm going to partially answer my own question:
I did not find any way to intercept the Start method on a component when using the Startable facility. It looks like the facility is not using the proxy created for the object to perform the call, but the object itself.
A dedicated post presents the problem here.
Anyway, I quicly figured out that doing AOP with Proxy objects has it's limits. That's why I moved to SheepAspect, an IL Weaving AOP Framework.
I mixed SheepAspect with Castle Windsor, and now, when my component's Start method is called by the Castle Startable facility, all my aspects are also called!
Here is how i wrote my ExceptionAspect with SheepAspect:
[SingletonAspect]
public class ExceptionAspect
{
    IExceptionLogger m_ExceptionLogger;

    public ExceptionAspect(IExceptionLogger exceptionLogger)
    {
        if (exceptionLogger == null)
            throw new ArgumentNullException("exceptionLogger");

        m_ExceptionLogger = exceptionLogger;
    }

    [SelectTypes(typeof(WorkflowService))]
    void Targets() { }

    [Around("Execute")]
    [SelectMethods("Name:('Start') & InType:@Targets")]
    public void Execute(MethodJointPoint jp)
    {
        object result = null;

        try
        {
            result = jp.Execute();
        }
        catch (Exception ex)
        {
            m_ExceptionLogger.Write(ex, jp.Method.Name, jp.Method.ReflectedType.Name);
        }

        return result;
    }
}


text:
Q: Error for invalid css when trying to compile sass I am new to sass, after having downloaded bulma, installed gem, and sass, I tried to compile a default sass file with sass style.scss style.css, here is my directory structure

But I get errors likes this:
/*
Error: Invalid CSS after "$pink": expected selector or at-rule, was ": #ffb3b3 "
        on line 2 of styles.scss

1: $blue: #72d0eb
2: $pink: #ffb3b3
3: $orange: #FFA500
4: $family-serif: "Georgia", serif
5:
6: $danger: $orange
7: $family-primary: $family-serif

Backtrace:
styles.scss:2
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/scss/parser.rb:1207:in `expected'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/scss/parser.rb:1137:in `expected'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/scss/parser.rb:42:in `parse'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/engine.rb:406:in `_to_tree'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/engine.rb:381:in `_render_with_sourcemap'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/engine.rb:298:in `render_with_sourcemap'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/exec/sass_scss.rb:391:in `run'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/exec/sass_scss.rb:63:in `process_result'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/exec/base.rb:52:in `parse'
/usr/local/share/gems/gems/sass-3.4.23/lib/sass/exec/base.rb:19:in `parse!'
/usr/local/share/gems/gems/sass-3.4.23/bin/sass:13:in `<top (required)>'
/usr/local/bin/sass:23:in `load'
/usr/local/bin/sass:23:in `<main>'
*/
body:before {
  white-space: pre;
  font-family: monospace;
  content: "Error: Invalid CSS after \"$pink\": expected selector or at-rule, was \": #ffb3b3 \"\A         on line 2 of styles.scss\A \A 1: $blue: #72d0eb \A 2: $pink: #ffb3b3 \A 3: $orange: #FFA500\A 4: $family-serif: \"Georgia\", serif\A 5: \A 6: $danger: $orange\A 7: $family-primary: $family-serif "; }

I can't seem to find a fix for this

A: Try terminating the line by a semi-colon (;)
For example -
$font-stack:    Helvetica, sans-serif;
$primary-color: #333;

A: You're compiling a real Sass file, with the Sass indented syntax (no braces, no semi-colon, indentation alone is sufficient).
But the extension of your file is *.scss, meant for CSS-like syntax (there's a c, see ^^)
Either rename your file to styles.sass with an a or write your styles as you'd write CSS (but with nested rules, variables, etc provided by this preprocessor :) )
Sass the compiler compiles both Sass indented syntax and Scss one, which is not straightforward...
EDIT: try to compile a plain CSS file (no variable, no mixin, no nesting just CSS) renamed to .scss. CSS is valid LESS and Scss so if it doesn't compile, the problem isn't with your file.
You can also try to compile the content of your file in http://www.sassmeister.com and play with the options.


text:
Q: Deactivate plugins using Migrate DB's find and replace options If possible, how would I go about disabling plugins using the Find and Replace options the Migrate DB plugin offers?
What I hope to achieve
I use Migrate DB to bring copies of production DBs down to local dev environments. There are a couple of plugins I use which I consider to be "production only", such as W3 Total Cache, and UpdraftPlus, which I don't want to be activated in my dev environment.
Migrate DB offers a find and replace function that changes the URL and file paths saved in the DB during migration. You can add additional custom find and replace queries to be run during migration, and I use this option to change the destination email address for things like contact forms to avoid sending emails during testing and causing confusion.
So, Is there a find and replace query that can be run to disable plugins during migration?

A: To disable plugins using the find and replace option in Migrate DB, search for the file path to the plugins main PHP file, and replace it with nothing.
To disable W3 Total Cache for example, you would search for w3-total-cache/w3-total-cache.php and leave the replace field empty.
Explanation
WordPress stores the active plugin data in the active_plugins record within the wp_options table as a serialised string. The Migrate DB plugin is smart enough to know it is performing a find and replace on a serialised string and will unserialise it, run the find and replace, and reserialise the string.


text:
Q: Add hyperlink to an image via cell in Excel is there a way to add a hyperlink, provided from a cell, to an image?
I tried the following VBA code:
Sub Storage_Test_Click()
    ActiveSheet.Hyperlinks.Add Anchor:=storage_image, Address:=Worksheets("Links").Range("B8:B8").Value
End Sub

But with this piece of code, the link is persistent. In other words, if I change the cell value, the link from the image is not affected.
Thanks,
Tro

A: Enter something like this in a Module
Sub Add_HLink(ws As Worksheet, picture_name As String)
    Dim sh As Worksheet: Set sh = Worksheets("Link")
    Dim shp As Shape
    For Each shp In ws.Shapes
        If shp.Type = msoPicture And shp.Name = picture_name Then
            ws.Hyperlinks.Add shp, sh.Range("B8").Value
            Exit For
        End If
    Next
End Sub

Then in your Link Sheet:
Private Sub Worksheet_Change(ByVal Target As Range)
    On Error GoTo halt
    Application.EnableEvents = False
    If Not Intersect(Target, [B8]) Is Nothing Then
        '~~> use the sub here, assuming Picture named "Picture 1" is in Sheet2
        Add_HLink Sheet2, "Picture 1" '~~> change the arguments to suit
    End If
continue:
    Application.EnableEvents = True

    Exit Sub
halt:
    MsgBox Err.Description
    Resume continue
End Sub

Is this what you're trying? HTH.

A: Private Sub Worksheet_SelectionChange(ByVal Target As Range)
ActiveSheet.Hyperlinks.Add Anchor:=storage_image, Address:=Worksheets("Links").Range("B8:B8").Value
End Sub

dont assign the macro to the image, because you can't click on the image (as it's a hyperlink!), if you right click your image with your original code after updating your link, im sure that selects it and your macro will run, however the above changes should mean everytime you make a selection on your sheet, your links will update


text:
Q: Finding the center of mass of a semicircular wire/disk of on non-negligible width, with the inner radius being $R_1$ and outer radius being $R_2$. [I know it's is a Physics Problem but I am sure that I am committing mistake in integration part. That's why so posting here. I am new to calculus-based physics so I frequently make conceptual mistakes when setting up integrals; I would really appreciate someone pointing them out.]

Goal: Finding the center of mass of a semicircular wire/disk of on non-negligible width, with the inner radius being $R_1$ and outer radius being $R_2$.

*

*I am gonna start this with a goal of setting up a Reimann Sum. First I divide the "arc" of angle $\pi$ into $n$ sub-arcs of equal angle $\Delta\theta$

*The total center of mass can be found if centers of mass of parts of the system are known. In each circular arc interval, I choose a height, $H_i$, approximating the height of the center of mass of each sub arc, hoping that the error goes to $0$ in the limit as $n \to \infty$, and multiply this by the mass of the sub arc. Pushing this through the limiting process, I set up the integral of $H$ w.r.t $m$.

*Finding $H_i$: Now, as $\Delta\theta \to0$, the sector-difference region formed by each sub-arc should get closer and closer to a tilted rectangle. Assuming that to be $\color{green}{\text{True}}$, the center of mass of each sub-arc (being approximated by a titled rectangle) would be a distance $H_i=\frac{(R_1+R_2)\sin(θ)}{2}$ above the origin.

*Lastly, since the shape has a constant mass per unit area, the differential mass and total mass can be replaced by differential area and total area. Using the sector area formula for each subinterval, the differential area, $dA$, should be equal to $0.5\;d\theta (R_2^2-R_1^2)$
Solving this gives me $$y_{com}=\frac{(R1+R2)}{\pi}$$ which upon looking up is clearly wrong. It is interesting thought that it gives the correct result when $R_1=R_2$ ($0$-thickness). What is the error in my reasoning?
Here I have solved it on Pen and Paper.

A: For sufficiently small $\Delta\theta,$ your element of area is approximately an isosceles trapezoid with one parallel side $R_1\Delta\theta$ and opposite side $R_2\Delta\theta$. No matter how small $\Delta\theta$ gets, the larger parallel side will always be $R_2/R_1$ times as large as the other.
If the parallel sides of a trapezoid have lengths $a$ and $b,$ and the interior of the trapezoid is a lamina of uniform density, then the center of mass of that lamina is at a distance
$$ \frac{2a + b}{3(a+b)} h$$
from the side of length $b,$ where $h$ is the height of the trapezoid.
Let $a = R_2\Delta\theta$ and $b = R_1\Delta\theta$,
these sides being respectively at distances $R_2$ and $R_1$ from the center of the circle;
then $a > b,$ $h = R_2 - R_1,$ and the center of mass is at a distance
$$ \frac{2R_2\Delta\theta + R_1\Delta\theta}
{3(R_2\Delta\theta+R_1\Delta\theta)} (R_2 - R_1)
=\frac{2R_2+ R_1}{3(R_2+R_1)}(R_2 - R_1) $$
from the short side of the trapezoid, which is is the same for every
small $\Delta\theta$ and is greater than $\frac12(R_2 - R_1).$
Hence the center of mass is located farther than $\frac12(R_2 + R_1)$
from the center of the circle.

A: Due to symmetry, the center of mass lies along the radial line of the angle $\frac{\Delta\theta}2$. So, it is natural to let the $y$-axis aligned with the half-angle radius. Then, integrate the center of mass in polar coordinates as follows,
$$y_c = \frac{\int_{R_1}^{R_2}\int_{\frac{\pi-\Delta\theta}2}^{ \frac{\pi+\Delta\theta}2}( r\sin\theta )rdr d\theta}{\frac{\Delta \theta}2(R_2^2-R_1^2)}=\frac43\frac{}{}\frac{\sin\frac{\Delta\theta}2}{\Delta\theta}\frac{R_2^3-R_1^3}{R_2^2-R_1^2}
$$
(You incorrectly assumed that $\frac{R_2+R_1}2$ is the COM along the radial direction, because the mass within $d\theta$ is not uniform along radius.)

A: Let us start with the center of mass of a unit half-disk. By symmetry, the average abscissa is $0$. Then the average ordinate,
$$\bar y=\frac1A\int_{-1}^1\int_0^{\sqrt{1-x^2}}y\,dx\,dy=\frac2\pi\frac12\int_{-1}^1(1-x^2)\,dx=\frac4{3\pi}.$$
To obtain the result for a half ring of radii $R_e$ and $R_i$, we will combine a positive and a negative mass. Computing the moments and areas, this gives us
$$\bar y=\frac{M_{y,e}-M_{y,i}}{A_e-A_i}=\frac4{3\pi}\frac{R_e^3-R_i^3}{R_e^2-R_i^2}=\frac4{3\pi}\frac{R_e^2+R_eR_i+R_i^2}{R_e+R_i}.$$


text:
Q: What is the difference between these two regular expression statements ([1|2|3|4|5|6|7|8|9]) and (1|2|3|4|5|6|7|8|9)
I would like to check each port of a Cisco Switch for a specified set of commands.  The ports are numbered 1 thru 9.  Using a regular expression I want the code to choose each one of the numbers to validate the configuration.

A: The first regular expression doesn't really make sense: it means "choose 1 or choose | or choose 2 or choose 3 or ... or choose 9"
The second means "choose 1 or choose 2 or choose 3 or ... or choose 9"
I think the regular expression you were looking for in the first regular expression is ([123456789]), which is exactly equivalent to the second regular expression.
To make it even simpler, you can use ([1-9]), which just indicates a range.
For more information about regular expressions, more specifically perl compatible regular expressions (PCREs), you can look here.

A: The first one will match any character in the set

|123456789

The second one will match

1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9

.

A: The first one will match any of:
1 2 3 4 5 6 7 8 9 |

while the second one will match any of:
1 2 3 4 5 6 7 8 9

Note that the first one is equivalent to: ([123456789|]).
Of course, the regex that would do the job for your problem is (slightly) different: ([123456789]), or ([1-9]).

A: As others noted, "|" in the first is obviously errant, since there would be no need to repeat it, and thus should be [123456789] or [1-9]. Beyond that, it is also worth noting that in a numeric context there would be no functional difference with this exact data, hiding a logical bug, because they both happen to contain only single characters (the second "strings" just happen to be single characters). However, ([1|2|3|4|5|6|7|8|9|10]) and (1|2|3|4|5|6|7|8|9|10) would not be functionally the same even in the numeric context, since only the first would match "0" (with redundant "1" as well as extraneous "|") and only the second would match 10. Noting this might further help clarify confusion, and potential bugs that make this important.


text:
Q: How to obtain the number of registries in a table that specifically match the characteristics of a different registry in another table? This is a problem that's had me stumped for a few days now. I'm not that proficient at SQL, so bear with me if this seems obvious.
I have two tables, one with ingredients a bit like so:

ITEM     INGREDIENTS
-----    -------------
A01      Ing-01
A01      Ing-02
A01      Ing-03
A02      Ing-01
A02      Ing-03
A02      Ing-05
A03      Ing-02
A03      Ing-12
A03      Ing-22
 .
 .
 .
A99      Ing-04

So, say, item A01 has a specific set of three ingredients.
And then, there's another table , much larger, that includes information like this:

PACK      INGREDIENTS
-----     ------------
AAA       Ing-01
AAA       Ing-02
AAA       Ing-03
ABB       Ing-72
ABB       Ing-74
ABB       Ing-81
BCC       Ing-01
BCC       Ing-02
BCC       Ing-07
 .
 .
 .
ZQY       Ing-02

The challenge here is that I need a quick way to determine how many packs have exactly the ingredients for a given item. So far I have to run a query to find the ingredient set for a given item and then run a separate query to count the number of packs that have EXACTLY that set of ingredients. So, I'm trying to put together a single query that gives me that information.
The problem becomes more complex because in some isolated cases I might need to know how many packs have AT LEAST two of the ingredients, so I have to build the query in such a way that I need only change it minimally in order to get the results.
Is it possible at all, or am I overreaching? Any and all help and suggestions will be deeply appreciated.
Regards,

A: if we assume that all items are made with three ingredients and all packs also have three ingredients exactly, you can easily find the matches between packs and items with this query:
SQL> SELECT p.pack, i.item, COUNT(*)
  2    FROM pack p
  3    JOIN item i ON p.ingredient = i.ingredient
  4   GROUP BY p.pack, i.item
  5  HAVING COUNT(*) >= 3;

PACK ITEM   COUNT(*)
---- ---- ----------
AAA  A01           3

You can replace the constant 3 in the query by 2 to find packs that have at least 2 ingredients in common with items:
SQL> SELECT p.pack, i.item, COUNT(*)
  2    FROM pack p
  3    JOIN item i ON p.ingredient = i.ingredient
  4   GROUP BY p.pack, i.item
  5  HAVING COUNT(*) >= 2;

PACK ITEM   COUNT(*)
---- ---- ----------
BCC  A01           2
AAA  A01           3
AAA  A02           2

If the number of ingredients is unknown, this query will return the exact matches:
SQL> SELECT p.pack, i.item, COUNT(*)
  2    FROM (SELECT pack, ingredient,
  3                 COUNT(*) over (PARTITION BY pack) ingredients#
  4            FROM pack) p
  5    JOIN (SELECT item, ingredient,
  6                 COUNT(*) over (PARTITION BY item) ingredients#
  7            FROM item) i ON p.ingredient = i.ingredient
  8                        AND p.ingredients# = i.ingredients#
  9   GROUP BY p.pack, i.item, i.ingredients#
 10  HAVING COUNT(*) = i.ingredients#;

PACK ITEM   COUNT(*)
---- ---- ----------
AAA  A01           3


text:
Q: Word that means "periodically purged" or "cleansed by fire" What is a word that means "periodically purged" or "cleansed by fire"?

A: Swailing is the term used by the forestry community to describe the process of using intentional controlled burns to reduce the hazards of forest fires and to encourage new tree growth.
Usage of swailing appears particular to wooded parts of the UK (except, naturally, Scotland, where it is called muirburn or moorburn). Controlled burn is more common in the US. Prescribed burn is also common in Australia.
An elegant pen could make fine use of swailing in a literary context, but it may send readers running for a dictionary -- and, unfortunately, the reputable entries for swailing seem to be few.

A: The word salamanderize has been used with that sort of meaning (regenerate, rejuvenate), but I think in more recent usage just means to burn up without regeneration.
There are several mystical terms that reflect the concept, named with catch-phrases like fiery rebirth, Phoenix rising and star fire cycle.  Less-mystical phrases include fire cycle (meaning the actual cycle of fire and regrowth in forests), rising from the ashes, tried in the crucible, and purified by fire.  The latter two phrases appear in or stem from Proverbs 27:21 and Zechariah 13:8-9 respectively.
Serotiny is a related but plant-specific term: "an ecological adaptation exhibited by some seed plants, in which seed release occurs in response to an environmental trigger, [...] The most common and best studied trigger is fire".  Etymology from wordnik: "Latin sērōtinus, coming late, from sērō, at a late hour, from sērus, late."
The term pyriscence refers in the main to seed release triggered by fire.  Also (mis)used in reference to release due to dry conditions, which more properly is xeriscence.
Pyriscence looks like a word that ought to mean what you want, except it doesn't.


text:
Q: What's the best way to read mixed (i.e. text and binary) data? I need to be able to read a file format that mixes binary and non-binary data.  Assuming I know the input is good, what's the best way to do this?  As an example, let's take a file that has a double as the first line, a newline (0x0D 0x0A) and then ten bytes of binary data afterward.  I could, of course, calculate the position of the newline, then make a BinaryReader and seek to that position, but I keep thinking that there has to be a better way.

A: You can use System.IO.BinaryReader. The problem with this though is you must know what type of data you are going to be reading before you call any of the Read methods.
Read(byte[], int, int)
Read(char[], int, int)
Read()
Read7BitEncodedInt()
ReadBoolean()
ReadByte()
ReadBytes(int)
ReadChar()
ReadChars()
ReadDecimal()
ReadDouble()
ReadInt16()
ReadInt32()
ReadInt64()
ReadSByte()
ReadSingle()
ReadString()
ReadUInt16()
ReadUInt32()
ReadUInt64()

And of course the same methods exist for writing in System.IO.BinaryWriter.

A: Is this file format already fixed? If it's not, it's a really good idea to change to use a length-prefixed format for the strings. Then you can read just the right amount and convert it to a string.
Otherwise, you'll need to read chunks from the file, scan for the newline, and decode the right amount of data or (if you don't find the newline) either buffer it somewhere else (e.g. a MemoryStream) or just remember the starting point and rewind the stream appropriately. It will be ugly, but that's just because of the deficiency of the file format.
I would suggest you don't "over-decode" (i.e. decode the arbitrary binary data after the string) - while it may well not do any harm, in some encodings you could be reading an impossible sequence of binary data, which then starts getting into the realms of DecoderFallbacks and the like.

A: I've had to deal with that when reading HTTP requests coming in over the wire on Compact Framework.  My solution was to roll my own non-buffering ASCII-only StreamReader, so that it was safe to interleave calls to both the StreamReader and the underlying Stream.