How do I add woocommerce hook based on product categories?

I’m adding an image to the woocommerce_product_thumbnails hook. What I want is that the image I added appears in the products that have the product categories I selected, how can I do this?

The hook I use

add_action( 'woocommerce_product_thumbnails' , 'wd_add_below_prod_gallery', 5 );  function wd_add_below_prod_gallery() {     echo '<div class="wd-add-image">';     echo '<img src="#" style="width:50%; margin: 0 auto;"></div>'; } 

How to create random interpolated polygon shapes based Mesh in Unity?

I want to generate random Polygon (or maybe I am not using correct term) shapes as Mesh generated randomly and dynamically from script in runtime as shown in the picture attached. enter image description here

I want to use as Mesh Collider based on those procedurally generated shapes, I am using those shapes as to detect Bounds.Contains a certain gameObject’s position. I also want to assign a transparent material to those shapes, that will only be a color though or a diffuse texture with different opacity.

I have seen some tutorials on how to generate mesh from script, but it only helps me if I know the vertices positions exactly and how to adjust the tangents. I am unable to make them randomly generated. If you can help me correct the technical term used for this kind of shapes will also be useful. Or any work done before similar to this in the form of an Asset available on Unity store, or github repository. Or maybe even basic idea on approach how to research it or do it.

generate future dates for multiple entries based on start and end date of each row

i have an issue figuring out the below approach, would appreciate f you can give me a hand with a SQL query to generate the required result (basically i want to generate dates that semi annually Greater than start date and less than or equal end date)

Table

ID Start Date End Date
X 1 Jan 2021 1 Jan 2023
Y 1 Mar 2021 1 Mar 2023
Z 1 Jun 2021 1 Jun 2023

results needed

ID Date
X 1 Jun 2021
X 31 Dec 2021
X 1 Jun 2022
X 1 Jan 2023
y 31 Sep 2021
y 1 Mar 2022
y 31 Sep 2022
Y 1 Mar 2023
z 1 Jan 2022
z 1 Jun 2022
z 1 Jan 2023
z 1 Jun 2023

thanks in advanced

Get datetime based on change in another column using UDF and computed column in TSQL

Given: Given a Microsoft SQL database table Log with multiple columns including these important ones: id (primary key), code (an integer that can take multiple values representing status changes), lastupdated (a datetime field)…

What I need: I need to add a computed column ActiveDate which stores the exact first time when the code changed to 10 (i.e. an active status). As the status keep[s changing in future, this column must maintain the same value as the exact time it went active (thus keeping the active datetime record persistently). This timestamp value should initially begin with a NULL.

My approach I want the activedate field to automatically store the datetime at which the status code becomes 10, but when the status changes again, I want it to remain the same. Since I can’t reference a calculated column from a calculated column, I created a user defined function to fetch the current value of activedate and use that whenever the status code is not 10.

Limitations:

  • I can’t make modifications to the Db or to columns (other than the new columns I can add).
  • This T-SQL script must be idempotent such that it can be run multiple times at anytime in the production pipeline without losing or damaging data.

Here is what I tried.

IF NOT EXISTS (SELECT 1 FROM sys.columns WHERE Name=N'ActiveDate' AND OBJECT_ID = OBJECT_ID(N'[dbo].[Log]'))     /* First, create a dummy ActiveDate column since the user-defined function below needs it */     ALTER TABLE [dbo].[Log] ADD ActiveDate DATETIME NULL      IF OBJECT_ID('UDF_GetActiveDate', 'FN') IS NOT NULL        DROP FUNCTION UDF_GetActiveDate     GO      /* Function to grab the datetime when status goes active, otherwise leave it unchanged */      CREATE FUNCTION UDF_GetActiveDate(@ID INT, @code INT) RETURNS DATETIME WITH SCHEMABINDING AS         BEGIN            DECLARE @statusDate DATETIME            SELECT @statusDate = CASE               WHEN (@code = 10) THEN [lastupdated]               ELSE (SELECT [ActiveDate] from [dbo].[Log] WHERE id=@ID)            END            FROM [dbo].[Log] WHERE id=@ID            RETURN @statusDate         END     GO          /* Rename the dummy ActiveDate column so that we can be allowed to create the computed one */     EXEC sp_rename '[dbo].[Log].ActiveDate', 'ActiveDateTemp', 'COLUMN';      /* Computed column for ActiveDate */     ALTER TABLE [dbo].[Log] ADD ActiveDate AS (        [dbo].UDF_GetActiveDate([id],[code])     ) PERSISTED NOT NULL      /* Delete the dummy ActiveDate column */     ALTER TABLE [dbo].[Log] DROP COLUMN ActiveDateTemp;      print ('Successfully added ActiveDate column to Log table') GO 

What I get: The following errors

  • [dbo].[Log].ActiveDate cannot be renamed because the object participates in enforced dependencies.
  • Column names in each table must be unique. Column name ‘ActiveDate’ in table ‘dbo.Log’ is specified more than once.

Is my approach wrong? Or is there a better way to achieve the same result? Please help.

Best way to implement a to hit formula based on provided stats

There are a ton of these questions, some can get really mathy – which is fine, but I am looking for a simple way based on a few stats, I thought I came up with one, so I will share it in hopes that someone can tell me where I might be going wrong.

The goal is that the monster should, depending on how powerful you are, be able to have a chance to hit. Weaker monsters instant death to them, harder monsters possible instant death to you.

I also realize these are hard questions to answer because it is game dependant. I hope I have provided enough info for you to give some guidance.

Lets get the stats out the way:

  • To Hit Stat (Character): base stat / modded stat (ie: 12/100)
  • Accuracy / Dodge (Character): between 0.0001 – 1.0 (0.01% – 100% (can be higher))
  • Enemy Dodge / Enemy Accuracy: Between 0.0001 – 0.85 (0.01% – 85%)
  • To Hit (Monster): Dex / 10,000 – where 10k is 1k higher then max stats (9k) for monsters
  • Monsters do have a max level (if that will help)

When a character levels they get 1 point into their base stat – which is then used in conjunction with all equipment and so on to increase the modded stat additively (base stat + base stat * bonuses = modded stat)

Characters can cap out (Modded stat) Higher then 10K which might pose issues for a to hit formula. How ever at that point I would assume your skills are 100% as max level is 1000 – thus you should always be hitting

The idea I had was (based off another question asked):

(stat / modded stat) + (((accuracy - dodge) / accuracy) * 100) 

Some assumptions I made based on how I built the system:

  • Accuracy at 100%+ means you always hit
  • Dodge at 100%+ Means you always dodge.
  • Enemies dodge and accuracy do not go above 85% (they can start at 0.01% for both)
  • Monsters always use their dex (ie 12/max cap), monsters do not have modded stats
    • All Monster stats are the same, IE: if Dex is 9k all other stats, such as str, int, chr … are also 9k

There are some issues with this formula though:

  • If stat and stat mod are the same (no equipment or bonus for character only) I chose to use the stat (as opposed to stat / modded stat) so, if 11 === 11 – well, use 11. For the character (see below for example)
  • Because a character might never train (I don’t know why) Accuracy or Dodge their bonus might be 0.01% (there are equipment bonuses that can increase this to a max of 30% across all equipment with another 5% for boons (135% max) how ever in the following example we will assume you have nothing)

So:

   Level 1 (Character) = (11) + ((0.0001 - 0.0001) / 0.001) * 100) = 11 // Nothing equipped no bonuses     vs.     Rat (Enemy) = (8/10000) + ((0.0001 - 0.0001) / 0.001) * 100) = 0.0008 

This doesn’t seem right, so the player has a 11% to hit and the rat has a 0.0008% chance to hit?

Character : 100 – 11 = 82% chance to hit Rate : 100 – 0.0008 = 99.9992% chance to hit?

This doesn’t make sense to me. For context here’s a high level monster with a character that has a 95% dodge chance:

 (9000/10000) + ((0.75 - 0.95) / 0.75) * 100) = -25.7666666667 

That does not look right.

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?

I want to know if the attact on my websites were successful based on the response code from my server

My websites got attacked with a bruteforce attack and this is the log I get from my server. Just want to confirm that they didn’t got any data

 20.96.201.62 - - [20/Jul/2021:09:21:19 -0700] "POST //xmlrpc.php HTTP/1.1" 200 401 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4240.193 Safari/537.36" 

Creating a trigger to update one table’s row based on another update from a different table’s row

So, I have the following two tables:

CREATE TABLE IF NOT EXISTS `services` (   `services_id` INT NOT NULL AUTO_INCREMENT,   `staff_num` INT NOT NULL,   `health_and_wellness` INT NOT NULL,   `tutoring` INT NOT NULL,   PRIMARY KEY (`services_id`),   UNIQUE INDEX `services_id_UNIQUE` (`services_id` ASC) VISIBLE,   INDEX `fk_services_healthandwell_idx` (`health_and_wellness` ASC) VISIBLE,   INDEX `fk_services_tutoring_idx` (`tutoring` ASC) VISIBLE,   CONSTRAINT `fk_services_tutoring`     FOREIGN KEY (`tutoring`)     REFERENCES `tutoring` (`tutoring_id`)     ON DELETE CASCADE     ON UPDATE CASCADE,   CONSTRAINT `fk_services_healthandwell`     FOREIGN KEY (`health_and_wellness`)     REFERENCES `health and wellness` (`health_and_wellness_id`)     ON DELETE CASCADE     ON UPDATE CASCADE) ENGINE = InnoDB; 

and

CREATE TABLE IF NOT EXISTS `tutoring` (   `tutoring_id` INT NOT NULL AUTO_INCREMENT,   `subject` INT NOT NULL,   `staff_members` INT NOT NULL,   PRIMARY KEY (`tutoring_id`),   UNIQUE INDEX `tutoring_id_UNIQUE` (`tutoring_id` ASC) VISIBLE,   INDEX `fk_tutoring_subject_idx` (`subject` ASC) VISIBLE,   CONSTRAINT `fk_tutoring_subject`     FOREIGN KEY (`subject`)     REFERENCES `subjects` (`subject_id`)     ON DELETE NO ACTION     ON UPDATE NO ACTION) ENGINE = InnoDB; 

I want to create a trigger that updates services.staff_num whenever tutoring.staff_members is updated.. I’ve tried a couple different triggers, but each time nothing happens or I get an error.. My latest attempt was this:

DELIMITER $  $   CREATE TRIGGER UpdateStaffNum AFTER UPDATE ON collegedb.tutoring FOR EACH ROW     BEGIN         UPDATE services         SET services.staff_num = services.staff_num + tutoring.staff_members;  END; 

Which of course would be too simple too work, heh. Anyone have any suggestions on this? Thanks.

MySQL 8.0.24 – Change transaction_isolation based on incoming session

I have a requirement for a newly added DB in MySQL instance to have READ-COMMITED as the transaction isolation level. While the rest of the DBs require the default REPEATABLE-READ.

I am trying to leverage init_connect system variable to check incoming session and based on that setting the transaction-isolation at session level.

Added below line to my.cnf and restarted the service and I can see it is reflecting post reboot, but when i logged in as test user i still see default transaction isolation which means my condition in init_connect is not working. What am i doing wrong here

init_connect = "SET @@transaction_isolation = CASE CURRENT_USER() WHEN 'test@10.X.X.X' THEN 'READ-COMMITTED' ELSE @@transaction_isolation END;" 

Thanks