« first day (1569 days earlier)      last day (3373 days later) » 
00:00 - 18:0018:00 - 00:00

6:00 PM
wait
that sucked
 
ohhhh
 
so did your mom
 
... so did your mom
 
nailed it
 
heh
@Mosho I nailed your mom too
 
6:00 PM
nice...
 
damn
 
@FlorianMargaine I am, and I hate discouraging people. By all means @Charly you should learn it it is interesting.
However do not ever roll your own crypto.
48
Q: Why shouldn't we roll our own?

PolynomialWhy shouldn't we create our own security schemes? I see a lot of questions around here about custom crypto and custom security mechanisms, especially around password hashing. With that in mind, I'm looking for a canonical answer, with the following properties: Easy for a newbie to understand....

 
kk thx
 
@Mosho I don't know, that code that downloads stuff from wibits... :P
 
not more random than wibbitz themselves
 
6:03 PM
@m59 I don't understand?
 
Hi all , i have a quick question
 
@Osadellah 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.
 
what's a good rule for what needs to be an <img> and what can use background-image?
 
is it part of the content?
 
I'm thinking, stuff with text are tags with alt attributes
see I never did get that distinction :P
 
6:05 PM
You can't put a function inside a function can you?
 
@JaWapa you can
 
Okay, thank you.
 
I have a dropdown menu on my code that doesn't show the menu items after submitting the form :
here is a snapshot of my code
 
@Mosho If it's part of the content of the page it's an <img>, if it isn't it's a background image
 
@Mosho I'm with @FlorianMargaine the rule is "is it a part of the content or part of the presentation". An analyst image is part of the content for example
 
6:06 PM
<ul class="dropdown-menu">
<li>


<a data-toggle="modal" href="@Url.Action("Edit", "Customer", new { id = item.CustomerId })" data-target="#responsive">Edit</a>

</li>
<li>

<a data-toggle="modal" href="@Url.Action("details", "Customer", new { id = item.CustomerId })" data-target="#responsive">Details</a>
</li>
<li>

<a data-toggle="modal" href="@Url.Action("Delete", "Customer", new { id = item.CustomerId })" data-target="#responsive">Delete</a>
</li>
<li class="divider"></li>
<li>

<a data-toggle="modal" href="@Url.Action("ResetPassword", "Customer", new { id = item.CustomerId })" data-tar
 
For instance, a graph would be an image
A pattern to make it look nice is a background.
 
what about a logo
 
the responsive is a modal page
 
@Mosho <img>
 
so the dropdown menu works great at first but once i open the modal , it wont open the options again
i think it's a JS issue
maybe a conflict between my scripts
but not sure where to look for it
 
6:09 PM
@SecondRikudo how about this, which means someone is ranked at the top 25
there
 
@Mosho Two options
 
image with text
 
Either that's an <img>, or the medal itself is a background and the number inside is text.
 
I agree
 
The number is the "content" here
 
6:11 PM
I see
 
Here's a screenshot of the working Dropdown menu
 
what? firefly has a movie to end it??? I know how to keep procrastinating today
 
but once i open the modal and click on the Dropdown menu , it wont show the menu at all, so i have to refresh the page
 
!!afk my dog just ran :(
 
TIL @BenjaminGruenbaum has a dog
 
6:14 PM
A big one. @BenjaminGruenbaum good luck
 
I'm parsing an RSS feed with Google's Feed API and I want it to show a snippet of the blog post. Once a button is clicked I want it to show the rest of the blog post. What's the best way to go about this? Is it possible to use variables from one function in another?
 
6:28 PM
found him
!!afk movie
 
6:41 PM
I need to Ajax my brain
 
@Simone 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.
 
6:55 PM
Does anyone else write JavaScript just for fun?
2
 
in most of the tutorials I see, the username addition part is handle by socket, like form.onsubmit = fn(e) { e.preventDefault(); socket.emit('username', $(..).val() }; can't the form submission be handled with normal express form submission ? like in the index page the username and then redirect to /chats
i need a database for that stuff!!
 
I write JavaScript only so that my schoolmates will be like "Oh that guy knows how to code"
Is this valid syntax? n+=p=a() where a() returns a string and both n and p are strings.
 
7:15 PM
@Charly It's "valid", but it's probably not doing what you want it to.
 
Add whats returned from a() to n and change p to whats returned from a()?
 
@Charly Oh; maybe it is doing what you want. But I wouldn't write it that way; I'd just do it in two lines.
n += a();
p = a();
 
#unecessarycodeminimization
 
7:36 PM
that reason feels weird
 
why I write JavaScript?
 
yeah
 
I was kidding
 
I see
 
8:06 PM
awsome
this just keeps getting better
how d you calculate?
 
8:27 PM
Lo all, wondered if anyone could explain why, as a naive implementation of a deep copy, this was really stupid: jsfiddle.net/wLgoLz80 *prepares to cry*
 
crl
var matrix = [];
for (var i=0;i<img.height;i++){
    var row=[];
    for (var j=0;j<img.width;j++){
        var d = ctx.getImageData(i, j, 1, 1).data;
        row[j]=(d[0]+d[1]+d[2])/(255*3)>.5 ? 1 : 0;
    }
    matrix[i] = row;
}
^ Is there a fast way to put all image pixels in a matrix, I'm doing this but it takes very long (more than 5 minutes)
 
@IanClark Why do you think so?
@crl Yes, move ctx.getImageData out of the for loops
 
@copy because I wrote it :D
 
It'll take less than 2ms
 
After not much thought it must be said
 
crl
8:37 PM
@copy thanks but how do you do so?
 
getImageData gets data for every pixel without looping ?
 
@IanClark Looks okay, I would have done some things a bit differently, but ok
@crl You call it with (0, 0, width, height)
 
crl
@copy I get it, with a temp variable
 
http://stackoverflow.com/q/28267667/2407212
 
8:54 PM
Is there an alternative to request which isn't a horrible function/object hybrid with less than optimal documentation?
(As long as it supports cookies)
 
Im trying to match some strings like "(Res:blablabla)" to change the type of brackets in a passage of text, ive tried a few regexps but none seem to give the desired result.. \((Res:[.]*)\) is an example (hopefully it wont get un-escaped) anyone able to help?
 
m59
@SecondRikudo something in the link has to identify what record is being verified. If the code is hashed, I can't use that, since the user will have the code and I only have the hash. I figure I could store that record with the hash and use its id to identify it.
/:verificationId/:verificationCode
 
@m59 All authentication relies on two parts
First part is the user claiming to be someone, and the second part is proving it with a secret.
Generally, the user's email (or username) is him claiming who he is, and the password that goes along with that email is him proving it
(as only him and the server should know the secret)
In a "forgotten password" the case is the same
 
m59
Yeah, but that would mean putting the email in the link, right?
 
@m59 No
The fact that the link only exists in his email address already means he has the email address
Rather, by entering his email address he "claimed" to be the user with that email address at hand.
 
m59
9:06 PM
I think you're not getting what I mean.
He clicks the link, so what?
 
Now he needs to prove that he is who he claims he is, by going to the email, getting the secret provided there, and passing it back to the server.
 
m59
Yes, so if the link is clicked, he's good to go. But I don't know who he is.
I would if the code wasn't hashed. I could just look up the code, of course. If I can't lookup the code because I have a hash instead, then I have to have something to lookup.
 
@m59 Indeed, So you need to pass the user ID as part of the link, yes.
 
m59
lol that's what I said =D
 
You hash the code and then look it up?
 
9:08 PM
Also that's an option as well ^
 
m59
The hash is different each time. Is that not normal?
 
@m59 No it isn't
 
m59
It is for me.
 
The entire point is that the hash is deterministic.
Ah wait
 
Then it also generates a salt, probably
 
9:09 PM
No, scratch that.
 
So you need a separate verify function
 
m59
Yep.
 
Yeah, if it generates a salt (which it should), you won't be able to do it cleanly.
 
would mongoose be considered an ORM?
 
m59
Exactly.
 
9:09 PM
@m59 cleanest solution is to pass the user ID
example.com/resetPassword/?id=42?verificationCode=abc123
 
Oh, right
 
Woot, you hash the secret, store the hash, never the secret.
Next time user tries to pass the secret, you hash it and check it agains the stored hash.
If a salt is used, store the salt as well, and use it again, the salt is not the secret
 
How do I prevent the screen from expanding when div goes below screen?
overflow: hidden doesn't cut it it seems
 
I wanted to show errors in username validation, so in my mongodb I added a unique: true for nicknames, now in my create action I have
new User({ nick: req.body.name}).save(function(err, data){
if(err) {
err["dest"] = "index"; err["message"] = "user name taken";
return next(err);
} res.redirect('/chats')

and then in the end of my routes I have
app.use(function(err, req, res, next) { res.render(err.dest, err.message) });

I dunno if its a proper way to do it, all I want is to show the error message from the page the request came, the above works except the url stays at the form's action url,
 
@Jonathan No canvas?
 
9:12 PM
Divs :D
I'll rewrite it later to canvas I guess
 
background-repeat: none!
 
Nah, I don't want the view to expand at all
 
so, let's say I have a rectangle of which I know the diagonal and the area. I'm pretty sure that there is only 1 base and height for any rectangle with those properties, but how do I get them?
 
How do you calculate the area for a triangle?
 
I only know some specific cases, as when the area is 0, or the area is a square and the hypotenuse is the radix of the area times the radix of 2
@Jonathan b*h/2
so what? I still can't find anything to help me
 
9:17 PM
Ok, so you should be able to get the rest with Pythagoras I guess: A^2 = B^2 + C^2
 
I tried, couldn't manage to get anything
 
Solve A=b*h and d^2=b^2*h^2
 
wait... b^2 * h^2?
wasn't it +?
 
Oh, yes
 
so... (b*h)^2 = b^2 + h^2...
b^2*h^2 = b^2 + h^2?
 
9:20 PM
No
A is the area and d the diagonal
 
A^2 = b^2 + h^2?
yeah woops
I have no idea
oh wait...
nope
 
in mongoose, is there some kind of data type to say "it is one of the following things"?
 
In the following code why self is public method?
var obj = function(){
//public
var self = {
.......
}
//private
var privateData = ....;
return self;
}();
is it because, it's returning self?
 
@corvid - like how exactly?
 
@corvid enum?
 
9:29 PM
@adeneo The goal is to represent "user roles" in a database. I guess a join would really be more fitting. Not used to mongodb though
 
@BhojendraNepal that should be ` (function(){...})()`
!!google IIFE
 
@Jonathan It doesn't need to be wrapped in () because it appears in an expression context
 
@copy will that be executed?
 
@corvid - Well, there's mixed, otherwise it's one of the other seven
 
9:31 PM
Yes
 
@adeneo please help me understanding why var self is public and var privateData is private?
 
@BhojendraNepal - It's in the name, privateData just have to be private, doesn't it
 
I'm not understanding why self is public though both are declared with var..
 
@BhojendraNepal it's like you said, the obj self is returned
 
nevermind, I wasn't paying attention
 
9:33 PM
:P
 
@Jonathan thanks. I was guessing right.
 
@BhojendraNepal - there is no public or private, it's just a matter which scope they are available in, and what's returned to the outer scope etc.
 
@BhojendraNepal I would however (even though it is apparently not required) wrap that IIFE in parenthesis, to make it clear it is immediately invoked.
 
@adeneo so self is available in outer scope?
 
yeah
the return self;
 
9:38 PM
You're returning self, and it's just an empty object, so now obj === self
 
okay I actually don't get something; what is the deal with the get method? Is that just saving the unhashed password in the database? Idontgetit
UserSchema
  .virtual('password')
  .set(function(password) {
    this._password = password;
    this.salt = this.makeSalt();
    this.hashedPassword = this.encryptPassword(password);
  })
  .get(function() {
    return this._password;
  });
 
crl
@copy sorry I misunderstood you, I don't know what to do, here's a fiddle: jsfiddle.net/h661n2g6/5
 
@adeneo so I can access self.something but not privateData.anything, right?
from outer scope...
 
No, not really, you'd probably get window.self in some places though
var obj = (function(){
    var self = 'Hello Kitty' ;
    var privateData = 'Hacketty Hack';

    return self;
})();

console.log(obj);  // Hello Kitty
console.log(self); // undefined, or window.self (yes, "self" is a global), depending on where
console.log(privateData); // undefined
 
Yes, and it will now be obj.something
 
9:41 PM
@adeneo yes?
 
@crl Do ctx.getImageData(0, 0, width, height) in line 15
And remove the repeated call
And adapt d[0]
 
@SomeKittens - yes, in the sense that it's now obj, but you can't access the variable self with that name, which is what I thought he/she meant
 
@adeneo yes, in terms of cat greetings
 
cat greetings always makes things clearer
 
8
Q: Kitten can't speak

SomeKittensI'm running through the mongoose quickstart and my app keeps dying on fluffy.speak() with the error TypeError: Object { name: 'fluffy', _id: 509f3377cff8cf6027000002 } has no method 'speak' My (slightly modified) code from the tutorial: "use strict"; var mongoose = require('mongoose') , db =...

surprisingly relevant
 
9:44 PM
gravatar.com/avatar/… -> The guy who answered
 
var obj = (function(){
var self = {
something: 'something'
}
var privateData = {
anything: 'anything'
}

return self;
})();
console.log(self.something);//returns undefined
 
Again, you can't access self outside the function
Now it would be obj.something
 
oh! Thank you.
 
crl
@copy thanks
 
To make it clearer
var fn = function() {

    var variable = {
        something : 'something'
    }

    return variable;

}

var obj = fn(); // calls the function, and writes the returned result to "obj"

console.log(obj.something);
 
9:54 PM
it will log "something"
amirite?
 
@adeneo It's totally clear now. Thank you very much..
@FlorianMargaine Yes, it logs 'something'
 
!!palm breeze or fluffy melons
 
@rlemon fluffy melons
 
My dog today:
 
10:04 PM
@BenjaminGruenbaum did you find him?
 
Yeah, a couple of nice people found him and started walking him to the vet. I was driving my car in circles looking for him when I saw some guy who said he saw a couple with a dog nearby so I drove another few blocks and found him.
 
hhahahhaa
 
@BenjaminGruenbaum nice :)
 
He looked annoyingly satisfied with himself and under the impression he was a very good boy. Got a treat, came into the car and we drove home - we even made it to the movie.
Looks pretty satisfied now.
 
10:09 PM
@BenjaminGruenbaum see, where I live, I don't need to worry about my dogs getting lost
I need to worry about all the neighbors' dogs suddenly disappearing :|
 
@SecondRikudo also - because you don't have a dog :D
@IanClark lots of edge cases missed :D
@SecondRikudo request is actually pretty good IMO but you can always use http from node it's a basic but solid HTTP client. There are also a bunch of other libraries for this.
 
@BenjaminGruenbaum Sure I do.
Remind me to show you Nala next time we meet.
 
pics or didn't happen
 
@BenjaminGruenbaum :
Hermes Conrad: Do ya wanna see a picture of my boy?
[holds out a picture]
Dr. Zoidberg: That's your penis.
Hermes Conrad: That's ma boy!
 
10:18 PM
Yeah I don't have any on me
I'll get some and post 'em
 
A true dog owner carries hundreds of pictures of the dog
I have hundreds.
 
@BenjaminGruenbaum give me a break, I switch phones not that long ago
Lemme see in my backup drive
 
I have videos too. (see on facebook.)
@SecondRikudo why is 6to5 getting renamed?
 
@BenjaminGruenbaum ^
 
Hi doggy :D
Now I believe you
Although those pictures are 2 years old and mine are from today.
@FlorianMargaine :D
@FlorianMargaine es6 is renamed to ES2015
Or something stupid like that.
We need to "educate" people it's not ES6 any more.
Or something stupid like that.
 
10:25 PM
@BenjaminGruenbaum These are from my backup drive and I'm far away from her and don't make me miss her more than I already do :(
 
@BenjaminGruenbaum uh, really?
 
And also that second one is more recent than 2 years
 
@FlorianMargaine yup
 
@BenjaminGruenbaum Also FYI, 2010 was 5 years ago, not 2.
 
10:35 PM
Hello
Can you check my recent question please? stackoverflow.com/questions/28268535/…
 
You say bulshit, documentation on reader card ? YOU WILL FIND HOW YOU USE IT plug and play .. and you think that an idiot ?. please don't comment if you don't have an answedr — user36190 31 mins ago
wat
 
flagged
 
And instakilled
 
@SecondRikudo wat
 
10:53 PM
!!afk beer
 
@BenjaminGruenbaum you can't just say that without so much as a hint of what they are!
 
@IanClark BenjaminGruenbaum is afk: beer
 
@IanClark try to clone a regex
extend*
Also getters and stuff
Also, other stuff
!!afk beer for real
 
11:15 PM
woah what?
es6 isn't named es6 now
.. thats really weird
wow yeah thats weird
shit man so es5toes2015
lol
god.. that just dates it immediately (obviously) like.. wow look at us we're still stuck on es2015 here.. its been 10 years!
/me goes back to playing with react
 
on passport, is it possible to do a function on log in rather than having a redirect?
 
11:35 PM
can anyone help me with youtube?
 
MLM
@BenjaminGruenbaum Is there a method like Bluebird.tap where you can return a new value? (still want to pass on a error if it happens)
 
@MLM BenjaminGruenbaum is afk: beer for real
 
MLM
Bluebird.return is pretty close but I want to manipulate the result of the first promise.
nvm, looks like .then passes on the error by itself: jsfiddle.net/2unpft7c
 
11:54 PM
Yes, it's called .then :p
Back to my beer
!!afk
 
00:00 - 18:0018:00 - 00:00

« first day (1569 days earlier)      last day (3373 days later) »