« first day (1634 days earlier)      last day (3313 days later) » 

2:00 PM
@rlemon that seems very inefficient :P
 
@TimSalabim with that said, I'm kind of curious how far you got on your own.
 
@FlorianMargaine ohh it is
 
I tried that and didn't work....
@rlemon document.body.addEventListener('scroll', function(e) {
if( document.body.scrollTop > 0 ) {
logo-img img = "logo_01.png";
} else {
logo-img img = "logo_01_white.png";
}
});
 
mind showing me what you already have?
 
yes sure
 
2:02 PM
logo-img img
what the hell is this?
 
@mash don't be an ass
 
Sorry
 
that is my css?
 
@FlorianMargaine having seen Tim's code... he does need a tutorial
 
@Shea <script type="text/javascript">

$(function(){
$(window).scroll(function(){
if($(this).scrollTop() > 100) {
$('').fadeOut('slow');
$('.logo_h logo_h__img')
.css({'width':'216px','height':'73px'})
.attr('src','logo_01_white.png');
}
if($(this).scrollTop() < 100) {
$('').fadeIn('fast');
$('.logo_h logo_h__img')
.css({'width':'216px','height':'73px'})
.attr('src','logo_01.png');
}
});
});

</script>
 
2:03 PM
@JanDvorak still...
 
noted
 
@TimSalabim that is a "selector"
 
I mean, would you say that to your intern?
 
Yes I would. Actually.
 
Hahaha
 
2:04 PM
you'd be a terrible boss then
 
Tough love...
 
abuse all the interns
 
Don't abuse the interns. Buy them a drink first. Maybe dinner (they can't buy that for themselves).
 
@TimSalabim I respect the attempt, but do you know where it's failing?
 
2:06 PM
No I don't
I think I am picking the wrong selector / css.... but not sure as it worked in my test but not on the live page...
 
kinda... my point is that I just want to point out, that part of figure out why your code isn't working, is figuring out exactly where it's failing
 
I have a feeling it could be due to the logo being embedded in a section which stays static at the top of the web page
 
at a glance I have no idea what's wrong with it, but have you gone as far as ensuring that the event is actually firing?
 
How do I do that?!
chuckles everywhere?*
 
or rather, that the event is actually be caught/trigger. or other words, that your code is even being reached
 
2:08 PM
@TimSalabim breakpoints brah
 
$('').fadeOut('slow');
$('.logo_h logo_h__img')
 
Yes how do i do this?
 
the selectors are not valid css selectors
 
personally, I would use something quick and simple, like placing a console.log statement within the event's response function
 
so by putting that in it will show up in a log file if it fires?
 
2:10 PM
@FlorianMargaine I was in the mood to break down the troubleshoot/debug routine :(
 
Awesome browsers got awesome developer tools (F12)
 
@TimSalabim set a breakpoint at the start of your handler, then do the action that should trigger the event.
 
and so does firefox
 
yeah i've been using firebug / chrome dev tools whatever...
 
If the breakpoint is hit, execution will pause and you can step through your handler.
 
2:11 PM
@Shea there's nothing to break down...
 
The same code fires in my test and works so I know it is either the selectors which are incorrect or something preventing the image from being recognised as scrolling...
 
@FlorianMargaine make a long an tedious point about the importance of something that's probably important, and more importantly missing?
 
here is the concept
this code is not copy-pastable (on purpose)
now take ten minutes and re-write that so it makes sense to you
 
@rlemon it is :>
 
is there another way to do this...
 
2:13 PM
@FlorianMargaine well, ofc it is. it just wouldn't serve him well to just plop it into his webpage.
 
@TimSalabim no. You're doing it the right way, just not quite right.
 
in the template a grey bar comes across and the navigation stays up the top... can we trigger it to change when the navigation becomes static?
 
@TimSalabim no offense, but this kind of response makes it hard to gauge the approach I want to take, as someone willing to teach you
 
@ssube problem is he's from Australia. We're giving him advice but it is very hard to read upside down.
 
Hahaha I am listening and this is much appreciated
 
2:14 PM
@rlemon oh, that explains everything. Instead of (document.body.scrollTop > 0), he'll need (document.body.scrollTop < document.body.height)
 
it's just hard to give appropriate amount of help, if we can't determine your current level of experience
 
My experience is basic and a small amount of exposure over the past few years
 
Australian browsers scroll up from the bottom.
 
Hahahaha @ssube
 
any experienced craftsman should know the tools of his trade, right?
which is why you sure really know and take seriously, at least, what browser you're developing in.
 
2:16 PM
what will be my element @rlemon
@rlemon For the logo in this template....
 
I mean, not to drag on my point, it's just firebug vs chrome dev is a big difference
 
@TimSalabim right click on the element and 'inspect element'
 
@TimSalabim that is the slowest-scrolling site I have ever seen, including pages that have frozen entirely
 
I realize it is a lot of information, but just scan over it
sounds like you need a better understanding of selectors
 
I wonder why that is... Is there a smooth scroll thing set to slow maybe?!
I have right clicked @rlemon & inspected element....

<img src="http://livedemo00.template-help.com/wordpress_52089/wp-content/themes/theme52089/images/logo.png" alt="Chop" title="Creative agency based in UK">
 
2:20 PM
@TimSalabim there's nothing there you can possibly select on
it needs an ID or some other way to uniquely identify the element
 
I see!
 
in a pinch, you might be able to use a unique parent and ask for the first child img, but that element by itself is not going to work
 
Ok I tried that... Then tried parents... "logo pull-left" & class "logo_h logo_h__img"
 
you need the selector!
 
@TimSalabim how exactly did you set up that selector?
 
2:25 PM
@TimSalabim document.querySelector(selector) returns an element corresponding to the selector
 
$('.logo_h logo_h__img')
 
querySelectorAll returns a list of matched elements (if you need more than one)
@TimSalabim if an element has more than one class name and you wanna match against both you 'group' them
<div class="foo bar">
$(".foo.bar");
 
@rlemon good example, thanks
 
guys I have a dumb question. Is there any way to avoid this ridiculous callback sequence?
 
<div class="foo"><div class="bar">select me</div> not the outer </div>
$(".foo .bar"); // I select the inner div, not the outer one.
 
2:26 PM
@corvid promises
 
^
 
How do I do that with mongo, though?
 
bluebird
 
Bluebird's promisify(All)
 
@rlemon but then you wrote $(".foo .bar"); which selects both, correct?
 
2:27 PM
@corvid don't use mongo
 
@TimSalabim naw bro lol
 
@TimSalabim selectors are chains, of sorts, and only return the final link(s)
 
SomeCollection.insert(someObject, function(err, id2) {
  var toAdd = _.extend(otherObject, { someCollectionId: id });
  Collection.insert(toAdd, function(err, otherObjectId) {
    // ... etc
  })
})
 
oh ok!
That makes sense!!!!
 
.foo will give you the foo, .foo .bar will give you the bar, .foo .bar .baz will give you the baz (or every baz, if there are a few)
 
2:29 PM
@ssube thank you, understood
 
since I wrote it...... that's and element containing a bar class that is inside and element of containing the foo class
 
.foo, .bar will give you both
 
great job guys... this patience you got
 
fantastic, thank you!
 
@TimSalabim now I really want to help you with some advice though
 
2:30 PM
I had to come somewhere and ask someone
@shea yes sure. please
 
I guess I work with too many newbies who're not as talented as Tim I would not even care anymore.
 
it's been itching at me, and I kinda already said it, I just don't know if you realize seriously I feel about it
 
@mash you beleive I am talented in regard to coding?!!??!
 
if you really have a thing for this, and want to improve, you have got to really get the debugging thing down lol
 
I got the skills that pay the bills.
 
2:32 PM
@corvid there're libs like when. So you can make promise stuff everywhere it makes callback stacks much nicer
 
and part of that starts with knows your tools, and what you're working in
 
@shea understood... i would like to learn this
 
got the impression you didn't know whether you were in Firefox of Chrome
 
@mash @corvid Bluebird is the definitive promise library
 
2:32 PM
^
 
I use notepad ++ & chrome & now have a jsfiddle... @shea
 
That makes me a super dev guy @shea
 
Bluebird works with meteor? It looks like all the versions are kind of old.
 
Hahaha Chrome with Firebug plugin
 
@TimSalabim I think it would do you a lot of good to learn more about what those tools have to offer
 
@corvid Bluebird is a promise implementation. it has some nice features allowing you to Promisify other libs. bluebird is well maintained, fast, and has more features than any other promise implementation I've seen.
 
@Luggage what's the advantage over when?
 
bluebird works with everything, but I'm unfamiliar with metoer to know if it behaves well with promises without some coaxng
 
Definitley @shea
 
2:34 PM
well, I don't use 'when' but bluebird is one of the most popular used promise libraries, it's known to be faster than competitors, it has good error handling and lots of helpers for common promise-related tasks
 
Definitely ** @shea. I need to understand code more
 
For example, Chrome has dev tools (not firebug, that's Firefox) and features that could've help you answer your own question, because the way you asked it, it sounded like you were on the right track
 
@TimSalabim hit up, you have two minutes to edit messages (see)
 
alright I'll keep that in the back of my head
 
i right click and inspect elements @shea... that is chromes dev tools correct?
 
2:36 PM
yes, but I think FF has that too
 
@rlemon what do i need to edit??
 
IE even has that, now. :)
 
so then it basically just becomes...
 
@TimSalabim looked like this should have just been an edit
 
SomeCollection.insert({
  // ...
}).then(function(err, id) {
  // ...
}).then();
 
2:38 PM
@TimSalabim but not just for Chrome either. not saying Notepad++ is bad, but there's a whole other world of IDEs with great features for JS dev and picking one, all kinda starts with learning what each one has to offer
 
many people get away with a plain text editor for JS. Few IDEs have really good auto-completion for JS.
sublime-text is quite popular. I use atom.io
(i use sublime, too)
 
Thank you for all of your help, I will read up on pages bookmarked...
I have work early in the morning so can't stay up any later!!
 
4
A: Avoiding Callback Hell with Multiple Meteor Method calls on Client

Benjamin GruenbaumSince the other answer suggests RSVP this answer will suggest Bluebird which is actually the fastest promise library when running real benchmarks. Rather than a micro benchmark that does not really measure anything meaningful. Anyway, I'm not picking it for performance, I'm picking it here becaus...

@corvid
 
to be completely honest.... I don't have much room to talk though.
 
Will you all be on again soon?
 
2:40 PM
No need for heavy IDE's anyway I even use LightTable for C++
 
as far as picking a quality one
 
if you want to write real code too, use IntelliJ. If you want to do real work too, use vim.
 
@Luggage bluebird was also made by an old regular here :P
 
@shea @mash @ssube @rlemon Thank You!!
 
SomeCollection.insertAsync(someObject)
	.then(function(id) {
		return Collection.insertAsync(_.extend(otherObject, {someCollectionId: id}));
	})
	.catch(function(error) {

	})
@corvid
 
2:41 PM
I got hooked on using Dreamweaver, solely because I can't find an IDE with a better auto-complete. but as far as quality, I hate the IDE
 
"petkaantonov"? I knew some regulars contributed but that's all.
 
Good night everybody, thanks again. Speak soon
 
night.... gl
 
@Luggage yeah, his username is Esailija on SO
 
2:41 PM
I'm a convert. I used to use async.js (looks at floor in shame).
 
async.js: A great solution if you MUST keep node-style callbacks.
But.. you never do.
 
I don't have to be ashamed. when doesn't seem that bad when looking at performance
 
Async is good for working with "legacy" codebases that don't use promises.
 
2:44 PM
bluebird can .Promisify() them
 
Yeah, but eugh to mixing callbacks and promises.
 
did you mean .promifisyAll()?
 
as long as you are using promises you are doing it right. implementations can be interchanged (some times)
 
In reality you'll always need to convert back and forth because different APIs use different conventions.
 
I really don't want to look up whether or not X method returns a promise or if it takes a callback
 
2:45 PM
So you only need to choose which style you want in YOUR code.
 
@BenFortune bah, both keep messing up... I think it has to do with meteor's abstractions from mongo
 
and yeah, bluebird provides promisifyAll but also nodeify
 
@corvid did you look at this stackoverflow.com/questions/28633187/…
 
which transforms promise code to callback code
 
@Retsam Then either only choose libaries that take your preferred style, or jstu wrap them in a conversion layer.
 
2:46 PM
Ah; I meant to say when working in legacy codebases.
 
thankfully the conversion layer can just be a bunch of promisifyAll
 
Right.
 
Sure, if you're just consuming libraries, you can promisify; but I'm not going to do that within the same library.
 
and yea, every ideal goes out the window when trying to hack on some old code.
 
@rlemon trying that now, but using Collection.insert() instead of Meteor.call
 
2:47 PM
well.. the library can still use which style it wants to internally and then chosoe to expose node-back and promises
I think I'm agreeing. No good reason to use both style in one code-base
just at the exposed api
 
What happens when you call promisify on a promise?
 
You make a black hole.
If you do it three times in a row, the Great Procrastinator is born.
 
If it already knows it's a promise, you can just call it regardless without worrying what the library is returning
 
just keep the code simple and beautiful and nice and lovely. It's important that you want to return to your code.
 
No, you promisify methods
If you want to handle a result and don't know if it's a normal value or a promise you can Promise.resolve(thatValue)
 
2:51 PM
I know, I meant if it knew it was already a promise you could promisify the whole library with promisifyAll.
 
I don't see anythign in the docs, yet, indicating if it's smart enough to not re-promisify.
Even if it was, I'd just stick to promisifying your library once only.
 
I was just going off what @Retsam said, about having to check if the library method returns a promise or a callback
 
once at startup, or wrap a library in a module like:
//fs-promise.js
module.exports = require('bluebird').promisifyAll(require('fs'));
 
Doesn't bluebird modify the object it accesses? Re-exposing it seems futile.
 
yea.
 
2:55 PM
@Luggage Fun fact, this doesn't quite work.
 
You could just do the promisifyAll in your bootstrap and require('fs') later.
 
promisifyAll() should be safe to run twice, actually, since it makes new methods
 
Promise.promisify = function (fn, receiver) {
    if (typeof fn !== "function") {
        throw new TypeError(NOT_FUNCTION_ERROR);
    }
    if (isPromisified(fn)) {
        return fn;
    }
    var ret = promisify(fn, arguments.length < 2 ? THIS : receiver);
    util.copyDescriptors(fn, ret, propsFilter);
    return ret;
};
the second if should answer your questions
 
@FlorianMargaine Was just about to paste those exact lines >.<
 
ok, so no good reasons left to not just require('fs') and not worry about accidently re-promisifying
simple.
 
2:57 PM
@FlorianMargaine I can't make out any checks in promisifyAll though, since it doesn't call promisify.
 
You don't need to. It's indempotent (it can be called multiple times without doing bad things).
ohh, maybe I misunderstood what you are saying..
 
unrelated question; in mocha, how do you test that something did throw an error?
 
@BenFortune yeah it's a little harder to find
 

« first day (1634 days earlier)      last day (3313 days later) »