Permanently burn font to text

I have .ttf of the fonts, what i want to do is permanently burn font to the text, like coolfont.org

What i want is

Step 1: input text

Step 2: upload font

Output

Copy the text with font on clipboard

I’m stuck with this for quite a while any help would be appreciated, thanks

how to do relationships in node js

I am trying to make a relationship between two collections a books collection and an author collection. I have got the get function and create function working in authors and books but I can’t get the update and delete requests to work.

here is my request body

{
    "name":"TestAuthor",
    "_id":"625cbc5bad86965c4e5ee104"
    
}

I postman I get this error

    {
        "msg": "E11000 duplicate key error collection: myFirstDatabase.books index: _id_ dup key: { _id: ObjectId('625cbc5bad86965c4e5ee104') }"
}

here is my author’s update function

const updateAuthor = async (req, res) => {
  try {
    const { id } = req.params;
    const author = await Author.findByIdAndUpdate(id, req.body);

    if (!author) {
      return res.status(404).json({
        success: false,
        msg: `No author with the id ${id}`,
      });
    }

    const newAuthors = await Book.find({});
    return res.status(200).json({ success: true, data: newBook });
  } catch (err) {
    return res.status(500).json({
      msg: err.message || "Something went wrong while updating an Author",
    });
  }
};

And the Delete function

const deleteAuthor = async (req, res) => {
  try {
    const { id } = req.params;
    const author = await Author.findByIdAndRemove(id);

    if (!author) {
      return res.status(404).json({
        success: false,
        msg: `No Author with the id ${id}`,
      });
    }

    const newAuthors = await Author.find({});
    return res.status(200).json({ success: true, data: newAuthors });
  } catch (err) {
    return res.status(500).json({
      msg: err.message || "Something went wrong while deleting an Author",
    });
  }
};

and my routes for authors just in case but I don’t think that is the issue.

import { Router } from "express";
const router = Router(); // Accessing the Router() object from express. This allows to handle various requests

// Importing the four functions
import {
    getAuthors,
    createAuthor,
    updateAuthor,
    deleteAuthor,
} from "../controllers/authors.js";

// Four routes that are mapped to the functions above
router.route("/").get(getAuthors);
router.route("/").post(createAuthor);

router.route("/:id").put(updateAuthor);
router.route("/:id").delete(deleteAuthor);

export default router; // You do not need to enclose router in curly braces

How to save form data in div to a text file using HTML and Javascript

So currently I have an HTML page where the user completes some data entry. Their data is spanned into a form on the page which they then copy and paste into a text file. I would like to include a button that would simply take the form, along with the spanned data, and save it to a text file. This will all be done locally, the user will have the HTML file saved on their computer. I have tried doing this via a textarea and a div but in both cases the text file doesn’t include the actual user data but just the HTML code. Here as example of how the program works:

function example(){
   var elements = document.querySelectorAll(".showexample");
   for(var i = 0; i<elements.length; i++){
      elements[i].innerHTML = document.querySelector(".exampleinput").value;
   }
}

<TD><input type="text" class="exampleinput" oninput="example()"></TD>

<div id="forUserDownload">
your input:<span class='showexample'></span>
</div>

When I try to include a download function (such as the one here:https://thiscouldbebetter.wordpress.com/2012/12/18/loading-editing-and-saving-a-text-file-in-html5-using-javascrip/), it just shows the HTML code instead of the actual user input. Is there anyway to do this with only HTML and Javascript?

How do I allow my program to detect keyCode without getting a type-error in Javascript?

I am fairly new to coding and I have been constantly been coming upon one problem. When making a game, such as snake or pong, I tend to use an event listener to listen for a keydown event such as : document.body.addEventListener("keydown", moveSnake);. I then go onto declare the function moveSnake :

function moveSnake(event){
    switch(event.keyCode){
        case 87:
             break;
        case 83:
             break;
        case 65:
            break;
        case 68:
            break;
         default:
             break;
    }
}

I understand there is no code telling the snake what to do yet. Once I do this I get a reoccurring issue. My program stops, and I get an error message in my console that says : Cannot read properties of undefined (reading 'keyCode'). I am using the latest version of google chrome and if someone could tell me what I am doing wrong it would be much appreciated. I have tried declaring the keyCode as a variable, and many other suggestions I have found randomly online but nothing as worked. Thank you!

useLocation equivalent in Nextjs

I’m trying to rebuild a menu that I had done using a tutorial but in Nextjs instead of react. At the time of doing the tutorial I had used react-router-dom v6 and useLocation. However as I am trying to learn and understand Nextjs more I am unsure if I should be still using react-router-dom (as I understand Next has built in routing) and if not how I should be using useLocation properly or the equivalent of it.I have attached the file and the code below, and really appreciate any input on trying to make this work.

Header.jsx

import React, { useEffect, useState } from "react";
import { FiMenu } from "react-icons/fi";

const Header = () => {
  // Need to find Nextjs equivalent
  const location = useLocation();

  // State for menu button
  const [state, setState] = useState({
    initial: false,
    clicked: null,
    menuName: "Menu",
  });

  // State for disabled button
  const [disabled, setDisabled] = useState(false);

  // Use effect for page changes
  useEffect(() => {
    setState({ clicked: false, menuName: "Menu" });
  }, [location]);

  const handleMenu = () => {
    disabledMenu();
    if (state.initial === false) {
      setState({
        initial: null,
        clicked: true,
        menuName: "Close",
      });
    } else if (state.clicked === true) {
      setState({
        clicked: !state.clicked,
        menuName: "Menu",
      });
    } else if (state.clicked === false) {
      setState({
        clicked: !state.clicked,
        menuName: "Close",
      });
    }
  };

  // Determine if the menu should be disabled
  const disableMenu = () => {
    setDisabled(!disabled);
    setTimeout(() => {
      setDisabled(false);
    }, 1200);
  };

  return (
    <div className="w-full mx-auto my-0">
      <div className="px-12 py-0">
        <div className="relative z-20 flex items-center justify-between h-32">
          <div className="text-base">LOGO</div>
          <div className="flex flex-row">
            <div className="mx-5">
              <button>Home</button>
            </div>
            <div className="mx-5">
              <button>Home</button>
            </div>
            <button
              className="ml-10 text-xl font-bold"
              disabled={disabled}
              onClick={handleMenu}
            >
              <FiMenu />
            </button>
          </div>
        </div>
      </div>
    </div>
  );
};

export default Header;

Hamburger.jsx

import React, { useEffect, useRef } from "react";
import gsap from "gsap";
import Link from "next/link";

const Hamburger = ({ state }) => {
  //Variables for animated nodes
  let menu = useRef(null);
  let revealMenu = useRef(null);
  let revealMenuBackground = useRef(null);
  let serviceBackground = useRef(null);
  let line1 = useRef(null);
  let line2 = useRef(null);
  let line3 = useRef(null);
  let info = useRef(null);

  useEffect(() => {
    if (state.clicked === false) {
      // close the menu
      gsap.to([revealMenu, revealMenuBackground], {
        duration: 0.8,
        height: 0,
        ease: "power3.inOut",
        stagger: {
          amount: 0.07,
        },
      });
      gsap.to(menu, {
        duration: 1,
        css: { display: "none" },
      });
    } else if (
      state.clicked === true ||
      (state.clicked === true && state.initial === null)
    ) {
      // open the  menu
      gsap.to(menu, {
        duration: 0,
        css: { display: "block" },
      });
      gsap.to([revealMenuBackground, revealMenu], {
        duration: 0,
        opacity: 1,
        height: "100%",
      });
      staggerReveal(revealMenuBackground, revealMenu);
      fadeInUp(info);
      staggerText(line1, line2, line3);
    }
  }, [state]);

  const staggerReveal = (node1, node2) => {
    gsap.from([node1, node2], {
      duration: 0.8,
      height: 0,
      transformOrigin: "right top",
      skewY: 2,
      ease: "power3.inOut",
      stagger: {
        amount: 0.1,
      },
    });
  };

  const fadeInUp = (node) => {
    gsap.from(node, {
      y: 60,
      duration: 1,
      delay: 0.1,
      opacity: 0,
      ease: "power3.inOut",
      stagger: {
        amount: 0.1,
      },
    });
  };

  const staggerText = (node1, node2, node3) => {
    gsap.from([node1, node2, node3], {
      duration: 0.8,
      y: 100,
      height: 0,
      delay: 0.1,
      ease: "power3.inOut",
      stagger: {
        amount: 0.3,
      },
    });
  };

  const handleService = (service) => {
    gsap.to(serviceBackground, {
      duration: 0,
      background: `url(${service}) center center`,
    });
    gsap.to(serviceBackground, {
      duration: 0.4,
      opacity: 1,
      ease: "power3.inOut",
    });
    gsap.from(serviceBackground, {
      duration: 0.4,
      skewY: 2,
      transformOrigin: "right top",
    });
  };

  const handleServiceReturn = () => {
    gsap.to(serviceBackground, {
      duration: 0.4,
      opacity: 0,
    });
  };

  const handleHover = (e) => {
    gsap.to(e.target, {
      duration: 0.3,
      y: 3,
      skewX: 4,
      ease: "power3.inOut",
    });
  };
  const handleHoverExit = (e) => {
    gsap.to(e.target, {
      duration: 0.3,
      y: -3,
      skewX: 0,
      ease: "power3.inOut",
    });
  };

  return (
    <div
      ref={(el) => (menu = el)}
      className="fixed inset-0 z-10 hidden w-full h-full"
    >
      <div
        ref={(el) => (revealMenuBackground = el)}
        className="fixed inset-0 w-full h-full bg-black -z-10"
      ></div>
      <div
        ref={(el) => (revealMenu = el)}
        className="relative h-full overflow-hidden bg-accentedPink"
      >
        <div
          ref={(el) => (serviceBackground = el)}
          className="absolute inset-0 w-full h-full bg-no-repeat bg-cover opacity-0"
        ></div>
        <div className="w-full mx-auto my-0">
          <div className="px-12 py-0">
            <div className="relative flex items-center justify-between top-52">
              <nav className="block">
                <ul className="p-0 m-0">
                  <li className="relative h-32 overflow-hidden font-bold list-none cursor-pointer text-8xl w-160">
                    <Link
                      onMouseEnter={(e) => handleHover(e)}
                      onMouseOut={(e) => handleHoverExit(e)}
                      ref={(el) => (line1 = el)}
                      to="/"
                    >
                      Opportunities
                    </Link>
                  </li>
                  <li>
                    <Link
                      onMouseEnter={(e) => handleHover(e)}
                      onMouseOut={(e) => handleHoverExit(e)}
                      ref={(el) => (line2 = el)}
                      to="/"
                    >
                      Solutions
                    </Link>
                  </li>
                  <li>
                    <Link
                      onMouseEnter={(e) => handleHover(e)}
                      onMouseOut={(e) => handleHoverExit(e)}
                      ref={(el) => (line3 = el)}
                      to="/"
                    >
                      Contact Us
                    </Link>
                  </li>
                </ul>
              </nav>
              <div ref={(el) => (info = el)} className="info">
                <h3>Our Promise</h3>
                <p>
                  Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
                  do eiusmod tempor incididunt ut labore et dolore magna aliqua.
                  Ut enim ad minim veniam, quis nostrud exercitation ullamco
                  laboris nisi ut aliquip ex ea commodo consequat. Duis aute
                  irure dolor in reprehenderit in voluptate velit esse cillum
                  dolore eu fugiat nulla pariatur. Excepteur sint occaecat
                  cupidatat non proident, sunt in culpa qui officia deserunt
                  mollit anim id est laborum.
                </p>
              </div>
              <div className="locations">
                Location:
                {cities.map((el) => (
                  <span
                    key={el.name}
                    onMouseEnter={() => handleService(el.image)}
                    onMouseOut={handleServiceReturn}
                  >
                    {el.name}
                  </span>
                ))}
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  );
};

export default Hamburger;

How can I resolve a single reference in react?

fruit json value.

console.log(fruit)
[
    {
      content: "apple",
      information: [
        {
            calorie: "122"
        },
      ],
    },
    {
        content: "banana",
        information: [
          {
            calorie: "221"
          },
        ],
      },
    {
        content: "mango",
        information: [
          {
            calorie: "52"
          },
        ],
    },
];

Create a button by running the map function on the information on the fruit.

The dynamically created button is {value.calorie} first button 122 second button 221 third button 52 is created.

And the content also maps function to fruit and puts {fruit.content} as the argument value in the button.

And set useRef so that when the value.calorie button is clicked, the fruit content button is also clicked.

const Content = useRef(null);
const Calorie = useRef(null);


const onClickContent = (content) => {
  console.log(content);
};

const onClickCalorie = (calorie) => {
  Content.current.click();
  console.log(calorie);
};

return (
  <>

    fruit.map((Fields, index) => (
  <>
  <p>{Fields.content}</p>
  <button style={{"display": "none"}} ref={Content} onClick={() => onClickContent(Fields.content)}></button>
  </>

  {Fields.information.map((Value, key) => {
      return (
          <>
          <p>{Value.calorie}</p>
          <button onClick={() => onClickCalorie(Value.calorie)}>{Value.calorie}</button>
          </>
      )
  })}
  ))
  </>
)

The problem is that when you click the 122 displayed on the button, the content is also output to the console, apple should be output, but mango is output.
If you click the button with calorie 221, banan should be output, but mango is output to the console. This is said to be because of a single reference.
How can I solve the single reference function? I do not know.

Cannot get specific information from a database using SQL

it’s my first time making two SQL requests in on ‘connection.query’ and something is definetly not right, first of all here is my code:

pool.getConnection(function (err, connection) {
    if (err) throw err;
    let sql = `SELECT * FROM custom_prefix WHERE guild_id = '12345678912345678'; SELECT * FROM cache_size`;
    connection.query(sql, async function (err, result) {
        if (err) throw err;
        console.log(result);
        connection.release();
    });
});

So far everything works perfectly fine and the output will be:

[
  [
    RowDataPacket {
      prefix: '!',
      guild_id: 12345678912345678,
      guild_name: 'server name',
      changed_by_id: 12345678912345678,
      changed_by_name: 'username#1234',
      changed_date: 2022-04-13T19:50:33.000Z
    }
  ],
  [ RowDataPacket { guilds: 4, users: 39 } ]
]

If I change the console.log(result) to console.log(result[1]) the output will be:

[ RowDataPacket { guilds: 4, users: 39 } ]

So everything works like I would expect it, but if I only want a specific value from the result[1], lets say the guilds, then I would do console.log(result[1].guilds).

I would to this because I have some other files where I check the database for something and use the result[0].something method and there it works absolutely fine. But as soon as I use two SELECT * FROM requests it doesn’t.

So if I try to console.log the result[1].guilds the output will be:

undefined

Which makes no sense for me because I oftenly use this method and it works fine.
But here it says undefined.

So I don’t know how to get a specific value from one of the results when using two , I hope somebody here can help me.
Thanks.

Node.js app not starting after upgrading webpack to v5

I’ve upgraded all npm libraries to latest versions including webpack..
Made appropriate updates to webpack.config file…

But my app fails to start with an error I cannot find solution for even google it:

[1650242490129] ERROR (xxxxxxxxxxxx): Cannot add property autodllStatsRetrieved, object is not extensible
    err: {
      "type": "TypeError",
      "message": "Cannot add property autodllStatsRetrieved, object is not extensible",
      "stack":

Please, advise

exif.js using old file

I implemented an EXIF button in a gallery to read EXIF data using the well-known exif.js script from here. My image loads into a img0 img node, and then I use:

function exif() {
  EXIF.getData(img0, function() {
   var model    = EXIF.getTag(this, "Model");
   var datetime = EXIF.getTag(this, "DateTimeOriginal");
   var fnumber  = EXIF.getTag(this, "FNumber");

   .... <print this.src, and the exif output>

  });
}

When I click a thumbnail, the large image appears fullscreen (in a modal, with the img0 img node on it with the corresponding img.src), with an EXIF button (top, second from left), which executes the above function exif() when onclick. It works fine. Then I close the image by clicking on it, click on another thumbnail, and a second large image opens (with an updated img.src). When I click the EXIF button again, I can see a different img.src, yet the same EXIF as the first one (same gps, same time, etc). Somehow exif.js keeps the old img.src, and does not update it. You can check the gallery working here.

How do I force exif.js to see the new img.src file? Can I ask exif.js to read the file instead of the img node? This is not supported in the documentation.

Setting up routers for my node.js project

So i am running into quite a few problems with how i am setting up my routes for my node.js app

here is my app.js and how i am calling the route

const express = require("express");
const bodyParser = require("body-parser");
const app = express();
require('dotenv').config()
const passport = require('passport')
const flash = require('express-flash')
const session = require('express-session')
const initializePassport = require('./passport-config')


const saltRounds = 10;
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({
  extended: true
}));
app.use(express.static("public"));
// app.use('/public', express.static(__dirname + "/public"))
app.use(flash())
app.use(session({
  secret: process.env.SESSION_SECRET,
  resave: false,
  saveUninitialized: false
}))
app.use(passport.initialize())
app.use(passport.session())


//Routes

// app.use(require('./routes'));
require('./routes/index.js')(app, passport, bcrypt, checkAuthenticated, checkNotAuthenticated, dbSize, saltRounds, User, setupDb);
require('./routes/dashboard.js')(app, passport, checkAuthenticated, checkNotAuthenticated, User, User_database, dbSize, Db_size, setupDb);
require('./routes/db.js')(app, passport, checkAuthenticated, checkNotAuthenticated, User, dbSize, User_database, Db_size, Db_tablespace, setupDb);
//GETS and POSTS


app.get('/logout', function (req, res) {

  req.logout();
  res.redirect("/");

});

app.use((req, res) => {
  res.status(404).render('404');
});

here’s one of my routes db.js

var express = require('express');
var router = express.Router();
const Db_size = require('../db/models/db_size')
const Db_tablespace = require('../db/models/db_tablespace')

module.exports = (app, passport, checkAuthenticated, checkNotAuthenticated, User,dbSize,User_database,Db_size,Db_tablespace,setupDb) => {

    
    router.get('/:id/db_size', checkAuthenticated, async function (req, res) {
        const id = req.params.id;
        try {
            let dbSizeInfo = await Db_size.query().where('db_id',id)
            res.render("db-size", {
                free: dbSizeInfo[0].db_free,
                used: dbSizeInfo[0].db_used
            });
            app.use('/db/'+id , express.static("public"));

        } catch (error) {
            console.error(error)
        }

    });

    app.use('/db', router , express.static("public"));
    // app.use('/db/?', express.static("public"));

}

as you can see in the db.js i have redefine my public folder on the route, so like each time i create a route i have redefine my public folder on each route i make (otherwise it would look in the /theCalledRoute folder instead of /public for my static files), which was annoying but it worked. Now however that i added the /:id to it is looking db/:id folder to find all my static files instead of the public. I would have make a app.use(‘/everyidever’, router , express.static(“public”)); for all the ids. Is there a better way to do this?. I need to export the necessary variables from my app.js for everything to work. Let me know if you need more info

Is there a way to have a photo link to React Components?

not sure how I’d be able to accomplish this but I wanted to have a photo where when I click on a certain area, it would route the user to a certain URL and render the according component. I figure I can capture the event.target’s windowX & windowY coordinates or something, but I’m hoping there’s some concise way of doing this. Or maybe a name for what I’m trying to do?

Any info helps!
Thanks!

Three.js Detect if Traverse is complete

Is there a way to check if the traverse function is complete (finished traversing the scene)?

Something like (example)

                fbx.traverse( function( c ) {

                    if ( c instanceof THREE.Camera ) {              

                        // Debug log camera child
                        console.log( c );

                    }

                }).onComplete(function( e ) {
                    // Do something on complete
                });

How to make API data a link once fetched to take user to another page to display data

I am trying to make a API call and return the JSON object in an unordered list in Component A. Once I make the unordered list, I need to make the name property a link which will take me to component B and show the data related to the name property. How can I achieve this?

Component A (Home.js)


import React , { useState} from "react";
import axios from 'axios'; 
import Display from './Display'

function Home(){

  const [info, setInfo] = useState([]);
  const [orgName, setOrg] = useState([]);
  const [dataToMove, setDataToMove] = useState([]);

  let signal = axios.CancelToken.source();

  function handleChange(event) {
      setOrg(event.target.value);
  }

  function handleClick(event) {
      axios.get(`https:/api.github.com/orgs/${orgName}/repos`, {
          cancelToken: signal.token,
      })
          .then(res => {
              const info = res.data;
              setInfo(info);
              setDataToMove(info);
              console.log(info);
          }).catch(err => {
          console.log(err);
      });
  }
//  < Display parentToChild={this.state.dataToMove}>
//|Image: <img src={dummy.owner.avatar_url} alt="" />
  const parentToChild = () => {
    let data ={};
    data = dataToMove;
  }
  let getInfo = info;
    return (
      
        <div>
           
          <span>Enter User Id</span>
               <input type="text" onChange={handleChange}/>
               <button onClick={handleClick}>Get Posts By User</button>
               <button onClick={parentToChild} > Go to Display Page</button>
               <ul> 
             {
              getInfo.map(dummy => 
               (
                 <li key={dummy.id} >
                       Name: {dummy.name}  
                     
                       || Fork: {dummy.fork ? "true" : "false"} || Owner: {dummy.owner.login}
                       || Avatar: {} || Open Issues: {dummy.open_issues_count}} 
    
                           </li>
                    
               ))
    
             }
           </ul>
         
        </div>
       
                       
              
       );
}

export default Home;


Component B (Display.js)


function Display({parentToChild}){
  const info =[];

    return (
      
        <div>
          <span>See Data Below</span>
               
               <ul> 
             {
              info.map(dummy => 
               (
                     <li key={dummy.id} >
                       Name: {dummy.name} 
                     
                       || Fork: {dummy.fork ? "true" : "false"} || Owner: {dummy.owner.login}
                       || Avatar: {} || Open Issues: {dummy.open_issues_count}} ||Image: <img src={dummy.owner.avatar_url} alt=""/>
    
                           </li>
                                      
                         
               ))
    
             }
           </ul>
              <p> {parentToChild}</p>
        </div>
                       
              
       );
}

export default Display;

Navigation.js

import React from "react";
import { NavLink } from "react-router-dom";

function Navigation() {
  return (
    <div className="navigation">
      <nav className="navbar navbar-expand navbar-dark bg-dark">
        <div className="container">
          <NavLink className="navbar-brand" to="/">
            React Multi-Page Website
          </NavLink>
          <div>
            <ul className="navbar-nav ml-auto">
              <li className="nav-item">
                <NavLink className="nav-link" to="/">
                  Home
                  <span className="sr-only">(current)</span>
                </NavLink>
              </li>
              <li className="nav-item">
                <NavLink className="nav-link" to="/about">
                 Display Data
                </NavLink>
              </li>
            </ul>
          </div>
        </div>
      </nav>
    </div>
  );
}

export default Navigation;

index.js

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
import  {Navigation, Display, Home }from './Components';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
  <React.StrictMode>
  <Router>
    <Navigation />
    <Routes>
      <Route path="/" element={<Home />} />
      <Route path="/Display" element={<Display />} />
    </Routes>
  </Router>
  </React.StrictMode>
);