« first day (3292 days earlier)      last day (1639 days later) » 

9:00 AM
That will be represented with maybe black dots
 
@NishantArora sure
 
I'll try to implement what you told me.
 
@HassanAlthaf yeah, that's what I was thinking
a black dot where hallways meet and at the beginning and end
if the hallway doesn't lead to anything, it's not a big deal
it won't ever be the fastest route
you should have dots anywhere where a person might walk
 
user8732191
https://jsfiddle.net/x0sao4pv/

In the given fiddle for running loop you have implemented this loop :-
for(let i=0; i<5; i++) {
    ar.push(doAction(function() {
        console.log(i);
    }, Math.random() * 2000));
}

so instead of this loop if I am using this:-

for (let i = 0; i < 5; i++) {
    ar.push(
        doAction(function () {
            setTimeout(function run() {
                console.log(i);
            }, Math.random() * 2000);
        })
    );
}

then again it is printing completed first and then running loop.Why this is happening?
 
user8732191
what is the diffrence actually in both the ways?
 
9:04 AM
@NishantArora doAction is calling setTimeout
you don't need to call it
func() is getting called inside setTimeout in my doAction function
so you're being redundant
 
user8732191
Sorry I didnt got this thing?
 
user8732191
Do you mean that settimeout is getting called two times?
 
take a look at what doAction does
it calls setTimeout for you
what you pass to doAction is what happens when the timeout occurs
so in this case just console.log(i)
 
user8732191
ok so if I remove settimeout from top then?
 
user8732191
function doAction(func) {
    return new Promise(function(resolve) {
            func();
            resolve();
    });
}
let ar = [];
for (let i = 0; i < 5; i++) {
    ar.push(
        doAction(function () {
            setTimeout(function run() {
                console.log(i);
            }, Math.random() * 2000);
        })
    );
}
console.log(ar);
Promise.all(ar).then(function() {
    console.log('Completed');
});
 
user8732191
9:08 AM
like this
 
you're still calling setTimeout
hmm I see what you did
The problem with this is that the function gets called, and calls setTimeout, then it proceeds to immediately resolve the promise
This would still work except the last line would be executed before the rest
the "Completed" would be shown right away like this
this is why I called the setTimeout inside the doAction, so that it gets resolved only after the timeout occurs
 
user8732191
Yeah that's what happening so If I want to work with this then what should I do?
 
user8732191
I am actually just trying multiple ways to do it so that I can get knowledge of this?
 
@Neil yes, I'm doing that now.
 
user8732191
Ok sure, thank you!
 
9:14 AM
hallway: [
        {
            start: [x, y],
            end: [x, y]
        }
    ]
@Neil Dose this format look good for hallway?
*Does
 
second guys
work calls
 
user8732191
Neil you there?
 
He's on a call.
 
user8732191
Ohh ok
 
@HassanAlthaf like this how will you connect with other hallways? otherwise to me it looks fine
@NishantArora for doing specifically what you requested, I don't think there is another way
though there are other ways of handling async operations like using await/async
 
9:28 AM
Not really sure honestly, trial-error.
I'm guessing the greaph?
 
user8732191
@Neil Ok, thank you so much neil for all the help. Anyway my task is done with you solution.
 
Is there any video/guide on the basic theory of that graph?
 
posted on October 21, 2019 by Michaël Zasso

This release marks the transition of Node.js 12.x into Long Term Support (LTS) with the codename 'Erbium'. The 12.x release line now moves into "Active LTS" and will remain so until October 2020. After that time, it will move into "Maintenance" until end of life in April 2022. Notable changes npm was updated to 6.12.0. It now includes a version of node-gyp that supp

 
Would I use a similar graph like the above?
 
@HassanAlthaf yes, think of it like the graph (and not so much like the map with the bridges)
 
9:35 AM
Any example graph
That I could try to model in code?
 
sure
 
parseHallwayLines: function (points) {
        for (let i = 0; i < points.length; i++) {
            hallwayPoints[points[i].id] = points[i];
        }
    }
 
just remember each node needs a coordinate as well
you need to be able to traverse your graph, starting from a single node
 
{
        id: 3,
        start: {
            x: 110,
            y: 110
        },
        end: {
            x: 110,
            y: 0
        }
    }
I pass data of that sort
Build an object with the key as id of the path
So, my plan here is
 
the id should be associated with the node, not the hallway
you can reach the end of the hallway and not actually go inside the hallway, right?
 
9:38 AM
Here's my plan:
After populating the hallwayPoints object,
I'll re-iterate
And find previous node's ID
and that will be the line adjacent to the
starting point
And find next Node's ID, that'll be the hallway adjacent to the ending point
Does this sound good?
I did try giving nodes an ID, but I can't seem to figure out how to link them
 
hmm, no
you're treating hallway like it's itself a thing
 
Should I hard code the possible next nodes and previous nodes?
 
for path finding, there is no hallway or room
there are only nodes which connect or don't connect
 
that's why I was saying you should represent the hallway as two points
they are literally two nodes connected with each other
if you add a door from a room, then it becomes start of hallway connects to door of room connects to end of hallway
etc.
 
9:41 AM
So should I do something like:

{
    id: 1
    x: 10,
    y: 10,
    connected: [... ids of all the nodes directly connected to the node ...]
}
 
yes, now I think you're getting it
at least for what concerns the pathfinding aspect
 
Is there any way to auto calculate the connected nodes?
 
you may still be very much interested to know it is a hallway for creating the svg later
 
how could you do that? you're the one that decides how you can get where :P
if all nodes were connected, then it would be a trivial task :P
 
9:43 AM
I don't get you
I'm sorry I'm bad with english
So lets say I have a Node in a junction
It's a four way junction
 
ok
 
So this particular node would be connected to 4 different adjacent nodes.
 
ok
 
so in the connected: [1, 2, 3, 4]
Ids of 4 different nodes that are adjacent to the center junction node?
 
lets call the id of the node in the middle node 0
 
9:44 AM
Alright.
 
yes, if there werne't a point in the middle, then you couldn't turn
if 1 is north, 2, is east, 3 is south
The path might be 1, 0, 3
or 1, 0, 2
It can't just be 1, 2 or 1, 3
do you see why?
 
I mean I suppose you could, but also drawing such a path would be difficult
there's no harm adding additional nodes if it is convenient for you to do so
 
So how would I
 
when you want to draw the path, then you simply draw a line from the coordinates of nodes 1, 0, 2 or 1, 0, 3
 
9:47 AM
Represent
The nodes
As a Model
 
I think it would be a good idea to represent the nodes as a java object containing ids of adjacent nodes, a unique id for itself, and coordinates
 
So for the current example,
It would be
{
            id: 0,
            x: 110,
            y: 110,
            connected: [1,2,3]
        },
 
yeah, I think so
You could put it in a map so you can look them up easily too
 
Interesting
Ok, let me re-code everything
For this part
 
let map = {};
map[0] = {
    id: 0,
    x: 110,
    y: 110,
    connected: [1, 2, 3]
}
so if you come across node 0, then map[0] will get you everything about that node
the ids aren't important. They could be generated. The important thing is that they're unique
 
9:51 AM
Yes
That code was the API side. Will turn into an array in the object that works on it
I want the calling side of the object to be simpler to work on
I have to map out a huge 6 storey building, and it will be a pain HAHA
 
well once you're confident it works for a simple two node graph, four-node graph, full floor layout, and two story layout
then it could be a 1000 story building
you probably want to separate the graph into floors
you could technically make the elevator connect all floors like it were part of the same graph, but that would slow down pathfinding quite a bit
if anything, keep track for each floor, which node points to the elevator
 
alright, that should be do-able.
So that's my data so far.
Let me show you the graph
I mean diagram
 
it helps to visualize it
that's for sure
 
Black dots represent what I just showed you. Red dots are the doors
 
with a door, it would complicate things slightly
 
9:58 AM
    parseHallwayPoints: function (points) {
        for (let i = 0; i < points.length; i++) {
            hallwayPoints[points[i].id] = points[i];
        }
    }
So with a point id, I can get the entire object.
Should I try to find the adjacent nodes with a door first?
 
if a door C is added between two points A and B, then A should no longer point to B, but rather to C, and B should point to C and not A also
 
Oh! The door must be a point as well?
 
yep
if it weren't, you'd have a hard time getting to the destination room :P
if a door were only an exit with a coordinate, you could just have a connector from the door to the hallway
but you also must be able to arrive to a door
so that isn't enough
Every dot in your graph, black or red, should be a node with its own coordinate and connecting to nodes nearby
for simplicity, assume no node can skip another
before you can traverse the hallway, you must necessarily pass by the node represented by the door
if that affects how you draw the line in the end, then you could optionally include information on the node like "isDoor" true/false
 
but don't do that if you don't need to
 
10:03 AM
dont need isDoor
I have coordinates of door with each building
And if I have coordinates of door in the hallwayPoints,
if there is a match between the two, its a door
So I was thinking, get the coordinates of the starting door to ending door
 
you can't make that assumption
 
That should be easy with the room id
 
if you assume every node between exactly two other nodes is a door, then hallway corners are also doors by that logic
 
No
I have the coordinates of door
Stored within
Each room's object
And also corodinates of door are stored in the hallwaypoints object
if coordinates in a hallway point object
 
hmm
maybe it would be easier to not save this information together with hallway and room
 
10:06 AM
Wouldn't it be easier
To find the starting point
first node would be found by room id
 
well like this you'd have to cycle through every room and hallway to find the nodes
you'd need to know the doors of a room, but the hallways are just connected nodes
 
No, it's simple.
doors[roomId] = coordinates of room's door
thats our starting node
find the node in the nodes list
 
as long as the nodes tell you where to go next
 
from that list, we can iterate through the connected adjacent nodes until we find the coordinates of doors[destinationRoomId]
Is this idea good?
 
yeah, I think so. you can't have multiple nodes with the same coordinates
or if you can, it's a mistake
 
10:08 AM
yes
exactly
 
though it's probably better to give them ids
the nodes I mean
 
yes, they all do have
 
so you can simply check that the node you've reached has the same id as the id you're looking for
 
findPath: function (startId, endId) {
        console.log(
            "Start ID: " + JSON.stringify(doors[startId]) + "\n\n"
            + "End ID: " + JSON.stringify(doors[endId])
        );


    },
even if there was an overlapping node
as long as we got the building, should be fine, i guess?
roomId*
I have the starting and ending coordinates easily.
now i need to find the adjacents of starting
until I find ending coordinates
I was thinking going left, left, left
 
there shouldn't be an overlapping node :P
you don't have to worry about that
 
10:11 AM
there could be
 
how?
 
u see the
 
two points with the same coordinates should be considered the same
 
blackdot next to the red dot in the middle of workspace and meetnig room
 
nodes can be arbitrarily close, but that doesn't mean they're the same
 
10:12 AM
there could be a door there
to exit the building
 
well fine, so long as the door node is connected to the hallway node with the same coordinate
ultimately makes no difference
 
yeah, doesnt make a difference
 
adds a bit to the confusion though
 
office is closing down, let me pack up and run home before it gets dark and continue at home
 
\o
 
10:14 AM
i should be home in 10 minutes
will you be around?
ill attempt that and share progress if you're around
 
sure, I'll be here
Unless I'm eating
 
haha cool
you're so pro dude
 
192 messages ... ugh
 
Oh I know :)
 
gotcha let you manage him :P
I am Sam. You Frodo. IF you disappoint me, then I am just going back to the Shire
 
10:23 AM
hah
I imagine a Sam that wasn't so patient and understanding with Frodo
"I'm tired of your BS, Frodo! How hard could it be? Carry the freakin' ring!"
 
hey, google sheet scripts is syntactically similar to js .so i am posting my doubt here.
how to call a addon function from a google app script. i have a script which process a row, i need to check for all the rows in a given sheet that means i have to run this addon function for each row based on some condition. But the app script is showing reference error.
 
hey guys, can someone help me out with some jquery? at least i think it's jquery
 
yall ever had bullies in your life-time?
Now imagine your bully comes illegally onto your home property over 7 times in 1 night, and is now being chased by police
lol that happened this weekend
Its kindof creepy, but hilarious
anyways
is there a way to calculate the area left on a page with javascript?
I have a smooth transition site, and it looks beautiful, but it has scrollbars because I set the page content height to 100%, and its a bit aggrivating scrolling 2 pages in 1
I used iframes to simulate smooth transition, fade to white, load page, fade to transparent
so, can I subtract the topbar at the top of my page from pageheight, and somehow make it so it isnt scrolling? (Also I know I could use css to disable scrolling, but I cant re-enable it for child elements inside the iframe, ruining the point)
Edit: I disabled the scrolling on that version of the page, so it doesnt do that
 
10:42 AM
@zadders jquery related questions are ok here
 
well if you guy's don't mind, then please check out this question I've just posted stackoverflow.com/questions/58484613/…
 
@zadders if the card is in a container, just re-fetch its data and update the container
it is a classic javascript behavior people can implement
 
What do you mean? how could i go about doing this? sorry I'm quite new to javascript so a lot of techniques are still new to me
 
@TaylorS jesus that is not okay
I'd lock myself in at night if I thought that I were being stalked
If it's any consolation, when you're older, the worst thing people will do to you is simply talk bad about you behind your back
 
11:05 AM
Hey Neil.
I'm kind of stuck with iterating through the list.
 
for what purpose? For traversing the graph?
it is a recursive thing. you have one path [1, 2, 3] and node 3 has connecting nodes [2, 4, 5]
You need to remove [1, 2, 3] and add [1, 2, 3, 4] and [1, 2, 3, 5] to the list
 
*sings Dijkstra Short Path Algorithm *
 
you wouldn't add [1, 2, 3, 2] because 2 already exists in the list (and you'd be going backwards)
 
yes, i figured its recursive
 
11:08 AM
or another js implementation
 
Hi All
 
Need to brush up on recursion
 
im trying to update a single column value in mongodb..but im getting the below exception from my mongoose modell
No document found for query "{ _id: '5dad63aea93bedb4505f1f2c' }" on model "myModel"
 
then that model does not exist in the db
don't update something that does not exist
 
well it doesn't have to be recursive strictly speaking
but you need an array of arrays representing all your paths
if there is no more nodes a path can go to and it hasn't reached the final node, then you remove it
 
11:21 AM
you'll prolly laugh at my buggy recursion LOL
hell is it even recursion
the first time its run, the current point is starting point
 
that's technically recursion, but I don't think that does what you think it does
first: why the starting point? you don't need it
 
oh, then?
how would it figure out
 
you need to know: given current path A and end point B, am I there yet?
If not, push all adjacent nodes not yet added to path and recursive call
when you're there, return the current path, otherwise null
 
dont get it
lol
i kind of got it, let me try what i understood
 
let startingPath=[0];
let allPaths = recursiveFindPath(startingPath, endNode);
make recursiveFindPath return an array containing all paths leading to your end node
 
11:26 AM
by paths mean, nodes?
 
Hey, got a vue.js question for you guys, if you had multiple ratings you're pulling from an API in JSON format, how would calculate the average rating?
 
how do I populate an array
for the path
 
let newPath = [];
newPath.push(idNode);
 
Should this be
inside the recursion?
 
again, just be sure you're not adding any nodes already added to the path, because it would literally never end
 
11:29 AM
lol exactly
 
@HassanAlthaf yeah
each recursive call would be to take existing path, add all adjacent nodes, and call itself with the new node added
but do this only if the path being passed in doesn't have, as its last node, the node you're looking for
also it is possible you cannot find adjacent nodes which don't already exist in your path
 
        let newPath = [];

        if (start.connected.indexOf(end.id) !== -1) {
            newPath.push(start);

            return newPath;
        }

        // Otherwise run run other ercursive iterations for the connected.
 
so you should be prepared for that scenario
no, the path being passed to your recursive function is arbitrary long
 
What do you mean arbitrary long
oh wait, the path being passed is
basically the array?
 
your recursive function extends the existing path.
you shouldn't be doing [] inside your recursive function in other words
yeah, the array of node ids is a path
 
11:33 AM
so, my start here would be path[path.length - 1]
right?
 
in the first call to your recursive function, you'll add your starting node like [idStartingNode] and pass that
@HassanAlthaf that'll be the last thing added, sure
 
So basically,
I keep pushing until I find the last node?
and return the path when I find the last?
This loop is so confusing omg lol
 
you have an arbitrary path leading to a node, right?
You want to take that path, and create new paths for each new and different adjacent node
and continue the search recursively calling itself for each new path created
or possibly none
What should be returned is an array of paths that actually found the destination node
you take each one of these and you combine it into a single array holding all of them, and you return that (could be empty)
 
    recursiveIterationOfPoints: function(path, end) {
            let current = path[path.length - 1];

            if (current.connected.indexOf(end.id) !== -1) {
                path.add(current);

                return path;
            }

            // Otherwise run run other ercursive iterations for the connected.
            for (let i = 0; i < current.connected.length; i++) {
                path = this.recursiveIterationOfPoints(hallwayPoints[current.connected[i]])
            }
        },
 
but of course your exit condition is this.. the last item added to the path is the end node
 
11:39 AM
So, do I have the exit condition right?
 
and of course if you can't find new and different adjacent nodes, it will end that way too
 
don't put functions in objects ._.
 
current.id === end
that's your exit condition
in otherwords, the last node added was the destination!
 
yup.
so, when that reaches that, path.add(current); return path;
 
in that case, return an array holding that path
 
11:41 AM
so, my exit condition is sorted
 
the reason why it has to be an array is because higher up the chain, you may be receiving multiple paths which reached your destination
It still needs to be an array of paths
the path is an array, I know, but you'll have several of these by the end potentially
 
I see.
 
after you've found these paths, you'll want to calculate distance for each one
so ultimately you'll end up with one, but still
 
i made an infinite loop
lol
 
¯\_(ツ)_/¯
@HassanAlthaf you know why?
 
11:50 AM
no i dont lol
woops
 
because if you have path [1] and see it is connected to 2, right? so you have [1, 2] and then you call it again
Now you have [1, 2], and 2 is connected to 1.. so now you have [1, 2, 1]..
hopefully now you see how this could be a problem :P
 
woops lol
got it, ill try
 
what are you trying to do
 

« first day (3292 days earlier)      last day (1639 days later) »