woocommerce – How to get $ Product_id every time $ product-> set_price happens

I am writing an API add-in. Every time a product or quantity changes in woocommerce, I need to export a new price to the server.

Also in the API there is import, which I will do through cron.
During import, the price will also change and it is necessary to provide for the closing of exports in this case.

c – This program reads from the serial port, saves it in a text file, increases the name of the file each time it is run

I want to condense it and get rid of any newbie programming error.

The code works fine, but I know it's not as elegant as it could be and I really want to improve. Your advice would be great!

I have spoken with other engineers and received basic help, but not much.

int main(){

int res = 0;        //variables to be passed to functinos
int logNum = 0;
hComm = CreateFile( "\\.\COM4",                //port name
                    GENERIC_READ | GENERIC_WRITE, //Read/Write
                    0,                            // No Sharing
                    NULL,                         // No Security
                    OPEN_EXISTING,// Open existing port only
                    0,            // Non Overlapped I/O
                    NULL);        // Null for Comm Devices

  if (hComm == INVALID_HANDLE_VALUE){ //print if COM port wont open
      printf("Error opening port");
  else {
      printf("Opening of port successfuln");   //Print to know serial port is open

//Calling necessary functions
res = fileExist();
logNum = readPort(hComm, res);
CloseHandle(hComm);//Closing the Serial Port
return 0;   //main returns 0

void serialPort(HANDLE Comms){
    BOOL Status;
    DCB dcbSerialParams = { 0 }; // Initializing DCB structure
    dcbSerialParams.DCBlength = sizeof(dcbSerialParams);

    dcbSerialParams.BaudRate = CBR_57600;  // Setting BaudRate = 9600
    dcbSerialParams.ByteSize = 8;         // Setting ByteSize = 8
    dcbSerialParams.StopBits = ONESTOPBIT;// Setting StopBits = 1
    dcbSerialParams.Parity   = NOPARITY;  // Setting Parity = None

    SetCommState(Comms, &dcbSerialParams); //Assignin serial settings to comm handle
    Status = EscapeCommFunction(Comms, SETRTS); //RTS Request to Send Signal to esentially reset Serial port (arduino)
    Status = EscapeCommFunction(Comms, SETDTR); //DTR data terminal ready, PC side terminal ready to recieve data


int fileExist(void){

int result = 0;
char testNum(10);    
char fp(80);
char file(80) = "C:/Users/jgrayjt/Documents/Logs/TestLog_";
char fileEnd(5) = ".txt";

for (int i = 1; i < 1000; i++){

    sprintf(testNum, "%d", i); //converting testNum as int to string
    //adding test num to file dir
    strcpy(fp, file);       //adding strings to make file name
    strcat(fp, testNum);
    strcat(fp, fileEnd);
    printf("%s", fp);

        /* Check for existence */
        if((_access(fp, 0 )) != -1 ){           //Function to check if file exists
            printf( "nFile logs existsn" );
         else { //if file doesnt exists 
          printf("nFile doesnt existn");
          result = i; //set result to equal current value for i
return result;  //send file num to next function

int readPort(HANDLE Comms, int testNum){
//time_t rawtime;
//struct tm * timeinfo;
//time (&rawtime);
//timeinfo = localtime (&rawtime);
char word(14) = "Test Finished";  //Text to look for
char SerialBuffer(256);//Buffer for storing Rxed Data
DWORD NoBytesRead;  //set type for NoBytesRead
char Num(10);
sprintf(Num, "%d", testNum);    //convert test num to string
char str(80);
//char buf(100);
char *file = "C:/Users/jgrayjt/Documents/Logs/TestLog_";
//char tandd(8) = "_%x_%X";
char fileEnd(5) = ".txt";
//strftime(buf,64, "_%x_%X", timeinfo);
strcpy(str, file);      //adding strings to make file name
strcat(str, Num);
//strcat(str, buf);
strcat(str, fileEnd);
printf("%s", str);

FILE *fp;    //create file pointer

fp = fopen(str, "w");   //create file to write serial data to

    do { //start do while loop
        ReadFile(Comms,           //Handle of the Serial port
                 SerialBuffer,       //
                 sizeof(SerialBuffer) -1,//Size of Buffer
                 &NoBytesRead,    //Number of bytes read

        SerialBuffer(NoBytesRead) = ''; //Specify null terminator to stop data rxing strangly

        printf("%s", SerialBuffer); //Print rx'd data to CMD
        fprintf(fp, "%s", SerialBuffer); //Save rx'd data to txt file

        char *fin = strstr(SerialBuffer, word); //Find 'search' in SerialBuffer and assign to 'fin'

        //if fin has data then close Serial and close/save file
        if (fin != NULL){
            printf("Results Successfully logged n r n r");
            fclose(fp);         //close file
            fp = NULL;          //set file pointer to equal null to break from the loop
    } while (fp != NULL);  //while, from do while loop
return testNum; //return testNum for use in another function

void parseFile(int fileNum){

char Num(10);   //set Num as char and give extra memory
sprintf(Num, "%d", fileNum); //Convert filenNum to string
char dir(80);   //set dir as char and give extra memory
char *file = "C:/Users/jgrayjt/Documents/Logs/TestLog_";
char fileEnd(5) = ".txt";
strcpy(dir, file);      //adding strings to make file name
strcat(dir, Num);
strcat(dir, fileEnd);
printf("%s", dir);
FILE *fp1;      //create file pointer
char str(512);  //string to store data read from log file
const char fail(5) = "FAIL";    //text to look for
const char testnum(23) = "Test Iteration";     //text to look for
char *ret;  //create char variables
char *num;

fp1 = fopen(dir , "r");  //Open file to read

    if (fp1 == NULL){ //if you cant open file, print 
        printf("File open fail");

    //Loop to find test number and fail strings  
    while( fgets (str, 512, fp1)!=NULL ) { 
        num = strstr(str, testnum); //find test num in string and assign to num
        ret = strstr(str, fail);    //find 'fail' in string and assign to ret

    if (ret != NULL && num != NULL){    //if both variables have data then print num
        printf("n r %snr", num);  //num has been given enough mem to include the fail that comes after it

fclose(fp1);    //close/save fil

time – What are the accepted annotations of Fail2ban duration?

I have been looking for the accepted duration formats for the Fail2ban Jail configuration file (it may not be exclusive to F2B).

I want to make sure which suffixes are valid when expressing an amount of time.

The F2B configuration is not explicit regarding this: https://www.fail2ban.org/wiki/index.php/MANUAL_0_8#Jails

So far, it seems that the following annotations are accepted: m, h, d

Can anyone point me to the full list of such suffixes?

Using Ultimate cron to set a specific time to execute a module function, but it does not work as expected

I have set the definitive cron working time once a day but it works to hourly because another defect site cron It is working every hour.

This code works in production, but not according to crontab time, that is, once a day. It is running every hour, I checked the list of cron jobs on the acquia server, there is a set of cron jobs called "site cron" that runs every hour.

/ **
* Implements hook_cronapi ().
* /
demo_cronapi function ($ op, $ job = NULL) {

$ items (& # 39; monitor_run & # 39;) = (
& # 39; description & # 39; => & # 39; Publish solution & # 39 ;,
& # 39; planner & # 39; => (
& # 39; name & # 39; => & # 39; simple & # 39 ;,
& # 39; simple & # 39; => (
& # 39; rules & # 39; => (& # 39; 0 & # 39; => & # 39; 0 7 * * * & # 39;),

return $ items;

/ **
* Activate event to generate report.
* /
monitor_run function ($ job) {
// logical code.

7 – How to reduce TTFB time for the drupal website

My website takes a long time to load the homepage and other internal pages. Actually, the home page of the website has many images and videos. The home page has almost 85 images and 18 videos as a video slider.

I am also using CDN for the Drupal project.

I tried to compress the image and the video. I have also enabled the Drupal cache and I add all the JS and CSS, but it doesn't affect the speed much.

TTFB takes almost 7-8 seconds during page load.

Any ideas?

End time «youtube.com/watch/»

I clearly remember seeing a parameter on "youtube.com/watch/" that indicated when I should have a video stop playing, as much as the "t" parameter indicated the starting point. It had a name of several letters of some kind and took a value in seconds just like the "t" parameter. I have some videos that will only be played on "youtube.com/watch/" and it seems unfair that these videos cannot also be played with an endpoint. Any information you can provide will be greatly appreciated.

complexity theory: polynomial time algorithm for vertex coverage

I am aware that the vertex cover problem is full NP and I have read the reduction of the clique problem.
I have written an algorithm that determines the minimum vertex coverage of a graph in polynomial time. Could someone explain what is wrong in my thinking?

I have attached an image of the algorithm and an example. enter the description of the image here

unreal 4 – How to set the execution time of an animation based on attack speed?

According to an answer I received on this question:

How to make an action take place only after an animation has been executed?

I am using notifications in animations to perform certain commands / actions.

See in the documentation:


Before resorting to this site, I researched somewhere else about the modification of the animation speed and the closest question I found was this:


Simply by changing the animation speed, I know how to do it, but I want to control its runtime. Something like determining how long you have to play the animation.

In the image below I show more or less the scenario I have:

enter the description of the image here

Note that the notification occurs at the end of the animation (where I apply the damage).

Then, depending on the speed I set for the animation to take place, each time the notification ends, applying the damage.

It turns out that the animation does not necessarily have the exact duration of an attack that begins when the other ends (the image below will make it easier to understand):

enter the description of the image here

There is one more scenario that I imagined.

In the latter case, assuming that the animation is (usually) of 1 second duration, and the character has the maximum attack speed (I set the maximum to 2 attacks per second). Then the animation will run 2 times faster:

enter the description of the image here

But the attack speed will not always be a "simple" number, I would like to know how to calculate / configure the time so you don't have problems when the attack speed is any number.

I want to know how to configure the execution time of the animation and a time interval between the execution of the animation.

Time complexity: variant of several sets of known algorithms of subset summation problem

I have been working on the time analysis for a solver that I designed for the subset summation problem (multiple set variant), and determined that its time complexity depends on the count of repeated elements in the input.

The complexity of time is $ O (2 ^ {n / 2} cdot 0.75 ^ { frac {d / 2} {n}}) where $ d = $ # of duplicates in the input instance (assuming both $ n $ Y $ d $ they are even)

For example when $ d = n / 2 $ so:

$ O (2 ^ n / 2} 0.75 ^ { frac {n / 4} {n}}) approx. Or (1.4142 0.93) approx. O (1,316 ^ n) $

In addition to asking for comments, I am also looking for other known algorithms with similar behavior to compare approaches (I searched for them but did not find anything so far …)

Full server is delayed at a specific time each day and uses 90% + CPU (but not exclusively at that time)

Good afternoon,

This can be long since it is a problem that I have been fighting for a long time, but I desperately need help and I hope someone has some ideas for me. My server technicians do not have much response apart from some ideas about software change.

We have a dedicated machine with around 150 active websites (all wordpress) and email addresses for some of them. Every day around 4 pm, all websites begin to slow down, mail is not delivered in a timely manner (my tests show that they arrive an hour later) and when SSH enters the server and runs Top, it seems that almost all A single website is blocking the server at the same time (even development sites where there should be no real traffic). We have been dealing with this for quite some time and have tried several things that we think could be to blame.

Each site has the same set of add-ons, Wordfence for security, Backupbuddy for backups. So, in our first round of changes, we discovered that Wordfence was running scans at this time of day, so we entered each website and deactivated the WordFence (not ideal) scan function, we thought this had helped, but that It may have had been a coincidence when the problem started again.

Then we started to look deeper into the top command and discovered that when it crashed every day all sites were running cron jobs and some of them seemed to be connected to the backup plug-in, so we went to each website and deactivated our plug-in. backup. That seemed to help for a day, but again it can be a coincidence. As the problem continues to happen, and even worse in recent days.

Now my servers keep saying that they are just random processes and the server is getting overloaded, but why every day at the same time? You can see the running processes jump from 14 or so to 50.60.80 etc.

Now, when you look at the top command when it's happening, it doesn't seem to be cron jobs, it just says random ones like /index.php and /wp-login.php. The normal things you would expect to see, but they are only very bad when it happens, and in places that I know are not receiving visitors.

My servers are suggesting moving to Cloud Linux, which I don't mind doing, but I wanted to get some tips here first, since it seems that nobody has a clue and is just shooting in the dark.

Has anyone seen anything like this before? My knowledge with all this is limited and self-taught, but all help is greatly appreciated.

Restarting HTTP and SQL used to solve the problem, but many times it simply comes back up after a few seconds.

I will try to give more details about our specific situation.

150 (ish) sites, all running wordpress, not all updated (since some have custom add-ons or outdated themes and would require work that the client is not willing to do to correct the update). Most run in PHP 5.6 (another thing I need to fix, but it takes time that we don't have).

The unit is 90% full, which I know is not an idea, but its repair is expensive.

The server specifications are:
Intel Xeon
E3-1270 V2
3.5 GHz
Four cores
16 gb of ram
800 gs ssd
backup mirror unit

Cpanel / WHM / MySQL

I can provide any other necessary information, I just need to get to the bottom of this since my clients are not happy.

Should I be experiencing this kind of problem with those server specifications and so many sites? Or is something else happening?

Is obsolete PHP my problem, or websites, or disk space? I just don't know what would cause more than 100 sites to hit the server at once and delay it.

Thanks in advance for any help you can provide.