« first day (3385 days earlier)      last day (1546 days later) » 

1:55 AM
Moin guys, Is it possible to justify a flex container to the center only if it isn't overflowing?
 
@JBis User agent strings are from a time period when the server had to choose which HTML to serve to the client
 
OMG haha, that was a while ago
 
The server can still choose to serve specific content to specific UAs based on the User-Agent header
But yeah, it's basically useless now. In nearly all cases you would use client-side feature detection
 
2:14 AM
@JacobSchneider js?
thanks @user220944
 
 
2 hours later…
3:49 AM
I'm convinced Google is purposely breaking YouTube on non Chrome browsers.
 
 
2 hours later…
DON
5:31 AM
how to convert to json format
var obj = { name:john, place:lax };
var myJSON = JSON.stringify(obj);
console.log(obj);
 
 
2 hours later…
7:37 AM
@DON did you not answer your own question? JSON.stringify does convert an object to a json string. If you want to have the object from the given string, use JSON.parse
@JBis oh don't be surprised that they want people use chrome
 
Hi All
i have a query related to the error codes send in the response from a node api
router.post('/SampleEndpoint', function(req, res){
 // Here directly res.statusCode comes as 200,
  i tried to overwrite like below
  res.status(401).send("something went wrong");
 // i gets the exception as Cannot set headers after they are sent to the client
}
please ignore the error code or the error message, the purpose is to return correct error codes in response
right everytime i get the status code as 200, even if there is authentication error.
 
7:56 AM
@SamSam you are close
first, set the message via res.statusMessage then do res.status(401).end()
 
@KarelG, tried the above
still getting the below response
Status Code: 200 OK
 
are there other statements after those two ?
 
no, those are the final return statements
nothing executed after that,
also i get this error
res.statusMessage is not a function
 
res.statusMessage = 'you did sumethin wrong';
 
yes, i tried this as well
res.statusMessage ="my message";
		     	res.statusCode = 401;
				res.end()
 
8:15 AM
@JBis > I'm convinced Google breaks YT on non-chrome.

Yes, absolutely. I use MS Edge Chromium (literaly the latest chrome version) and it only got support from Google recently
@JBis regarding my flex question, no, preferably pure-css
 
8:34 AM
@SamSam hmm intriguing
 
8:56 AM
actually the problem was there was a code which adds the json
res.json({
// some response properties
})
i placed my code above this
@KarelG thanks for the link.
 
oooh you altered the headers already
THAT WAS NOT IN UR EXAMPLE!
:P
 
9:39 AM
Hi every one.. here I am stacked in another problem. here I'm sharing github link. please solve my problem. github.com/sanghamitra1994/pdf-creation-from-mysql-database.git
 
9:58 AM
@SanghamitraLahiri That's Java.
 
 
1 hour later…
11:01 AM
I came across this in JS, what is this? k = q >>> 1;
also what is 5 ^ 6? what does it do?
 
:P
 
and this 2<<3
 
all are bitwise operators
>>> is zero-fill bitwise
<< is left shift
you have to comprehend how numbers are represented on a hardware component. For example 2 is 10 and 3 is 11
that is referred as "binary representation" of a number
 
I haven't got a cs background, so what exactly do they do?
oh okay, so it takes the binary representation of 2 and moves some things around is it?
 
2 is in bit 0010 ok?
 
11:06 AM
okay
so what happens when you fo a left shift?
*do
 
2 << 1 can be seen as 0010 << 1 which means "left shift 0 to it 1 times"
 
try it
 
end result: 0100
which is 4
 
!!> 0b11 << 1
 
@BenFortune 6 Logged: ``
 
11:07 AM
if you do 2 << 3 then you have 0010 << 3, which is then 001 0000 (3 zeroes added)
 
okay. cool, thanks :)
 
which is 16
 
what is the use case? why do we do stuff like this?
 
it is usually used in C and on "low machine level". People is trying to be clever if they use this in javascript
 
The only time I've really seen bitwise ops in JS is emulation and cryptography
 
11:09 AM
Yeah, I was reading source code of some SHA512 library in JS
and didn't understand it.
 
fyi, you can convert x << y into ... x * (2 ** y) or x * math.pow(2, y)
ah cryptography libs are full of bitwise operators yes.
@illiteratewriter see that as 5 XOR 6
 
also, x and y has to be to base 2 right?
in the above equation
 
yes. Bitwise operators expects operands to have be in binary. But they are always have that representation. You don't see it when you type 5
all numbers are just bits. But try to write 60 * 60 (for time, 60 sec * 60 min = 1h) using binary strings :D
you can even use strings on it
||> '2' << 1
 
@KarelG 4 Logged: ``
 
Don't do that in C tho. The js engine is smart enough to convert it to a number first
 
11:16 AM
cool.
 
if the string is not a number, you get 0
 
 
1 hour later…
12:21 PM
is anyone here able to provide some input on:
https://stackoverflow.com/questions/59854761/express-implementing-mongodb-session-store
I am now getting somewhat desperate D:
 
anyone with experience in mongoose? i want to know something about the model method .findByIdAndUpdate because mongoose documentation is confusing, don't know if this question should be here
 
@JDCH Ask your question
@Wietlol Would you like me to add him to C#?
I'll ask em myself
 
Basically, i need to create a new model for my database and i want to know if the approach im thinking of is good. So, i have another model, let's call it "Anecdotes" which keeps some fields like "content", "author", "info" and the like
This is is kept in my mongodb atlas database and it's used to show my users those anecdotes on my frontend
what i want to add to this part of the frontend (the one that shows those anecdotes) is a list of comments that users can add to said anecdote, so, i want to make a model that has 2 fields, one that's an array of comments, let's call it "comments" and other called "anecdoteId" so that i can link this model to the anecdotes model when an user request an anecdote in the frontend
it should be looking like this on the frontend
 
12:39 PM
Can anyone help me out with this post : stackoverflow.com/q/59500955/5783700
 
i already made the schema for this model, what i want to know is that if it's possible to to make a single endpoint o my backend (made in nodejs with express) using .findByIdAndUpdate from mongoose
in a way that allows me to create a new "entry" on my database if none is found and if one is found, it just fetched the "comments" field of this model for me to concatenate it with the message my user sends
that way i don't have to make two different endpoint, one for .post request and other for .put requests
or if there's a different approach i could use, per example, here mongoosejs.com/docs/api.html#model_Model.update
 
bot show yourself!
 
says something about [options.upsert=false] «Boolean» if true, and no documents found, insert a new document
 
@Hans1984 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.
 
12:45 PM
which sounds like something i want to add to this method for me not to add a .post endpoint
 
 
1 hour later…
1:45 PM
@FlameStinger I'm confused at what you're trying to achieve. Can't you just store the result of session({...}) to a variable and pass that around?
 
2:34 PM
Hey guys, can someone help me out with a basic react / typescript question?
 
please just ask your question
 
I've basically made a CRUD API on asp.net MVC which works perfectly. And now I've decided to make the frontend on react typescript in which I've made successfully done.

My Get method retrieves all the objects and displays them on a table. but I've also put my PUT, POST and DELETE methods within the same class component.

Is there a way for me to call the PUT, POST and DELETE methods in a different module than the one of my component?

Because I have different components for the EditUserForms and NewUserForms, and I want the submit buttons for either of them to use a method that I've made
 
 
2 hours later…
4:27 PM
Has anyone here used 2D game libraries? Which do you suggest? I'm looking at phaser right now.
 
4:59 PM
@TaylorS weren't you doing some canvas games?
 
5:20 PM
Suppose there is an DOM object you have a reference to in a variable foo, i.e. foo = document.getElementById('foo') or foo = event.target
How can I get an absolute query selector to this object in the DOM?
For example: fooQuerySelector = getQuerySelector(foo)
> fooQuerySelector
fooQuerySelector = "html > body > div.wrap > div#outer-wrap > button.button#buy-button"
Much like how you can right click a node in DevTools and select Copy > CSS Selector
 
5:41 PM
@jdgregson why do you need?
 
I need a reliable way to identify what was clicked in a click event, where the click target might not have an id or class.
 
just testing what it is
 
@TarasKryvko 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.
 
For example, if a user clicks something, it will be reported like this: window.addEventListener('click', (event) => {
sendTelemetry(`[${getCssSelector(event.target)}] was clicked`, 'click');
});
Which should look like this in the logs: "[html > body > div.wrap > div#outer-wrap > button.button#buy-button] was clicked"
The correct answer is just to use Google Tag Manager, but I'll integrate that at a later time.
I could walk up the DOM and note each tag name, class, and ID along the way, but I was hoping it was already implemented in the browser.
 
 
1 hour later…
6:55 PM
@jdgregson why not just log the element it self?
 
I tried that initially, but if they clicked #outer-wrap I'd get the innerHTML of the entire page in the logs.
 
7:17 PM
 
@jdgregson huh? Don't do innerHTML
And what is sendTelemetry?
 
8:09 PM
> Uranus and Neptune are redundant and Neptune is better. Tough but fair.
 
clicks on developer tutorial on YouTube - youtuber opens IE - hits back button
 
...
who opens developer tutorials on youtube
 
I don't like dev stuff on youtube unless it's a conf talk or something, because I find that articles are normally a lot more concise and you can get through them at your own pace instead of waiting for the dude to open his IDE or whatever
but I expect that visual learners would get more from YT content than I would
 
8:25 PM
...
rly jbi
lol
 
Fair point, articles are usually better.
 
user8729657
Not going to lie, I was driving today and seen this female officer looking at me. She was cute but I don't know if she was checking me out or profiling me :/.
 
@OvieTrix You say some weird stuff
 
user8729657
LOL @JBis
 
aren't they both teh same thing
 
user8729657
8:35 PM
One leads to having coffee and the other one leads to getting a new bracelet.
 
why not both
anyway, "checking someone out" is indeed just its own flavor of "profiling"
 
user8729657
You're a freak lol
 
¯\_(ツ)_/¯
 
@JBis I implemented the DOM walking idea and it seems to address my need: jsfiddle.net/25bs9qr3
 
wow that is a nightmare
 
8:40 PM
@jdgregson but why?!
 
So I know what they clicked even if they clicked something without a class or ID.
 
Just log the element itself!
 
I don't think you're understanding the issue.
 
I'm not. If you are trying to log the element the user clicked to a actual log text file, then why? If you are just logging to console then just log the element.
 
I am "logging" by my making an AJAX request to a server, where the "log" becomes that server's access log.
 
8:48 PM
ew and security ew
 
If I just logged the target, it would be converted to a string: [object HTMLDivElement]
 
Ok lets start off with the ew
Why do you need to log to the server what the user is clicking?
 
I want analytics in the app and don't want to bother with Google Tag Manager at the moment.
@JBis What's the security issue you're seeing here?
GET /index.html?there+was+an+error
That's exactly as safe as any other web request.
 
If you don't sanitize you could have issues
 
The sanitation is done by Chrome and Apache automatically.
*the browser
 
8:51 PM
Chrome is the client. What sanitation is Apache doing?
What about rate limiting? I can create huge log files if I want.
 
Apache sanitizes requests automatically when writing them to the access log. This is the standard behavior. Every web site you go to logs the request in an access log.
"Lock your shit with too many requests" That's what logrotate is for, which again, the server generally handles automatically.
 
sure but it doesn't log user input like that
the bigger issue is why you are doing it
are you doing some kind of mouse tracking?
 
If you go to "https://facebook.com/index.php?whatever-i-wanna-write-in-your-log", Facebook will automatically log "GET /index.php?whatever-i-wanna-write-in-your-log"
 
Yes true. I'm not getting into my security concerns (which are debatable) until we figure out why you are doing this.
 
@JBis that's a common element of DOS attacks
even if you don't overload their CPU, you can take advantage of untrimmed logging and run their server out of disk space
 
8:58 PM
Yes.
 
Most modern server OSs I've used have logrotate implemented out of the box, meaning they can backup and trim the log when it passes certain size or time limits.
That's not to say it is impossible to crash a server by making too many requests which get logged. It does however mean that it isn't quite as trivial as you're implying.
Also
 
7 mins ago, by JBis
the bigger issue is why you are doing it
 
When a linux server runs out of disk space, it usually continues to stay up and operational. It just can't do anything new. It's kind of weird and hard to explain.
Okay, let's start from the beginning. I want to know if anybody is using the app. In the future I should implement Google Tag Manager which exists for this very purpose, but for right now, I am lazy.
So what can I do? The simplest solution would be to keep track of whatever anybody clicks on. So onclick -> tell a server what they clicked
 
"I want to know if anybody is using the app"
That can simply be done by checking if someone makes a request to your page so what else are you trying to figure out?
 
"I want to know if anybody is using the app" for the record, they are ;P
 
9:04 PM
And if you want a live thing, simply make it ping the server every 10 seconds or websockets.
 
@JBis I want to know what they're clicking on. This can tell me if the UI/UX isn't working like they expect. Or that there are always errors if they click button2 and then button1.
 
there it is!
You are going to hate my answer tho.
Use a library!
Or add id's to the buttons. You users aren't idiots (hopefully). They may click the wrong button, but it should at least be a button.
It doesn't have to be id="sdfsddfs" it could be a data-id
 
But. I already solved the issue, securely, without adding five dependencies for the users to download, all before you understood the issue.
 
So then why'd we spend 2 hours discussing it?
 
I was on lunch and somebody was wrong on the internet.
 
9:14 PM
lol alright
 
Is JSFiddle broken for everyone or just for me? I can't save, just getting CORS errors.
 
||choose down or up
 
down
 
9:35 PM
james has spoken
 
Thanks James!
||choose np or whatever
 
whatever
 
:(
 
user8729657
10:12 PM
How do I get this innerText?
 
user8729657
 <script>
    const suby = document.getElementById("subtotal").childNodes[16].childNodes[0];
    //Returns <h3 id="realPrice">300.00</h3>

    function getPrice() {
      console.log(suby);
    }

  </script>
 
..
 
document.getElementById("subtotal").childNodes[16].childNodes[0].innerText
 
user8729657
Nothing comes out lol
 
((document.getElementById("subtotal")).childNodes[16].childNodes[0]).innerText;
What about that?
or
(((document.getElementById("subtotal")).childNodes[16]).childNodes[0]).innerText;
 
10:18 PM
can you show how this is used?
i suspect it has less to do with actual code, and more to do with logic.
a complete example.
 
user8729657
This is the parent node
 
user8729657
<div id="finalPriceOuterDiv"><h3 id="realPrice">30.00</h3></div>
 
Try using children[16] instead of childNodes[16]
childNodes might be returning text nodes.
$0.children
HTMLCollection(3) [div.dim-label, input.dim-input.cantilever, div.dim-label]
$0.childNodes
NodeList(7) [text, div.dim-label, text, input.dim-input.cantilever, text, div.dim-label, text]
 
i mean
the h3 has an id
if we're gonna start changing that part of the code, that's where we should start
i don't think that part is relevant to the problem
 
user8729657
I guess it can't be done :(, I had to remove the parent node
 
10:30 PM
i'd guess the element referenced by suby is being replaced.
 
user8729657
and use an inline style to style the size of font
 
user8729657
But still cant do innerText to get the value :/ of that node
 
user8729657
<div style="color:white; display: inline-block; position:relative; left:5px;" id="subtotal">
  <div id="finalPriceOuterDiv" style="font-size: 50px;"><h3 id="realPrice">90.00</h3></div>
  <div id="removeMe">
    <div></div>
  </div>
  <div id="finalPriceOuterDiv" style="font-size: 50px;"><h3 id="realPrice">70.00</h3></div>
  <div id="removeMe">
    <div></div>
  </div>
  <div id="finalPriceOuterDiv" style="font-size: 50px;"><h3 id="realPrice">20.00</h3></div>
  <div id="removeMe">
    <div></div>
 
@AaronHall - thanks for your thoughtful answer. I would like to take you up on your offer to meet face-to-face at our NYC office. My team will reach out to you by email to arrange a meeting. I look forward to engaging in a deeper discussion with you. — Pchandrasekar ♦ 7 hours ago
good move
 
10:45 PM
works for me
 
@forresthopkinsa holy shit
 
eh
 
I'll be honest, maybe he isn't so bad after all.
Depends how that meeting goes.
 
i don't think he's bad, I just don't trust the other people who are carrying out everything. I don't know him well enough to decide either way, he simply hasn't been around long enough to really show what his vision is.
words are cheap
 
my first impressions have been bad tho
Most of his blog post sounded like an investment pitch. So I was skeptical.
 
user8729657
10:50 PM
Where's this discussion @forresthopkinsa?
 
you can click the link and it'll send you there
 
his background doesn't give me the impression that he's interested in the core QA product any further than it's usage in teams and promoting teams/jobs.
 
user8729657
oh thanks!
 
but he hasn't really taken any actions, so i'm willing to give the benefit of the doubt
 
@OvieTrix np
 
10:51 PM
aside from the past few days ofc
 
I get the feeling that he probably didn't know what he was getting into
When taking the job I mean
 
he's presenting a bunch of data, but... i don't trust this data. I feel it's being manipulated from the get go
for example, i've never been presented this magical survey popup
 
DRP
@KevinB github issue closed for bigRat() issue, removed weird character, hotlink now works
 
i mean hi
 
data only tells half of the story, and SE has developed tunnel vision on that half
 
DRP
10:52 PM
thanks for helping out
 
Nice
glad it worked out
and to my knowledge, the data is being presented, as is, likely by design. it's not segmenting the results and showing what parts of the community care about what
which allows you to say "this other stuff noone really cares about"
but... it's being presented to a group of people who, generally, care more about those smaller lines in the results rather than what makes up the majority of the responses.
 
Probably a long shot but I figured I'd ask anyway. Is anyone interested in a fun side project and want to create a pretty simple game with me in js? I expect it to only take a couple months to get to beta.
 
kinda reenforces the whole... "you're only 0.015% of the community" attack.
 
@KevinB Right
@JBis Sounds like fun but I've got so many things on my to-do list already hahaha
 
np :)
 
user8729657
11:07 PM
Oh, thanks @KevinB
 
user8729657
it went something like this,
 
user8729657
 <script>
    const suby = document.getElementById("subtotal");


    function getPrice() {

      console.log(suby.childNodes[16].innerText);

    }

  </script>
 
i had to use 14, because my html isn't an exact match of yours
but it worked just fine
tldr, you're probably just not selecting the right element.
 
user8729657
yea, probably :(
 
11:47 PM
ummm what about in typescript instead of js?
 
making a game in typescript instead of js.
 
do you know how to use the 'reply' function in this chat
 
@forresthopkinsa yes
 
are you talking about "making a game in typescript" in reference to what Jbis was talking about earlier?
 
11:50 PM
I sure am.
 
Alright, that was very unclear from what you said lol
 
haha sorry
 
||magic
 
(∩ ͡° ͜ʖ ͡°)⊃━☆゚. * ・ 。 ᵀᴴᴱ ᴳᴬᴹᴱ
 
My spider senses told me I was being mentioned so I came back and what do ya know? They were right!
@Unbreachable Good, idea. Maybe I will. Thanks!
 
11:55 PM
I personally like ts way better than js but it's whatever.
 

« first day (3385 days earlier)      last day (1546 days later) »