« first day (3335 days earlier)      last day (1604 days later) » 

11:00 AM
@KarelG You could store it in memory :P
 
Sure way to bring the server down.... :D
 
GC or a ramdisk could help with that
@JBis Why? ._.
 
Why what? #isConfused
Oh, the link.
 
11:16 AM
ohai ben
master kenobi, would you like to break a bot?
I heard you did quite a job on james
 
Hey I can break bots too!
in Shadow's Den on Meta Stack Exchange Chat, Mar 2 '18 at 21:21, by rene
@ShadowWizard you broke it ... :( ... I send you the bill
 
oh... nvm, it is already broken...
 
Broken bot is broken.
 
well... my bot is live in the sandbox, and I wanted someone to break the eval js feature of it
I tried together with some other plebs, but we couldnt do it
 
Is broken bot broken if it is broken?
 
11:20 AM
but it seems there is something wrong with the bot anyway, it is seeing double
 
eval("while (true) x++;");
 
maybe it is doing exactly what it is designed to do
 
@ShadowThePrincessWizard that would result in a timeout
but you are welcome to try
 
 
11:21 AM
Too many rooms anyway... also need to go eat lunch. :D
 
Enjoy the meal :)
 
Thanks! Didn't decide what to eat yet.
Suggestions?
 
Might end up with a pizza.
 
robots
 
11:22 AM
There was a bot on Den who served pizza.
 
@ShadowThePrincessWizard Bacon wrap with mayonnaise, tomato, and lettuce
 
@Neil not sure what is it... ? lol
 
you also have a proxy?
 
11:26 AM
never heard that expression? "wakey wakey eggs and bakey"?
 
And no, I don't eat lube. :P
@Neil not really...
not from the US
Or Europe.
 
pretty sure that was just the username
 
Such name won't hold on SO... someone will spot and flag. ;)
 
probably :)
 
Closest I can find...
 
11:36 AM
Nothing wrong with needing one's space
 
it could be MySpace as well
it was popular back then (~2000)
 
Then he should update his name to INeedFacebook
whatever happened to MySpace anyway?
did facebook just buy them up or something?
 
user10864482
good morning
 
hola, human
 
@Neil still online and is now property of a group. It got acquired by News Corporation (owned by Rupert Murdoch, that media magnate) and got sold again
*googles*
> On February 11, 2016, it was announced that MySpace and its parent company had been bought by Time Inc.[17] Time Inc. was in turn purchased by the Meredith Corporation on January 31, 2018. wiki
 
11:51 AM
@KarelG well what a great purchase that was
 
it is not the product it has been
 
they quietly buried it
 
yeah, the wiki article mentions that Murdoch said that it was a mistake
 
The guys who sold the company must have had some hella good salesman skills
"MySpace is on the up! The future is now! Buy now before it's too late! We'll even throw in a free car!"
 
12:22 PM
Hey, so I was working some more on my snake game, and I noticed that if you played for long enough, food started spawning IN the snake body... which shouldnt be possible, making the game IMPOSSIBLE to beat (Because in the very end of the game, your very limited on where you can go, and if the food is on your snake's body, it would be VERY difficult to win
I have this code so far for the snake's body and the food:
// create the snake

let snake = [];

snake[0] = {
 x: 9 * box,
 y: 10 * box
};

// create the food

let food = {
 x: Math.floor(Math.random() * 17 + 1) * box,
 y: Math.floor(Math.random() * 15 + 3) * box
};
So If I were to run through each snake cell every time a food was created, could I create some kind of engine thatd not spawn food on the snake's body
 
@TaylorS well that's why
 
however, I think thatd be quite performance heavy right?
 
you create food using an x and y that could be anywhere
 
like doing math random until it gets perfectly in a spot thats not on the snakes body
yeah thats what I doing
 
well towards the end, yeah, it would be performance heavy
 
12:25 PM
I have to make a.. well to-the-rules snake
 
if you had 1 legitimate spot it could be and 100 possible cells, then you'd statistically need to reroll 100 times
 
not have to, more like want to
yeah
thats VERY bad
 
yeah, it is
what you can do is this..
you know how long the snake is.. so you can calculate the number of free cells on your board
 
If I had created food on the same array as snake like in a sand-simulation game, its possible you could create a "Food never overwrites snake body" sort of engine
 
generate a random number from 0 to number of free cells on your board - 1
 
12:27 PM
and because its in the same array, itd never overwrite another value\
 
then map that random number to a coordinate
 
well my board is just a dimension
theres no array for the ground
So I cant do that
 
@TaylorS not sure what you mean by sand-simulation game
 
the snake is just an array
neil, like sand-spiel google it
or powder toy
they used a giant array of elements
detect for different elements in the array next to each other, and produce reactions
like tnt element touching fire element = explosion in sand game
 
hmm, ok, well you could still approach the problem in the same way
though it's just easier now because you have one dimension
if the random spot is beyond the start of your snake, then just add snake.length
 
12:30 PM
codepen.io/SkylerSpark/pen/oNgvLQO Well, basically, the ground is just 32x32 boxes (17 boxes by 15 boxes)
and it detects that location on the canvas, and calls the gameOver
so I guess you could make "coordinates" using the boxes
 
hmm, doesn't seem to work in chrome
 
Im in chrome :l
Everyone else says it isnt working, but its working fine on my computer and on my home computer
 
Just shows: GAME OVER!
Click to Restart!Food:
 
same
 
12:32 PM
did you die
should look like that
 
could be my proxy
 
unless you clicked the arrow keys, it shouldnt have killed you
 
won't let me load certain things
You just need to generate a number representative of all free positions
then have a means to map that number to its cell
then you can place food there
If you use literal coordinates, then you risk to hit the snake
 
so... Create an array that stores 0 for empty, 1 for food, and like 2 for snake, and subtract or add numbers based on the positions of food and snake
I guess?
and limit food spawning to anywhere in the array
I mean I guess I could rewrite the whole thing to be 1 single array
rather than seperated arrays
thatd be complicated ;-;
 
"GAME OVER! Click to restart"
Nothing happens if I click, white text on black background
 
12:36 PM
why is it broken for everyone else?!?!
 
again, I don't understand the game
 
it works perfectly on all my devices
 
but the principle is the same
 
RIP, this project may have to go into the bin, may have to start over lol
 
you know where the snake is, you know the board size, therefore you know the number of free cells
random number representing all free cells, then put your food there
 
12:37 PM
HOLY FUCK! Did you write that wool thing yourself?!
 
Im still trying to understand this system, and Im not fully "skilled" in writing a whole video game, it may be simple for me to understand, but the computer is going to be difficult
Heck noooooooooo, I just added extra effects
and the dat.gui controller
and the window
 
Damn that thing's cool!
 
the original was just a plain cloth with gravity controls on a blank page
check it out, dissimulate created the original
 
A little buggy if you just click and hold the mouse still :D
 
lol its old tbh
 
12:38 PM
also, I see you using magic numbers
 
I first started editing and playing around with that cloth like 3 years ago
 
don't
you should see 17 and 15 exactly once in your entire script
it should work if you decide to go from 17 to 19
 
also, neil, this snake game is half based off of gaming tutorials and drawing on canvas online
 
without changing another line in your code
 
so its kinda ducktape and staples :P
 
12:39 PM
@TaylorS how do you keep track of snake position?
 
@TaylorS fair enough, just saying for your sake
 
snake[0] = {
 x: 9 * box,
 y: 10 * box
};
 
@TaylorS Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
That produces the first head
and if the x and y collide with a food, it adds another x and y to the array
 
upon deciding where to place your food: loop through all cells, then check if that cell is not in use by the snake. If not, add to a new array
 
12:40 PM
and continues
 
then it is simply math.random [0 -> array.length - 1] as index of that array
then use that cell to place food
O2
 
this is the function
 
you can optimize further by traversing the platform and have an iterator of the snake array
 
// if the snake eats the food
 if (snakeX == food.x && snakeY == food.y) {
  score++;
  document.querySelector('#score').innerHTML = "Food: " + score;
  food = {
   x: Math.floor(Math.random() * 16 + 1) * box,
   y: Math.floor(Math.random() * 14 + 3) * box
  };
  // we don't remove the tail
 } else {
  // remove the tail
  snake.pop();
 }
it adds to the score and then adds a new x and y
 
ok, well you can see that this is just putting the food in a new random spot
that food could be over the snake.. could turn out to be the very same position it was potentially
 
12:43 PM
do food = calculateNewFoodPosition();
and there perform the task I just explained
 
alright
actually, Ill be right back, Im switching from homeroom to math :P
 
if you knew how many free spots there were, you could, say, roll a random number from 1 to number of free spots. If it is a 1, then you place the food there, if not you move onto the next, but for number of free spots - 1
when you get to the end, you're guaranteed that food will be placed
 
oh.. that makes sense.
Well, I originally thought: I could detect if a food chunk has the same location as any snake cell, and then if so, add 1 or subtract 1 from its x and y
basically... push it out of the way :3
that may be simpler to make, considering my skill level
well Ill try that "large array" method and see what I can come up with
Ive seen a lot of games based on arrays, so might as well try it
And Im also going to rework that gameOver method
make it inside the canvas, as I think its overlapping the canvas when its not supposed to
 
@TaylorS there are two problems with that logic
A) it wouldn't be random (but not that important) but more importantly B) it could be part of the snake
just like when you write a card game, there's only one correct approach to distributing cards, and that involves keeping track of which cards are in your deck
if you just random a card, then you risk to get repeats
and you can't just random cards until you get one that isn't already used either, because if one card remains left in the deck, you'll be there forever
 
right, so what should I do then? go with your original solution then?
 
12:54 PM
I would, sure
if you have three components on your board, you only need to keep track of two.. the third can be calculated
 
Ive scrapped the HTML out and only left the canvas, is this working: codepen.io/SkylerSpark/full/oNgvLQO
 
and you should keep track of the two which is most efficiently kept track of
@TaylorS yes, this works
well somewhat.. it works in that I can see it
 
I also fixed an issue with the food, as any food on the very left column was non-solid, for some reason I made the math random calculate only 1 behind the x and y (14 and 16 rather than 15 and 17)
explain? like you cant control the snake with the arrow keys?
Yup I screwed something up... the food is a solid object, and its not eaten
 
@TaylorS well it responded to arrow keys a couple times and then stopped
and yeah food is uneaten
 
Ya know what this thing is giving me so many problems, Im going to do some more research, and I think im gonna redo this project when I'm able to clearly state that I know enough to actually write a snake game
I dont think I approached this correctly
 
12:58 PM
you already know enough to rewrite it better
 
I guess I was also just trying to have fun, I dont normally write anything interesting
 
consider it a challenge
 
I guess so
 
1:24 PM
Ended up with a pizza! i.stack.imgur.com/83cDS.jpg
Planned to keep half for tomorrow but couldn't hold myself and ate it all. :/
@TaylorS don't give up, learning by trial and error is the best way, IMO.
If you touch it and feel it, you can understand it better. Just reading about JS won't make you really know it.
 
I tell the first part to my girlfriend as well
3
Just kidding, I don't have a girlfriend ._.
 
In my very early days I wrote Archery game, where you shoot an arrow on a moving target.... these days the code would probably seem awful, but hey.... it worked.
 
But I couldn't let that one get away.
 
lol
recalculating room mentality
@geisterfurz007Stopthischaos sorry to hear... when did you have one, if I may ask?
 
ummm... never ;-;
Out of curiosity: How old would you say, I am?
 
1:30 PM
oh... teenager?
 
If you had to ignore the girlfriend stuff :D
 
Well I thought a 13 y/o girl who came to other room is 30, so I'm truly horrible with that. LOL
 
Judging from your online persona alone, which I can see.... 20? @geist
 
1:31 PM
OH
Yay
happy dance
 
I met my first girlfriend when I was 21, so you're all good. :P
 
@ShadowThePrincessWizard wanna see something funny?
 
@Wietlol shoot
ducks
Stalking time! @geist you still keep those things? i.stack.imgur.com/lowkY.png ;)
 
1:37 PM
dafak
yes, I do
 
@ShadowThePrincessWizard slowly open the sandbox room
be prepared for the würst
 
It's not even been a year, there is no reason I wouldn't have them :)
 
ugh... link? I'm still n00b in SO chat. @Wie
 

Sandbox

Where you can play with regular chat features (except flagging...
 
1:37 PM
@ShadowThePrincessWizard room 1
 
@geisterfurz007Stopthischaos dunno.. with the recent crisis... and all.
 
Free shirt and stuff is free shirt and stuff.
In fact, the nalgene bottle (right one) serves me well as water bottle at work and the orange water cup thingy as water glass at home.
And the arcade mousepad is on my desk at home as well.
And one of the small brown notebook is here at work an serves me as.... notebook
 
@BenFortune I copied that line straight from the docs. What's the issue?
 
shit...
well I wasnt paying attention
I was on here talking not doing my mathwork. RIP
 
|| learn sandbox Please go and play in the Sandbox
 
1:46 PM
sandbox has been added
 
|| sandbox
 
Please go and play in the Sandbox
 
@geisterfurz007Stopthischaos nice... I keep money in the SO mug that I got.
 
@ShadowThePrincessWizard you're rich
at least moreso than I
 
@Neil nah it's just Shekels
Each Shekel is about $0.3
 
1:55 PM
1 min ago, by Neil
at least moreso than I
 
Donate it to TeamTrees :P
 
buy a pitcher of beer for you and your friends :)
 
HELP
we got a bot out of control in sandbox
 
!!pee
:(
I'm afraid sandbox is conquered.
R.I.P
 
2:21 PM
I have this project with a lot of complicated calculations going on. I've been able to do what the boss wants so far. My issue is with this latest thing they want done. I was able to implement it, but when I did the whole thing started running a LOT slower. I think I know why, but I don't know what to do about it.
The problem is that it's calculating the same sums over and over again.
 
sandbox salvaged
@Hypersapien ok, well you need to figure out what needs recalculating and what doesn't
and for the things which do need recalculating, figure out a way of doing so efficiently
like the new average is the (old average * number of items + new value)/(number of items + 1)
 
Hey guys
Does some of you play a bit with Vue ?
 
It's just doing sums. I know I could store the sums instead of calculating them again. The problem is that the numbers that it's summing might change and I'm not sure how to let it know when to use the stored value and when to recalculate.
@Baldráni I do.
 
2:36 PM
Nice, I'm trying to update a value when it is render.

Something which would be on v-for, if we enter v-if :value="value = value++"
Any idea how to do that ?
 
I'm not sure what you mean. Can you elaborate a bit what you're trying to do?
 
// index = 0
            <div v-for="(p, j) in row">
                <div v-if="p" :data-index="index++">Something</div>
                <div v-else class="g-item g-empty" />
            </div>
I want my index to be update at each display
And not be a reactive data
 
By index, you mean j?
 
@ShadowThePrincessWizard was this for me ?
No
Index is a value define as 0
A data if you prefiere
 
2:38 PM
Oh, sorry. I see
Why don't you just use j there?
 
@Baldráni yes. have v-if="check(p)" and in the check function you can probably increment the value of the variable.
 
@Hypersapien Because j is reseted from an other v-for
 
Why did a different v-for modifying the indexer of this v-for?
Or if j is the indexer of a v-for that's around this one, why are you using j here instead of a different variable name?
 
@ShadowThePrincessWizard noop, as expected, the data keeps being reactiv and all the data update at each iteration
 
@Baldráni use actual field, not the loop iterator
 
2:45 PM
Its the same as saying :data-idnex="index++"
What do you mean by actual field ?
@Hypersapien its not modifying but I cant really on it only because there is an other v-for sublevel
 
What are you using data-index for?
 
Why does this matters
^^
 
Because there might be easier ways to do what you're trying to do.
 
Its for displaying a grid of photos
 
Do the photos have some kind of unique id?
 
2:48 PM
@Baldráni part of the data object of the Vue.JS extend.
 
the problem with assigning an id client-side is that it's got no handle server-side, so if more data comes, you can't really match the two
it's fine if you don't update from the server, but otherwise, it's best to have some sort of id
 
Even if they had, I can't use it because the ids of the photos does not helps me on the display of my photoswip
 
You're trying to display photos, but what are you using the index for?
 
var MyComponent = Vue.extend({
    template: templates["template-name"],
    data: function () {
        return {
            x: 0,
            y: 1
        };
    }
    ...
That ^
 
I need the index to specify which photo to display
 
2:50 PM
So in theory, if you change x or y in a method, they should keep their changed value.
 
When the user clicks on one?
 
Humm
So extend keep the data from being reactiv 🤔?
And yeah on click @Hypersapien its for using a library called photoswip
 
You don't really need an index here. The list of photos is still connected to the objects in row. Just pass the photo URL to the method that's displaying them.
        <div v-for="(p, j) in row">
            <div v-if="p" v-on:click="display(p.url)">Something</div>
            <div v-else class="g-item g-empty" />
        </div>
or just display(p) if you need more info than just the URL
 
The thing is you need to pass an index to the photswip constructor
For multiple reason
 
2:58 PM
For exmple to navigate between them with arrow
 
I still think your best bet is to use the indexer that v-for is giving you. If j is being used somewhere else, use i or something.
 
Can't do that
I specifically need to increment on displauy only
 
You could add an incremental ID to the objects in row before they're passed to the v-for.
and bind that to data-index
 
I'm not sure that would works
I've tried
A few time
i is reactiv*
 
3:51 PM
@JBis Because it has an async API
 
4:07 PM
anyone here have experience with testcafe?
got an error im havingtrouble with
 
@BenFortune true. I must have copied over when I was trying to use worker threads where it didn't matter. I'll change.
 
4:23 PM
Anyone with experience in NestJS?
1
Q: NestJS nodejs load nested comments in one query with relations?

Ben BeriI have the following models: User, Customer, Comment User can comment on a Customer, user can reply to another user's comment, recursively unlimited. I have done this but it's limited to just one reply, and I want to get all replies NESTED: public async getCommentsForCustomerId(customerId: st...

 
4:51 PM
So I have this jquery function with way to many lines of code in it. To implement one of these solutions for stopping duplicate calls from pressing enter. stackoverflow.com/questions/2830542/…
The function itself does a handful of callbacks in Ajax. And Im not familiar with the code so want to change as little as possible. But have confirmed the bug Im tasked with is caused by spamming enter in the text field.
 
@BenjaminGruenbaum What about using Object.freeze to prevent changing certain things?
 
5:13 PM
how do you define a getter in a function object?
 
err
 
@Hypersapien how do you mean?
 
|| mdn getter
 
5:16 PM
@user400654 you ninja'd me
 
I mean a function that you instantiate with new
 
so a constructor?
 
right
 
|| mdn constructor
 
functions are objects... so...
 
yeah
 
you can also just do a simple function
||> function test(num){ this.y = num }; const x = new test(5); console.log(x.y);
 
@JBis undefined Logged: 5
 
5:33 PM
 this.parentElement.removeChild(this);
this is so dark..
Every time I see it, I imagine a Child forcing the Parent to Kill the Child that forced the parent to do so, only for another Child to be created later on
 
why not write it a different way
it's just so redundant
 
6:12 PM
just do this.remove()
 
6:53 PM
removeChild() might have some cleanup processes
 
7:04 PM
hi
 
@AMINEDAIEF Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
7:43 PM
are there katas for react?
or bootstrap?
(i just found q# katas by microsoft)
 
7:56 PM
like, a quantum computing language for react? or...
question isn't making sense
 
8:47 PM
man command has been added
|| man mdn
 
mdn: Searches for query on MDN Examples: || mdn array sort
 
|| man magic
 
magic: "User-taught Command: (∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。 ᵀᴴᴱ ᴳᴬᴹᴱ" Examples:
 
Oh! (okay, i made an infinitely stupid mistake here) — Zircoz 1 hour ago
 
lmao
 

« first day (3335 days earlier)      last day (1604 days later) »