MUI CheckBox fill color when the box is unticked

I have a requirement to show checkboxes like below when there is no check.

enter image description here

When the user marks the checkbox it should be like this

enter image description here

The second thing I already achieved with this code

 <Checkbox
        sx={{
          color: "#DFE0EB",
          // backgroundColor: "#DFE0EB",
          "&.Mui-checked": {
            color: "#1DFB9D"
          }
        }}
      />

But when the user doesn’t mark the checkbox how can I fill it with this color #DFE0EB

This is my code

Animated text slides off to the right in HTML CSS

The tutorial I followed for the animated text is: https://www.youtube.com/watch?v=4PbgtyE0mGs .

The animated text appears correctly and works, however, when the animation has finished, the text slides off to the right off the screen. After having a look online, it looks like I need to use display:flex , however, using this makes my custom cursor implementation not work. The custom cursors do not stay as the png image for most of the page. Is there any other way to fix this issue?

Here is my HTML page:

    <!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <link rel="stylesheet" href="style.css">
    </head>

    <body>

        <h1 data-text="&nbsp;Hi! I'm Julie &#58;&#41&nbsp;">&nbsp;Hi! I'm Julie &#58;&#41&nbsp;</h1>

        <div class="main-wrapper">
            <div class="season winter" data-background="#2b1055">Winter</div>
            <div class="season summer" data-background="#5988e2">Summer</div>
            <div class="season spring" data-background="#7cdea1">Spring</div>
            <div class="season autumn" data-background="#f79762">Autumn</div>
        </div>

        <div class="wrapper">
            <div>
                <img id="earth" src="img/earth.png" alt="scroll">
            </div>
        </div>

        <script src="app.js"></script>
    </body>
</html>

CSS:

    * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}

body {
  transition: background 1s ease-in-out; 
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  text-align: center;
}

h1 {
  align-items: center;
  position: relative;
  font-size: 6em;
  color: transparent;
  margin: 40px;
  cursor: url('img/winter-cursor.png'), auto;
}

h1::before {
  content: attr(data-text);
  position: absolute;
  color: white;
  width: 350px;
  overflow: hidden;
  white-space: nowrap;
  border-right: 4px solid #fff;
  animation: animate 8s linear infinite;
  filter: drop-shadow(0 0 20px #fff);
}

@keyframes animate {
  0%, 10%, 100% {
    width: 0;
  }
  70%, 90% {
    width: 100%;
  }
}

.season {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100vh;
  color: #fff;
  font-family: sans-serif;
  font-size: 72px;
  font-weight: 600;
  text-transform: uppercase;
}

.winter {
  cursor: url('img/winter-cursor.png'), auto;
}

.summer {
  cursor: url('img/summer-cursor.png'), auto;
}

.spring {
  cursor: url('img/spring-cursor.png'), auto;
}

.autumn {
  cursor: url('img/autumn-cursor.png'), auto;
}

.wrapper {
  top: 120%;
  left: 50%;
  transform: translate(-50%, -50%);
  position: fixed;
  cursor: url(img/earth-cursor.png), auto;
}

#earth {
  width: 800px;
  height: 800px;
  cursor: url(img/earth-cursor.png), auto;
}

Why does website look different in google chrome incognito mode

I think that I have lost control in my website https://www.shailenders.com because its diffrent shows in incognito tab last 2 weeks. I cleared all cache and coockies in my chrome browser history and use 4 diffrent browsers.

I removed old cache plugin and also delet all all cache files in cpanal. But I dont get any fresh result in me website. I changed my “website homepage into latest post” but in incognito tab is show old hompage ” statics page”.

Please Give me Solution “How Can I fix it”.

https://www.shailenders.com** because its diffrent shows in incognito tab last 2 weeks. I cleared all cache and coockies in my chrome browser history and use 4 diffrent browsers.

I removed old cache plugin and also delet all all cache files in cpanal. But I dont get any fresh result in me website. I changed my “website homepage into latest post” but in incognito tab is show old hompage ” statics page”.

Please Give me Solution “How Can I fix it”.

Postponing .then() calls on a Promise returned from an async JavaScript function until after multiple awaits have run inside the function

I am using an asynchronous JavaScript http client to download & process some paged JSON data from an initial URI & subsequent page URIs.

Each JSON page includes the URI for the next page, if there are more pages.

Sometimes, I need to process all pages for an initial URI & its subsequent page URIs before progressing to the next completely new initial URI.

I’d prefer to use await calls to the async http client to handle the initial URI & all subsequent page URIs all within an single call to my own async function (named f()), calling .then() on the Promise returned from f() to process a second initial URI only after the first initial URI & all of its pages have been downloaded & processed, rather than having to pass a callback to f() that I must manually call at the end of f().

e.g., can f() and/or the code that uses it below be modified such that 'uri2' will only be processed after all pages of 'uri1' have been processed without resorting to something like the manual callback mechanism in g()?

async function f(initialPageUri) {
  let nextPageUri = initialPageUri
  while (nextPageUri) {
    const o = await getObjectFromJsonFromUri(nextPageUri)
    // do stuff with o
    nextPageUri = o.nextPageUri
  }
}

f('uri1').then(() => f('uri2'))

async function g(initialPageUri, then) {
  let nextPageUri = initialPageUri
  while (nextPageUri) {
    const o = await getObjectFromJsonFromUri(nextPageUri)
    // do stuff with o
    nextPageUri = o.nextPageUri
  }
  then()
}

g('uri1', () => g('uri2', () => {}))

Adding http headers in JsonRpcProvider of ethers.js

I like to add next http headers in JsonRpcProvider of ethers.js v6.x.

const headers = {
   'authorization': AUTH_VAL,
   'x-chain-id': '1001'
}

In v5.x version, ConnectionInfo object is accepted as the argument of constructor like next.

const connInfo = { url: URL, headers: headers };
const provider = new ethers.providers.JsonRpcProvider(connInfo);
const resp = await provider.send("klay_blockNumber", []);

A few links tell FetchRequest is the replacement of ConnectionInfo.
But next code lines result in error in the send() statement.

let fetchReq = new FetchRequest(url);
fetchReq.method = 'POST';
fetchReq.setHeader('authorization', AUTH_VAL);
fetchReq.setHeader('x-chain-id', '1001');
const resp = await provider.send('klay_blockNumber', []);

The error received:
{code: ‘SERVER_ERROR’, request: FetchRequest, response: FetchResponse, error: undefined, stack: ‘Error: server response 400 Bad Request (reque…commonjs/providers/provider-jsonrpc.js:239:40’, …}

I’d like to get some samples that set custom http headers and send Json RPC request with ethers.js v6.

How to change the shape of a Marker

How could i display a marker like this in my app (using react native): example

Currenty is looking like this: image

I want the marker to have that tail/arrow in the bottom.

this is the style that i’m using:

ballon: {
    height: 60,
    width: 60,
    borderRadius: 100,
    backgroundColor: '#2ec4b6',
    justifyContent: 'center',
    alignItems: 'center',
  },
  imgInsideBallon: {
    height: 55,
    width: 55,
    borderRadius: 100,

Change the shape of the Marker.

How to make WebRTC works between Host and a service in the docker compose network?

Here is a diagram explaining the issue I am facing and trying to solve.

This prevents my browser to peer connect, through webRTC, to a service running in a docker container which belongs to the docker-compose default network.

enter image description here

Here is what I tried so far with no success:

  • Using STUN and a TURN servers
  • Using the extra_hosts option in docker compose for both containers with the following value: host.docker.internal:host-gateway

So my question is: why the iceConnection transitions from checking to disconnected states, and more importantly, how to solve this?

Note:
My assumption is that the WebRTCPeerconnection from the code running in the web browser fails to connect to the socket opened by the service running in the container because Host and Docker Compose project are not in the same network. I would have thought that the TURN middleman would solve this though, which is not the case apparently.

Can I Embed a Custom Video Player with Local Videos in Google Sites?

I have added a html file through Embed tag in Google Sites. This is a custom video player. I used <video> tag to add video into the page but in case of google sites there is no file manager system, you know. That’s why I can’t locate the video file in there.
Is there any way to add local videos (of course uploaded on google drive or directly on the site page <I don’t know whether it is possible or not>)?

I have also tried youtube’s video url in src attribute. And simply didn’t work. I was expecting that the two players will overlay. In case of testing on my localpc chrome’s default video player and my video player overlayed.

THE CODE Only (sorry for the mess. one file embed is supported there so i bring all the three files- .html, .css, .js together.)

    <!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>Megaplex</title>
    <link rel="stylesheet" href="style.css">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- These 3 links are only for icons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css">
    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Rounded:opsz,wght,FILL,[email protected],100..700,0..1,-50..200" />
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<style>
/* Import Google font - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600&display=swap');
*{
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Poppins', sans-serif;
}
body{
  min-height: 100vh;
  background: hsl(0, 0%, 0%);
}
body, .container, .video-controls, .video-timer, .options{
  display: flex;
  align-items: center;
  justify-content: center;
}
.container{
  width: 98%;
  user-select: none;
  overflow: hidden;
  max-width: 900px;
  border-radius: 5px;
  background: #000;
  aspect-ratio: 16 / 9;
  position: relative;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}
.container.fullscreen{
  max-width: 100%;
  width: 100%;
  height: 100vh;
  border-radius: 0px;
}
.wrapper{
  position: absolute;
  left: 0;
  right: 0;
  z-index: 1;
  opacity: 0;
  bottom: -15px;
  transition: all 0.08s ease;
}
.container.show-controls .wrapper{
  opacity: 1;
  bottom: 0;
  transition: all 0.13s ease;
}
.wrapper::before{
  content: "";
  bottom: 0;
  width: 100%;
  z-index: -1;
  position: absolute;
  height: calc(100% + 35px);
  pointer-events: none;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
}
.video-timeline{
  height: 7px;
  width: 100%;
  cursor: pointer;
}
.video-timeline .progress-area{
  height: 3px;
  position: relative;
  background: rgba(255, 255, 255, 0.6);
}
.progress-area span{
  position: absolute;
  left: 50%;
  top: -25px;
  font-size: 13px;
  color: #fff;
  pointer-events: none;
  transform: translateX(-50%);
}
.progress-area .progress-bar{
  width: 0%;
  height: 100%;
  position: relative;
  background: #2289ff;
}
.progress-bar::before{
  content: "";
  right: 0;
  top: 50%;
  height: 13px;
  width: 13px;
  position: absolute;
  border-radius: 50%;
  background: #2289ff;
  transform: translateY(-50%);
}
.progress-bar::before, .progress-area span{
  display: none;
}
.video-timeline:hover .progress-bar::before,
.video-timeline:hover .progress-area span{
  display: block;
}
.wrapper .video-controls{
  padding: 5px 20px 10px;
}
.video-controls .options{
  width: 100%;
}
.video-controls .options:first-child{
  justify-content: flex-start;
}
.video-controls .options:last-child{
  justify-content: flex-end;
}
.options button{
  height: 40px;
  width: 40px;
  font-size: 19px;
  border: none;
  cursor: pointer;
  background: none;
  color: #efefef;
  border-radius: 3px;
  transition: all 0.3s ease;
}
.options button :where(i, span) {
  height: 100%;
  width: 100%;
  line-height: 40px;
}
.options button:hover :where(i, span){
  color: #fff;
}
.options button:active :where(i, span){
  transform: scale(0.9);
}
.options button span{
  font-size: 23px;
}
.options input{
  height: 4px;
  margin-left: 3px;
  max-width: 75px;
  accent-color: #0078FF;
}
.options .video-timer{
  color: #efefef;
  margin-left: 15px;
  font-size: 14px;
}
.video-timer .separator{
  margin: 0 5px;
  font-size: 16px;
  font-family: "Open sans";
}
.playback-content{
  display: flex;
  position: relative;
}
.playback-content .speed-options{
  position: absolute;
  list-style: none;
  left: -40px;
  bottom: 40px;
  width: 95px;
  overflow: hidden;
  opacity: 0;
  border-radius: 4px;
  pointer-events: none;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
  transition: opacity 0.13s ease;
}
.playback-content .speed-options.show{
  opacity: 1;
  pointer-events: auto;
}
.speed-options li{
  cursor: pointer;
  color: #000;
  font-size: 14px;
  margin: 2px 0;
  padding: 5px 0 5px 15px;
  transition: all 0.1s ease;
}
.speed-options li:where(:first-child, :last-child){
  margin: 0px;
}
.speed-options li:hover{
  background: #dfdfdf;
}
.speed-options li.active{
  color: #fff;
  background: #3e97fd;
}
.container video{
  width: 100%;
}

@media screen and (max-width: 540px) {
  .wrapper .video-controls{
    padding: 3px 10px 7px;
  }
  .options input, .progress-area span{
    display: none!important;
  }
  .options button{
    height: 30px;
    width: 30px;
    font-size: 17px;
  }
  .options .video-timer{
    margin-left: 5px;
  }
  .video-timer .separator{
    font-size: 14px;
    margin: 0 2px;
  }
  .options button :where(i, span) {
    line-height: 30px;
  }
  .options button span{
    font-size: 21px;
  }
  .options .video-timer, .progress-area span, .speed-options li{
    font-size: 12px;
  }
  .playback-content .speed-options{
    width: 75px;
    left: -30px;
    bottom: 30px;
  }
  .speed-options li{
    margin: 1px 0;
    padding: 3px 0 3px 10px;
  }
  .right .pic-in-pic{
    display: none;
  }
}
</style>
  </head>
  <body>
    <div class="container show-controls">
        <div class="wrapper">
            <div class="video-timeline">
            </div>
            <ul class="video-controls">
                <li class="options left">
                    <button class="volume"><i class="fa-solid fa-volume-high"></i></button>
                    <input type="range" min="0" max="1" step="any">
                    <div class="video-timer">
                        <p class="current-time">00:00</p>
                        <p class="separator"> / </p>
                        <p class="video-duration">00:00</p>
                    </div>
                </li>
                <li class="options center">
                    <button class="play-pause"><i class="fas fa-play"></i></button>
                </li>
                <li class="options right">
                    <div class="playback-content">
                        <button class="playback-speed"><span class="material-symbols-rounded">slow_motion_video</span></button>
                        <ul class="speed-options">
                            <li data-speed="2">2x</li>
                            <li data-speed="1.5">1.5x</li>
                            <li data-speed="1" class="active">Normal</li>
                            <li data-speed="0.75">0.75x</li>
                            <li data-speed="0.5">0.5x</li>
                        </ul>
                    </div>
                    <button class="pic-in-pic"><span class="material-icons">picture_in_picture_alt</span></button>
                    <button class="fullscreen"><i class="fa-solid fa-expand"></i></button>
                </li>
            </ul>
        </div>
        <video src="https://www.youtube.com/embed/3sDfsZboq3Y" oncontextmenu="return false;"></video>
    </div>

<script>
const container = document.querySelector(".container"),
mainVideo = container.querySelector("video"),
videoTimeline = container.querySelector(".video-timeline"),
progressBar = container.querySelector(".progress-bar"),
volumeBtn = container.querySelector(".volume i"),
volumeSlider = container.querySelector(".left input");
currentVidTime = container.querySelector(".current-time"),
videoDuration = container.querySelector(".video-duration"),
playPauseBtn = container.querySelector(".play-pause i"),
speedBtn = container.querySelector(".playback-speed span"),
speedOptions = container.querySelector(".speed-options"),
pipBtn = container.querySelector(".pic-in-pic span"),
fullScreenBtn = container.querySelector(".fullscreen i");
let timer;

const hideControls = () => {
    if(mainVideo.paused) return;
    timer = setTimeout(() => {
        container.classList.remove("show-controls");
    }, 2000);
}
hideControls();

container.addEventListener("mousemove", () => {
    container.classList.add("show-controls");
    clearTimeout(timer);
    hideControls();   
});

const formatTime = time => {
    let seconds = Math.floor(time % 60),
    minutes = Math.floor(time / 60) % 60,
    hours = Math.floor(time / 3600);

    seconds = seconds < 10 ? `0${seconds}` : seconds;
    minutes = minutes < 10 ? `0${minutes}` : minutes;
    hours = hours < 10 ? `0${hours}` : hours;

    if(hours == 0) {
        return `${minutes}:${seconds}`
    }
    return `${hours}:${minutes}:${seconds}`;
}

videoTimeline.addEventListener("mousemove", e => {
    let timelineWidth = videoTimeline.clientWidth;
    let offsetX = e.offsetX;
    let percent = Math.floor((offsetX / timelineWidth) * mainVideo.duration);
    const progressTime = videoTimeline.querySelector("span");
    offsetX = offsetX < 20 ? 20 : (offsetX > timelineWidth - 20) ? timelineWidth - 20 : offsetX;
    progressTime.style.left = `${offsetX}px`;
    progressTime.innerText = formatTime(percent);
});

videoTimeline.addEventListener("click", e => {
    let timelineWidth = videoTimeline.clientWidth;
    mainVideo.currentTime = (e.offsetX / timelineWidth) * mainVideo.duration;
});

mainVideo.addEventListener("timeupdate", e => {
    let {currentTime, duration} = e.target;
    let percent = (currentTime / duration) * 100;
    progressBar.style.width = `${percent}%`;
    currentVidTime.innerText = formatTime(currentTime);
});

mainVideo.addEventListener("loadeddata", () => {
    videoDuration.innerText = formatTime(mainVideo.duration);
});

const draggableProgressBar = e => {
    let timelineWidth = videoTimeline.clientWidth;
    progressBar.style.width = `${e.offsetX}px`;
    mainVideo.currentTime = (e.offsetX / timelineWidth) * mainVideo.duration;
    currentVidTime.innerText = formatTime(mainVideo.currentTime);
}

volumeBtn.addEventListener("click", () => {
    if(!volumeBtn.classList.contains("fa-volume-high")) {
        mainVideo.volume = 0.5;
        volumeBtn.classList.replace("fa-volume-xmark", "fa-volume-high");
    } else {
        mainVideo.volume = 0.0;
        volumeBtn.classList.replace("fa-volume-high", "fa-volume-xmark");
    }
    volumeSlider.value = mainVideo.volume;
});

volumeSlider.addEventListener("input", e => {
    mainVideo.volume = e.target.value;
    if(e.target.value == 0) {
        return volumeBtn.classList.replace("fa-volume-high", "fa-volume-xmark");
    }
    volumeBtn.classList.replace("fa-volume-xmark", "fa-volume-high");
});

speedOptions.querySelectorAll("li").forEach(option => {
    option.addEventListener("click", () => {
        mainVideo.playbackRate = option.dataset.speed;
        speedOptions.querySelector(".active").classList.remove("active");
        option.classList.add("active");
    });
});

document.addEventListener("click", e => {
    if(e.target.tagName !== "SPAN" || e.target.className !== "material-symbols-rounded") {
        speedOptions.classList.remove("show");
    }
});

fullScreenBtn.addEventListener("click", () => {
    container.classList.toggle("fullscreen");
    if(document.fullscreenElement) {
        fullScreenBtn.classList.replace("fa-compress", "fa-expand");
        return document.exitFullscreen();
    }
    fullScreenBtn.classList.replace("fa-expand", "fa-compress");
    container.requestFullscreen();
});

speedBtn.addEventListener("click", () => speedOptions.classList.toggle("show"));
pipBtn.addEventListener("click", () => mainVideo.requestPictureInPicture());
mainVideo.addEventListener("play", () => playPauseBtn.classList.replace("fa-play", "fa-pause"));
mainVideo.addEventListener("pause", () => playPauseBtn.classList.replace("fa-pause", "fa-play"));
playPauseBtn.addEventListener("click", () => mainVideo.paused ? mainVideo.play() : mainVideo.pause());
videoTimeline.addEventListener("mousedown", () => videoTimeline.addEventListener("mousemove", draggableProgressBar));
document.addEventListener("mouseup", () => videoTimeline.removeEventListener("mousemove", draggableProgressBar));
</script>

  </body>
</html>

Getting “npm ERR! code ENOENT” while running npx

I an currently learning React with Javascript. I was able to install node.js without any errors. But when i try to create react project, its throws an error like this:

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:Program FilesGitusrlocal
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:Program FilesGitusrlocal'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

and this the error log

0 verbose cli C:Program Filesnodejsnode.exe C:Program Filesnodejsnode_modulesnpmbinnpm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 6ms
4 timing config:load:defaults Completed in 4ms
5 timing config:load:file:C:Program Filesnodejsnode_modulesnpmnpmrc Completed in 4ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 4ms
8 timing config:load:env Completed in 2ms
9 timing config:load:project Completed in 2ms
10 timing config:load:file:C:UsersTHAIPAK KEL.npmrc Completed in 1ms
11 timing config:load:user Completed in 2ms
12 timing config:load:file:C:Program FilesGitusrlocaletcnpmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:setEnvs Completed in 3ms
15 timing config:load Completed in 23ms
16 timing npm:load:configload Completed in 23ms
17 timing npm:load:mkdirpcache Completed in 1ms
18 timing npm:load:mkdirplogs Completed in 1ms
19 verbose title npm exec create-react-app nyube
20 verbose argv "exec" "--" "create-react-app" "nyube"
21 timing npm:load:setTitle Completed in 3ms
22 timing config:load:flatten Completed in 9ms
23 timing npm:load:display Completed in 10ms
24 verbose logfile logs-max:10 dir:C:UsersTHAIPAK KELAppDataLocalnpm-cache_logs2023-05-26T03_41_02_876Z-
25 verbose logfile C:UsersTHAIPAK KELAppDataLocalnpm-cache_logs2023-05-26T03_41_02_876Z-debug-0.log
26 timing npm:load:logFile Completed in 19ms
27 timing npm:load:timers Completed in 0ms
28 timing npm:load:configScope Completed in 1ms
29 timing npm:load Completed in 65ms
30 silly logfile start cleaning logs, removing 2 files
31 timing arborist:ctor Completed in 2ms
32 silly logfile done cleaning log files
33 timing arborist:ctor Completed in 0ms
34 http fetch GET 200 https://registry.npmjs.org/create-react-app 2163ms (cache revalidated)
35 timing arborist:ctor Completed in 1ms
36 timing command:exec Completed in 2817ms
37 verbose stack Error: ENOENT: no such file or directory, lstat 'C:Program FilesGitusrlocal'
38 verbose cwd C:UsersTHAIPAK KELDesktop
39 verbose Windows_NT 10.0.17763
40 verbose node v18.16.0
41 verbose npm  v9.5.1
42 error code ENOENT
43 error syscall lstat
44 error path C:Program FilesGitusrlocal
45 error errno -4058
46 error enoent ENOENT: no such file or directory, lstat 'C:Program FilesGitusrlocal'
47 error enoent This is related to npm not being able to find a file.
47 error enoent
48 verbose exit -4058
49 timing npm Completed in 3135ms
50 verbose code -4058
51 error A complete log of this run can be found in:
51 error     C:UsersTHAIPAK KELAppDataLocalnpm-cache_logs2023-05-26T03_41_02_876Z-debug-0.log

your input will be appreciated.

I also tried to delete npm cache and it also didn’t work.

Getting “npm ERR! code ENOENT” when running npx

I Have to learning react for javascript, when i try to installed a node.js, its running okay. But when i went to try create react project, its have error like this:

npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:Program FilesGitusrlocal
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:Program FilesGitusrlocal'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

and this the error log

0 verbose cli C:Program Filesnodejsnode.exe C:Program Filesnodejsnode_modulesnpmbinnpm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 6ms
4 timing config:load:defaults Completed in 4ms
5 timing config:load:file:C:Program Filesnodejsnode_modulesnpmnpmrc Completed in 4ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 4ms
8 timing config:load:env Completed in 2ms
9 timing config:load:project Completed in 2ms
10 timing config:load:file:C:UsersTHAIPAK KEL.npmrc Completed in 1ms
11 timing config:load:user Completed in 2ms
12 timing config:load:file:C:Program FilesGitusrlocaletcnpmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:setEnvs Completed in 3ms
15 timing config:load Completed in 23ms
16 timing npm:load:configload Completed in 23ms
17 timing npm:load:mkdirpcache Completed in 1ms
18 timing npm:load:mkdirplogs Completed in 1ms
19 verbose title npm exec create-react-app nyube
20 verbose argv "exec" "--" "create-react-app" "nyube"
21 timing npm:load:setTitle Completed in 3ms
22 timing config:load:flatten Completed in 9ms
23 timing npm:load:display Completed in 10ms
24 verbose logfile logs-max:10 dir:C:UsersTHAIPAK KELAppDataLocalnpm-cache_logs2023-05-26T03_41_02_876Z-
25 verbose logfile C:UsersTHAIPAK KELAppDataLocalnpm-cache_logs2023-05-26T03_41_02_876Z-debug-0.log
26 timing npm:load:logFile Completed in 19ms
27 timing npm:load:timers Completed in 0ms
28 timing npm:load:configScope Completed in 1ms
29 timing npm:load Completed in 65ms
30 silly logfile start cleaning logs, removing 2 files
31 timing arborist:ctor Completed in 2ms
32 silly logfile done cleaning log files
33 timing arborist:ctor Completed in 0ms
34 http fetch GET 200 https://registry.npmjs.org/create-react-app 2163ms (cache revalidated)
35 timing arborist:ctor Completed in 1ms
36 timing command:exec Completed in 2817ms
37 verbose stack Error: ENOENT: no such file or directory, lstat 'C:Program FilesGitusrlocal'
38 verbose cwd C:UsersTHAIPAK KELDesktop
39 verbose Windows_NT 10.0.17763
40 verbose node v18.16.0
41 verbose npm  v9.5.1
42 error code ENOENT
43 error syscall lstat
44 error path C:Program FilesGitusrlocal
45 error errno -4058
46 error enoent ENOENT: no such file or directory, lstat 'C:Program FilesGitusrlocal'
47 error enoent This is related to npm not being able to find a file.
47 error enoent
48 verbose exit -4058
49 timing npm Completed in 3135ms
50 verbose code -4058
51 error A complete log of this run can be found in:
51 error     C:UsersTHAIPAK KELAppDataLocalnpm-cache_logs2023-05-26T03_41_02_876Z-debug-0.log

please help me, thank you

i try to delete a npm cache, and its not working

Add event listener to ref from React context

The React context provider sets a ref that is used by another component to set a blur event listener. The problem is that a blur event does not trigger the listener.

Code extract for the context provider.

...
export function useEditorContext(): EditorContextProps {
    return useContext(EditorContext) as EditorContextProps;
}

export default function EditorProvider({ children }: { children: React.ReactNode }) {
    const ref = useRef<HTMLDivElement>(null);
    const historyState = useMemo(createEmptyHistoryState, []);
    const context = { historyState, ref };
    return (
        <EditorContext.Provider value={context}>
            <div ref={ref}>
                {children}
            </div>
        </EditorContext.Provider>
    );
}

The goal is to attach the listener in a Lexical plugin.

const { historyState, ref } = useEditorContext();

const blurHandler = (event: FocusEvent) => {
    console.log('Blurred');
};

useEffect(() => {
    const element = ref.current;
    if (element) {
        element.addEventListener('blur', blurHandler, false);
    } else return;

    return () => {
        element.removeEventListener('blur', blurHandler);
    };
}, [ref.current]); // eslint-disable-line

I have run the code with logging and tried several solutions/answers for useRef and addEventListener but none worked in the above scenario. Any suggestions are welcome!

How to save uint8array media files on nodejs server received from frontend web streams?

I have used the web streams on the frontend side to send big files into multiple chunks , but when it comes to the backend nodejs side i am not able to consume the received unit8array properly . all i got is unsupported file format while saving it to disk.

Here is my code :

import { Writable, Readable } from "stream";
import { writeFileSync } from "fs";
import { createServer } from "http";
import { pipeline } from "stream/promises";

const headers = {
  "Access-Control-Allow-Origin": "*",
  "Access-Control-Allow-Method": "*",
  "Access-Control-Allow-Headers": "*",
};

createServer(async (request, response) => {

  if (request.method === "OPTIONS") {
    response.writeHead(204, headers);
    response.end();
    return;
  }

  response.writeHead(200, headers);

  async function* consumeStream() {
    let body = Readable.toWeb(request).getReader();
    let read = (await body.read()).value;
    // received read as an uint8array
    yield Buffer.from(read, "base64");
  }

  await pipeline(
    consumeStream,
    new Writable({
      write(chunk, enc, cb) {
        writeFileSync("./output.jpg", chunk);
        cb();
      },
    })
  );

}).listen(3000, () => {
  console.log("Server started");
});

How to apply to blogger [closed]

Sorry anyone can help, I want to try to make a repository on Github but I want to apply it to blogger (blogspot), there is some js and css code that I can’t convert so it can be applied on Blogspot. github repository: GITHUB

Thank You.

Can applied on Blogger

Play music button on global components work for child components

i want to know something.

I have a global component, it’s a music-player.vue, here is the code:

    <button class="btn bg-[#a47551] hover:text-gray-50 p-3 shadow-xl"  @click="togglePlayback">
       <span class="material-symbols-outlined">
          {{ isPlaying ? "pause" : "play_arrow" }}
        </span>
    </button>

<script>
import { onMounted, ref } from "vue";

export default {
    setup() {
        const audio = new Audio();
        const isPlaying = ref(false);
        
        function togglePlayback() {
            if (isPlaying.value) {
                pausePlayback();
            } else {
                playPlayback();
            }
        }

        function playPlayback() {
            if (!isPlaying.value) {
                audio.play();
                isPlaying.value = true;
            }
        }

        function pausePlayback() {
            if (isPlaying.value) {
                audio.pause();
                isPlaying.value = false;
            }
        }

        function handlePlaybackStart() {
            isPlaying.value = true;
        }

        function handlePlaybackPause() {
            isPlaying.value = false;
        }

        onMounted(() => {
            audio.src = "./../../../assets/song/1.mp3";
            audio.loop = true;
            audio.addEventListener("play", handlePlaybackStart);
            audio.addEventListener("pause", handlePlaybackPause);
        });

        return {
            togglePlayback,
            isPlaying,
        };
    },
};
</script>

My question is: I also want to trigger that togglePlayback() button, when i am clicking lihatUndangan button on my Home.vue. Here is my code:

<button class="btn bg-[#a47551] text-gray-50" @click="lihatUndangan">Lihat undangan</button>

<script>
import { ref } from 'vue';
import { useRouter } from "vue-router";

export default {
  data() {
    return {
      namaTamu: '',
    };
  },
  mounted() {
    const isPlaying = ref(false);
    const audio = new Audio();
    const namaTamu = localStorage.getItem('namaTamu');

    if (!namaTamu) {
      const namaInput = window.prompt('Masukkan nama:');
      
      if (namaInput && namaInput.trim() !== '') {
        localStorage.setItem('namaTamu', namaInput);
        this.namaTamu = namaInput;
      } else {
        this.namaTamu = 'Tamu Undangan';
      }
    } else {
      this.namaTamu = namaTamu;
    }

    setTimeout(() => {
      this.isLoading = false;
    }, 500);
  },
  setup() {
    const router = useRouter();

    function lihatUndangan() {
      router.push('/welcome');
    }

    return {
      lihatUndangan
    };
  }
};
</script>

Can anyone give me a solution or advice? i am new to Vue, thank you 🙂

correct socket.io implementation

I’m trying out socket io for my project to show online friends, and I was wondering (actually, it looks kinda strange to me) that whenever I try to rerender the page (it doesn’t matter if a user changes his profile info or send a friend req) the useEffect which is in charge of initializing the socket will disconnect and reconnect. Well… I agree that if the page is being refreshed or closed, the socket should be closed, but not whenever a user sends a friend request or changes his profile info… I just started to include the socket and the functionality is not full but so far at the beginning, having these various reconnections and creation of Sockets is strange. plusssss, my main concern shows itself on rerender; the socket will be disconnected (which is normal) and won’t connect back (which is abnormal), but i only want this behavior on actual refreshes or logouts 🙁 again, I will try to be as clear as possible, I have my case open on my screen for further explanation on your questions asap 🙂

File (Client): socket.js:

import { io } from 'socket.io-client';

export const initializeSocket = (token, userInfoQuery, setOnlineFriends, setSocket) => {
  if (token && userInfoQuery) {
    const socket = io(process.env.REACT_APP_API_URL, { auth: { token } });

    const friendIds = userInfoQuery.friends
    socket.emit("userFriends", friendIds);

    socket.on("onlineUsers", (users) => {
      setOnlineFriends(users);
    });

    socket.on("addFriend", (friend) => {
      console.log("Received friend request:", friend);
    });

    socket.on("removeFriend", (friend) => {
      console.log("Received friend request:", friend);
    });

    setSocket(socket);
    return socket;
  }
  return null;
};

File (Client): App.js:

export default function App() {
  const { token, logout, login } = useContext(AuthContext);
  const [onlineFriends, setOnlineFriends] = useState([]);
  const [socket, setSocket] = useState(null);

  const userInfoQuery = useQuery("userInfo", async () => {
    const response = await axios.get(
      `${process.env.REACT_APP_API_URL}/api/user`,
      {
        headers: {
          Authorization: "Bearer " + token,
        },
      }
    );
    return response.data;
  });
  const userBooksQuery = useQuery("userBooks", async () => {
    const response = await axios.get(
      `${process.env.REACT_APP_API_URL}/api/user/books`,
      {
        headers: {
          Authorization: "Bearer " + token,
        },
      }
    );
    return response.data;
  });

  useEffect(() => {
    if (socket) {
      socket.connect();
    }
    if (token && userInfoQuery.data && !socket) {
      initializeSocket(token, userInfoQuery.data, setOnlineFriends, setSocket);
    }

    return () => {
      if (socket) {
        socket.disconnect();
      }
    };
  }, [token, userInfoQuery.data, socket]);

return ( ...
)

as you can see, I initaiated the socket and all its functionality on one useEffect and those dep array. not having the userInfoQuery as dep would not rerender the page since online friends are coming from the socket.

File (Server): socketController.js:

const knexConfig = require("../knexfile");
const { knex } = require("knex");
const db = knex(knexConfig);
const io = require("socket.io");
const jwt = require("jsonwebtoken");
require("dotenv").config();

module.exports.socketController = (io) => {
  const onlineFriends = new Map();

  io.on("connection", async (socket) => {
    console.log(`A user connected ${socket.id}`);
    try {
      const token = socket.handshake.auth.token;
      const decoded = jwt.verify(token, process.env.JWT_SIGN_KEY);
      const userId = decoded.user_id;

      await db("user").where("user_id", userId).update({ is_online: 1 });
      const user = await db("user").where("user_id", userId).first();

      onlineFriends.set(userId, user);

      socket.join(userId);

      const onlineFriendList = Array.from(onlineFriends.values());
      socket.emit("onlineUsers", onlineFriendList);

      socket.on("userFriends", async (friendsList) => {
        friendsList.forEach((friend) => {
          socket.join(friend.friend);
        });

        const onlineUsers = await db("user")
          .whereIn(
            "user_id",
            friendsList.map((friend) => friend.friend)
          )
          .andWhere("is_online", 1);

        onlineUsers.forEach((user) => onlineFriends.set(user.user_id, user));
        const updatedOnlineFriendList = Array.from(onlineFriends.values());

        socket.broadcast.emit("onlineUsers", updatedOnlineFriendList);
      });
      socket.on("addFriend", async (friendId) => {
        const recipientUser = onlineFriends.get(friendId); 
        if (recipientUser) {
          const recipientSocket = io.sockets.sockets.get(recipientUser.socket_id); 
          if (recipientSocket) {
            recipientSocket.emit("addFriend", userId);
          }
        }
      });
      socket.on("removeFriend", async (friendId) => {
        const recipientUser = onlineFriends.get(friendId);
        if (recipientUser) {
          const recipientSocket = io.sockets.sockets.get(recipientUser.socket_id); 
          if (recipientSocket) {
            recipientSocket.emit("removeFriend", userId);
          }
        }
      });
      socket.on("disconnect", async () => {
        await db("user").where("user_id", userId).update({ is_online: 0 });

        onlineFriends.delete(userId);
        const updatedOnlineFriendList = Array.from(onlineFriends.values());

        socket.broadcast.emit("onlineUsers", updatedOnlineFriendList);

        console.log(`${socket.id} disconnected`);
      });

    } catch (error) {
      console.error("Authentication error:", error.message);
      socket.disconnect();
    }
  });
};

I feel the server-side is pretty much fine in terms of sending back the online friend users. again if the server-side had some problem or you had suggestions on it, feel free to let me know…

each user object if like this :

{
    avatar_image: "https://i.pravatar.cc/150?img=13"
    ​​email: "[email protected]"
    ​​favorite_genre: "comedy"
    ​​first_name: "ross"
    ​​friends: Array [ {…} ]
    ​goal_set: 9
    last_name: "test"​​
    username: "rosss001"
}

thanks for coming this far… this problem stoped me to move on my project for days, would appreciate if you could help me out here 🙂

should you have any suggestion, let me know

again, I have my case open for answering questions

Although not being efficient in useEffect, I tried to do socket.connect() to attempt to reconnect to the socket, but it seems not to work. Also, when a user changes his profile info, I tried to in my component refetch the data to trigger the useEffect by : queryClient.refetchQueries("userInfo"); . again it seems it rerenders and disconnects the whole socket and causes the problem altogether. on the other hand, I need to rerender the page to inform the user and the changes made to his account! the socket.connect() at the beginning of useEffect was my ultimate try…