« first day (2028 days earlier)      last day (2923 days later) » 

8:00 AM
I miss alpha centauri
I think it was better than the civilization games though I loved them too
 
the only game my generation knows is minecraft
(sigh)
 
@towc you missed a great era
 
I did :,(
 
Though minecraft is a decent game
 
@towc And those would be placed in the place between the inner and outer functions, so they could be probably shared among multiple functions without having to assign them to this thus making them public, right?
 
8:02 AM
tf2 is the best game ever made
 
Would have been better if it were a little harder, but that's just me
 
@DavidPacker "locally public" would probably make sense to you. That is what is meant by private
 
like this
Civ3 and Civ2 were awesome, I also played Civ 3 the other day
never really liked 4 or 5 very much
 
@towc You've actually made me even more confused. Locally public in what sense?
 
Civ2 was better than the first
 
8:04 AM
var fn = (function(){
	var cheese = 'delicious';
  	return function(){
    	console.log( cheese );
    }
})();

fn(); // 'delicious'
console.log( cheese ); // cheese is undefined
 
Sorry, perhaps these questions are really basic, but I have little to no JS experience. :D
 
^ that's what happens
 
I didn't pkay civ3 ,but civ 4 lost something
 
Oh yes, that's exactly what I mean.
 
cheese is private to the scope of the IIFE (IIFE = (function(){}))
 
8:05 AM
@Neil yeah
civ3 is great, try it @Neil
 
And if you wanted to share variable value among multiple functions without exposing it to public, then the variable would be actually defined between the inner and outer function, is that correct?
 
@BenjaminGruenbaum I might take you up on that. It has been too long since I played those
 
@DavidPacker wut? Write an example
 
It's the best civ game so far imo.
 
My strategy was to get all wonders and technology
When you had tanks and they are still using catapults, win :)
 
8:08 AM
@towc pastebin.com/iRGJ0QRv The user can modify the counter value using the increaseCount function, but cannot access it directly.
 
@DavidPacker oh yeah, that makes it a "static" variable ;)
which is why it's not a proper private one
static doesn't mean not-dynamic
 
@towc So this one would be shared among all the questions instances?
 
read up on C's static
@DavidPacker yup
I mean, you can try it for yourself
 
Damn, and where would the counter then be placed if you wanted to assign it an instance without exposing it?
 
read about getters and setters in javascript
 
8:13 AM
It's a bit like it holds the scope it had when it was defined
Which is weird compared to other languages
 
^ what mom said
 
I have over a decade of experience in OO programming and I just don't get JS.
 
@DavidPacker JS is not a standard OO lang, think of it as JS rather than anything else :P
 
@DavidPacker I come from c++/java background. I know what you mean
 
on the other hand, starting from JS it's easy to jump to most other langs
 
8:16 AM
It is a unique language feature. Once you get it, you get it
 
@towc I looked up the getters, it seems like that's the encapsulation I was thinking about.
 
@DavidPacker JS has prototypal inheritance. Read about it. Understand it. Live it.
 
yup, that's how you make private variables and all sorts of weird pre-existing functions that made no sense beforehand in javascript
 
@littlepootis I know what that means, as a matter of fact. I read about it a lot.
 
JS is love, JS is life
 
8:17 AM
Anywho, thanks for the discussion, I gotta run now.
Take care, guys.
 
try not to fall in an infinite loop :)
 
@DavidPacker good luck
May the 5th be with you
 
Hi
 
A very important thing happened today, many years ago
something to be remembered in history
changed so many lives, future generations will remember this for years to come
and after they forget they'll still be affected by it
it's my dog's birthday :D
 
any idea on why token is not created using this piece of code?
    if(bcrypt.compareSync(request.body.password,data[0].password)){
        var token = jwt.sign({
           username: data[0].username,
        }, superSecret,{
            expiresInMinutes: 1440
        });

        console.log(token);
        // return the information including token as JSON
        response.json({
            success: true,
            message: 'Token Created',
            token: token
        });
    }
 
8:27 AM
@towc you should buy him a nice steak to eat
 
why do you assume it's a he? That's sexist, racist and plain wrong
 
@towc before I apologize, knowing you, I should ask if the dog really is a he
 
it's a she
>:(
 
you should buy the bitch a steak
 
now, that's better
 
8:30 AM
Ah well, I had a fifty - fifty chance
 
lol
 
It was a nifty fifty-fifty
 
You should buy the bitch a steak. Bitches love steaks
 
wow
so rude
you put it on a whole other level
 
Why? "bitch" is no worse than "pig", "cock", "tit" or "booby".
 
8:32 AM
bitches love steaks classically means bitches love <new word for dick>
and that's dark...
 
Steak means dick now?
 
that ... kinda fits
 
@Neil well, it's meat. Anything put after "bitches love" which meaning can kind of be transposed to dick, means dick
 
I love how that sentence can be entirely innocent or very sexist
@towc now you're stretching
 
> bitches love dogs
 
8:35 AM
@towc when did you become a feminist?
 
well, you technically just suggested I should buy the dog a dick to have fun with. That assumes 1) dog prostitution 2) dog sex toys ... should I go on?
 
What if I only meant to say that canines enjoy eating beef fillets?
 
@Shea I'm protecting my dog, it's different
@Neil then you don't call her bitch ;)
 
@towc let me mention how stereotypical rubber bones look like
 
(this is all a joke btw, don't take me seriously)
 
8:36 AM
damn online doggy predators
 
@towc bitch means "female dog". That's the joke
 
@Neil that's what the media wants you to think
#anarchy
 
@towc ok, just telling ya in case you didn't pick up on it
 
On invoking fs.readFile(), I could not understand the flow of events getting generated and the call back getting executed here..
 
oh... hi again
 
8:38 AM
@overexchange did you make that image?
 
no
Am learning NodeJS
 
@overexchange I think you think that there is some sort of event bus at work? It is much simpler
The second parameter is a callback
It is "called back" when the work is done
 
What is happening first? event gets generated first(for fs.readFile) or callback get invoked first? in that diagram?
 
How can you pass an event to a callback without having the event?
 
8:42 AM
callback function is generated, readFile is invoked, event is triggered, callback is invoked
 
^
 
^
 
^
 
 
8:44 AM
 
c-c-c-combo breaker
 
 
0
Q: How NodeJS event loop works?

overexchangeOn invoking fs.readFile, I could not understand the sequence from, libuv receiving the request to generating the event and invoking the callback by event loop. Please help me on understanding the flow after invoking fs.readFile() in the below event loop. Does event gets generated in the Event que...

 
Haven't you asked that question already?
 
XY problem? What do you want to accomplish?
 
8:51 AM
 
@AwalGarg You suck. I'm 19
 
@JanDvorak do you actually live in czeckia?
US, right?
 
Czechia, yes
 
going to Prague for the whole week next week, so stoked :P (with school :/)
but I'm guessing you don't live in Prague, right?
 
9:06 AM
I do
 
fancy having a drink toghether?
 
I might. I'm at work right now though
 
:D could be nice. I don't think I've ever met any of us (other than myself?) IRL
 
@SomeGuy weren't you 2 yrs older than me at some point?
 
Is he no more?
 
9:12 AM
Haha, I don't know when your birthday is, so I don't know
 
Is there a way to display javascript at html using a tool to make it look good?
 
@tylerl-uxai Welcome to the JavaScript chat! Please review the room 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.
 
@tylerl-uxai Google provides a syntax highlighter, IIRC
 
thanks
 
@tylerl-uxai in which editor?
 
9:38 AM
!!> 535.2 - 415.6
 
@Shea 119.60000000000002
 
whhhhyyyyyyy
!!> (421.75 - 415.6).toFixed(2)
 
@Shea "6.15"
 
is there a git command to add all the modified files to index?
 
iirc, just commit
 
9:48 AM
I've both files which are untracked and modified...I want to stage some of the untracked files in the index as well as those modified files...
 
iirc, if you commit without any staged files, they all automatically get staged
 
no, you just get status instead
 
okay you mean git commit -a -m first...
then individually add the rest to index...?
 
(I have no context)
 
No wait...
that won't work...
I am trying to stash my changes...
 
9:52 AM
git add -u I believe
 
I have two websocket connections in chrome developer tools, 1-livereload (to reload the page when files are changed) and a websocket to server apis i am using.

Chrome automatically selects the "livereload" websocket every 5 seconds, making it impossible to debug my server websocket.

Any idea?
 
Unlikely. Does the server websocket close and reopen once every five seconds?
 
NO, Its stable. no new packets are excahanged in livereload websocket.
 
start chrome with --remote-debugging-port=9222 flag and use valence instead
 
@AwalGarg I will check it now.
 
9:55 AM
I was quarter-way trolling but sure. That's a good option nonetheless
 
How can i open chrome with that flag? and what is valence.
 
What OS are you using?
 
I'm on osx.
 
doesn't it have some sort of command line? google-chrome --remote-debugging-port=9222 in there should work I think
 
OK, found it /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --remote-debugging-port=9222
 
10:01 AM
cool
 
what is valence?
Thanks.
 
Hello All
I am trying to use gm .
paste.ubuntu.com/16234133

I am getting this error {"message":"object is not a function","error":{}}
 
Anyone help me please
 
10:02 AM
Why should gm be a function?
 
@JanDvorak, i have no idea
 
@AwalGarg Awesome, Thanks man :-)
 
@HituBansal and yet you expect us to make it so?
 
my aim is to please
 
@JanDvorak : i am new to nodejs
 
10:05 AM
@HituBansal there seems to be problem with imagemagick. check this imagetragick.com
 
10:24 AM
iam sorry i see alot of developers write next at the end of javascript function after they pass it as a parameter can someone explains to me what does it mean please: )?
 
nvm
 
That's a right parenthesis. It closes whatever the corresponding left parenthesis opened. Possibly a function call, of which the last argument was a function.
 
that was smiley
 
without a nose?
 
for example this one
router.use(function(req, res, next) {

  // check header or url parameters or post parameters for token
  var token = req.body.token || req.query.token || req.headers['x-access-token'];

  // decode token
  if (token) {
    // verifies secret and checks exp
    jwt.verify(token, 'superSecretForUniverseum', function(err, decoded) {
      if (err) {
        return res.json({ success: false, message: 'Failed to authenticate token.' });
      } else {
        // if everything is good, save to request for use in other routes
what does next do ?
what does next?*
 
10:28 AM
In Javascript, you can pass functions to functions.
 
next is a function
which is defined by your team of some plugin
 
ok in that case what I previously said applies. expressjs specific code. Read expressjs.com/en/guide/writing-middleware.html
 
i see
 
@Kob_24 it's an express middleware function
 
i see i see, thank u.
 
10:36 AM
@AwalGarg Nope, i really like chrome developer tools.
FF tools are not just as easy as chrome.
 
ok?
who are you again?
ohh, valence. no you don't have to use FF devtools for that. just hookup valence and reverse proxy the websocket events to the terminal
I think this is documented. somewhere. maybe.
 
10:56 AM
how to redirect form page to another in angularjs in the controller?
 
you can use this $window.location.href = '/index.html';
 
@Manmohan Welcome to the JavaScript chat! Please review the room 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.
 
ok
 
11:15 AM
@Kob_24 Use $location.path
 
12:02 PM
@BenFortune ohai
trying to figure out why req.body is empty -- find your answer :P still empty
app.use(bodyParser.urlencoded({
	extended: true
}));
app.use(bodyParser.json());
before I define my routes
	res.json(req.body);
in the router.post(path) is always {}
nvm, somehow the forms got enctype multipart
:/
solved.
 
\o/
Not sure why he removed multipart parsing tbh.
 
I'm not uploading files
no clue why it was on the form
(3+ year old code I'm working on)
 
The jump from Express 3 - 4?
 
jumping from CI to express4
so even more fun
 
Ooh, CI as in CodeIgniter?
 
12:11 PM
yes
 
I kinda liked that framework
 
so did I (at the time)
looking at it now... what in the world.
 
Laravel will always have a place in my heart though
CI helped me learn the concept of MVC, for which I'm grateful. Looking back it's a bloated craphole, but stupidly easy.
 
dgk
Hi,
Can i share my Sencha Extjs issue here?
 
@dgk Welcome to the JavaScript chat! Please review the room 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.
 
dgk
12:23 PM
Hi,
In sencha extjs i created nested grid. In nested grid i am using cellediting plugin. When i click on nested grid cell editor is enable and when i click again focus losing out from editor and couldn't able to make selection in grid editor. This issue happening only for nested grid. Could you please give me some solution? Thanks
 
@Waxi yes, its nice
 
@BenFortune sorry to bother, but do you have a decent form validator for node/express? I see there are a few -- I can take the most stars/recently updated or a suggestion from someone who maybe used one.
seems pretty okay?
 
12:39 PM
does someone have experience with clustered node js here? (more specifically this library )
 
@Ming Welcome to the JavaScript chat! Please review the room 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.
1 message moved to Trash can
@Ming Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
Hi, I cant seem to understand why this code below produces undefined. I believe its to do with bindings and references to i. The function is expected to store the value of i at the time the nested function was created. But instead it contains a reference to i.
function wrapElements(a) {
	var result = [], i, n;
	for(i = 0; i < a.length - 1; i++) {
		result[i] = function() {return a[i]; };
	}
	return result;
}
The corrected code is this. but I dont get it. Appreciate some help. thanks
function wrapElem1(a) {
	var result = [];
	for (var i = 0; i < a.length; i++ ) {
		(function() {
			var j = i;
			result[i] = function() {return a[j];};
		})();
	}
	return result;
}
var wrap = wrapElem1([10, 20, 30, 40, 50]);
 
Hint: what is the value of i when the inner function is called?
 
@Ming What's the purpose of that function? Couldn't you just do result[i] = a[i] ?
 
I tested the code with console.log in the for loop
i works well. 0, 1, 2, 3, 4
but outside the loop it replaces and becomes 5
i dont get why does result not store the value?
 
12:53 PM
0
Q: How NodeJS event loop works?

overexchangeFor the below code, var fs = require('fs'); fs.watch('target.txt', function(event, fileName){ console.log('Event: ' + event + ', for file: ' + fileName); }); Console.log('Now watching target.txt'); As per the below architecture, 1) fs.watch() will invoke libuv. libuv will launch a ...

 
@Waxi its a tutorial from effective javascript. teaching IIFE
 
I modified the query
 
@rlemon I sort of knew that they worked their devs hard, but wow.
 
Where should it store the value?
 
result[i] should be pushed to result list correct?
 
12:53 PM
@KendallFrey yea that thread links to others
few of the former devs are speaking out about them
 
@Ming Nope.
 
kinda a shame. the game is so good
 
because I tested return a[i] and it gives the right number. but it's not storing in result
 
I wonder if the fact that they aren't a game dev shop has anything to do with it
 
@overexchange This is like what.. the 400th time you asked that question?
 
12:54 PM
@JanDvorak
why
 
result[i] is inside the function, and it refers to result and i, which are outside the function.
it's inside the function, so it's computed when the function is run
 
i trying to wrap my head around it.
 
@overexchange at 2k rep you should know not to edit a question by deleting it and reposting it
 
@JanDvorak bro at 322:1 q:a i don't even
 
@Ming result[i] is an expression. It's computed and then used. It isn't stored anywhere.
 
12:57 PM
@JanDvorak i see. do you are saying the final result will have all result[i] where i = 5?
 
Yes.
 
ok. result[i] throws away all the i values in for loop. but how come it stores the functions
 
result[i] takes the variable i (which contains the number 5) and the variable result (which points to the array) and uses the former to determine which property of the latter to evaluate to.
The function expressions are in the outer function, and that's when they get evaluated to function instances
identical, because they arose from the same literal in the same context, but distinct.
 

« first day (2028 days earlier)      last day (2923 days later) »