« first day (1563 days earlier)      last day (3389 days later) » 

12:29 AM
@phenomnomnominal nerd. Still having trouble?
 
Sim
1:03 AM
who wants to help me?
 
yolo
 
Sim
@CSᵠ how u been?
 
ossm!
 
Sim
i know lol
 
omg, ofc!
 
1:32 AM
@SomeKittens Nah, I've got it I think, but seems kinda weird - I still have access to angular.mock.module and angular.mock.inject even without having done app.module('app', ['ngMock'])? Does that seem right?
 
right
 
when I do require mongoose and run node app.js I have the following error:
{ [Error: Cannot find module '../build/Release/bson'] code: 'MODULE_NOT_FOUND' }
js-bson: Failed to load c++ bson extension, using pure JS version
I am using the 3.8.0 version
help please
 
1:52 AM
@argentum47 maybe
43
Q: Failed to load c++ bson extension

ThejaA total node noob here. I've been trying to set up a sample node app but the following error keeps popping up every time I try to run: node app Failed to load c++ bson extension, using pure JS version events.js:72 throw er; // Unhandled 'error' event ^ Error: failed t...

 
@phenomnomnominal worldmapswithout.nz
 
2:04 AM
@SomeKittens that's great!
 
user4330208
To all my hommies and hoodrats out there. What it do.
 
user4330208
2:23 AM
Hey so can I just go ary.length = 5
 
user4330208
( lets say i don't like having 10000 keys in an array )
 
Yep, MDN even has such an example for truncating an array
(I didn't know Array.length was writable until this moment..)
 
Sure is
 
My instinct wants to ask about memory usage, freeing pointers and that sort of thing, but I'm guessing the answer would boil down to "It doesn't matter"
 
user3949359
Can anyone get me a link to a good function stack flow article?
 
2:32 AM
That's quite broad, functions do... a lot.
 
@darkyen00 Happy Republic Day!
 
@jdphenix Most implementations have a concept of a "sparse" array, so you can do ary.length = 1000000000 without your browser blowing up.
 
I just tried that, Firefox's (35.0, Win 8.1 x64) memory usage shot up 600 MB
 
56
A: Why is array.push sometimes faster than array[n] = value?

olliejAll sorts of factors come into play, most JS implementations use a flat array that converts to sparse storage if it becomes necessary later on. Basically the decision to become sparse is a heuristic based on what elements are being set, and how much space would be wasted in order to remain flat....

 
@jdphenix Modifying array.length is not the fastest way to truncate an array though. The fastest way to truncate an array is to use array.pop() within a loop until the array is of the desired size.
 
2:35 AM
@AaditMShah Uhh, I kind of doubt that.
 
while (array.length > desiredLength) array.pop();
 
Dude, you beat me to it by one second.
 
Hehe. :)
 
I created the jsPerf though. =P
5 days ago....
 
2:38 AM
Indeed you did.
Color me surprised on the results
 
Hmm, I'm surprised enough to be skeptical. I could see that being a little faster, maybe, but ~50 times faster?
 
user3949359
how do I make jquery .append() insert the element at the end of the selected one?
 
Really though I almost wonder if the test has a flaw of some kind, my benchmark shows 50x faster
 
That blows my mind. Anyone have insight as to why?
 
@nosille Function stack flow? Do you mean a stack overflow? Try (function foo() { return foo(); }()).
 
user4330208
2:41 AM
@jdphenix you're telling my my syntax above was correct?
 
Assuming ary is an Array yes
 
guys :\ who here is familiar with passport for Node.js?
 
@corvid just ask
 
The "profile" variable in my callback keeps coming back as an empty object and I am not sure why
 
@corvid You should probably ask a question on StackOverflow directly.
 
user4330208
2:45 AM
@jdphenix I was just guessing but you're telling me that ary.length = 5 does the same as ary.slice( 0, 5 );
 
user3949359
@AaditMShah I meant the execution flow and context
 
@nosille I'm going to need a little more information than that.
 
@AaditMShah Okay, yeah, no way that the popping method is 50 times faster than the len method. I just tested in my console and got the popping method as being some 30,000x slower. (For an array of ridiculous length, but still)
 
Talking about control flow using functions, boolean values can be written as functions:
function False(f, t) { return f; }
function True(f, t) { return t; }
@Retsam I would love to see the benchmark.
Is it a sparse array?
 
user3949359
$('.powerpress_player').on('click', function(){
$('.powerpress_player').after('<br>');
});
 
user3949359
2:50 AM
why is this code not working (ready handler is used)? jQuery is imported as well.
 
@AaditMShah Probably. Here's a JS fiddle with the code I used in it: jsfiddle.net/xa9z34xm
 
I just tried Retsam's code but modified it to populate the array, similar results
Output was 4338.928576739854
40.47937234514393
 
Yes, but you are only executing it once. Most JavaScript interpreters optimize functions that are called more than once. Trace trees. Try executing the same function multiple times and averaging the time.
 
user4330208
Its possible to create a JS app that looks for patterns in the lottery and predicts the outcome. TOO EASY
 
user4330208
k, im sleepy. bedtime.
 
3:01 AM
@AaditMShah fair enough, here you go jsfiddle.net/xa9z34xm/2
Array length of 1,000,000, invoking each 10,000 times
Output results are 344.2070495693479
7.199799615191296
 
@jdphenix You are only setting up the array once. You need to set it up for every iteration.
Use benchmark.js. It handles all these edge cases for you.
 
I sent it to the masses
2
A: Is Array.pop() in a loop really 50x faster than Array.length =

BergiJsPerf runs each test multiple times per setup. Which means that you only test against the 10000-elements array once, and in the subsequent (very many) runs only have 100 items left in the array. For that case, the condition of the while loop is super-fast: A single, probably cached, property ac...

 
:O
 
3:18 AM
@jdphenix Neat.
 
@jdphenix That makes much more sense.
 
I am having a hell of a time using this template that a friend of mine wanted me to check out. It uses require.js (I think) to load all of the assemblies and javascript, but I can't seem to get an assembly that I specify to load to save my life.
The rconfig.js file appears to specify all of the assemblies (angular, jquery, etc) that the app uses. I am adding angular-local-storage to it. Here is the rconfig.js as I have it right now: pastebin.com/ZZpxwCyf
I dont get any errors in my console window from require.js saying that it can't find the angular-local-storage.js file (would there even be an error in that instance?), but I do get an error from my app,js where it tries to pull in the angular-local-storage provider and can't find it.
The non-assembly javascript appears to be minified into the main.js file via grunt. I have gotten that working (again, no experience with this) is there a similar process that I need to run to get this working?
 
 
1 hour later…
user4330208
4:36 AM
I'm code vamping, but is there an easy way to split an array into even chunks?
 
user4330208
All vampires aren't bad.
 
@carb0nshel1 what happens if you have a prime length array?
 
user4330208
My array is going to be the same length always
 
user4330208
I just brushed up on .splice though
 
user4330208
I think ima be good.
 
user4330208
4:43 AM
@phenomnomnominal thanks for caring though.
 
user4330208
kind soul.
 
user4330208
why the kick lol
 
\o/ Finally figured the darn networking for a FPS out
 
@carb0nshel1 because you're painful.
 
user4330208
no pain no gain
 
4:53 AM
Stop saying dumb shit
 
user4330208
k. point taken.
 
 
5:09 AM
@darkyen00 to you too!
 
5:28 AM
@AwalGarg There isn't any justification.
It's just them being stupid.
@Zirak My brain's body was not ready!
@Zirak Nice, that looks interesting. There's too much reading to do!
@Zirak I haven't listened to any recently. The only podcast I've been listening to is Serial, but it's not programming related at all. Tell me what you end up finding, though?
@BenjaminGruenbaum What's that?
Hurray for a mountain of replies!
 
 
2 hours later…
7:50 AM
@jdphenix I fixed that, why default version was python3.4.x which was unable to build bjson and kerberos , so I went into the directories and did node-gyp rebuild --python python2.7,
the problem was Python executable "python" is v3.4.2, which is not supported by gyp
 
@SomeGuy machine learning.
 
Ah
 
@jdphenix that benchmark is beyond broken - hope you realize that
 
In that case, Andrew Ng's ML course just started. @Zirak, you want to join me? coursera.org/course/ml
 
Does this look broken? http://jsfiddle.net/Jonathan_Ironman/1fgr91LL/1/
It is broken in Chrome 41
 
0
Q: Timing of resolving of promises and handling browser events

MarcConsider the following code written in ES6: function waitForMessage() { return new Promise((resolve, reject) => { function handler(event) { resolve(event); window.removeEventListener('message', handler); }; window.addEventListener('message', ha...

I lit the @BenjaminGruenbaum signal!
 
@BenjaminGruenbaum Indeed, I have learned...
 
The approach is wrong in my eyes, but the question is interesting nonetheless.
 
@Jonathan firefox 35 looks fine, FWIW
 
8:24 AM
@SecondRikudo heh
 
@Second Rikudo: I agree on that a promise should eventually be resolved or rejected. Insofar, my above code is not complete - in a real piece of code, waitForMessage should have a way to reject the promise when listening for further incoming messages should stop. For otherwise, the main loop would run forever. — Marc 1 min ago
What's his point?...
 
[tag:some-people-don't-get-it] stackoverflow.com/questions/28146491/…
@SecondRikudo he wants to use es6 because cool, and he doesn't understand what promises are. Pretty common - not his fault.
Added an answer - his question actually makes sense and the answer is 'yes - it will always work'
 
In what context would it make sense ?
Especially as it would break as soon as the promise chain would be extended with asynchronous actions inserted before the call to loop...
 
8:40 AM
@dystroy it wouldn't - but it would work.
It's a lot less robust than just using the event emitter.
 
9:05 AM
0
Q: Broken Duplicate

Benjamin GruenbaumThis question "Namespaces are one honking great idea -- let's do more of those!"... Why? is closed as a duplicate of this question. This gives users a broken link when they click on the duplicate link. This is probably not intentional.

 
Anyone with Chrome 41 who can check?
 
9:25 AM
 
Ok, so should I report this as a bug?
 
@Jonathan please do
 
Too bad : If the accepted answer had been momentjs I would not have voted to delete. But right now I agree it could confuse beginners
 
(3).days().ago();
Lol that's horrible :D
 
9:38 AM
Ugh
 
@BenjaminGruenbaum source ?
 
@dystroy the DateJS thing in stackoverflow.com/questions/996995/…
It's on their homepage :D
 
This isn't much cleaner :
Date.today().add(3).days();
I hate it when library authors try to make their API look like magic. And unfortunately that's the case for so many node modules which do almost nothing but manage to hide it...
 
9:58 AM
@Jonathan Works fine on 40
 
10:09 AM
Anyone here working with JIRA/Stash?
stackoverflow.com/q/28148054/871050 <<< Would love some help here
 
LOL, I had seen your question before you posted it here...
(and no, I hadn't dived in our JIRA yet)
 
Morning!
Simple question: is it possible to sort an array with just one iteration...?
 
one iteration ? That sounds conceptually impossible for an arbitrary size array or I misunderstand your question.
 
That's an exercise from a teacher: sort an array of integers (positive, negative and zero) with one itearation... I guess it's not possible.
 
How does he define iteration ? Can you cheat by using recursion ?
 
10:14 AM
I interpreted it like a loop in array.
It's fine, just wanted to know if there is a known algorithm that does this.
Thanks!
+30 from me :p
 
Hey, you mean you randomly upvoted 3 of my answers ? you shouldn't do that. Not only is it about forbidden (and clearly not good for SO) but I don't think I really helped you there
Please remove your upvotes.
 
That's how I say thanks when somebody helps me on chat. :p
Anyway they area already frozen. :D
 
@dystroy I keep on losing travelers or crashing them into planets, >.<
 
@jdphenix What level are you playing ?
 
3
 
10:29 AM
@IonicăBizău you can do O(n) with radix sort
iterating something with recursion is still iterating it.
 
@jdphenix Wait for the bullet to be on track and press P. Then move the planets while the bullet is frozen
 
@BenjaminGruenbaum Thanks! Reading on wikipedia about it.
 
@Zirak this function is amazing (see usage in the lines after)
 
@dystroy thank you for that tip, there's no way I would have been able to get past that without it
I think you may consider disabling the pause button for some levels, unless it's by design - level 6 was made trivial by it
 
10:51 AM
@jdphenix Yes, it's possible I disable pause in some levels if I come back to SpaceBullet. But it's more about thinking than about dexterity.
 
Hi Guys
 
@AlexFilatov Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don'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.
 
Well none the less you love your game, i'll have to revisit later
 
Ugh, this is why quick and dirty answers are bad:
-1
A: How to invoke function inside another function in JavaScript as I've mentioned below

VijayThis is for your curiosity and clarity :) function person() { name = "David"; hello = function() { console.log("I'm in hello"); }; } Now, in order to call hello from outside without using this or class pattern, you will have to first make a call (method execution) to person me...

An answer that promotes the use of globals, doesn't explain why his solution works, but since it does exactly what the OP wants, it gets accepted...
 
Sigh... More downvotes to sow...
 
10:54 AM
I kind of hate myself for writing this:
@Marc I'm not sure how much more me and jfriend00 can stress this fact - promises are not a good fit for your problem here. You should not use them for this scenario - I really don't want to appeal to my or his authority but we've both seen hundreds of questions like this one and can spot the cases pretty well. For a more general reasoning see github.com/kriskowal/gtorBenjamin Gruenbaum 1 min ago
Anything I should have done differently?
@Cerbrus your answer seems just fine although it's generally better to give construct names PascalCase
 
True, but the person was copied from the OP
 
I know, I'd still change it though :P
 
nods
 
yeah, at least make your code validated by jshint :P
 
Hi all
 
10:57 AM
Oh look, fancy code highlights for Person :P
 
Thanks for fixing
 
@BenjaminGruenbaum "edge cases" being with? :D
 
@FlorianMargaine Yes, I didn't want to say the word with :P
I didn't feel easy saying it was always the case though.
 
technically correct is the best kind of correct
 
So says XKCD
 
11:04 AM
Better to be creative with the truth than to lie :P
 
Look at the profile picture of the guy who asked stackoverflow.com/q/28148613/1348195 reminds you of anyone?
 
ZIGI ?
 
should he?
 
Nevermind
 
I just hit the review cap on the suggested edit queue, a user is adding [android] to random questions...
 
11:12 AM
@jdphenix name ?
 
God I love abstract references.
So good.
6to5.org/repl/…*1000).then(()%20%3D%3E%20console.log(el)))%0‌​A
@BenjaminGruenbaum I can see the point now. Thanks for all of your input. I have edited my question and added some motivation, namely to be able to use the proposed ES7 async functions in these kind of situations. So I tried to make a nail a screw just to be able to use a screwdriver. — Marc 6 mins ago
:D
 
Or not
 
ok then :D
 
12:30 PM
Hi, is someone able to explain me this a little: "You don't regard "non-blocking" and "async" as challenges but as the only way forward"
 
@Duikboot people like to use buzzwords, it's an interesting psychological phenomena where people try to sound smart.
non-blocking calls have performance advantages but they're not "the only way forward" by any standard. Some people just like to sound clever.
 
Aha Hi, @BenjaminGruenbaum ( Thanks for that resource you gave me yesterday for AngularJS. Still a newbie ofcourse but the tutorials are really nice. )
 
12:47 PM
Sure
 
!1 better than false?
 
@Neoares Welcome to the JavaScript chat! Please review the room pseudo-rules. Please don'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.
 
@Neoares no
 
But it's the same, isn't it?
 
Yes, it's just less readable
 
12:54 PM
But what if I have this js file in a CDN, where traffic matters?
 
Your production code should be minified using a minifier anyway
 
I know, but i saw some production codes using true and false, that's why I asked
 
Sometimes it doesn't matter but usually minfiers take care of these issues. To be fair it's not a big issue even without minifiers since reasonable servers use compression which can also take care of this.
 
[off-topic] Why is it not suggested to have a 'history' item in your menu?
 
@dystroy's credit there: find the odd thing tutorialspoint.com/assembly_programming
 
1:03 PM
(reddit's cretdit)
 
1:16 PM
@dystroy link?
I miss ctrl + up...
 
gist.github.com/aghosh47/cd58b7705d94a39a2f52#file-errors why do I have this error when I hit localhost:8000/users/new and the error goes away when I remove the line extends layout.jade
:(
 
1:59 PM
You can take a look at this gist. — Danilo Valente 1 min ago
Does this look horrible to you too ?
 
the comment is the worst for me
 
2:20 PM
O_O subclassing in javascript ?
 
film anyone?
 
@towc weekend at bernies
 
@towc fight club
 
@FlorianMargaine already seen
 
tell me this isn't enticing
 
2:23 PM
catch me if you can
la vérité si je mens
 
@rlemon and you didn't photoshop that ?
 
@rlemon plot seems cool
 
Dirty Work is a pretty funny movie
 
2:35 PM
Reading up on functional programming; seems to add difficulty to the programming process. I can imagine it could be easy to stray from it if you aren't paying close attention
 
@towc I would highly recommend "Brick"
 
> Functional programming is the mustachioed hipster of programming paradigms.
lol
 
@NickDugger it may seem so at first. Once you get used to it though, it's much more elegant and expressive.
 
Could you combine OO and functional?
(Still haven't grasped it, fully)
 
yes, you can
 
2:47 PM
So it's not an alternative, just another tool?
 
2:59 PM
you can, but it makes a huge mess if you do it wrong (seealso: scala)
 

« first day (1563 days earlier)      last day (3389 days later) »