« first day (3379 days earlier)      last day (1552 days later) » 
00:00 - 20:0020:00 - 00:00

12:10 AM
Edge 79 hit public stable release today
aka Edgium
 
12:51 AM
@JBis bummer
 
I wasted 10 min of my life on this website williamhoza.com/text/?t=Pointless
3
 
 
7 hours later…
8:14 AM
hmm been back from illness and had a moment of dis-belief when I noticed the starred messages
😟
 
8:25 AM
@KarelG ikr? :(
 
8:41 AM
@JBis Great, now I did on this: williamhoza.com/newton/…
 
I just noticed Madara's post. wtf
 
Shog9 and Madara's resignations hit harder than any of the previous ones
 
yeah
 
I guess the former probably wasn't a "resignation" but yeah
 
8:45 AM
Shog9's "resignation"
Yeah
 
Madara was the only mod I could honestly say I knew
 
@Neil oof
 
Ditto
I'm exhausted and pissed off and the whole thing is a major bummer
 
feels like a damn eulogy talking about this stuff
 
That it does
Anyway I'm going to bed, just wanted to pop in and say that this has really hit critical mass now
This is the tipping point
Congratulations SE, you played yourself
 
8:48 AM
@forresthopkinsa shog did not resign
tbh he's hard to replace, knowing what he has added to SE in the last years.
@geisterfurz007 newton's law of universal gravitation is one of the most influential laws in physics. Until Einstein came.
 
Good job Einstein... Taking all the fame from poor Newton
 
Although his law of conversation of energy is the most important one among all laws/theorems in physics IMO.
hmm I don't think it was from Newton :|
that german dude
*le google*
> In 1844, William Robert Grove postulated a relationship between mechanics, heat, light, electricity and magnetism by treating them all as manifestations of a single "force" (energy in modern terms). In 1846, Grove published his theories in his book The Correlation of Physical Forces.
> In 1847, drawing on the earlier work of Joule, Sadi Carnot and Émile Clapeyron, Hermann von Helmholtz arrived at conclusions similar to Grove's and published his theories in his book Über die Erhaltung der Kraft (On the Conservation of Force, 1847). The general modern acceptance of the principle stems from this publication. src
interesting
so the answer is a rather difficult name to remember: Hermann von Helmholtz
 
9:11 AM
@KarelG It's easier to try out Teams now tho!!!!
 
I think well-known scientists tend to get credit for things which they only delved with very little if at all
Euler is accredited to so many mathematical formulas that they literally began naming some of these formulas using the names of mathematicians who had nothing to do with it, just so that they wouldn't all be named "Euler's formula"
I'm sure he's also accredited for plenty that he didn't actually discover as well
 
9:32 AM
Hi
 
hello Ricardo
 
Hello :)
 
How can i convert string to object
please help
 
@Wietlol Dahek are you doing here?!
JSON.parse
 
'string' to ['object']
 
9:33 AM
[ is an array ]
 
@geisterfurz007 KarelG is heere, Neil is here, geisterfurz007 is here... this is the Java room, right?
 
Give us an example string and the object you want to have out of it. Otherwise this is going to be random guesses and mostly chaos :)
 
@Ricardo you need to add more information on that. What's the string?
 
@Wietlol right, yeah. The Script is only optional anyway. Java is basically the same as JavaScript
 
because i have this variable roles which is = ['foobar']
then i want to convert a string equal to roles data type
i tried typeof roles and the output is object
 
9:35 AM
this is the java room, sorry. You're in the wrong room (joking)
 
yeet
 
wait im sorry haha
i have this data
 
what is the "roles" data type?
 
1 message moved to Trash can
@Ricardo Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
 
@JBis Fucking hell, at least give them a chance to edit it
 
9:37 AM
data: {
      roles: ['bbh'],
      introduction: 'I am a BBH',
      avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
      name: 'BBH'
    }
i want to convert it to data.roles type
 
JSON.parse(`[${yourStringVariable}]`)
 
you want to see if a string is contained within data.roles?
 
i have another role which is a string
 
could you give us an example of the string?
 
Ricardo, you are trying to build that data object. And the roles field needs to contain an array, so you want to convert your string to an array to be able to put together a correct data object; is that correct?
 
9:39 AM
role = 'BBH'
wait
hahaha
its hard to explain
 
@Ricardo Then come back when you can properly explain your question.
 
const { data } = {
    code: 20000,
    data: {
      roles: ['bbh'],
      introduction: 'I am a BBH',
      avatar: 'https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif',
      name: 'BBH'
    }
  }
  const jwtToken = VueJwtDecode.decode(state.token)

  const { name, avatar, introduction } = data
  commit('SET_ROLES', roles)
  commit('SET_NAME', name)
  commit('SET_AVATAR', avatar)
  commit('SET_INTRODUCTION', introduction)
as you can see, the roles in SET ROLES is object
but i have to get the roles inside jwtToken which is jwtToken.roles and is equal to string
 
ok but the data object that you showed, roles is nothing more than an array of strings
 
i want to set that role I get inside the jwtToken in SET ROLE which need to be an object
 
ok, for each of these values, what should be the string version of it?
[]
['aaa']
['aaa','bbb']
 
9:44 AM
is it an array of string?
 
ye
 
because when i console log the typeof roles i get object
 
ye, but JS is silly
 
||mdn typeof
 
9:45 AM
LOL
 
It's JavaScript, almost everything is an object
 
> // use Array.isArray or Object.prototype.toString.call
// to differentiate regular objects from arrays
typeof [1, 2, 4] === 'object';
 
so how can i change the string into this ['role']
 
dont you want to change the array to a string?
instead of changing the string to an array?
 
no
const yourArray = [yourRole];
 
9:47 AM
Waiting for him to try comparisons on the arrays using ===
 
ive tried it already
wait ill see the logs
 
||> const role = 'role';
const roleArray = [role];
console.log(roleArray);
 
@geisterfurz007 undefined Logged: ["role"]
 
There is your array from your string
 
btw, did something special happen on 2020/01/05 08:23 ?
 
9:54 AM
no?
@Wietlol you have been googling that no? :P
 
as if he knew js
 
it appears that Wietbot lost connection to chat
@KarelG no, that is following the link geis posted
 
that isArray is doing Object.prototype.toString.call internally.
so that comment needs to be corrected. But I lost my MDN sign-up
 
@Wietlol Guessing you don't have any error handling or reconnection logic? :P
 
both
 
9:56 AM
SO probably did a deployment
 
I cant really see any activity in the transcript on that specific moment
 
your bot need to have a failure logging mechanism
 
Wietlol is a noob at coding, really :')
 
then you can simply read "time UTC: <x happened>"
@geisterfurz007 it's tough to write a solid service. That from my server farm is not perfect. And I've spent 5 weeks on it.
there is a cronjob at the 1st day of each month to show some statistics. I still have 4-6% of "unrecognized log" (= using default handler) entries.
at launch it was < 1% for a year :|
made me sad. Thought I had reached the perfection.
 
I have quite a lot logged
but the connection was properly closed, which means it is time for Wietbot to go to bed
but... I have no clue how that connection closing was initiated
 
10:13 AM
good old human error
 
@KarelG I dont think its difficult really
just this application is a bit different
since it must be running constantly
 
harr harr. you are probably just logging the error message / stacktrace
I interpret it and make it human readable :P
there is a mechanism to correct it (if log comes from configuration errors) automatically. A little AI fun I had
I hate people re-deploying some service without doing any validation/unit test check that is clearly part of the maven script. They just remove the flag.
 
A little fun "AI" had
 
they complain to me with "X is broken" afterwards.
 
it sounds like it should be policy then
 
10:27 AM
ah, I can force it to make the script only having r and x rights
but some have sudo access and can adjust it. I just don't care much.
 
Is there a way to disabled saved autofills? chrome
 
620
Q: Disabling Chrome Autofill

templaedhelI have been running into issues with the chrome autofill behavior on several forms. The fields in the form all have very common and accurate names, such as "email", "name", or "password", and they also have autocomplete="off" set. The autocomplete flag has successfully disabled the autocomple...

In short, no, not really, not without hacks
Why would you want to disable a useful feature?
 
Chrome ignores autocomplete TMK
 
It does, but that's not the issue
Have a well structured form with the correct autocomplete attributes, and you shouldn't have issues
 
@BenFortune sometimes clients are not easy to convince.
 
10:37 AM
it is beyond your control
 
@KarelG HAHA, like I said, clients are clients :D
 
So educate your clients
 
@BenFortune is that "suggestion" list not being displayed if the browser detects a combination of text and password input in a form?
 
@BenFortune thank you btw, if does not work, I have facts
 
Yeah, it can get annoying. If you don't properly autocomplete your form, then Google just assumes the input before your type="password" input is the username/email box
We had an issue a few years ago where autocomplete was using the house number as a quantity field, so people were accidentally ordering tens/hundreds of products when they in fact only wanted one
 
10:40 AM
lol
easy money
 
heh
 
11:02 AM
@BenFortune :D
 
@BenFortune "issue" :)
 
@Neil It is when it's a 10 grand order and you have to refund it, but still get charged the gateway fee for the payment 😃
 
ah well I can see that
At the bank I work for, I heard someone requested an invoice for a 9 digit figure. Turns out it was his phone number
 
lmao
 
we all got a good laugh from it
I don't think we would have even seen it, except that notifications are made for amounts above certain limits
 
11:10 AM
Hello guys! At DOMContentLoaded or load time I insert a canvas into my document and I need to know how much space it will occupy in order to correctly compute its contents. All of el.clientWidth, el.offsetWidth, getComputedStyle(el).width, el.getBoundingClientRect().width are 0 at this point in time. How do I wait until the browser has rendered the element so that I can retrieve correct values?
 
@purefanatic 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.
 
@purefanatic my intuition is that it gets queued to create the canvas for when your function ends
so it can't know its width or anything like that until after it's attempted to put it on the page
you should try calling setTimeout with timeout 0 which gets that information
the reason why that works is because the function "ends" letting the browser put it on the page
though I could be wrong about that
 
Yeah. There's also requestAnimationFrame(). Might this be better?
 
I honestly don't know what the difference is, other than the fact that it's meant for drawing frames
try with both
 
@purefanatic how did you add the canvas to the DOM?
 
11:14 AM
Yes I will try. Thanks a lot!
 
getComputedStyle should work
 
simply xyz.appendChild(document.createElement('canvas'))
 
well if you define its width and height, then you'll definitely know
does it have to be the default browser size for canvas?
 
Not sure what you're struggling with?
 
@KarelG well getComputedStyle definitely works later as do all other methods except maybe clientWidth when the element is not styled
 
11:16 AM
is xyz on the page?
 
you get an error if it isn't
 
do you?
 
@BenFortune yeah no, I can not use .width because it is not the amount of space the element occupies when it is styled!
 
"styled" as in ... ?
 
this should show 50, not 300
@purefanatic I think that's what you mean, correct me if I'm wrong
 
11:18 AM
@purefanatic clientWidth works too fyi
as does getComputedStyle
 
@Neil exactly, am too slow lol
 
and yes, clientWidth does seem to work
 
@Neil you cannot set canvas width via css
you have to do it in the html itself
 
@KarelG no of course you can
width attribute and css width are two disparate things!
same thing for img
 
11:23 AM
@KarelG it seems to work in the jsfiddles
 
@KarelG Sure you can
It'll stretch, but you can 😃
 
@Neil I am confused and need to test some more, in my project it shows zero :/
 
I meant ... that's style.width is not what Neil expected
canvas has its own width properties
setting the width via css only influences the display property, but not the canvas' intrinsic dimension itself
 
@KarelG Indeed. I want both to match, that's why I need to find out the correct "screen width" of the element (which depends on styling) in order to set the .width of the canvas to match.
 
unless I am old and my memory is fading
 
11:27 AM
ah, true
it's confusing that canvas would have a width property
 
how would you define the dimension in the x-axis then?
dimX ? 😛
but hey, you aren't the only one that struggle(s/d) with this
 
width of course.. that's what it should have been for every DOM element
everything else gets clientWidth, and then along comes canvas and they decide the property name should be "width"..
not confusing at all
 
portal :3
ANY CAKE IS A LIE!
 
Watch that video (with headphones on), it's so good!
 
12:40 PM
Hi @geisterfurz007 thank you so much. Sorry late reply
 
No worries! You're welcome :)
 
Have a nice day :)
 
@BenFortune I'll add in a couple seconds but in my defense cap did that exact same thing.
 
excuses
@Ricardo Thanks; you too!
 
Grrr, adding this is surprisingly a PIA
 
12:48 PM
@JBis I think that cap waits for 5 seconds
nah, it is hard to check. If you detect a comment that contains unformatted code, display that message and use timeout. Once ellapsed, re-evaluate the comment.
 
^ exactly except the messages don't update in memory so I need to do some other crap to make it work
 
1:05 PM
@Neil After a short break I immediately found my error. The canvas' parent was not appended to the document yet... Thank you guys for those suggestions and tests! :)
 
@purefanatic ah :)
 
1:16 PM
@geisterfurz007 nice tribute video for portal 2
 
@JBis no it didn't, it waits 10 seconds
 
Yeah, you are right. Will fix.
 
@JBis how do you get comments?
they all have the id. Just fetch the comment with the id?
then compare with what's present in the memory
if not different -> move
else check if still unformatted -> on true move / false = do nothing
 
I would have to look for a new endpoint for that. Instead, I can do similar to how cap did it. Store in an Id with a timeout in memory and remove if it's edited properly.
But yeah that's the basic idea.
 
1:33 PM
@JBis check the transcript
 
1:50 PM
it is just getting the transcript (eg https://chat.stackoverflow.com/transcript/message/<id> ) then parse it as DOM. After that.... querySelector('#message-<id> .content')?
 
no need to do html parsing if i dont have to
Ok its fixed
this.ListenerCheck(msg);
        if (msg.isMyEvent()) {
            return;
        }
        if (!this.validateMsg(msg)) {
            this.emit("invalid-message", msg);
            return;
        }
 
@JBis Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
@KarelG Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
1 message moved to Trash can
 
that's quick
 
2:05 PM
10 sec. How long would you prefer?
 
it was in less than 10 sec, no?
 
nope, i checked the timestamps. Maybe delayed on your side. But I agree 10 sec is a bit short.
 
mhm gotcha try again
 
@KarelG Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
 
now
 
2:08 PM
1 message moved to Trash can
 
ok
works fine 👍 good job
but not sure if someone manages to edit it within 10 seconds 😀
we will see if there are any complaints. Maybe you can add another sentence that auto-removal will occur in 10 seconds
 
sounds good. will add
 
2:29 PM
Is there a mod here?
Honest question: was this question really asking for opinions?
-1
Q: How to synchronize the model (json) and HTML in vanilla js for dynamic forms?

Zeta.InvestigatorI'm beginner in web design. I have created my UI in bootstrap 4 in my index.html. The app is a calculator of user points based on some parameters. The result section should be updated as soon as each input changes. There are ~60 input fields of different types. I've grouped them in like 10 gro...

 
@Zeta.Investigator Yes.
 
How can I reword it if I want plain-js solution?
 
Firstly, you should only have one question.
#3 is def opinion based.
 
Too broad, opinion based
 
You should make your question more general. Not specific for your issue.
 
2:38 PM
@Zeta.Investigator You haven't provided any JS
We aren't a code-writing service
 
@BenFortune yes i did
 
Funny, its both too broad and not general enough.
 
So split it up
Because that wasn't obvious at all
 
Ah, I used the native html/js code feature
It is splitted
 
Also theres too much there. IMO questions should be pretty short. Enough to explain the general issue.
If you need more of 'advise' you can ask in chat where a discussion is probably a better forum.
 
2:42 PM
I removed my other 2 questions
I didn't remove the additional info because I thought they would help in answering
 
you need to establish some convention
such as, say, have the name of the key correspond to an id on the page that you want to update
 
@Neil convention?
 
yeah
then for each key, you search for an element on the page with that key..
if you find it, then you set its value
 
Oh you are answering the question. I thought you were talking about how to reword it
Seriously SO was not like this few years ago...people are like on-alert to remove/close posts
@Neil Should I like append a counter to each dynamic form id?
And for 10 dynamic forms, I should have 10 counters?
 
if this is something you will update the server with, then the server needs to give them their ids
and then when you need to update them, the server says, "The one with id X should have this new value"
 
2:48 PM
And this is for updating UI based on model. How to handle all these listeners for each inputs?
 
give them classes as well, so you can select them all and apply listeners to them all at the same time
 
Do you suggest to break it and use a framework here since it would get complicated?
 
no, I think you're complicating things needlessly
this isn't that complicated
 
@Neil I want to consume these values on js side so no upload to server. I just want to upload the final json model to server for saving the data
 
ok, well there you go then
make the server save the json representation of the model
client-side, have way to parse the json representation and build the page
no ids
what's missing here is a way to serialize/deserialize a json
 
2:53 PM
Is this project similar to mine?
 
@Zeta.Investigator yes, looks like that could be very similar to what you're doing, except you need to persist to the server
 
3:23 PM
you know I'm pretty sure Cap did delete the messages immediately after the 'no-unformatted' message
I don't recall her giving users any time to edit
 
I recall there being a delay
it wasn't long, but I always assumed the delay was just the network delay or something
 
I think cap did the opposite, waited 10 seconds then sent the message, but I'm proposing the opposite of that
Give them a chance to edit it before cap aggressively removes it
 
that seems reasonable
though there's a chance that it does get edited and immediately sent to the bin
that would be a little disheartening
 
It should be checked again before doing that
 
it could be checked, and then edited that very same second
 
3:28 PM
Well then it's tough shit 😃
 
fair enough
 
your proposed idea, if I'm understanding:

user posts unformatted code

james responds with standard warning, including "If not fixed within 10 seconds, your message will be deleted."

wait ten seconds, re-check message, trash it if necessary
 
Pretty much. I think a longer timeout would be more convenient though? How many people are going to read the message and understand how to format it in 10 seconds?
Especially if English isn't their native language
 
at that point, 20 seconds would be more reasonable
 
^
 
3:42 PM
should be able to check /events?${roomId}=${messageId}
 
3:58 PM
@BenFortune Could you provide an example url?
 
@JBis It's a POST request, it's how I do my AJAX fallback for the websocket connection
 
Thanks. I'll take a look.
 
4:43 PM
hi there
  getMessage() {
    return this.socket
      .fromEvent('message').map(data => data.msg);
  }
error
ERROR in machine.component.ts(33,29): error TS2339: Property 'map' does not exist on type 'Observable<unknown>'.
    fromEvent<T>(eventName: string): Observable<T>;
ok forgot to import:
import { map } from 'rxjs/operators';
and use pipe(map( ))
 
5:05 PM
Rubber ducking ^
 
works wonders
 
@JBis ok, you are welcome.
 
 
2 hours later…
6:41 PM
can someone help me through email or something on a project? thought i had it sorted but haven't and feel like giving up. having to make a front end for a library server and my JS partially works with an API but i'm so lost with it
 
@Strict Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it. For posting large code blocks, use a paste site like like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
1 message moved to Trash can
 
function compareNumeric(a, b) {
if (a > b) return 1;
if (a == b) return 0;
if (a < b) return -1;
}

let arr = [ 1, 2, 15 ];

arr.sort(compareNumeric);

alert(arr); // 1, 2, 15

How does the array get sorted based on the return values? Let's say I have an array:
[2, -5, 3, -7, -8, 14]. If -1 is returned, does that mean that the smaller element switches places with the bigger one? If i compared -7 to the previous bigger element, it would switch places only once though. Or is the whole array traversed by the function so often till there is no return -1
Not quite sure how to format, I hit ctrl+K
 
7:27 PM
to format properly, text and code should be separate
 
Ok, I wrote out the output of each alert when the function is called:
https://i.imgur.com/coUjTbn.png

And I don't entirely understand it. It seems that only after the 5th call of the function, the first 4 items are sorted, because now 17 is compared to 2
 
it sounds like you're essentially asking how the sort function uses the compare function
links to an opernsource project that implements the method using the same process, you could dig through that
 
Stop staring messages please
:)
Thank you
And unstar those if you can please :)
Stupid SO mobile chat
 
wtb cancel multiple stars tool
 
7:49 PM
Why are we unstarring things?
 
user inexplicably starred the latest dozen messages
 
00:00 - 20:0020:00 - 00:00

« first day (3379 days earlier)      last day (1552 days later) »