How do I remove an item from localStorage and update the state once removed?

// **Card.jsx code**

import { useState, useEffect } from "react";
import "./card.scss";

function Card({ movieList, removeMovie }) {
  const [saved, setSaved] = useState(null);

  const handleButtonClick = (movie) => {
    setSaved(saved === movie ? null : movie);
    if (saved === movie) {
      setSavedMovies((prev) => prev.filter((item) => item !== movie));
      removeMovie(movie);
    } else {
      setSavedMovies((prev) => [...prev, movie]);
    }
  };

  const handleDelete = (movie) => {
    const filtered = movieList.filter((item) => {
      return item !== movie;
    });
    setSavedMovies(filtered);
  };

  const [savedMovies, setSavedMovies] = useState([]);

  useEffect(() => {
    const retrieveSavedMovies = () => {
      const savedMovies = localStorage.getItem("savedMovies");

      return savedMovies ? JSON.parse(savedMovies) : [];
    };

    setSavedMovies(retrieveSavedMovies());
  }, []);

  useEffect(() => {
    localStorage.setItem("savedMovies", JSON.stringify(savedMovies));
  }, [savedMovies]);

  return (
    <div className="cardContainer">
      {movieList.map((movie) => (
        <div className="card" key={movie.id}>
          <div className="save">
            <button
              onClick={() => {
                handleButtonClick(movie);
              }}
              className={`button ${saved === movie ? "saved" : ""}`}
            >
              {saved === movie ? (
                <img src="/star.png" alt="" />
              ) : (
                <img src="/trash.png" alt="" />
              )}
            </button>
          </div>
          <img
            src={`https://image.tmdb.org/t/p/w500${movie.poster_path}`}
            alt=""
          />
          <p>{movie.title}</p>
        </div>
      ))}
    </div>
  );
}

export default Card;

// **SavedMovie.jsx code**

import "./savedMovie.scss";
import { useState, useEffect } from "react";
import Card from "../card/Card";

function SavedMovie() {
  const [savedMovies, setSavedMovies] = useState([]);

  useEffect(() => {
    const retrieveSavedMovies = () => {
      const savedMovies = localStorage.getItem("savedMovies");
      return savedMovies ? JSON.parse(savedMovies) : [];
    };

    setSavedMovies(retrieveSavedMovies());
  }, []);

  return (
    <div className="savedMovie">
      <div className="body">
        <div className="content">
          {savedMovies.length > 0 ? (
            <Card movieList={savedMovies} />
          ) : (
            <p>No saved movies</p>
          )}
        </div>
      </div>
    </div>
  );
}

export default SavedMovie;


Hello, I’m trying to create a movie list app with react. I have 2 tabs, the first one being “Movies” which is also the homepage, where I display a list of movies using TMDB API, and the second tab is “To Watch” where I display all the movies the user chose to save by clicking on the button. How do I remove the movie from the “To Watch” tabs when the user clicks on the same button?

I tried creating a removeMovie function and passing it to the Card component as props and then call it in the handleButtonClick function which is being called by the button onClick. However nothing actually happened.

How to I can view background apps in a React Native application?

I’m working on a Gaming Social Media app with react native and I need to access information about background apps running on the device. Specifically, I want to retrieve a list of background apps along with their information such as the time when it started and package name. to set status automatically for ex: “playing {game name}” if user allow me.

I’ve searched through the React Native documentation and various libraries, but I couldn’t find a clear solution for this. Is there a native module or library available that allows me to achieve this functionality? If not, what would be the recommended approach to implement this feature in a React Native application?

Any guidance or suggestions would be greatly appreciated. Thank you!

Javascript in TypeWriter Effect

I try to create a typeWriter effect using Javascript. It done perfectly, but it cannot type ‘<‘ character. I don’t know how to fix it

My code is:

let other = document.getElementById('other');
let txt = "Hello World <br> this typing effect.";
let i = 0;
function typeWriter() {
    if (i < txt.length) {
      other.innerHTML += txt.charAt(i); i++;
      setTimeout(typeWriter, 10);
      window.scrollTo(0, document.body.scrollHeight);
    }
}

typeWriter();
<h1 id='other'></h1>

I hope the result like:

Hello World
this typing effect.

Actual result I get:

Hello World <br> this typing effect.

Please give me some clue. Thanks in advance

How do I create a custom command to generate files with Node?

For my job, we create a lot of small web applications with NodeJS for the backend and Angular for the frontend

Said apps usually involve a lot of CRUDs

With Angular, I can run:

ng generate component 'component-name'

Which generates the ts, html, scss, and spec files

How would I go about creating a custom script to do something similar in NodeJS?

Currently, the project uses ExpressJS and Sequelize, and the structure as follows:

├── src
│   ├── controllers
│   |   ├── product.controller.js
│   ├── models
|   |   ├── product.model.js
│   ├── routes
|   |   ├── product.routes.js
├── index.js
├── package.json

Basically I want to create a script that generates all 3 files when given the name, something like

node generate client

Is it possible?

event listener is not removing even though command is complete

I’m making an RPG game inspired by freecodecamp but with my own twist where I have a buy weapons section and you can choose which weapon you would like to buy. it works normally up until i return to the store function and all of a sudden the button function isn’t changed even though i already added removeEventListener

Javascript

let xp = 0
let health = 100
let coin = 1000;
let inv = [
    {weapon : "Spiderweb", damage : 2}
]

const xpNum = document.querySelector("#xpNum");
const healthNum = document.querySelector("#healthNum");
const coinNum = document.querySelector("#goldNum");
const button1 = document.querySelector("#button1");
const button2 = document.querySelector("#button2");
const button3 = document.querySelector("#button3");
const button4 = document.querySelector("#button4");
const textbox = document.querySelector("#textbox");
const textbox2 = document.querySelector("#textbox2");

xpNum.innerHTML = xp
healthNum.innerHTML = health
coinNum.innerHTML = coin

const weapons = [
    {weapon : "Shield", damage : 5, price : 50},
    {weapon : "Taser", damage : 10, price : 75},
    {weapon : "Gun", damage : 15, price : 100},
    {weapon : "Trident", damage : 20, price : 200},
];

const villains = [
    {villain : "Sandman" , health : 40, place : "under"},
    {villain : "Robber" , health : 20 , place : "city"},
    {villain : "Kidnapper" , health : 30, place : "city"},
    {villain : "Green Goblin" , health : 50, place : "city"},
    {villain : "Mysterio" , health : 50, place : "under"},
    {villain : "Lizard" , health : 50, place : "under"},
    {villain : "Kingpin" , health : 100, place : "city"},
];

const places = [
    {place : "store" , 
    text : "Spiderman is inside the store. What should he do?",
    btnText : ["Buy Weapons" , "Sell Weapons" , "Increase Health", "Leave Store"],
    btnFunc : [buy,sell,increase,start],
    text2 : "Im boutta cum"
}
];

function update(location) {
    button1.innerHTML = location.btnText[0]
    button2.innerHTML = location.btnText[1]
    button3.innerHTML = location.btnText[2]
    button4.innerHTML = location.btnText[3]

    button1.onclick = location.btnFunc[0]
    button2.onclick = location.btnFunc[1]
    button3.onclick = location.btnFunc[2]
    button4.onclick = location.btnFunc[3]

    textbox.innerHTML = location.text

    if(Object.hasOwn(location,"text2")){
        textbox2.innerHTML = location.text2
    } else {
        textbox2.style.display = "none"
    }
}

function store() {
    update(places[0])
}

function buy() {
    let weaponsText = ""
    inv.forEach((item,index) => {
        weaponsText += `${index + 1}. ${item.weapon}<br>`
    })
    textbox2.innerHTML = "1. Shield - 5 Damage - 50 Coins<br>2. Taser - 10 Damage - 75 Coins<br>3. Gun - 15 Damage - 100 Coins<br>4. Trident - 20 Damage - 200 Coins<br>"
    textbox.innerHTML = `Spiderman currently has <br>${weaponsText} Which weapon should Spiderman buy?`
    button1.innerHTML = "Shield"
    button2.innerHTML = "Taser"
    button3.innerHTML = "Gun"
    button4.innerHTML = "Trident"

    button1.removeEventListener("click",buyWeapon)

    const buyWeapon = (cmd) => {
        let weaponName = cmd.target.innerHTML
        let weapon = weapons.find(item => item.weapon == weaponName)
        if(weapon){
            inv.push(weapon)
            alert(`${weaponName} bought!`)
            coin -= weapon.price
            coinNum.innerHTML = coin
            cmd.target.removeEventListener("click",buyWeapon)
            store()
        }
    }

    button1.addEventListener("click",buyWeapon)
}

function sell() {

}

function increase() {

}

function start() {

}

button1.addEventListener("click",()=>{
    store()
})

HTML

<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>RPG Game</title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="styles.css">
    </head>
    <body>
        <div id="container">
            <div id="stats">
                <span id="xpText" class="stat">XP : <strong id="xpNum">0</strong></span> |
                <span id="healthText" class="stat">Health : <strong id="healthNum">0</strong></span> |
                <span id="coinsText" class="stat">Coins : <strong id="goldNum">0</strong></span>
            </div>
            <div id="buttons">
                <button id="button1" class="button">Go to store</button>
                <button id="button2" class="button">Go to city</button>
                <button id="button3" class="button">Go to underground</button>
                <button id="button4" class="button">Exit</button>
            </div>
            <div id="textbox2">ddddddd</div>
            <div id="textbox">
                Spiderman is near a mom-and-pop shop in Queens. What should he do?
            </div>
        </div>
        
        <script src="script.js" async defer></script>
    </body>
</html>```

Javascript code random insult nested in html not working [duplicate]

It just doesn’t work. Nothing in the console. I hope someone can debug it.
Thanks!

I’ve tried changing the script around, but still nothing. This is actually based off another one of my posts, but when I added more insults, and changed the random picker, it stopped working as needed. As I’ve said before, this will be a basis for more of my projects to come.

<main>
    <script>
        const insults = [
'${name} is a lucky ducky! 99, dam!.',
'${name} was so close to success. But I guess you`re just a failure in life.',
'${name}, is kinda stupid.',
'Hey, ${name}, turn 96 upside down.',
'${name}, 95 is literally the most boring number you could have gotten. Go try again..',
'${name}, can I have the name of your hair salon? I need to know where not to go.',
'${name}, you are the human equivalent of a participation trophy.',
'${name}, you have a face for radio.',
'${name}, whatever kind of look you were aiming for, you missed.',
'${name}, I smell something burning. Are you trying to think again?',
'${name}, you’re like a lighthouse in a desert: bright but not very useful.',
'${name}, you’re as useless as the “ueue” in “queue!',
'${name}, whatever is eating you must be suffering terribly.',
'${name}, if you ever had a thought, it would die of loneliness.',
'${name}, this is why the gene pool needs a lifeguard.',
'${name}, you have the charisma of a wet sock.',
'${name}, I don’t understand, but I also don’t care, so it works out nicely.',
'${name}, I’ve seen salad that dresses better than you.',
'${name}, You have the communication skills of an alarm clock.',
'${name}, honestly, I`m just impressed you could read this.',
'${name}, no I`m not insulting you, I`m describing you.',
'${name},  your birth certificate is an apology letter from the condom factory.',
'${name}, the only way you`ll ever get laid is if you crawl up a chicken`s ass and wait.',
'${name}, my psychiatrist told me I was crazy and I said I want a second opinion. He said okay, you`re ugly too.',
'${name}, you must have been born on a highway because that`s where most accidents happen.',
'${name}, brains aren`t everything. In your case they`re nothing.',
'${name}, some babies were dropped on their heads but you were clearly thrown at a wall.',
'${name}, you can walk, but can you talk?',
'${name}, I`d slap you, but that would be animal abuse.',
'${name}, stop trying to be a smart ass, you`re just an ass.',
'${name}, Damn, you just got the best number! 6--------9!',
'${name}, One off from 69, get better at life.',
'${name}, why was six scared of seven? Because seven ate nine!',
'${name}, why don`t you slip into something more comfortable... like a coma.',
'${name}, you get ten times more girls/boys than me? ten times zero is zero...',
'${name}, You`re so fat, you could sell shade.',
'${name}, have you been shopping lately? They`re selling lives, you should go get one.',
'${name}, I don`t think you understand the concept of `no eating`.',
'${name}, that`s one small step for me, and a massive one for you.',
'${name}, I`d like to see things from your point of view but I can`t seem to get my head that far up my ass.',
'${name}, every time I`m next to you, I get a fierce desire to be alone.',
'${name}, why do you always wear black? Do you like looking like a clown?',
'${name}, you`re so dumb that you got hit by a parked car.',
'${name}, how did you get here? Did someone leave your cage open?',
'${name}, I didn’t ask for your opinion.',
'${name}, pardon me, but you`ve obviously mistaken me for someone who gives a damn.',
'${name}, don`t you have a terribly empty feeling - in your skull',
'${name}, as an outsider,what do you think of the human race?',
'${name}, I have neither the time nor the crayons to explain this to you.',
'${name}, I would agree with you but then we would both be wrong.',
'${name}, you`re so dense, light bends around you.',
'${name}, you`re as useful as a waterproof teabag.',
'${name}, you`re so clumsy, you could trip over a wireless network.',
'${name}, you`re so slow, you make sloths look like Olympic sprinters.',
'${name}, you`re not completely useless; you can always serve as a bad example.',
'${name}, you`re so gullible, I could sell you air and you`d buy it.',
'${name}, your family tree must be a cactus, because everyone on it is a prick.',
'${name}, you`re not just a clown; you`re the entire circus.',
'${name}, your agility is comparable to a turtle on a trampoline.',
'${name}, you have the problem-solving skills of a confused penguin in a desert',
'${name}, you look like you were drawn with my left hand',
'${name},  I do not consider you a vulture. I consider you something a vulture would eat',
'${name}, what do you think of that, Mr. Pajama-Wearing, Basket-Face, Slipper-Wielding, Clipe-Dreep-Bauchle, Gether-Uping-Blate-Maw, Bleathering, Gomeril, Jessie, Oaf-Looking, Stauner, Nyaff, Plookie, Shan, Milk-Drinking, Soy-Faced Shilpit, Mim-Moothed, Sniveling, Worm-Eyed, Hotten-Blaugh, Vile-Stoochie, Callie-Breek-Tattie?',
'${name}, Your mother was a broken down tub of junk with more gentlemen callers than the operator.',
'${name}, White people are just untitled word documents.',
'${name}, you`re so dumb, when your dad said to put your grades up, you put your test up on the roof.',
'${name}, Mirrors can`t talk. Lucky for you, they can`t laugh either.',
'${name}, in a parallel universe, you might be smart.',
'${name},  Only 1 in 100 people get this on their first try. You aren`t lucky. you`re just the hundreth person.',
'${name}, I`ll never forget the first time we met. But I`ll keep trying.',
'${name}, Here are the first hundred digits of pi! you`re welcome: 3.1415926535 8979323846 2643383279 5028841971 6939937510 5820974944 5923078164 0628620899 8628034825 3421170679',
'${name}, Honestly, does anyone even appreciate my work?',
'${name},The number 29 is fine. But are you?',
'${name}, Did the mental hospital test too many drugs on you today?',
'${name}, thought of you today. It reminded me to take out the trash.',
'${name}, somewhere out there is a tree tirelessly producing oxygen for you. You owe it an apology.',
'${name}, you just might be why the middle finger was invented in the first place.',
'${name}, if I had a face like yours, I would sue my parents.',
'${name}, if I wanted to kill myself, I would climb to your ego and jump to your IQ.',
'${name}, Phew, I`m getting tired of typing all those insults. Why don`t you help me out a little, and tell me your personality so that I can make more.',
'${name}, don’t be ashamed of who you are. That’s your parent`s job.',
'${name}, you are proof that evolution can go in reverse.',
'${name}, Isn’t it dangerous to use your whole vocabulary in one sentence?',
'${name}, if I had a dollar for every time you said something smart, I’d be broke.',
'${name}, people clap when they see you. They clap their hands over their eyes',
'${name}, I bet your parents change the subject when their friends ask about you.',
'${name}, find the fact that you’ve lived this long both surprising and disappointing.',
'${name}, carry a plant around with you to replace the oxygen you waste.',
'${name}, don’t know what your problem is, but I’m guessing it’s hard to pronounce.',
'${name}, you see that door? I want you on the other side of it.',
'${name}, final 10, I can see the light. Oh wait, you`re on the other side. Back we go!',
'${name}, You look like a person in their 80`s, but you act like someone who`s 9.',
'${name}, If I had a dollar for everytime you said something smart I would be broke.',
'${name}, may both sides of your pillow be uncomfortably warm.',
'${name}, This is the most useless number you could have gotten.',
'${name}, you had a five percent chance to get this number. Good job!',
];

function Submit(e){
  e.preventDefault();
  let data = new FormData(e.target);
  let name = data.get("name");
  let random = Math.round(Math.random() * 96 - 1); //(4) change according to array length - 1
  const insult = insults[random]?.replace('${name}',name);
  setResult(insult);
}

const res = document.getElementById('result');

function setResult(val){
  res.textContent = val;
}
    </script>
    <form onsubmit='Submit(event)'>
      <label for='name'>Name</label>
      <input id='name' name='name' type='text'>
      <button type='submit'>Check</button>
    </form>
    <div>
      <h2>Insult</h2>
      <h3 id='insult'></h3>
    </div>
  </main>

I hope someone can help.

Combination Sum using recursion

I am new to data structure and I am trying this problem Combination Sum

I know this might be super basic stuff but I am learning recursion and not want to learn where I am doing wrong so that I can correct my thinking process.

Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order.

The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the
frequency
of at least one of the chosen numbers is different.

The test cases are generated such that the number of unique combinations that sum up to target is less than 150 combinations for the given input.

var combinationSum = function(candidates, target) {
    if(candidates.length == 0) return [[]]
    if(target == 0) return [[]]
    if(target<0) return []
    result = []
    for(let i=0; i<candidates.length; i++){
        let arr = [...candidates]
        // take the element
        let result1 = combinationSum([...candidates], target-candidates[i])
        // ignore the element
        result1.forEach((e)=>{e.push(candidates[i])})
        let result2 = combinationSum(arr.slice(0, i).concat(arr.slice(i + 1)), target)
        result.push(...result1, ...result2)
    }
    return result
};

Right now, I am now working toward finding combination and not unique,
I am not able to comprehend why this is not working.

enter image description here

How to make images replace each other with a button?

So, I’m trying to develop a sort of visual novel, and I’m trying to make a code to replace other images when a specific image appears, (for example, if “happy” is onscreen i want “sad” to be hidden so the pictures don’t overlap eachother)
Here’s my code:

<style>
section {
  display: none;
}

.d-block {
  display: block;
}
</style>
<section class="d-block">Horace</section>
<section>Ursa</section>
<section><img id=sad src=https://png.pngtree.com/png-clipart/20220716/ourmid/pngtree-banana-yellow-fruit-banana-skewers-png-image_5944324.png></section>
<section><img id=neutral src=https://www.shutterstock.com/image-photo/banana-bunch-five-600nw-1057197824.jpg></section>
<section><img id=happy src=https://t4.ftcdn.net/jpg/05/65/93/25/360_F_565932566_6bll77MbikvLen4pPoLVvlrqmvKTZ7Nw.jpg></section>
<section>Thus</section>

<button>Next</button>
<script>
document.addEventListener("DOMContentLoaded", () => {
const TextShower = document.querySelector('button');
TextShower.addEventListener('click', function() {
  let hidden_section = document.querySelector('section:not(.d-block)');
  if (hidden_section != null) {
    hidden_section.classList.add('d-block');
  } else {
    TextShower.disabled = true;
    }
  });
  const Happy = document.getElementById("happy")
  if (happy.hasAttribute("d-block")) {
  document.getElementById("sad","neutral").removeAttribute("d-block")
        }
  });
    </script>
  const Happy = document.getElementById("happy")
  if (happy.hasAttribute("d-block")) {
  document.getElementById("sad","neutral").removeAttribute("d-block")
        }
  });

this is the if statement i tried to create to replace the portraits. did not work

Why i have to do “double submit” in my search form?

I’m currently working on a form that allows users to search for bills by their description, ID, or price. However, I’ve encountered an issue: after the initial search, I have to submit the form twice to get the desired results.

getBillsByIdDescriptionPrice(formState.search)
is a function that brings from de DB all the bills that match with the content from the input formState.search

The first search usually works fine. However, upon the second search, after submitting the query, it initially returns all the data instead of the specific result I’m looking for. Only after submitting the form again does it finally bring up the correct data.

Doing console logs, I noticed that during the second search, it briefly returns the correct result. However, shortly after, it reverts to displaying all the data, requiring an additional submission.

I hope someone can help me. Thanks a lot!

React with Typescript and Material UI

Link to the repo: https://github.com/guidomora/facturacion-front/blob/main/src/billing/components/BillingSearch.tsx

Here you can check the code:

 const { bills, getBillsByIdDescriptionPrice } = useContext(DataContext)
  const { formState, inputChange, search } = useFormSearch({ search: '' })

  const handleSubmit =  (e: React.FormEvent<HTMLFormElement>) => {
    e.preventDefault()
    if (formState.search === '') return
    getBillsByIdDescriptionPrice(formState.search)
    
  }

  const submitButton = () => {
    if (formState.search === '') return
    getBillsByIdDescriptionPrice(formState.search)
  }


{/* displayed data */}
      {(bills.length === 0) ? <Typography variant='h5' 
      sx={{ textAlign: 'center', color: 'black', fontWeight: 600, mt: 35 }}>
        No bills found...
      </Typography> :
        <BillingTable bills={bills} />
      }

selenium cannot execute webpack related code?

I want to use selenium to execute this code to get the token, but when I execute it like this

”driver.execute_script(‘(webpackChunkdiscord_app.push([[”],{},e=>{m=[];for(let c in e.c)m.push(e.c[c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken()’)”

He reported an error saying m is not defined.

But if you execute this directly in the browser’s developer console

‘(webpackChunkdiscord_app.push([[”],{},e=>{m=[];for(let c in e.c)m.push(e.c[ c])}]),m).find(m=>m?.exports?.default?.getToken!==void 0).exports.default.getToken()’

The code works fine

I want to execut this code use selenium ,please, who can help me!!

App restarts when I make an api call through firebase functions

I’m fairly new to google firebase functions.

For some reason when my frontend makes an api call to the backend, the app looks like it restarts everything. Im not sure why. The endpoints are correct. I get a console message from the backend. Here is my code for reference

const express = require("express");
const functions = require("firebase-functions");
require("dotenv").config();

const cors = require("cors");
const axios = require("axios");
const baseURL = "https://api.pledge.to/v1/organizations";
const myHeader = {
  "Authorization": `Bearer ${process.env.API_KEY}`,
};

// Instantiate the app here
const app = express();
app.use(cors());

app.get("/", (req, res) => {
  console.log("Hello World");
  res.status(200).send("baus");
});

app.get("/organizations", async (req, res) => {
  console.log("Making API call");
  console.log(req.query.cause_id);
  try {
    // eslint-disable-next-line max-len
    const response = await axios.get(baseURL+"?"+`cause_id=${req.query.cause_id}`, {
      headers: myHeader,
    });
    const data = await response.data;
    res.status(200).send(data);
    // res.json(data);
  } catch (error) {
    console.error(error);
    res.status(500).json({error: "Internal Server Error"});
  }
});

app.get("/searchOrg", async (req, res)=> {
  console.log("Search query >>>", req.query.q);
  try {
    const response = await axios.get(baseURL+"?"+`q=${req.query.q}`, {
      headers: myHeader,
    });
    const data = await response.data;
    res.status(200).send(data);
  } catch (error) {
    console.error(error);
    res.status(500).json({error: "Internal Server Error"});
  }
});

app.get("/next", async (req, res)=>{
  // console.log("Im in the next endpoint");
  // Using template literals
  let queryString = " ";
  // eslint-disable-next-line guard-for-in
  for (const key in req.query) {
    queryString += `${key}=${req.query[key]}&`;
  }
  // Remove the trailing '&' if necessary
  queryString = queryString.slice(0, -1);

  try {
    const response = await axios.get(baseURL+"?"+`${queryString}`, {
      headers: myHeader,
    });
    const data = await response.data;
    res.status(200).send(data);
    // res.json(data);
  } catch (error) {
    console.error(error);
    res.status(500).json({error: "Internal Server Error"});
  }
});

// Listen command
exports.api = functions.https.onRequest(app);

I tested it using firebase emulators:start. I made sure to update the endpoints on my frontend so that it sends the request to the right server.

I checked the network tab when I make the api call and it says I am getting a 101 status code and a type websocket Also for some reason the amount of time it is taking to process the request is pending

Any ideas why this could be happening? Could it be that I configured the hosting wrong for my frontend. Any help is appreciated. Thanks in advance. Happy coding!

ascii art using letter in javascript [duplicate]

Create a program that translates the input (any combination of X, Y, or Z) to their low-resolution
ascii art-like representation (use letter ‘O’ as the character to draw the letters).

Input Parameters:

  • letters – any combination of the letters X, Y, and Z (example: XYZ, ZXY, ZZXXXYYYYY)
  • size – block size of each letter; odd numbers, greater than or equal to 3 (example: 3, 5, 7, 9… etc)
  • direction – horizontal or vertical

more for a beginner coding and i could not find any refence other reference ive found is make image into ascii art and it would be helpful if it could be explained every part.thank you

Playwright headless tests are slower than headful tests

Playwright headless tests are supposed to be faster than the headful tests. My headful tests are taking ~17sec and headless ones are taking ~1min.

Looking into the problem, I saw that in headless mode, the chrome might be running without gpu acceleration and I should force enable gpu acceleration through flags like

--use-gl="swiftshader"
--enable-unsafe-webgpu
--ignore-gpu-blacklist

I tried all of them, none of them seems to work. Do someone know the solution? Am I on the right track?