« first day (1564 days earlier)      last day (3400 days later) » 

10:02 AM
@SecondRikudo yes.
var Promise = require('bluebird');
Promise.promisifyAll(Suggester);

Promise.map(suggestions, (function(suggestion) {
    return Suggester.findOneAsync({"id": suggestion.suggester_id});
})
.then(completeSend);
ES5 is so verbose :S
 
@BenjaminGruenbaum How would you have written this differently in ES7?
 
@SecondRikudo also, Sails' ORM already returns bluebird promises so there's that.
import {all} from "bluebird"

all(suggestions.map(s => ({"id": s.suggester_id})).map(Suggester.findOne));
 
@BenjaminGruenbaum suggestions, s => (?
Ah
 
Basically, your promisifyAll and bluebird are redundant anyway since waterline (sails ORM) already returns bluebird promises.
Although that query is inherently broken - it's called the SELECT N+1 problem.
you're performing N selections with the ORM instead of one.
 
Oh yeah, he was better off using find and be done with it
 
10:08 AM
The correct way to write what OP is doing is:
Suggester.find({id: suggestions.map(x => x.suggester_id)}).then(completeSend);
This would not only be much faster, it's also shorter and cleaner.
 
@BenjaminGruenbaum Ended up writing another answer
 
1) Link
2) Please fix your other one as waterline already returns promises
kthx
 
0
A: Javascript forEach non blocking query

Second RikudoThe correct way of doing this would be Suggester.find({ id: suggestions.map(function(s) { return s.suggester_id; }) }) .then(completeSend); You call find once, and pass an array of IDs, once that's done, completeSend will be called with the array of results.

@BenjaminGruenbaum Done and done
 
+1
@SecondRikudo your original answer is not fixed :/
 
Have now
@BenjaminGruenbaum how would you rate Sails.js? Worth my time?
(did you try it?)
 
10:20 AM
@SecondRikudo 4 rank points. Overall not really.
 
should I have a changelog.md or history.md in my bower project
 
@SuperUberDuper If any, it should be auto generated from your commit history.
 
You should just use NPM instead of bower, usually.
 
@SuperUberDuper dont put it on bower, put it on npm
 
how can I do that?
but what if its only clinetside?
isnt that for bower?
 
10:23 AM
@SuperUberDuper bower is a smaller and less robust version of npm
npm works for both server and client, and is more widely known and installed
bower works just for client, and you have to install it (via npm, oh the irony) for it to work.
 
oh thanks
 
Guys working with JIRA/Stash, still looking for an answer on this
8
Q: Have JIRA send mails to watchers on commit from Stash on a ticket

Second RikudoOur workflow is as follows: Someone opens ticket in JIRA (ABC-123) Developer commits with commit message ("Do the thing, relates to ABC-123") Developer pushes to Stash server Commit will show on JIRA (and when viewed on Stash, ticket will linked to JIRA). Note: I'm not sure if the above workf...

(No idea how it got 8 9 votes :o)
 
@SecondRikudo Many people here might be curious about Jira... I know I am
Besides, I'm tired of downvoting low quality question so whenever I see a good quality one, I tend to upvote
 
@dystroy I have a feeling that I'd need to break my records for rep spent in one week to get an answer for that one
 
@SecondRikudo This might be the kind a question which would benefit from a bounty, yes
 
@BenjaminGruenbaum you bad boy
<Domenic> benjamingr: I'd appreciate if you stopped advertising Bluebird on
	  the io.js issue tracker.
5
 
@FlorianMargaine :D
Where's that?
 
10:41 AM
#promises
 
hahahahaha
 
When? I don't see it?
 
9:30 am
 
I didn't see that message :/?
 
you weren't there
<Domenic> benjamingr: I'd appreciate if you stopped advertising Bluebird on
	  the io.js issue tracker.  [09:30]
*** aslant (~aslant@5751a00f.skybroadband.com) has quit: Remote host closed
    the connection  [09:46]
*** aslant (~aslant@5751a00f.skybroadband.com) has joined channel #promises
								        [09:47]
*** aslant (~aslant@5751a00f.skybroadband.com) has quit: Remote host closed
    the connection  [10:16]
*** benjamingr (uid23465@gateway/web/irccloud.com/x-pqcwmqfzqorworja) has
    joined channel #promises  [10:27]
 
10:43 AM
Ah, I joined it in 11am
 
> Domenic: I'd appreciate if you didn't try to ping me while I'm not here
 
at 10:27am, actually.
 
@SecondRikudo where?
 
@BenjaminGruenbaum Is what you should reply.
 
I didn't even push bluebird
(In the io.js tracker)
Now that I think of it I probably should :D
 
10:44 AM
Does anyone know of any limitation to the amount of scripts that can be loaded in a single page application (performance implications).
 
Domenic is also involved in io.js ?
 
@dystroy Domenic is involved with everything :D
@Wawy there is no practical limit but you should try and minimize it
 
@BenjaminGruenbaum But the whole point of a single page app is that you don't do a full refresh. And even if I do get the script async if the user navigates through all the pages they will have all the script loaded.
 
!!tell Wavy google javascript bundling
 
@Wawy anything under let's say a megabyte is fine
but have less than that
 
10:51 AM
Try for much less if you intent to load it on a shitty mobile connection
 
but the bigger your app, the more js you will have, I can't control the limit. I can minify and concat to reduce the amount of lines but the interpreter will still load all the scripts in memory.
that's my concern, I'm not talking about payload.
It's not about how long will it take to load my page, it's how the browser handles that many scripts in memory.
 
The browser will be fine with a megabyte of JS, probably more but you really shouldn't get there.
 
but you can't unload scripts
how are you supposed to achieve that
 
a megabyte of javascript is a LOT
 
I'm building a big app :)
 
10:55 AM
Maybe you should be building several smaller apps
 
then it's not a single page app
 
no, but it could be several connected SPAs
 
but with full reload in between them it won't look great
 
user4202350
Was Facebook hacked today?
 
@Wawy only the first time.
 
10:57 AM
What do you mean?
 
$(document).on("click", ".button", function() { ... }
 
(+10k users)
 
^^^ why do I have to do this sometimes only?
 
@iroegbu you mean delegation ?
 
yes
 
10:59 AM
 
$('.button').on('click', function(){..})
 
you use delegations in 2 cases: when the element doesn't exist at the time you add your event handler, or in case of performance issues.
 
works sometimes though
oh! Thanks
 
and yes, I already had to refactor some code to use event delegation because IE8 chokes (i.e. "script takes too long to execute") when ~50 event handlers are added
 
Interesting. I always assumed binding to many elements on click should not be a big impact (when the function is the same)
 
11:03 AM
it was slightly slower, but at least it didn't crash the browser.
@dystroy I did too.... IE8 proved me wrong
1 message moved to Trash
 
user4202350
Exception up = new Exception("Something is really wrong.");
 
yes, the joke is old.
 
user4202350
can you cathc ecxeption in jabacsript?
 
The ruler of jabbascript.
 
Javascript have no exeptions
 
user4202350
11:13 AM
I puked when i saw that face
 
user4202350
awwwwww
 
user4202350
eweee
 
@Ifch0o1 You mean the default exception constructor is called Error ?
 
Is someone familiar with red-black trees?
 
user4202350
i once found it in jungle
 
11:15 AM
0
Q: Changements that have to be done in order to delete node of red-black tree

evindaAccording to my lecture notes: Let x be the child of the node that we delete. Let w be its sibling node and p the father of x. There are four cases: At the first case, w is red. We cahnge the color of w to black and of p to red and we make a left rotation around the father of x. Now we hav...

That is my question
 
Just saw a thing : you can throw null or undefined
This doesn't look really right...
And I'm sure my catching code isn't always testing for that
var a;
try {
  throw a;
} catch(e){
  console.log("error:",e.toString());
}
 
user4202350
<script>
try {
adddlert("Welcome guest!");
}
catch(err) {
document.getElementById("demo").innerHTML = err.message;
}
</script>
 
user4202350
HI Passionate
 
I have this issue here and one of the suggestion which is an answer is only returning null for body and statusCode
0
Q: How to do parallel async multiple requests at once with Promises in Node

Passionate DeveloperThe healthcheck array and loops through but I want to be able to run all of them in parallel instead as I don't want to run one after another. I basically want to store all endpoint calls status codes, body and time as array and return them as results regardless of there are errors or not in the...

I used .settle and it works fine except I cannot get time latency for each request
 
11:25 AM
is your getAsync function returning a promise ?
 
yes
multiple promises
I'm almost there...lol
.settle is great but I cannot get time to work properly. Method Esailija suggested works except body and status returns null all the time
 
@PassionateDeveloper why did you remove all of the code from the question?
 
Without seing getAsync it's hard to tell where the error is
Does it return a promise settled with and array of body and status ?
 
var getAsync = Promise.promisify(request.get);
@dystroy
 
guys
I need to claim one "insta noob lazy help token" naw
how do I multiform groups in bootstrap
 
like <form> [main stuff][item 1][item 2], with "add item" somewhere later
 
var getAsync = Promise.promisfy(request.get);
 
@SecondRikudo then why spread and not then ?
 
Oh wait, that links to the wrong profile :P
 
request = require('request');
 
11:34 AM
@dystroy I put the code back
 
@dystroy It's request
@SecondRikudo thank you
I wasn't expecting an answer from the founder of BlueBird btw
 
esailija used to hang out here
now he's too cool for us
 
need somebody to find a QA to close this one :
1
Q: Javascript: {}+'',!+[]+!+[]+!+[],etc

R3Z4 BHwhy when we insert these codes: alert(+!+[]); //1 alert(!+[]+!+[]); //2 alert(!+[]+!+[]+!+[]); //3 alert({}+''); //[object Object] alert(+[][+[]]); //NaN alert([][+[]]+[]); //undefined javascript responds to this? I will be grateful if you would explain. thanks...

 
@BenjaminGruenbaum roger
 
11:41 AM
Thanks
 
@BenjaminGruenbaum Didn't know @phenomnomnominal works for TR too
 
@dystroy what do u think?
 
@phenomnomnominal screenshots?
 
@PassionateDeveloper Already told you : why spread and not then ?
(but I'm a js noob so I might be missing something)
 
Hello All
 
11:49 AM
@dystroy I tried then and getting same results. I'll have to find another way......
@dystroy thanks for ur help. Hopefully solution is there!
 
I have a function call to "getData" which has jQuery Ajax call in it. The code after this function call is dependent on the data of Ajax call.. can I define a call back here?
 
yes
 
@SecondRikudo he doesn't
 
getData(){
jQuery.ajax({.....}):
}

var data = getData();
 
@techie_28 this you can't do
 
11:51 AM
@techie_28 Promises
function getData() {
    return jQuery.ajax({....});
}

var dataPromise = getData();
dataPromise.done(function (data) { /* data is available here */ });
 
promises or callbacks
 
@tereško Callbacks are also possible, but if you want to return the future value and use it elsewhere, promises are the way to go.
 
@FlorianMargaine ^
 
@SecondRikudo you mean dataPromise.promise().done(....)
?
getData(){
var retData = {};
jQuery.ajax({

success: function(resp){
......some code loop here..
---Insert values in retData here--
}
});
return retData;
}

var getAllData = getData();
console.log(getAllData);

this is working fine for me and I do get the response in getAllData console log
 
heh
 
12:04 PM
It should not have worked according to stackoverflow.com/questions/14220321/… ?
 
Dear fellows. Can any one of you will please help me with this?

If 30th January falls in 5th week, then how will the next entry be selected if there are only 3-4 weeks in February? Will the Monday of last week be selected in February? And how? Any ideas please.
 
Write a distributed map reduce function in Erlang
3
 
rlemon :(
 
Hi, I have a redis question, I need to add the {user_id, timestamp} for a particular profile when the user visits a profile, how do I do this, I was thinking a hmset, but then the key is constant, I was imagining if profile:id : { {user_id: 1, time: }, {user_id: 2, time: }}
 
user2620028
12:10 PM
javascript has too many libraries!!!!!!
 
user2620028
The only solution i can think of is seperate them into even more libraries :/ Does that fix the problem?
 
!!xkcd standards
@caaaaaaaaaaaaaaaap
 
user4202350
Guys where can we ask Random question about SO.??
 
user2620028
Google
 
Meta
 
user4202350
12:14 PM
This---?
 
:(
 
user4202350
 
@ShaU yes
 
Im getting an error "done" is not a function on
var allData = getData();
getData function doesnt have the ajax call only but other code also
Im using jQuery 1.10
 
then learn to use javascript
 
12:24 PM
sorry I think I got the error now
 
user4202350
0
Q: Which one you will Open first?

ShaU Which one is more interesting for you guys and why? Note: Its just a random question nothing related to SO.

 
@ShaU dude come on.
 
user4202350
I was told , we can ask random stuff
 
haha
which one do you @ShaU
 
user4202350
Ha ha ah
 
user4202350
12:30 PM
I will accept answer
 
user4202350
Let someone post ans
 
but which one do you open first?
 
@ShaU I can tell you what I'll close first
 
:D @KendallFrey
 
@ShaU Are you begging for downvotes or what ?
 
user4202350
12:33 PM
Wait i am counting the number of downvotes it can get
 
I'm surprised the question hasn't been deleted yet
 
You know you might be banned ? And that ban will be kept on all your relatives until the seventh generation.
 
@dystroy Let's hope it never gets to that (him reproducing, that is)
 
Some relatives already did and they might do it again...
 
Heyo Javascripters!
 
12:35 PM
Hello
 
user4202350
It was good question though...prrrr
 
It wasn't a good question at all.
 
It was a horrible question whose sole purpose was to annoy people and get downvotes
 
Good afternoon
Is there a way you can learn MVC in native-JS without any other framework? Or a guide how to start with that? I think that might improve lateron when using a framework how it works under the hood.
 
I would say that there is no way to learn anything about MVC, if you are using JS frameworks
 
12:51 PM
@tereško I respectfully disagree.
gtg meeting, ttyl
 
@SecondRikudo really, can you name a JS framework which has anything in common with MVC, except the names ?
ember, angular, backbone, node ?
 
@tereško TBF you can't really do MVC client-side
MVC with node is entirely possible, yes.
 
you can, in single-page-apps
 
@tereško If you really force it, yes.
 
Hmmm, but what is the step between a JS framework like angular and native JS?
 
12:54 PM
but, nevertheless, I don't know any framework which would teach you about MVC
JS frameworks teach you about JS frameworks
 
That is not really the question. I am not looking for a framework that teach me about JS.
I was thinking about getting an MVC structure right with only native javascript. But as you say it will probably be a single-page-app then...
 
@Duikboot JS MVC outside a SPA is possible with node
 
I think I remember this ShaU guy
as a help vampire
 
ok, never used nodejs before :)
 
also you're bad as an emergency help service
@Duikboot and you might not ever in your life, because io.js #hype
 
1:08 PM
Hahaha :D
All those anti-js-FrameWork- people :D
 
@Duikboot remove the X
as an afterthought, remove "FrameWork" too
 
Haha
 
And "js" too
 
.. Why does this room even exists. ;)
 
@Duikboot to serve as my personal trolling platform bows
 
1:11 PM
The web is dead... everyone should start writing on paper and using a mail-pigeon again.
 
user2620028
@bartek i was a c help vampire during my c programming course lol
 
user2620028
i am watching my girlfriend play the fantasia xbox one kinect video game and it is very funny.
 
1:33 PM
I'm unsure and I don't find it. Will '**' be the power operator in ES6 ?
 
Yeah
 
Someone mentioned it before here, that ** is Math.pow yeah.
 
2 ** 3 === 2^3
I found that yesterday
it's pretty neat
works in 6to5
 
user2620028
How is that a good thing
 
Is V8 smart enough to fix Math.pow(x,3) in x*x*x ?
 
user2620028
1:36 PM
Just improves readability in control structures?
 
@NickDugger hmpfj
why not allow creating custom operators then
>>= !
Promises would get so much more readable.
 
If you make up your own standard, then no, it makes it less readable...
 
@dystroy I'd guess yes
But maybe not because they're not the same in floats
 
In what case is the result different ?
 
floating point math is a disease, but I also understand what it is and why it exists... It's just so anti human.
#logic
 
1:51 PM
@NickDugger >>= is kinda established as a monadic bind though
 
Man, just checked salary rates for a FED in Houston, and I am getting underpaid by a good chunk...
 
If it's different instructions on a FPU, it can have different precision behaviours
 
@NickDugger documentation source ?
 
damn that was a long day
long ass day so to speak
 
Oh, I just see there's tail call optimization in ES6
 
1:55 PM
butt tail calls, eh
 
that's a nice feature ! Why do they implement it ? that's a nice feature ! Why do they implement it ? that's a nice feature ! Why do they implement it ? that's a nice feature ! Why do they implement it ? that's a nice feature ! Why do they implement it ? that's a nice feature ! Why do they implement it ? that's a nice feature ! Why do they implement it ?
 
> Considering the importance of exponentiation in mathematics, Math.pow should really be an infix operator such as ** rather than a function. (Fixed in ES6 with **)
though, on the second link, not sure what their source is -- but it does work in 6to5
 
@dystroy why is it a standard feature? shouldn't it be an implementation-dependent feature?
 
Because previous versions were preventing TCO with arguments.callee or so
 
@FlorianMargaine not really, because there are algorithms you can only make if you're sure they won't explode at runtime. You need a guarantee.
 
1:58 PM
yeah I guess js is special...
for languages where you can compile you basically choose your implementation, so you can rely on implementation-dependent stuff
 
1
Q: NodeJS 0.11 Flame Charts

Jiew MengI was trying to profile my NodeJS app using Node 0.11's flamechart, according to https://github.com/thlorenz/v8-perf/issues/4. With the provided code/options, node --prof --track_gc_object_stats --trace_gc_verbose --log_timer_events app.js I dont seem to be getting the expected results: ...

 
2:17 PM
@FlorianMargaine meh
I like how it's done in Haskell. You have to specify required language extensions at the top of the code file to use them. That way if you try to use a compiler that doesn't support them, you get a hard error.
 
@BartekBanachewicz you'd love lisp
:D
 
@FlorianMargaine I get that you write the language you use in Lisp (that's my understanding of Lisp)
but a) dynamic typing
b) )
 
@BartekBanachewicz not really...
it's just that code is data
@BartekBanachewicz you can make it static
 
@FlorianMargaine how's that different from what I said
 
@BartekBanachewicz (
@BartekBanachewicz you don't have to use the code as data
 
2:28 PM
@FlorianMargaine I am aware of Racket and friends more or less, so that's indeed not a blocker
 
it's just available there
@BartekBanachewicz sorry, I just mean common lisp
(brb smoke)
 
@FlorianMargaine gah it's bad for you
@FlorianMargaine have you perchance looked at my last haskell toy code I posted here? It used a monadic context to turn operations (code) into data. I wonder how that compares to Lisp's ideas.
 
Whoo, 6to5 supports es7 await functions
 
@BartekBanachewicz which part? I don't see what you're talking about...
my lack of haskell understanding might be related
 
@FlorianMargaine look at the priority function. It takes an operation, and instead of executing it, it adds it to the list, annotated with the priority value. Then, the list of the operations is looked at, sorted, and only then executed.
 
2:42 PM
hello
 
i like your dress...
 
How can I use string methods (string.Join specifically) in mongodb's shell? (I know it's not purely a js question, but I figured you may know)
@rlemon thanks
 
@BartekBanachewicz oh. You're basically doing something like this in js?
 
@FlorianMargaine yeah, more or less (my priorities can duplicate, but the idea is correct)
the code above (in the same gist) shows how it's actually useful.
And now that you spoke about Lisp it sprung to my mind
 
@BartekBanachewicz to give an example in js, with a macro system
// forced to do this:
priority("foo", function());

// with a macro system, I could do this:
defpriority foo () {}
and foo would only be evaluated when necessary
or not evaluated at all
just transformed in a string and added to fns, for example
 
2:48 PM
posted on January 27, 2015

var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); try { var pageTracker = _gat._getTracker("UA-3727700-1"); pageTracker._trackPageview(); } catch(err) {} In Seattle to record a certain audiobook...

 
I like that elevator game thanks.
 
@FlorianMargaine so you actually can transform ... lexemes? into strings. Or other things, I suppose. Sounds like a way to write a language in a language, but... does that really buy you that much?
 
see the example I gave you
 
I kinda don't get the idea frankly
what's foo? A value of priority?
 
another example
var actions = {};
function addAction(action, fn) {
    actions[action] = fn;
}

// without macro:
addAction('foo', function() {});

// with a macro, I could have this:
defaction foo () {
}
both codes would call addAction with the correct parameters in the end
it's just much clearer
 
2:55 PM
what kind of "macros" are you talking about? C-style pre-parse replacements?
or something more useful?
 
lisp macros
 
they would be unfortunately useful in JS, given how many concepts have been bolted into the lang at random
probably worth it just for event handling
course, just like operator overloading and communism, they would make a mess in real life
 
@ssube meh
@FlorianMargaine but... foo isn't checked by the language. I see how the syntax is nicer, sure, but... I am not sure if it's such a dealbreaker.
 

« first day (1564 days earlier)      last day (3400 days later) »