I try to implement the GOOGLE document AI API

Good morning colleagues, I try to implement the document AI api to be able to compare a document to see if it comes with phrases to know if the document is valid.

I am using nodejs to implement the document AI api.

and the document I receive is a pdf that is sent through an input file

This is the error that I get:
Error: Error: 3 INVALID_ARGUMENT: Invalid resource field value in the request.

{
  code: 3,
  details: 'Invalid resource field value in the request.',
  metadata: Metadata {
    internalRepr: Map(4) {
      'endpoint-load-metrics-bin' => [Array],
      'grpc-server-stats-bin' => [Array],
      'google.rpc.errorinfo-bin' => [Array],
      'grpc-status-details-bin' => [Array]
    },
    options: {}
  },
  note: 'Exception occurred in retry method that was not classified as transient',
  statusDetails: [
    ErrorInfo {
      metadata: [Object],
      reason: 'RESOURCE_PROJECT_INVALID',
      domain: 'googleapis.com'
    }
  ],
  reason: 'RESOURCE_PROJECT_INVALID',
  domain: 'googleapis.com',
  errorInfoMetadata: {
    service: 'documentai.googleapis.com',
    method: 'google.cloud.documentai.v1.DocumentProcessorService.ProcessDocument'
  }
}

This is the code in nodejs that I use to authenticate myself and to make the comparison, I hope you can help me.

//documentAI

const { DocumentProcessorServiceClient } = require('@google-cloud/documentai').v1;

const keyFilename = path.join(__dirname,"../../src/credentials/documentApp.json");

// Configuración del cliente de Document AI
const client = new DocumentProcessorServiceClient({
  keyFilename: keyFilename,
});

async function procesarDocumentoConAI(document) {
    try {
        const request = {
            parent: 'projects/c26b6829b968a72c/locations/us',
            processorId:'c26b6829b968a72c',
            inputConfig: {
                content: document,
                mimeType: 'application/pdf',
              },
          };

        const [response] = await client.processDocument(request);

        if (response && response.text) {
            const text = response.text;
            const isINE = text.includes('INE') || text.includes('Instituto Nacional Electoral');

            if (isINE) {
                console.log('El documento contiene una INE mexicana.');
                return true;
            } else {
                console.log('El documento no contiene una INE mexicana.');
                return false;
            }
        } else {
            console.log('No se encontró texto en el documento.');
            return false;
        }
    } catch (error) {
        console.error('Error:', error);
    }
}

InfoWindow is displayed 2 times instead of once

To explain what I am doing, I want to display the InfoWindowF when I click on a marker on the map, same thing when I click on store locations on the list of all the stores.
The issue I am facing, is when I click on a Marker, the InfoWindowF will be displayed 2 times, that means both conditionals renders are true, I only want to display the InfoWindowF once, either when the marker is clicked or when the store location is clicked.
Code:

const [selectedMarker, setSelectedMarker] = useState<any>(null);
  const [infoWindowContent, setInfoWindowContent] = useState<string | null>(
    null,
  );
  const [isSelectedStore, setIsSelectedStore] = useState<any>(null);
  const [SelectedInfoWindowContent, setSelectedInfoWindowContent] = useState<
    string | null
  >(null);
  const handleMarkerClick = (location: Location) => {
    setSelectedRegion({
      region: location.country,
      geoLocation: location.geo,
      id: location._id,
      name: location.name,
    });
    setSelectedMarker(location);
    setInfoWindowContent(location.name);
  };
  useEffect(() => {
    if (selectedStore) {
      setIsSelectedStore(selectedStore);
      setSelectedInfoWindowContent(selectedStore.name);
    }
  }, [selectedStore]);
return(
 <GoogleMap
     ...
    >
      <Marker ... />
     {selectedMarker && (
        <InfoWindowF
          position={selectedMarker.geo}
          onCloseClick={() => setSelectedMarker(null)}
        >
          <div>{infoWindowContent}</div>
        </InfoWindowF>
      )}
      {!selectedMarker && isSelectedStore && SelectedInfoWindowContent && (
        <InfoWindowF
          position={isSelectedStore.geoLocation}
          onCloseClick={() => setIsSelectedStore(false)}
        >
          <div>{SelectedInfoWindowContent}</div>
        </InfoWindowF>
      )}

This is where the problem is coming from :

useEffect(() => {
    if (selectedStore) {
      setIsSelectedStore(selectedStore);
      setSelectedInfoWindowContent(selectedStore.name);
    }
  }, [selectedStore]);

how can I fix this

How to properly setup FastSpring Popup Storefronts for Monthly and Yearly subscription?

I am currently trying to use FastSpring to sell subscription membership for my SaaS. I am trying to do this by implementing their Popup Storefront feature into my website’s pricing page. What I wanted on this page is for users to be able to choose AND switch whether he/she wanted to subscribe to either Monthly or Yearly plan.

I was able to display and make the buttons to display the popups but somehow when/if I clicked both of the buttons, the checkout popup added the Monthly&Yearly pricing together instead of on or the other:

enter image description here

Here’s my code that I have simplified to make it easier for someone to read and help out:

<script
    id="fsc-api"
    src="https://sbl.onfastspring.com/sbl/0.9.5/fastspring-builder.min.js"
    type="text/javascript"
    data-storefront="readermode.test.onfastspring.com/popup-readermode"
    data-continuous=true
>
</script>
<div class="container text-center">
    <br/><br/>

    <h1>Subcribe with Fastspring</h1>

    <br/>

    <div class="row">
        <div class="col-md-6">
            <div class="pricing">
                <h3>Monthly Plan</h3><br/>
                <button class="btn btn-md btn-primary btn-block" data-fsc-item-path-value='reader-mode-premium-monthly' data-fsc-action="Reset, Add, Checkout">Subscribe monthly</button>
            </div>  
        </div>
        <div class="col-md-6">
            <div class="pricing">
                <h3>Yearly Plan</h3><br/>
                <button class="btn btn-md btn-secondary btn-block" data-fsc-item-path-value='reader-mode-premium-yearly' data-fsc-action="Reset, Add, Checkout">Subscribe yearly</button>
            </div>  
        </div>  
    </div>  
</div>

Pointer pressure is 0 in Safari in pointer events despite button being pressed

I implemented pointer events on my website. I use the “pressure” property to check if a button is currently pressed. The code goes something like this:

let element = document.querySelector("#some_id"),
pointer = function(e) {
  if (e.pressure>0) console.log("ok");
};
element.onpointermove = pointer;

When I drag on the #some_id element, Chrome, Firefox, and Edge all show “ok” in the console. But Safari doesn’t. I have tested it on two MacBooks (when I use Chrome on a MacBook, everything works fine, so it is not a hardware issue). Why does it happen? How do I check if the button is pressed in Safari?

I tried looking for answers on the Internet but surprisingly “safari pointer down pressure 0” yielded no relevant results. Am I the only person having this issue?

Puppeteer JS page.eval won’t trigger within MutationObserver

Currently, I’m trying to print to console a player’s bet size whenever a new bet is made on pokernow.

My code is able to scrape the players in a lobby and pull their current bet amount, when the code first runs. However, I’m trying to recognize whenever a player makes a new bet and print it to console. With the MutationObserver, I can recognize when a specific player div tag changes but I’m not able to re-evaluate that div tag to scrape their current bet.

How can I run a page eval within the MutationObserver?

My code executes this line “printMe(playerNumber + “yum”);” , but doesn’t hit the next printMe statement.

If I reverse the order and do page.eval then printMe(newStuff) first, the printMe(playerNumber + “yum”) never prints to console.

const puppeteer = require("puppeteer");

const playerMap = {};

async function run() {
  const browser = await puppeteer.launch({
    defaultViewport: false,
    headless: true,
    //saves cookies for saving captcha
  });

  const page = await browser.newPage();
  await page.goto("https://www.pokernow.club/games/pgl4O2TEDE9Tge9k2ltFDj7Fa");

  await page.exposeFunction("printMe", (lul) => console.log(lul));

  await page.exposeFunction("getPlayerNumber", (playerTagClassName) => {
    console.log(`playerTagClassName is ${playerTagClassName}`);
    const classNameTokens = playerTagClassName.split(" ");
    return Promise.resolve(classNameTokens[1]);
  });

  await page.evaluate(async () => {
    const playerTags = document.querySelectorAll(".seats .table-player");

    for (const playerTag of playerTags) {
      if (!playerTag.className.includes("table-player-seat")) {
        const playerNumber = await getPlayerNumber(playerTag.className);

        const observer = new MutationObserver(async (mutations) => {
          for (const mutation of mutations) {
            if (mutation.type == "childList" || mutation.type == "subtree") {

              printMe(playerNumber + "yum");

              const newStuff = await page.evaluate(() => {
                return Promise.resolve("test");
              });

              printMe(newStuff);
            }
          }
        });

        observer.observe(playerTag, { childList: true, subtree: true });
      }
    }
  });
}

run();

I’ve tried calling page eval within an exposedFunction similar to how printMe functions, but that also didn’t work.

What does this raw property mean in v-for directive on vuetify?

I saw a code block on vuetify documentation but i don’t really get why they use the raw property in v-card component? Is that a special property?

Can anyone help me understand that?

Thank you.

<v-data-iterator :items="items" :page="page">
  <template v-slot:default="{ items }">
    <template
      v-for="(item, i) in items"
      :key="i"
    >
      <v-card v-bind="item.raw"></v-card>

      <br>
    </template>
  </template>
</v-data-iterator>

export default {
  data: () => ({
    page: 1,
    items: Array.from({ length: 15 }, (k, v) => ({
      title: 'Item ' + v + 1,
      text: 'Lorem ipsum dolor sit amet consectetur adipisicing elit. Commodi, ratione debitis quis est labore voluptatibus! Eaque cupiditate minima, at placeat totam, magni doloremque veniam neque porro libero rerum unde voluptatem!',
    })),
  }),
}

I checked this documentation but couldn’t understand it.

https://vuetifyjs.com/en/components/data-iterators/

P5 Canvas not showing on mobile device (iOS)

I don’t have the portion causing the issue, but the code is available on the website being worked on.

on an iPad device it works mostly, aside from misalignment on loading the page which corrects itself upon reorientation of device. On computer, the website functions responsively at all scales on the browsers/OS I tested. (Firefox, Chrome, Edge, Safari[Mac]) On my iPhone I get a white box where the canvas should be on the page load, which disappears to an empty page.

I tried looking for the problematic cause, but can’t find what the cause of the incompatibility is

How to zoom and scroll an element

I’m a newbie in html/css/JS development, I’m trying to learn for hobbyist purpose.
I’m trying to create a page with an <svg> element inside a <div> and I’m looking for a way to pan with scrollbar and zoom its content without using external libraries (because I’d like to understand the mechanism behind first).

Here below the code of my page with a couple of buttons to zoom in and out a blue square drawn with a <rect> element.
More or less it works but when I’m zooming in and scroll bars appear, when I drag them I’m not able to see completely the square, it looks clipped out if the viewport.

I also tried to play with the viewBox attribute in the but probably I didn’t fully got how it works, maybe that’s the right way to go….

How could I modify this code to obtain the result I’m looking for in a robust and elegant way?

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0px;
            padding: 0px;
        }

        #container {
            width: 80lvw;
            height: 80lvh;
            border: 1px solid black;
            justify-content:left;
            overflow: auto;
            --scale-k: 1;
        }

        #svg {
            transform: scale(var(--scale-k));
            transform-origin: center;
        }
    </style>

    <script>

    </script>
</head>

<body>
    <div id="container">
        <svg id="svg" xmlns="http://www.w3.org/2000/svg" version="1.1" height="100%" width="100%" stroke="black"
            stroke-width="3" fill="transparent">
            <rect x="100" y="100" width="100" height="100" fill="blue" rx="20" ry="20" />
        </svg>
    </div>
    <button type="button" id="zoom-in" style="z-index: 100000">zoom in</button>
    <button type="button" id="zoom-out" style="z-index: 100000">zoom out</button>
</body>

<script>

    const container = document.querySelector('#container');
    const svg = document.querySelector('#svg');

    let zoomF = window.getComputedStyle(container).getPropertyValue('--scale-k');
    console.log(zoomF);

    const btnZoomIn = document.querySelector('#zoom-in');
    const btnZoomOut = document.querySelector('#zoom-out');

    btnZoomIn.addEventListener('click', (evt) => {
        zoomF *= 1.1;
        resize();
    });

    btnZoomOut.addEventListener('click', (evt) => {
        zoomF /= 1.1;
        resize();
    });

    function resize() {
        let svgWidth = parseInt(svg.getAttribute('width'));
        svg.setAttribute('width', `${(svgWidth * zoomF)}%`);
        let svgHeight = parseInt(svg.getAttribute('height'));
        svg.setAttribute('height', `${(svgHeight * zoomF)}%`);
        container.style.setProperty('--scale-k', zoomF);
    }


</script>

</html>

How to put a username session variable on a page with an already started session

Ok, so in my code, I have an index.php page with username variable in it that has a username session to call the variable, but it’s in the same file that has it’s own session opened up as well and it plays a role in my website functionality. I’m continually getting these errors on my page, Warning: Undefined variable $username in C:xampphtdocsWebsiteindex.php on line 15, Warning: Cannot modify header information – headers already sent by (output started at C:xampphtdocsWebsitefooter.php:1) in C:xampphtdocsWebsiteindex.php on line **7
**
Here is my index.php code:

<?php
include_once "safe-header.php";

$username = isset($_SESSION['username']) ? $_SESSION['username'] : '';

if (empty($username)) {
    header("Location: login.php");
    exit();
}
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
<div class="upload-container">
    <p class="username"><?php echo $username;?></p>
    <div class="account-options">
        <a href="update-profile.php" class="update-profile">Update Profile</a>
        <a href="serverside/logout-server.php" class="logout-btn">Logout</a>
    </div>
</div>



<?php
include_once "footer.php";
?>

I tried multiple times rephrasing it so I could fit the $username variable into my file, but it’s not working no matter what I’ve tried. I’m trying to print the $username that the user set in the login and signup page to the screen.

Cannot find where nunber becomes NaN?

I have a variable that holds the product of multiplication. The two variables that are the factors in this multiplication are numbers that I have verified as false with isNaN(). One variable is from a constant and the other one is from the user input.

I’ve tried using Number() and parseFloat() on this variable but neither helped.

I have included a conditional ternary in the div that holds the product so you can see if a number is returned or if the product is not a number.

Can someone tell me where the problem is and how to correct it?

I have replicated the problem in the included snippet.

const space_types = {
  option1: {
    space: 'Option 1',
    kwhuse: 9.4,
    kwhcost: 0.92,
    fueluse: 30.8,
    fuelcost: 0.21,
    othuse: 62.7,
    othcost: 1.17
  }};
    
const calculate_utilities = {
    electric: { total_usage:0, total_cost: 0 },
        fuel: { total_usage:0, total_cost: 0 },
 electric1: { unit_rate: 0, unit_cost: 0, unit_usage: 0, total_usage: 0, total_cost: 0 },
         fuel1: { unit_rate: 0, unit_cost: 0, unit_usage: 0, total_usage: 0, total_cost: 0 }    
};

$(function() {
  $("#area").trigger('focus');
    $("#area").blur(function() {
        var type = $("#space_type option:selected").val();
        var area = $("#area").val();
        calculate_utilities.electric1.unit_cost = space_types[type].kwhcost* area;
    calculate_utilities.electric.unit_cost= calculate_utilities.electric.unit_cost+calculate_utilities.electric1.unit_cost;
        $("#totals").html(
    isNaN(calculate_utilities.electric.unit_cost) ? 
      "TRUE: This is not a number" : 
       calculate_utilities.electric.unit_cost
    );
    });
});
.test {
    display: flex;
    flex-direction: column;
    width: 26%;
    line-height: 22px;
  font-size:14px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="test">
    Space Type: 
    <select id="space_type" name="space_type">
        <option value=""></option>
        <option selected value="option1">Option 1</option>
    </select>
    Area:
    <input id="area" type="number" value="100000">
    Totals:
    <div id="totals">0</div>
</div>

Javascript & the dom Form submission (Web Developer student)

I am doing a level 5 diploma in web development and going through the Javascript module.

I have been given a task, When I run the task I get the messages I should in the console but from my automated educator an error, I have ran it through AI and they tell me I have the correct code, I am guessing it is something small I have missing, but Id like to fix it and find out what I need to to learn from this.

Here is my task

Declare a variable form assign it the HTML element with the id of “contact-form”

  1. Add a submit event handler to the form that calls a function named: handleSubmit

  2. Create a function called handleSubmit, which takes a single parameter named: event

  3. The handleSubmit function should:
    Prevent the default submit behavior.
    console.log(“submitting form…”)
    Retrieve the message entered into the element with id of “message”
    And assign it to the variable test
    console.log(test)
    submit the form
    console.log(“form submitted”)

I have come up with this code so far, I am stumped, could anyone help me understand where I am going wrong so I can learn from this? Thank you for your time.

    let test; // assignment to this variable is to be done inside the function you create
    // write your code below

    let form = document.getElementById("contact-form");
    form.addEventListener("submit", handleSubmit);

    function handleSubmit(event) {
       event.preventDefault();
       console.log("submitting form...");
       let test = document.getElementById("message").value;
       console.log(test);
       form.submit(); 
       console.log("form submitted");
    }



I have tried

event.target.submit();
event.target.dispatchEvent(new Event('submit'));
document.form.submit();

And some methods AI has given me, but they create more mistakes for the task needed. AI says my code is correct when checked next to the tasks given.

I get this error
⚠ Hint
Does the function handleSubmit work? Does it prevent the default
event? Does it read the value from the textarea element and assign
it to a variable? Does it submit the form?

How to intercept fivem js api request using BurpSuite

i want to know how to intercept FiveM NUI Js API request using BupSuite the request looks like this

fetch("http://xxx.xxx.xxx.xxx:xxxx/purchase", {
   method: "POST",
   headers: {'Content-Type': 'application/json'}, 
   body: JSON.stringify(data)
}).then(res => {
   console.log("Request complete! response:", res);
   this.titel = "";
   this.beschreibung = "";
   this.telefonnummer = "";
   this.preis = "";
   this.currentPage = 0;
   this.getInserate();
});

i try to intercept port 13172 and 30120 but it didnt capture the fivem nui request .

500 Internal Server Error in few routes (Next JS)

The pages work in local dev environment, but not on the deployed URL.

The pages under dynamic slug are SSR and they work fine. But the statically generated ones are going 500 internal server error on deployed url. not sure what is causing the issue.

enter image description here

my next.config.js : only has

{
reactStrictMode: true,
trailingSlash: true,
}

Any help here is much appreciated. Thanks.

enter image description here
All the pages should work as expected in local

okay sir, help me for work on tasks that I can’t solve about property=”og.image” on header.php

please visit to my website :

https://safiramedia.com/headset-headphone-handsfree-jbl-c100si-mic-extra-bass-stereo-earphone-safiramedia

and then click “resource page” on your web browser, in this case, please open browser same like me google chrome.

in there , look script meta :

Notice: Array to string conversion in
/home/u1495966/smoscart21/storage/cache/template/e3/e3e7b03d12fa73f931e03a7e90031b93d387fae679b23ab0e41c0efdcda51ad3.php
on line 64Array” />

What part should I do to repair it? sory if my english lang too bad

you need to know that I will reveal to the public about the script that I made myself, if you are willing to help solve my problem, let’s discuss.
This opencart is provided to the public for free? a legal open source platform that we can customize, why should there be any information covered up?

Satya From Indonesia [ Opencart 3.0.3.7 ]

I NEED YOUR HELP MASTER OPENCART 3.0.3.7