These are chat archives for FreeCodeCamp/Help

3rd
Sep 2018
Kyle Holm
@thekholm80
Sep 03 2018 00:35
@bjorno43 but did you get it unbanned?
Zojja
@zojjak
Sep 03 2018 00:51
Pardon me if this isn't the right place to ask but is there a preferred code playground that people like? I found Codepen but it has some limitations if you don't pay for it
Manish Giri
@Manish-Giri
Sep 03 2018 00:52
I like repl.it
Karma Drukpa
@coderkarma
Sep 03 2018 00:52
:fire:
Kyle Holm
@thekholm80
Sep 03 2018 00:52
+1 for repl.it
Manish Giri
@Manish-Giri
Sep 03 2018 00:53
altho recently I can't seem to find "ES6" in their list of language options from the dropdown
Zojja
@zojjak
Sep 03 2018 00:54
ok thanks, I'll check it out
R
@GoldenOwl_twitter
Sep 03 2018 01:40
,
Claudio Restifo
@Marmiz
Sep 03 2018 02:04
@Manish-Giri coz i think ES6 is now in javascript by default :)
or at least that's what I assume since I stopped seeing it as well
psyperl
@psyperl
Sep 03 2018 04:14
everytime i am adding css style.. i always have to look up which one is for id and which for class . vs #
wonder if there is an easy way to remember this
Ai rui 艾瑞
@aisolae
Sep 03 2018 04:26
i need lots of help
psyperl
@psyperl
Sep 03 2018 04:27
tell me about it.. me too.. lost and forgotten
Aditya Dehal
@aditya2000
Sep 03 2018 04:34
@psyperl easy way is to use one of them .... and try doing it as many times as possible
psyperl
@psyperl
Sep 03 2018 04:49
@aditya2000 yeah thanks
Ai rui 艾瑞
@aisolae
Sep 03 2018 05:02
i need help, i need to create a product page which products will be stored in the html local storage then checkout to email
i am pretty clear on the ul aspect
my major concern is the adding products to local storage and retrieval with checkout form and sending by mail
any idea is welcome
something similar to this checkout
the submit order
YiMing18
@YiMing18
Sep 03 2018 05:09
how to use font awesome
Aditya Dehal
@aditya2000
Sep 03 2018 05:12
go to font awesome's website and then follow the link saying how to use
Jun Yada
@junyada100
Sep 03 2018 05:52
@psyperl for me, my trick is to remember the id is # ; id is likely meaning of number which # can represent meaning of number
psyperl
@psyperl
Sep 03 2018 05:52
haa nice trick thanks @junyada100
Aditya Dehal
@aditya2000
Sep 03 2018 06:03
@junyada100 interesting trick
Ghost
@ghost~5b53da7dd73408ce4fa1d2e5
Sep 03 2018 07:08
hi guys, do you have any idea of using keyframes with react inline style
?
creeps
@winnypie_twitter
Sep 03 2018 07:49
How should i handle memory leak issues when switching between location real fast that handles setState on mounting process?
i have two components that gets data from my server onMount and update the state when i receives the data, but when i switch between these two components really fast like maybe when the setState is about to be process i get memory leak issue
I have no listeners or anything so can someone clarify this issue
Claudio Restifo
@Marmiz
Sep 03 2018 08:40
@isemaj_gitlab I've used styled-component for that. Way cleaner.
I guess you could write the animation as a const then use it inline, but look messy to me tbh
Ghost
@ghost~5b53da7dd73408ce4fa1d2e5
Sep 03 2018 08:40
ok, thank you
Claudio Restifo
@Marmiz
Sep 03 2018 08:41
@winnypie_twitter do you delete the request on unmount
John
@taloloy18
Sep 03 2018 12:19
Hi guys!
https://codepen.io/taloloy18/pen/gdmGrJ with how he present his portfolio is that achievable with CSS?
Ene Catalin
@EneCatalin
Sep 03 2018 12:23
that is css and js
it's just included as libraries
imported from outside
John
@taloloy18
Sep 03 2018 12:25
Ok, Thanks! :-)
Niraj Nandish
@Nirajn2311
Sep 03 2018 12:37
I can't seem to understand it
Philip Durbin
@pdurbin
Sep 03 2018 12:38
What part is confusing?
Niraj Nandish
@Nirajn2311
Sep 03 2018 12:38
I'm not sure if my code is correct
class MyComponent extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      itemCount: 0
    };
    // change code below this line
    this.addItem = this.addItem.bind(this);
    // change code above this line
  }
  addItem() {
    this.setState({
      itemCount: this.state.itemCount + 1
    });
  }
  render() {
    return (
      <div>
        { /* change code below this line */ }
        <button onClick={this.addItem()}>Click Me</button>
        { /* change code above this line */ }
        <h1>Current Item Count: {this.state.itemCount}</h1>
      </div>
    );
  }
};
Kranti Nebhwani
@darkphotonKN
Sep 03 2018 12:41
@Marmiz Hey man :) I managed to get my nodejs to handle a post request and get an image requested to it to save to a local folder. How do i do the same but put the image onto firebase but still using node (without using only firebase). I only found one tutorial and its outdated nothing worked. This is for the task of taking name a name and an image from a user and then producing a link to a page with the image and name included etc
or if anyone has experience using node to take a file or image from request and storing it on a db or soemthing please direct me to where to look or learn this
Aditya
@ezioda004
Sep 03 2018 12:42
@Nirajn2311 onClick={this.addItem}
Kranti Nebhwani
@darkphotonKN
Sep 03 2018 12:44
@Nirajn2311 basically if you do onCLick(this.addItem()} you are directly calling the function so it runs as soon as render() runs I think. So like @ezioda004 said above you need to omit the () so that its only a reference and only runs when you click the button
Niraj Nandish
@Nirajn2311
Sep 03 2018 12:44
@ezioda004 thx and @darkphotonKN thx for the explanation
Kranti Nebhwani
@darkphotonKN
Sep 03 2018 12:44
@Nirajn2311 :thumbsup:
Xarri Jorge
@xarrijorge
Sep 03 2018 14:01
Finally got my internet back today. Hurrah!
psyperl
@psyperl
Sep 03 2018 14:02
who borrowed it?
Kyle Holm
@thekholm80
Sep 03 2018 14:02
he probably left it on the bus my mistake
Xarri Jorge
@xarrijorge
Sep 03 2018 14:03
@psyperl talking to me?
psyperl
@psyperl
Sep 03 2018 14:03
@xarrijorge :D
yeah about your internet
Xarri Jorge
@xarrijorge
Sep 03 2018 14:04
My ISP was taking their time to renew it. They just did this morning after a heated discussion with customer service
@psyperl
And that is after I've paid
:wave: @thekholm80
psyperl
@psyperl
Sep 03 2018 14:05

And that is after I've paid

that's possibly the key

Kyle Holm
@thekholm80
Sep 03 2018 14:05
:wave:
Xarri Jorge
@xarrijorge
Sep 03 2018 14:05
Naa, its always prepay here so I paid last week and they didn't renew till today. @psyperl
Whats good @thekholm80
Kyle Holm
@thekholm80
Sep 03 2018 14:06
trying to pry my eyes open
:zzz:
Xarri Jorge
@xarrijorge
Sep 03 2018 14:06
Yeah, sleep is magical isn't it?
psyperl
@psyperl
Sep 03 2018 14:06
use toothpick .. ..
rarely seen anyone use matches as toothpick but...
Xarri Jorge
@xarrijorge
Sep 03 2018 14:08
He could just duck tape the eyelids to the his forehead. That should solve the problem :smile: @psyperl @thekholm80
psyperl
@psyperl
Sep 03 2018 14:08
^
Kyle Holm
@thekholm80
Sep 03 2018 14:08
if the coffee doesn't work i'll give that a shot
Xarri Jorge
@xarrijorge
Sep 03 2018 14:09
oh Coffee! Where would we be without you?
psyperl @psyperl secretly put whiskey on @thekholm80 's coffee
Smootimus
@Smootimus
Sep 03 2018 14:27
Muahaha
:D
Kyle Holm
@thekholm80
Sep 03 2018 14:32
man i hate having to go back through and document code days after writing it
dunno why it's so hard to write the comments while writing the code
psyperl
@psyperl
Sep 03 2018 14:33
is a habit.. i think
Smootimus
@Smootimus
Sep 03 2018 14:34
Yeah I can't really do it days after writing it
I mean sometimes I can
Depends
On how long lol
But I try and do it right after I get it going.
Kyle Holm
@thekholm80
Sep 03 2018 14:35
my code is heading towards spaghetti so i gotta get them comments in lol
psyperl
@psyperl
Sep 03 2018 14:36
i always put comment in my code
// this function will populate form field!
const populateFormField = x => ....
Kyle Holm
@thekholm80
Sep 03 2018 14:36
i'm using doc strings
like this:
image.png
psyperl
@psyperl
Sep 03 2018 14:39
that looks neat.. yeah for some doc rendering thing
what fonts did you use @thekholm80 ?
Smootimus
@Smootimus
Sep 03 2018 14:39
Usually
What I do
Instead of flowcharting and whatnot
is I get a blank sheet of code and I start writing comments
Kyle Holm
@thekholm80
Sep 03 2018 14:40
it's Operator Mono with ligatures added @psyperl
Smootimus
@Smootimus
Sep 03 2018 14:40
For my ideas of what I wanna do
And then I just fill it in lol
With actual code
I don't do it all the time, and sometimes I get ahead of myself
But that's one of my processes
psyperl
@psyperl
Sep 03 2018 14:42
i want that font
600 bucks? lol
Kyle Holm
@thekholm80
Sep 03 2018 14:43
it's pretty
psyperl
@psyperl
Sep 03 2018 14:43
it is.. i want it
Kyle Holm
@thekholm80
Sep 03 2018 14:43
I'll sell it to you for $550
plus shipping and handling
psyperl
@psyperl
Sep 03 2018 14:44
lol 10% disc? :p
Smootimus
@Smootimus
Sep 03 2018 14:45
Hah
I was looking into fonts when I was designing this campaign site for my class
Talk about ridiculous
Kyle Holm
@thekholm80
Sep 03 2018 14:46
google fonts ftw
free and easy to use
Smootimus
@Smootimus
Sep 03 2018 14:48
I couldn't get Google Drawings to bring in the font, tho :'(
Kyle Holm
@thekholm80
Sep 03 2018 14:48
and you call yourself a computer scientist
smh
psyperl
@psyperl
Sep 03 2018 14:48
lol
Smootimus
@Smootimus
Sep 03 2018 14:54
I know, right?!
It caused me to rethink my entire life
psyperl
@psyperl
Sep 03 2018 14:54
i've never play around with font actually
Kyle Holm
@thekholm80
Sep 03 2018 14:54
i had a major breakthrough yesterday
Smootimus
@Smootimus
Sep 03 2018 14:54
Do tell, do tell
Kyle Holm
@thekholm80
Sep 03 2018 14:55
finally got the math sorted out to be able to click stuff in my game
Smootimus
@Smootimus
Sep 03 2018 14:55
@psyperl It's not that bad really, when putting it on your system
OoOo
Kyle Holm
@thekholm80
Sep 03 2018 14:56
image.png
so now i can target stuff lol
gotta clean up the code i have before writing anything new or it's going to be a huge mess
psyperl
@psyperl
Sep 03 2018 14:57
is that up on your pen?
Kyle Holm
@thekholm80
Sep 03 2018 14:57
on codepen?
psyperl
@psyperl
Sep 03 2018 14:57
yeah
Kyle Holm
@thekholm80
Sep 03 2018 14:57
no, doing it locally
psyperl
@psyperl
Sep 03 2018 14:58
ah
Kyle Holm
@thekholm80
Sep 03 2018 14:58
codepen isn't fun to write code in
psyperl
@psyperl
Sep 03 2018 14:58
for me it is :D
Kyle Holm
@thekholm80
Sep 03 2018 14:59
i've got close to 3k lines of code so far, i'd go nuts trying to find anything in codepen
psyperl
@psyperl
Sep 03 2018 14:59
/findsomething
Screen Shot 2018-09-03 at 22.00.46.png
Kyle Holm
@thekholm80
Sep 03 2018 15:01
yeah it's not impossible, but less than ideal
psyperl
@psyperl
Sep 03 2018 15:01
hehehe
i only have normal editor on desktop ( for javascript at least ), codepen is better than anything i have locally
Kyle Holm
@thekholm80
Sep 03 2018 15:03
i like vs code, i feel it helps me work efficiently
psyperl
@psyperl
Sep 03 2018 15:03
installing vs code on my machine will feel like betraying myself :D.. not even sure if they are available here
oh it's available for most system
Kyle Holm
@thekholm80
Sep 03 2018 15:05
i'm using in in linux. it works great
psyperl
@psyperl
Sep 03 2018 15:05
i tried once yeah.. i got confused though
Smootimus
@Smootimus
Sep 03 2018 15:06
I have a few things I use
Some of the basic things
image.png
psyperl
@psyperl
Sep 03 2018 15:07
lol
Smootimus
@Smootimus
Sep 03 2018 15:07
I use Code more than anything now a days
And VS
psyperl
@psyperl
Sep 03 2018 15:07
no Steam? :p
Smootimus
@Smootimus
Sep 03 2018 15:07
Those are the two things I stay in
Nah not on this computer, I don't really use it for gaming
Kyle Holm
@thekholm80
Sep 03 2018 15:08
image.png
Smootimus
@Smootimus
Sep 03 2018 15:08
It's kinda my mobile development station
Kyle Holm
@thekholm80
Sep 03 2018 15:08
most of my coding stuff is in the VM
Smootimus
@Smootimus
Sep 03 2018 15:08
It's powerful enough to run any game, but it's an ultrabook. So it's pretty thin
Nice :D pretty similar
Kyle Holm
@thekholm80
Sep 03 2018 15:09
i <3 gimp and inkscape
Smootimus
@Smootimus
Sep 03 2018 15:09
I've been getting pretty upset with GIMP lately
psyperl
@psyperl
Sep 03 2018 15:09
Screen Shot 2018-09-03 at 22.09.05.png
Smootimus
@Smootimus
Sep 03 2018 15:09
The formats =\
Been favoring Photoshop
Kyle Holm
@thekholm80
Sep 03 2018 15:10
eww
Smootimus
@Smootimus
Sep 03 2018 15:10
GIMP isn't bad for a free solution
Kyle Holm
@thekholm80
Sep 03 2018 15:10
oh you're a student you prolly get free adobe
Smootimus
@Smootimus
Sep 03 2018 15:10
Hehe
Surprisingly it's not COMPLETELY free
But I get a great deal at a ridiculous price
In comparison
Kyle Holm
@thekholm80
Sep 03 2018 15:10
give me your copy of premier pro
Smootimus
@Smootimus
Sep 03 2018 15:10
Hah I was saying the other day how I would NEVER use that
Spark as well
Kyle Holm
@thekholm80
Sep 03 2018 15:11
i've been using HitFilm Express and it's not awesome
Smootimus
@Smootimus
Sep 03 2018 15:12
Hmm, haven't heard of that one
Video and imaging isn't my forte =\
Kyle Holm
@thekholm80
Sep 03 2018 15:12
i tried Blender but it was a nightmare
not intuitive at all
Smootimus
@Smootimus
Sep 03 2018 15:12
But Photoshop has those features and tools that GIMP is just lacking
Hmm Yeah I've heard a few people say that
psyperl
@psyperl
Sep 03 2018 15:12
maybe blender is for advance user?
Kyle Holm
@thekholm80
Sep 03 2018 15:12
gimp is just python, if it lacks anything it's your fault
Smootimus
@Smootimus
Sep 03 2018 15:13
LOL
I haven't even looked into that, honestly
PS just comes packed with it and I'm like "OH, nice!"
I NEVER touched it until I started school
Then I was like :O
"So THIS is what everyone is talking about!"
Kyle Holm
@thekholm80
Sep 03 2018 15:13
wait, maybe i'm thinking blender. one of the 2 has a python console for tweaking stuff
Smootimus
@Smootimus
Sep 03 2018 15:14
Hmm I dunno if it's gimp I haven't checked on that
Kyle Holm
@thekholm80
Sep 03 2018 15:14
that being said, 3d modeling in blender is pretty awesome
psyperl
@psyperl
Sep 03 2018 15:14
blender have python interface yeah
Smootimus
@Smootimus
Sep 03 2018 15:14
It say something about Python-Fu tho
I've been wnating to get more into 3d modeling
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:14
@Smootimus pls help
Smootimus
@Smootimus
Sep 03 2018 15:14
In the game lab, school has a sick 3d modeling
psyperl
@psyperl
Sep 03 2018 15:14
i know nothing about drawings but seen them etc
Kyle Holm
@thekholm80
Sep 03 2018 15:15
i did a few tutorials but i'm not artsy enough to really get into it
psyperl @psyperl psst @Smootimus pretend you didn't see his text
Smootimus
@Smootimus
Sep 03 2018 15:15
@diomed Sup
psyperl
@psyperl
Sep 03 2018 15:15
too late
Smootimus
@Smootimus
Sep 03 2018 15:15
:'(
Dang it
lol
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:15
https://diomed.github.io/json-generator/
I can't figure out why long text doesnt break
Smootimus
@Smootimus
Sep 03 2018 15:15
I'm wanting to go through some tuts and get more into artsy stuff
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:15
I mean I have word-break property
so what is it?
Smootimus
@Smootimus
Sep 03 2018 15:16
I was avoiding it but I really really need to get more involved
Break where
I think I see what you're talking about
When you put in a long text, why doesn't it wrap in the element?
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:19
yes
Smootimus
@Smootimus
Sep 03 2018 15:19
Like this?
image.png
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:19
yup
Smootimus
@Smootimus
Sep 03 2018 15:20
Like my testing? ;)
Hmm, gonna have to dig around here
put break-all
Just to see if it even breaks anything at all
Smootimus
@Smootimus
Sep 03 2018 15:25
Cause I don't see why it's not
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:28
mby I should have put it as a class
I'm not entirely sure. hmmm
usually these properties work on elements
Smootimus
@Smootimus
Sep 03 2018 15:29
I dunno I can't really change things and play with it lol
Ugh, I keep missing things in my ebook u.u
LydaTech
@lydatech
Sep 03 2018 15:33
injected content wont apply the css
Smootimus
@Smootimus
Sep 03 2018 15:33
Ah...
Make sense why it's not colored or styled as well
Smootimus
@Smootimus
Sep 03 2018 15:39
Writing up some sorting algos :D
And searching
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:41
@lydatech sorry, what?
LydaTech
@lydatech
Sep 03 2018 15:42
@diomed google "Injecting HTML into an element via the innerHTML input binding ignores CSS styling"
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:42
oh , and hello. long time no seen, sir
oh, I see. is there a way around that .
LydaTech
@lydatech
Sep 03 2018 15:42
:wave:
psyperl
@psyperl
Sep 03 2018 15:44
is that new cert @lydatech never heard of CTT before
ah from comptia
LydaTech
@lydatech
Sep 03 2018 15:46
@psyperl No its been around for a while. Certified technical trainer
@diomed angular?
May Kittens Devour Your Soul
@diomed
Sep 03 2018 15:46
it's not angular . just regular js
Smootimus
@Smootimus
Sep 03 2018 15:51
do it in the js maybe
like when you're doing the innerHTML
Maybe do it right there
So that way it's all being handled at that time
May Kittens Devour Your Soul
@diomed
Sep 03 2018 16:02
so, apparently
document.getElementById('result').innerHTML = <span style='word-break:break-word'>result</span>;
that's not a good way to put it
@psyperl as an avid horror fan have u seen Hereditary?
psyperl
@psyperl
Sep 03 2018 16:06
wew i don't normally watch horror @diomed :see_no_evil:
Smootimus
@Smootimus
Sep 03 2018 16:59
What you mean that's not a good way to put it?
What's it saying?
May Kittens Devour Your Soul
@diomed
Sep 03 2018 17:43
@Smootimus it doesnt insert words, just reloads
psyperl
@psyperl
Sep 03 2018 17:44
an octet is two hex digit right? just to make sure
BuntyBru
@BuntyBru
Sep 03 2018 17:45
no @thekholm80 today
?
May Kittens Devour Your Soul
@diomed
Sep 03 2018 17:46
he came, he saw, he ran away
Aditya
@ezioda004
Sep 03 2018 17:46
@psyperl Yep, each hex is 4 bits
BuntyBru
@BuntyBru
Sep 03 2018 17:46
@diomed hahah
psyperl
@psyperl
Sep 03 2018 17:46
thanks @ezioda004
Kyle Holm
@thekholm80
Sep 03 2018 17:48
@BuntyBru hey
Niraj Nandish
@Nirajn2311
Sep 03 2018 17:49
@diomed Veni Vidi fugerunt
psyperl
@psyperl
Sep 03 2018 17:49
i want something similar to Uint32Array() but in 64 bit
seems like it doesn't exists in mdn
gonna make it and probably sell it on ebay or something
Aditya
@ezioda004
Sep 03 2018 17:51
Float64Array?
BuntyBru
@BuntyBru
Sep 03 2018 17:51
@thekholm80 so whats going today
psyperl
@psyperl
Sep 03 2018 17:51
oo nice thanks.. that could do @ezioda004
Aditya
@ezioda004
Sep 03 2018 17:51
Not sure why its not called Double64Array
Kyle Holm
@thekholm80
Sep 03 2018 17:51
@BuntyBru working on a game. trying to build a bit of optimization for html5 canvas right now
you?
May Kittens Devour Your Soul
@diomed
Sep 03 2018 17:52
@Nirajn2311 Pater fugerunt
story of black kid's life
BuntyBru
@BuntyBru
Sep 03 2018 17:55
@thekholm80
pretty much done with Angular lectures
looking into small things which are a bit confusing
Kyle Holm
@thekholm80
Sep 03 2018 17:55
oh cool
progress
Kyle Holm
@thekholm80
Sep 03 2018 18:16
son of a female dog. that feeling when you spend an hour refactoring to get some performance and the outcome is worse than the original
i'm really bad at this
May Kittens Devour Your Soul
@diomed
Sep 03 2018 18:18
don't worry Kyle. I also have memory leaks.
Niraj Nandish
@Nirajn2311
Sep 03 2018 18:18
the crystal ball is telling me something @thekholm80
May Kittens Devour Your Soul
@diomed
Sep 03 2018 18:18
my designer was also bad at this
Niraj Nandish
@Nirajn2311
Sep 03 2018 18:19
And the result is - TAKE A BREAK ☕☕
May Kittens Devour Your Soul
@diomed
Sep 03 2018 18:19
@Nirajn2311 what's sad is I'm so pathetic I never got that menu thing to work :sad: :(
Niraj Nandish
@Nirajn2311
Sep 03 2018 18:20
Wait i'll be online in 20 min
Practicing for IELTS
Kyle Holm
@thekholm80
Sep 03 2018 18:20
i think i need a new hobby
maybe i'll take up stamp collecting or something. surely i'm smart enough for that
May Kittens Devour Your Soul
@diomed
Sep 03 2018 18:21
@thekholm80 pft. that's for people who lost it. you're not there yet
Kyle Holm
@thekholm80
Sep 03 2018 18:21
i guess you're right
Niraj Nandish
@Nirajn2311
Sep 03 2018 18:21
@diomed but you are
Kyle Holm
@thekholm80
Sep 03 2018 18:21
you have to have it before you can lose it
May Kittens Devour Your Soul
@diomed
Sep 03 2018 18:21
true that
altho, it's different for cats
@thekholm80 buy me a domain :smirk_cat:
@thekholm80 isn't today in USA some kind of free day from work? - labor day
Kyle Holm
@thekholm80
Sep 03 2018 18:26
yep
Aditya
@ezioda004
Sep 03 2018 18:26
So a Sunday on Monday, neat
Kyle Holm
@thekholm80
Sep 03 2018 18:26
that's why i'm writing bad code instead of doing bad work
is Object.keys() O(n)?
Aditya
@ezioda004
Sep 03 2018 18:28
Si
Kyle Holm
@thekholm80
Sep 03 2018 18:28
that's probably a large part of my problem
i guess i could use Object.entries() instead of Object.keys().forEach() and save a loop?
oh no i'd still have to iterate over them
May Kittens Devour Your Soul
@diomed
Sep 03 2018 18:32
smells like technical debt
Kyle Holm
@thekholm80
Sep 03 2018 18:33
it's a lot like trying to turbo charge a smart car. if the code is bad from the start it's hard to get it to go much faster
Aditya
@ezioda004
Sep 03 2018 18:33
@thekholm80 You need keys first?
Kyle Holm
@thekholm80
Sep 03 2018 18:33
@ezioda004 how do you iterate over an object?
Aditya
@ezioda004
Sep 03 2018 18:34
for (let key in obj){
  obj[key] //do something
}
Kyle Holm
@thekholm80
Sep 03 2018 18:34
my usual method is
const keys = Object.keys(obj);
keys.forEach(el => // magic );
Aditya
@ezioda004
Sep 03 2018 18:35
Thats 2 loops, if you need to squeeze performance then sticking to for loop is a better idea
Kyle Holm
@thekholm80
Sep 03 2018 18:35
but if Object.keys() is O(n) and Array.forEach() is O(n) i'm killing myself
that's 2O(n)
just in a single iteration
Aditya
@ezioda004
Sep 03 2018 18:36
Coefficients are usually discarded with big O, though 1 loop is better than 2
Kyle Holm
@thekholm80
Sep 03 2018 18:36
okay, gonna refactor my refactor
i could still be wrong about this whole thing though. this part of my canvas has 170 images and i was redrawing all 170 of them every update. now i'm checking to see which are different and only redrawing the images that have changed. somehow that's slower
Aditya
@ezioda004
Sep 03 2018 18:39
Hmm, that should be faster theoretically
Maybe theres something else which is also slowing things down
Kyle Holm
@thekholm80
Sep 03 2018 18:39
we'll see. probably still my garbage code slowing it down
Kyle Holm
@thekholm80
Sep 03 2018 18:45
@ezioda004 that got me some gains. i'm back to about the same as redrawing everything every update
Aditya
@ezioda004
Sep 03 2018 18:48
@thekholm80 You had no loop when you were redrawing everything?
Kyle Holm
@thekholm80
Sep 03 2018 18:49
just nested for() loops. went through row by row, column by column and redrew everything
i could probably rewrite that as a single while() loop
not sure it's worth the effort though
Aditya
@ezioda004
Sep 03 2018 18:53
Nested for loops are bad, if its achievable with a while loop then you should gain a lot of performance
Kyle Holm
@thekholm80
Sep 03 2018 18:55

i think i can change

    for (let x = -8; x < 9; x++) {
       for (let y = -5; y < 5; y++) {

to

while (x < 9 && y < 5)
then just have some if()s to increment x and y each loop
May Kittens Devour Your Soul
@diomed
Sep 03 2018 18:56
loopty doopty doo
Kyle Holm
@thekholm80
Sep 03 2018 19:00
not much of a difference with a while() loop either
oh well, just gonna give people seizures with all the screen flashing. i'm okay with that
psyperl
@psyperl
Sep 03 2018 19:01
are you sure canvas drawing doesn't have that function already? ( i dunno the answer just random question )
Kyle Holm
@thekholm80
Sep 03 2018 19:01
have what function?
psyperl
@psyperl
Sep 03 2018 19:01
drawing only the changes
Kyle Holm
@thekholm80
Sep 03 2018 19:01
not that i'm aware of
but if you know of a way i'm all ears
psyperl
@psyperl
Sep 03 2018 19:03
no i was saying maybe it's built-in already and the optimization code is doubling the process or some such .. i could be very wrong though.. although is possible
Aditya
@ezioda004
Sep 03 2018 19:04
Idk about canvas but browser do repaint/reflow for every element unless you tell them not to do
Niraj Nandish
@Nirajn2311
Sep 03 2018 19:04
@diomed did you change the nav code
Kyle Holm
@thekholm80
Sep 03 2018 19:04
@psyperl what i'm saying is, i've never seen anything on MDN or any other canvas reference that made me believe that was true, but if you come across something to that effect i'd love to read it
psyperl
@psyperl
Sep 03 2018 19:05
oh right yeah
Aditya
@ezioda004
Sep 03 2018 19:06
It's the same reason why React or any frontend libraries relies on Virtual DOM to render only things that need rendering
Repaint/reflow is expensive
psyperl
@psyperl
Sep 03 2018 19:07
i remember having similar problem on game of life.. ended up shrinking the canvas :D
Kyle Holm
@thekholm80
Sep 03 2018 19:08
it's pretty annoying
i wonder if i can pre-render the redraws to an invisible canvas and then just update with the pre-renders?
:thought_balloon:
Aditya
@ezioda004
Sep 03 2018 19:09
@thekholm80 I was reading about that here
Kyle Holm
@thekholm80
Sep 03 2018 19:10
hmm, worth a shot
psyperl
@psyperl
Sep 03 2018 19:20
so previously ( unoptimized ) you clear the canvas before redrawing everything? and then you try to optimize it by not clearing the canvas but redrawing only the portion right?
Kyle Holm
@thekholm80
Sep 03 2018 19:20
right
Kyle Holm
@thekholm80
Sep 03 2018 19:58
weird. i can prerender samples outside my project but can't get it working in the project
psyperl
@psyperl
Sep 03 2018 20:01
:D var conflict maybe
Kyle Holm
@thekholm80
Sep 03 2018 20:01
nope
psyperl
@psyperl
Sep 03 2018 20:02
yeah i tried to look around i can't remember wether i solved that issue or not, yours is more advance though, i've never try drawing an image only basic shapes
Kyle Holm
@thekholm80
Sep 03 2018 20:02
oh crap i'm dumb
psyperl
@psyperl
Sep 03 2018 20:03
what happen?
Kyle Holm
@thekholm80
Sep 03 2018 20:04
i was drawing the pre-rendered canvas to the existing canvas inside the pre-render method. moving it didn't fix it though
i probably need to take a break for a while lol
psyperl
@psyperl
Sep 03 2018 20:05
yeah you probably get too intense and can't focus
Kyle Holm
@thekholm80
Sep 03 2018 20:06
i just start making assumptions that make it really hard to debug, like "this is all correct so why isn't it working" when if it was actually correct it would work lol
psyperl
@psyperl
Sep 03 2018 20:06
too much coffeee :D
Aditya
@ezioda004
Sep 03 2018 20:07
@thekholm80 Just blame JS and get a lemonade
Kyle Holm
@thekholm80
Sep 03 2018 20:07
lol
Xarri Jorge
@xarrijorge
Sep 03 2018 20:31
:wave:
Kyle Holm
@thekholm80
Sep 03 2018 20:33
@xarrijorge :wave:
May Kittens Devour Your Soul
@diomed
Sep 03 2018 20:53
mistakes. mistakes were made
Kyle Holm
@thekholm80
Sep 03 2018 20:57
i saw that on a subreddit i can't share here
Xarri Jorge
@xarrijorge
Sep 03 2018 20:59
Yeah, nothing like experience eh?
Aditya
@ezioda004
Sep 03 2018 21:11
>17
<17
>017
<15
>018
<18
Thats enough JS for the day
Kyle Holm
@thekholm80
Sep 03 2018 21:12
i think you broke it
May Kittens Devour Your Soul
@diomed
Sep 03 2018 21:13
is 017 > or < 17
Aditya
@ezioda004
Sep 03 2018 21:15
@thekholm80 Cant break something thats already broken
17 === 017 //false
18 === 018 //true
Kyle Holm
@thekholm80
Sep 03 2018 21:16
does === compare values or convert to something and compare those values?
Aditya
@ezioda004
Sep 03 2018 21:23
Each number is an expression so it evaluates and then compares, its comparing 17 to 15
Not sure why 017 evaluates to 15 though, but seems consistent (017).toString(10) //15
Kyle Holm
@thekholm80
Sep 03 2018 21:24
i was digging through the ECMA docs lol
11.9.6 The Strict Equality Comparison Algorithm
The comparison x === y, where x and y are values, produces true or false. Such a comparison is
performed as follows:
  1. If Type(x) is different from Type(y), return false.
  2. If Type(x) is Undefined, return true.
  3. If Type(x) is Null, return true.
  4. If Type(x) is not Number, go to step 11.
  5. If x is NaN, return false.
  6. If y is NaN, return false.
  7. If x is the same number value as y, return true.
  8. If x is +0 and y is −0, return true.
  9. If x is −0 and y is +0, return true.
  10. Return false.
    11.If Type(x) is String, then return true if x and y are exactly the same sequence of characters (samelength and same characters in corresponding positions); otherwise, return false.
  11. If Type(x) is Boolean, return true if x and y are both true or both false; otherwise, return false.
    13.Return true if x and y refer to the same object or if they refer to objects joined to each other (see13.1.2). Otherwise, return false.
Aditya
@ezioda004
Sep 03 2018 21:31
@thekholm80 I think I get why
Any number starting from 0, engine assumes its octal..so 015 == (8^1)*1 + (8^0)*5
Kyle Holm
@thekholm80
Sep 03 2018 21:33
oh so you're saying it's user error
JS is perfect, you're using it wrong
got it
Aditya
@ezioda004
Sep 03 2018 21:33
Since octals consist of [0-7], 018 is not valid in octal system
@thekholm80 My fav is this:
let y = 0/0;
var arr = [y];
arr.includes(y); //true
arr.indexOf(y); // -1
Kyle Holm
@thekholm80
Sep 03 2018 21:36
that's weird
Aditya
@ezioda004
Sep 03 2018 21:36
Goodluck debugging that :D
Kyle Holm
@thekholm80
Sep 03 2018 21:37
i have a hard enough time debugging my own garbage code, you're gonna have to figure yours out yourself :joy:
Aditya
@ezioda004
Sep 03 2018 21:38
There should be a program which evaluates your code and automatically deletes it, if its garbage
I'll have net total of 0 projects left
Kyle Holm
@thekholm80
Sep 03 2018 21:39
oooh maybe we should make a node script that will go through all your github repos and delete those that don't pass muster
Aditya
@ezioda004
Sep 03 2018 21:41
Instead of node script, we should make a proposal to the ECMAScript people
Though I'm afraid it'll end up deleting JS itself
Kyle Holm
@thekholm80
Sep 03 2018 21:41

i can just imagine SO after:

every time i write code it disappears, HALP

if they did that for every language Windows would disappear
Aditya
@ezioda004
Sep 03 2018 21:42
Except Web servers made of PHP
Because its the perfect language
Kyle Holm
@thekholm80
Sep 03 2018 21:46
i heard after the apocalypse all that will be left is cockroaches and PHP
and Keith Richards, for some reason
Zojja
@zojjak
Sep 03 2018 21:46
I thought it was twinkies
Kyle Holm
@thekholm80
Sep 03 2018 21:47
oh, well that's good news for the cockroaches and Keith Richards
Kyle Holm
@thekholm80
Sep 03 2018 21:53
Aditya
@ezioda004
Sep 03 2018 21:57
/r/petthedamndog
@ezioda004 @thekholm80 need a help on this.
Kyle Holm
@thekholm80
Sep 03 2018 22:35
ok
Karma Drukpa
@coderkarma
Sep 03 2018 22:54
function diamond(n){
 // if n even  || negative just return null
 // create empty str
 // do for loop starting at 1 and upto n times incrementing by 2
 // do another loop starting from backword to 
 //  concate asteriks and return
 let str = '';
    if (n % 2 === 0 || n < 0 ){
        return null;
 }
 for (let i = 1; i <=n; i += 2){
         str += "*";
         console.log(str, i);

     }
}
diamond(3)
any hints @thekholm80
Karma Drukpa
@coderkarma
Sep 03 2018 23:24
@thekholm80
hello
@ezioda004 are you online?
Aditya
@ezioda004
Sep 03 2018 23:58
@coderkarma For diamond(3) the pattern is " *\n***\n *\n"