caching – Create cache context for anonymous users based on ip range

I have a form within a custom block that is displayed on the front page of a Drupal 9 site on Acquia Cloud. I want to be able to have different displays for users coming from certain ip ranges. Is this possible to do while leaving all Drupal caching such as dynamic page cache and internal page cache?

If it is possible, how do I create cache contexts for this custom block/form such that Drupal knows to cache different displays based on that context? any examples would be great.

I know I can possibly accomplish this on the client side or using ajax but I would like to avoid that.

microsoft excel – Is there a formula or function i can use assign a value to column based off the criteria in another cell?

I have a spreadsheet with multiple header columns and and the aim of the spreadsheet is to pick the value on the left hand side and place it in the correct column based on the description on the right hand side. The description on the right hand side has consistent elements which help decide which column it needs to go in like Trials, Supermoto, MX and membership Im just wondering if there is a formula or function that i could set up that would check for this criteria and then allocate the amount on the left hand side to the correct column.
enter image description here

nt.number theory – Finding a number based on its divisors

I’m trying to comprehend whether the following question has an answer that you can actually calculate, or not.

Let $1 = d_1 < d_2 < d_3 < … < d_k = n$ be all of the positive divisors of the positive integer $n$.
Would it now be possible to find the largest possible number n such that $n = d_2^2 + d_3^3$?

I’ve been trying to figure this one out for a while now, but I feel like my limited knowledge in number theory is preventing me from doing so.

sql server – Create a json based on multiple queries on the same table when join is irrelevant

I need to construct a json based on the results of two different queries on the same table, where a join is irrelevant.

Consider the following example (full demo is here):

CREATE TABLE Trees
(
    (Id) INT,
    (Type) NVARCHAR(100),
    (Height) DECIMAL(2,1)
);

INSERT INTO Trees ((Id), (Type), (Height))
VALUES 
 (1, 'Palm', 5.5), 
 (2, 'Pine', 6.2), 
 (3, 'Apple', 2.5), 
 (4, 'Japanese Cedar', 0.5), 
 (5, 'Spanish Fir', 0.6);

I want to construct the following json:

(
  "highTrees": 
  (
     {
        "id": 1,
        "type": "Palm",
        "height": 5.5
     },
     {
       "id": 1,
        "type": "Pine",
        "height": 6.2
     }
  ),
  "lowTrees": 
  (
     {
        "id": 4,
        "type": "Japanese Cedar",
        "height": 0.5
     },
     {
       "id": 5,
        "type": "Spanish Fir",
        "height": 0.6
     }
  )
)
  

I tried this:

SELECT 
   Id as 'highTrees.id',
   Type as 'highTrees.type',
   Height as 'highTrees.height'
FROM Trees WHERE (Height) > 5
UNION ALL
SELECT 
   Id as 'lowTrees.id',
   Type as 'lowTrees.type',
   Height as 'lowTrees.height'
FROM Trees WHERE (Height) < 1
FOR JSON PATH;

But obviously this isn’t the way to go, since it gives this:

(
  {
    "highTrees": {
      "id": 1,
      "type": "Palm",
      "height": 5.5
    }
  },
  {
    "highTrees": {
      "id": 2,
      "type": "Pine",
      "height": 6.2
    }
  },
  {
    "highTrees": {
      "id": 4,
      "type": "Japanese Cedar",
      "height": 0.5
    }
  },
  {
    "highTrees": {
      "id": 5,
      "type": "Spanish Fir",
      "height": 0.6
    }
  }
)

How can I achieve the desired result?

c# – UNITY: UI Use Buttons based on Key Presses instead of Mouse Click

I have a UI Button. I want a function to be called whenever I press a specific Key on my Keyboard while my mouse is hovering over the button.

The Button Component On Click () has not received keypress input, only mouse clicks.

I am using the New Unity Input System

Similar to in Ark SE where you can press T while hovering over an item in your inventory to transfer it.

I have tried using a Raycast from ScreenPointToRay however this did not work as I do not have colliders on my UI and it is part of a Canvas

Is it will be good to use firebase database in android app when there is need to integrate the android app with unity based module?


Your privacy


By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.




seo – How to show same company’s different office address in google based on the user’s country?

our company has five offices in five countries , once the user search in google, I need to show the office address based on the user’s country, for example if the user search from US , I need google to show US office address automatically, also if the user search a specific office address then the search result will show that country office address, for example, the user search “ABC UK or ABC UK office address ” then the search result shows the UK office address. How can I do that?

woocommerce offtopic – adding surcharge based on subcategory and category

    // Add percentage based additional fee or surcharge

add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' );
function woocommerce_custom_surcharge() {
  global $woocommerce;

    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    $percentage = 0.3; // Add your percentage here
    $surcharge = ( $woocommerce->cart->cart_contents_total + $woocommerce->cart->shipping_total ) * $percentage;    
    $woocommerce->cart->add_fee( 'Surcharge', $surcharge, true, '' );

}

this is all good but I want to add a surcharge based on the product category and subcategory too. is there any option to that ?

wp : 5.8
php 8.0.7

database – How to implement notification system based on time that runs in regular intervals

I have a MySQL database with nodeJS server. I want to implement a notification functionality which is as follows. Once a user registers, I want to (inform) send some particular information to the user that runs in fixed time interval. Something like a task management and tracking.
If user A registers at 10am local time, notification must be sent 24 hours after A registers ie (notifications depends upon time that user registers however with a fixed interval). How do I implement this solution. I have looked at jobs in sql and cron jobs in NodeJs however I’m not sure of the approach, any guidance would be appreciated.

P.S. What would be the approach for same problem with mongoDB?

sharepoint online – Filter array of objects based on multiple properties/conditions

I’m pretty sure you are not getting any results from your filter because when you build your counter object in the reducer, you build it with complex property names that are combining many of your SharePoint field values into one long string, and then when you try to access the properties of the counter object in the filter, you are only specifying one of the SharePoint fields to try to find the property.

There are no properties on that object that have only the value of one of the SharePoint fields.

If you were to console.log(lookup) right after you build it using the reduce() function, you will see an object that looks something like this:

{
    "3001317_0001_Wood_FOO": 0,
    "3001317_0001_Metal_BAR": 1,
    "3001316_0002_Wood_FOO": 0,
    "3001316_0002_Metal_FOO": 2,
    "3001316_0001_Wood_BAR": 0
}

Now, the way that reducer works is that it adds a new property with that complex property name for each unique combination of those four field values. When it first adds it, it gives it a value of 0. 0 in this case means there is one item that has that unique combination of four field values. Then, if it finds another item with the same combination, it increments the counter. So a counter value of 1 means there are actually two duplicate items, and 2 means there are actually three items that are identical.

The reason the filter then works to pull out the duplicates is because you are checking against the counter object, and if there was only one unique item, then the counter value for that combination will be 0, which is a falsy value, so the filter won’t pull it, whereas if there were duplicates, the counter value will be 1 (or more), which is a truthy value, so the filter will pull it.

But, in your filter, you are only using the one field to try to access the counter properties, like this:

var askingForValue = lookup("3001317")

BUT – remember all the properties on the counter are much more than just that, there is no property on the counter object that is as simple as "3001317".

So what you have to do is re-create the complex property names / keys you created in the reducer:

FltrInv = getResp.filter(e => lookup(`${e.PCF_x0020_No}_${e.Item_x0020_No}_${e.Material}_${e.YourReference}`));

Also keep in mind, that filter will pull all the items that have duplicates, even if there are multiple sets of duplicates.

For example, if you look back at my fictitious counter object, if you ran that filter over the SharePoint results, you would end up with an array of 5 items:

  • 2 items would have field values 3001317 / 0001 / Metal / BAR
  • 3 items would have field values 3001316 / 0002 / Metal / FOO