Graph DB and finding shortest path between coordinates

I am evaluating what graph db to use for my use case .

Use Case : The building layout has multiple rooms , R1, R2 , R3 , R4 , R5 ..etc . We can use these 2 paths to reach R5 From R1 .

R1 –> R2 —> R4 —> R5

R1 –> R2 —> R3 —> R5

Similary we have n number of points and x number of paths . Now as every of these points can be interconnected and i want to find.

  1. All the available paths from point A to B .
  2. Shortest available path from A to B .

Please note every above is in form of x,y coordiantes . For Example : R1 is at 50,100 and R2 is at 100,200

What DB shall i use as the usage is low ?

Any example on how to store , retrieve using Javascript would be helpful

Test case in jest for Excel calculate method

I am working on a function in JavaScript that recalculates Excel workbook. A major part of worksheets are cells with a results from API.
This function works fine but I need to write test scenario for it in Jest.
Can someone help me with this??

const someFunction = async () => {
  await Excel.run(async (context) => {
    context.application.calculate(Excel.CalculationType.full);
    await context.sync();
  }).catch(function (error) {
    console.log(error);
  });
};

How to call Vue 3 method from outside the app

what I want is to call a method, declared in vue 3 app form outside the component of the page. So what I did sofar:

App.vue

<script setup>
 
function test(){
console.log('test');
}
</script>

vue.js

import { createApp } from 'vue'
import App from 'App.vue'

window.app = createApp(App).mount('#app')

index.html

<div id="app"></app>
<script src="app.js"></script>

<script>
 fuction callTest(){
   window.app.test() // <-- this returns undefined
 }
</script>

however it worked with vue2. Any idea how to get it work with vue3?

Hovering not working while displaying an element on hovering another button

Intro

I am having a color palette. I wanted to display a tooltip whenever I hover that button. But when I hover over them , it is not.

I am using ReactJS and css for styling.

So this is the color palette and I want to display the tooltip whenver someone hovers any button.

cp

Now I followed upto 2nd answer here. But it is not working.

Code

App.js

themeList.map((t, k) => (
      <button
        key={k}
        id="theme_color_btn"
        data-theme={t}
        onKeyDown={this.keyboardNavigation}
        className={`theme-button bg-${t}-500${theme === t ? " is-active" : ""}`}
        onClick={this.changeTheme}
      >
        <div
          id="tooltip"
          className={`bg-${t}-100 absolute text-${t}-900 text-sm p-1 rounded-md ring-1 ring-purple-900 z-10 mt-3 transition-transform capitalize `}
        >
          {t}
        </div>
      </button>

where const themeList = [ "indigo", "yellow", "red", "purple", "pink", "blue", "green", ];
index.css

#theme_color_btn{
  display:block;
}

#theme_color_btn:hover + #tooltip{
  display:block; 
  z-index:5;
  background-color:gray;
}

#tooltip {
  display:none ;
}

Instead,no tooltips are displaying on hover.

For Full code refer index.css and App.js files here

useRef.current returns empty array while console log shows updated value

Using useRef to update a variable with an array in my Context and then pass it down to another component. Problem is, I noticed that useRef updates said variable in ComponentA.

However when I try to access said variable in ComponentB this is what I see in my console log:

useEffect useRef is it working?: 
{current: Array(0)}
current: (3) ['testingUser', 'testing', 'value']
[[Prototype]]: Object

My question is that, I see the values I updated using useRef while at the same time, when I try to access these values using availableOnlineUsers.current I just see a blank array

Here is my code in ComponentA:

...
availableOnlineUsers.current = availUsers
...

console log at this point returns:

(3) ['testingUser', 'testing', 'value']

This is my code in my Context:

...
const availableOnlineUsers = useRef([])
...

and in ComponentB this:

console.log(availableOnlineUsers.current)

returns an empty array

While this:

console.log(availableOnlineUsers)

returns:

{current: Array(0)}
current: (3) ['testingUser', 'testing', 'value']
[[Prototype]]: Object

generate a specific number of dates from an array of days

if I have an array of : [‘Thursday’, ‘Friday’]

and I want to generate 5 dates on the next dates of these days

for example, i want the result is the next Thursday is 14/7/2022, next Friday 15/7/2022

 Thursday  ,    Friday   ,   Thursday  ,   Friday    ,   Thursday   

=> [’14/7/2022′, ’15/7/2022′ , ’21/7/2022′ , ’22/7/2022′ , ’28/7/2022′]

get max sum of multiple functions

I’m trying to get the largest number of this 3 functions then store in an array, the variables of that function and their amount..how to do that?

var array = [50,55,60,165] // x,a,b,x+a+b

function r1(){
 var x = 5;
 var a = 10;
 var b = 10;
return x+a+b
}
function r2(){
   var x = 50;
   var a = 55;
   var b = 60;
return x+a+b
}
function r3(){
   var x = 25;
   var a = 15;
return x+a
}

Google Calendar API get Event details

I tried to get the event from Google Calendar of the specific date

function testing(){

var cal = CalendarApp.getCalendarById('[email protected]');
var events = cal.getEvents(new Date("7/11/2022 07:30 AM"),new Date("7/12/2022 10:00 AM"));
for (var i=0;i<events.length;i++){
var title = events[i].getTitle();
var start_time = events[i].getStartTime();
var end_time = events[i].getEndTime();
}}

But I don’t know how to get the same detail from Calendar when I schedule any meeting without specifying any date range.

My request is, I need to get the Title, Organizer Name, Start and End Time of the meeting when I schedule any meeting in Google Calendar.

Moment I press Save in the Calendar, My script needs to trigger and get the details of the meeting I scheduled in calendar.

How can I represent objects as an interface

How can I represent the following javascript object as an interface:
I did try using http://json2ts.com/, however did not give a clean and dynamic interface.
Hence, I do not want the id/codes (i.e. 6000, 6001, 6002) to be present in the interface.

{
    "6000": {
        "id": 6000,
        "type": "text",
        "subType": "tileDynamicSection",
        "title": "Title 1",
        "description": "Description 1",
        "imageUrl": "https://prod.assets.domain.com/uploads/myimage.jpg"
    },
    "6001": {
        "id": 6001,
        "type": "text",
        "subType": "tileDynamicSection",
        "title": "Title 2",
        "description": "Description 2",
        "imageUrl": "https://prod.assets.domain.com/uploads/myimage.jpg"
    },
    "6002": {
        "id": 6002,
        "type": "text",
        "subType": "tileDynamicSection",
        "title": "Title 3",
        "description": "Description 3",
        "imageUrl": "https://prod.assets.domain.com/uploads/myimage.jpg"
    }
}

Need help for counting common elements

<3
I have two objects :

obj1 [
  'Anime',
  'Movies/TV Series',
  'Coding',
  'Cooking',
  'Sport/Fitness',
  'Gaming'
]

and

obj 2 [
  'Music',
  'Movies/TV Series',
  'Coding',
  'Party/Night Clubs',
  'Gaming',
  'Traveling',
  'Roleplay'
]

i need to count the number of common elements.
How can i do it please in js… ?

Thanks in advance

JavaScript wrap existing function in async one: deal with the result (automatically wrapped into a Promise)?

I’m trying to write a “mixing” for JavaScript classes (controllers, in my app) to automatically “await” for a given function to be resolved, before actually invoke the real methods. Real class methods should receive the resolved value as last argument.

Here is the code of useAwait, where i’m looking for the static class property awaits and wrapping the originalFunc into a new async one. I’m calling the new function passing the original arguments plus the asyncFn call result:

const useAwait = (controller, asyncFn) => {
  controller.constructor.awaits.forEach(func => {
    const originalFunc = controller[func];

    controller[func] = async (...args) => {
      return originalFunc.apply(
        controller,
        [...args, await asyncFn.call(controller)]
      );
    };
  });
}

So when useAwait(ctrl, this.load) is invoked on an instance this class:

class Controller {
  static awaits = ['foo', 'bar'];
  
  promise;
  
  constructor() {
    useAwait(this, this.load);
  }
  
  async foo(e, resolved) {        
    return resolved;
  }
  
  bar(resolved) {
    return resolved;
  }
  
  async load() {
    if (!this.promise) {
      this.promise = new Promise(resolve => setTimeout(() => {
        resolve('Hello World!');
      }, 3000));
    }

    return this.promise;
  }
}

The problem: all seems fine for foo (already async), but it’s not for bar: the result is a Promise because now the bar is wrapped in async (wan’t before). I know that an async function result is wrapped into a Promise. Codepen example where bar call outputs “[object Promise]”.

So the question is: in theory, I should check if the original function is async and if it was not, await for it’s return value?

status : 500 Internal Server Error postman only posts empty curly brackets when enter the data on the body

and this is my code (index.js), (auth.js)

const express = require("express");
const dotenv = require("dotenv");
const mongoose = require("mongoose");
const authRoute = require("./routes/auth");
const app = express();

dotenv.config();
app.use(express.json());


mongoose.connect(process.env.MONGO_URL, {
    useNewUrlParser: true,
    useUnifiedTopology: true,
    useCreateIndex: true,
  }).then(console.log("Connected to MongoDB"))
  .catch((err) => console.log("err"));
app.use("/api/auth",authRoute );

app.use("/api/auth",authRoute);


app.listen("3000", () => {
  console.log("Backend is running.");
});
const router = require("express").Router();
const User = require("../models/User");

//REGISTER
router.post("/register", async (req, res) => {
  try {
    const newUser = new User({
      username: req.body.username,
      email: req.body.email,
      password: req.body.password,
    });

    const user = await newUser.save();
    res.status(200).json(user);
  } catch (err) {
    res.status(500).json(err);
  }
});

//LOGIN


module.exports = router;
and image of the postman result 

when I send the request postman posts empty curly brackets. I want to get the post data on the down of the body at the postman

screenshot of the postman

POST information problem with Firefox (but also Opera) for Android

Hello dear forum members,

Sending a form with filename and text in it, from a HTML page with javascript and
server side using PHP creating doesn’t always work.
Usually only the first send, but sometimes other sends are missing in between.
The situation is a large html file with many lines.
Sending with Chrome or Samsung Android or an old slow mobile with Firefox Android version 68 is no problem.

What is the problem here; javascript code compatibility ?

I have no special software and also not enough expirience to detect something with it.

I have tried in different situations; checked the quotes and used with that single or double quotes;
I use .text ipv. .textContent but also that make no difference
I checked all variables; I used var, but now let and const
I have w3c validated, but not all, because I must learn a lot off that
I checked all , and ; and replace them were I think that realy mathers
Its always the same problem the site works with Chrome and Samsung browser and
sometimes there is now request with Firefox v102
In Firefox 68 for Android v4.x on an old HTC mobile there is no problem.

Who can help ?; What is playing here aroud the code

I build this site for non commercial use and it’s temporary useable here:
myrequest.nl/_firefox.htm

I’m not really a programmer, but because of my quality thinking through my profession I have a good sense of how things should go together and also to be able to test that from different angles. Sorry but I don’t always know direct the naming conventions for some code, because I am always learning about it.
That’s also a reason why I keep it simple as it can and used no third part software

Here are snips off the code:

<form id="form3utxt" action="ab.php" method="post" target="_blank">
<input type="hidden" name="w" id="w">
<input type="hidden" name="fSA" id="fSA">
<input type="hidden" name="formSubmit" value="Submit">
</form>

Here is a lot of code with jscript variables

fSA="K"+pm+dt+"_"+na+"_("+c.substring(0,3)+r+"_"+ncc+")_"+v+"-"+vt+dd+"_("+sB+").m3u";

w="D:\KAR\"+c+t+" "+l;

Normaly there is much information in the varibles
But if i replace only text in the strings like

fSA="This_is_a_test.m3u";
w="This is a text";

the problem is staying there

document.getElementById('w').value=w;

document.getElementById('fSA').value=fSA;

document.forms["form3utxt"].submit();

And the php is here:

if($_SERVER["REQUEST_METHOD"]=="POST")

{

$varLink=$_POST['w'];

$varBestand=$_POST['fSA'];

print "<h2>varlink inhoud:</h2>";print "<h2>".$varLink."</h2>";
print "<h2>varBestand inhoud:</h2>";print "<h2>".$varBestand."</h2>";
chdir("av");

$fs=fopen($varBestand,"a");

fwrite($fs,$varLink."n");

fclose($fs);

}

echo '<script>window.open("","_self").close();</script>';

Greeting from the Netherlands,

Herman