This is related to npm not being able to find a file

Every time I open the project I always get this error: I can’t run the projectenter image description here
(base) apple@192 MernStack-Tour-Management % npm start
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/TinhXuan/Documents/GitHub/MernStack-Tour-Management/package.json
npm ERR! errno -2
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open ‘/Users/TinhXuan/Documents/GitHub/MernStack-Tour-Management/package.json’
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

I want to fix it, everytime I want run project it alway fail

Make iframe height 100% and reload plus resize the iframe on resizing

I would like to show the iframe height 100% (now there is a space between the iframe and the footer)
enter image description here

AND resize + reload iframe on resize (when i resize the height, iframe should reload content and resize).

I tried with iFrameResize for resize and with contentDocument.location.reload for reload, but none of them work.

What could be the problem?

// $('.footer-nav-menu-item').on('click', function() {
//   var label = $(this).attr('data-label');
//   $('.panel').removeClass('active');
//   $('#' + label).addClass('active');
// });

$(window).resize(function() {
  document.getElementById('myframe').contentDocument.location.reload(true);
});
iFrameResize({
  log: true
}, '#myframe');
$('.footer-nav-menu-item').on('click', function() {
  var label = $(this).attr('data-label');
  $('.panel-header').text(label);
  $('.panel').addClass('active');
});

$('.panel-close').on('click', function() {
  $('.panel').removeClass('active');
});
.main {
  /*padding: 1rem;*/
}

#myframe {
  width: 1px;
  min-width: 100%;
}

#footer-nav {
  background-color: #444;
  color: #f9f9f9;
  position: fixed;
  bottom: 0;
  width: 100%;
  position: fixed;
  z-index: 100;
}

.footer-nav-inner {
  padding: 1rem;
}

.footer-nav-menu {
  list-style: none;
  padding: 0;
  display: flex;
  justify-content: space-between;
}

.footer-nav-menu-item i {
  font-size: 2rem;
}

.panel {
  height: 100%;
  width: 100%;
  position: fixed;
  top: 0;
  left: 0;
  background-color: #f9f9f9;
  transform: translateY(100%);
  transition: transform 500ms ease;
}

.panel.active {
  transform: translateY(0);
}

.panel ul {
  list-style: none;
  padding: 0;
}

.panel ul li {
  margin: 1rem 0;
}

.panel-inner {
  padding: 1rem;
}

.panel-close {
  margin: 0;
  text-align: right;
}

.panel-close i {
  font-size: 2rem;
}
<html>

<head>
  <link href="https://cdnjs.cloudflare.com/ajax/libs/material-design-iconic-font/2.2.0/css/material-design-iconic-font.min.css" rel="stylesheet" />
  <script src="https://cdnjs.cloudflare.com/ajax/libs/iframe-resizer/4.3.9/iframeResizer.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
</head>

<body>
  <div class="allpage">
    <div class=main><iframe id="myframe" class="singlegame-iframe" frameborder="0" scrolling="no" allowfullscreen="" src="https://adobe.com/"></iframe></div>
    <nav id="footer-nav">
      <div class="footer-nav-inner">
        <ul class="footer-nav-menu">
          <li class="footer-nav-menu-item" data-label="Book Shelf"><i class="zmdi zmdi-collection-bookmark"></i></li>
          <li class="footer-nav-menu-item" data-label="About"><i class="zmdi zmdi-account"></i></li>
          <li class="footer-nav-menu-item" data-label="Favorites"><i class="zmdi zmdi-star"></i></li>
          <li class="footer-nav-menu-item" data-label="Help"><i class="zmdi zmdi-help"></i></li>
        </ul>
      </div>
    </nav>
    <nav class="panel">
      <div class="panel-inner">
        <p class="panel-close"><i class="zmdi zmdi-close"></i></p>
        <h2 class="panel-header"> </h2>
        <ul>
          <li class="panel-item">Item 1</li>
          <li class="panel-item">Item 2</li>
          <li class="panel-item">Item 3</li>
          <li class="panel-item">Item 4</li>
          <li class="panel-item">Item 5</li>
        </ul>
      </div>
    </nav>
  </div>
</body>

</html>

How to, in JavaScript, find the biggest number value in the object that can fit in the given number from an input value?

My question might be confusing, but I’ll try to be as clear as possible.

So I am stuck with the “Roman Numerical Converter” project of my own, the idea is to type the Arabic number into the input field and then it converts into a roman number. I’ve looked for a couple of guides on the internet, but the solution is not what I expect.

(I have my object with roman equivalents declared globally, it is like
const obj = {

X: 10,
V: 5,
IV: 4,
I: 1
}
)

My idea to implement is that the number value from the input goes to the loop, then the code searches for the biggest possible number from an object that can be fit inside the number from the input, for the next step the number found from the object is subtracted from the initial number from the input and then the product of the subtraction is used further unless it reaches 0 or the negative number and does it as many times as needed.

After that it should return the number values that were subtracted, get their keys from an object as strings and concatenate together into one string, so it will be possible to display the final roman number on the page.

That’s what I am struggling with, please help me

const numberInput = document.getElementById("number");
const convertBtn = document.getElementById("convert-btn");
const output = document.getElementById("output");

const removeHide = () => {
  output.classList.remove("hide");
};

// removeHide();

// addOutput() handles the appearence of the #output
// the value always comes as a string
const addOutput = (num) => {
  let roman = "";

  const romanNumbers = {
    M: 1000, 
    CM: 900, 
    D: 500, 
    CD: 400, 
    C: 100, 
    XC: 90, 
    L: 50, 
    XL: 40,
    X: 10,  
    V: 5, 
    IV: 4, 
    I: 1
  };

  let a;

  if (numberInput.value === "") {
    removeHide();
    return output.innerHTML = `<p>Please enter a valid number</p>`;
  } else if (Number(numberInput.value) <= -1) {
    removeHide();
    return output.innerHTML = `<p>Please enter a number greater than or equal to 1</p>`;
  } else if (Number(numberInput.value) >= 4000) {
    removeHide();
    return output.innerHTML = `<p>Please enter a number less than or equal to 3999</p>`;
  } else {
    for (let key in romanNumbers) {
      a = Math.floor(num / romanNumbers[key]);
      if (a >= 0) {
        for (i = 0; i < a; i++) {
          roman += key;
        };
      };
      num = num % romanNumbers[key];
    };
    removeHide();
  };

return roman, output.innerHTML = `<p>${roman}</p>`;

};

convertBtn.addEventListener('click', addOutput);

numberInput.addEventListener('keydown', (e) => {
  if (e.key === "Enter") {
    addOutput();
  };
})

// Here is my latest piece of code that I have tried, I got random in here, since nothing worked out before

Ball stuck – Pong made in JS [closed]

I am working on a project with some games and decided to add a Pong game to it. However, the ball is stuck in the middle of the screen, and I’m a bit lost as I don’t know how to fix it. Is there a way to improve this? Did I make a mistake in the code construction? Thank you in advance! enter image description here


import React, { useEffect, useState } from 'react';
import './pong.css';

const Pong = ({ progressToNextLevel }) => {
const [xBolinha, setXBolinha] = useState(300);
const [yBolinha, setYBolinha] = useState(200);
const [velocidadeXBolinha, setVelocidadeXBolinha] = useState(6);
const [velocidadeYBolinha, setVelocidadeYBolinha] = useState(6);
const [xRaquete, setXRaquete] = useState(5);
const [yRaquete, setYRaquete] = useState(15);
const [xRaqueteOponente, setXRaqueteOponente] = useState(585);
const [yRaqueteOponente, setYRaqueteOponente] = useState(15);
const [meusPontos, setMeusPontos] = useState(0);
const [pontosDoOponente, setPontosDoOponente] = useState(0);

useEffect(() => {
const gameInterval = setInterval(() => {
movimentaBolinha();
verificaColisaoBorda();
movimentaRaqueteOponente();
verificaColisaoRaquete(xRaqueteOponente, yRaqueteOponente);
incluiPlacar();
marcaPonto();
}, 30);

    return () => clearInterval(gameInterval);

}, [xBolinha, yBolinha, xRaqueteOponente, yRaqueteOponente, meusPontos, pontosDoOponente]);

const movimentaBolinha = () => {
setXBolinha((prevX) => prevX + velocidadeXBolinha);
setYBolinha((prevY) => prevY + velocidadeYBolinha);
};

const verificaColisaoBorda = () => {
if (xBolinha + 6 > 600 || xBolinha - 6 < 0) {
setVelocidadeXBolinha((prev) => -prev);
}
if (yBolinha + 6 > 400 || yBolinha - 6 < 0) {
setVelocidadeYBolinha((prev) => -prev);
}
};

const incluiPlacar = () => {
};

const marcaPonto = () => {
};

const movimentaRaqueteOponente = () => {
const velocidadeYOponente = yBolinha - yRaqueteOponente - 45;
setYRaqueteOponente((prevY) => prevY + velocidadeYOponente);
};

const verificaColisaoRaquete = (x, y) => {
const colidiu =
xBolinha - 6 < x + 10 &&
yBolinha - 6 < y + 90 &&
yBolinha + 6 > y;
if (colidiu) {
setVelocidadeXBolinha((prev) => -prev);
}
};

return (
<div className="pong-container">
{/* Bolinha */}
<div className="bolinha" style={{ left: `${xBolinha}px`, top: `${yBolinha}px` }}></div>

      {/* Raquetes */}
      <div className="raquete" style={{ left: `${xRaquete}px`, top: `${yRaquete}px` }}></div>
      <div className="raquete" style={{ left: `${xRaqueteOponente}px`, top: `${yRaqueteOponente}px` }}></div>
    
      {/* Placar */}
      <div className="placar">
        <span className="pontos">{meusPontos}</span> : <span className="pontos">{pontosDoOponente}</span>
      </div>
    
      {/* Marcação de ponto */}
      <div className="marca-ponto">Ponto!</div>
    </div>

);
};

export default Pong;

Alguma ajuda em como solucionar esse problema

How to parse dynamic html element node.js

I do an axios request to an api that returns me an HTML page as a response.data. I need to save various information from that page (like name, date, address, etc.)
To parse the HTML I’m using jsdome. But when I try to get data from that page, I can not reference by its Id or class as it is generic and dynamic (for example: class=”col-sm-3 col-md-2″).

I tried to use the Xpath and evaluate dom.window.document.evaluate(path, document, null, XPathResult.ANY_TYPE, null)), but in jsdom it doesn’t work and in fact, they recommend to use another tool if I need the Xpath.

So my question is what could I use to get an element from a path like this: /html/body/pc-root/div/div/pc-applications/div/section/div[2]/section/div/div/div/section[2]/div[1]/h5

Would be grateful for your response as I am very new to programming

AppScripts Function returning NaN

I’ve been working on an automated ELO System in Google Sheets, and I have an issue with my AppScripts, in which the Formula which outputs a new ELO is for some reason returning NaN. Each individual value that goes into the formula is a number, so I was wondering what the issue is with my function?

Here is my code:

function Loop() {
    const Sheet2 = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet3Test');

    var EndRow = Sheet2.getLastRow();

    for (var i = 2; i <= EndRow; i++) {
        Utilities.sleep(12)
        var Team1ELO = Sheet2.getRange(i, 10).getValue()
        var Team2ELO = Sheet2.getRange(i, 11).getValue()
        var ExpectedResult = Sheet2.getRange(i, 12).getValue()
        var ActualResult = Sheet2.getRange(i, 13).getValue()
        var KFact = Sheet2.getRange(i, 14).getValue()



        var newELOVal = Sheet2.getRange(i, 8).getValue()
        var newELOVal2 = Sheet2.getRange(i, 9).getValue()

        if (newELOVal == "" & newELOVal2 == "" && Team1ELO != "" && Team2ELO != "" && KFact != "" && ActualResult != "" != ExpectedResult != "") {

            var TeamAELOOutput = Team1ELO + KFact * (ActualResult - ExpectedResult)

            var TeamBELOOutput = (Team2ELO + (KFact * ((1 - ActualResult) - (1 - ExpectedResult))))

            Sheet2.getRange(i, 8).setValue(TeamAELOOutput)
            Sheet2.getRange(i, 9).setValue(TeamBELOOutput)


        }
    }
}

Sorry for my sloppy code by the way, I just started using Sheets + AppScripts 2 days ago.

Express res.download() don’t work when calling from a function but work when direct call to API thorugh browser

I’ve a button and when clicked it’ll call the downloadFile function which make a call to backed to download a file.

async downloadFile(name) {
    await this.$axios.$get(process.env.API_LINK + '/api/files/' + name)
},
app.get('/api/files:name', (req, res) => {
    res.download('files/' + req.params.name, function (error) {
      console.log('Error : ', error);
    });
})

When the button is clicked, the console print the error as undefined BUT when I direct access the API through the browser (localhost:9000/api/files/teste.pdf), the file is downloaded.

The file name is being correctly passed to the API when the button is clicked.

How can I setup a “can visit the link once and only once” kind of permission for my links in django?

I am creating a game webapp using on HTML CSS and Django. There is no JS involved so far because I dont know JS well enough to implement it in my app. I am not a webdeveloper either. I just know python and basic web design. Now to my issue: I have setup various tasks in different levels of the game. the user can visit these task to play them. But they should not be allowed to visit these tasks again after they’ve played it once. I was think of disabling the link after visiting once. Or maybe lock the link and make it unaccessable after visiting it one time and only be able to unlock it through the admin panel with a toggle or something. These are the ideas I have but don’t know how to code.
How can I implement this in django. I am also open to solutions on the front end with JS. Is this a case for django permissions or is it something else?.

an image of the the levels dashboard

I have tried targeting links using :visited pseudo class but not what I wanted.

Why isn’t my sticky header changing background color and text?

I have a problem in my header. Its purpose is to stay on the page when you scroll. So with a fixed position and being sticky. During scrolling, its background changes color as well as the text. However, it doesn’t work. It’s sticky and fixed, but nothing else appears. So the background and color don’t change. Here’s the HTML, CSS and JS.

window.addEventListener("scroll", function () {
    var header = document.querySelector("header");
    header.classList.toggle("sticky", window.scrollY > 0);
  });
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap");

html, body{
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    scroll-behavior: smooth;
}

body{
    width: 100vw;
    height: 100vh;
    margin: 0;
    background: #222;
}

header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: 0.6s;
  padding: 40px 5px;
  z-index: 1000;
}

header.sticky {
  padding: 40px 100px;
  background-color: black;
}

header .logo {
  margin-left: 60px;
  position: relative;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  font-size: 2em;
  text-transform: uppercase;
  letter-spacing: 2px;
  transition: 0.6s;
}

header ul {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

header ul li {
  margin-right: 50px;
  position: relative;
  list-style: none;
}

header ul li a {
  position: relative;
  margin: 0 15px;
  text-decoration: none;
  color: #fff;
  letter-spacing: 2px;
  font-weight: 500;
  transition: 0.6s;
}

li a:hover {
  color: cyan;
}

.section1, .section2, .section3, .section4, .section5, .section6, .section7{
    width: 100%;
    min-height: 100vh;
    position: relative;
}

.section1::before{
    content: "";
    width: 100%;
    height: 100%;
    position: absolute;
    background: url(moonlight.jpg) top center fixed;
    background-size: cover;
}

.section2 {
  background: #141414;
  color: white;
}

.section3 {
  background: white;
}

.section4 {
  background: white;
}

.section5 {
  background: white;
}

.section6 {
  background: white;
}

.section7 {
  background: white;
}

.About{
    font-size: 50px;
    text-align: center;
    font-family: 'Franklin Gothic Heavy';
}

.section1 .parallax-hangman {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  position: fixed;
  font-family: 'Franklin Gothic Heavy';
  font-size: 15vw;
  color: white;
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.3), 5px 5px 70px rgba(255, 255, 255, 0.5), 0 0 10px rgba(255, 255, 255, 0.8);
}


#image-track {
    display: flex;
    gap: 4vmin;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(0%, -50%); 
    user-select: none;
  }
  
#image-track > .image {
    width: 40vmin;
    height: 56vmin;
    object-fit: cover;
    object-position: 100% center;
}

#image-track .image {
    transition: transform 0.3s ease;
}

#image-track .image.full-size {
    max-width: 100%;
    object-fit: contain;
    transform: scale(1.5);
}

@media (width <= 1499px){
    .html{
    flex-direction: column;
    }
}
```html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" type="text/css" href="styles.css"/>
    <title>Hangman</title>
</head>
<body>
<header id = "top">
    <a href="#section1" class="logo">Logo</a>
    <ul>
      <li><a href="#section2">Sommaire</a></li>
      <li><a href="#section3">Go</a></li>
      <li><a href="#section4">Git</a></li>
      <li><a href="#section5">Gitea</a></li>
      <li><a href="#section6">Règles</a></li>
      <li><a href="#section7">Jeu</a></li>
    </ul>  
  </header>
    <div class="section1" id = "section1">
        <div class="parallax-hangman">HANGMAN</div>
    </div>

    <div class="section2" id="section2">
        <div class="About">Sommaire</div>
    </div>

    <div class="section3" id="section3">
        <div class="About">Go, c'est quoi ?</div>
    </div>

    <div class="section4" id="section4">
        <div class="About">Git, c'est quoi ?</div>
    </div>

    <div class="section5" id="section5">
        <div class="About">Gitea, c'est quoi ?</div>
    </div>

    <div class="section6" id = "section6">
        <div id="image-track" data-mouse-down-at="0" data-prev-percentage = "0">
            <img class="image" src="installation.png" draggable="false"/>
            <img class="image" src="https://github-production-user-asset-6210df.s3.amazonaws.com/153553034/289691894-ecf6bf92-9fd6-427e-8c83-3ddce18eefa2.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240113%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240113T121811Z&X-Amz-Expires=300&X-Amz-Signature=8f3debc38bb1c093582577e66f2ebf0def75f46aa82cdb1297a3f7cf271a2761&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=730370407" draggable="false"/>
            <img class="image" src="Settings.PNG" draggable="false"/>
            <img class="image" src="https://github-production-user-asset-6210df.s3.amazonaws.com/153553034/289691782-8643510e-6288-4151-8e0b-018a3d276265.jpg?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAVCODYLSA53PQK4ZA%2F20240113%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20240113T121912Z&X-Amz-Expires=300&X-Amz-Signature=a0b8072d79ad6369fe85ce11894b886faf3727fa371dc4d14f0e052ab28d8774&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=730370407" draggable="false"/>
        </div>   
    </div>    
    <div class="section7" id = "section7"> Jeu </div>
    <script src="javaScript.js"></script>
</body> 
</html>

index.html freezes when opened on Google [closed]

I am trying to open the index.html file in the Java folder, but Google freezes. How can I solve the problem?

I was expecting index.htm not to freeze when opened your text

I am trying to open the index.html file in the Java folder, but Google freezes. How can I solve the problem?

I was expecting index.htm not to freeze when opened your text

How to change the day format in resource view using library React FullCalendar?

I’m using React FullCalendar with the resource view, specifically the resourceTimelineWeek view. Currently, the day format in the header is displayed in the default format I want to customize it to a different format (e.g., “Sunday”, “Monday”).

Fullcalendar resource time line view with custom 7 days

views={{ timeLineWeek: { type: "resourceTimelineWeek", slotDuration: { days: 1 }, }, }}

Bootstrap style import has a problem in React.js

I’m making a blog website using react.js and for its navbar I’m using Bootstrap. The problem is that when I import the Bootstrap styles, it’ll change the whole website style such as fonts, flexbox, and grid.
I import this line: import 'bootstrap/dist/css/bootstrap.min.css';

And from this:
Before

Coverts to this:
enter image description here

I want it to just be applied on my navbar, not other places.
I would appreciate the assistant people…

CREATE_MESSAGE in discord bot using WebSocket (node.js)

I’m having trouble making the bot send a message when the user types !ping. The bot doesn’t respond to the !ping message with Pong! in the channel, but it is being sent to the console. Here’s the code:

const WebSocket = require('ws');

const ws = new WebSocket('wss://gateway.discord.gg/?v=10&encoding=json');

const payload = {
    op: 2,
    d: {
        token: 'I REMOVED IT',
        intents: 3276799,
        properties: {
            $os: 'linux',
            $browser: 'chrome',
            $device: 'chrome'
        }
    }
}

ws.on('open', function open() {
    ws.send(JSON.stringify(payload));
});

ws.on('message', function incoming(data) {
    let payload = JSON.parse(data);

    const { d, event, op, t } = payload;

    switch (op) {
        case 10:
            const { heartbeat_interval } = d;
            interval = heartbeat(heartbeat_interval);
            break;
    }

    switch (t) {
        case 'MESSAGE_CREATE':
            console.log(d.author.username + ' : ' + d.content);

            if (d.content === '!ping') {
                const response = {
                    op: 1,
                    d: {
                        content: 'Pong!',
                        tts: false
                    }
                }

                ws.send(JSON.stringify(response));
            }
    }
});

const heartbeat = (ms) => {
    return setInterval(() => {
        ws.send(JSON.stringify({ op: 1, d: null }));
    }, ms);
}

INFO: This is my first experience with WS to create a Discord bot, so please forgive me if something is simple or trivial.

I tried to change ‘op’, but errors occur because ‘op’ varies based on its number.

GitHub Pages Hosting Issue [closed]

I made Spotify clone. When I open live server in VS Code it’s running properly. But when I open it on GitHub Pages, all my mp3 songs are not loaded and viewed.

The repo: https://github.com/arnavnagpurkar/Spotify-Clone/
The Github Pages site: https://arnavnagpurkar.github.io/Spotify-Clone/

What should I do to host this?

On GitHub Pages it looks like this: Github Pages Screenshot

On my localhost it looks like this: Localhost site screenshot

It should look same in GitHub Pages and work the same as it looks in localhost.

Can anyoneo help me how to host this and it should be fully functional !?