« first day (1571 days earlier)      last day (3394 days later) » 

9:00 AM
Moreover, I am using require.js
 
It also depends on your version. Some build on <= 3.0 and don't have LINQ (3.5) or TPL/Task (4.0). Though honestly anything below 4.0 is practically ancient.
 
@RoelvanUden sending in a minute
 
@BenjaminGruenbaum Ah I won't be able to make it before tonight, unless it's really short. At work and all that. :-)
 
@RoelvanUden it's a JavaScript test - not a C# one. Also it's pretty short.
 
Ah, ok! :-)
 
9:06 AM
I want to benchmark a response we got from someone who says they're from a similar background as well as measure the test's difficulty, it's the first out of several and it's supposed to not take very long to do
 
I got it. I quickly skimmed it, but I'll probably need ~15m to do that. So that will definitely be tonight. :-)
 
can I haz it?
 
@FlorianMargaine I think you already got it at some point but sure, send me an email
 
florian at margaine dot com
 
9:12 AM
ty
ah yeah, this one
 
Yeah, it has proven to be a good first round :)
 
Want a second round question?
 
Well, usually our second rounds are implementing patterns to make sure people understand them. Usually it's 2 or 3 implementations.
 
9:16 AM
oh
 
Lemme randomly get 3 patterns from our doc brb.
 
like which pattern?
k
 
The Math.random() gots say you get: router with states, and observable
Router with states is something that would work like:
var router = new Router(); // can be just Router
router.when("/", function(params){
    // do stuff here
});
router.when("/foo", function(params){
   // do stuff here
});
router.go("/foo", {}); // navigates to "/foo".
You may but don't have to support the HTML5 history api
Observable is an event emitter with a .map method.
 
so I have to implement this router?
 
Hi, I am looking for some quick help for me. I am new with angularJS. I work on some app and need to add new page with controller. My problem is with controller. Getting error message Unknown provider: financialPlanProvider <-NaNinancialPlan which I don't understand. I can't find error :( can you help me? Code of controller is here: pastebin.com/BbvR6CZS thanks for help
 
9:20 AM
@goldJ 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.
 
Yes, writing stuff about observable. Hold on
var o = new Observable(); // can just be `Observable()` don't have to use constructor
o.on("foo", function(){
 // event handler
});
o.on("bar", function(){
   // handle event
});
o.on("baz", function(ev){
    return ev * 2;
}).map(function(twoTimes){
    return twoTimes * 2;
}).map(function(fourTimes){
    return bar.on("foo"); // bar is another observable, wait for it, this is the tricky part
});
 
anoyne can tell me what I require to do as said here.. I am new to js so... not getting what he said
 
The router is client side but that's pretty close. Also don't use your older code that's not fair :D
 
yeah... just saying I've already done this...
 
9:22 AM
The observable one is harder anyway :)
 
yeah it looks like so
 
I don't care how the syntax for an observable waiting for another observable looks like as long as it can do that.
 
I don't understand what .map does here...
nor where bar comes from :P
 
Let's simplify things.
 
@BenjaminGruenbaum you can send by email if you prefer
 
9:26 AM
var o = new Observable(function(next, done){
    // this is your creation source, you can call next here to signal the next value and done
    // to signal that this observable has finished, for example:
    next(1); // generate 1
    next(2); // generate 2
    next(3); // generate 3
    done(); // finished
});
o.map(function(value){ // will get called 3 times for the above
    return value + 1;
}).map(function(value){
     // same values as above + 1 - so 2, 3, 4 instead of 1, 2, 3
}).map(function(value){
Should do this, doesn't have to look particularly pretty, you can assume throws don't happen and whatever else you need to assume.
 
@BenjaminGruenbaum Wouldn't you need .flatMap if you want to flatten a 2d observable stream?
 
@SecondRikudo you, same exercise. No flatMap, in this exercise .map flattens because it's an exercise and not a library...
 
Any short explanation on requirejs and browserifyjs?
Why should I use them?
reading docs now
 
what do you use to use multiple js files and organize your code? js "namespaces"?
 
@Mr_Green Because modules are preferable to leaving global variables everywhere.
 
9:30 AM
so it just to keep the code structure right?
 
@Mr_Green And scoped, and namespaced. Yes.
 
I <3 emacs
 
Nice theme
 
oh, that's just monokai
 
@BenjaminGruenbaum I like Darcula better
 
9:35 AM
Darcula you mean
 
cc @Zirak ^^^
 
@BenjaminGruenbaum Yeah
 
yeah sorry @BenjaminGruenbaum but I don't understand what this has to do
 
@FlorianMargaine what part?
 
9:39 AM
all of it...
 
Start without assuming assuming other observables - basically an event emitter with .map - when you're past that the interesting part is assimilation.
 
I did this but I think it's not related to it at all:
function Observable(fn) {
    return {
	map: function(v) {
	    fn(console.log.bind(console), function() {});
	}
    };
}
but... an event emitter with .map doesn't make sense
 
@FlorianMargaine You aren't mapping an event emitter
 
.map probably returns a new observable (although it doesn't have to - it can mutate the existing one - it's just harder if you do)
@FlorianMargaine you're mapping the result to another result.
 
You're mapping a stream of "values" to another stream of "values"
 
9:40 AM
@SecondRikudo take a shot at it too :)
 
@BenjaminGruenbaum What's up?
 
nope... still doesn't make sense
 
@SecondRikudo the exercise I gave Florian
 
@BenjaminGruenbaum Link
 
@FlorianMargaine look at the example code and think about it some - I tried finding a less common pattern
 
9:42 AM
maybe the example is bad?
dunno
this is the final code?
var o = Observable(function(next, done){
    // this is your creation source, you can call next here to signal the next value and done
    // to signal that this observable has finished, for example:
    next(1); // generate 1
    next(2); // generate 2
    next(3); // generate 3
    done(); // finished
});
 
@SecondRikudo make this work chat.stackoverflow.com/transcript/message/21318533#21318533 implement an Observable object
@FlorianMargaine this is how you create it, you can then map the values it yielded (1 2 and 3 in this case) to other values (for example 2 3 and 4 by adding 1 to each)
 
Why wouldn't you use an event string?
 
nope, still don't get it
function Observable(fn) {
    var values = [];
    return {
	map: function(v) {
	    var i = 0;
	    fn(function(v) {
		values[i++] = v;
	    }, function() {});
	    return values;
	}
    };
}
that's not at all what's required right?
 
.map returns a new observable and not an array but that's a good start :)
An observable doesn't know all its values in advance, for example here is an observable that yields infinitely many values asynchronously :
var o = Observable(function(next, done){
    // this is your creation source, you can call next here to signal the next value and done
    setInterval(function(){ next(1); }, 1000);

});
Yields the number 1 every second.
 
ah, so in instances in which event strings would be impractical
 
9:49 AM
Doing o.map(function(v){ return v + 1; }) returns an observable that yields 2 every second.
 
"dynamic events" for lack of a better term
 
@BenjaminGruenbaum I need to think about how next() fits in
Alright lunch, tackle this after :D
 
@SecondRikudo it's not an "easy question", it's not a first rounder for sure and it takes people time to figure this out. Don't expect to figure it out in 2-3 minutes - at least I didn't :)
 
is it something like this you want?
function Observable(fn, values) {
    values = values || [];
    return {
	map: function(v) {
	    var i = 0;
	    fn(function(v) {
		values[i] = (values[i] ? values[i] : 0) + v;
		i++;
	    }, function() {});
	    return Observable(fn, values);
	}
    };
}
wait, you want something yieldable?
 
This is getting closer, although remember we don't know all the values in advance.
An observable is like an asynchronous generator that lets you know when the value will be ready instead of you being able to call .next from the outside - like an event emitter.
 
9:53 AM
oh, so you want us to implement yield without es6?
it looks like you want us to implement something common like promises or yield... but you're trying to say it another way
 
No, what I want is harder than yield, I want async yield.
 
a way I don't understand though, I'm afraid
I still don't know what you want the API to do...
 
The ES construct that supports these is an ES7 for..on loop - I mainly wanted something you wouldn't know (in advance) :)
 
indeed, I don't know what for..on does
 
@FlorianMargaine well, what I said above, you can generate values by calling next in the constructor and then map them to other sequences.
 
9:55 AM
and I still don't know, because your exercise confuses me :P
 
Because it's a new abstract concept - deal with it :D
For example - imagine something like the following:
 
in the real code
 
*arbitrary sunglasses fall*
 
is it really next(1); next(2); next(3);?
 
It can be, but it's usually more like:
    var keyDowns = new Observable(function(next, done){
         document.getElementById("myInput").addEventListener(click, next);
    });
    var valuesOnKeyPress = keyDowns.map(function(ev){
         return ev.target.value;
    });
    var autocomplete = valuesOnKeyPress.map(function(ev){
       return new Observable(function(next, done){
             ajax("/autocomplete", function(res){ next(res); done(); });
       });
    });

    autocomplete.map(function(results){
         myDiv.innerHTML = myTemplate.render(results);
This is autocomplete, basically.
 
9:59 AM
oh, I think I'm starting to understand the concept...
 
it's basically .on, but with an end, and when it's over it returns the values it emitted
 
Take your time, like I said this is something that takes people a few hours to implement.
 
is that it?
 
@FlorianMargaine yes, it's possible to end it for consumption but you don't have to - while the observable for the autocomplete (the one with the AJAX) ends each time - the more general one doesn't - it keeps listening for events forever.
 
10:00 AM
yeah the keyDowns one never uses done
 
:)
When you're done send it by email to not spoil it for Dor
 
Dor?
but yeah now I got an idea of what you want to do, not gonna do it now
I got work to do :P
 
SecondRikudo.
@FlorianMargaine lame.
Oh no he's making me think :P
 
nah I mean, as you said, it's not 5 minutes as I thought it'd be. So need to work before :)
 
I bet Zirak could do it in 5 minutes, just sayin :P
But yeah, it's about 30 minutes to an hour or two
Our interviews don't take 5 minutes
 
10:07 AM
@Zirak is amazing tho
@BenjaminGruenbaum wait... isn't it basically chained event emitters? as in, on(function(emit) { emit(foo); return new EventEmitter(); }? also... isn't it FRP?
 
Yes, and yes :)
 
Note that the newly returned event emitter should be aware of the old event emitters' events. For simplicity there is only one event type
 
yeh ofc, didn't pass the arg to new EventEmitter because I didn't think much about it, but it has to be something
but anyway... that's really complicating things. You could've said it the way I just said since the beginning :P
 
I know I could but a big part of the exercise is realising what the problem is and understanding it. Once you do implementation isn't nearly as challenging.
 
10:25 AM
greetings
 
yeah... but you're just trying to be tricky. Saying it another way, you still understand it
 
I'm not trying to be tricky, I'm deliberately not using the commonly used terminology so you need to figure out what you're making on your own. Understanding the pattern and recognising it is a great cargo cult filter :)
 
I don't buy it...
 
does anyone knows a good tutorial about posting a imput file with ajax + php
iºm having a hard time with this
iºm posting but i´m not able to pull the image from my .php file
and i don´t know why
 
10:43 AM
@BenjaminGruenbaum Am I allowed to use promises?
 
@SecondRikudo sure
 
(TBF I'm probably not familiar enough with Observables and RX to implement one, but I'll give it a shot regardless :P)
 
I'm not expecting perfect
 
@BenjaminGruenbaum link to php rfc process on esdiscuss?
there's still no search on esdiscuss...
 
10:52 AM
ty
 
Many programmers can't get past fizzbuzz. Probably way too challenging for an interview question unless you have a lot of time on your hands to select candidates
 
Hey everyone.
 
or you want senior candidates...
 
    if you have the following ajax:

            var serialized_data = $(this).serialize();
        $.ajax({
            type: "POST",
            url: url,
            data: {
                request: 'ajax',
                form_data: serialized_data
            }, // serializes the form's elements.
            success: function(data)
            {
                 // show response from the php script.
            }
        });

        return false; // avoid to execute the actual submit of the form.
 
@FlorianMargaine that. @Neil also I don't expect people to finish it - I expect them to give it a shot and get something done.
 
10:55 AM
And you then in PHP have the following result: user_id=118&location=Marc&date=02-02-2015&hour=5&minute=30
how would you get each specefic value?
 
@BenjaminGruenbaum I suppose that can still be telling
 
@FlorianMargaine $_POST just contains comp_id = user_id=118&location=Marc&date=02-02-2015&hour=5&minute=30
or in this case: form_data = "user_id=118&location=Marc&date=02-02-2015&hour=5&minute=30"
 
@Neil I don't expect people to implement promises either when I tell them to do that - I can't do that in a short time span - I expect them to recognize and understand the problems and to take a shot at it
 
@BenjaminGruenbaum I'm getting close :D
I have o.subscribe() working
o.map() too (can't return observables yet)
 
11:01 AM
Looks like you have the fun part waiting for you :)
 
i fyou're anything like me, youre miles away! i usually think im getting close and then have a eureka moment as to how things are meant to work together etc and realise ive done thing totally wrong and convuluted
 
J82
$('.slick-slide img').load(function() {
var imgHeight = $(this).height();
$('.slick-slide img').parents().css('height', imgHeight);
});
How can I attach that to the resize event? Sorry, I ran out of the number of questions to ask.
 
crl
!!mdn onresize
 
J82
I tried making a function out of the whole thing and using this but couldn't get it to work: $(window).on('resize', functionName);
 
crl
11:13 AM
start a fiddle for it
 
"ran out of the number of questions to ask"? There is a limit?
Holy shit your Q/A ratio lol
 
J82
Making a fiddle now...
Yeah it's embarrassing lol. I've been learning though
 
@BenjaminGruenbaum here's what I have so far :P
export class Observable {
    /**
     * @constructor
     * @param {function(function(Object), function)} creationSource
     */
    constructor(creationSource) {
        this.callbacks = [];
        this.creationSource = creationSource;

        creationSource(this.emit.bind(this));
    }

    /**
     * Map observable to another observable.
     * @param {function(value)} callback
     */
    map(callback) {
        var newObservable = new Observable(this.creationSource);
        newObservable.originalObservable = this;
(no done so far yet either)
 
@J82 better use "height: inherit" in css
 
Does it assimilate Observables?
 
11:17 AM
Not yet
But it shouldn't be too hard
just recurse up the observable chain and call emit on that.
 
I wonder why you're creating the new observable from the same creation source in map and defining a mutator - I recall something like this when I implemented it:
map(callback) {
    return new Observable(next, done => {
          this.subscribe(function(val){ next(callback(val)); });
          this.end.then(done);
    });
}
Or something like that, IIRC, just wrote it in chat.
(Where next also assimilates observables, and is the one doing that)
Or something like that, don't really remember it's been a while since I implemented observables :D
 
@BenjaminGruenbaum next is undefined in this example, or am I missing something?
 
@SecondRikudo next is the new observable's next.
Oh whoops, I meant (next, done) => there not (next, done =>
 
Ah, okay, that makes sense
 
morning.
 
11:22 AM
Ah okay, so you went with the opposite approach
Which makes more sense really
 
Don't want to ruin your thunder - make assimilation work :)
 
@BenjaminGruenbaum would you do something like this: jsfiddle.net/kelunik/6e0umjsf ? :-P
 
@BenjaminGruenbaum Your solution is more efficient than mine (O(1) vs O(n))
But I'll continue my way for now just for kicks :D
 
@kelunik you don't want to know what I really think about that :P
data-id is an antipattern that demonstrates lack of understanding of how separation of concerns works in frontend code :P
Also when you do this:
HTMLCollection.prototype.forEach = function (callback) {
	Array.prototype.forEach.call(this, callback);
};
You really mean to do this:
HTMLCollection.prototype.forEach = Array.prototype.forEach;
 
My solution is gonna be ugly as hell :D
 
11:27 AM
@BenjaminGruenbaum Yes, my frontend code is really ugly, I know. :P
What I want to do is ensure all messages are displayed in the right order, but they don't necessarily arrive in the same order.
 
@BenjaminGruenbaum nope, I don't think it's entirely possible with my approach
Gonna have to shift to yours
 
@kelunik insert them in your messages array in the right spot?
@SecondRikudo go for it :)
Start by just teaching next in the constructor to assimilate an observable.
Also, you can use attr in css @kelunik
 
@BenjaminGruenbaum I'm still not sure how to cause done to end the observable.
But I'll start with that, sure.
 
For the exercise - It's just a signal so observables consuming it know when to resume consuming their next results.
 
@BenjaminGruenbaum developer.mozilla.org/en/docs/Web/CSS/… < Not supported yet.
At least not for integers, which are required here.
 
J82
11:35 AM
Damn, this was the best I could do. I'm not sure why it's not working in the fiddle but image's parents' heights are supposed to match the height of the image. jsfiddle.net/8dudym5s
 
Works on Chrome and FF :D That's browser support
Oh, you're right, nevermind then
I'd just do the insert at a JS level though.
And then update the UI
 
That's what I currently do, but it looks pretty ugly, see here. :-D
 
Why the query selectors? I want to cry -_-
The PHP equivalent of what you're doing is having a single .php file for all the logic and for the templating in one place.
Create a Message object to manage the state of well... a message that takes your server data (which is a DTO) and contains message relevant stuff.
 
crl
Why can't we use forEach on the result of document.querySelectorAll("...")?
 
Then have a MessageView view that handles presenting a message which contains the logic about presenting messages.
Your messages are an array of messages sorted on message id, when a new message comes you insert it in the correct place in the sorted array (probably by linear search from the end - if you feel clever you can binary search or interpolate but that's overkill IMO)
Then, you update the view. Which shouldn't care about why the messages changed order just that they did.
 
11:42 AM
Alright @BenjaminGruenbaum I think I'll continue doing this after I get a bit more understanding on observables :P
I feel like continuing to prod this won't do much good... for now.
 
@SecondRikudo well, I'm glad I made you think :)
Nice work
 
@BenjaminGruenbaum Oh yeah, it's only yesterday I was exposed to Observables, it blew my mind about as much as Promises
I need to use those in one or two projects to gain exp
BTW @FlorianMargaine this might interest you
I really like the whole "Promise is kind of a private case to the more general Observable"
 
Naa, that's totally FUD :P
Promises are not a private case of observables any more than a number is a private case of an array of numbers.
x is not a private case of [x,y,z] or of [x] - it's just a single value.
Observables are just the plural of promises.
 
J82
12:16 PM
Anyone know why the code inside the `load resize` event isn't firing?

$(window).on('load resize', function() {
$('.slick-slide img').load(function() {
var imgHeight = $(this).height();
$('.slick-slide img').parents().css('height', imgHeight);
});
});
 
@BenjaminGruenbaum Do you recommend backbone.js?
 
No, backbone is horrible.
Avoid it like the plague
 
Or any other framework for that model view structure?
 
Just use JS objects for the model layer and JS objects for the view layer and HTML as templating.
Oh, you can try out Aurelia it just came out last week that could be nice
Aurelia.io
 
12:46 PM
hello. can anyone recommend a lib for rendering big, directed acyclic graphs?
 
@Nebril 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.
 
in the browser, I should probably add
 
How sparse are they?
I think someone compiled git to JS :D
 
Using emscripten?
 
@BenjaminGruenbaum You're a fan of Aurelia now?
 
12:56 PM
Not sure yet
Considering it
 

« first day (1571 days earlier)      last day (3394 days later) »