« first day (2775 days earlier)      last day (2174 days later) » 

12:40 AM
morn
 
x0a
how to get an empty gulp.src() that I can .pipe(myOwnPlugin) to append my own file to the empty stream
 
1:36 AM
I want to do something like nested looping here. I do it with promise map
Promise.all(venue.map(venue => {
      return Promise.all(concat_all.map(tgl => {
             pool.query("INSERT INTO peminjaman_venue VALUES
                     (?,?,?,?,?,?,?,?,?,?,?)", [id_event, venue,
                       nama_lengkap_peminjam, jabatan_nim_peminjam,
                       jumlah_personel, id_google_calendar, waktu_mulai_rutin,
                       waktu_selesai_rutin, tgl, tgl, fasilitas_lain],
                            function (err, rows, fields) {
                                if (err) throw err;
 
1:52 AM
What is the difference between document.addEventListener('keydown', function(e) {alert(e.keyCode)}); and window.onkeydown = function (e) {alert(e.keyCode)};. Both of them seems to do the same. Which one is better or more common?
 
first one is better because you can add multiple event listeners
second one only allows you to add one, and if you add a second one it will stop the first listener from firing
 
Thanks
 
another thing, ender look is that if you want to remove the listener later you need to keep a reference to the listener function and not put it as an inline function
 
@RyanAllen Ok. Thanks
 
2:21 AM
Got a math question
I'm simply trying to find the divisors of 20 but all of them being from 20 and up
not 1,2,4,5,10
 
@CarlEdwards You mean the integer multiples of 20?
 
yeah
apologies in advance
I suck at math
 
So, what seems to be the problem?
 
Man you had me looking up the definition of divisors because 1,2,4,5,10 ARE the divisors of 20 ><
so you want 20,40,60,80,100,etc?
the multiples of 20?
 
yeah
20,40,60,80,100,etc
 
2:24 AM
What part of that do you want help with?
 
I wanted to created a conditional in my for-loop using the modulo operator
 
wait what
what's an entirely different question
 
so: if (i % someInteger === 0)
 
yeah?
 
what additional information is needed?
 
2:26 AM
Did you have a question for us?
I'm not sure what you're having a problem with
 
i'd like additional information around what exactly you're trying to achieve...
because at the moment you're making less than zero sense
 
obviously if I do something like: if (i % 20 === 0) I'm gonna have the conditional do stop at 1,2,5, and 10
 
No you're not
 
I just want it where it's like
h.o.
 
no, you're thinking of 20%i
 
2:27 AM
complete for loop
 
That would be 20 % i, not i % 20
 
i%20 would give you what you want... but it's possible you can just make your for loop increment in 20s
 
well...I was hoping to delay a API requests
 
ok back wayyy up
 
and was counting how many requests are made in total
 
the max for calls per minute is 20
so for every 20 calls I just wanted to pause the loop
 
ahahah
 
"pausing the loop" isn't important here
 
No, that's the wrong approach
 
why?
 
2:30 AM
you've gone down this crazy path, and asked us a question at the end of the path
 
You only want to pause the loop if there have been 20 requests in the last minute
 
where really your problem happened way earlier
 
not every 20 requests
oh wait, you're making the requests, aren't you
 
yeah
I am
 
the simplest solution would be waiting 3 seconds before every request
 
2:31 AM
why that particular amount of time?
 
!!> 60 / 20
 
@KendallFrey 3
 
there are 60 seconds in a minute
 
gotcha
thanks and sorry for the confusion
 
how are you making the requests? do you use an async function with a for loop?
 
2:33 AM
yeah
 
are you using promises and .then chains?
 
yup
via fetch
in full I'm utilizing the iTunes Search API
gathered a list of 50K albums or so
and do a search for the album name, grab the best result
and do a second track based search using the album id
 
does the API not respond with rate limiting information? good APIs will tell you when you can make your next request
 
I can try and see but for the time being here is currently their policy: stackoverflow.com/a/41377650/3046413
 
oh yay, another -30%?
 
This is a wonderful day
A new security vulnerability has been discovered in PGP (and GPG) that affects a range of email clients and plugins. To protect yourself, EFF highly recommends that for now you uninstall or disable your PGP email plug-in. #efail 1/4 https://www.eff.org/deeplinks/2018/05/attention-pgp-users-new-vulnerabilities-require-you-take-action-now
<3 <3
 
ahahaha, ouch... isn't pgp that thing that people who were super anal about email security use?
and noone else uses?
 
i guess with the vulnerability they're only as insecure as non pgp users... so it's not that bad
 
3:04 AM
> A new security vulnerability has been discovered in PGP
That's so very not true.
 
@littlepootis oh okay cool, i'll inform the eff that they're wrong
phew, i'm sure there were a few people who got spooked by that article
 
Not sure if you're being sarcastic or not.
I can tell you don't use PGP for encrypting your email, but you don't need to be condescending to people who do.
 
there's a lot of things that i don't 'need' to do that i do anyway
 
@littlepootis :P
@littlepootis That is called Marketting, did you see the details yet ?
 
user9728810
3:28 AM
hello anyone did iife in module.exports?
 
@Melissa92 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.
 
@Melissa92 Here is a tip, always add "y u do dis" part to all the questions.
I am not even sure if you mean by
module.exports = (() => {})();
or
module.exports = (() => {
(() => {})();
});
 
user9728810
yeah why you do that?
 
user9728810
module.exports = (() => {})();
 
3:30 AM
That'll give the you result of the function you just executed
but you don't need to do that
 
user9728810
why you do that? i know the syntax, you can even do this
const module = require('module')()
 
module code is run when it loads
That is not an IIFE, that is a function that you are running after the module loaded
 
user9728810
if I return a class instance I have to call it, can't just require it, it won't exec
 
Again you are missing a why, well let me ask it differently
 
user9728810
why if I return a class instance I have to call it, can't just require it, it won't exec
 
user9728810
3:31 AM
lol
 
what are you trying to do ?
export a singleton?
class Foo {
};

module.exports = new Foo();
create a dynamic class ?
 
user9728810
dynamic class
 
Ok, why? do you have an example of consumer api ?
 
user9728810
I want to do const a = new Foo(config) in multiple files
 
user9728810
s3 api
 
3:32 AM
I do that too
I just do this in one s3 singleton file
 
user9728810
as you know you have to create instance of 3s, pass your config
 
user9728810
but usually your config is the same, like your bucket name, region
 
user9728810
i don't want to repeat that
 
user9728810
so my plan is to return an instance
 
import {S3} from 'aws-sdk';
import config from './config';

export default new S3(config);
@Melissa92 that is a singleton
 
user9728810
3:33 AM
ok I got it, I put the new S3 in the function body
 
user9728810
No what?
 
const S3 = require('aws-sdk').S3;
const config = require('./path/to/config');

module.exports = new S3(config);
 
user9728810
what's the different btw

module.exports = (() => new S3 )()
 
You need that not an IIFE
 
user9728810
3:35 AM
than module.exports = new S3(config);
 
Module code are an IIFE
 
user9728810
yeah I got you, I return the instance in the function body, that's the mistake.
 
you don't need a function
 
user9728810
you remind me I can export the instance right after the module.exports
 
user9728810
3:36 AM
yeah
 
user9728810
thanks mate
 
G'day mate
Other ROs can see and probably infer I am in a <censored for friendlyness brownies> great mood today
 
Why are you so happy?
 
I am in the US.
@Jhawins o/
 
4:03 AM
!!!
congrats!
permanently? h1b?
whereabouts?
 
4:14 AM
@david no just here for a week, but EVEN THAT HELPS!
Anybody going to identityverse ?
 
ahah, fair enough
 
\o morning
 
4:32 AM
AJAX has successfully ascended to jQuery levels
 
 
2 hours later…
6:11 AM
Hey
This is might sound like a redundant question
but can anyone point me to javascript learning resources
 
Hello guys, is it okay to create a condition where there is undefined value?
 
Most of the time when I search on such sources I end up reaching old blogs
 
Rob
@jsonGPPD What do you mean?
 
user2620028
6:36 AM
@ShrekOverflow hell yeah man
 
My problem is, I have an object that doesn't return null but it instead, it returns an "undefined" value. @Rob
 
Objects don't return values
 
it works whenever I use !== undefined but I don't know if it is okay
output or return
that's what I meant @littlepootis
 
Rob
@jsonGPPD !== undefined is perfectly fine. A bigger issue would be interchanging undefined and null in general
 
6:45 AM
@jsonGPPD sure, as long as you stick to undefineds and not null
oh yeah rob just said that
 
did rob just rob you?
@ShrekOverflow that reminds me that I have to send you my brownie baking pics
ping me back later today
 
Oh I understand @Rob and @KamilSolecki thank you so much for that idea. :)
By the way, I'm beginner using state management in my application. How are the benefits of using state management like Redux and Vuex?
 
First and foremost, separation of concerns
 
Morning all
 
While using state management, you are decoupling the state of your application from your components, making them more reusable, for example
 
7:02 AM
@Rob I would also recommend !== null
 
@dou2abou 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.
 
Oh, I see now I started to realize because I split the module into different pages that share a single javascript file which is my store.js. But when it comes to performance, does it make fast the application? @KamilSolecki
 
Rob
@dou2abou That'll give the wrong answer if the value is undefined, though.
 
@jsonGPPD not really
its an architectural thing mostly
but your app will become way more structured, for sure :D
 
True,
But sometimes you might have either or case, so in my opinion, I might have a very limited answer due to the fact that I don't know what exactly it is that you're talking about, but in my opinion `(var !== null || var !== undefined)` would be a pretty good scenario
 
7:05 AM
yeah @dou2abou that's what I tried before. when I view the value, it's undefined and not null even though I was expecting the null value.
 
There you go then.
Have you guys ever considered starting a slack channel?
 
I see and now I understand completely @KamilSolecki. Thanks for that info. Because before, I wrote js codes in a single file where the create, update and delete objects, actions etc. are mixing together.
I ended up writing like thousands of lines
just for a single module
Now I started to appreciate the benefit of using state management.
thank yo u@KamilSolecki for that info
 
gosh...
4
A: Difference between return ''; and return; in javascript

BlackBeardFirst function returns an empty string, second returns nothing ieundefined. You can try it like this: function function1() { return ''; } function function2() { return; } console.log(function1()) console.log(function2())

 
@jsonGPPD perf should not be your main concern. the app has to work flawlessly, that it is secure and that you have a manageable code (with other words, not having a spaghetti code)
 
@dou2abou maybe I should consider using if(!value) instead? right?
 
7:08 AM
Doesn't work that way
If anything
 
@DenysSéguret Damn that fly is realistic! Tried swipping it away.
 
Your ideal case would be if (value)
So if value already has something, it's going to execute whatever's in the code
That would work, but !value might not be that good a choice because it's not a boolean, so it won't return true or false
get my point?
 
Oh I get it @KarelG thanks for that additional info
I understand @dou2abou because I was writing single one conditioning ? :
 
What do you mean @jsonGPPD
 
you do not have to ping everyone at each reply :P
 
7:10 AM
the conditional operator
 
What about it?
 
@dou2abou you can hack around
 
this.value = this.oldvalue !== undefined ? this.oldvalue : {}; @dou2abou
would be great if I use if(this.oldvalue){ this.value = this.oldvalue; }?
 
@jsonGPPD Yessur
 
because the first line, looks only getting the undefined and not the null.
 
7:12 AM
I hope that you are not using "null" somewhere in the system
 
OH MY GOD
 
so, it looks like if(this.oldvalue) is great choice that one line conditional operator
 
someone sent in a lamp for a guarantee change. It was the freaking light tube that he put the other way around
uuugh
 
@jsonGPPD uhm, what if this.oldvalue is 0 :)
that is also a falsy value
same for empty strings ect
 
@KarelG is it possible even my object is always an array?
 
7:22 AM
then not anymore no
 
I just put the value of the result to be default {} again
 
@KamilSolecki that happens. I recall that kind of stupidy from my student job
133
Q: Why is Mother’s Maiden Name still used as a security question?

AlexeiFrom time to time, some web sites asks to enter a security question and an answer for it. The question list is standard and it usually includes "What is your mother's maiden name?". Most persons will use their mother's real maiden name so that they are sure they can remember what to provide when...

 
@All Hi
need one help
 
hello sam.
 
im looking for a regular expression which willl check for the string be it upper or lower case
For Example
i need to check a domain within i form field
like email = abc@bandy.com
i dont want the user to allow have any email with bandy domain
it could be
email = abc@bandy-auto.com
email = abc@bandy.com
email = abc@bandy.org
it should not allow any.
i have some expression which is doing the job for me
 
7:36 AM
you can use .indexOf('@bandy') === -1 :P
 
var myEmail= /\@(bandy)+/;
no but if the user put
email = abc@bandyRockz.com then it should allow
 
it is hard to differentiate between that and bandy-auto with regex
you said that the latter should not be allowed
you can try to exclude subdomains of bandy too
\@(.+\.)?(bandy)\W+
that would hit a match at abc@bandy-auto.com but not at abc@bandyRockz.com
 
i will check and come back
 
@KarelG ewww use includes
!!> 'abc@bandy.com'.includes('@bandy')
 
lol ibrahimovic crying as a little baby because someone stepped on his toes youtube.com/watch?v=d72Ru3y4YJA
then slapped other's head
<hastag> soccer players...
!!> 1+1
 
7:46 AM
@KarelG 2
 
why did it not respond to your js command?
 
!!why
oh, just completely ignores me
I'm in mindjail
I urbaned something and rlemon disagreed
 
she would say that you're in mind jail
anyways, fyi .includes uses what I used ...
 
yeah, I'm surprised too
@KarelG but it's much easier to read :3
 
true that.
should have used that.
 
7:49 AM
asker wanted something ignoring the case. This rules out includes
 
@DenysSéguret sure, we established that
 
@towc but if we use include it will check for @bandyRockz as well
in my case i want to allow @bandyRockz but not @bandy.com
 
I was just pointing out a code style "error", not a solution to your problem
 
^
was a reaction on my code example and he is correct
@SamSam did the regex work or do you have more requirements?
 
8:06 AM
o/
 
@KarelG thanks mate for the help
 
hi can you use npm install? I get 404 errors. Maybe the server @npm is broken?
specially package d3
 
8:35 AM
Hi. Can some one give an example of when I'd use Apply ? I've read up on the docs, but I still don't see when I'd use it. It appears when I do Math.max.apply(null, [1,2]); or Math.Max([1,2]); they are the same. As such, I feel I'm missing the point. Any pointers?.
 
> The fourth variant can be potentially exploited by script files running within a program – such as JavaScript on a webpage in a browser tab – to lift sensitive information out of other parts of the application – such as personal details from another tab.
welp
 
@MyDaftQuestions Math.max([1, 2]) doesn't do what you think it does
 
@MyDaftQuestions the best usage I see would be to concatenate 2 arrays into a single one.
 
Oh... @DenysSéguret. So Apply is more about splitting the array out into the individual 'items'?
 
@MadaraUchiha you asked what happened with Ayo - github.com/nodejs/node/pull/20876
 
8:40 AM
In fact apply is much less useful now that we have the ... construct
!!> Math.max(...[1, 2])
 
yes @DenysSéguret, I'm reading about ...and felt a little history lesson would be good
 
@DenysSéguret 2
 
Agreed
 
Was Ayo that SJW fork?
 
@DenysSéguret how often/rarely you use cast to bool operator? I've seen a lot of new devs using Boolean(value)
these days
 
8:43 AM
Why do you ask me ? In any case it's exactly never
If I really really need a boolean, I'd use !!
 
I prefer Boolean
Especially for things like ints.map(Boolean)
 
@MyDaftQuestions use spread
 
@DenysSéguret Math.max([1, 2]) doesn't do what you think it does THANK YOU. Just played with and things are now coming together :)
 
!!> Math.max(...[2,9,100,2,65,3,5,9,85,3])
 
@KarelG 100
 
8:46 AM
@BenjaminGruenbaum so they got back in?
 
They never left
 
well, now I'm confused
 
Thank you everyone. Very hepful, thanks for chatting to me
Bye
 
@DenysSéguret I was just curious, and I like how you used !! > in the above scenario. I'm much more 'old school' dev, and prefer !!, but I see a lot of my colleagues using Boolean(stuff) instead.
 
even better is someArray.filter(Boolean)
takes out all the falsey values
 
8:53 AM
I often use filter(Boolean) too (TBH mostly when needing a short snippet, not for production). But there the real goal isn't to get a boolean.
 
still ...
 
@mutantkeyboard In that case, the !!> is a command to our chat bot, which tells the bot to execute the following JavaScript.
It's got nothing to do with booleans.
 
there is no usecase for intArray.map(Boolean) ...
 
!!> console.log("I can run JavaScript!")
 
@Cerbrus "undefined" Logged: "I can run JavaScript!"
 
8:55 AM
is npm worling for you?
working
 
is "edit message" working for you?
 
no sorry is temporaly disabled
 
@Maciej21592 vergüenza!!
!!giphy shame
 
Hah
That's a shame :P
 
8:57 AM
@rlemon pls
 
@Neoares rlemon is afk: 💐
 
can somebody try out please?
 
what do you mean by "npm working"
you mean the repos?
 

« first day (2775 days earlier)      last day (2174 days later) »