glb model cant be accessed after build – Three.js

I imported a model using GLTFLoader and it works perfectly with npm run dev but when I build it with npx vite build it doesn’t seem to be able to access the model file. the file is stored at /public/models/miku_pde.glb

npm run dev:
run with npm run dev

after build:
after build

this is the part of the code used for importing the model

import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';

let model;
const loader = new GLTFLoader();
const modelPath = "/models/miku_pde.glb";

loader.load(modelPath, (gltf) => {
  model = gltf.scene;
  model.position.y = -15;
  scene.add(model);
});

i expected the model to show. I tried to make sure the path was correct but it always didn’t work after build

Error while using npm run dev command to run a next js app

error in the terminal:

$ npm run dev
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:UsersHARSH KUMARDesktopAmazon watchdogpackage.json
npm ERR! errno -4058
npm ERR! enoent Could not read package.json: Error: ENOENT: no such file or directory, open ‘C:UsersHARSH KUMARDesktopAmazon watchdogpackage.json’
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: C:UsersHARSH KUMARAppDataLocalnpm-cache_logs2023-11-29T03_32_33_232Z-debug-0.log

package.json file:

{
“name”: “my-app”,
“version”: “0.1.0”,
“private”: true,
“scripts”: {
“dev”: “next dev”,
“build”: “next build”,
“start”: “next start”,
“lint”: “next lint”
},
“dependencies”: {
“react”: “^18”,
“react-dom”: “^18”,
“next”: “14.0.3”
},
“devDependencies”: {
“typescript”: “^5”,
“@types/node”: “^20”,
“@types/react”: “^18”,
“@types/react-dom”: “^18”,
“autoprefixer”: “^10.0.1”,
“postcss”: “^8”,
“tailwindcss”: “^3.3.0”
}
}

How can i resolve this error , i’ve tried updating , node , npm but i’m getting the same error.

Async const return object [duplicate]

I am trying to create a reusable function to return data from fetch. Like so many others I am only getting the Promise {<pending>} not the actual object that is inside the pending promise.

This is my code:

async function getapi(u, h, p) {
    const response = await fetch(u,{"method": "POST", headers: h, "body": JSON.stringify(p)});
    var data = await response.json();
    if (response){
        return data
    }
}

const status = getapi(api_url, headers, post);
console.log(status);

This will return Promise {<pending>}.

However, if I add a function inside the getApi() it will return the actual result like this:

async function getapi(u, h, p) {
    const response = await fetch(u,{"method": "POST", headers: h, "body": JSON.stringify(p)});
    var data = await response.json();
    if (response){
        showData(data)
    }
}
const status = getapi(api_url, headers, post);
console.log(status);

function showData(data){
    console.log('showData', data)
}

Then the console.log is {status: 1, result: 1} however this does not create a reusable wrapper.

I need to get the object returned from the single getapi() function.

Thanks

Using A Script Tag File And calling Function From The Script In Angular Component

I am trying to integrate clover ecommerce iframe into my angular application but am running into an issues. I am trying to get This example to work in my angular projects component but it fails to find the name clover. I looked for a typescript package but could not find one.

I put this tag in the index.html file:

<script src="https://checkout.sandbox.dev.clover.com/sdk.js">

But when creating the clover and elements globally in my component:

clover = new Clover('a2c04bd36719c1ae6867d9f978f7cefa');
elements = clover.elements();

I get the following error:

TS2304: Cannot find name 'Clover'.

Is there something I am missing? I tried adding the link to the index.html and in the angular.json but that was no luck either. How can I add this script file successfully to my angular project and call its functions?

404 error when try to import files in html

I have a project in pycharm which use app.py to call the page1 and page2_test html file. My project structure is like this:
Project structure
All the csv and jpg files are in the data folder.

My app.py file is like this:

from flask import Flask, request, render_template, redirect, url_for, session, jsonify
from datetime import datetime
import logging
from portfolio import portfolio

#app = Flask(__name__)
app = Flask(__name__, static_url_path='/data')
app.secret_key = 'your_secret_key'  # Replace 'your_secret_key' with a real secret key

@app.route('/')
def home():
    return render_template('page1.html')

@app.route('/trading', methods=['GET', 'POST'])
def trading_page():
    if request.method == 'POST':
        crypto = request.form.get('crypto')
        start_date = request.form.get('start-date')
        session['trading_data'] = {'crypto': crypto, 'start_date': start_date}
        logging.info(f"Trading page accessed with crypto: {crypto}, start date: {start_date}")
        print(f"Trading page accessed with crypto: {crypto}, start date: {start_date}")
        #global portfolio =
    return render_template('page2_test.html', title='Trading Page', data=session.get('trading_data', {}))


if __name__ == '__main__':
    app.run(debug=True, port=5002)

For example, I want to import the a jpg file as my background. In the html, I have:

background-image: url('{{ url_for('static', filename='Background1.jpg') }}');

However, when I get to page2_test with the url http://127.0.0.1:5002/trading. The Background1.jpg cannot be found. I get the error:404 error

How can I fix it?

Changes label position in Google Pie Chart

I’m using regular 3D pie chart from Google visualization like this one

`

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

<script type="text/javascript">

  google.charts.load("current", {packages:["corechart"]});

  google.charts.setOnLoadCallback(drawChart);

  function drawChart() {

    var data = google.visualization.arrayToDataTable([

      ['Task', 'Hours per Day'],

      ['Work',     11],

      ['Eat',      2],

      ['Commute',  2],

      ['Watch TV', 2],

      ['Sleep',    7]

    ]);

    var options = {

      title: 'My Daily Activities',

      is3D: true,

    };

    var chart = new google.visualization.PieChart(document.getElementById('piechart_3d'));

    chart.draw(data, options);

  }

</script>
<div id="piechart_3d" style="width: 900px; height: 500px;"></div>

`

I would like to ask a question, how I want put label under pie chart ?

I can’t find anything how to customize the label position.

Dynamic Horizon: Interactive List with Edge Fades in white background

I have a list of items. At both ends of my list when there is still some content that isn’t preset yet on the page I want it to fade out like how it does for youtube[fade][1]
[1]: https://i.stack.imgur.com/fFIQO.png. Mine currently looks like [My list][1]
[1]: https://i.stack.imgur.com/EY4ep.png.
My html:

    <div class="content-bar">
        <button id="scroll-left"><</button>
        <div id="scroll-area">
            <ul>
                <li>All</li>
                <li>Music</li>
                <li>Sports leagues</li>
                <li>Romantic comedies</li>
                <li>Dramedy</li>
                <li>Gaming</li>
                <li>Fashion shows</li>
                <li>Live</li>
                <li>Cristiano Ronaldo</li>
                <li>Lionel Messi</li>
                <li>News</li>
                <li>Basketball</li>
                <li>Trailers</li>
                <li>Computer programming</li>
                <li>Podcasts</li>
                <li>Recently uploaded</li>
            </ul>
        </div>
        <button id="scroll-right">></button>
    </div>

my css:

.content-bar {
    display: flex;
    align-items: center;
    margin-left: 90px;
    margin-top: 10px;
    margin-bottom: 10px;
 }
 #scroll-right:hover, #scroll-left:hover {
    background-color: #d8d8d8;
 }

 #scroll-right, #scroll-left {
    padding: 10px 15px;
    border-radius: 50%;
    border: none;
    font-size: 20px;
    position: absolute;
    z-index: 3;
    background: transparent;
 }
 #scroll-right {
    right: 1%;
 }
 #scroll-left {
    left: 5.5%;
 }
  
 #scroll-area {
    overflow-x: hidden;
    white-space: nowrap;
    flex-grow: 1;
    width: 100%;
    position: relative;
 } 

 #scroll-area::before, #scroll-area::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 2;
    width: 100px; /* Width of the fading effect */
    pointer-events: none;
}

#scroll-area::before {
    left: 0;
    background: linear-gradient(to right, #ffffff 0%, transparent 100%);
}  
  
#scroll-area::after {
    right: 0;
    background: linear-gradient(to left, #ffffff 0%, transparent 100%);
}

#scroll-area::before, #scroll-area::after {
    display: none;
}

 #scroll-area ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: row;
 }
  
#scroll-area ul li {
    margin-right: 0px;
    padding: 2px 6px;
    border-radius: 5px;
    background-color: #efefef;
    font-family: "Roboto","Arial",sans-serif;;
    margin: 10px;
 } 

my js:

const scrollArea = document.getElementById('scroll-area');
const leftArrow = document.getElementById('scroll-left');
const rightArrow = document.getElementById('scroll-right');
let isDown = false;
let startX;
let scrollLeft;

function toggleArrows() {
   
    if (scrollArea.scrollLeft === 0) {
      leftArrow.style.display = 'none';
    } else {
      leftArrow.style.display = 'block';
    }
  
    if (scrollArea.scrollWidth - scrollArea.clientWidth - 1 <= scrollArea.scrollLeft) {
      rightArrow.style.display = 'none';
    } else {
      rightArrow.style.display = 'block';
    }
  }

document.addEventListener('DOMContentLoaded', toggleArrows);

scrollArea.addEventListener('scroll', toggleArrows);

document.getElementById('scroll-left').addEventListener('click', () => {
    const scrollArea = document.getElementById('scroll-area');
    scrollArea.scrollBy({ left: -200, behavior: 'smooth' }); 
});
  
document.getElementById('scroll-right').addEventListener('click', () => {
    const scrollArea = document.getElementById('scroll-area');
    scrollArea.scrollBy({ left: 200, behavior: 'smooth' });
    toggleArrows();
});

scrollArea.addEventListener('mousedown', (e) => {
  isDown = true;
  startX = e.pageX - scrollArea.offsetLeft;
  scrollLeft = scrollArea.scrollLeft;
});

scrollArea.addEventListener('mouseleave', () => {
  isDown = false;
});

scrollArea.addEventListener('mouseup', () => {
  isDown = false;
});

scrollArea.addEventListener('mousemove', (e) => {
  if (!isDown) return;
  e.preventDefault();
  const x = e.pageX - scrollArea.offsetLeft;
  const walk = (x - startX) * 2; 
  scrollArea.scrollLeft = scrollLeft - walk;
});


function toggleFadeEffects() {
  const maxScrollLeft = scrollArea.scrollWidth - scrollArea.clientWidth;

  // Toggle the 'fade-in' class based on the scroll position
  if (scrollArea.scrollLeft > 0) {
    scrollArea.classList.add('fade-in');
  } else {
    scrollArea.classList.remove('fade-in');
  }

  // Since the ::after pseudo-element indicates there is more content to the right,
  // you should check whether we're at the very end of the scroll area to hide the fade effect.
  if (scrollArea.scrollLeft < maxScrollLeft) {
    scrollArea.classList.add('fade-in');
  } else {
    scrollArea.classList.remove('fade-in');
  }
}

// Initial check
toggleFadeEffects();

// Event listener for the scroll event
scrollArea.addEventListener('scroll', toggleFadeEffects);

document.getElementById('scroll-left').addEventListener('click', () => {
  scrollArea.scrollBy({ left: -200, behavior: 'smooth' });
  setTimeout(toggleFadeEffects, 200); // Use a timeout to give the scroll action time to complete
});
  
document.getElementById('scroll-right').addEventListener('click', () => {
  scrollArea.scrollBy({ left: 200, behavior: 'smooth' });
  setTimeout(toggleFadeEffects, 200); // Use a timeout to give the scroll action time to complete
});

Modal Carousel Component In Astro Js

I have a component that renders 3 ‘cards’ when a user hovers each card it does some things (irrelevant) and when a user clicks a card it should open that corresponding card along with some carousel controls that when clicked should cycle through the 3 cards rendered. Where im having trouble is getting the corresponding clicked card to open (it will open a card at a different index). Or if i fix that, the carousel functionality breaks. The problem lies in the logic of the newIndex variable… i need one variation of the variable for the carousel functionality and another variation of the variable for when a user clicks a card to open it, and i cant figure out a condition to grab them accordingly.

See variables:

  newIndex = (activeIndex + direction + noiseCards.length) % noiseCards.length; // needed for carousel this grabs the wrong index if used for card click
  newIndex = (activeIndex + 3) % noiseCards.length; // needed for card click

full code applicable (i’ve left out some not applicable hover related functions):

document.addEventListener('DOMContentLoaded', function () {
  const noiseCards = document.querySelectorAll('.freq-wrapper');
  let currentIndex = 0;

  noiseCards.forEach((card, index) => {
    card.addEventListener('mouseenter', () => handleHover(index));
    card.addEventListener('mouseleave', resetHover);
    card.addEventListener('click', () => toggleContent(index));
  });

  const prevButton = document.querySelector('.carousel-control-prev');
  const nextButton = document.querySelector('.carousel-control-next');

  if (prevButton && nextButton) {
    prevButton.addEventListener('click', function () {
      navigateCarousel(-1);
    });

    nextButton.addEventListener('click', function () {
      navigateCarousel(1);
    });
  }

  function toggleContent(activeIndex: number) {
    const direction = activeIndex > currentIndex ? 1 : -1;
    const newIndex = (activeIndex + direction + noiseCards.length) % noiseCards.length;
    const newIndexT = (activeIndex + 3) % noiseCards.length;
    const useIndex = prevButton && nextButton ? newIndex : newIndexT;

    console.log(useIndex);
    console.log('newIndexT:', newIndexT);
    console.log('newIndex:', newIndex);

    noiseCards.forEach((card, index) => {
      const element = card as HTMLElement;
      const staticContent = card.querySelector('.background-content--static') as HTMLElement;
      const dynamicContent = card.querySelector('.background-content--dynamic')  as HTMLElement;
      const svgElement = card.querySelector('svg') as SVGSVGElement | null;

      if (prevButton && nextButton == null) {
        console.log('it was null')
        const shouldAddClass = index === newIndex;
        console.log(`Card ${index}: shouldAddClass=${shouldAddClass}`);
        toggleClassAndWidth(element, 'active--card', shouldAddClass);
        currentIndex = newIndexT;
      } else {
        console.log('it was true')
        const shouldAddClass = index === newIndex;
        toggleClassAndWidth(element, 'active--card', shouldAddClass);
        hideElement(staticContent, shouldAddClass);
        showElement(dynamicContent, shouldAddClass);
        hideSvgElement(svgElement, shouldAddClass);
        currentIndex = newIndex;
      }
      
    });


    toggleCarouselButtons();
    console.log('currentIndex:', currentIndex);
  }

  function toggleCarouselButtons() {
    const nextAndPrevButtons = document.querySelectorAll('.carousel-control');

    nextAndPrevButtons.forEach(button => {
      button.classList.add('carousel-control-prev--is-shown');
    });
  }

TypeError: Cannot read private member #samples from an object whose class did not declare it

I was using #samples for my class, but a strange thing happen, my code work sometimes but it throws exception other times:

TypeError: Cannot read private member #__samples from an object whose class did not declare it

I did search on the internet but none of them apply to my case (thus please don’t duplicate it or close with a simple glimpse):

  1. I don’t use the proxy
  2. From the vscode debugging, the this is the class that has the private field. When it works, I can see the #samples in this, and when it fails, I don’t see the #samples in this but I can all other members and methods in the class.
  3. I cannot reproduce the issue with the same code by extracting the code out of the repo.
  4. In my unit test with Jest within the repo, the same code runs successfully.

The sample code is (note this sample cannot reproduce the exception and I cannot paste the whole repo here)

class AF {
    #samples = [1, 3, 4];
    
    get samples() {
        return this.#samples;
    }
    addSamples(...samples) {
        this.#samples.push(...samples);
    }
}

const af = new AF();

class AFCollector {
    constructor() {
        this.afs = [];
    }
    addAF(af) {
        this.afs.push(af);
    }
    
    printAF(af) {
        if (af.samples.length !== 1) {
            console.log(af.samples.length, af.samples.join(','));
        }
    }
    main() {
        this.afs.map( af => this.printAF(af));
    }
}

const afCollector = new AFCollector();
afCollector.addAF(af);
afCollector.main(); // 3 1,3,4

I’m guessing some modules loaded in my repo cause this but I have no clue and no approach to pinpoint the culprit. Appreciate ANY HELP!

How to Animate and Stop Spin Wheel at Value we want

I created a spin wheel using javascript and html, all is perfectly work and now I want to add a value where the spin to stop at.

    function randomColor(){
        r = Math.floor(Math.random() * 255);
        g = Math.floor(Math.random() * 255);
        b = Math.floor(Math.random() * 255);
        return {r,g,b}
    }
    function toRad(deg){
        return deg * (Math.PI / 180.0);
    }
    function randomRange(min,max){
        return Math.floor(Math.random() * (max - min + 1)) + min;
    }
    function easeOutSine(x) {
        return Math.sin((x * Math.PI) / 2);
    }
    // get percent between 2 number
    function getPercent(input,min,max){
        return (((input - min) * 100) / (max - min))/100
    }


    const canvas = document.getElementById("canvas")
    const ctx = canvas.getContext("2d")
    const width = document.getElementById("canvas").width
    const height = document.getElementById("canvas").height

    const centerX = width/2
    const centerY = height/2
    const radius = width/2

    
    const items = [
          { minDegree: 0, maxDegree: 40, value: 1, name: "chicken" },
          { minDegree: 41, maxDegree: 80, value: 2, name: "neko" },
          { minDegree: 81, maxDegree: 120, value: 3, name: "bird" },
          { minDegree: 121, maxDegree: 160, value: 4, name: "goat" },
          { minDegree: 161, maxDegree: 200, value: 5, name: "sheep" },
          { minDegree: 201, maxDegree: 240, value: 6, name: "duck" },
          { minDegree: 241, maxDegree: 280, value: 7, name: "cow" },
          { minDegree: 281, maxDegree: 320, value: 8, name: "dog" },
          { minDegree: 321, maxDegree: 360, value: 9, name: "cat" },
        ];
    
    console.log(items);

    let currentDeg = 0
    let step = 360/items.length
    let colors = []
    for(let i = 0 ; i < items.length + 1;i++){
        colors.push(randomColor())
    }

    function createWheel(){
        // items = document.getElementsByTagName("textarea")[0].value.split("n");
        step = 360/items.length
        colors = []
        for(let i = 0 ; i < items.length + 1;i++){
            colors.push(randomColor())
        }
        draw()
    }
    draw()

    function draw(){
        ctx.beginPath();
        ctx.arc(centerX, centerY, radius, toRad(0), toRad(360))
        ctx.fillStyle = `rgb(${33},${33},${33})`
        ctx.lineTo(centerX, centerY);
        ctx.fill()

        let startDeg = currentDeg;
        for(let i = 0 ; i < items.length; i++, startDeg += step){
            let rewardName = items[i];
            let endDeg = startDeg + step;
            //console.log(rewardName + " startdegre"  + startDeg + " endDeg" + endDeg);

            color = colors[i]
            let colorStyle = `rgb(${color.r},${color.g},${color.b})`;

            ctx.beginPath();
            rad = toRad(360/step);
            ctx.arc(centerX, centerY, radius - 2, toRad(startDeg), toRad(endDeg));
            let colorStyle2 = `rgb(${color.r - 30},${color.g - 30},${color.b - 30})`;
            ctx.fillStyle = colorStyle2;
            ctx.lineTo(centerX, centerY);
            ctx.fill();

            ctx.beginPath();
            rad = toRad(360/step);
            ctx.arc(centerX, centerY, radius - 30, toRad(startDeg), toRad(endDeg));
            ctx.fillStyle = colorStyle;
            ctx.lineTo(centerX, centerY);
            ctx.fill();

            // draw text
            ctx.save();
            ctx.translate(centerX, centerY);
            ctx.rotate(toRad((startDeg + endDeg)/2));
            ctx.textAlign = "center";
            if(color.r > 150 || color.g > 150 || color.b > 150){
                ctx.fillStyle = "#000";
            }
            else{
                ctx.fillStyle = "#fff";
            }
            ctx.font = 'bold 24px serif';
            ctx.fillText(rewardName, 150, 10);
            ctx.restore();

            // check winner
            if(startDeg%360 < 360 && startDeg%360 > 270  && endDeg % 360 > 0 && endDeg%360 < 90 ){
                document.getElementById("winner").innerHTML = rewardName;
            }
        }
    }
    

    let speed = radiansUntilStop = 0;
    let maxRotation = randomRange(360*3,360*6);
    let pause = false;
    function animate(){
        if(pause){
            return;
        }
        console.log(currentDeg);

        speed = easeOutSine(getPercent(currentDeg ,maxRotation ,0)) * 20
        // speed = getPercent(currentDeg ,maxRotation ,0)
        if(speed < 0.01){
            speed = 0;
            pause = true;
        }
          if( currentDeg >= radiansUntilStop ) {
            // stop spinning the wheel
            currentDeg = radiansUntilStop;
            speed = 0;
             pause = true;
          }
        
        currentDeg += speed;
        draw()
        window.requestAnimationFrame(animate);
    }
    
    function spin(){
        if(speed != 0){
            return
        }
        currentDeg = 0
        maxRotation = randomRange(360*3,360*6)
        console.log(maxRotation);
        radiansUntilStop = 41;
        pause = false
        window.requestAnimationFrame(animate);
    }

I set a value radiansUntilStop to stop the spin at “neko” yes its stop at it, but the spin not animate (spin at random times then stop) only stop without animation
here is the demo https://jsfiddle.net/wsmcf8ub/

I try to remove the code

      if( currentDeg >= radiansUntilStop ) {
        // stop spinning the wheel
        currentDeg = radiansUntilStop;
        speed = 0;
         pause = true;
      }

then it animate the spin but will stop at random value

https://jsfiddle.net/7b61p4az/

What I want is to animate it then stop at value we set, any ways to fix this? thanks

disable add br tag when get content tinymce

I have a problem like this:

  • T am using tinymce v6. whenever i using tinymce.get(“html”).getContent() it always add
    tag after linebreak. So can someone help me that disable auto add
    tag after linebreak.
    I have tried:

    forced_root_block: false,
    force_br_newlines: false,
    force_p_newlines: false,

But it does not work in v6.

HERE IS MY CODE

tinymce.init({
            selector: 'textarea#html',
            plugins: 'anchor autolink charmap codesample emoticons image media code link lists searchreplace table visualblocks wordcount',
            imagetools_cors_hosts: ['picsum.photos'],
            menubar: 'file edit view insert format tools table help',
            toolbar: 'undo redo | blocks fontfamily fontsize | bold italic underline strikethrough highlight custom | link image media code ruby table mergetags | align lineheight | tinycomments | numlist bullist indent outdent | emoticons charmap removeformat',
            toolbar_sticky: true,
            // toolbar_mode: 'floating',
            toolbar_mode: 'wrap',
            autosave_ask_before_unload: true,
            paste_data_images: true,
            autosave_interval: '30s',
            autosave_retention: '2m',
            height: 800,
            statusbar: false,
            forced_root_block: false,
            force_br_newlines: false,
            force_p_newlines: false,
            extended_valid_elements: 'script[language|type|src]',
            content_css: ['/dist/css/adminlte.min.css'],
            content_css_cors: true,
            importcss_append: true,
            convert_urls: false
        });

Really sorry for my bad english!!!

disable auto add
tag after linebreak in tinymce v6

‘fetch’ing a URL gives me a CORS error, but when I paste the URL into the address bar it works

I’m working on a Rails site with rack-cors. I’m doing a js fetch request, which is failing with a CORS error (I think the error comes in when a redirect is attempted):

No 'Access-Control-Allow-Origin' header is present on the requested resource.

Copy / pasting the “Location” in the response headers into the address bar works fine.

The URL it should be redirecting to is in the Rails public folder. It’s an HTML game that I copy/paste from game builds. The game then communicates with the remote server using the token provided in the initial response.

I think the error may be related to rack-cors not coming into action as the redirect request is to a page in public.

Chrome console for the failing request, which should be followed by a redirect:

GENERAL

Request URL:
https://example.com/api/example/createToken?url=http://localhost:3000/demo/game-name/&game_session=gjaR_4bTCiae7DkNYw1nTYJschF6RxXxJ6eNquYhdr0=&setCookie=true
Request Method: GET
Status Code: 302 Found
Referrer Policy: strict-origin-when-cross-origin

RESPONSE HEADERS:

Cache-Control: no-store
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Date: Wed, 29 Nov 2023 00:48:46 GMT
Location: http://localhost:3000/demo/game-name/?jwt={TOKEN}
Request-Id: clj8krj0cl4nridf6m8g
Server: nginx/1.24.0
Set-Cookie: jwt={TOKEN};Path=/
Strict-Transport-Security: max-age=63072000; includeSubDomains; preload
Transfer-Encoding: chunked
X-Content-Type-Options: nosniff
X-Powered-By: Express

REQUEST HEADERS:

Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: en-GB,en-US;q=0.9,en;q=0.8
Cache-Control: no-cache
Connection: keep-alive
Dnt: 1
Host: example.com
Origin: http://localhost:3000
Pragma: no-cache
Referer: http://localhost:3000/
Sec-Ch-Ua: "Google Chrome";v="119", "Chromium";v="119", "Not?A_Brand";v="24"
Sec-Ch-Ua-Mobile: ?0
Sec-Ch-Ua-Platform: "macOS"
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: cross-site
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36

Any suggestions for ways to move forwards much appreciated.

Uploading and Displaying Compressed Images in PHP – Optimization Help Needed

I have a website with a form that allows users to upload four images to the database when they click on the confirm button. However, the form takes a long time to submit due to the large size of the images. I’m looking for a solution to compress these images on the client side before uploading them to the database using PHP.

Here’s a brief overview of what I’m trying to achieve:

The website has a form with four image upload fields.
When the user clicks on the confirm button, I want to compress these images on the client side before uploading them to the database.
I’m using PHP on the server side to handle the form submission and database interaction.
After compression and upload, I want to display the compressed images on the website.

I tried to solve this problem using JavaScript but it was not solved
I expected the form submission to be faster due to the image compression, but I’m unsure about how to handle the compressed images on the client and server side and subsequently display them on the website. Any guidance on best practices for PHP handling of compressed images and database storage or any library solution would be greatly appreciated.

Why do the JavaScript Array methods includes() and indexOf() not recognize the words in my array? [closed]

I am writing a simple word counting program in Node.js, and I am not counting certain words from a list that is in a file with one word on each line. I have converted this file to an array with this code:

var exclude = fs.readFileSync(process.argv[3], 'utf-8')
    .split('n')
    .filter(Boolean); 

However, when I try to check if a word exists in the array using exclude.includes() or exclude.indexOf(), it returns false or -1 respectively for any word, whether the word exists in the list or not. I have printed out the array, and I can see that all the words are there. I have checked the type of the items in the array using typeof() to make sure they are strings and that I haven’t accidentally converted them to objects of some kind, and I have checked the type of the variables I’m seeking to compare against the array as well.

I have specifically checked individual words I know are in the array like so

console.log(exclude.indexOf("the")+" the");

and the result is -1 the. I have tried the same thing using includes(). Why can’t these methods find the strings that are in the array?