« first day (2344 days earlier)      last day (2827 days later) » 

00:08
['Delta', 'alpha', 'CHARLIE', 'bravo'].sort((a, b) => +(a > b) || +(a === b) - 1);
Can anyone tell me whats going on with the: +(a > b) || +(a === b) - 1);? And why it works?
Fancy way of 1 or 0 or -1?
+(a > b), + converts whatever comes next to a number, and a > b returns either true or false which, convert to number as 1 or 0
!!> +(2 > 1)
@BenjaminGruenbaum 1
!!> + ( 1 > 2)
00:10
@BenjaminGruenbaum 0
!!> + ( 'Delta' > 'alpha')
So, +(a > b) is 0 if a <= b or 1. The other side tests for equality, if they're not equal and not less then it returns 0 - 1 which is -1, if a is bigger it returns 1 and if they're equal it returns 1 - 1 === 0
So, it's a clever way to return 1 0 or -1 (which are values sort expects to get) for bigger than/less than. You could just do sort((a,b) -> (a > b) ? 1 : (b > a) ? -1 : 0)
For numbers you could just do a - b
Fancy, is that the bare minimum for sorting strings?
No, you could just not pass anything to .sort
!!> ["D","E","A","C","B"].sort()
00:13
@BenjaminGruenbaum ["A","B","C","D","E"]
The author is just being 'clever'
> The author is just being 'clever'

Thanks MDN
lmao
It's a wiki, you know
Promise.using() and promise.disposer() looks like a more involved one to do..
Thanks for the explanation. I know, I skipped the relevent parts and scanned the examples since my .sort((a, b)=> a> b); didn't work;
@Luggage Do you like RxJs?
00:17
that's not RxJS. I have nothing against it. looks neat. Never used it.
I love RxJs. It is worth trying out if you like functional programming.
Just look at all of these functions you will never use: rxmarbles.com
You could even write code that no one else can read. Take this gem:
i like the interactive docs there
fetchProductsArrayFromSkuArray(skus: string[]) {
    // console.info('fetchProductsArrayFromSkuArray',skus);
    return Observable.forkJoin(skus.map((sku) => this.skuFetch(sku).map((p) => new Product(p))));
  }

  skuFetch(sku: string) {
    return this.http.get(this.productUrl + '/' + sku + '?locale=' + this.locale, { withCredentials: true })
      // .retry(1)
      .map((response: Response) => {
        if (response.status !== 200) {
          throw new Error(response.json());
        }
        else {
@Luggage The docs are actually good reactivex.io/documentation/operators/zip.html
would that "return" [sku, sku, sku] ?
or 'emit' or whatever.
It takes [sku, sku, sku] and returns [ProductObject, ProductObject, ProductObject]
00:27
+1 for rxjs though i haven't really used it though
modelling user interaction as a stream is interesting
I've gotta pair with a JavaScript candidate, and they're a no-semicolon dev...
  async fetchProductsArrayFromSkuArray(skus: string[]) {
    let skuData = await Promise.all(skus.map(sku => this.skuFetch(sku)));
    return skuData.map(p => new Product(p));
  }

  async skuFetch(sku: string) {
    try {
      let response = await this.http.get(this.productUrl + '/' + sku + '?locale=' + this.locale, { withCredentials: true });

      if (response.status !== 200) {
        throw new Error(response.json());
      }
      else {
        return response.json();
      }
    }
    catch (err) {
@jake ^
ask him what this returns :p
return
x ++
I see the vaue in RxJS, but your use feels like normal every day data-fetching and it feels like overkill
@monners don't you guys have standards where you're at?
coding standards I mean
00:30
@Loktar Yep
that's not something enforced (I mean one way or the other?)
His code test would light up like a christmas tree with my linter
haha
@Luggage Property 'filter' does not exist on type 'Promise<Product[]>'. :(
this[subProduct] = this.fetchProductsArrayFromSkuArray(product[subProduct]).filter((x) => x.sku);
ohh, i didn't say it would be compatible with other rxJS code..
it's promise-based.
00:32
How would I pass that? Then?
well, if all your code is rxjs, don't really use mine.. but yes. .then.
or async/await like i was demoing
I mean, its always good to learn. Its an angular app and its pretty functional
Yea, that wasn't a "you should use my code" but just a translation to my style, just for shits and giggles.
let products = await fetchProductsArrayFromSkuArray(...);
let filteredProducts = products.filter(x => x.sku);
"The keyword 'await' is reserved" hmmm
is can only be used in async functions. typescript supports them.
00:41
"Cannot find name await"
this[subProduct] = await this.fetchProductsArrayFromSkuArray(product[subProduct]);
    console.warn('this[subProduct]',this[subProduct]);

    return product[subProduct].length
      // && this.fetchProductsArrayFromSkuArray(product[subProduct]).subscribe(
      //   (pds: Product[]) => {
      //     // console.warn('hpds',pds);
      //     // console.warn('hpds',pds.map((p) => p.sku));
      //     this[subProduct] = pds.filter((x) => x.sku);
      //   },
      //   (err) => console.log('Something is wrong..', err));
the function that is in needs to be async
but.. don't really change that or you'll have to keep making changes..
ohhhhh
that fixed it, but the chain is sooo long
Lol, adding async to all the functions worked!!
um. it made them all return promises..
Hey, those are all observables anyway! What are you trying to pull?
I trusted you @Luggage
00:48
...I thought they would be promise objects. Does async return observables?
no.
promises.
My bad. From medium.com/javascript-scene/… it seems that I should be using async anyway since I am not returning a stream of values.
well, you can't just replace random bits of code with rxjs with it..
you can use promises and observables together, but it sounds like you are just pasting in my code and then wondering why it doesn't work
Nah, I wanted to work with it because I have been meaning to get educated on async/await.
ah
well, i can't help you with the integrating with rxjs part since I don't know that.
Also, it's time to try to close the laptop for a bit
00:53
👌
Its better to start from a fresh jsbin anyway
01:28
Hi
I need a little help to understand better solution in my case:
I am creating a three.js game
I am doing bullets collision
atm it is detected on client side (three.js raycaster)
but I wonder if I should instead detect it on server side (so server decides the collision)
what do you suggest?
that is generally better
but to do it on server side how do I calculate the 3d collision?
(it was pretty simple on client side with three.js raycaster...)
but now I am confused
same way as you do on the client
just a bit more complex
you mean I have to load the whole three.js on server side?
noooo
you just want to run basically the same simulation
on the client and the server
but the server is the one you should trust
01:37
yes but I was using three js functions to detectect collisions
I don't know how to do it without three js
this is my actual problem
for example I was using stuff like:
var intersections = raycaster.intersectObjects(objects);
pull in something like cannonjs.org
it looks interesting (you mean pull on server side right?)
Alright the time has come where I got to make up my mind
How do I get the user's location without using a 3rd party web service :|
01:52
@Alesana is navigator geolocation an option for you?
Nope don't want it to need permission from the user
I think I will end up making my own API and letting people who use my app link to it
then just keep my database updated
I need to undo my last commit in git (not pushed yet)
because I forgot to exclude some files through .gitignore
git reset HEAD~
@rlemon Hi, and thank you. I was not sure :) stackoverflow.com/a/19303993/5638869
then I have to restart from git add .
or git commit -m "blabla"
?
sorry, I'm tired. of course git add .
I guess I'll forfet gitignore again
> 86 mile high volcanic plume on Io, one of Jupiter's moons. Taken by Galileo.
02:07
now without glasses I see nothing
some days I thought to kill myself
maybe don't?
all these efforts... to achieve nothing... just a fucking noob
who not even understood how to make a simple 3d game
xD
Wow. 940m is surprisingly good.
I missed this chat <3
02:51
getInitialSlide(): number {
    return +(this.videos.length && this.videos.length - 1 <= 0)
      + +(this.images.length && !(this.images.length < 2) || 1);
  }
Can anyone give me a second pair of eyes on this?,
I want to return a number that represents the second image ie this.images[1]
--but only if there is >= 2 total images.
after that I concat the video and image array.
I need to stop with these one-liners is the problem
this is insanity
Yeah, I am throwing it all out now.
this.videos.length && this.videos.length - 1 <= 0 is the same as this.videos.length === 1
If statements never went out of style 😎
03:12
@phenomnomnominal The proper way:
getInitialSlide(): number {
    if(this.images.length >= 2) {
      // If we have 2 or greater, return the slide after the last video
      //  OR return the second slide
      return this.videos.length || 1;
    }
    else {
      // If we have ANY videos, videos.length
      //  will return the slide after the last video
      return this.videos.length || 0;
    }
  }
03:25
Hey everyone, I'm working on an assignment where we need to use prevent default for an event listener. The link keeps hopping to the next page, how do I get "preventdefault" to work?
(function() {
    var anchorElement = document.getElementsByTagName('a');

    anchorElement[0].addEventListener("click", function() {openImageInCurrentWindow(this)}, false);

    function openImageInCurrentWindow(element) {
        // create new image element
        var newImageElement = document.createElement('img');

        // assign the link passed to the image element source
        newImageElement.src = element.href;

        // add as the last element to the body
        document.body.appendChild(newImageElement);
03:46
function() {openImageInCurrentWindow(this)} <- the browser will pass you the event as an argument to this function
you can then call preventDefault() on thew event to prevent the default behaviour from activating
oh dind't expand the paste
@bloopletech Can't you explain, where does prevent default go?
I also tried like this:
right your problem is that 'this' in the callback is not an event object; this refers to the node , not the event
I'm not going to tell you what to write because I'd rather you work it out yourself
oh, I see
the callback you pass to addEventListener can take an argument, which is an event object
the event object has a preventDefault() method that will do what you want
it should be easy enough to google and look for examples
So, instead of passing "this" I just pass the anchorElement?
03:49
no, the anchorElement doesn't have a preventDefault function. The preventDefault is on the event, not the anchor/node
Wait
hmm, I'm really confused. Because it did work that way for another example
'this' can mean different things depending on the context
so if you just copy paste something with 'this' it might not work the same way
So, for another example I did an html event listener like this:
<p><a href="images/demo.png" onclick="openImageInCurrentWindow(this); return false" title="Demo Image">Demo Image Link</a></p>
here the return false prevents the link from switching pages. The "this" passes the element so I can get the link to update the image source.
return false doesn't work when you're using addEventListener, it only works when you're setting onclick directly, like you are doing in that example
You need to understand how event handlers actually work, for which there is lots of goof info online
Yeah, I find lots of good examples of the the onclick even listener, but I haven't found anything that works for prevent default that I need
that's simply just return false. Is preventDefault a built in method of the browser?
03:57
not just examples, you need to learn the actual logic behind them
otherwise the assignment isn't serving it's purpose. This looks like a good link: eloquentjavascript.net/14_event.html
it even has an example of the exact solution you want. But please do read the whole page. Sorry if I sound rude but I'm also busy with my work :D
<a href="https://developer.mozilla.org/">MDN</a>
<script>
  var link = document.querySelector("a");
  link.addEventListener("click", function(event) {
    console.log("Nope.");
    event.preventDefault();
  });
</script>
I assume you're talking about this one
So, that's what I was getting at. Essentially the prevent default is put where the add event listener is not inside of the function
whoops, hold on.
Thanks for your help!
no worries. but really, read the whole page, otherwise you'll never make the big $$$ :P
04:05
man I remember when I thought xcd was awesome
hmmm
(function() {
    var anchorElement = document.getElementsByTagName('a');

    anchorElement[0].addEventListener("click", function(element) {
        // create new image element
        var newImageElement = document.createElement('img');

        // assign the link passed to the image element source
        newImageElement.src = element.href;

        // add as the last element to the body
        document.body.appendChild(newImageElement);

        element.preventDefault();
    });


} ());
This should be correct, but now I can't get the element's href property and pass it to the image
look at the example again, specifically the addEventListener line
The only difference is that they used query selector to get their a tag and I used getelementsbytagname which returns a collection
but they are both holding the a element
function(element) { is wrong, you get passed an event not an element
they aren't the same thing
Oh so event is an actual keyword, not just a variable
I see
So would I use this.href to refer to the element that called it?
04:14
well event is a variable
you could call it bobsburgers
but an event object would still come to it
def look into the docs @bloopletech linked you above
Okay, no I got you.
it would be event.target
for the element
/me is playing forhonor lol
yes, thank you thank you thank you
Thanks @Loktar and @bloopletech
@bloopletech nice to see someone on late helping people actually
usually it's just noise people asking random questions and leaving lol
Yeah, you guys helped a lot. I obviously need to go back over the event listener stuff to get a better understanding of how it all works togethe
05:09
blerg
morning r17
lol :P
i forgot it's friday..
05:40
hi
has someone worked with jest?
06:05
1 message moved to Trash can
@Phoenix Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
1 message moved to Trash can
@Phoenix Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq.
Hello, I am trying to find out a solution for my problem.
Please see : https://hastebin.com/nefonerute.xml
Here I want to replace text inside <p> tags withing <code></code> without effecting the <p> tags outside <code>
How can I achieve this?
06:48
<input
@hellzone 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.
Do I need to use class name or id when I try to get a html element?
I mean some people says never use html Id attribute. Always use $('.button-class') instead of $('#buttonId') when you try to get an element from JS.
07:09
@hellzone it depends on how your element is on your html file. for example
@narutim8 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.
for example, if you have an <div id="test">, then you have to retrieve it with $('#test'), but if you element is <div class="test">, then you have to use $('.test') (be careful these selectors are really vague, you'll have to add more than just '.test' if you have multiple elements with the 'test' class)
08:03
@narutim8 No, that's not what it depends on.
@hellzone @narutim8 You use an ID when you want to identify an element on the page. When there's only one of it on the entire page.
You use a class when you want to categorize an element into a class of items
You don't code your HTML to your selector, you code your selectors to match your DOM.
08:16
@SterlingArcher @Loktar youtube.com/watch?v=DE7oZ9nVFB0 :)
not rebecca black btw
08:40
@Meredith I believe you've met @MadaraUchiha
@Zirak and @Mosho as well.
@rlemon @KendallFrey @Loktar o-o-o-o-o-ooooh yeah!!!
08:59
There should be a penalty for the second link in the day to this video
09:20
I hate it when people rush to answers easy questions which should be closed instead. We're not a remote debug service
09:36
Good morning chat
good morning
if you're lucky enough to be irish than you're lucky enough. happy st Patrick's day everyone!
Nailed it.
Time to send my folks some money so they can buy a Guinness on me :-)
Doesn't need to be Irish. There are events in most (all?) big UK cities.
@Sheepy huh, what do you mean?
Actually, my city also have a parade over half the Earth...
09:40
there are events pretty much everywhere on the earth
well, not everywhere
but in a lot of nations
Yeah in the UK there's celebrations going on pretty much everywhere
I'll just head to my favorite Irish pub tonight
Nice, I'm doing the same this evening as they have a outdoor band and bar going on. Plus for some reason the weather isn't crap today here in (normally) rainy plymouth.
Pissing it down here
Where you at?
09:43
Halifax
Isn't halifax a bank?
Yes, it's also a city believe it or not
Oh yorkshire, your a fair bit from me
Not going to lie I didn't know halifax was a place haha
@BenFortune I believe it. Sheepy is a UK "village" with a population of 1174!
09:47
Haha brilliant
Would any of you know how Aberdeen is like to live in?
It'd mean living in Scotland
yeah, what would that mean? :D
Is that the nice city or the one where your likely to be stabbed?
because I think I found my dream job
09:49
Aberdeen is nice, it's Glasgow you want to stay away from
really, why's that?
apart from the "don't wear blue/green in this part of town" thing
One of the highest crime rates in the uk
Really? I used to live in Birmingham. Have witnessed (and subjected to) my share of minor crimes.......
Glasgow was the place where they gave a syrian refugee a slap on the wrist for abusing his children for attempting to play with other children.
what's the job @GNi33?
09:53
it's not so much about the job, it's about the company
Hey guys can some1 help me with this
2
Q: Put google-drive folders in selectbox

Nayir NolamazI have an application using google drive api. What I want to do is show the child folders in a selectbox. File structure folder1 -folder1.1 -folder1.1.1 -folder1.1.2 -folder1.2 folder2 -folder2.1 -folder2.2 If I am in folder1.1, my selectbox must only show folder1.1.1 and folder1.1.2....

would be a job with brew dog ;)
what's the benefit?
i have an function that shows me the files
function getFiles(){
	var query = "";
	if (ifShowSharedFiles()) {
		$(".button-opt").hide();
		query = (FOLDER_ID == "root") ? "trashed=false and sharedWithMe" : "trashed=false and '" + FOLDER_ID + "' in parents";
		if (FOLDER_ID != "root" && FOLDER_PERMISSION == "true") {
			$(".button-opt").show();
		}
	}else{
		$(".button-opt").show();
		query = "trashed=false and '" + FOLDER_ID + "' in parents";
	}
    var request = gapi.client.drive.files.list({
        'maxResults': NO_OF_FILES,
        'q': query
@towc uhm... beer?
09:54
@towc free beer?
I freaking love brew dog
how can i put the output in select box
@GNi33 All about spitfire
but it would be a job as backend dev for their ecommerce stuff, which is pretty much what I do all day now
but yeah, I'll probably go back to college this year, so it's off the table anyhow. Just curious how scotland would be like
wait, what's your current job?
and did you drop college?
09:56
@BenFortune hm, didn't have this one yet
what's your social security number?
I need an address as well
@towc I'm not an american
Mother's maiden name?
@GNi33 we have one in the UK too :P
@towc No we don't lol
09:56
fell in love with Ballast Point in the US
well, we have an equivalent
Not even close
great IPA
don't we?
the tax thingie
You on about the NI number?
09:57
maybe. What's it stand for?
@towc I'm a full stack dev for online shops right now
national insurance
and no, I didn't
I just never did a master's degree. which I could do now besides work
@GNi33 freelance?
no
09:58
do you regret not having done it?
I work with an agency
not really, but I want to broaden my horizon
refresh all the CS stuff I have forgotten by now, and branch out a little
maybe go into data science, all that stuff
still, it always was kind of a dream for me to work in the UK one day
It's nothing special
Brexit did bend this one a little
Might need a work visa soon haha
you?
10:03
You 😛
ah, okay :D
yep, but I'm actually pretty happy with where I am right now anyways
no town like your hometown
10:39
@BenjaminGruenbaum You answered a question a while ago about promise all (bluebird ones), I currently need to request a bunch of information from an API (around 50-60 calls) which I then save in a database. I'm using the same function for those and then calling it, How would I implement a promise for all these requests that only resolves when all of the nested promises resolve or is there a way I could put all of the requests inside some kind of promise.all?
work in the UK, really? Breeh I denied a job offer on Facebook London just because I didn't want to go there
why UK @GNi33?
51 mins ago, by GNi33
because I think I found my dream job
@jAndy London is a different pace of life for sure.
@BenjaminGruenbaum Here's a sample of the code I'm working on if it helps to understand what I mean gist.github.com/LiamDotPro/fed58b08903004d7e50cc6f5a2385ed4 :-)
@BenFortune don't suppose you might have an idea how I'd construct the above code so it doesn't attempt to load from the database until it's made all the requests
I'm still trying to figure out how to make promises work for my code
@jAndy I also answered Facebook London that I wouldn't move but not because I don't like London, it's a wonderful city in my opinion.
Probably true, I only traveled through a few times really. I'd be more concerned on the british weather and culture :P not made for me
10:50
The weather... well, yes, it's not perfect...
For the culture I loved the museums and the fact they're free and easy to enter
When you're used to museums in other European countries, being able to enter a major one by just walking in is just magical
!!afk tomatoes
I don't half get some shit emails
@lix Don't use for..in on arrays :(
Swap it out for a Promise.each or .map
Are all those articleObj.set methods synchronous?
@DenysSéguret I was more about culture lived by the pleebs, like food, interaction, especially as vegan :-P I mean there is of course a lot of vegan options in a capitol like London, but from what I've heard its way behind like Barcelona or Berlin for instance. And yea, rainy days for like 240 days/year is also tough
@BenFortune I guess so

« first day (2344 days earlier)      last day (2827 days later) »