These are chat archives for FreeCodeCamp/HelpJavaScript

31st
Jan 2019
Brad
@bradtaniguchi
Jan 31 00:04
@JLuboff Your actual code is returning data right?
Jason Luboff
@JLuboff
Jan 31 00:05
Yup
Brad
@bradtaniguchi
Jan 31 00:05
like you called res.send(data) right?
Jason Luboff
@JLuboff
Jan 31 00:05
res.json(data) but ya
Brad
@bradtaniguchi
Jan 31 00:05
Also the endpoint your testing is a post right?
Jason Luboff
@JLuboff
Jan 31 00:05
Correct
Brad
@bradtaniguchi
Jan 31 00:06
hmm
You restarted the test-suite just incase it got messed up right?
Jason Luboff
@JLuboff
Jan 31 00:07
So my other POST test to the same endpoint works. Difference is, I'm expecting that one to fail and send back status 500 which it does.
Ya, its not running continous (I have to keep running npm test lol)
There's something I'm missing..
Actually...I have two POST tests that work lol
Brad
@bradtaniguchi
Jan 31 00:10
Id see if using done works, I believe thats still a thing in jest
also verify the 500 error is actually being tested by flipping the expect so it should fail
Jason Luboff
@JLuboff
Jan 31 00:11
Ya I actually have a test for 200 and a seperate one for 500, using the same data except for one change (which causes the failure status 500)
Brad
@bradtaniguchi
Jan 31 00:12
hmmm odd, yea I'd try out done
Jeff
@jargonfilter
Jan 31 00:14
ok i think i got it down to one line. what do you guys think?
function translatePigLatin(str) {
  return /^[^aeiou]/.test(str) ? /^[^aeiou]+$/.test(str) ? str + "ay" :  str.replace(/([^aeiou]*)(\w+)/, "$2$1" + "ay") : str + "way";
}

translatePigLatin("algorithm");
Jason Luboff
@JLuboff
Jan 31 00:17
@bradtaniguchi nope..done don't do it. There has to be something that I'm missing here. Hmm
Brad
@bradtaniguchi
Jan 31 00:18
@jargonfilter Damn, can't call it beautiful thats for sure XD
Jeff
@jargonfilter
Jan 31 00:18
haha, i was trying to see if i could get it all in a single line
in reality i dont think i'd want to nest things like that all in one line lol
but then again, i really dont know what i'm doing :P
Brad
@bradtaniguchi
Jan 31 00:22
Yea I wouldn't it just makes it really confusing XD, bad enough to have regexes in there, throw in ternaries ouch
Jason Luboff
@JLuboff
Jan 31 00:24
Ok got the test working. Moved it above the one that I expect 500... so that makes me think that while the route fails (and I see the throw from the query does bubble up to the route where its caught in the catch block and thus returns 500).. the server isn't clearing from that error for some reason
Brad
@bradtaniguchi
Jan 31 00:25
@JLuboff Wait, your saying the order of tests matters? Once you get 500 your tests "stop working"?
That sounds really fishy when it comes to the app code
Jason Luboff
@JLuboff
Jan 31 00:26
Ya...not sure whats going on there...time to delve deeper
Jeff
@jargonfilter
Jan 31 00:35
@bradtaniguchi yeah I actually really never used ternaries until now lol
was really mostly an attempt to see if i could condense it as much as possible.
Jason Luboff
@JLuboff
Jan 31 00:35
Hmmm.... I wonder if its from how I'm opening/closing the database connection...
Brad
@bradtaniguchi
Jan 31 00:35
@jargonfilter They are ok, but I'd keep it a rule to format them (using prettier or something) so they don't become a nightmare haha
Jeff
@jargonfilter
Jan 31 00:36
you mean using new lines and such
?
Brad
@bradtaniguchi
Jan 31 00:37
Yes, here's the code you just posted, but pretty-fied:
function translatePigLatin(str) {
  return /^[^aeiou]/.test(str)
    ? /^[^aeiou]+$/.test(str)
      ? str + "ay"
      : str.replace(/([^aeiou]*)(\w+)/, "$2$1" + "ay")
    : str + "way";
}
same code, same "one-line" but formatted so its not 1 line, but still just as concise (if you know what I mean)
Jeff
@jargonfilter
Jan 31 00:38
yeah, i'll definitely do that next time around.
Jason Luboff
@JLuboff
Jan 31 00:44
@bradtaniguchi So it is something goofy in my test file. Just tried with postman. First ran the test that returns 500 then the test that will return 200 without restarting the server and no problems
Brad
@bradtaniguchi
Jan 31 00:46
hmm interesting, how is the test suite affecting your DB tho?
some spooky stuff
Brad
@bradtaniguchi
Jan 31 00:52
I was looking into why my lib code was returning undefined... it was because I basically had no code and just a comment saying "do this later" -__-
Jason Luboff
@JLuboff
Jan 31 00:53
Its opening the connection for the routes to work as supertest runs the server itself as opposed to running off of an already running server (if that makes sense)
Hey now its later!
Brad
@bradtaniguchi
Jan 31 00:54
Yea I just did it, but was smacking myself for letting that be there for god knows how long XD
Brad
@bradtaniguchi
Jan 31 01:15
Idk how I feel about an area of our code, that is so complex I am at a loss for words
Simon Cordova
@gbsimon87
Jan 31 01:47
whats up whats up
Christopher McCormack
@cmccormack
Jan 31 01:48
@gbsimon87 hey what's up man? I think most people probably logged off for the night already :)
Simon Cordova
@gbsimon87
Jan 31 01:49
oh shoot
I really just came on mainly to catch you and @JLuboff
Got huge news
She's about 8 months away!!! :)
Christopher McCormack
@cmccormack
Jan 31 01:52
oh wow congrats!
away from what?
:p
Where are you at now?
Simon Cordova
@gbsimon87
Jan 31 01:52
lol, we named the fetus Beanie Appleseed
Christopher McCormack
@cmccormack
Jan 31 01:53
lol is that a trend? My friends named theirs baby bok choy
Simon Cordova
@gbsimon87
Jan 31 01:54

I arrived in Toronto this past Sunday, visa round 2
Got here just in time for 26cm of snow and -35 Celcius tonight, which is -31 F

JUST.MY.LUCK

I honestly never heard about it before, I guess it is - the app she's using to learn about the changes throughout time asked her to name it

Christopher McCormack
@cmccormack
Jan 31 01:54
jeeze will cars even run in those temps??
Simon Cordova
@gbsimon87
Jan 31 01:55
It sucked though, I found out one day, then had to leave the very next
Now I'm really in need of this visa
Christopher McCormack
@cmccormack
Jan 31 01:55
does a baby help with the process at all?
Simon Cordova
@gbsimon87
Jan 31 01:55
Not for my particular visa, it's a work visa
I"m honestly in complete disbelief at the moment, hasn't fully hit me, but the more days pass the more I think about it
Brad
@bradtaniguchi
Jan 31 01:56
congratz :D
Christopher McCormack
@cmccormack
Jan 31 01:56
We'll all pitch in and get the little one some JavaScript jammies
Simon Cordova
@gbsimon87
Jan 31 01:57
HELL YEAH!
I hope he/she will be a Raptors lover and Javascript nerd like pops
jesus, did I just call myself pops?
Christopher McCormack
@cmccormack
Jan 31 01:57
yessir
could be papa
Simon Cordova
@gbsimon87
Jan 31 01:58
How's things on your end?
Christopher McCormack
@cmccormack
Jan 31 01:59
no babies so... pretty smooth and without issue :p
Nothing new really, in one of those boringly consistent times
Simon Cordova
@gbsimon87
Jan 31 02:01
Consistency is like peripheral vision, key
oh man I don't know what to do, this is crazy
I'm ecstatic, nervous, and feel like I don't have it in my control all at the same time
Christopher McCormack
@cmccormack
Jan 31 02:02
deep breaths maybe?
do we ever really have control? Life is just a bunch of little emergencies strung together
Simon Cordova
@gbsimon87
Jan 31 02:04
Yeah, I suppose
Work is going tough as hell, I hope I don't get let go because I'm not performing too high and am a contractor atm
Lady is pregnant 6,000 km away
And need the visa
lol
deep breaths
Anyways big man I should get back to work I've got a hard deadline tomorrow which doesn't look like I'll meet
Now that I'm in Toronto I'll come online and catch you guys more often
Be safe alright :)
Christopher McCormack
@cmccormack
Jan 31 02:06
You'll be fine I hope, keep reading, learning, working hard, and remember you have another person to take care of now so you can't slack off @gbsimon87
Take care!
Simon Cordova
@gbsimon87
Jan 31 02:07
Thanks buds :)
Catch you soon
Simon Cordova
@gbsimon87
Jan 31 03:23
@cmccormack you there by any chance?
Christopher McCormack
@cmccormack
Jan 31 03:29
I am
@gbsimon87 sup?
Simon Cordova
@gbsimon87
Jan 31 03:34
Hey buds, got a question for you
man i'm so screwed lol
let me see how I can phrase it
@cmccormack you know what man I just solved it trying to phrase it to you lolol
god damn, after a good half hour
Pagnito
@Pagnito
Jan 31 03:36
does a git merge basically overwrite the master with the other branch?
Simon Cordova
@gbsimon87
Jan 31 03:39
@Pagnito hey there
Pagnito
@Pagnito
Jan 31 03:39
@gbsimon87 hey
Christopher McCormack
@cmccormack
Jan 31 03:39
@gbsimon87 I'm your rubber ducky
@Pagnito not overwrite, it creates a new commit that points to the head of both branches
Brad
@bradtaniguchi
Jan 31 03:40
^
Christopher McCormack
@cmccormack
Jan 31 03:40
and that new commit becomes the head of your master
Simon Cordova
@gbsimon87
Jan 31 03:40
I love and hate gi
Christopher McCormack
@cmccormack
Jan 31 03:40
or whatever branch you're merging
@gbsimon87 gi?
Simon Cordova
@gbsimon87
Jan 31 03:41
I'm so behind right now because like an idiot I deleted tw obranches that had work and now for the life of me I can't find their SSH key
git**
I've tried git reflog and everything
f
what a day it's been
Kaz Baig
@kbaig
Jan 31 03:41
F
Pagnito
@Pagnito
Jan 31 03:41
so when i merge a branch, basically that branch becomes the master branch?
Simon Cordova
@gbsimon87
Jan 31 03:41
depends what you mean by master branch
look at the this way...
you've got branchA and branchB
Say you're currently on branchA but it's missing something that branchB has and you want to merge that something into branchA
git merge branchB
Pagnito
@Pagnito
Jan 31 03:43
ah so it just adds into the master branch?
Simon Cordova
@gbsimon87
Jan 31 03:43
now branchA has the contents of branchB, unless there are conflicts and you accept the current and not the incoming
I think in terms of a regular git or scrum methodology you're using the term master branch loosely
Christopher McCormack
@cmccormack
Jan 31 03:44
everything is just a tree of commits, merging just binds two trees with a new commit
Simon Cordova
@gbsimon87
Jan 31 03:44

branchA has 123
branchB has 45

say you're on branchA and do git merge branchB

branchA will now be 12345

Does that make sense sort of?
Pagnito
@Pagnito
Jan 31 03:45
yea it does, wht if i only changed a few lines of code?
Simon Cordova
@gbsimon87
Jan 31 03:45
whatever is different between both branches is what 'merges' in
Pagnito
@Pagnito
Jan 31 03:46
so the one that merges in replaces the one being merged into?
Christopher McCormack
@cmccormack
Jan 31 03:46
there is no replacing
Simon Cordova
@gbsimon87
Jan 31 03:46
no no no
don't think of it as replacing
you're still in BRANCHES
think of a tree upside down, the seed you could say is your master branch, while the branches springing up are different branches on your git
normally you create a new branch from the seed, but you could also create a new branch from any branch really
but keeping it simpler...
Pagnito
@Pagnito
Jan 31 03:49
i still dont understand what happens to the master branch when i merge lol
Brad
@bradtaniguchi
Jan 31 03:49
This is where id say understanding some graph theory helps
Christopher McCormack
@cmccormack
Jan 31 03:50
master is just a pointer to the latest commit on the master branch, that commit being a reference to the head of the previous commit in master as well as the head of the branch you're merging into master
if you type something like git log --oneline --decorate --color --graph you can see all of the commits prior
Simon Cordova
@gbsimon87
Jan 31 03:52

let's say your 'seed' on the upside down tree is called branchSeed

now you're on branchSeed and do git checkout -B branchA
This creates a copy of branchSeed named branchA

Now on branchA you can do different things, add things, whatever you want, write a poem in it

Once you're happy with the changes on branchA, you add your changes and commit them
To add all changes at once you can do git add .
To commit you can do git commit -m "My changes" pro tip: use that '-m' flag
Up to this point those changes only exist on branchA

Now, if you want to bring those changes into branchSeed, you do the following
git checkout branchSeed
git merge branchA

Now branchSeed has the contents of branchA

Pagnito
@Pagnito
Jan 31 03:54
i get the part that branchseed will have the contents of brancha
Simon Cordova
@gbsimon87
Jan 31 03:54
I've updated my comment above
Pagnito
@Pagnito
Jan 31 03:55
yup noticed
Simon Cordova
@gbsimon87
Jan 31 03:55
nice, which part are you somewhat cloudy with?
Pagnito
@Pagnito
Jan 31 03:55
but yea the part i dont get how the process of supplying branchseed with the new data happens
Christopher McCormack
@cmccormack
Jan 31 03:55
This might help
Simon Cordova
@gbsimon87
Jan 31 03:56
and this https://www.youtube.com/watch?v=BCQHnlnPusY
Is how I learned it
Pagnito
@Pagnito
Jan 31 03:57
@cmccormack @gbsimon87 k thnx, ima watch the video then do that course
Christopher McCormack
@cmccormack
Jan 31 03:57
I thought this was kind of neat as well for a simple overview of what git is doing underneath
I've read a shit ton of articles and docs and I'm still not 100% sure how it all works, but at a certain point you have enough info to not be AS afraid of breaking something
Simon Cordova
@gbsimon87
Jan 31 03:59
True that
Another pro tip - don't be an idiot like me and go crazy delete branches thinking you don't need them anymore, find SSH keys to recover them is a pain
Pagnito
@Pagnito
Jan 31 03:59
lol
Simon Cordova
@gbsimon87
Jan 31 03:59
my conjugation is on point today lol
Christopher McCormack
@cmccormack
Jan 31 04:00
sounds spanish
haha shouldn't have fixed it
what do you mean @gbsimon87 ? what's the relation to deleting a branch and your SSH keys?
Simon Cordova
@gbsimon87
Jan 31 04:01
You can recover deleted branches with ssh keys
I usually do git reflog and look around for the specific commit
Nothing worked today though
Kaz Baig
@kbaig
Jan 31 04:02
damn dude what did your repo do to deserve a flogging
Simon Cordova
@gbsimon87
Jan 31 04:02
image.png

I usually get the keys like that

Oh man, what did my repo NOT do lol

Got a hard deadline tomorrow and I went delete crazy today and am paying the price since 6am, it's currently 11pm
Kaz Baig
@kbaig
Jan 31 04:04
I know that feel
It's not a good feel
Simon Cordova
@gbsimon87
Jan 31 04:04
lololololol
Christopher McCormack
@cmccormack
Jan 31 04:05
so.. why do you need to restore a branch you deleted?
I'm genuinely curious, never have to do anything like that for my personal stuff
Simon Cordova
@gbsimon87
Jan 31 04:06
It's for work, even worse
I thought I had merged everything and my dev branch was up to date, I went and got rid of 6 local and remote branches to keep it clean on the client's repo
Not a bright idea
Christopher McCormack
@cmccormack
Jan 31 04:07
ohh
I thought they were already merged and you had to back out something
get it all back on track?
Simon Cordova
@gbsimon87
Jan 31 04:10
I'm about an hour away from getting it back, but I still hadn't finished the project so there's quite a bit to go
It's going to be an all nighter night, first one in who knows how long
Christopher McCormack
@cmccormack
Jan 31 04:11
ouch, good luck man don't let us distract you :)
Simon Cordova
@gbsimon87
Jan 31 04:12
Oh man
Thanks buddy appreciate it
Pagnito
@Pagnito
Jan 31 04:19
if im in master branch\
and i run git merge
what happens
Kaz Baig
@kbaig
Jan 31 04:19
it'll prob ask you which branch you want to merge with
Pagnito
@Pagnito
Jan 31 04:25
if i merge two branches, are they basically like one branch now?
Kaz Baig
@kbaig
Jan 31 04:26
nah they're still two separate branches
it's like copying your code from one branch onto the other one
Pagnito
@Pagnito
Jan 31 04:26
so lets say i merged branch A nd B
next time i commit to branch A
will that also update branch B?
Kaz Baig
@kbaig
Jan 31 04:28
nope
Pagnito
@Pagnito
Jan 31 04:29
k thnx
Simon Cordova
@gbsimon87
Jan 31 04:36
@Pagnito if you committed to one branch and it updated that branch plus another branch it would basically defeat the purpose of 'branching' out
You may as well just have one branch if that were the case
Pagnito
@Pagnito
Jan 31 04:38
@gbsimon87 true, that videos 2nd part helped alot
Simon Cordova
@gbsimon87
Jan 31 04:38
nice :)
Jason Luboff
@JLuboff
Jan 31 06:09
@simon (fucking Gitter mobile can’t find your username)...Mozel Tov! That’s awesome news!
Simon Cordova
@gbsimon87
Jan 31 06:50
Thanks buddy :) Highly appreciate it
@JLuboff
Simon Cordova
@gbsimon87
Jan 31 10:43
sorry, no clue about electron, perhaps theres a channel for that?
Mais
@mais-hatem
Jan 31 10:44
@gbsimon87 I honestly looked but couldn't find any! there's only one for angular and electron together where I got no reply.
Thank you anyways!
tundeiness
@tundeiness
Jan 31 11:48
Hi all I am still having issues with getting my audio to play in this project: https://codepen.io/highness/pen/xmMMoG?editors=0011 I keep getting this error on the console TypeError: _this.audio.play is not a function at App._this.handleClick handleClick is to check if the drum-pads were clicked and if it was clicked the Refs will get the audio file embedded in drum-pads I have been scouring the internet (and avoiding spoilers as well) on how to get it to work. Help is required please.
@cmccormack
Tom
@moT01
Jan 31 13:24
@tundeiness not sure those audio urls will work
try opening one of them in a browser where you aren't logged in to google
tundeiness
@tundeiness
Jan 31 13:27
@moT01 I get this
Forbidden
Error 403
@moT01 I can't think of any other place to store it.... It was recommended by someone here though.
Tom
@moT01
Jan 31 13:32
well, I don't think that's going to work
the fcc project used aws, not sure if that's free or what
I stored mine on my github repo, but I'm not sure if you can just host them there and then get them through codepen like that
tundeiness
@tundeiness
Jan 31 13:37
@moT01 i am skeptical about the github approach. I think someone here said codepen does not allow that anymore
@moT01 i doubt if AWS is free. However I need quick feedback on the project. Thanks.
Tom
@moT01
Jan 31 13:38
well, you could use github, but you would have to host it somewhere other than codepen
tundeiness
@tundeiness
Jan 31 13:39
@moT01 wow...
Tom
@moT01
Jan 31 13:39
the sounds are in the public folder
tundeiness
@tundeiness
Jan 31 13:40
@moT01 having gone through the hassles of refactoring and now storage problem again?
Tom
@moT01
Jan 31 13:46
it probably is free for a small amount
var averageRating = watchList.map(x=>({director:x["Director"], rating:x["imdbRating"]})).filter(x=>x.director === "Christopher Nolan").map(x=>Number(x.rating)).reduce((x,y)=>x+y)/4;
I do not like my answer
the 4 at the and of the code irritates me
do you have any short or more logical answer?
Christopher McCormack
@cmccormack
Jan 31 14:59
@enestatli it's common when chaining functions like that to put the .function on a new line for readability like
myArray.map(() => {})
.filter(() => {})
.reduce(() => {})
enestatli
@enestatli
Jan 31 15:02
@cmccormack okay, I want to know this curly braces are required {}
sometimes they work without them
Christopher McCormack
@cmccormack
Jan 31 15:02
it depends on your usage, with arrow functions return is implied, but if you need to use more than one expression then you can wrap it all in curly braces. Note that you will need to then add a return within the curly braces
I just didn't want to write actual code so put curly braces
enestatli
@enestatli
Jan 31 15:03
okay I got the point, thank you!
tundeiness
@tundeiness
Jan 31 15:04
@moT01 will it work with dropbox?
Christopher McCormack
@cmccormack
Jan 31 15:05
@enestatli reduce has 4 arguments, check the documentation for the fourth argument and you can determine how to remove the need use 4 explicitly
enestatli
@enestatli
Jan 31 15:06
this would be great if I destroy the 4 :D, thank you I will check it out
Christopher McCormack
@cmccormack
Jan 31 15:07
@tundeiness why not just use the clips in the example?
tundeiness
@tundeiness
Jan 31 15:09
@cmccormack example where? i don't understand please.
Christopher McCormack
@cmccormack
Jan 31 15:09
The FCC exercise has an example of the finished product, it has an object that has aws stored sound effects
Unless I misread your question
tundeiness
@tundeiness
Jan 31 15:13
@cmccormack oh! i didn't know...besides my thought was no peeking at the codes while doing my projects.
Christopher McCormack
@cmccormack
Jan 31 15:21
eh
probably should avoid much more than that though
I'm personally not a big fan of the drum project for this and a few other reasons
tundeiness
@tundeiness
Jan 31 15:25
@cmccormack leaves me no choice than to seek for alternatives. Beside it was @NJM8 that recommended the google cloud solution but as it is it wont play the sounds stored in there.
Christopher McCormack
@cmccormack
Jan 31 15:26
No reason to make it more difficult, just grab the aws links from the example project - many other drum machine projects are also using it
tundeiness
@tundeiness
Jan 31 15:36
@cmccormack great will check it out.
Pagnito
@Pagnito
Jan 31 15:43
hey i can set config for babel in package json instead of babel rc right?
oh ok it seems so
Christopher McCormack
@cmccormack
Jan 31 15:50
@Pagnito yessir. I like how you answer your own questions almost immediately :)
Pagnito
@Pagnito
Jan 31 15:51
@cmccormack haha thnx
Simon Cordova
@gbsimon87
Jan 31 15:51
@cmccormack whats happening
I'm almost done!
Christopher McCormack
@cmccormack
Jan 31 15:51
@gbsimon87 woah did you actually work all night?
Simon Cordova
@gbsimon87
Jan 31 15:51
I had to, visas riding on my performance lol
Christopher McCormack
@cmccormack
Jan 31 15:52
yeah but now how will you work today?
you'll be all sluggish and prone to additional mistakes
unless your deliverable is due right now and you can sleep :)
Simon Cordova
@gbsimon87
Jan 31 15:52
It's due in literally two hours there's 6 of us working like crazy monkeys atm
Christopher McCormack
@cmccormack
Jan 31 15:53
oh good at least it's not you in solitude, that could be very stressful
@Pagnito I'm always torn on whether I want to put those types of configs in my package.json, in it's own file, or in its own file in a directory just for that stuff.
Pagnito
@Pagnito
Jan 31 15:56
@cmccormack yea, i dont like having too many files in the root directory, thats why i wanna put into my package.json, but i seen some projects that have a really long package.json so maybe ima gonna end up going back to seperating files in the future lol
Christopher McCormack
@cmccormack
Jan 31 15:57
yes that's exactly the conundrum lol
I'd prefer to put it in its own directory but I haven't looked into how those different tools auto-grab the configs. May need to add a flag to point to it or something
Pagnito
@Pagnito
Jan 31 15:59
@cmccormack yea that makes sense
Simon Cordova
@gbsimon87
Jan 31 16:25
@cmccormack yeah we're all going crazy atm but life
At least I'm seeing the Raptors against the Bucks tonight :)
Jason Luboff
@JLuboff
Jan 31 16:36
Morning
Christopher McCormack
@cmccormack
Jan 31 16:36
@gbsimon87 sleeping through it I bet
@JLuboff hey gm
Jason Luboff
@JLuboff
Jan 31 16:36
Whats up
Christopher McCormack
@cmccormack
Jan 31 16:37
Finally working on my documentation/training stuff for the new platform I built last year. I hate it but it has to be done
Jason Luboff
@JLuboff
Jan 31 16:38
Would that fall under "Technical Writing"? I almost took a class once on that..
Adedeji Stephen
@ionware
Jan 31 16:38
Good day. Can someone please recommend me a good book on Node.js?
Christopher McCormack
@cmccormack
Jan 31 16:40
@JLuboff not what I'm doing, just putting it on confluence as a step by step guide
I'll do the technical writing later if I"m asked to
Jason Luboff
@JLuboff
Jan 31 16:40
Ah
Christopher McCormack
@cmccormack
Jan 31 16:50
@JLuboff what you doing today?
Jason Luboff
@JLuboff
Jan 31 16:51
Continuing on backend/database stuff. Currently trying to decide on how I should refactor some stuff (or if I even should)
Christopher McCormack
@cmccormack
Jan 31 16:56
Use the KonMari method, does the code spark joy?
Jason Luboff
@JLuboff
Jan 31 16:57
Lol
Yes, yes it does
I still need to do more decluttering at home lol
Christopher McCormack
@cmccormack
Jan 31 17:00
Seriously though I do tend to write code based on how much I "Like" it. If it seems off, I try to fix it
even if it already works
Jason Luboff
@JLuboff
Jan 31 17:01
Ya I have working code... but I don't like it..as I need to delve too deep in too many seperate functions that use the same starting data. So.. trying to manipulate my data into a more friendly format for the rest of the functions
Christopher McCormack
@cmccormack
Jan 31 17:02
would it be better overall afterward?
Jason Luboff
@JLuboff
Jan 31 17:06
Ya. It would reduce the number of maps I have to use in each function which will create cleaner code :)

Need to come up with better names but

const reduced = steps.reduce((parentArr, step) => {
  const hazardAndControls = step.hazardAndControls.reduce((hazards, hazard) => {
    const obj = {
      stepNumber: step.stepNumber,
      hazardName: hazard.hazardName,
      controlIDs: [...hazard.controlIDs]
    };
    hazards.push(obj);
    return hazards;
  }, [])
  parentArr.push(...hazardAndControls);
  return parentArr;
}, [])

Flattens everything into a single array of objects versus an array of objects with a nested array of objects

Credit to @bradtaniguchi as I changed up another function I have to create this, of which he helped me write that function heh
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:10
hey @JLuboff, didnt look with alot of attention but wouldn't a double .map do the job aswell here?
Jason Luboff
@JLuboff
Jan 31 17:11
Yo. And possibly... didn't try lol
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:11
do you have a data sample I can test out reall quick?:D
Jason Luboff
@JLuboff
Jan 31 17:11
But ya...thinking about it, I would gander that a double map would work as well
I'll send it to you in a DM just so I don't clutter things up in here
Blauelf
@Blauelf
Jan 31 17:13
The parentArr.push(...hazardAndControls); would not match nicely to map, unless you do an additional [].concat(...result) step with the array returned.
map means number of input element equals number of output elements.
Jason Luboff
@JLuboff
Jan 31 17:16
A quick test reveals that @Blauelf is right.. but.. then again..I haven't tried very hard lol
const mapped = [].concat(...steps.map(({
  hazardAndControls,
  stepNumber
}) => {
  return hazardAndControls.map(({
    hazardName,
    controlIDs
  }) => {
    const obj = {
      stepNumber,
      hazardName,
      controlIDs
    };
    return obj;
  })
}))
Ya this technically works the same way as the reduced version
Hmmm...but what about combining reduce and map
Jason Luboff
@JLuboff
Jan 31 17:21
Yup.. can do a reduce and map
const both = steps.reduce((parentArr, step) =>{
const hazardAndControls = step.hazardAndControls.map(({
    hazardName,
    controlIDs
  }) => {
    const obj = {
         stepNumber : step.stepNumber,
      hazardName,
      controlIDs
    };
    return obj;
  })
    parentArr.push(...hazardAndControls);
  return parentArr;
}, [])
Can probably be refactored a bit.. but neat to see all the different ways heh
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:24
@Blauelf you were right didnt notic the part that it had to be 1d array at the end my bad :)
Blauelf
@Blauelf
Jan 31 17:25
I've done too many variations of steamroller to not notice that :P
Jason Luboff
@JLuboff
Jan 31 17:27
Alright. Now taking bets on which variation is fastest!
No bets? Oh well. Testing seems inconclusive anyhow. But seems double reduce is more consistently slightly slower
Where map->map and reduce->map are somewhat similar
DMZ
@DMZ011
Jan 31 17:34
hey guys
I need help with regex :S
I have this string:
"<div class="ExternalClassF2125A75A16249D887D5E3B9A4D6B98E"><p>Fourth&#160;delivery sprint nearing completion, estimated UAT testing to begin mid-late <strong>January 2019</strong>.</p></div>"
I want to remove the surrounding divs, but keep the other inner HTML tags
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:37
Just do it :D
make capture group that matches the div inner content and replace the string above by the capture group
Kevin Peña
@kebien6020
Jan 31 17:38
Regex is a bad idea for HTML
DMZ
@DMZ011
Jan 31 17:39
capture group?
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:40
as said above dont use regex for html
DMZ
@DMZ011
Jan 31 17:40

i tried this:

```

b.replace(/<.*?>/mg, "")
what do i use?
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:40
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:41
then you can use $1 on the replace part
DMZ
@DMZ011
Jan 31 17:41
:O
@tiagocorreiaalmeida how did u do it so fast????
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:42
played alot with regexp
DMZ
@DMZ011
Jan 31 17:43
but when i do:
b.replace(/\<div.*\>(<p>.*<\/p>)\<\/div>/mg, "")
it returns an empty string
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:43
use regex101 and try it by yourself
ofcourse cause you want to replace the entire match by the first capture group
DMZ
@DMZ011
Jan 31 17:44
hmm
i'll google "capture groups" :joy:
Kevin Peña
@kebien6020
Jan 31 17:46
const html = "<div class=\"ExternalClassF2125A75A16249D887D5E3B9A4D6B98E\"><p>Fourth&#160;delivery sprint nearing completion, estimated UAT testing to begin mid-late <strong>January 2019</strong>.</p></div>"
const elem = document.createElement('div')
elem.innerHTML = html
console.log(elem.firstChild.innerHTML)
// <p>Fourth&nbsp;delivery sprint nearing completion, estimated UAT testing to begin mid-late <strong>January 2019</strong>.</p>
Tiago Correia
@tiagocorreiaalmeida
Jan 31 17:46
im not sure what he is trying so im just following along.. .D
Kevin Peña
@kebien6020
Jan 31 17:47
I want to remove the surrounding divs, but keep the other inner HTML tags
DMZ
@DMZ011
Jan 31 17:48
@kebien6020 whoaaa! that's neat!
Kevin Peña
@kebien6020
Jan 31 17:49
If you want to also repove the <p> just do elem.firstChild.firstChild.innerHTML
or even elem.querySelector('p').innerHTML, or this one for multiple <p>s inside the div Array.from(elem.querySelectorAll('p')).map(elem => elem.innerHTML).join('')
DMZ
@DMZ011
Jan 31 17:52
yeah
now I can do whatever with it
haven't thought about it this way
@tiagocorreiaalmeida don't use regex for html man, it's bad
:joy:
Pagnito
@Pagnito
Jan 31 17:55
does the stream contain a buffer?
Kevin Peña
@kebien6020
Jan 31 17:56
do what now?
Tiago Correia
@tiagocorreiaalmeida
Jan 31 18:04
@DMZ011 ...
DMZ
@DMZ011
Jan 31 18:04
@tiagocorreiaalmeida haha :joy: thanks again man :thumbsup:
good to know regex anyway
Kaz Baig
@kbaig
Jan 31 18:06
@gbsimon87 if you don't mind me asking, why is a visa riding on your performance? Was it for an interview?
Pagnito
@Pagnito
Jan 31 18:09
are the any instances in big scale apps where someone would use regulard readfile writefile over streamwrite and streamreads?
Kaz Baig
@kbaig
Jan 31 18:09
probably but also probably not for good reasons
I'm sure my old company was doing that
Pagnito
@Pagnito
Jan 31 18:11
cool thnx
hey u still play league?
Kaz Baig
@kbaig
Jan 31 18:11
nah I haven't since last spring
Pagnito
@Pagnito
Jan 31 18:14
i feel u, i havent in a while either, i feel like some of the champs are really unbalanced, i wanna play sometimes, then i remember going up against gahren or illaoi, and i lose the desire to play pretty quickly
Kaz Baig
@kbaig
Jan 31 18:15
I'd play again if adc or draven were fun again
Tiago Correia
@tiagocorreiaalmeida
Jan 31 18:15
There's urf ATM always fun XD
Kaz Baig
@kbaig
Jan 31 18:16
Not worth it in a world where kingdom hearts 3 just came out
Pagnito
@Pagnito
Jan 31 18:16
oof
i heard riot is working on a mmorpg
i dont know how to feel about that. i like it, but i feel like ill b too scared to touch it
enestatli
@enestatli
Jan 31 18:20
I am getting used to higher-order functions
but it makes feel lazy
Kaz Baig
@kbaig
Jan 31 18:21
how so
enestatli
@enestatli
Jan 31 18:21
function destroyer(arr) {
  // Remove all the values
   var args = Array.prototype.slice.call(arguments);
   return arr.filter(x=>!args.includes(x));

}

destroyer([1, 2, 3, 1, 2, 3], 2, 3);
I solve this with filter()
but can't solve it with for loops now :D
Tiago Correia
@tiagocorreiaalmeida
Jan 31 18:24
loop the array if args includes the current value push it to the new array you create at the top?
Simon Cordova
@gbsimon87
Jan 31 18:28
@kbaig was more a joke really than anything (regarding the visa)
Kaz Baig
@kbaig
Jan 31 18:29
ah oke
Simon Cordova
@gbsimon87
Jan 31 18:31

@cmccormack haha, no chance I sleep through that game!
It's my team against my girl's and shes back in London not able to make it :(

Whats up @JLuboff

Kaz Baig
@kbaig
Jan 31 18:31
@gbsimon87 tier 2 general I'm guessing?
Simon Cordova
@gbsimon87
Jan 31 18:31
indeed
haha
Kaz Baig
@kbaig
Jan 31 18:31
ahh gotcha
Jason Luboff
@JLuboff
Jan 31 18:32
@gbsimon87 Que paso hombre?
Simon Cordova
@gbsimon87
Jan 31 18:32
Hey guys quick q
I'm looking for some advanced React techniques, anybody got a source?
@JLuboff I'm good man finally the weather warmed up a bit it was crazy
I can't believe I'm saying that and its -18 outside
Jason Luboff
@JLuboff
Jan 31 18:33
It's pouring here right now
Kaz Baig
@kbaig
Jan 31 18:33
you may call recompose advanced
but the author says hooks solve most of the problems targeted by it
enestatli
@enestatli
Jan 31 18:35
@tiagocorreiaalmeida I will give it a try but it seems I need nested loop :D
Simon Cordova
@gbsimon87
Jan 31 18:57
@JLuboff I'm good man, tired, working all night
@kbaig good point, should study hooks, didn't they get released?
Brad
@bradtaniguchi
Jan 31 18:58
gosh darn laptop giving me troubles again :/
Kaz Baig
@kbaig
Jan 31 18:58
@gbsimon87 slated for feb 04
Jason Luboff
@JLuboff
Jan 31 18:58
@gbsimon87 You should get some rest man, gotta get it before the kiddo
Simon Cordova
@gbsimon87
Jan 31 18:59
haha true, was just talking to the lady
sounds corny but I think I've grown more emotionally attached to her since the news
Jason Luboff
@JLuboff
Jan 31 19:00
Not corny at all
Simon Cordova
@gbsimon87
Jan 31 19:00
I guess no, and by I think I definitely have
I see her with a different eye, it's like I want to protect her
Oh man I got old
Jason Luboff
@JLuboff
Jan 31 19:03
Ya you have
Simon Cordova
@gbsimon87
Jan 31 19:03
lololol
enestatli
@enestatli
Jan 31 19:05
okay some help pls
Kaz Baig
@kbaig
Jan 31 19:05
that's awesome
enestatli
@enestatli
Jan 31 19:05
:(
function whatIsInAName(collection, source) {
  // What's in a name?
  var arr = [];
  // Only change code below this line
  for(let i=0;i<collection.length;i++){
    for(const [key,value] of Object.entries(collection[i])){
      for(const [k, v] of Object.entries(source)){
        if(key===k){
          arr.push(collection[i]);
        }
      }
    }
  }

  // Only change code above this line
  return arr;
}
Simon Cordova
@gbsimon87
Jan 31 19:05

Thanks @kbaig

Oh man I haven't done algorithms in two years Im' going to get back in them

Jason Luboff
@JLuboff
Jan 31 19:06
Too many loops
enestatli
@enestatli
Jan 31 19:06
@JLuboff otherwise I couldn't reach dictionary :(
Simon Cordova
@gbsimon87
Jan 31 19:06
and too many ambiguous variables, @enestatli I really recommend you make the code more idiomatic
It'll help you so much just by first glance
enestatli
@enestatli
Jan 31 19:07
@gbsimon87 you are right!
Christopher McCormack
@cmccormack
Jan 31 19:07
NOT ENOUGH LOOPS
enestatli
@enestatli
Jan 31 19:07
@cmccormack :D
Simon Cordova
@gbsimon87
Jan 31 19:07
@cmccormack
lololol
Christopher McCormack
@cmccormack
Jan 31 19:07
Some loops can be implicit, like an indexOf method
enestatli
@enestatli
Jan 31 19:08
hmmm
Christopher McCormack
@cmccormack
Jan 31 19:09
or map/reduce/filter
Simon Cordova
@gbsimon87
Jan 31 19:09
whooooooa
just singed in to the FCC curriculum for the first time in a long time, there's whole new sections
Christopher McCormack
@cmccormack
Jan 31 19:09
yeah man
Jason Luboff
@JLuboff
Jan 31 19:09
Lol they've been there for a good while now
Christopher McCormack
@cmccormack
Jan 31 19:09
been a while
DMZ
@DMZ011
Jan 31 19:09
u guys still follow the curriculum?
Christopher McCormack
@cmccormack
Jan 31 19:09
no
all done
DMZ
@DMZ011
Jan 31 19:09
i never finished it :joy:
Jason Luboff
@JLuboff
Jan 31 19:09
Last section I did was the React section, otherwise haven't done much
Christopher McCormack
@cmccormack
Jan 31 19:09
well mostly
all done with projects
enestatli
@enestatli
Jan 31 19:09
@cmccormack I want to solve using with for loop :/
DMZ
@DMZ011
Jan 31 19:10
would be fun to do the projects with react/typescript
Christopher McCormack
@cmccormack
Jan 31 19:10
@enestatli I'm not telling you how to solve anything
enestatli
@enestatli
Jan 31 19:10
@cmccormack yes that's why I like way of teaching anything :D
Kaz Baig
@kbaig
Jan 31 19:10
I got somewhat close to finishing the old curriculum
Jason Luboff
@JLuboff
Jan 31 19:11
I had finished front end and backend with the old curriculum
Christopher McCormack
@cmccormack
Jan 31 19:11
@JLuboff did you redo some of the old ones that had tests added?
Kaz Baig
@kbaig
Jan 31 19:11
I might do the projects if I'm looking for ideas, but there's plenty of stuff I could do before I get to that point
Christopher McCormack
@cmccormack
Jan 31 19:11
I basically had to redo my entire pomodoro from scratch
Jason Luboff
@JLuboff
Jan 31 19:11
@cmccormack Naaahhh
DMZ
@DMZ011
Jan 31 19:12
u inspired me to do the projects man @cmccormack
Christopher McCormack
@cmccormack
Jan 31 19:12
well I guess it's a frontend project now so that would have to be done anyhow
Kaz Baig
@kbaig
Jan 31 19:12
I cringe at my front end projects in jquery
Jason Luboff
@JLuboff
Jan 31 19:12
I cringe at my node projects lol
DMZ
@DMZ011
Jan 31 19:12
I cringe at my development skills
Christopher McCormack
@cmccormack
Jan 31 19:12
@DMZ011 they're so much fun! it's what kept me motivated, late nights working on the dungeon crawler and the pomodoro timer, getting all the CSS to look lovely
Kaz Baig
@kbaig
Jan 31 19:12
@DMZ011 same tbh
Simon Cordova
@gbsimon87
Jan 31 19:12
Ive got a soft spot for jQuery
RIP and long live jQuery :/
DMZ
@DMZ011
Jan 31 19:12
i hate jquery
Simon Cordova
@gbsimon87
Jan 31 19:13
Was the gateway to my first job
Christopher McCormack
@cmccormack
Jan 31 19:13
jQuery isn't dead, a lot of jquery like features are now part of the browser
DMZ
@DMZ011
Jan 31 19:13
react & jquery together?
Christopher McCormack
@cmccormack
Jan 31 19:13
I bet $50 we'll see something like React built into the browser as well
DMZ
@DMZ011
Jan 31 19:13
the React browser
Kaz Baig
@kbaig
Jan 31 19:13

react & jquery together?

shudder

DMZ
@DMZ011
Jan 31 19:13
browser from FB
Simon Cordova
@gbsimon87
Jan 31 19:13
Part of the browser, and support for older browsers as well - but in everyday code...hmm....
DMZ
@DMZ011
Jan 31 19:14
would be nice to have a browser named React with the React logo
Christopher McCormack
@cmccormack
Jan 31 19:14
I've used React + jQuery but only because it was early react days, trying to get bootstrap stuffs working
Kaz Baig
@kbaig
Jan 31 19:14
jquery is just a polyfill for modern vanilla js
change my mind
Simon Cordova
@gbsimon87
Jan 31 19:14
jQuery literally goes against the unidirectional structural pattern of React
DMZ
@DMZ011
Jan 31 19:14
is there a need for jquery now with es6?
Jason Luboff
@JLuboff
Jan 31 19:14
I don't have any hate towards jQuery.. hell I have production apps built with it...but definitely think its time to move on
Christopher McCormack
@cmccormack
Jan 31 19:14
@DMZ011 it's more about what the browser api's support rather than es6
DMZ
@DMZ011
Jan 31 19:14
es6 and all the libraries
Simon Cordova
@gbsimon87
Jan 31 19:14
once document.querySelector came around it changed the game
Christopher McCormack
@cmccormack
Jan 31 19:15
^
also built in fetch or axios are pretty much replacing the jquery ajax calls
DMZ
@DMZ011
Jan 31 19:15
@gbsimon87 when I saw that the first time, I started searching for the library that provides querySelector :joy:
Simon Cordova
@gbsimon87
Jan 31 19:15
@DMZ011 lolol
Christopher McCormack
@cmccormack
Jan 31 19:16
and libraries like React make it so you don't even need to do all that confusing selector logic, you build from the top down in a very concise way
DMZ
@DMZ011
Jan 31 19:16
i was like: how did the dev stick a function called querySelector to the document object
Simon Cordova
@gbsimon87
Jan 31 19:16
@cmccormack which browsers is axiox now built into?
Christopher McCormack
@cmccormack
Jan 31 19:16
@gbsimon87 sorry didn't mean to imply axios was built in
Simon Cordova
@gbsimon87
Jan 31 19:16
$('#myDiv').closest('div').find('p') just shoot me man
oh ok I thought I was about to switch browsers
Christopher McCormack
@cmccormack
Jan 31 19:17
oh my I have done exactly that with jquery lol
I think my Twitch app
that kind of odd selector madness is what made me fall in like with React
Simon Cordova
@gbsimon87
Jan 31 19:19
same
top down, not upside down ans sideways
and**
but Im not hating, it got my foot in the door
DMZ
@DMZ011
Jan 31 19:20
how do we learn about git/branches?
I was working on a project the other day
and the dev told me to create a branch, I was like ok, easy peasy, then to push the code for my branch into the master branch, it caused a mess
he said I have to switch to the master branch from vscode, pull changes, push them into my branch, then merge, then push my branch's changes, then make a pull request :O
that sounded harder than learning development
is there any good resource u guys recommend that explains these things
Christopher McCormack
@cmccormack
Jan 31 19:22
@DMZ011 you don't push code into a branch
DMZ
@DMZ011
Jan 31 19:23
hmm
Christopher McCormack
@cmccormack
Jan 31 19:23
from the branch you are on, you can merge another branch. merging is basically creating a new commit that points to the head of both branches
@DMZ011 you should scroll back to our conversation last night :)
DMZ
@DMZ011
Jan 31 19:24
we talked last night? :S
DMZ
@DMZ011
Jan 31 19:26
oh
Christopher McCormack
@cmccormack
Jan 31 19:26
The general "we"
DMZ
@DMZ011
Jan 31 19:27
hahaha ah
i was like what the hell, i wasn't there
hmm
so i made a commit to my branch
i pushed the changes from vscode
then went to the UI, made a pull request there
from my branch to master
isn't this the right flow?
Christopher McCormack
@cmccormack
Jan 31 19:28
you did a pull request from a branch on the same repo?
DMZ
@DMZ011
Jan 31 19:28
yeah, on the repo
Christopher McCormack
@cmccormack
Jan 31 19:28
my understanding is pull requests and forks are a github/bitbucket type term and not a git specific term
DMZ
@DMZ011
Jan 31 19:29
i went to my branch, the one i created, made a pull request to move changes from my branch to the master one so they can approve it
Christopher McCormack
@cmccormack
Jan 31 19:29
you shouldn't need to do a pull request
oh
DMZ
@DMZ011
Jan 31 19:29
how come?
Christopher McCormack
@cmccormack
Jan 31 19:29
so that's a requirement where you work?
I thought it was a personal project
DMZ
@DMZ011
Jan 31 19:29
they said: if u wanna change a module, make a branch for it and work on it
when ur done, delete the branch
Christopher McCormack
@cmccormack
Jan 31 19:29
ok that makes sense
DMZ
@DMZ011
Jan 31 19:30
but... why would i wanna make a branch in the first place?
Christopher McCormack
@cmccormack
Jan 31 19:30
I feel like a little backstory may be required though lol
Pagnito
@Pagnito
Jan 31 19:30
wait is there no way to clone a specific branch?
DMZ
@DMZ011
Jan 31 19:30
haha
Christopher McCormack
@cmccormack
Jan 31 19:30
can you confirm this isn't a fork of the repo @DMZ011 ?
@Pagnito sure just do git branch [new branch name] from the branch you want to clone
DMZ
@DMZ011
Jan 31 19:31
no not a fork
Christopher McCormack
@cmccormack
Jan 31 19:31
or do you mean git clone?
DMZ
@DMZ011
Jan 31 19:31
they said: whenever u wanna work on a widget, create a new branch from the master branch
Christopher McCormack
@cmccormack
Jan 31 19:31
remember it's all pointers, it's not like you're copying everything over or something
DMZ
@DMZ011
Jan 31 19:31
work on it, once done, make a pull request
when u finish ur work and finish the widget, delete the branch
Christopher McCormack
@cmccormack
Jan 31 19:32
@DMZ011 they don't want you messing with the master
DMZ
@DMZ011
Jan 31 19:32
ah
so if I do a push from vscode
to the master, it'll be approved right away?
Christopher McCormack
@cmccormack
Jan 31 19:32
vs code has nothing really to do with this
vs code is just going to reference the branch you currently have checked out
DMZ
@DMZ011
Jan 31 19:32
yah, I use vscode as an interface to deal with git
since i don't remember the commands
Christopher McCormack
@cmccormack
Jan 31 19:33
@DMZ011 I can't answer that, I only work on personal projects and with forks
DMZ
@DMZ011
Jan 31 19:33
ahaa
Christopher McCormack
@cmccormack
Jan 31 19:33
There may be some github/bitbucket settings that only certain users can actually modify master
DMZ
@DMZ011
Jan 31 19:33
yeah i guess it's as u said
Pagnito
@Pagnito
Jan 31 19:33
git clone -b <branch> <remote_repo>
?
DMZ
@DMZ011
Jan 31 19:33
if I push right away to master, no one can review that
Christopher McCormack
@cmccormack
Jan 31 19:33
@Pagnito ?
DMZ
@DMZ011
Jan 31 19:33
however if i push it to a branch, then make a pull request, they can review what's going to be added
Christopher McCormack
@cmccormack
Jan 31 19:33
@DMZ011 yup
DMZ
@DMZ011
Jan 31 19:33
makes sense now
Christopher McCormack
@cmccormack
Jan 31 19:33
they can add reviews/approvals or request changes
Pagnito
@Pagnito
Jan 31 19:34
is that how i clone a specific branch?
Christopher McCormack
@cmccormack
Jan 31 19:34
it's how FCC works - contributors fork the main repo, make changes on a branch, then submit a pull request to merge their branch onto fcc master
DMZ
@DMZ011
Jan 31 19:34
git clone --single-branch --branch <branchname> host:/dir.git
Christopher McCormack
@cmccormack
Jan 31 19:35
@Pagnito did you clone the repo already?
Christopher McCormack
@cmccormack
Jan 31 19:35
you should be able to checkout the branch if so
sometimes not all branches are visible
Pagnito
@Pagnito
Jan 31 19:36
@cmccormack i didnt clone it yet
DMZ
@DMZ011
Jan 31 19:36
brb
Pagnito
@Pagnito
Jan 31 19:37
i dont wanna clone the whole repo,i wanna be able to see the differences in the file structure
Simon Cordova
@gbsimon87
Jan 31 19:44
@Pagnito
There are two common ways of seeings differences between two branches

one is do a merge request if you have access to a remote repo, using Gitlab, github whatever

another way is you can run the command git diff branchA...branchB
https://stackoverflow.com/questions/10039747/how-to-view-file-diff-in-git-before-commit

Pagnito
@Pagnito
Jan 31 19:47
the thing is if im working in master, then switched to a branchB and made some changes committed them, and switched to master branch, i want to be able to see my file structure in the texteditor to be the one of master
Simon Cordova
@gbsimon87
Jan 31 19:49
I don't mean this rudely at all ok, rather constructively, but if you're working on master you're defeating the entire purpose of the git workflow in my opinion
Why risk making breaking changes to the master branch?
You should a SINGLE source of truth
should have**
if you want to be be able to see your file structure in the text editor to be the one of master, you have to go back to master
git checkout master
Pagnito
@Pagnito
Jan 31 19:51
oh i see
true
yea i just recently started to use branchin, im n00b at this
Simon Cordova
@gbsimon87
Jan 31 19:51
no worries it's all good man
Pagnito
@Pagnito
Jan 31 19:52
recently=yesterday
Simon Cordova
@gbsimon87
Jan 31 19:52

let me recommend something to you

have master, dev, and then other branches

so master is your SINGLE SOURCE OF TRUTH
dev is like the 'staging' area, is the one branch you keep up to date with merged changes of all other branches but you only merge it into master once you're FULLY sure it's working
Christopher McCormack
@cmccormack
Jan 31 19:54
@gbsimon87 do you do the WIP git stuff?
Pagnito
@Pagnito
Jan 31 19:54
i see, thanks
Simon Cordova
@gbsimon87
Jan 31 19:54
I do yeah I find it helpful
@cmccormack do you not use it?
@Pagnito no worries
Christopher McCormack
@cmccormack
Jan 31 19:54
how does that work? I only ran into it yesterday because I saw some git aliases in the zsh git plugin
Simon Cordova
@gbsimon87
Jan 31 19:55
It basically does an auto rejection of merging that branch as it is recognised as a work in progress
One of my clients uses Gitlab and that fully blocks it
Pagnito
@Pagnito
Jan 31 19:56
so what happens if lets say on my dev branch, i add some stuff, but also change some function that were already existing on master. What happens with those functions?
Simon Cordova
@gbsimon87
Jan 31 19:56
Whenever you have changes that affect two same areas you can get what is known as a merge conflict
Git follows your changes, but it can't read your mind
Christopher McCormack
@cmccormack
Jan 31 19:57
minor edits may just go through without conflict but major may force you to resolve them first
I'm actually not sure what the threshold is on that though
Pagnito
@Pagnito
Jan 31 19:57
so is that what everybody is scared of, this conflict?
Simon Cordova
@gbsimon87
Jan 31 19:57
if on branchA on line 10 you write var x - 10 and on branchB you write Mary had a little lamb you have to 'solve' the conflict
Christopher McCormack
@cmccormack
Jan 31 19:58
conflicts are pretty easy to resolve but the syntax looks weird at first
Simon Cordova
@gbsimon87
Jan 31 19:58
yeah they can be tricky at times, but if you work carefully and have separate branches for different parts of your application then you can pretty much fully avoid them
Sometimes it's unavoidable, but don't worry it's fine, just take your time with it and read it carefully
VS Code and Atom use syntax highlighting to show you 'current' changes and the 'incoming' changes in a visual manner
Pagnito
@Pagnito
Jan 31 20:00
i see, ok now i feel camfortable with it, thnx
Simon Cordova
@gbsimon87
Jan 31 20:00
:+1:
Christopher McCormack
@cmccormack
Jan 31 20:00
Looks somethinglike this
<<<<<<< incoming change
incoming changes from branch that affect whatever is below the =====
=====
already on master, conflicts with incoming change
>>>>>>> master
vs code has a pretty good merge conflict tool built in
Simon Cordova
@gbsimon87
Jan 31 20:02
It's actually really good, very intuitive
Although, ha!
I merged the wrong one today on one branch but then went and made the change on a separate branch
Only one coworker caught it
Oh my god the things that amuse me
Christopher McCormack
@cmccormack
Jan 31 20:03
your head is in the game man, it's the only place you have to find amusement right now
Simon Cordova
@gbsimon87
Jan 31 20:04
fucking right ;)
We here should unite and work on a little project together
You guys should hop on board with my sports app loloololol
shamelessly trying to get free work out here hahahaha
Christopher McCormack
@cmccormack
Jan 31 20:05
if you think it will sucker convince people to shell out cash I'm in
Simon Cordova
@gbsimon87
Jan 31 20:06
"Take my money" - Fry somewhere
@cmccormack I'm writing my first blog, going to send it in a few days let me know what you think
Christopher McCormack
@cmccormack
Jan 31 20:07
I think it's shallow and pedantic!
Simon Cordova
@gbsimon87
Jan 31 20:08
Does that sound like something you'd be interested in?
lol, ever seen Entourage?
On a side note, they did a pretty nice job with the FCC curriculum, it's full of stuff man
DMZ
@DMZ011
Jan 31 20:09
@gbsimon87 will it be: React apps for IE6?
Simon Cordova
@gbsimon87
Jan 31 20:10
I'm a legacy type of guy
Keegan
@Keggatron
Jan 31 20:53

Hi guys, I'm getting a couple of linter warnings with a reduce function I'm trying to run.

const newArray = arr.reduce((acc, element) => {
      element.subElements.map(sub => acc = [...acc, sub]);
      return acc;
    }, []);

These are the linter complaints

[eslint] Arrow function should not return assignment. [no-return-assign]
[eslint] Assignment to function parameter 'acc'. [no-param-reassign]
What is the best way to write this function?
Jason Luboff
@JLuboff
Jan 31 21:08
Maybe I'm not reading it right...but.. acc never changes..? Shouldn't you be returning element.subElements.map..
Kaz Baig
@kbaig
Jan 31 21:11
@JLuboff both warnings were related to sub => acc = [...acc, sub]
first one because he was assigning something during implicit return
second one because he was reassigning a function param
we hashed it out in helpfrontend
Jason Luboff
@JLuboff
Jan 31 21:12
Ah.. touche
Christopher McCormack
@cmccormack
Jan 31 21:16
@JLuboff ohh look at mr. fancy words
Jason Luboff
@JLuboff
Jan 31 21:16
;)
Pagnito
@Pagnito
Jan 31 21:18
does anyone use quokka?
Christopher McCormack
@cmccormack
Jan 31 21:21
I did for a little bit but had some issues with it, although it may have been another extension at fault not sure
Pagnito
@Pagnito
Jan 31 21:23
i really like their lil squares that show u the code working or not
thats literrally the only reason i installed it
tho it seems it has a alot of cool features
Christopher McCormack
@cmccormack
Jan 31 21:23
looks nice, I don't think they had that when I first used it
Pagnito
@Pagnito
Jan 31 21:25
yea, i just found out about it from funfunfunction
damn, it seems it doesnt work when i save a file O.o
Brad
@bradtaniguchi
Jan 31 21:33
whats that?
Brad
@bradtaniguchi
Jan 31 21:35
hmm interesting
Pagnito
@Pagnito
Jan 31 21:37
yea, im thinking about buyin the pro one, thankfully its not a subscription
i cant stand subscriptions
Jason Luboff
@JLuboff
Jan 31 21:38
That does look interesting
alpox
@alpox
Jan 31 21:48
Heheh thats what clojure has out of the box
Just... Better
Jason Luboff
@JLuboff
Jan 31 21:50
Which one is better?
Brad
@bradtaniguchi
Jan 31 21:53
oh god clojure crap :/
alpox
@alpox
Jan 31 22:34
@JLuboff clojure :D
@bradtaniguchi Crap? No crap!
Jason Luboff
@JLuboff
Jan 31 22:37
I have a (maybe stupid) question... how do you decide when to use object literal vs object constructor? I have a tendency to pretty much always use an object literal..
alpox
@alpox
Jan 31 22:41
@JLuboff pretty much always object literal
Ofc. you use a constructor when using classes though
Jason Luboff
@JLuboff
Jan 31 22:42
Naturally.. (I haven't gotten too far into using classes except for my testcafe tests heh)
alpox
@alpox
Jan 31 22:42
Ye there I used them too
I dont usually like OOP in JS
Jason Luboff
@JLuboff
Jan 31 22:43
Well.. glad to hear you mainly use object literals. I've never really ran into much of a use-case for constructor
Kaz Baig
@kbaig
Jan 31 22:45

I dont usually like OOP in JS

same

Brad
@bradtaniguchi
Jan 31 22:50
I use object literals for data/maps/configs/whatever, and classes for utilities, and code that might be mocked later. I've tried a few ways to get rid of classes when mocking/stubbing but found it not as convenient. This only applies to my node/ts-node projects. Angular uses classes everywhere
Jason Luboff
@JLuboff
Jan 31 22:50
Oh ya...forgot I use classes in React.. lol
Christopher McCormack
@cmccormack
Jan 31 22:51
@JLuboff don't need to with hooks!
Brad
@bradtaniguchi
Jan 31 22:51
Oh yea that reminds me....
Jason Luboff
@JLuboff
Jan 31 22:52
Woah woah woah there buddy... don't go getting me started with some other do-hickey! (Yes I know hooks is part of React)
Christopher McCormack
@cmccormack
Jan 31 22:55
@JLuboff you never even got started with the old do-hickey! (context)
Jason Luboff
@JLuboff
Jan 31 23:09
I'm working on it!
Brad
@bradtaniguchi
Jan 31 23:20
yes firestore is out of beta! Just in time haha
Jason Luboff
@JLuboff
Jan 31 23:20
Dope!
Brad
@bradtaniguchi
Jan 31 23:21
time to go out and build front-end only, real-time PWA apps guys!
Jason Luboff
@JLuboff
Jan 31 23:23
I'll stick with backend as much as I can
Brad
@bradtaniguchi
Jan 31 23:27
still got the cloud functions for that kinda stuff, but all the CRUD actions become an API
Jason Luboff
@JLuboff
Jan 31 23:29
Mmhm yes yes
Jason Luboff
@JLuboff
Jan 31 23:54
When looking at a test coverage report.. what does "Branches" represent?