How do I resolve MaxLimitersExceededWarning on vscode?

I am trying to create a react-app, but each time I try, it tells me to increase the limit of maxListeners and I have exceeded maxListenersExceededWarning and I am confused as to how to do that.

I tried asking chatgpt for help and I was given numerous ways to solve it. Such as updating my npm and node.js(which I already did) but all to no avail. Also tried writing codes to increase my limits of maxListeners but it didn’t change anything. I am confused on what to do now.

NextJS ‘ReferenceError: cant find variable window’ due to useRouter hook

Every time I load the page, it gives me the ReferenceError as stated in the title. I was able to find the cause of the error and it was the useRouter hook. I tested this by commenting out the lines where I used the hook, and when I loaded the page again, I did not get the error anymore.

According to the NextJs docs useRouter hook is used in client components which I have done. I have also followed the docs by importing useRouter from next/navigation instead of next/router since I am using the App Router.

Here is my code:

'use client'
import styles from './page.module.css'
import {garamond} from "@/app/fonts";
import {motion} from 'framer-motion';
import Link from "next/link";
import {useState} from "react";
import {useRouter} from "next/navigation";
import {createClientComponentClient} from "@supabase/auth-helpers-nextjs";

export default function Home() {
  const[email,setEmail] = useState<string>('');
  const[password,setPassword] = useState<string>('');
  const[error,setError] = useState<string | null>(null);

  const router = useRouter()
  const supabase = createClientComponentClient()

  supabase.auth.getSession().then((res) => {
    if(res.data.session) router.back();

    router.refresh();
  });

  const handleSignUp = async () => {
    const {data,error} = await supabase.auth.signUp({
      email,
      password,
      options: {
        emailRedirectTo: `${location.origin}/auth/callback`,
      },
    });

    if(error) setError(error.message);

    router.refresh()
  }

  //returns JSX for page
}

Payload with get method in Google APP script

I am trying to send payload using get method in GAS and it keeps failing. I was able to do that in Google cloud function using nodejs but I can’t do this in Google app script. ANY SUGGESTIONS on how to send a params in the body for get method in Google app script?

I have tried urlfetchapp with method get

Iam stuck in a js error coding a calculator [closed]

Iam updating an islamic inheritence calculatior and facing an error whome i have shared an screenshot. but the problem is not in the only functions and i have doubt that some parts are effecting it too like inputs so kindly review the screenshot and if you can guide me i will be very thankful. iam stuck here since yesterday. the code is very large so shoud i paste it here or you can be able to just let me know the possibilities of error.

type here

I have checked the error related functions and the “num” which is basically saying underfines worked correct when assigned value through input less tha or equal to 1 but if greater than 1 than it shows that error that num is not defined

marking dates does not work in the calendar [closed]

I have a problem developing a calendar where it marks events on the appropriate dates, I receive the dates in the following way in PHP

[
  {
    "status": "OK",
    "statusCode": 200,
    "statusMensagem": "Listado com sucesso!",
    "arrayDados": [
      {
        "data": "2024-01-17",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-17",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-17",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-24",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-19",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-18",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-19",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-19",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-23",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-24",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-24",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-26",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      },
      {
        "data": "2024-01-27",
        "dadosDoDia": {
          "selected": true,
          "marked": true,
          "selectedColor": "blue"
        }
      }
    ],
    "ondeEstou": [],
    "proximos": []
  }
]

the code in the calendar is as follows:

<Calendar
                  style={[Styles.w95,{
                    borderTopLeftRadius:0,borderTopRightRadius:0,
                    borderBottomLeftRadius:20,borderBottomRightRadius:20,
                    marginTop:'2%',
                    borderWidth: 0,
                    borderColor: 'gray',
                    height: 350,
                    borderRadius:4,
                  }]}
                  current={new Date().toDateString()}
                  onDayPress={day => {
                    
                  }}
                  markedDates={agenda}
                />

when I put markedDates like this:

markedDates={{
    '2012-03-01': {selected: true, marked: true, selectedColor: 'blue'},
    '2012-03-02': {marked: true},
    '2012-03-03': {selected: true, marked: true, selectedColor: 'blue'}
  }}

so it marks the dates correctly, but when it returns from the database it does not mark it and the following message appears.
Warning: Failed prop type: Invalid prop markedDates of type array supplied to Calendar, expected object.
at Calendar (http://192.168.1.7:8081/node_modules%5Cexpo%5CAppEntry.bundle//&platform=android&dev=true&hot=false&lazy=true:223709:28)

could someone help me please

I can’t solve it, I need him to mark the dates like this

React Google Login: Cross-Origin-Opener-Policy Error and Popup Closure Issue

I’m facing an issue with the React Google Login component, and I would appreciate your help in resolving it. When using the Google login button in my React app, I encounter the following errors:

cb=gapi.loaded_0?le=scs:175 Cross-Origin-Opener-Policy policy would
block the window.closed call.

cb=gapi.loaded_0?le=scs:175 Cross-Origin-Opener-Policy policy would
block the window.closed call.

Here are the steps leading to the issue:

I click the Google login button.
The Google login popup appears.
After successfully logging in, there is a loader for a couple of seconds.
The Google login popup closes by itself.
I’m unsure about the root cause of the Cross-Origin-Opener-Policy error and the unexpected closure of the popup. I have checked for common issues like CORS configurations and authorized redirect URIs, but the problem persists.

Environment:

React version: 18.2.0

Browser: google chrome, edge,firefox

react-google-login version: 5.2.2

also when i first start the app i get two warnings and a object

An iframe which has both allow-scripts and allow-same-origin for its
sandbox attribute can escape its sandboxing.

Third-party cookie will be blocked. Learn more in the Issues tab.

and this object

Object details : “You have created a new client application that uses
libraries for user authentication or authorization that are
deprecated. New clients must use the new libraries instead. See the
Migration Guide for more information.” error :
“idpiframe_initialization_failed” [[Prototype]] : Object

How to link OR tools (python module) on a site in php javascript

I am developing a website in PHP with JavaScript. Part of the site consists of solving a timetabling problem which is written as an integer linear optimization problem. I currently have a python program that uses the ORtools module for python running to solve my problem, but I would like to put it online.

I’m wondering how to do this. Here are the ideas I’m thinking of:

  • there is an or tools interface written for node.js. Unfortunately, I don’t know node.js (this would be an opportunity to get started) and its use seems incompatible with the current scripts that run on the client side.
  • is it possible to install / upload the or-tools module on my host’s server, and to communicate my javascript with python (for example with pyScript. Brython does not allow the use of this module because it contains vs).

Do you have any other solutions/tracks to submit to me?

Thanks in advance !

I tested solvers written in javascript (jsLPsolver.js and glpk.js) but they do not work on problems of the size of those I have (around 10000 variables).

functions that are not considered as functions [closed]

I have a problem where the function I created is not considered a function, can you please help me find a way out? “TypeError: (0 , app_api_User_saran_route__WEBPACK_IMPORTED_MODULE_5_.Saran) is not a function”

import {Saran} from '@/app/api/User/saran/route';

async function simpanSaran(dataSaran) {
  try {
    console.log('Data saran yang akan disimpan:', dataSaran);
    // koneksi ke backend nya
    const res = await Saran(dataSaran);
    console.log(res);
    // tambahkan logika tambahan di sini jika diperlukan untuk menangani respons yang diterima
  } catch (error) {
    console.error('Terjadi kesalahan saat menyimpan saran:', error);
    // tambahkan logika penanganan kesalahan di sini, seperti menampilkan pesan kesalahan kepada pengguna
  }
}

const handleSubmit = (e) =>{
  e.preventDefault();
  simpanSaran(formData);
  // console.log(formData);
  setfromData({
    full_name:'',
    email:'',
    message:''
  })
}

Is there a way to clear one column filter dynamically in Angular 17 – Primeng?

I am using angular 17 with Primeng 17

The filter is being removed from PrimeNG table filters or whenever I try to clear the filter value for my table. Is there another way to clear the filter for a specific column?

I have the following input inside a p-columnFilter in my template:

<ng-template pTemplate="filter" let-value let-filter="filterCallback">
                        @switch(column.type){
                        @case('number'){
                        <p-inputNumber inputId="integeronly" [ngModel]="value"
                            (onInput)="applyColumnFilter(column, $event.value)"
                            class="p-inputtext-sm w-full"></p-inputNumber>
                        }
                        @default {
                        <input (input)="applyColumnFilter(column, $any($event.target).value)" pInputText
                            [ngModel]="value" class="p-inputtext-sm w-full" placeholder="Search..." />
                        }
                        }
                    </ng-template>

Whenever I call the removeFilter Dynamically

removeFilter(index: number) {
    this.table?.filter('', 'attribute', FilterMatchMode.CONTAINS);
  }

How to get dotnet core streaming response in javascript by same order?

I have a dotnet core web api that retuens stream response from openai api like following.

        StreamingResponse<StreamingChatCompletionsUpdate> responses = 
            await client.GetChatCompletionsStreamingAsync(chatCompletionsOptions);
        
        await foreach (var completion  in responses)
        {
           
            if (!string.IsNullOrEmpty(completion.ContentUpdate))
            {
                Console.WriteLine(completion.ContentUpdate);
                await context.Response.WriteAsync(completion.ContentUpdate);
            }
        }

This writes response as async and console write order of words are like following.

After
 a
 long
 day
 of
 work
,
 I
 like
 to
 unwind

And I am getting this http method from javascript like this:

const  generate = async () => {
    try {
        resultTexts.innerText = "";
        
        const response = await fetch(apiUrl, {
            method: "GET"
        });
        
        const reader = response.body.getReader();
        const decoder = new TextDecoder("utf-8");
                
        while(true){
            const chunk = await reader.read();
            const {done, value} = chunk;
            if(done){ break; }
            const decodedChunk = decoder.decode(value);
            
            console.log(decodedChunk)
            
           resultTexts.innerText += decodedChunk;
        }
        
    }catch (error){
        console.error("Error: ", error);
    }
};

generateBtn.addEventListener("click", generate);

But the response of javascripr is like following.

After a long day
 of work, I like
 to
 unwind 

The stream chunks are joined on javascript side. How can I solve this problem? I want to get shunks same order as server on javascript.

New to JS. I’m trying to code something that toggles divs on a site using .setProperty, but nothing happens

Currently, I’m using the display property on my divs and they are manually toggled on/off by the user when they click a button. I have tried this using the visibility property and it works, but it leaves a blank space when the div is toggled off, which I don’t want.

   function init(){
        let current = 1
        show(current)
    }

    function show(n) {

        document.getElementById(n).style.setProperty('display', 'block');

        let current=n;
        
        for (let i = 1 ; i < 4 ; i++) {
            if (i!=current) {
                document.getElementById(i).style.setProperty('display', 'none');
            }
        }



    }
<!DOCTYPE html>

<html>
<head>
    <style>
        div {
            background: red;
            padding: 10px;
            color: white;
            margin: 10px;
            display:none
        }

        html {
            background: grey;
        }

    </style>
</head>

<body onload="init()">

    <!-- no real reason to make a 'main' div, but i plan to when i implement this into my site -->
    <div id="main"> 
    <div id="1">div1</div>
    <div id="2">div2</div>
    <div id="3">div3</div>
    <div id="4">div4</div>
</div>

<button onclick="show(1)">show 1</button>
<button onclick="show(2)">show 2</button>
<button onclick="show(3)">show 3</button>

</body>


</html>

Here’s my current code. It does not return any errors; I feel like the logic i tried to implement is just off, but I can’t see it.

StyleX group hover

I was testing the new StyleX library and I was faced with a challenge within it. Is it possible to realize a group hover effect for a component only by using the library?

To make an example. Let’s suppose we have this component in Tailwind (the same could be achieved using CSS):

<div className='group'>
  <button className='blue-50 group-hover:blue-40'>Call</button>
  <hr className='gray-50 group-hover:gray-40'/>
  <button className='blue-50 group-hover:blue-40'><i className='dropdown'/></button>
</div>

The functioning of this component is straightforward: when we hover over any subcomponent, we apply a lighter color shade to all the siblings.
I tried to do the same within StyleX but I couldn’t replicate it WITHOUT using a state and relying on JS callbacks.

By reading the StyleX guide I know that Encapsulation is not available. However, I was wondering if they have a different approach to reach the same result within the library and without relying on onMouseEnter, onMouseOut, and other callbacks.

JavaScript fetch random choice on list, not working [closed]



process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = 0

setInterval(() => {

const apiversions = ["v6", "v7", "v8", "v9", "v10"];

const random = Math.floor(Math.random() * apiversions.length);

fetch("https://mywebsite.com/api/${random}/test", {

  "method": "GET",

  "mode": "cors",

}).then(res => Promise.all([res.status, res.json()]))

  .then(([status, jsonData]) => {

    console.log(jsonData);

    console.log(status);

  });

}, 2000)

not working

I want the API version to randomly select the versions I specified in the list for each request, but it doesn’t work, the url goes as I wrote ${random}, that is, it does not select the API version.

Add instance of a 3D component dynamically on runtime in react-three-fiber

I have a custom 3D object with some properties. When the app starts a instance of this object is in the canvas. At runtime I want to add another instance of the object when a button is clicked. If possible, I want to retrieve one property of the instance (the end position) so I can use it in the next instance (as a start position).

So I would like to make the following code able to add the LinkCompo component at runtime after a button is pushed (the button is located inside the <SidePanel /> component, and also to use the endLinkPos variable ( located at linkRef.current.children[2].position) for the start position of the new LinkCompo.

The component file:

// LinkCompo.jsx


import * as THREE from 'three';
import { forwardRef } from 'react'
import { LinkBase, LinkNext } from './Links';

const LinkCompo = forwardRef( function LinkCompo( {positionStart, linkLength}, ref) {
  const link_support_offset = 0.03;
  const cylinderHeight = linkLength - 2 * link_support_offset;
  const linkBody =  new THREE.CylinderGeometry(0.025, 0.025, cylinderHeight)

  const startPos = new THREE.Vector3(positionStart[0], positionStart[1], positionStart[2]);
  const cylinderPos = new THREE.Vector3(0, cylinderHeight / 2 + link_support_offset, 0);
  const endLinkPos = new THREE.Vector3(0, linkLength, 0);

  cylinderPos.add(startPos);
  endLinkPos.add(startPos);

  return (
      <group ref={ref}>
        <LinkBase position={startPos} name="LinkA" />
        <mesh position={cylinderPos} geometry={linkBody}>
          <meshBasicMaterial color={'lime'} />
        </mesh>
        <LinkNext position={endLinkPos} name="LinkB" rotation={[0, 0, Math.PI]} />
      </group>
    )

})

export default LinkCompo;

The App file:

// App.jsx

import React, { useState, useRef, useEffect  } from 'react';
import { Suspense } from 'react';
import { Stats, OrbitControls, Environment } from '@react-three/drei';
import { Canvas } from '@react-three/fiber';

import SidePanel from './SidePanel';
import LinkCompo from './LinkCompo';

import './App.css';

export default function App() {

  const linkRef = useRef();
  const [links, setLinks] = useState();
  setLinks([{ 
    positionStart: [0, 0, 0] // HERE it should be -> linkRef.current.children[2].position but it is not resolved initially
    , linkLength: 0.5
  }]);
    
  useEffect(() => {
    if (linkRef.current){
      console.log(linkRef.current.children[2].position)
    }
    
  },[links])




  const handleAddLink = () => {
    
    setLinks([...links,{ 
      positionStart: [0, 0.6, 0] // HERE it should be -> linkRef.current.children[2].position but it is not resolved initially
      , linkLength: 0.5
    }]);
  };



  return (
    <div className="App">
      <div className="panel">
        {/* Pass handleAddLink function to SidePanel component */}
        <SidePanel onAddLink={handleAddLink} />
      </div>
      <div className="scene">
        <Canvas camera={{ position: [-0.5, 1, 2] }}>
          <Suspense fallback={null}>
            <Environment files="./environment.hdr" background blur={0.5} />
            <directionalLight position={[3.3, 1.0, 4.4]} intensity={4} />
            {links.map((link, index) => (
              <LinkCompo key={index} positionStart={link.positionStart} linkLength={link.linkLength} ref={linkRef} />
            ))}
            <OrbitControls />
            <axesHelper args={[5]} />
            <Stats />
          </Suspense>
        </Canvas>
      </div>
    </div>
  );
}

I have tried to access the Component property with a forwardRef().
It works, but not as supposed to. I use the useEffect() to resolve the reference but it is not called at for the initial component (maybe because the state is initialized). If I don’t initialize the state, and instead use the setLinks() for passing the first value, error occurs (links is undefined).

Utilisation d’une bibliothèque python d’optimisation en nombre entiers (OR tools) dans un site en php / javascript [closed]

I am developing a website in PHP with JavaScript. Part of the site consists of solving a timetabling problem which is written as an integer linear optimization problem. I currently have a python program that uses the ORtools module for python running to solve my problem, but I would like to put it online.

I’m wondering how to do this. Here are the ideas I’m thinking of:

  • there is an or tools interface written for node.js. Unfortunately, I don’t know node.js (this would be an opportunity to get started) and its use seems incompatible with the current scripts that run on the client side.
  • is it possible to install / upload the or-tools module on my host’s server, and to communicate my javascript with python (for example with pyScript. Brython does not allow the use of this module because it contains vs).

Do you have any other solutions/tracks to submit to me?

Thanks in advance !

I tested solvers written in javascript (jsLPsolver.js and glpk.js) but they do not work on problems of the size of those I have (around 10000 variables).