« first day (2813 days earlier)      last day (2137 days later) » 

12:10 AM
@ShrekOverflow Dear God..........
 
 
1 hour later…
1:22 AM
Anyone therE?
 
@JBis 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.
 
Sure.
Anyone know why this won't parse:
The JSON data is random movie data.
 
because you're 2 strings deep you need to escape the `\`
so it should be \\"Horse Soldiers\\"
 
So then why if I make an XMLhttprequest it works?
 
because you're only one string deep then
you don't have the single quotes around it
 
1:28 AM
Ah...
So how would I go about fixing this?
I don't want to use an XML request
 
you just want to hardcode the data?
 
Well for purposes of this convo Yes
 
well the string you're trying to parse is wrong, because '"' === '\"'
so you need to escape it properly before pasting it into your code
where are you getting the string from?
 
an API
 
it looks like you're taking pre-parsed json and just putting quotes around it
or maybe JSON.stringifying and copying what the console outputs
 
1:33 AM
I am a bit confused
Are you saying there's no reason to JSON.parse?
 
you have a tricky problem happening
no, JSON.parse is fine, but you need to get your string in the right format
 
you have a tricky problem -- Yay so I'm not an idiot.
So how do I do that?
 
long story short... you probably want to do JSON.stringify(apiResult).replace('\\', '\\\\')
and put single quotes around whatever that spits out
 
Hmm.
I feel like that's making the browser do extra work
How does XMLhttp do it?
can we manually do that?
 
morn
 
1:40 AM
your problem isn't that XMLhttp is doing something magical, it's that the string you're pasting into your code isn't the same as the string you're getting from the API
 
Whats the difference?
 
the string from the API has the nested double quotes correctly escaped
in the process of taking that API result and hard coding it you're losing that
 
But all I am doing is retrieving data from the API and echoing it with PHP into the JSON function.
I am not altering it.
 
yeah, but you need to alter it
because javascript parses it before the JSON.parse gets to parse it
 
:(
 
1:44 AM
javascript needs to see '\\"' so that the JSON parser will see '\"'
 
So can you edit the Codeshare to make it work
 
at the moment javascript sees '\"' and turns that into '"', and then JSON.parse thinks you're prematurely terminating the string
 
(not asking you to just fix it I am just a bit confused exactly what you want me to do)
 
the string you've got is unfixable
 
What about the function you gave before?
JSON.stringify(apiResult).replace('\\', '\\\\')
 
1:45 AM
you need to escape it before you do whatever "php echo" thing you're doing
 
Do you know PHP?
 
nope
 
Lol
Ok I know a bit
 
if php has a string replace function then you need to do that
 
It does
 
1:46 AM
i thought you were doing all this in javascript
 
Its a longstory
PHP is echoing the raw data from the API request into JavaScript
Heres the function for PHP
 
okay so you're doing that kinda stuff
then don't even bother making it a JSON string
and parsing it
 
str_replace("replace this","with this", "from this text")
 
just put it in as an object
 
But I am having JavaScript handle the data
 
1:49 AM
instead of const x = JSON.parse('<whatever>') just do const x = <whatever>
 
Does parse it into an array then
x.Title is undefined
When it should be 12 Strong
 
did you leave the ' marks in or something?
 
Yes
 
yeah don't, remove them
 
Genuis
Thanks!
So simple.
Really appreciate it!
P.S. we are back to I am an idiot
bye JavaScript chat. I shall come again soon.
 
 
2 hours later…
3:27 AM
I asked theme designer to help but his solution was a dead end. Is there anyone who can help me. When i hover over Browser username autofill option ,mouseleave gets triggered and dropdown menu fades with the login form. Anyone has an idea ?
 
@user2102266 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.
 
video of the behavior is this. https://www.youtube.com/watch?v=PyNytNoYeq8&feature=youtu.be . Sadly when i hover over on a previously saved username, pointerout, mouse out, leave(target:window) all gets triggered so below code didnt work.
jQuery(document).delegate( '.sp-megamenu-parent > li', 'mouseenter',function(){
var t = jQuery ( this ).toggleClass('active');
t.children('.sp-dropdown').css('display','block');
}).delegate( '.sp-megamenu-parent >li', 'mouseleave',function(){
var t = jQuery ( this ).removeClass('active');
I learned that hover works with XY but browser autofill options act like they are out of the window so cordinates doesnt really work here :( i am losing too much time on front end again
 
4:19 AM
Quick question on Mongoose, I have created a schema similar to this pastebin.com/FJt7PtDu and is using express to make a post request. How do I push a field of type arrays to which each array has a subfield of array in them? I understand that there is the option of using the update operator, such as $push, but as the name tells it's an update operation, meaning that the data is already there, and we use the operator to update fields.
What confuses me is the possibility of using update operator on fresh post request. How would I proceed?
 
is theri a way to convert a form to json?
 
this is the wrong chat i believe
 
user379888
0
Q: Reddit access key authentication failure

Fahad UddinI can't seem to pass the Reddit access key authentication here. It asks username and password. I have tried giving it the following, My Reddit username along with the Reddit password. My Reddit username along with the client id as the password. My Reddit username along with the secret key of th...

 
user379888
Can someone help with the above question?
 
4:35 AM
The data doesn't come from a form. But converting it to json form, I think, i need to use body-parser?
Oh wait, I don't need to use the update operator. I've created the JSON object. And in the field, I can populate the array, and just post the entire object.
There's no need to iterate each and push it piece-by-piece. The field gets filled when the object is created, and that includes the array.
 
 
2 hours later…
6:33 AM
I want to call a function and not be bothered what happens there? Ho do I call a function and forget about it with other operations in the original function.
function random(arg)
{

//some operation - outbound calls etc.

};

exports.original_function = function(req, res)
{
// some operation 1 here
random(data);
//some operation 2 here
res.json({status : 200, message : ''});
};

If the random function here has some outbound calls, like, calling other server etc then in original_function some operation 2 will be started without waiting for completion of things in random function and response will be sent for the api call. I just want to know will it cause some memory issues like when the operation gets actually completed in random function. No de
 
javascript is single threaded per browser (except the background worker threads)
and works event driven
 
 
1 hour later…
7:45 AM
Good Morning all! Long time no see. :D
 
loved the discussion on Musk's twitter page about a mug with an unicorn that farts
 
 
1 hour later…
8:58 AM
vihart's tau video is kinda dark: youtube.com/watch?v=deg1wmYjwtk&ab_channel=Vihart
I really wanted to not have to think whether I should trust her or not :/
 
Expected that to be a Friday link.
 
9:36 AM
was just going through ::- flow.org/en/docs/usage
question about flow in react
 
@AlexanderSolonik Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
 
function foo(x: ?number): string {
  if (x) {
    return x;
  }
  return "default string";
}
apologies .. i used the wrong formating
foo(x: ?number): string

is the above JS syntax ? what is it a ternary operator ?
 
it's TS syntax
I think the ? means "optional"
 
TS ... typescript ?
 
yes
 
9:41 AM
Yeah I think so too
 
@AlexanderSolonik mhm AFAIK that means x is a number
ah it is a maybe type
so x is either a string, void or null. (?number means that null can be passed)
 
Thanks :)
@KarelG Oh , didt see that , TY !
its flow syntax , i realize now.
 
yeah it has its own syntax
played with it before. Seems so so
 
Asking here because you are creative (as seen in the various ways to get people to watch Friday): What would you write as a small training app in react-native?
 
9:56 AM
the least creative thing: todo apps
 
Yeah I wrote a checklist thingy for flight training already which accidentally became my playground so now I have a tab named BACON where I can see images taken with the camera from the statistics tab. This happens too quickly when I am starting with a new framework
 
or maybe a simple customer satisfaction survey app ::- github.com/gautamz07/cs-survey
 
Oh that sounds good! Thanks :)
 
no problem :)
 
 
2 hours later…
11:32 AM
Hey all, I have a question: Is there a tool that would let me calculate my project's dependency on a particular library? Say I am using rangyInputs across five JS files on my project. Is there a way to get a ratio, something like: number of library methods used in my code/total number of library methods available. (Of course, this would also have to count - say - the method Y, which is used by method X (which my code uses), even if my code doesn't use the method Y, because X depends on Y)
Any idea?
 
That sounds like tree shaking
I think webpack does that, but I know very little about it
 
Hey @KendallFrey! Actually, I am not trying to eliminate dead code per se (assuming that's what "tree shaking" is about). What I wish to achieve is that, for example, if the ratio comes out to be < 0.1, that means I would implement those library functions - which I actually need - on my own (after looking at their source code), instead of importing the whole library.
 
oh I just had grand ole day configuring webpack
 
Which would seem to be for the purpose of eliminating dead code, yes?
 
@KendallFrey ah, eliminating dead code from the library's code. Right, I agree.
that seems tough :/
I was hoping for an easier way
 
11:48 AM
if you already have webpack set up, it's actually fairly easy
 
I doubt you'll find one. There are many ways to measure "size" of a library, and they'll all give different ratios.
 
otherwise, I think chrome's dev tools have code coverage stuff, so you can check it while running some tests to see what's never being used
 
Actually, rangyInputs doesn't export its methods, does it?
It just adds its methods onto the jQuery object prototype
while this webpack thing seems to be only concerned about methods that are actually exported
if I am reading it correctly
Am I?
 
I probably wouldn't use webpack with jquery
and if you use jQuery, you probably have much bigger problems to worry about
 
Indeed
I am trying to eliminate jQuery
for which I first need to eliminate libraries that depend on jQuery
 
11:53 AM
btw, you're very likely using much less than 0.1 of jQ's functionality anyway, so by that logic, you should reimplement those parts
 
yep, I am more than willing to get rid of it
what do I do then, finally?
i can look into Code Coverage
didn't try that before
 
good start would be to see everywhere $ is used
or jQuery
 
@Neil well I would do it manually but it's too much manual work
 
just do a search in all js files
that should give you a quick estimate
 
and without knowing the ratio of used/total library methods beforehand, I don't even know if it would be worth it
 
11:56 AM
it's possible that say, jQuery gets assigned to another variable, but very unlikely
 
@Neil $ is used quite a bit in both vue and angular :/
 
you're using these!? @GaurangTandon
 
@GaurangTandon your best bet to get rid of jQuery is to refactor the whole thing
 
i wouldn't even attempt to separate angular and vue from jQuery
so the question then becomes removing not only jQuery but also angular
 
no, I am not using Angular and Vue
 
11:58 AM
one of the strong points of vue is that it's a progressive framework, so you can switch parts of jquery to vue completely
 
ah ok
 
so you might want to refactor to that
 
@towc hmm :(
 
well which libararies are you using which depend on jQuery?
most plugins use jQuery, but only for querying and such
 
just rangyInputs
 
12:00 PM
btw, having jQ as a dependency that your libraries use is not too big of a deal
as long as you're using a better abstraction
and even then, you might want to look for better libraries
 
i'm trying to stick to vanilla JS as far as possible
 
what are you building?
that's often a bad idea, when dealing with semi-complex states and interactions
 
a simple JS userscipt
I have no clue why I used jQuery to begin with
:/
 
You'd be surprised how many javascript programmers start off using jQuery heavily
they do a good job promoting their product
 
what is your end goal? seems like you're trying to preemptively optimize? If only one of your dependencies is using jquery, then try a comparable package that doesn't?
 
12:04 PM
@towc Code Coverage is not very good. It marks my function declarations that are attached to event handlers (paste/keydown/etc.) as unused code :(
 
well, they weren't used
paste and press keys and they will be used
 
@TravisWhite it's just not about rangyInputs, I'm trying to get rid of jQuery entirely. Given that it's just a userscript, I'm pretty sure myself I'm not using more than 20% of jQuery, but I just wished to verify this intuition getting a ratio of unused/total methods, before I start to refactor the code
 
you're going to want to refactor anyway
 
@towc oops. Still, a lot of work. I can't execute every single case for that
@towc indeed, I guess so
 
someone needs to write a middlewear library for jquery
 
12:09 PM
to compliment those hats and shoes
 
like for people who want to stop using jQuery can easily switch out with this library
i guess that's basically a jQuery library though
 
well, they just need to read dugger's site
jQuery is now bad because its paradigm is limited and abused
doing something in between paradigms is not a great way to start with a different paradigm
might be better to just jump into the new one
 
I wish there was a download section for jQuery where I could just tick which methods I need from it, and it would download only those methods (along with the built-in methods on which those methods depend)
I guess the same could apply to lodash (not using it yet, but in case I do), or any highly bloated library in general
 
@GaurangTandon size is not as important as you might think it is
jQ is not that big
and if you wanted to optimize heavily, you'd start by getting rid of jQ anyway
 
if you replace jquery's central query method, you've probably done 90% of the work
 
12:13 PM
yeah I don't understand why you are so adamant on removing jquery. Just stop using it in new code, if it isn't breaking anything or causing problems, then why spend time/effort removing it?
 
@TravisWhite hmmm
well, I guess you're right
I should be focusing on something else
if it ain't broke, don't fix it
thanks for the help everyone!
 
just don't add it in your new project without serious consideration
if you think you may add it later, write a simple facade library which does the things jQuery does which lets you replace usage everywhere without changing out your code
 
I have a question regarding the repository design pattern. Traditionally repository patterns are used to separate data access and domain logic. The usual way to do this is to have a Base interface and Base class with implementation of some common CRUD operations, and then have entities defined that use these methods for data extend the Base class with some specialized methods.
 
@Shasak 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.
 
My question is why have the base level implementation in the first place?
I feel that each entity should transparently define all allowed operations. Having a base level means that some operations are always allowed, which to me is not a good idea.
What if I want to enforce behavior like a Person cannot be searched for by their ID under the assumption that Ids should not be leaked to userland? if the base implementation has this method available then I cannot enforce this behavior. Am I wrong in thinking this way? I find this to be much simpler to implement and reason about as well. Please let me know your thoughts on this. Thanks.
@CapricaSix did that. Thanks.
 
12:41 PM
@Shasak If they're protected, then no
you'd use the base to not have to replicate the code
or you'd override the base methods and throw an exception or something, but that's not ideal of course
 
Of course code reuse is a pro. Now that I think of it I could use composition as well for doing that. Could you elaborate a little bit on the protected approach? how do you do protected methods in javascript?
One more thing. As a general approach would you not prefer to have reusable functions emerge out of specific use-cases rather than have them defined before hand and then overridden?
 
@Shasak Well you could create a mix-in (expose only the methods made public)
isn't there a way to protect methods in javascript classes?
I thought so
@Shasak If they're hidden, they're not really considered part of the class's "api"
so even if a given class doesn't use certain methods, it's not considered a violation of liskov's substitution principal
 
12:57 PM
I don't know of any way to hide methods on a Base class and make them available to some subclasses and not to others. That is if I understand you correctly. If you mean that the subclass should hide these methods then that would essentially be similar to overriding right?
And yes, Javascript classes don't have protected members.
 
yet
 
1:28 PM
@Shasak Well I suppose in the meantmie, I suppose you have a tradeoff to consider
You could override and make them throw errors or not add them to the base class
I would argue the first is better just because I detest duplicated code, but to each his own I suppose
 
Can someone explain some things to me? In order to use require I have to be using node.js, right?
Or is just have this and linking to it enough --> requirejs.org/docs/download.html#requirejs
 
@neil Thanks for your answers. Much appreciated. I conclude that code reuse is essentially the only reason for this. Which I can achieve through composition. As long as I am doing that it shouldn't be much of problem. I don't have to stick to precise descriptions of the pattern, and do what works better for the stack I am in. Thank you very much!
 
Can anyone help on this question? stackoverflow.com/questions/51095465/…
 
@vinay 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.
 
@vinay Are the cookies restored only after you refresh? Or are you not being able to reset them at all? If they are restoring only on refresh it could mean that the server is setting them in response. Also look into HTTP only and secured cookies if you are trying to send them back to the server.
 
1:44 PM
after i click on reset button checked states are clear but when i refresh page checked state come back. cookies not deleting.
 
@vinay That can only happen if the response is setting them. Check the network tab on chrome to see what cookies are set in the response.
 
@towc still useful for css animations...
for the rest? ofc
 
check, if the cookie is set by the server, is HTTP only you should see something like
Set-Cookie: ASP.NET_SessionId=ig2fac55; path=/; HttpOnly
 
2:15 PM
@KarelG it's limited for css animations too
more than the alternatives, anyway
 
user1596138
When you work remote but haven't had a stand-up for 3 days
 
user1596138
Feels weird
 
you mean you haven't left your chair in 3 days?
 
A stand-up meeting (or simply "stand-up") is a meeting in which attendees typically participate while standing. The discomfort of standing for long periods is intended to keep the meetings short. == Notable examples == By tradition, the Privy Council of the United Kingdom meets standing. == Software development == Some software development methodologies envision daily team-meetings to make commitments to team members. The daily commitments allow participants to know about potential challenges as well as to coordinate efforts to resolve difficult and/or time-consuming issues. The stand-...
 
just giggle
 
2:25 PM
just be funny
 
it's hard
 
@towc like?
 
web animation api
tweenmax
 
you do not need that for those simple features such as slides, rolling down submenu animations
I would extract that animation functions from jquery and use it as an api for simple stuff
 
Hi all
How can I make generic components in reactjs ?
 
2:36 PM
is that not a googleable question?
 
for small things, I add/remove classes in vanilla and do the rest with transitions in css
 
mhm it seems that americans works more than other people in the world: abcnews.go.com/US/story?id=93364
I work 43~45h per week o.O
 
That's it?
 
that is more than average belgian work hours :P
 
I actively try to work less than 40 hours a week
because fuck; people need time to unwind and enjoy life. Modern day work is such a drain on happiness
 
2:47 PM
my normal hours is 40h per week
 
user1596138
@towc It feels that way.
 
user1596138
I can never find my keys anymore because I don't leave the house for 2-3 days at a time
 
user1596138
Feels bizarre
 
after four weeks, I have a free day "recuperation"
 
user1596138
After today I am off work until Thursday tho
 
2:47 PM
ohhi
 
nice
 
so I have a holiday but is not a holiday. I have also 20 + 12 days holidays per year
 
I haven't taken a vacation in over a year
 
then official holidays
 
I'm planning to in August
 
2:47 PM
i'm off till monday
after today
 
maybe go to Alaska, or just up north here
head up to the boundary waters
with the dog
 
monday is my "recup" (= recovering your overdue work time)
 
user1596138
We get 2 floating holidays and 18 days PTO that expire in December... So I jus try to use them throughout the year and use whatever's left for December
 
@KarelG Can I do like this -> <Barchart batdata={this.props} statType='Batting'/> similarly <Barchart bowldata={this.props} statType='Bowling'/> and <Barchart fielddata={this.props} statType='Fielding'/> After that in my Barchart component which is generic can I do` if (this.props.statType === 'Batting')` -> render Barchart with batting data similarly else if (this.props.statType === 'Bowling') render Barchart with bowling data and same for fielding.
 
your PTO doesn't carry over?
 
2:48 PM
we get 2 weeks paid and a mandatory 1 week unpaid
 
user1596138
Btw what does everyone else get? I had this one company laugh me off saying I got 18 days PTO, they were offering me 5!
 
no carryover
 
user1596138
@ndugger No. If you wanted to sue for it technically it should tho
 
I got down to 5-6 hrs/day
 
yeah, that's shady
 
2:49 PM
it's getting rid of the headaches and emptiness inside
 
user1596138
Yea they have a separate rule book for California where they get way more vacation and carry over. But whatever
 
it can carry over if you get approval for it to, but you'd have to get approval every quarter of the following year till you use it
 
I think I get 15 days, which is bullshit, but I do get unlimited sick days, which is great since I often have painful stomach issues
 
user1596138
15 days sounds pretty decent
 
user1596138
Especially with sick days!
 
2:50 PM
in the US, maybe
 
user1596138
My 18 days includes sick days
 
user1596138
It's all one bucket of PTO
 
Ah, yeah, that's lousy
 
Hi all is my approach for creating generic react component correct -> chat.stackoverflow.com/transcript/message/43090088#43090088
 
user1596138
Well our mentality has always been how are you too sick to type from home?
 
user1596138
2:51 PM
Since we are so flexible with remote work. If you're not seriously sick you should just WFH
 
i am allowed to carry over my holidays. But that depends from company to company
my dad's one does not have that regulation
 
user1596138
We just added 4 weeks paternity leave @100% pay too. Hoping I don't need that
 
@Jhawins I can pretend to be your kid, and we can split 50/50
 
@stonerock I have seen your message but ... Idk why you pinged me. Did we spoke to each other before?
I am still rereading that post
 
user1596138
2:53 PM
@towc That would be a net loss for me...?
 
user1596138
I lose half my pay for 4 weeks and have to take care of you
 
damnit, you caught on
 
meh you can agree and ignore towc
 
@KarelG Ok if possible can you just tell me is my approach correct ?
 
user1596138
I still lose half my pay lol
 
2:55 PM
well if you ignore towc, then you do not have to care for him So you get his "money"
@stonerock how am I supposed to answer if I do not know the context?
seems react?
 
@KarelG I told you I am creating react generic component which is basically a barchart in my case
Yes it is react
I want to render barchart component with different data so I have added statType and passed it as props
Then I am just matching the props to know whether it is batting bowling or fielding
 
and why did you ping me? I only have basic knowledge of react and I still do not know the right answer. So why should i answer it?
your comment was out of the blue.
so ._. ?
(please note that I did not have problems with you pinging me. But I am just ... confused)
 
@KarelG I thought that you know reactjs pretty well as you told just google the question
Sorry I will not ping :)
 
that assumption is not correct. Sorry. But it could be a googleable question
 
Oh ok
 
3:00 PM
i litteraly googled "How can I make generic components in reactjs ?" and got two possibility nice answers :P
like this one
 
@KarelG I got on google but my question is different here
 
Would D3 be suitable to do an SVG-based UI in? I'm trying hard to not attempt it in WebGL, because of text inputs...
 
@KarelG I thought that you are react expert that's why I wanted to confirm whether my approach is correct
 
ah. My excuses to disappoint you.
 
No problem :)
Hi all, Can someone please tell me what will be series a multidimensional array or not in below code:
var times = function(n) {
  return Array.apply(null, new Array(n));
};

var data = times(52).map(Math.random).reduce(function(data, rnd, index) {
  data.labels.push(index + 1);
  data.series.forEach(function(series) {
    series.push(Math.random() * 100)
  });

  return data;
}, {
  labels: [],
  series: times(4).map(function() { return new Array() })
});

var options = {
  showLine: false,
  axisX: {
    labelInterpolationFnc: function(value, index) {
      return index % 13 === 0 ? 'W' + value : null;
 
3:06 PM
ok good morning all, I'm gonna interject with something unrelated
last night I spent HOURS trying to figure out why my vue app's styling was broken on one specific item
the icon inside a FAB wasn't centered
sounds like a simple problem, right? ugh
I literally replicated my project 1:1 in a codepen and it worked
finally I figured it out: I had imported the Material Icons stylesheet after Vuetify, and it was overriding it
 
user5891775
Poor dog
 
@ndugger what part of common html is too limited for this?
 
user1596138
Das what u get
 
user1596138
#hoonigan
 
I had a large crash when going inline skating in the past. My whole right arm around the elbow was burned
painful as fuck. He has more damage to his skin
 
user1596138
I have ridden home a fair few times with no pant leg on the right side from mybike crashes lol
 
user1596138
Nothing like that tho. I wear armor
 
3:38 PM
do you still drive with your motorcycle ?
 
I sold mine
 
user1596138
I sold both of mine
 
tag nsfl
 
user1596138
Getting ready to pick up another for the summer
 
3:39 PM
did the summer not start already? :P
 
user1596138
 
user1596138
It did but I moved 600 miles in May and am still catching up
 
user1596138
 
user1596138
"In the future, this is the only device that will matter."

Bender and his cofounder, former Instagram engineer Greg Hochmuth, are betting that television viewership is going to switch to mobile.
 
user1596138
The next failed startup
 
user1596138
Cause I and anyone else really want to watch TV and movies on our phones.... lmao that's a last resort
 

« first day (2813 days earlier)      last day (2137 days later) »