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.

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?

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?

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

function woocommerce_custom_surcharge() {
global \$woocommerce;

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

\$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: