Looking for a Free Text Editor with Advanced Features (FREE)

I’m on the hunt for a free text editor that goes beyond the basics! I’m looking for something that offers features like:

  • Font customization (size, type)

  • Bold, italics, underline, and strikethrough options

  • Bullet points and numbered lists

  • Alignment options (left, centre, right, justify)

  • Highlighting text with custom colors

  • Easy copy-paste functionality with formatting preserved

  • User-friendly interface (bonus if it’s lightweight and fast!)

Which I use in the react code for the mail System.

I Have try many editor like qull , ngx and ck but not give Font customization (type) feature.

Can’t understand why my useState variable is not showing the initial value nor the updated value

I’m trying to remove the deleted element from the UI without having to refresh. The element does get successfully deleted from the database, but I have to refresh the page to see the removal. Even after passing updatedData to setData, data will not update. Sessions is an array full of elements, so the data initial value should not be an empty array, yet that is what is logged every time I try to render data. Can anyone help me understand why? Do I need to implement a useEffect? I’ve tried to but it hasn’t made a difference.

import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/router';

const ViewSessions = ({ sessions }) => {
    const [data, setData] = useState(sessions);
    const router = useRouter();

    const handleDeleteClick = async (session) => {
        try {
            await deleteDoc(doc(db, "sessions", session.id));
            console.log("Document successfully deleted!");

            // Update the local state to remove the deleted session
            const updatedData = data.filter((s) => s.id !== session.id);
            setData(updatedData);
        } catch (error) {
            console.error("Error deleting document:", error);
        }
    };

    console.log("sessionsData updated:", data);
    console.log("sessions", sessions)

    return (
        <div>
            <h1>Sessions</h1>
            <ul>
                {data.map((session) => {
                    return (
                    <li key={data.id}>
                        <button onClick={() => handleDeleteClick(session)}>Delete</button>
                    </li>
                    );
                })}
            </ul>
        </div>
    );
};

How to make other components inaccessible when React Material UI Backdrop is opened?

When the Material UI Backdrop component is in use, the elements in the website are still visible and accessible, which can be fairly easy to see in the official demo, or by using this CodeSandbox:

Edit eager-ully-vcfgxq

I went through certain questions in plain JS, such as tabindex -1 not working for child elements, and many suggested using visibility: hidden. However, I would like to know if there are ways to prevent other components from accessing, but still being visible.

In Ajax call Data Passing Limit

I am working with bank entity which have branches , In ajax call I am passing bank object instead of FormData , This Banks have Branches and they have photo property , when I am Trying to pass more than 154 branches then it gives below exception

fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.IO.InvalidDataException: Form value count limit 1024 exceeded.

Here is my branch that that I am trying to post with bank by ajax call :

$("#branchTable tbody tr").each(function (index, row) {
    const branch = {
        Name: $(row).find(".branch-name").val(),
        Email: $(row).find(".branch-email").val(),
        Status: $(row).find(".branch-status").is(":checked"),
        Photo: null 
    };

    const branchPhotoFile = $(row).find(".branch-photo")[0].files[0];
    if (branchPhotoFile) {
        const reader = new FileReader();
        reader.onload = function (e) {
            branch.Photo = e.target.result.split(",")[1];

            Bank.Branches.push(branch);
        };
        reader.readAsDataURL(branchPhotoFile);


        for(var i =0 ; i<253 ; i++){
            Bank.Branches.push(branch);
        }


    } else {
        Bank.Branches.push(branch);
    }
});

and This is my ajax call :

$.ajax({
    type: "POST",
    url: "@Url.Action("Create", "BanksV6")",
    data: Bank, 
    contentType: "application/x-www-form-urlencoded", 
    success: function (response) {
        if (response.success) {
            window.location.href = "@Url.Action("Index", "BanksV6")";
        } else {
            alert("Error occurred.");
        }
    },
    error: function (response) {
        alert("Request failed.");
    }
});

Here my question is if I use FormData then how many branches can i add to the bank?

Question about Node js infinite recursion and async/await behavior

I’ve been trying to make an infinite loop in Node js, and came across this problem. I experimented a bit and came up with these three functions.

async function rc1(){
    rc1();
}
//-> stack overflow error
async function rc2(){
    await rc2();
}
//-> stack overflow error
asyn function a(){}
async function rc3(){
    await a();
    rc3();
}
//-> no stack overflow error

Why does this happen?

I’ve been reading up on the async/await tutorials, but most just post code. There are great visualizers but they don’t show any examples of the await code. If there are any resources that would be great.

Fastify Passport LocalStrategy: Error ‘Expected a string or Buffer’ when accessing protected route

I’m implementing a Fastify authentication system using @fastify/passport with a LocalStrategy. Below is the auth plugin that handles user serialization, deserialization, and the local strategy configuration.

import fp from "fastify-plugin";
import fastifyPassport from "@fastify/passport";
import LocalStrategy from "passport-local";
import { FastifyInstance, FastifyReply, FastifyRequest } from "fastify";
import { User } from "./types";
export default fp(async function auth(fastify: FastifyInstance) {
  const { store, httpErrors } = fastify;
  fastifyPassport.registerUserSerializer(async (user: { id: number }, request) => {
    if (!user?.id) return httpErrors.notFound("User ID is missing");
    return user.id;
  });
  fastifyPassport.registerUserDeserializer(async (id: number, request) => {
    try {
      const user: User[] = await store("users").where({ id }).limit(1);
      if (!user || user?.length < 1) return null;
      ....
      return sessionUser
    } catch (error) {
      console.error("Deserialization error", error);
      return null;
    }
  });

  async function handleUserRecovery(req: FastifyRequest, email: string, password: string) {
    try {
      const user: User[] = await store("users").where({ email }).limit(1);
      if (!user || user?.length < 1) return false;
      ...
      return sessionUser;
    } catch (err) {
      console.error("Error fetching user:", err);
      return false;
    }
  }
  fastifyPassport.use(
    "local",
    new LocalStrategy(
      {
        passReqToCallback: true,
        usernameField: "email",
      },
      handleUserRecovery
    )
  );

  await fastify.register(fastifyPassport.initialize());
  await fastify.register(fastifyPassport.secureSession());
}, {
  dependencies: ["fastify-env", "fastify-session", "fastify-store", "fastify-sensible"],
});

The issue arises when I try to access a protected route like the following:

fastify.route({
  method: "GET",
  url: "/protected",
  preValidation: fastifyPassport.authenticate("local", { authInfo: false }),
  handler: async (req: FastifyRequest<{ Body: { email: string; password: string } }>, res: FastifyReply) => {
    return res.send({ msg: "ok" });
  },
});

When calling this route, I always receive the following error:

Attempted to send payload of invalid type 'object'. Expected a string or Buffer.

Moreover, in the server logs, I notice two incoming requests being logged, as if the request is being processed twice.
Here is the detailed log output:

responseTime: 73.25737500190735
[01:00:23.679] ERROR (33597): server closing with error
err: {
  "type": "FastifyError",
  "message": "Attempted to send payload of invalid type 'object'. Expected a string or Buffer.",
  "stack": FastifyError: Attempted to send payload of invalid type 'object'. Expected a string or Buffer.
}

I expected the route to authenticate users based on email and password, and return a response like { msg: "ok" }. Instead, I get an error saying:

Attempted to send payload of invalid type ‘object’. Expected a string or Buffer.

In the logs. I also noticed that the request seems to be processed twice, which is unexpected.

Why CSS and Javascript did not respond together when I put their links together to HTML?

I tried to put link together in html. I want the browser still there (sticky) while scrolling down. Example this is how I put link below:

I put this link before body <link rel= "stylesheet" href="TaveCSS.css"> (<——-CSS link)

I put this link inside body <script src="javascript.js"></script> (<——-java script link)

But the CSS didn’t respond my JavaScript link, so I doubt I did something wrong in JavaScript. I tried research, spell check and fix the code, but it didn’t work. How do I fix the JavaScript? Sorry I’m still learning JavaScript.

Please check my HTML, CSS and JavaScript Codes

document.addEventListener('DOMContentLoaded', function() {
    const nav = document.querySelector('.navi');

window.addEventListener('scroll', () => {
    if (window.scrollY > 100) nav.style.background = 'white';
    else nav.style.background = 'white';
});
});
body {
    margin: 0;
    font-family: Ariel;
  }

  *{
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  #logo { 
    float:left;
    display: inline-block;
    width: 3.5%;

}

#nav{
    padding-left: 500px;
    position: sticky;
}
 

.navi {
    list-style-type: none;
    margin:0;
    padding:0;
    overflow: hidden;
    background-color: #ffffff;
    font-size: 1.7vw;
    position: sticky;
    }

.list1 {
    float: left;
    text-align: center;
    }

.list1 a {
    display: block;
    color: rgb(0, 0, 0);
    text-align: center;
    padding: 14px 20px;
    text-decoration: none;
    }

.list1 a:hover {
    background-color: #000000;
    color:#ffffff
    }

body, html {
    height: 100%;
    }


@media screen and (max-width: 850px) {
  .box {
    grid-template-columns: 1fr;
  }

}

footer{
    position:absolute;
    bottom: auto;
    left: 0;
    right: 0;
    background:black;
    height: auto;
    width: 100vw;
    padding-top: 20px;
    color: #fff;
    
}
   .footer .box{
    width:auto;
    display:flex;
    flex-direction: column;
    padding-left: 2%; 
    padding-bottom: auto;
}

.box-row{
    display:table-row; 


}
.box-cell{
    display:table-cell;
    padding-left: 9.5em ;
    
    
    
}
.box-cell li{
    cursor:pointer;
}

.box-cell ul li a{
    color:white;
}
    
.footer-title{
    font-size:1.5vw;
    padding-bottom:0.5em;  
}

.list2{
    font-size:1vw;
    font-weight: 10;
    padding-bottom:0.6em;  
}



    .fa {
    padding: 5px;
    font-size: 30px;
    width: 50px;
    text-align: center;
    text-decoration: none;
    margin: 3px 1px;
    }

    .fa:hover {
        opacity: 0.7;
    }

    .fa-facebook {
        background:rgb(0, 0, 0);
    
    }


    .fa-youtube {
     background:rgb(0, 0, 0);
    color: white;
    }

    .fa-instagram {
        background:rgb(0, 0, 0);
    color: white;
    }

    #subbutton:hover{
    background-color:coral;
    font-weight: 600;   
}

   .payment fa{
    display: flex;
    position: absolute;
   }
    
    .payment-container{
      font-size:0.9em; 
      color:white;
      text-align: center;
      position: absolute;
      display: flex;
      right: 43%;
      bottom:12%;
    }

.footer-2{
 width: 100%;
 height:auto;
 position:relative;
 text-align: center;
 padding-top:20px;
 padding-bottom:10px;
 font-size:1vw;
 color:white;
 font-weight: 400;
}

.footer-2 a{
    text-decoration: none;
    color:white;
    cursor: pointer;
}
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel= "stylesheet" href="TaveCSS.css">
        <title>
            Trave nz home
        </title>
   
    <style>


    .skytower1{
        background-image: url(photo/tower.jpg);

        height: 100%;

        background-attachment: fixed;
        background-position: center;
        background-repeat: no-repeat;
        background-size: 100% auto;
    }
    @media screen and (max-width: 768px) {
        .skytower1 {
            background-attachment: inherit;
        }
    }
    

    .alphine{
        width: 80%;
    }

    .insidealph{
        padding-left: 20%;

    }
    .note{ 
        padding:2% 2% 0 2%;
        
    }

    .note2{
         padding:2% 2% 0 2%
    }

    #map {
        width: 20%;
    }

    .mapcontainer{
        padding-left: 45%;  
    }
    
   
  
    </style>
     </head>
        <body>
            <img src="photo/travelogo (1).png" id="logo" />
            <div id="nav">
            <ul class="navi">
                <li class="list1"><a href="Home_trave.html">Home</a></li>
                <li class="list1" ><a href="Tour_trave.html">Tour </a></li>
                <li class="list1"><a href="contact_trave.html"> Contact</a></li>
            </ul>

             </div>
        <div class="skytower1"></div>
        <br>
        <br>
        <br>
        <br>
        <br>
            <center><h1>About New Zealand (Aotearoa)</h1></center>
            <div class="insidealph"><img src="photo/alphine.jpg" class="alphine"></div>

        <div>
            

            <p class=" note">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
                Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar 
                ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. 
                Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. 
                Pellentesque habitant morbi tristique senectus et netus et malesuada 
                fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. 
                Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui 
                purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque 
                at sem venenatis eleifend. Ut nonummy.
                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
                Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar 
                ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. 
                Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. 
                Pellentesque habitant morbi tristique senectus et netus et malesuada 
                fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. 
                Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui 
                purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque 
                at sem venenatis eleifend. Ut nonummy.
                Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
                Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar 
                ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. 
                Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. 
                Pellentesque habitant morbi tristique senectus et netus et malesuada 
                fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. 
                Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui 
                purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque 
                at sem venenatis eleifend. Ut nonummy.
            </p>
        </div>

        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>
        <br>

    <div class="mapcontainer">
        <img src="photo/map.jpg" id="map"/>
    </div>

    <div>
        <center><h2>About Us</h2></center>
    </div>
    <br>
    <div>

        <p class = "note2">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
            Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar 
            ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. 
            Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. 
            Pellentesque habitant morbi tristique senectus et netus et malesuada 
            fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. 
            Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui 
            purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque 
            at sem venenatis eleifend. Ut nonummy.
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
            Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar 
            ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. 
            Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. 
            Pellentesque habitant morbi tristique senectus et netus et malesuada 
            fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. 
            Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui 
            purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque 
            at sem venenatis eleifend. Ut nonummy.
            Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
            Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar 
            ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. 
            Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. 
            Pellentesque habitant morbi tristique senectus et netus et malesuada 
            fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci. 
            Aenean nec lorem. In porttitor. Donec laoreet nonummy augue. Suspendisse dui 
            purus, scelerisque at, vulputate vitae, pretium mattis, nunc. Mauris eget neque 
            at sem venenatis eleifend. Ut nonummy.
        </p>
        <br>
        <br>
    </div>
    <br>
    <br>

    <footer>
        <div class="box">
            <div class ="box-row">
                <div class="box-cell">
                    <ul class = "ullist" style = "list-style-type:none;"><p class = "footer-title">Follow Us On</p>
                        <li class = "list2"><a href="#" class="fa fa-instagram"></a>Instagram</li>
                        <li class = "list2"><a href="#" class="fa fa-facebook"></a>Facebook</li>
                        <li class = "list2"> <a href="#" class="fa fa-youtube"></a></a>Youtube</li>
                        </ul>
                </div>
                    <div class = "box-cell">
                        <ul class = "ullist" style = "list-style-type:none;"><p class = "footer-title">Contact Us</p>
                        <li class = "list2">Feedback</li>
                        <li class = "list2">Location</li>
                    </div>
                    <div class = "box-cell">
                        <ul class = "ullist" style = "list-style-type:none;"><p class = "footer-title">Sign Up for News Letters</p>
                        <li class = "list2">Get our latest news!</li>
                        <div class = "input1">
                            <input type = "text" id = "text1" value = "Your Email Address"/>
                            <input type = "button" id = "subbutton" value ="&#9668; Subscribe">
                        </div>
                    </div>



                        
                </div>
                <div class ="payment-container">
                    <div class ="payment">
                        <i class="fa fa-cc-visa"></i>
                        <i class="fa fa-cc-mastercard"></i>
                        <i class="fa fa-cc-paypal"></i>
                 </div>
                    
    
            </div>
            </div>
            <div class="footer-2">
                <p><a href="#">© Since 2023 Trave New Zealand (Aotearoa)</a></p>
              </div>
        </div>


    </footer>
    <script src="javascript.js"></script>
   </body>
</html>

Using module bundlers with Firebase: unexpected token in webpack-cli

I followed this documentation on firebase to use it with webpack: https://firebase.google.com/docs/web/module-bundling. But when I get to the last step and try to run webpack and generate the build folder by calling npm run build I get the following error:

    Documents/NewTracker/node_modules/webpack-cli/node_modules/commander/lib/command.js:396
    enableOrNameAndArgs = enableOrNameAndArgs ?? 'help [command]';
                                               ^

SyntaxError: Unexpected token '?'
    at wrapSafe (internal/modules/cjs/loader.js:1053:16)
    at Module._compile (internal/modules/cjs/loader.js:1101:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Documents/NewTracker/node_modules/webpack-cli/node_modules/commander/index.js:2:21)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `webpack --mode=development`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /.npm/_logs/2025-01-09T01_22_50_310Z-debug.log

Any help would be greatly appreciated

I tried to follow the steps twice and look for answers online but was unable to find any.

Instagram scroll through comments Selenium Python

I came across this situation, I need to scroll through the instagram comments to the end, but only this code works for Selenium:

    driver.execute_script("arguments[0].scrollTop = arguments[0].scrollHeight", window)

But I need to make sure that the comments scroll to the end, and this method scrolls them only at the beginning.
You also need to consider uploading comments.
It is also important to clarify that there is no end element for which the script can be stopped.

Vanilla JS TicTacToe Win Logic

I’ve been messing around with some vanilla JS, having gotten too used to frameworks, and was building a simple TicTacToe game, and I am stuck on a certain piece of the win logic and switch players logic. Here is the code (hopefully it’s not too long):

const GameBoard = (() => {
  const board = Array(9).fill("");
  const getBoard = () => board;
  const resetBoard = () => board.fill("");

  const setBoard = (symbol, index) =>
    board.forEach(() => (board[index] === "" ? (board[index] = symbol) : ""));

  const checkForWinner = () => {
    const winningCombinations = [
      [0, 1, 2], // Top row
      [3, 4, 5], // Middle row
      [6, 7, 8], // Bottom row
      [0, 3, 6], // Left column
      [1, 4, 7], // Middle column
      [2, 5, 8], // Right column
      [0, 4, 8], // Diagonal from top-left to bottom-right
      [2, 4, 6], // Diagonal from top-right to bottom-left
    ];

    for (const combo of winningCombinations) {
      const [a, b, c] = combo;

      if (
        getBoard()[a] &&
        getBoard()[a] === getBoard()[b] &&
        getBoard()[a] === getBoard()[c]
      ) {
        return true;
      }
    }

    return false;
  };

  return { checkForWinner, getBoard, resetBoard, setBoard };
})();

const players = () => {
  const activePlayers = [
    {
      name: "Player 1 (X)",
      symbol: "X",
      active: true,
    },
    {
      name: "Player 2 (O)",
      symbol: "O",
      active: false,
    },
  ];

  const getActivePlayer = () => activePlayers.find((player) => player.active);
  const switchPlayers = () =>
    activePlayers.forEach((player) => (player.active = !player.active));

  return { getActivePlayer, switchPlayers };
};

(() => {
  const gameBoardContainer = document.querySelector("#game-board");
  const { checkForWinner, getBoard, setBoard } = GameBoard;
  const { getActivePlayer, switchPlayers } = players();
  let button;

  for (let i = 0; i < getBoard().length; i++) {
    button = document.createElement("button");
    gameBoardContainer.appendChild(button);
  }

  document.querySelectorAll("button").forEach((button, index) => {
    button.addEventListener("click", () => {
      if (getBoard()[index] === "" && !checkForWinner()) {
        setBoard(getActivePlayer().symbol, index);
        button.textContent = getActivePlayer().symbol;
        switchPlayers();
      }

      if (checkForWinner()) {
        console.log(`${getActivePlayer().name} has won!`);
        return;
      }
    });
  });
})();

My issue is specifically in the addEventListener of the button elements. The logic to check for a winner seems to work, but for some reason, when I am console.logging the active player winner, it actually logs the incorrect user for the win. If I have all X, then it logs that O is the winner, and vice versa. It’s something to do with the switchPlayers functionality I’m assuming, but not sure exactly where it’s failing and why.

Anyone offer any thoughts? Thank you…!

EDIT: And for reference, here is the corresponding 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" href="styles.css" />
    <title>Tic Tac Toe</title>
  </head>
  <body>
    <div id="game-board"></div>
    <script src="script.js"></script>
  </body>
</html>

http.request() returning http response code 408 and no errors

http.request() isn’t working for me. I tried the same code from different computers. It doesn’t give any errors, but gives the http response code 408 (which is timeout). Im so confused about why this is happening as i am doing what the documentation says.

If im doing something wrong, I’d be glad to know what to change as I can’t find any information about this.

note: Servez is running on localhost:8080 so there is a server to connect to

Here is the code:

const http = require('http');

ops = {
    hostname: 'localhost',
    port: '8080',
    path: '/',
    method: 'GET'
}

http.request(ops, res => {
    console.log('code: ' + res.statusCode + 'n');
    dat = '';

    res.on('data', chunk => {
        dat += chunk;
    }) 
    res.on('end', () => {
        console.log(dat);
    })
})

Check if image exists in javascript doesn’t work on first try

I have a JS function that is being used with a regex replace function

this.replacer = function (match, name) {
    let img = new Image();

    img.src = `./img/emoji/${name}.png`;

    if (img.height != 0) {
        return `<img class="emoji" src="./img/emoji/${name}.png" title="${name}" height="20px">`;
    }
    else {
        return match;
    }
};

When trying the function with an image, it doesn’t work the first try although it works on all subsequent tries. I am pretty sure that this is because Js loads images asynchronously.
I am working in an environment without npm packages.

Cheers

why compare two dates Journal Date with date Today Not matches or not working on jQuery?

I work on the client side using jQuery and I am facing an issue where the journal date is

less than the current date but still matches the criteria, causing the condition to be met

and the code to enter the if block.

Steps I followed:

1- Get the current date in the format dd/MM/yyyy, e.g., 01/09/2024.

2- Retrieve the journal date from the UI datetime picker control Id txt_journal_date, e.g., 31/12/2024.

3- Compare the journal date with the current date.

4- If the journal date is greater than the current date, display an error message.

My issue is that when the journal date (31/12/2024) is smaller than the current date (01/09/2024), it still displays an error and enters the if block.

The expected result is that if the journal date is greater than the current date, it should display an error.

I need to compare the journal date in the format dd/MM/yyyy with the current date in the

same format. If the journal date is greater than today’s date, it should display an error.

However, the condition is being applied even though the journal date is less than today’s date.

Correct behavior:

If the journal date > current date, display an error.

If the journal date < current date, proceed without any issue.

Here is the code I tried:

function formatCurrentDate() {
    let currentDate = new Date();
    let month = String(currentDate.getMonth() + 1).padStart(2, '0'); // Months are 0-based
    let day = String(currentDate.getDate()).padStart(2, '0');
    let year = currentDate.getFullYear();
    return `${day}/${month}/${year}`;
}

let currentDateFormatted = formatCurrentDate(); 09/01/2025 dd/MM/yyyy
let pJournalDate = $("#txt_journal_date").val(); //31/12/2024 dd/MM/yyyy

if (pJournalDate > currentDateFormatted) {
    ModelSuccessDanger(
        MYLang.ReturnLang() === "ar-KW" ? 'عفوا !!' : 'Warning !!',
        MYLang.ReturnLang() === "ar-KW" ? "يجب ان لا يكون تاريخ الغلق اكبر من تاريخ اليوم" : "You should specify a date for closing that is not greater than the current date",
        '0',
        null
    );
    return false;
}

How do I use crypto.createSign() with ED25519 key?

I’m trying to sign some data with ED25519 in Node.js using crypto.sign(). This is almost completely copied from Node.js docs.

const sign = createSign('ed25519');
sign.update('<sensitive data here>');
sign.end();
const signature = sign.sign(privateKey);

However, I’m getting this error:

Error: error:1C80007A:Provider routines::invalid digest.

I’ve been looking in the Node.js docs and running crypto.getHashes(), but I can’t find anything for ED25519. Is there a workaround or is there some algorithm that I’m missing?

This stuff works for RSA and DSA keys, since all I needed to do was run something like

createSign('sha3-512')

Is there something like this for Ed25519?