« first day (2399 days earlier)      last day (2774 days later) » 

15:00
Guys, can someone please explain this code to me? Thanks
@iLiveInAPineappleUnderTheSea please look at the example that is given at the top ....
Why is it outputting inside CallingFunction
inside myCallback myText
@tholo Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
and how?
15:02
var accumulator = (function () {
    var c = 0;
    // see this return ?
    return function(a) {
        c = c += a;
        return c;
    }
}());
that return ensures that when accumulator() is called, it calls that function (function(a) { ... }
@iLiveInAPineappleUnderTheSea see if this helps that example: gist.github.com/luggage66/aff8f663747fab28ed2e5a43a22121ed
so accumulator(5) becomes function(5) { ... }
function myCallBack(text) {
console.log("inside myCallback " + text);
}
function callingFunction(initialText, callback) {
console.log("inside CallingFunction");
callback(initialText);
}
callingFunction("myText", myCallBack);
@CapricaSix Snipe!
@tholo i don't understand the question
both functions are writing to the console,
15:04
@tholo just follow the code execution?
Yes, I'm trying to figure out the callback
why does it output this:
inside CallingFunction
inside myCallback myText
follow the code execution please
start at the last statement
257
Q: How to explain callbacks in plain english? How are they different from calling one function from another function?

Yahoo-MeHow to explain callbacks in plain English? How are they different from calling one function from another function taking some context from the calling function? How can their power be explained to a novice programmer?

i assume you expected them to run in the opposite order?
15:05
Put numbers on each line in the order you think it'll execute and we'll correct you.
or what
do what luggage has suggested
Can't believe I linked that, it needs nuking
"Define a function named accumulator that takes one argument" i thought the function assigned to accumulator is supposed to take an argument
@Luggage . thank you luggage i got it
read what an iife is and does
you're not assigning the iife, you're assigning its return
15:06
Thanks guys, I need to understand the callback..
@iLiveInAPineappleUnderTheSea Yeah, that's misleading
Accumulator IS a function with one arg, because it ends up with the value returned form inside the "wrapper" function.
i still don't understand the question
and I don't understand the execution. :D
var foo = (function() { return 42; })(); // makes a function. calls it. gets the return value (42) and assigns that to foo.
foo = 42. Not a function.
15:08
foo();
bar();
with me, so far?
runs foo then bar
oops, i got my people mixed up
might make more sense if you remove the iife. function makeAccumulator() { var sum = 0; return function (num) { ... }}
var accumulator = makeAccumulator();
yada yada
15:09
^
@tholo your logging before calling the callback. so the log happens, then the callback is ran, and thus the callback log happens. i'm not sure what part of that you're stuck on
is this all supposed to be easy? i know im not very bright right now but
looping/recursive logic doesn't come easy to everyone
well, it depends of what/who teaches you the concepts
@iLiveInAPineappleUnderTheSea depends on what kind of proclivities your brain has
15:12
@KevinB, I'm working on understanding the callback. I don't understand what does this do: callback(initialText);
that tutorial isn't so explanative
some people innately understand logical ordering and stuff
others really struggle with it
@tholo it executes the function with name "callback" with argument "initialText"
sorry for poor formating.
@tholo callback is the parameter you accepted. When you called the function, you gave it a function as it's parameter, and then you called it later.
15:12
formatting*
I think that I'm not blind and it didn't fix my problem.Thank you for your time and your comment ;) — user7883113 1 min ago
this boy would go to places man
so callback would be taking another functions parameter?
function foo () { console.log('foo');}
function bar () { console.log('bar');}

foo(); // foo
bar(); // bar

function stuff (a, b) {a(); b();}
stuff(foo, bar); // foo bar
a and b in that example are the same as your callback parameter. you passed in a function, and then called it at some point in time.
@KarelG commented and cv'd
hi lovely javascripters
15:18
am I a bitch for recognising his issue but still cv'ing?
@KevinB, thanks mate. This is now clearer.
Hey guys, can anyone help with this?gulp
[11:38:15] Using gulpfile ~/Sites/clients/**/gulpfile.js
[11:38:15] Starting 'default'...
[11:38:15] Starting 'phpcs'...
[11:38:15] Finished 'default' after 14 ms

events.js:141
throw er; // Unhandled 'error' event
^
Error: Execution of Code Sniffer Failed
$("#register-form").validate({
     submitHandler: function (form) {
              //loading plis w8
             if ($("#register-form").valid()) {
                         doAjaxThing();
              }
              return false;
       }
})
I'm dying since weeks. why the "return false" thing is ignored?

the form reloads.
@KevinB, why is this part first executing the first argument and not the second as defined
callingFunction("myText", myCallBack);
@Suisse look up "preventDefault()"
15:21
@Suisse, e.preventDefault() will stop the form from refreshing
ok, I'll try it with the e.preventDefault() but I thought it also works like that
return false in jQuery events should call that
er.. nevermind. i'm not sure how this validate jquery thing you use works
just need to find a good dupe
@Suisse i believe that it's jQuery form validator. It calls submitHandler differently than what you think
15:21
@rlemon right?
aaand ah it is only in safari not working
validate plugin might not care tho
and in safari you dont have this F12 thing
@tholo the arguments don't dictate what order the logic in the function runs.
the logic in the function does that.
@KevinB, so the arguments orders doesn't count?
wlel, they do count
if they're in the wrong order, the function may not run.
due to syntax errors
or logic errors
15:22
@tholo does it play a role, if the e.preventDefault() is first called before the ajax call or later?
i think you targeted wrong person
I fail to understand then why doesn't it count here. Because of the asnyc nature of the call?
no, there's no async in your function
you used console.log twice.
the first one logged, then the second one logged.
they happen in the order they are executed
I don't feel myself today
alcohol helps sometimes
15:28
@SterlingArcher *cough*
!!> function foo() { console.log(this); return foo.bind(this+1); } foo.bind(0)()()()()()()()()()
@rlemon "function bound foo() {\n [native code]\n}" Logged: 0,1,2,3,4,5,6,7,8
( Í¡° ͜ʖ Í¡°)
I'm on an alcohol cleanse
ohm
15:29
at least for beer.. if I go drinking, it's liquor for me
haha
nice
@rlemon i'll be honest I had no idea you could (chain?) invocations
if you return a function why not?
question: for my personal project (an Asp.net CORE Rest api) I am securing with Basic Auth and I plan to have an https certificate, it is only for receiving generic data from the azure db. Any other security measures that I need to consider? (oh also Azure CORS domain entries are required)..
function foo() { return function bar() {}}
foo()() // calls bar
15:31
but you binded a function, you didn't return one
wait
..
lol
that counts nvm
What is with the sudden savage hate for these fidget spinner things?
@SterlingArcher Is there a good reason not to hate them?
@SterlingArcher because of those assholes who bring them to meetings at work.
My fidget cube helps me from scratching my nails
15:37
not uncommon to hate things that are successful when you aren't successful
ples no hate. Only love fello beings
@SterlingArcher fidget cubes and fidget spinners are different
and inevitably drop them on the ground a bunch of times and interrupt the meeting
ah
wee my "how fat am i" scale comes tomorrow
@SterlingArcher those and rubber erasers aren't nearly as annoying because they aren't just toys
15:38
so, just a normal scale?
Did you see the jacksfilms video on fidget spinners?
@Luggage nah, it's one of those ones that can measure body fat %
people playing with their rings, I knew a guy who had silly putty (that was gross af)
Something something electrical pulse through your body and the time it takes to return idk
it's based on resistance
muscles conduct well because they're full of water (I think?)
15:40
so, it's an e-meter?
Hii, can any one help me ?
@AkashBose Welcome to the JavaScript chat! Please review the room rules. Pleasedon't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
ugh, figures that my big task for this morning was finishing up certs and namecheap/comodo is all down
user7480455
Hey Kevin B! Hey I got an email from my programmers.. they understood and where thankful for that link for yesterday!
user7480455
15:44
take care!
@007 @KevinB will be invoicing your company shortly I imagine
I have a problem with long polling, as i am using long polling for my chat application, but if the users open multiple tabs then the my long polling request will send more than one request to server I think which is a bad idea. So my question is can i rely on local storage's storage event?
@AkashBose sessionStorage might be better, but yes
if your domain's sessionStorage has been updated in the last few seconds, use that rather than polling
looks like it
15:48
storage.set('cache', [Date.now(), data])
@ssube yes, now checked about session storage i think it is a good idea what are the events that will fire with sessionStorage ?
no events, you just have to poll sessionStorage before you poll the server
can't he listen to the storage event?
@ssube alright thank you, for quick help. :)
Images are working in Amazon Onebox? O__o
15:52
I suppose, if you want one tab to be notified when the other updates, then storage events would help.
Or were they never broken for anyone but me? :P
@ssube okay, will do my research more on that. Thank you. :)
16:06
Has anyone used Async.js?
I'm trying to run an async.auto block inside an async.auto but im getting a callback already called error
yeah, probably
sounds like a logic error
I assume so, but I can't tell where its originating from
I have my first async block, which inside uses an async block to call a function to generate a password hash
Which itself is an async function. However, I have a console log at the top of the password hash function that is never fired
code would do better than a walkthrough of the code with no code :p
Yeah ill pastebin it
can anyone suggest me how to call a function of another class from current class in es6
16:09
foo.bar()
i have a function in class "bar" called callme() and current class is "foo" so it will be like...
foo.bar().callme() ?
wow, passport hasn't been updated on npm in 2 years?
@KevinB here's the async block: pastebin.com/RzSxLG73
why would it need to? It's a finished software. No bugs.
and heres the password hash function: pastebin.com/VqEryjC0
16:13
luggage is it correct?
whats passport?
@bangBang no. you need to create an instance of a class before calling a method. Also, foo.bar() calls bar() on foo.
shoe me what you have.
its react
if these are react components, not plain classes, then the answer changes.
16:16
:(
how to call a function is the same, of course, but how to get a reference to another class (if it's a react component) is potentially different.
hmm i just ran again and the console log at the top of the hash function did fire
ill run one more time to confirm
new Notification()._addNotification()
something like above i tried
and notification is a react component? Then you never create instances yourself.
React has docs on how to get a handle to a component (hint: 'ref')
0
Q: how to do user already there update ? if not there create document in particular collection using node,express,mongodb?

its me var logs = [{ mobilenumber : '1', ref : 3, points : 1000, ctype : 'mycredit', entry : 'sdfsdf', entry : 0 },{ mobilenumber : '1', ref : 6, points : 2000, ctype : 'mycredit', entry : 'sdfsdf', entry : 0 },{ mobilenumber : '2', ref : 7, points : ...

help me out
16:19
ya Notification is a react component having function _add... where Notification component is called in another component
@KevinB it seems when i remove the .bind() from the function call in the async block, the console log inside the hash function is fired
but still nothing farther than that
makes sense
because bind just makes a function
that you then did nothing with
did you intend to call or apply?
@Luggage whats passport ples tell me
Hi yall
laggage thanks...it worked
16:22
I meant to call. I think removing bind should be ok, right?
@Luggage
thanks al lot
yeah, only reason to use call or apply would be to change context.
dunno if that's important to your case
Hmm, could this be it? The async block that contains the call to the function ends before the hash function itself finishes its async block
I put some extra console logs in the hash function to know what step it was at, and it seems to end up starting hashing after the block that called the function goes to its own callback
i haven't used Async.auto, but i would have expected that function to need a done callback.
passwordHash: function() {
without one... how is async.auto to know when it's done?
Oh damn, didnt catch that. Ill try re running
16:28
none of these changes though address done being called multiple times
i don't see anything that would cause that yet
Hmm yeah adding done didnt fix it
Does the stack trace tell you which done was called last?
!!afk 🌮
No, it just looks like this:
```
scifi_1 | create root user object
scifi_1 | Password hash async
scifi_1 | generating passwordHash
scifi_1 | Salting
scifi_1 | end passwordHash async
scifi_1 | hashing
scifi_1 | /usr/src/sci-fi/frame-server/node_modules/mongodb/lib/utils.js:123
scifi_1 | process.nextTick(function() { throw err; });
scifi_1 | ^
scifi_1 |
scifi_1 | Error: Callback was already called.
scifi_1 | at /usr/src/sci-fi/frame-server/node_modules/async/dist/async.js:840:32
scifi_1 | at insertOne (/usr/src/sci-fi/frame-server/server/models/admin-group.js:21:7)
bbl
16:35
Hmm? The admingroup code is farther up, but didnt seem to cause any issues
line 21 is when an admingroup is being created, there are two being made. Ill check if both were created successfully
var cleanData = new FormData();
cleanData.append("test", "test");
alert(cleanData.get("test"));
this doesnt work in safari :O
there is no .get() function in safari on formdata
hm how can I solve my problem?
I'm working with node.js (sails) - when you submit a multipart form with an image in it
the image has to be the last attribute in your json object
thats why I do this:
  var avatar = formData.get("avatar");
                    formData.delete("avatar");
                    formData.append("avatar", avatar) //append the damn logo to the last place
Yeah both admingroups are showing up in the database, im not sure why the admingroup would be the issue
but when there is no .get() function, how could I solve this for safari?
@KevinB. Huh. Well so the admingroup code in async basically looks like this:
AdminGroup.create(blablah, done);
AdminGroup.create(blablah2, done);
I commented out one of them, and then the code proceeded further than before
uhm
that would call done twice...
16:41
Yeah, but what I dont get is why the error takes so long in execution to show up. Plus the admingroups themselves get created successfully
async
hmm. So i guess the async nests werent the problem, it was just a logic error from even higher that was being missed
Hopefully easy question. Is there anything client side I need to add to the code to make a CORS preflight check work? I have a URL that testing in postman with 'OPTIONS' works just fine. But the browser always returns 0 for the 'OPTIONS' check, I did verify by tailing the NGINX logs that it is actually returning a 200
@JonHeckman Welcome to the JavaScript chat! Please review the room rules. Pleasedon't ask if you can ask or if anyone's around; just ask your question, and if anyone's free and interested they'll help.
@KevinB Thanks! The admingroup issue was indeed the problem I was looking for
17:06
Bit of a dead chat today
@Shrek any word?
@Shmiddty marmalade
that is a word, indeed
you know what's a funny word?
PickleWeasle!
I'm flabbergasted
17:10
@SterlingArcher cooperation is the best
> TypeError: Object.assing is not a function
well now..
mmm Someone here an idea what I am doing wrong ( Im just confused and I might have forgot something really stupid )
I am only able to 'watch' my SCSS changes for the 'main' root SRC/ folder.
styles: './src/css/*.scss', = what I have now and I made it already like: styles: './src/css/**/*.scss',
17:25
Did any of you guys receive the MoneyConf invite with tickets?
@RahulDesai sounds legit
Never received this kind of email earlier, do I smell spam?
life is a scam
the discount code in it does work on their site here: ti.to/websummit/2017-moneyconf/with/…
people say "life is a gift", but they're leaving out the 'r'. "Life is a grift"
my god my video player component is excessively complex
Believe me, I am playing around that for 4 days. I know what I am talking about ;) — Fis 24 secs ago
4 days, that's cute
@SterlingArcher lmao wtf is that
rarely see js raped that good
determining scope when eval'd lol
I'm actually curious tbh
17:56
I succesfully sneaked Haskell Curry in the philosophy exam
and got a really good grade for it
I'm proud
plz someone be proud for me
thanks dad

« first day (2399 days earlier)      last day (2774 days later) »