What factors of the integer dataset being sorted can I change, in order to compare two sorting algorithms?

I am comparing two comparison and binary data structure based sorting algorithms, the Tree Sort, and the Heap Sort. I am measuring the time taken for both algorithms to sort an increasing size of an integer dataset. However, I am wondering if there are any other variables which I can modify, for example standard deviation, in the integer dataset itself that would be of any benefit to my comparison.

ORDER BY sort direction is exploitable in SQL Injection?

I am testing an internal application and come across a page where if I am able to make the application display a SQL error because it does not recognize the payload for ORDER BY sort direction. The query is:

select xxx  from something  where xxx xxx xxx  ORDER BY something  ASC LIMIT.....  

I am able to control the ASC part and the application throws out SQL error and display the Select query that gets broken whenever I send anything other than ASC or DESC. The column name used with ORDER BY is not injectable. Is this injection exploitable in this case? I read from couple of places that if we can control the column used by ORDER BY, then it is exploitable, but if we can control only the sort direction parameter, it is not an exploitable injection.

There are related questions here and here, but they don’t directly say whether the sort direction parameters are exploitable if user can control it.

The database is MySQL.

What opportunities exist in D&D 5e in order to turn into beasts, while maintaining personality and mental characteristics?

What opportunities exist in D&D 5e in order to turn into beasts, while maintaining personality and mental characteristics (Intelligence, Wisdom and not necessary Charisma)?

As far as I can see, one of the obvious solutions is Wild Shape. Are there any other options?

Prove: If $T’$ is not a MST one of its edges may be replaced by a lighter edge in order to get a lighter spanning tree

Prove: If $ T’=(V,F’)$ is not a MST of $ G=(V,E)$ , then there are edges $ e’ \in F$ and $ e \in $ $ E$ \ $ F$ such that $ w(e)<w(e’)$ and $ T’$ \ $ \{e’\} \cup \{e\}$ is a spanning tree.

My idea:

Let $ T=(V,F)$ be a MST of $ G$

for all $ e \in T$ , try to insert it into $ T’$ and see if there is an edge in the cycle created that is heavier than $ e$ . If we found such $ e$ we are done.

If not, define $ G’=(V,F \cup F’)$

This graph obviously has a MST.

We didn’t find a suitable $ e$ in the previous part so all edges in $ F$ may be colored in red.

That means there is a MST $ T”=(V,F”)$ such that $ F” \ F’$ but that is impossible because $ T’$ is not a MST of $ G’$ , because $ T$ is lighter.

Does that seem correct?

Time to FCP changes based on order of and tags

I was troubleshooting why one particular page took a full second longer to reach FCP compared to similar pages for mobile according to Google’s Page Insights. The difference ended up being the order of two tags at the beginning of the page.

3.4 seconds to FCP

<h2>heading</h2> <p>some paragraph</p> 

versus 2.5 seconds to FCP

<p>opening paragraph</p> <h2>heading</h2> 

In the first scenario, Google Page Insights gave a logo from the header as the FCP content. But with the second scenario, Google would display either text from the <p> or <h2> tag for the FCP content.

Why would the order of these two simple tags change the FCP content from text to an image header?

meta_query order by date present -> future then show null

Thanks for taking the time to read this. I’ve been struggling with a meta_query for an events site I’m working on.

I have used ACF to create a field for date start and date end, but not all events will have a date.

What I’m trying to achieve, is when you go to the archive or tax view, the first thing you see are the posts that have a date assigned, in order from today’s date into the future. Then after those dated events have been output, to cycle through all empty date posts.

So far I have the below in my functions.php file. This kind of works, but in the wrong order. So the correct events that are dated are output and in the right order. But only after the null valued items have output. I thought that may be because of the ordering in the arrays themselves, so moved the date ordered array to the end. That had no effect.

$  query->set( 'post_type', 'courses' ); $  query->set( 'meta_query', array(     'relation' => 'OR',     array(         'key'        => '_course_date_from',         'compare'    => '=',         'value'      => '',     ),     array(         'key'     => '_course_date_from',         'compare' => '>=',         'value'   => date('Ymd'),     ) ) ); $  query->set( 'orderby', 'meta_value title' ); $  query->set( 'order', 'ASC' ); 

Thanks for your time. Ben.

How to connect a mobile app through the woocommerce API to “Create Order” for a product linked to a vendor

I want to connect a mobile app through the woocommerce API to “Create Order” for a product linked to a vendor such that this will create the sub-order automatically for a given vendor account. The woocommerce API does not provide this capability by default and the "post author" is assigned to the user authorised to make the API call. How do I go about this?

Changing the Shopping cart Table order / VAT disappeared

I want to change the column order in the Shopping cart table. I want to exchange the Posititions of the Sum and VAT Column so that the Sum is the Last position. I guest the right php Template is the cart.php. Also the VAT name disappeared somehow in my column. I have VAT activated in all of my plugins and settings but it wont show :S I would be really thankful if the Pros out there could help me 🙂

enter image description here

    <?php /**  * Cart Page  *  * This template can be overridden by copying it to yourtheme/woocommerce/cart/cart.php.  *  * HOWEVER, on occasion WooCommerce will need to update template files and you  * (the theme developer) will need to copy the new files to your theme to  * maintain compatibility. We try to do this as little as possible, but it does  * happen. When this occurs the version of the template file will be bumped and  * the readme will list any important changes.  *  * @see     https://docs.woocommerce.com/document/template-structure/  * @package WooCommerce/Templates  * @version 3.8.0  */  defined( 'ABSPATH' ) || exit;  do_action( 'woocommerce_before_cart' ); ?>  <form class="woocommerce-cart-form" action="<?php echo esc_url( wc_get_cart_url() ); ?>" method="post">     <?php do_action( 'woocommerce_before_cart_table' ); ?>      <table class="shop_table shop_table_responsive cart woocommerce-cart-form__contents" cellspacing="0">         <thead>             <tr>                 <th class="product-remove">&nbsp;</th>                 <th class="product-thumbnail">&nbsp;</th>                 <th class="product-name"><?php esc_html_e( 'Product', 'woocommerce' ); ?></th>                 <th class="product-price"><?php esc_html_e( 'Price', 'woocommerce' ); ?></th>                 <th class="product-quantity"><?php esc_html_e( 'Quantity', 'woocommerce' ); ?></th>                 <th class="product-subtotal"><?php esc_html_e( 'Subtotal', 'woocommerce' ); ?></th>             </tr>         </thead>         <tbody>             <?php do_action( 'woocommerce_before_cart_contents' ); ?>              <?php             foreach ( WC()->cart->get_cart() as $  cart_item_key => $  cart_item ) {                 $  _product   = apply_filters( 'woocommerce_cart_item_product', $  cart_item['data'], $  cart_item, $  cart_item_key );                 $  product_id = apply_filters( 'woocommerce_cart_item_product_id', $  cart_item['product_id'], $  cart_item, $  cart_item_key );                  if ( $  _product && $  _product->exists() && $  cart_item['quantity'] > 0 && apply_filters( 'woocommerce_cart_item_visible', true, $  cart_item, $  cart_item_key ) ) {                     $  product_permalink = apply_filters( 'woocommerce_cart_item_permalink', $  _product->is_visible() ? $  _product->get_permalink( $  cart_item ) : '', $  cart_item, $  cart_item_key );                     ?>                     <tr class="woocommerce-cart-form__cart-item <?php echo esc_attr( apply_filters( 'woocommerce_cart_item_class', 'cart_item', $  cart_item, $  cart_item_key ) ); ?>">                          <td class="product-remove">                             <?php                                 echo apply_filters( // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped                                     'woocommerce_cart_item_remove_link',                                     sprintf(                                         '<a href="%s" class="remove" aria-label="%s" data-product_id="%s" data-product_sku="%s">&times;</a>',                                         esc_url( wc_get_cart_remove_url( $  cart_item_key ) ),                                         esc_html__( 'Remove this item', 'woocommerce' ),                                         esc_attr( $  product_id ),                                         esc_attr( $  _product->get_sku() )                                     ),                                     $  cart_item_key                                 );                             ?>                         </td>                          <td class="product-thumbnail">                         <?php                         $  thumbnail = apply_filters( 'woocommerce_cart_item_thumbnail', $  _product->get_image(), $  cart_item, $  cart_item_key );                          if ( ! $  product_permalink ) {                             echo $  thumbnail; // PHPCS: XSS ok.                         } else {                             printf( '<a href="%s">%s</a>', esc_url( $  product_permalink ), $  thumbnail ); // PHPCS: XSS ok.                         }                         ?>                         </td>                          <td class="product-name" data-title="<?php esc_attr_e( 'Product', 'woocommerce' ); ?>">                         <?php                         if ( ! $  product_permalink ) {                             echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', $  _product->get_name(), $  cart_item, $  cart_item_key ) . '&nbsp;' );                         } else {                             echo wp_kses_post( apply_filters( 'woocommerce_cart_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $  product_permalink ), $  _product->get_name() ), $  cart_item, $  cart_item_key ) );                         }                          do_action( 'woocommerce_after_cart_item_name', $  cart_item, $  cart_item_key );                          // Meta data.                         echo wc_get_formatted_cart_item_data( $  cart_item ); // PHPCS: XSS ok.                          // Backorder notification.                         if ( $  _product->backorders_require_notification() && $  _product->is_on_backorder( $  cart_item['quantity'] ) ) {                             echo wp_kses_post( apply_filters( 'woocommerce_cart_item_backorder_notification', '<p class="backorder_notification">' . esc_html__( 'Available on backorder', 'woocommerce' ) . '</p>', $  product_id ) );                         }                         ?>                         </td>                          <td class="product-price" data-title="<?php esc_attr_e( 'Price', 'woocommerce' ); ?>">                             <?php                                 echo apply_filters( 'woocommerce_cart_item_price', WC()->cart->get_product_price( $  _product ), $  cart_item, $  cart_item_key ); // PHPCS: XSS ok.                             ?>                         </td>                          <td class="product-quantity" data-title="<?php esc_attr_e( 'Quantity', 'woocommerce' ); ?>">                         <?php                         if ( $  _product->is_sold_individually() ) {                             $  product_quantity = sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $  cart_item_key );                         } else {                             $  product_quantity = woocommerce_quantity_input(                                 array(                                     'input_name'   => "cart[{$  cart_item_key}][qty]",                                     'input_value'  => $  cart_item['quantity'],                                     'max_value'    => $  _product->get_max_purchase_quantity(),                                     'min_value'    => '0',                                     'product_name' => $  _product->get_name(),                                 ),                                 $  _product,                                 false                             );                         }                          echo apply_filters( 'woocommerce_cart_item_quantity', $  product_quantity, $  cart_item_key, $  cart_item ); // PHPCS: XSS ok.                         ?>                         </td>                          <td class="product-subtotal" data-title="<?php esc_attr_e( 'Subtotal', 'woocommerce' ); ?>">                             <?php                                 echo apply_filters( 'woocommerce_cart_item_subtotal', WC()->cart->get_product_subtotal( $  _product, $  cart_item['quantity'] ), $  cart_item, $  cart_item_key ); // PHPCS: XSS ok.                             ?>                         </td>                     </tr>                     <?php                 }             }             ?>              <?php do_action( 'woocommerce_cart_contents' ); ?>              <tr>                 <td colspan="6" class="actions">                      <?php if ( wc_coupons_enabled() ) { ?>                         <div class="coupon">                             <label for="coupon_code"><?php esc_html_e( 'Coupon:', 'woocommerce' ); ?></label> <input type="text" name="coupon_code" class="input-text" id="coupon_code" value="" placeholder="<?php esc_attr_e( 'Coupon code', 'woocommerce' ); ?>" /> <button type="submit" class="button" name="apply_coupon" value="<?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?>"><?php esc_attr_e( 'Apply coupon', 'woocommerce' ); ?></button>                             <?php do_action( 'woocommerce_cart_coupon' ); ?>                         </div>                     <?php } ?>                      <button type="submit" class="button" name="update_cart" value="<?php esc_attr_e( 'Update cart', 'woocommerce' ); ?>"><?php esc_html_e( 'Update cart', 'woocommerce' ); ?></button>                      <?php do_action( 'woocommerce_cart_actions' ); ?>                      <?php wp_nonce_field( 'woocommerce-cart', 'woocommerce-cart-nonce' ); ?>                 </td>             </tr>              <?php do_action( 'woocommerce_after_cart_contents' ); ?>         </tbody>     </table>     <?php do_action( 'woocommerce_after_cart_table' ); ?> </form>  <?php do_action( 'woocommerce_before_cart_collaterals' ); ?>  <div class="cart-collaterals">     <?php         /**          * Cart collaterals hook.          *          * @hooked woocommerce_cross_sell_display          * @hooked woocommerce_cart_totals - 10          */         do_action( 'woocommerce_cart_collaterals' );     ?> </div>  <?php do_action( 'woocommerce_after_cart' ); ?> 

how to order the elements

Given $ U = \{(p_1,q_1),(p_2,q_2),…., (p_N,q_N)\}$ , where $ 0<p_1,p_2,…, p_N \le 1$ and $ 0<q_1,q_2,…, q_N$ , how to solve the following problem:

$ $ \begin{align} \max_{S\subseteq U }\max_\sigma&\quad \sum_{i=1}^{|S|}p_{\sigma_i}q_{\sigma_i}\Pi_{j=1}^{i-1}(1-p_{\sigma_j})\ s.t. & \quad |S|=K\le N. \end{align}$ $

where $ \sigma$ specifies the order of elements in $ S$ .

Suppose that we know the set of $ S$ , then $ \sigma$ should order the elements by $ q$ . (Otherwise, show the contradiction by switching two elements)

My question is: Suppose that $ (p_n,q_n)$ lies in $ S^*$ . Then when $ q_n$ increases, it will still lie in $ S^*$ , but will $ (p_n,q_n)$ be moved up?

Warding Bond: What is the Order of Operations for calculating cleric damage taken?

The warding bond spell allows a support character (cleric) to buff another creature (Basic Rules p. 105):

While the target is within 60 feet of you, it gains a +1 bonus to AC and saving throws, and it has resistance to all damage. Also, each time it takes damage, you take the same amount of damage.

What is the Order of Operations used to arrive at the final damage that the cleric receives as his share?

Resistance rules brought this up (Basic Rules, p. 75) as we hoped to Ward a raged Barb – MEGA Tank – until our DM reminded us that you don’t double stack like resistances (PHB, p. 197).

If a creature or an object has resistance to a damage type, damage of that type is halved against it.

I’ll be buffing our Paladin.
Two cases:

  1. Weapon damage (a hammer blow, a claw strike, gored by a gorgon …)
  2. Damage where a saving throw versus magical damage (usually a spell or spell like effect) is required.

Case 1. I stay 30′ behind Paladin. Giant scores a hit, doing 16 points of bludgeoning damage. Warding Bond (resistance) reduces that to 8. I take 8 HP.

Case 2. The Wizard whom the Giant serves fireballs the Paladin on his action. (I am outside blast radius). Rolled damage is 24, Fire. Paladin has resistance to all damage (from Bond) thus 24 is halved to 12. He rolls a saving throw, and succeeds with a 17. He takes 6 damage. I take 6 damage.

My view is that we can’t assign damage to Cleric until we know total damage to Paladin.

Paladin and I weren’t sure about the case of fireball: should it be different from the Giant’s hammer, since you don’t get a save versus melee weapon damage? With fireball reduced damage (from resistance) at 12, do I take 12 unless I too save versus fire as the Paladin did?

I don’t think so. It seems to violate the KISS principle. But, the Bond ties the cleric magically to the Paladin. Is magic going to follow that path of least resistance?

Do I have the order of operations right?

  1. First resolve all damage to Paladin.
  2. Then apply that amount to Cleric.

Is there something we missed that would support the other order of operations?