How to Implement Google, facebook and instagram, Authentication in React 18.18.1?

I’m working with React 18.18.1 and trying to implement Google, facebook and instagram Authentication in my project. I attempted to install react-google-login and @react-oauth/google, but both threw errors during installation.

I am looking for a solution that directly integrates Google login with OAuth. If needed, I’m also open to using Firebase Authentication for Google login, but I would like to understand my options. is there another options for these authentication.

What are the signs of a cheater

I think my boyfriend is cheating on me he always hides his phone I have tried spying apps tracking apps and don’t know what else to do I need a good spy tracking app that monitors his phone calls text messages and social media

in this code first 3to 5 line of code i does not understand and app.use and app.post also theses line of code can’t understand [closed]

imimport express from “express”; import bodyParser from “body-parser”; import {dirname} from “path”; import {fileURLToPath} from “url”; const __dirname = dirname(fileURLToPath(import.meta.url));

const app = express(); const port = 3000; app.use(bodyParser.urlencoded ({ extended: true })); app.get(“/”, (req, res) => { res.sendFile(__dirname + “/public/index.html”); }); app.post(“/submit”,(req,res) => { console.log(req.body); })

app.listen(port, () => { console.log(Listening on port ${port}); });

How to use a variable in a JSON parse [duplicate]

var Price = responseParsed.products.wheat.quick_status.buyPrice;

However I need to access different items dynamically.

It basically needs to end up like this.

var Price = responseParsed.products.(variable).quick_status.buyPrice;

Or

var variable = 'products.wheat.quick_status.buyPrice';
var Price = responseParsed.(variable);

Prevent Error Boundary from Replacing UI and Instead Show an Alert

I’m using an Error Boundary in my React application to catch errors in child components. However, whenever an error occurs, the entire component tree under the Error Boundary gets replaced by the fallback UI, resulting in a blank screen.

Instead of completely unmounting the previous component, I want to:

Keep the existing UI intact
Show an alert or a popup notifying the user that there was an issue loading the next component
Ensure the app remains usable despite the error
Is there a way to achieve this in React, where the Error Boundary catches the error but does not unmount the existing UI? Any insights or best practices would be greatly appreciated!

“Insert record if not present ” logic is not working for some request if we hit 100 request per second in Node Express Application

I have made an POC application, where the requeirment is to insert the reocord if ther is no record present in the db. This logic is not working if we hit 100 request per second with same data. For new data, there is 5-10 records are being created in table, though according to logic only there is one record shoulb be created for new record. The details of this application is below:

Language: Node JS

Framework : Express JS

Database: Oracle DB.

Please find the code

app.post('/v1/test',async function(req, res) {
    const searchInitialStartTime = new Date();
    console.log(req.requestUID);
    try{
        let dbResult = await dao.getSerachDate(req.body);
        console.log(req.requestUID,dbResult.rows.length);
        if(dbResult.rows.length == 0){
            await dao.insertSerachDate(req.body);
        }
        await utils.logSummeryDetailsInDB(null, "test", "200");
        return res.json(dbResult.rows);
    } catch(e){
        console.log(e);
        res.status(400).send("Error");
    }
}
);

How to set a boundary for drag events using vanilla javascript?

I have made a simple drag and drop game. I want to ensure the user cannot move the draggable elements outside of the bounds of the containing div (class=”fill_in_the_gaps–container) either by touch or mouse movement. I do not want to use any libraries. How do I achieve this using vanilla javascript?

// //backend produces an array with answers
// const gapFillAnswers = ["goods & services","opportunities","water","sports car","tangible","intangible","entrepreneurs"];
const answerSpaces = document.querySelectorAll(".fill_in_the_gaps--answer_space");
const answerContainer = document.querySelector(".fill_in_the_gaps--answers_container")
const answerWords = document.querySelectorAll(".fill_in_the_gaps--answers");


answerContainer.addEventListener('drop',dropHandler);
answerContainer.addEventListener('dragover',dragOverHandler);

answerWords.forEach(element =>{
    element.addEventListener('dragstart',dragStartHandler);
    element.addEventListener('dragend',dragEndHandler);
   
})

answerSpaces.forEach(element =>{
   
    element.addEventListener('drop',dropHandler);
    element.addEventListener('dragover',dragOverHandler);
    element.addEventListener('dragenter',dragEnterHandler);
    element.addEventListener('dragleave',dragLeaveHandler);
})

function dropHandler(e){

    //create a pointer to the original dragged element using the dataTransfer object this willl then be appended to the drop space
    if(e.target.classList.contains("fill_in_the_gaps--answer_space")){
     e.target.style.border = "none";
    }
   
    e.preventDefault();
    const element_to_be_dropped = document.getElementById(e.dataTransfer.getData("text"))
    e.target.append(element_to_be_dropped);
   
}

function dragOverHandler(e){
    e.preventDefault();  
}

function dragStartHandler(e){
    e.target.style.opacity = "0.5";
    e.dataTransfer.setData("text",e.target.getAttribute("id"));
}

function dragEndHandler(e){
    e.target.style.opacity = "1";
}
function dragEnterHandler(e){
   e.target.style.border = "2px dotted green";
}
function dragLeaveHandler(e){
    e.target.style.border = "none";
}
*{
    box-sizing: border-box;
}

:root{
    --blue: #000724;
    --pink: #DC398D;
    --yellow:#FEBD31;
    --green:#36F906;
}

body{
    background-color: var(--blue);
   
}


.fill_in_the_gaps--container{
    padding: 1rem;
    border-radius: 0.5rem;
    border-color: var(--pink);
    border-width: 5px;
    border-style: solid;
    background-color: whitesmoke;
}


.fill_in_the_gaps--answers_container{
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    overflow-y: scroll;
    padding: 1rem;
    border:2px dotted gray;
}

.fill_in_the_gaps--answers{
    display: inline-block;  
    white-space:nowrap;
    margin-left: 15px;
    margin-right: 15px; 
    
   
}

.fill_in_the_gaps--answer_space{
    display: inline-block;
    background-color: var(--yellow);
    width:8rem;
    height: 1rem;
    margin-top: 2px;
    margin-left: 2px;
    margin-right: 2px;;
    text-align: center;
    padding-bottom:2px;
    vertical-align:middle;
   
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.2.4/gsap.min.js" defer ></script>
    <script src="app.js" defer></script>
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <div data-board="aqa" data-level="gcse" data-subject="business" data-unit="1.1" data-type="fill_in_the_gaps" class="fill_in_the_gaps--container">
        <p class="fill_in_the_gaps--main_text">
            A business is an organisation that produces<span id="answer_space_0" class="fill_in_the_gaps--answer_space"></span>.Often businesses are setup to take advantage of business
            <span id="answer_space_1" class="fill_in_the_gaps--answer_space"></span>. Many businessess sell items that people need, some businesses sell items that people want. An example of a need is 
            <span id="answer_space_2" class="fill_in_the_gaps--answer_space"></span>. An example of a want is a <span id="answer_space_3" class="fill_in_the_gaps--answer_space"></span>. Goods are an example of 
            <span id="answer_space_4" class="fill_in_the_gaps--answer_space"></span>items. Services are an example of <span id="answer_space_5" class="fill_in_the_gaps--answer_space"></span>items. People who start up a business are known as 
            <span id="answer_space_6" class="fill_in_the_gaps--answer_space"></span>their reward for taking a risk is profit.
        </p>
        <div class="fill_in_the_gaps--answers_container">
            <span id="answer_0" draggable="true" class="fill_in_the_gaps--answers">goods & services</span>
            <span id="answer_1" draggable="true" class="fill_in_the_gaps--answers">opportunities</span>
            <span id="answer_2" draggable="true" class="fill_in_the_gaps--answers">water</span>
            <span id="answer_3" draggable="true" class="fill_in_the_gaps--answers">sports car</span>
            <span id="answer_4" draggable="true" class="fill_in_the_gaps--answers">tangible</span>
            <span id="answer_5" draggable="true" class="fill_in_the_gaps--answers">intangible</span>
            <span id="answer_6" draggable="true" class="fill_in_the_gaps--answers">entrepreneurs</span>
        </div>
    </div>
</body>
</html>

Generating EPS Files with Clipping Paths that Photoshop Correctly Recognizes as Vector Paths

I’m working on a web application (Vue.js) that removes backgrounds from images. An important component is exporting EPS files with clipping paths that are correctly recognized in Adobe Photoshop.

The Problem:

Despite multiple implementations, the path in the EPS file is not recognized as a vector path in Photoshop. The file opens correctly, but the path only appears as pixels in a regular layer, not as a vector path in the Paths panel.

What I Want to Achieve:

When the EPS file is opened in Photoshop, the path should appear in the Paths panel (Window > Paths) as an editable vector path, not as pixels in a layer.

What I’ve Tried:

  1. Various PostScript structures for defining clipping paths
  2. Registering the path with different notations (/DefaultClippingPath,
    /_clippingpath, etc.)
  3. Accurately converting SVG path instructions
    (M, L, C, Z) to PostScript path instructions (moveto, lineto,
    curveto, closepath)
  4. Different methods for naming and defining the
    path

Relevant Code:

const createEPSWithPath = async (imageBase64, pathString) => {
  return new Promise((resolve) => {
    const img = new Image();
    img.onload = () => {
      const imgWidth = img.width;
      const imgHeight = img.height;
      
      // Process SVG path accurately
      let postScriptPath = '';
      
      try {
        // Clean pathstring
        const cleanPathString = pathString.trim().replace(/s+/g, ' ');
        
        if (cleanPathString.includes('M')) {
          // Parse each instruction separately for better control
          let svgCommands = cleanPathString.match(/[MLCZmlcz][^MLCZmlcz]*/g) || [];
          
          svgCommands.forEach(cmd => {
            const command = cmd[0]; // First letter is the command
            const args = cmd.substring(1).trim(); // Rest are the arguments
            
            switch(command) {
              case 'M': 
                // MoveTo: x y moveto
                const movePoints = args.split(/[,s]+/);
                if (movePoints.length >= 2) {
                  const x = parseFloat(movePoints[0]).toFixed(3);
                  const y = parseFloat(movePoints[1]).toFixed(3);
                  postScriptPath += `${x} ${y} moveton`;
                }
                break;
              case 'L':
                // LineTo: x y lineto
                const linePoints = args.split(/[,s]+/);
                if (linePoints.length >= 2) {
                  const x = parseFloat(linePoints[0]).toFixed(3);
                  const y = parseFloat(linePoints[1]).toFixed(3);
                  postScriptPath += `${x} ${y} lineton`;
                }
                break;
              case 'C':
                // CurveTo: x1 y1 x2 y2 x3 y3 curveto
                const curvePoints = args.split(/[,s]+/);
                if (curvePoints.length >= 6) {
                  const x1 = parseFloat(curvePoints[0]).toFixed(3);
                  const y1 = parseFloat(curvePoints[1]).toFixed(3);
                  const x2 = parseFloat(curvePoints[2]).toFixed(3);
                  const y2 = parseFloat(curvePoints[3]).toFixed(3);
                  const x3 = parseFloat(curvePoints[4]).toFixed(3);
                  const y3 = parseFloat(curvePoints[5]).toFixed(3);
                  postScriptPath += `${x1} ${y1} ${x2} ${y2} ${x3} ${y3} curveton`;
                }
                break;
              case 'Z':
              case 'z':
                // ClosePath: closepath
                postScriptPath += `closepathn`;
                break;
            }
          });
        }
      } catch(e) {
        console.error('Error converting path:', e);
        // Fallback path
        postScriptPath = '0 0 moveton0 100 lineton100 100 lineton100 0 linetonclosepathn';
      }
      
      // EPS structure
      let epsContent = `%!PS-Adobe-3.0 EPSF-3.0
%%BoundingBox: 0 0 ${Math.ceil(imgWidth)} ${Math.ceil(imgHeight)}
%%Creator: Background Remover
%%Title: Image with Path
%%Pages: 1
%%EndComments

% Define clipping path
/CustomPath {
  newpath
  ${postScriptPath}
} def

% Register path as Photoshop clipping path
/CustomClippingPath {
  CustomPath
} def
/DefaultClippingPath {
  CustomPath
} def

% Make path visible (blue line)
1 setlinewidth
0 0 1 setrgbcolor
CustomPath
stroke

% Draw border (black line)
0.5 setlinewidth
0 0 0 setrgbcolor
newpath
0 0 moveto
${imgWidth} 0 lineto
${imgWidth} ${imgHeight} lineto
0 ${imgHeight} lineto
closepath
stroke

%%EOF`;

      // Create JPEG version for preview
      const canvas = document.createElement('canvas');
      const ctx = canvas.getContext('2d');
      canvas.width = imgWidth;
      canvas.height = imgHeight;
      ctx.drawImage(img, 0, 0);
      
      const jpegDataUrl = canvas.toDataURL('image/jpeg', 1.0);
      const jpegData = jpegDataUrl.split(',')[1];
      
      resolve({
        eps: epsContent,
        jpeg: jpegData
      });
    };
    img.src = imageBase64;
  });
};

What I Already Know:

  1. The paths are correctly converted from SVG to PostScript format.
  2. The EPS files can be opened in Photoshop without errors.
  3. The paths are visible as blue lines in the file, but only as pixels, not as vector
    paths.

Question:

What is the correct EPS file structure and PostScript code to create a vector clipping path that Photoshop recognizes? I’m looking for a correct example of the PostScript code that Photoshop needs to display the paths in the Paths panel and not just as pixels.

react-error-boundary renders fallback but still shows red screen

I have a component-

    const DataMonitor = () => {

    throw new Error("Test Error");
    return (
       <div>Hello</div>
    )
};

export default DataMonitor;

In my application i am using react-error-boundary to catch any unhandled error, as you can see i have one in my component shared above.

 <ErrorBoundary fallback={<div>Something went wrong</div>}>
    <DataMonitor />
 </ErrorBoundary>

Now the issue is fallback screen is rendered but there is red error screen above it as well.
enter image description here

I read somewhere that this is overlay and wont be shown in production. this is just for dev environment. just wanted to learn more about this. and confirm if this is true or not.
also, is there any way to disable this overlay in dev?

Framer [Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

After installing framer motion and applying some animations to my NextJS component, I get error,

[Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.

import { motion } from "framer-motion";

const HeroSection: React.FC = () => {
  return (
    <div className="text-white py-10 overflow-hidden">
      <div className="container mx-auto px-6 flex flex-col lg:flex-row items-center">
        <motion.div
          className="w-full lg:w-3/5 mb-12 lg:mb-0"
          initial={{ opacity: 0, x: -50 }}
          animate={{ opacity: 1, x: 0 }}
          transition={{ duration: 0.6, ease: "easeOut" }}
        >
        </motion.div>
      </div>
    </div>
  );
};

export default HeroSection;

Javascript: Playwright throwing an uncatchable error

I am using Playwright with extra and the stealth plugin. The below code randomly throws an error. Sometimes it downloaded 1000’s of pages before failing.

What I do not understand is why the try/catch block does not catch it. I also wrapped my entire app in try/catch with the same result. The error is

node:internal/process/promises:394
    triggerUncaughtException(err, true /* fromPromise */);
    ^
cdpSession.send: Target page, context or browser has been closed
    at Object.send (scrapernode_modulesplaywright-extradistindex.cjs.js:194:46)

I simplified the code I am using:

  try {
    browser = await chromium.launch({
      ...proxyConfig,
    });
    pageInstance = await browser.newPage();
    await pageInstance.goto(url, { timeout });

    const html = await pageInstance.content();
    await browser.close();

    return html;
  } catch (error) {
    await browser.close();
    return error;
  }

Build a Telephone Number validator in JavaScript [closed]

I’m trying to develop an algorithm that checks whether a phone number format is valid or not using regex in JavaScript, as part of a test on the FreeCodeCamp platform.

const userInput = document.getElementById("user-input");
const checkBtn = document.getElementById("check-btn");
const clearBtn = document.getElementById("clear-btn");
const resultDiv = document.getElementById("results-div");


const regex1 = /^1s[0-9]{3}-[0-9]{3}-[0-9]{4}$/;
const regex2 = /^1s([0-9]{3})s[0-9]{3}-[0-9]{4}$/;
const regex3 = /^1([0-9]{3})[0-9]{3}-[0-9]{4}$/;
const regex4 =  /(?:^|s)1s[0-9]{3}s[0-9]{3}s[0-9]{4}(?:$|s)/;
const regex5 = /(?:^|s)[0-9]{10}(?:$|s)/;
const regex6 = /(?:^|s)[0-9]{3}-[0-9]{3}-[0-9]{4}(?:$|s)/;
const regex7 = /(?:^|s)([0-9]{3})[0-9]{3}-[0-9]{4}(?:$|s)/;

const regexList = [regex1, regex2, regex3, regex4, regex5, regex6, regex7]





function checkNumber () {
    if(userInput.value === ""){
        alert("Please provide a phone number");
        return false;
    } else{
        return regexList.some(regex => regex.test(userInput.value))
    }
}


function displayResult(){
    const isValid = checkNumber();
    if(userInput.value === "11 555-555-5555"){
        resultDiv.textContent = `Invalid US number: ${userInput.value}`

    }else{
        if(isValid){
            resultDiv.innerHTML += `<p>Valid US number: ${userInput.value}</p>`
        }else{
           resultDiv.innerHTML += `<p>Invalid US number: ${userInput.value}</p>`
        }
    }
}







checkBtn.addEventListener("click", displayResult);
clearBtn.addEventListener("click", () => resultDiv.textContent = "");

that two last conditions are completed

  1. When the #user-input element contains a valid US number and the #check-btn element is clicked, the #results-div element should contain the text “Valid US number: ” followed by the number.

  2. When the #user-input element contains an invalid US number and the #check-btn element is clicked, the #results-div element should contain the text “Invalid US number: ” followed by the number.

Passing the username through an iframe without passing it in the url in extjs

Currently we have an extjs application where we are calling the /login API through an Iframe by passing the username as /login?username=YWRtaW5AZWZmaXNlci5jbzZTZzMTg= and reading this in the superset_config.py file. But since this is not a right practice we want to send the username in any way apart from passing it in the url. Please help in providing the possible ways with which we could achieve this and improve the security.

supersetIframeCmp.el.dom.src = superset_application_url + '?username=' + userNameEncoded;

if (supersetIframeCmp) {
                var supersetIframeCmpEle = supersetIframeCmp.getEl();
                if (supersetIframeCmpEle) {
                }
}
                       

How to run a more advanced javascript code in an angular project

I need to run a javascript code in my angular project, and following other questions on SO I could run a hello world js file. However, there is no example for usage of more advanced js files like cases in which js needs html elements of the angular component.

Following is my simplified myGame.js file:

export function greeting(){
    alert("Greeting from javascript");
}

var canvas, context;
export function initializeScenes() {
    canvas = document.getElementById("canvas");
    if (canvas)
        context = canvas.getContext("2d");
    else
        alert("No canvas");

}

and my runjavascript.component.ts:

import * as myGame from "../../../../assets/myGame.js"
.
.
.
export class RunJavascriptComponent {
    constructor() {
       myGame.greeting();
       myGame.initializeScenes()

    }    
}


and my runjavascript.component.htm:

<div class="container">
    <canvas id="canvas" width="600" height="400"></canvas>
</div>

When I run ng serve, I see “Greeting from javascript”, which means greeting() is called successfully, but then I get the alert “No canvas”, which I think means canvas element of my angular component.html is not recognized!

Does anyone know how to solve the problem? Thank you in advance.