« first day (1523 days earlier)      last day (3427 days later) » 

3:00 PM
there you go
 
var a = foo();
function foo() {
  return (function() { bar(); return 1; })();
}
function bar() {
  if( a === 1 ) console.log('done');
}
 
@rlemon jsfiddle.net/uraftzq0/5 seems to work
 
That was a silly approach but yeah.
 
@RoelvanUden noep
 
Hi guys!
 
3:00 PM
I don't get it. what's wrong in return a=1, bar(); ???
 
you're overcomplicating it. Just set a = 1, and call bar
^ what @dystroy said
 
@dystroy there could be any variable, not just a.
 
outside the spirit of the challenge, since the return isn't what's doing the assignment in that case
 
@dystroy I assume you want foo to return a as well
@dystroy which changes the answer very little, just tack a , a on to the end
 
It's hard to assume anything as it doesn't look like it has a goal
 
3:01 PM
i do a login page with node.js and passport and i wonder how can i delete expired sessions entries from my mongo database?
 
Works fine for me as it is.
 
@MikeBoutin timestamp each session and have a job, every N minutes (depending on performance vs load) cleanup any records older than N
 
@MikeBoutin That's a good question. Isn't that built-in ?
 
@dystroy what you mean by built-in?
i use passport-local strategy
 
And it doesn't clean expired sessions ?
 
3:03 PM
ahaha I'll have to work harder to think of more interesting 'challenges' then
 
and do a
app.post('/login', passport.authenticate('local',{
failureRedirect: '/login',
successRedirect: '/user'
}));
 
I figured that was impossible or close too it
glad to see there is so many js 'hackers' around ;)
 
@dystroy no, or how can i give an expired date for the session?
 
so... what is the solution?
 
42
 
3:04 PM
yesterday i tested my app a lot, today, i got 75 session entry
 
6
Q: Entries created by connect-mongo not being expired

robI have a Node server set up with Express, using Passport for authentication. I've heard that connect-mongo is good to use for persistent login sessions, so I have it set up and everything seems to work fine at first, with user sessions being automatically deleted by mongo according to the expire...

7
Q: Connect-mongo sessions not being deleted automatically

Kevan StannardI have an application using NodeJS, Express, MongoDB and connect-mongo. My issue is that sessions don't seem to be automatically deleted from MongoDB when they expire, so the db size grows until the disk is full. The developer of connect-mongo wrote a comment: connect-mongo will ask MongoDB...

 
@dystroy great!
 
Everything seems to point towards managed expiration (which looks the only reasonnable solution)
 
@jAndy fortunately, this question is not the question of life ;)
 
@rlemon (expr (',' expr)*) ruins a lot of things, unfortunately. It's just bad to actually use.
 
3:05 PM
sorry, i am very noob with node.js
BUT I FREAKIN LOVE IT
 
@AwalGarg doesn't matter. 42 is always the solution if in doubt
 
@ssube ah damn
@jAndy there is no doubt.
 
whoo, @SimonSarris has a tutorial on his site that's exactly what I was looking for.
 
@MikeBoutin Well, me too, I just googled
 
lol
i wanted some programmer opinion too
^^
 
user2620028
3:07 PM
Guys now i want to learn node. I had to write c code that was comment dated from 1987 and make it work with c sockets last night. I feel dirty
 
is passport a very good way to create logins? or does it have better ways?
 
user1596138
@rlemon what's the "correct" answer? Sure I see the ways they did it but they hardly seem realistic lol it's hacky
 
@HatterisMad Write the same thing in node and compare the two?
 
user2620028
@ssube probably the same :P
 
user1596138
I was waiting for a solution that still assigned a by returning 1
 
3:09 PM
@HatterisMad complaining about C, but not complaining about Java or C++ or C# is what should make you feel dirty.
 
function a() {
  var a = 42;

  return b();

  function b() {
    if( a ) return -1;
    else {
      var a = 0;
      return 1;
    }
  }
}

a(); // ??
 
user1596138
...Well that's code
 
@jAndy 1?
 
this is my favorite thing to confuse noobs
 
user2620028
@mintsauce i was not complaining about the fact that it was c, i was complaining about the fact that my professor was forcing me to use 1987 c code lol. I had to define true and false to equal 1 and 0 at the head of each document o.O
 
3:10 PM
@jAndy you bad boy
 
@jAndy You could throw this in the middle :
if ( a ) return
-1;
 
@HatterisMad what's wrong with code from 87? if it still works the same...
 
it would be -1, me thinks
 
@AwalGarg a is undefined when you reach the if
 
@dystroy shit yes
 
user2620028
3:11 PM
@ssube i have no prior programming experience with it and there was no instruction on the content. It was feel around blindly in the dark and hope you find a boob.
 
@jAndy Nice.
 
@jAndy good one. Thanks for sharing here ;)
 
the only real interesting point or lesson to learn there is, that var keyword in the else clause
 
@HatterisMad Seems more sensible than ==.
 
once you realized the hoisting effects .. you'll be much clearer what 'function scope' really means :)
 
user1596138
3:12 PM
@HatterisMad @BeerLovers
 
user1596138
 
user2620028
HAHAHA cute
 
user1596138
Haha I accidentally made a perfect loop with the gif too
 
What do you think is the outcome of this :
function a(){
  if (a) return
    {a:a}
  return
    {a:1}
  ;
}
console.log(a().a)
no trying
 
user1596138
1
 
3:14 PM
wrong
 
user1596138
2
 
@dystroy ASI?
 
@someDoge the correct answer is to refactor your code to not have such silly constraints
(this isn't actually from any of my code, it was just a thought I had)
 
!!google ASI
 
why do I see asi everywhere? :(
 
3:14 PM
@dystroy nothing
 
user1596138
@rlemon Of course :P. I was just expecting some cool solution
 
@dystroy undefined
 
if (a) return[;]
 
@dystroy I meant automatic semicolon insertion
 
3:15 PM
@AwalGarg yeah
 
Hi ninja :)
I need help :/
The website athimannil.com working with $route but unfortunately when I enter athimannil.com/about it doesn't work :(
 
@dystroy \o/ \o/
 
@dystroy a doesn't exist?
 
yep
can't work
 
@SomeGuy yes
 
3:15 PM
And yet people complain about JSLint.
 
the outcome is "annot read property 'a' of undefined "
 
I liked jAndy's challenge better
 
!!> function a() { console.log(a); }; a();
 
@mintsauce I don't like jslint
 
@SecondRikudo "undefined" Logged: "function a() {\n\"use strict\";\n console.log(a); }"
 
3:16 PM
Hoisting is harder than ASI
 
@dystroy It prevents bugs though.
Lots of bugs.
 
@SomeGuy I dislike and avoid both.
@mintsauce I prefer JSHint
It's JSLint - the obnoxious assumptions about my coding style.
 
@SecondRikudo We're talking about challenges, not how your actual code should look
 
ASI will only really kill you on return statements
 
@mintsauce that's because it takes a bunch of extremely arbitrary rules and considers them canon
 
3:17 PM
@mintsauce ASI causes more problems than it prevents.
 
Everybody know hoisting. Nobody here would have a bug due to hoisting.
 
@SecondRikudo it's stricter, but not obnoxious.
 
jshint is a far better tool, to achieve the same goals
 
user1596138
@AwalGarg nonsense
 
especially if noobs try to return objects and are used to "newline"
like

return
{
   foo: 42
};
 
3:17 PM
@dystroy function hoisting? yes. Variable hoisting is less known.
 
@AwalGarg Not really
 
@jAndy There are many cases when this formatting makes sense, not only for noobs (not exactly like this but similar)
 
JSLint's rules are based on actual bugs found in existing code. Its rules are anything but arbitrary.
 
ASI is generally a good thing to have. JS just implements it badly.
 
this can be nasty and is very SUBJECTIVE reason to force people to have parenthesis on the same line always
 
user1596138
3:18 PM
// See when I go to multilines I automatically want to do a
return (
  {
    content:'here'
  }
)
 
an has nothing to do anymore with style or something bias
 
@SomeGuy better now?
 
@someDoge Meh, this is more readable:
return {
    content: 'here'
};
 
user1596138
@SecondRikudo lol of course if that's all you're doing
 
@SecondRikudo Usually, yes. But the faulty formatting always arises due to surrounding code making it more readable. It happened to me at least twice, even if I perfectly know the problem
 
3:20 PM
@dystroy Explain
@someDoge Explain
 
@dystroy like?
 
hhmmmm how many hats can you wear at once
 
user1596138
function ff() {
  return {
    first:'ONE'
  }, {
    second:'TWO'
  };
}
 
@someDoge What are you even trying there?
 
@someDoge huh? :P
 
user1596138
3:22 PM
@SecondRikudo ^ What's that do
 
user1596138
We're talking noobs remember.
 
Returns the second object?
 
user1596138
Right
 
@someDoge puke
 
user1596138
Is the point... But thank you for displaying your disapproval
 
3:23 PM
Good morning everyone.
 
@someDoge That's all nice and fun, but that doesn't change the fact that no one does that, and whoever does that is someone I can feel safe to call "ugly and stupid".
 
@SomeGuy For some reason I was expecting the first
 
Hi ninja :)
please help me :/
The website athimannil.com working with $route but unfortunately when I enter athimannil.com/about it doesn't work :(
 
user1596138
@SecondRikudo Yeah that's the point.. I thought that was implied
 
@PeeHaa You know how , tends to behave, right?
 
3:23 PM
Related : here's a real bug I had in my code
proto.queryRows = function(sql, args){
	var resolver = Promise.defer();
	this.client.query(sql, args, function(err, res){
		if (err) resolver.reject(err);
		else resolver.resolve(res.rows);
	});
	return resolver.promise.bind(this);
}

['begin','rollback','commit'].forEach(function(s){
	proto[s] = function(){ console.log(s); return this.queryRows(s) }
});
 
user2620028
Hey Muhammed if you are trying to address ninja then you can use the @ symbol before their username
 
see it ?
 
@SomeGuy Apparently not
 
!!> (1,2)
 
Do you guys know any good books on JavaScript to write clean and pretty JavaScript? That don't demonstrate poor approaches and habits?
 
3:24 PM
@dystroy ahh
 
@SomeGuy 2
 
@someDoge Of course JSLint would have caught that ...
 
But why?
 
@dystroy miss a ; no ?
 
!!mdn comma operator
 
user1596138
3:25 PM
@mintsauce Uh, yeah?
 
user1596138
Good irrelevant point :thumbsup:
 
@dievardump Yes. It can be confusing when you're looking for something else
 
@PeeHaa it evaluates first expression, trashes it, then next, and so on. returns the last one.
 
@PeeHaa I think the MDN article should be enough
 
user2620028
3:25 PM
@mintsauce maybe read up in the chat a bit to get the context of why he was posting that? I don't think you are understanding.
 
user1596138
I don't think anyone understood lol and so now I don't know what I meant either
 
@SomeGuy Yeah kinda makes somewhat sense now I read it
 
user1596138
Let's just move on haha
 
@dystroy yep. That's why I always add a ; after a function declaration, then I lint and erase the one that are not neaded
needed*
 
@HatterisMad I am addressing everyone in the room :)
 
3:26 PM
@dystroy i dont see it where should the comma be after "return this.queryRows(s)" ?
 
I like to put 2 semicolons to be safe just in case I lose one.
4
 
@PeeHaa I can understand... PHP doesn't have a proper comma operator xD
 
@nderscore that's the spirit
 
@nderscore Ewwww XD
 
@AwalGarg Nope
 
user2620028
3:27 PM
I kind of want to play the opposite game on stack overflow during hat season. I want to try to avoid earning hats as much as possible. (Should be pretty easy due to my activity level) But in chat this means starring anything is dangerous business.
 
@nderscore gzip your files and they won't even take more space
 
proto.queryRows = function(sql, args){
	var resolver = Promise.defer();;
	this.client.query(sql, args, function(err, res){
		if (err) resolver.reject(err);;
		else resolver.resolve(res.rows);;
	});
	return resolver.promise.bind(this);;
}

['begin','rollback','commit'].forEach(function(s){
	proto[s] = function(){ console.log(s);; return this.queryRows(s);; };;
});;
 
@PeeHaa except in for loops ofcourse :D
 
Welllll.... some are still missing
 
Not sure I would want it though
 
3:28 PM
@SecondRikudo Hahaha
 
@AwalGarg yes they hacked that in
 
@ssube exactly, with compression it's a no-cost safety net
 
@dystroy Where? =)
 
After the assignment
 
3:29 PM
me neither..
 
Then you're not allowed to write JavaScript ever again
 
user1596138
@Greg see that's difficult... Practices are always changing and books take awhile to write, publish and get into your hands.
 
True, but it'd be nice to have some type of content.
 
@Loktar free games for all?!
 
3:30 PM
oh after the } ?
 
@rlemon no he personally restored that game Hatred to Green Light
 
@dystroy JSLint would have spot errors in that.
 
Otherwise, people attempting to learn correctly learn poor practice such as excessive:

$(document).ready(function () { });
 
['begin','rollback','commit'].forEach(function(s){
	proto[s] = function(){ console.log(s);; return this.queryRows(s);; };;
};;);;
 
@SecondRikudo When the assignment of proto.queryRows ends
 
3:31 PM
@SecondRikudo ^
 
@Loktar in 100 words or less, what was wrong with the game?
 
@Loktar gaben ruins your life. Gaben fixes your life. Praise gaben.
 
Ah, right
 
@SomeGuy you mean after the } right?
 
3:32 PM
@user3470815 Yeah
 
user1596138
@Greg Do you know why you shouldn't? I think that's the important bit
 
thats the greenlight page, watch the like 1:30 min video about the game
 
ok thx @SomeGuy
 
@mintsauce yeah, but jslint is affraid of everything. It only likes java
 
user1596138
@Loktar :O domestic terrorist simulator
 
3:33 PM
It's only afraid of avoidable bugs.
 
@Loktar so people hated hatred because it is too violent?
 
yea basically, so they cried to Steam to remove it
 
 
lame
 
is it possible?
 
3:34 PM
and Doug Lombardi did
but Gabe was like nah brah. Put that back on.
 
How about Nginx with Node.js ? Does Nginx work fine with Node.js ?
 
"if the humans are dead already (zombies) it is fine to run 20 of them over with your car... but if they are still alive! GTFO WITH YOUR GAME" basically?
 
user1596138
I mean I can totally see the line between video games and reality. It's not like that game is wrong or something.. But it sure would be a strange feeling playing it.
 
@towc Possibly
 
what do you mean "not trig. solution" ? If you want an angle it's related to trigonomy
 
3:35 PM
If you don't get an answer by later today, ping me and I'll sit on it
 
@towc What's the definition of "no trig"?
 
@towc why no triggie?
 
No trig functions allowed?
 
I know it's quite easy to get Beta, and I know that there must be a relation between a and b
 
@someDoge yeah not sure if Ill buy it even
 
3:35 PM
no trig = no sin/cos/tan
 
user1596138
@rlemon but the zombies wanna eat your face lol the shop owner just wants you not to shoot him in the face haha
 
@towc why not?
 
@someDoge he might wanna eat my face. can't be sure
 
but I still dont think it shouldn't be on Steam. I mean I also don't buy adventure games, but other people like them, so meh
 
haven't asked him yet
 
3:35 PM
@AwalGarg that's the challenge
 
@towc There are ways to use trig functions without directly using those, though
 
user1596138
I mean I play GTA and I run over like 4 dozen pedestrians in 2 miles
 
If you can't use trig functions, you could just fake it
 
@SomeGuy as?
 
All functions can be expanded to approximations
 
3:36 PM
yeah exactly GTA was a cited example
 
Maclaurin's / Taylor series
 
@SomeGuy I don't want no approximation
 
@SomeGuy I don't like the former... ew
 
@Loktar "giant rubber dildo bats so he can kill cops with it?! sure lets get this for our 9year old."
but hatred is taken down
 
user1596138
I'm not arguing ethics in video games hahaha. It is what it is. As long as the character isn't running around with an ISIS flag or being part of a IRL terrorist organization I think it's just a strange game
 
3:36 PM
LAME
 
Apart from $()
 
The approximations can be pretty much spot on if you really want
 
glad it's back up
 
@towc Well, technically virtually any answer will be an aproximation.
 
@Retsam don't think so
 
3:37 PM
@someDoge From what I've gathered is it does a ton of extra stuff through the persistence of the DOM, which is often overkill and not needed. If I'm correct awesome, if not- Some clarification would be splendid.
 
yeah same here, I had lost faith in Steams leadership when it was taken down
 
I don't necessarily want a number, just a fraction, even if irrational, is fine
 
but Gabe restored it :P
 
or roots or anything
 
user image
3
 
3:37 PM
@towc Most answers involving trig functions are going to be irrationals.
 
user1596138
@Greg There's also the fact that you're using jQuery to simply fire an event on document ready hahaha
 
This might be some of the most horrifying code I've had to review: (anonymized sample) pastie.org/private/6zg6ipk3pkzjw2bfiuyuq
 
The only way I can think of is to use expansions of the trig functions
 
@Retsam then leave them as roots or fractions
 
@towc Maybe @BenjaminGruenbaum can jump in?
 
3:38 PM
@towc They're not roots or fractions. They're based on trig functions.
 
@SomeGuy no
 
user1596138
> // first, check the javascript variable:
 
there is a theorem... which I can't remember right now.
 
user1596138
Good comments lol
 
@AwalGarg You mean, "No, that's not what you think"? :P
 
3:38 PM
Studied in 8th standard
 
user1596138
// second check the PHP variable??
 
@AwalGarg They're all based on trig functions, assuming we're thinking of the same things
 
@towc Trigonometry is based on the fact that all 90-α-β triangles are similar
 
@Retsam and how do you make those functions?
 
@SomeGuy We didn't have trigo in 8th standard. They were purely geometric.
 
3:40 PM
do { } while(false)
 
Geometry functions?
 
if(false &&...
 
If a right triangle has an angle α, all other right triangles with an angle α are similar.
 
@SomeGuy sorry bad words :( :P
 
Similar triangles have some rules which relate to the relations between them, so maybe you can use that.
 
3:40 PM
@AwalGarg And they weren't graphical?
 
@SomeGuy nope
 
Let me know if you figure it out
 
@someDoge Well, that to.
 
@towc Well... generally they're calculated by approximations. If you press the "sin" key, on your graphing calculator, its doing an approximation.
 
@Retsam Not in math
 
3:42 PM
@Retsam and throwing out an entire number... but I think that it could be read just as a fraction or root!
 
@nderscore what does line 8 mean the second and? && someGlobal
 
user1596138
Someone upvoted 3 of my old answers last night. lol stalkers
 
sin(α) = a/c
Nothing more nothing less
 
what's c?
speed of light? XD
 
isnt already checked with the typeof !='undefined' ?
 
3:43 PM
And even computers can do exact solutions, en.wikipedia.org/wiki/Symbolic_computation
 
@towc Maybe. I suppose if your angle is rational by definition the trig functions, by definition, will be rational, so I guess I'm overthinking it.
 
@towc Hypotenuse
The largest side of the triangle, opposite to the right angle.
 
@copy Well, yes; but that's Mathematica-level deep magic.
 
@SecondRikudo and a is alpha or a cethete?
 
@towc maybe with the use of V2 sqr relations i dont remember..
 
3:44 PM
@towc a = side opposite to alpha.
b = side opposite to beta.
 
We just use SOHCAHTOA
 
and how do I calculate a?
 
I'm pretty sure Mathematica requires a ritual sacrifice as one of the installation steps for installing it on a new machine...
 
user1596138
r = slidepoop
 
sin = opp / hyp
 
3:44 PM
(without sin)
 
@user3470815 I think he was trying to check if some global variable exists and that it has a property 'user'
 
In NODE.JS, in a Jade view, how can i put a ROUTE url in a link? Not a direct string like "/login" but something like app.route(...) who output the good url
 
@towc Well, if you had trig it would be simple XD
sin(α) * c = a
 
@towc Where'd you find that image?
 
but I don't have trig
@SomeGuy made it a few mins ago
 
3:45 PM
Something you just came up with then?
 
@SomeGuy yes, this wasn't requested by a teacher or found online, just pure curiosity
 
-_-
 
If you disallow expansions, I believe it isn't possible
 
@nderscore but isnt that already checked the !='undefined' i mean i think you could delete &&someglobal the second and
 
@towc I bet @BenjaminGruenbaum would be able to give you a more meaningful answer.
 
3:47 PM
but there has to be a pretty simple (not simple enough for me to figure out apparently) relation between a and b
 
@user3470815 yes, this is horrible code. there's so many weird/flawed/insane things going on there. that's why I shared it :)
 
@towc Yes, there is.
 
@SecondRikudo Haha already pinged him
 
tan(α)
 
also, here's a quote from the author of that code: "there are a lot of people out there who say they know javascript but don't really know how to code well."
 
3:48 PM
@towc There has to be some relation other than tan?
 
@towc a^2 + b^2 = i^2 lol
 
The ratio between a and b is dependant on α, and that function is called tan.
 
tan is really the definition of the relation between them
 
@Retsam instinctively I'd say yes, but I can't seem to find it
@SomeGuy but that's too literal...
 
@nderscore is this at bussines level¿
 
3:49 PM
@AwalGarg if we know either a or b I would be happy, but we don't
 
@towc yeah the whole point of trigonometry is to find the relation between the parts of a triangle
 
user1596138
@nderscore Soo... You guys are hiring then
 
Trying to do that without trig is like trying to take a derivative without calculus
 
the guy who wrote that code works in sales and somehow managed to push it live :(
 
user1596138
lmao
 
3:50 PM
@nderscore w00t?
 
user1596138
Hey at least he knows how to use ternary and "null" or 'null' // consistency
 
user1596138
I use do...while and ternary so I know how to codez
 
user1596138
@AwalGarg would like his use of try...catch :P
 
@nderscore then be happy he knew to write 1 code of line if he is "sales " depart
 
user1596138
No one else would..
 
3:52 PM
@nderscore Dear god that it horrible.
I don't think he got a single line right...
 
@Meredith how do we know them? Do they just contain a table of a lot of cases, and as you pass the parameters it sends you the value closest to the one of the parameter you pass in??
 
user1596138
try{console.log('checkIsNullIndustry(): isNullIndustry == ' + (isNullIndustry ? 'true' : 'false') + ", industry == " + industry);}catch(err){}
 
user1596138
This one just hurts though
 
@towc What?
 
@someDoge do { ... } while (false) hurt me more.
 
user1596138
3:52 PM
@SecondRikudo lol yeah that's what I meant earlier
 
@Meredith how does the computer know that sin(0) = 1?
 
How can i access Session variable with JADE?
 
Taylor/MacLaurin series
 
@MikeBoutin You pass it in... Jade is a templating language.
It doesn't have logic (or rather, you shouldn't do logic in it)
 
I know, but i have to pass it to every render() ?
There's no way to get this globally?
 
3:54 PM
@SecondRikudo In a different function, he does break to get out of one of these do while false loops :P
4
 
@Meredith so just approximations? It doesn't feel good to me
 
what is JADE?
 
@nderscore I'd fire him.
 
Approximations that are exact for more than 17 digits
 
who's starring all the things?
 
3:55 PM
@nderscore Hahaha
 
@Skynet go away
 
How long do you think decimals are in javascript?
 
spam bot again?
 
Todayis deploy day, soz. Check later.
 
3:55 PM
It's probably for the hat
@BenjaminGruenbaum Best of luck!
 
@towc Proper math software can also have rules tables and knows who to apply them
 
GOTO THE SANDBOX TO GET THE STAR HAT YOU TOOLS! don't spam the main rooms. FFS
 
Star bait
 
if I wanted more stars i'd pin it
 
3:56 PM
but there is already a pinned one people ignore
 
I want more stars :P
 
Ok
 
user1596138
@nderscore Oh I was joking on the code quality haha
 
@copy ?
 
@someDoge I know haha
 
3:57 PM
14 mins ago, by copy
And even computers can do exact solutions, https://en.wikipedia.org/wiki/Symbolic_computation
 
user1596138
I don't know if I wanna work with your coworker ;P
 
Jealous of others being starred :P
 
you wouldn't work with him at all. he's not supposed to be writing any code. I'm just cleaning up his mess. :(
 
Thank you for speaking
GTFO and have a nice day.
 
> this user has already been kicked from this room
hahahahahahaha
 
user1596138
3:59 PM
You guys do insights/analytics?
 
@rlemon Relax, your already bitter. You don't need to be angry as well.
 

« first day (1523 days earlier)      last day (3427 days later) »