These are chat archives for FreeCodeCamp/HelpJavaScript

20th
Jun 2018
Aymen
@AymenAlSalem
Jun 20 2018 00:41
Hi everyone , do I have always to define if-statment-false in conditional (ternary) operator ?
for (let i = 0 ; i < arr.length ; i++){
arr[i].indexOf(elem) < 0 ? newArr.push(elem) ; // error
arr[i].indexOf(elem) < 0 ? newArr.push(elem)  :  false // works fine
}
Tom
@moT01
Jun 20 2018 00:44
@AymenAlSalem i think so - you can put null if your looking for a placeholder
Brad
@bradtaniguchi
Jun 20 2018 00:47
I dislike the idea of using the ternary like that tho. A single line if is clearer/shorter, or just a normal if is the way to go.
Aymen
@AymenAlSalem
Jun 20 2018 00:49
thank you @moT01 and @bradtaniguchi
Brad
@bradtaniguchi
Jun 20 2018 00:50
np :D
pein
@pein
Jun 20 2018 01:01
image.png
ping @bradtaniguchi :)
Brad
@bradtaniguchi
Jun 20 2018 01:01
I can't read that haha
pein
@pein
Jun 20 2018 01:01
oupss !
image.png
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:10
@pein Please use services like Codepen or Pastebin when posting large walls of code (40+ lines). It disrupts the chat for other members and is therefor against our Code of Conduct
abraham anak agung
@padunk
Jun 20 2018 01:10
@pein use .map instead of foreach
pein
@pein
Jun 20 2018 01:13
@bjorno43 sorry :)
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:18
@pein No worries, no harm done ^^
anthonygallina1
@anthonygallina1
Jun 20 2018 01:22
Is 39 ok? :wink:
K sry sry Hi @bjorno43 :smile:
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:24
@anthonygallina1 lol, hi :smile:
DarkxPunk
@DarkxPunk
Jun 20 2018 01:24
Howdy
anthonygallina1
@anthonygallina1
Jun 20 2018 01:24
:smile:
DarkxPunk
@DarkxPunk
Jun 20 2018 01:24
So I am having a stupid moment...
anthonygallina1
@anthonygallina1
Jun 20 2018 01:25
Good you took it the right way I was nervous for a sec
DarkxPunk
@DarkxPunk
Jun 20 2018 01:25
        var navs = element.querySelectorAll('.backward');
        navs[0].addEventListener('click', changeSlide(-1));
        var navs = element.querySelectorAll('.forward');
        navs[0].addEventListener('click', changeSlide(1));

        function changeSlide(n) {
            var slideIndex;
            return function() {
                alert(n);
                var i;
                var slides = element.querySelectorAll('.slide');
                if (n > slides.length) { slideIndex = 1 }
                if (n < 1) { slideIndex = slides.length }
                for (i = 0; i < slides.length; i++) {
                    slides[i].classList.remove("active");
                }
                alert(slideIndex);
                slides[slideIndex-1].classList.add("active");
            }
        }
Why is slideIndex coming up undefined?
I am getting deeply frustrated with this...
Christopher McCormack
@cmccormack
Jun 20 2018 01:27
where are you logging it?
DarkxPunk
@DarkxPunk
Jun 20 2018 01:27
I am not… I am just having it alert me.
Christopher McCormack
@cmccormack
Jun 20 2018 01:28
if neither of your conditionals are hit it's going to be undefined
test that by assigning something when you declare it
abraham anak agung
@padunk
Jun 20 2018 01:30
@DarkxPunk i think an array will start from 0 to array.length -1
pein
@pein
Jun 20 2018 01:30
@bjorno43 didn't work
const resultDisplayArray = arr.map((e) => `<li class="text-warning"> ${e} </li>`);
abraham anak agung
@padunk
Jun 20 2018 01:30
@pein remove your space in ${e}. space is really matter :)
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:32
@anthonygallina1 I'm good. Just very busy tonight. You?
anthonygallina1
@anthonygallina1
Jun 20 2018 01:32
WOW started vagrant
Doing repl sets and keys and scramsha on sets
I never used vagrant before I seem to be picking it up fast though Kiiinda like getting thrown in a pool
Mongo repl sets
certs too etc
pem time
Whats new with you? @bjorno43
pein
@pein
Jun 20 2018 01:35
@bjorno43 done! thanx again :clap:
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:37
@pein Please check who you're tagging :P
abraham anak agung
@padunk
Jun 20 2018 01:37
Hi all, what is SCRUM / agile environment or agile development?
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:37
@anthonygallina1 Nothing much. Got 2 websites, 1 chatsystem and 1 CRM system to work on.
anthonygallina1
@anthonygallina1
Jun 20 2018 01:39
@bjorno43 COOL!
Christopher McCormack
@cmccormack
Jun 20 2018 01:39
@padunk that's a big question, you may want to find some overview videos. It's basically methodology for managing projects/issues
it's not just one thing
anthonygallina1
@anthonygallina1
Jun 20 2018 01:40
@bjorno43 whats the framework on the CRM?
abraham anak agung
@padunk
Jun 20 2018 01:40
@cmccormack you have a link to the videos ? most of jobs kind of required it ?
anthonygallina1
@anthonygallina1
Jun 20 2018 01:41
Or is there one? Meen from scratch?
pein
@pein
Jun 20 2018 01:41
@bjorno43 :laughing:
Christopher McCormack
@cmccormack
Jun 20 2018 01:41
@padunk I would just google Agile Development
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:41
@anthonygallina1 No framework yet. I didn't start on that one. They want something simular to vTigerCRM though
Christopher McCormack
@cmccormack
Jun 20 2018 01:41
My work put me through a class but I haven't watched any videos online
abraham anak agung
@padunk
Jun 20 2018 01:41
@cmccormack ok cool. Thanks
Christopher McCormack
@cmccormack
Jun 20 2018 01:42
Honestly unless you're trying to implement it within your organization, the company you work for will tell you how it works. It's not all that complicated
anthonygallina1
@anthonygallina1
Jun 20 2018 01:42
@bjorno43 ummm Tiger I dont know that one I dont think
abraham anak agung
@padunk
Jun 20 2018 01:43
@cmccormack i still searching for jobs :smile: but almost all the requirement put agile development or environment with Jenkins. etc...
anthonygallina1
@anthonygallina1
Jun 20 2018 01:43
Googles :worried:
Christopher McCormack
@cmccormack
Jun 20 2018 01:43
@padunk they probably just hope you have experience but that isn't going to stop them from hiring you if that's the only thing you're lacking
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:44
@anthonygallina1 https://www.vtiger.com/ It's a PHP based CRM. Used to be free in the past, now it costs money per user per month. So they want something for themselves
abraham anak agung
@padunk
Jun 20 2018 01:44
@cmccormack yeah, i hope so. Thanks again.
Christopher McCormack
@cmccormack
Jun 20 2018 01:45
@padunk np
anthonygallina1
@anthonygallina1
Jun 20 2018 01:45
@bjorno43 yup just saw it it looks good
@bjorno43 I did a tech help desk once static files and remote access
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:46
Ah cool :)
anthonygallina1
@anthonygallina1
Jun 20 2018 01:47
Man my training wheels are still on with the Mongo repl security But doing sh files and the automation is going to be nice
Bjorn van de Peut
@bjorno43
Jun 20 2018 01:48
Well they mostly just want a workflow like system. Customer registration and creation of support tickets, stuff like that
anthonygallina1
@anthonygallina1
Jun 20 2018 01:48
Sounds great!
Nico Mee
@nicoandmee
Jun 20 2018 05:25
https://gist.github.com/nicoandmee/6e938fe0ebde35c3a7d1f7d79caa083f Can anyone help me out- trying to just access the value from stream.once() which contains a one time passcode from email inbox. I need to access this value from another js file/script and await on it. My bot needs it to complete the login process on this site, thanks so much
Simon Cordova
@gbsimon87
Jun 20 2018 07:54
var state = {
    currentPlayer: '',
    teamRoster: [
        { name: 'GB', age: 30, location: 'London'},
        { name: 'Maren', age: 36, location: 'London'},
        { name: 'Daniel', age: 31, location: 'Toronto'},
    ]
}
Hey all, was wondering if anyone could offer some insight, I think I'm on the right track using Object.keys and map, but can't quite achieve it.
I've got an object, which one of the keys is an array of objects.
I need to get into one specific key and change the properties there...
For example, I'd like to click a button in the DOM which will increase age for the name 'GB'
Stephen James
@sjames1958gm
Jun 20 2018 10:04
@gbsimon87 Is this react? Where you don't want to mutate the state?
Simon Cordova
@gbsimon87
Jun 20 2018 10:47
@sjames1958gm
Indeed, but I wouldn't mutate the state directly - I've actually found a way to do it, someone offered help in another channel recently, eventually I'll look for a more 'ES6' way to go about it rather than using a for-in loop
Although there's nothing wrong with simplicity and the roots
Stephen James
@sjames1958gm
Jun 20 2018 10:59
@gbsimon87 I also answered this on another channel with es6 code which doesn't mutate state
Blauelf
@Blauelf
Jun 20 2018 12:51
I don't really understand why one would need Object.keys here. Are the property names not predefined?
Simon Cordova
@gbsimon87
Jun 20 2018 14:30
@Blauelf
I was thinking of using Object.keys due to the fact I need to go back to the basics before continuing on and touch up my object and array iterating skills tbh with you
Jose Pagan
@josepagan
Jun 20 2018 14:46
I am struggling a little bit with regular expressions. Maybe I need a walk in the park
koder3
@koder3
Jun 20 2018 14:52
image.png
can someone explain why im gettting a decimal value
koder3
@koder3
Jun 20 2018 14:57
@crokita Thanks, that solves the issue :)
Chris
@crokita
Jun 20 2018 14:57
nice
Simon Cordova
@gbsimon87
Jun 20 2018 15:07
Hey all, stuck again...
Got an object with the following structure, would like to check if a name exists more than once...
var state = {
    currentPlayer: '',
    teamRoster: [
        { name: 'GB', points: 0, assists: 0, rebounds: 0, steals: 0, turnovers: 0},
        { name: 'Mike', points: 0, assists: 0, rebounds: 0, steals: 0, turnovers: 0},
        { name: 'GB', points: 0, assists: 0, rebounds: 0, steals: 0, turnovers: 0},
    ]
}
I need to redo the FCC algorithm courses smh
Jason Luboff
@JLuboff
Jun 20 2018 15:08
@gbsimon87 Create a secondary object that keeps count?
Christopher McCormack
@cmccormack
Jun 20 2018 15:09
That's what I would do @JLuboff :D
also :wave:
Jason Luboff
@JLuboff
Jun 20 2018 15:09
:wave:
Whats the haps?
Simon Cordova
@gbsimon87
Jun 20 2018 15:09
This is what I've got but it's not working...
checkIfPlayerNamesAreDifferent = () => {
        const currentRoster = this.state.teamPlayers
        console.log(currentRoster)
        let counts = [];
        let currentRosterLength = currentRoster.length;
        for(let i = 0; i <= currentRosterLength; i++) {
            if(counts[currentRoster[i]] === undefined) {
                counts[currentRoster[i]] = 1;
            } else {
                // console.log('repeated')
                alert(`The name ${currentRoster[i]} has been entered more than once.\nPlease remove one and enter unique names for each player. `)
                return true;
            }
        }
        this.checkForNoDigits();
        return false;
    }
Christopher McCormack
@cmccormack
Jun 20 2018 15:10
Just bashing away at some projects in hope I can make some progress
Simon Cordova
@gbsimon87
Jun 20 2018 15:11
@cmccormack so am I, trying to finish this basketball statskeeping app, feel like a turtle on it
Christopher McCormack
@cmccormack
Jun 20 2018 15:11
@gbsimon87 maybe try to do this more functionally, instead of checking in a loop, build a new object that has the player's name as a key, and maybe their object as a value, adding an additional count property
then you can refer to the new object if you need to see if there are duplicates
if you're simply trying to merge, you can do that as part of your loop pretty easy as well
Jason Luboff
@JLuboff
Jun 20 2018 15:13
@cmccormack Work or personal project?
Blauelf
@Blauelf
Jun 20 2018 15:13

@gbsimon87 Did you mean < instead of <=?

Also, what if you did const counts = Object.create(null); (which was my version of a dictionary before ES6 maps)?

Simon Cordova
@gbsimon87
Jun 20 2018 15:14

@cmccormack
Hmm...Right now I've got a function that sets a 'teamPlayers' array in the React state

    addPlayerToRosterHandler = () => {
        const currentPlayerName = this.state.currentPlayerName;
        const newPlayerObject = {
            name: currentPlayerName,
            points: 0,
            assists: 0,
            rebounds: 0,
            steals: 0,
            turnovers: 0
        }
        if ( currentPlayerName !== '' ) {
            this.setState((prevState, props) => {
                return {
                    // teamRoster: [...prevState.teamRoster, currentPlayerName],
                    showHideEnterParagraphText: false,
                    currentPlayerName: '',
                    teamPlayers: [...prevState.teamPlayers, newPlayerObject]
                }
            });
        }
    }

@JLuboff personal but I've actually approached the basketball league I play in and they're willing to adapt it

Sorry, that's a huge code block
But that sets the 'teamPlayers' array by pushing 'newPlayerObject' to it...
Then once the team is created, I've got a 'submit team' btn which I want to make sure there are no duplicate names
Christopher McCormack
@cmccormack
Jun 20 2018 15:16
@JLuboff work. lots of projects converging on deadlines :/
Simon Cordova
@gbsimon87
Jun 20 2018 15:16
@Blauelf yes I did mean < thank you
@cmccormack So you recommend I check if the name already exists in the state before allowing the user to add it to the 'teamPlayers' array?
I need to seriously review arrays and objects this is ridiculous
Christopher McCormack
@cmccormack
Jun 20 2018 15:18
@gbsimon87 not really I was suggesting you iterate over the array and make a new object that merges properties if the name is the same
@gbsimon87 here is a crappy example of what I meant
Jason Luboff
@JLuboff
Jun 20 2018 15:21
@gbsimon87 Willing to adapt...for a fee...? :smile:
@cmccormack Oh deadlines, fun
Simon Cordova
@gbsimon87
Jun 20 2018 15:21
@JLuboff you forgot the 'r' after the 'f' in free lolol
Jason Luboff
@JLuboff
Jun 20 2018 15:21
Hah
Simon Cordova
@gbsimon87
Jun 20 2018 15:21
@cmccormack thanks buds I'll check it out
Jason Luboff
@JLuboff
Jun 20 2018 15:22
That took me moment... I just put a bunch of keys back on my keyboard since I spilled coffee on it last week and thought my 'r' wasn't working when you said that
Simon Cordova
@gbsimon87
Jun 20 2018 15:23
Happy to be back in the community, I made FCC gitter my homepage to remember to come around, it's good to be surrounded by other developers
Christopher McCormack
@cmccormack
Jun 20 2018 15:27
@JLuboff haha I hope it wasn't a pricey keyboard
Jason Luboff
@JLuboff
Jun 20 2018 15:29
@cmccormack Eh. Logitech mk710.. not too expensive. Plus I didn't pay for it. But they designed it well actually, very unluckily to damage unless you spill an entire cup on the thing. It's not the butterfly style keys but raised cylinders that the keys pop into (if that makes sense)
Christopher McCormack
@cmccormack
Jun 20 2018 15:32
oh I have a predecessor to that one in my closet
Jason Luboff
@JLuboff
Jun 20 2018 15:33
That was supposed to be unlikely not unluckily. Jesus it's too early
Christopher McCormack
@cmccormack
Jun 20 2018 15:33
sure you put those keys back in the right place? :D
Jason Luboff
@JLuboff
Jun 20 2018 15:33
Har har har
Markus Kiili
@Masd925
Jun 20 2018 16:45
Jesus :imp:
Brad
@bradtaniguchi
Jun 20 2018 16:54
@gbsimon87 :+1:
Simon Cordova
@gbsimon87
Jun 20 2018 17:21

Guys I give up, need a hand, or a break. I've restructured part of my code and now I'm back at creating the players Object
If I've got an array...

var players = ['GB', 'Mike','Katelyn']

How can I turn that into an array of objects where each array index is the key for each object, for example...

var convertedObject = {
    GB: {
          points: 0, assists: 0
    },
    Mike: {
          points: 0, assists: 0
    },
    Katelyn: {
          points: 0, assists: 0
    }
}

I tried with @cmccormack code earlier but I can't quite get it for multiple categories

Christopher McCormack
@cmccormack
Jun 20 2018 17:24
@gbsimon87 do you want an array of objects or an object of objects?
Brad
@bradtaniguchi
Jun 20 2018 17:25
I see map used here
Christopher McCormack
@cmccormack
Jun 20 2018 17:25
using an index as a key is almost the same is just using an array, fyi, unless you're using a player number or something like that as your index
@bradtaniguchi agreed
Brad
@bradtaniguchi
Jun 20 2018 17:26
hmm, reduce and map? Or just reduce hehe
The advantage of a map is the faster lookup tho
Simon Cordova
@gbsimon87
Jun 20 2018 17:27
The problem I'm facing at the moment is when setting the state of the specific player, I think I rather just use dot notation
I'm not sure how to access the exact player that was clicked if all my players are objects within an array
Christopher McCormack
@cmccormack
Jun 20 2018 17:28
@gbsimon87 if you're using an array of objects, best thing I find to do is create a component for each object. Then you will have the details of that object in your props and can use that in your callbacks
Simon Cordova
@gbsimon87
Jun 20 2018 17:30
image.png
As you can see, I've been able to update the state, just can't update the DOM with the new value because I don't know how to access that specific player...
Christopher McCormack
@cmccormack
Jun 20 2018 17:40
Maybe something like this is what you're trying to do?
Simon Cordova
@gbsimon87
Jun 20 2018 17:44
@cmccormack thanks a lot man for the help about to check it out :)
Christopher McCormack
@cmccormack
Jun 20 2018 17:45
@gbsimon87 I know it's not what you're trying to implement but I wanted to show how you can use each object in an array as a component using methods passed from a parent component
Simon Cordova
@gbsimon87
Jun 20 2018 17:47
@cmccormack Indeed, that's actually very similar to the implementation I've got atm, let me show you one part which I think is where my issue lies
Simon Cordova
@gbsimon87
Jun 20 2018 17:59
@cmccormack
https://codepen.io/gbsimon87/pen/mKxVae?editors=1010
This is how my table is being generated more or less
Christopher McCormack
@cmccormack
Jun 20 2018 18:01
this code is broken @gbsimon87
Jason Luboff
@JLuboff
Jun 20 2018 18:01
You're broken
Christopher McCormack
@cmccormack
Jun 20 2018 18:02
@JLuboff don't make me cry at work man!
Jason Luboff
@JLuboff
Jun 20 2018 18:02
....you're at home...no one will notice
Christopher McCormack
@cmccormack
Jun 20 2018 18:02
... still though
Jason Luboff
@JLuboff
Jun 20 2018 18:02
:smile:
Erg... need to figure out how to get pm2 to set the enviornment variable in windows
Christopher McCormack
@cmccormack
Jun 20 2018 18:04
you're using it with an npm script?
Jason Luboff
@JLuboff
Jun 20 2018 18:04
Trying to...but what I've tried so far doesn't work
Simon Cordova
@gbsimon87
Jun 20 2018 18:04
@cmccormack I realised it's broken as I went back to it...you know what, I think I need a break - but I'm going to try your approach, instead of just creating a table with td's I will create playerComponents for the table rows so I can props through
Christopher McCormack
@cmccormack
Jun 20 2018 18:05
Jason Luboff
@JLuboff
Jun 20 2018 18:05
@cmccormack No, but I may have found something to try
Christopher McCormack
@cmccormack
Jun 20 2018 18:05
@gbsimon87 yeah man break everything out into components, makes it much easier
Simon Cordova
@gbsimon87
Jun 20 2018 18:07
Yeah, I've just got so many already lol, but I guess it makes sense
Christopher McCormack
@cmccormack
Jun 20 2018 18:09
reconsider doing so much reassignment as well, you already have values keep using them
@gbsimon87 tableHeaders, if a React component, should be defined outside TeamStatsTrackingTable
Simon Cordova
@gbsimon87
Jun 20 2018 18:12
image.png
outside the const TeamStatsTrackingTable you mean?
Christopher McCormack
@cmccormack
Jun 20 2018 18:12
Also you created TeamStatsTrackingTable as a functional component, you don't use render inside those and they aren't objects
Jason Luboff
@JLuboff
Jun 20 2018 18:12
@cmccormack pm2 start app.js --name MOCRequest --env production thought this should work...but my process.env.NODE_ENV is still empty.. hmm
Christopher McCormack
@cmccormack
Jun 20 2018 18:12
oh my bad you aren't, read it wrong sorry
Simon Cordova
@gbsimon87
Jun 20 2018 18:13
I'm going for a 10 min break, @cmccormack I honestly appreciate the help
Christopher McCormack
@cmccormack
Jun 20 2018 18:13
@JLuboff don't use NODE_ENV
@gbsimon87 np
Jason Luboff
@JLuboff
Jun 20 2018 18:13
Just process.env?
Christopher McCormack
@cmccormack
Jun 20 2018 18:13
@JLuboff log your process.env, you probably have a production property now
I dunno those environment variables are a pain the butt haha
Jason Luboff
@JLuboff
Jun 20 2018 18:15
Mm....that gives me an object...let me stringify it
Christopher McCormack
@cmccormack
Jun 20 2018 18:16
@JLuboff yeah it's an object
sorry
Jason Luboff
@JLuboff
Jun 20 2018 18:17
Thats turning out to be a deep deep rabbit hole. Let me try something else lol
Christopher McCormack
@cmccormack
Jun 20 2018 18:18
really?
Jason Luboff
@JLuboff
Jun 20 2018 18:18
Ya...it has an env property, but it is also an object...but it wouldn't stringify it so
Christopher McCormack
@cmccormack
Jun 20 2018 18:19
it should, should just be a bunch of environment variables as property/value pairs
maybe it's a buffer or something?
Jason Luboff
@JLuboff
Jun 20 2018 18:20
Maybe. Dunno. Trying to create an ecosystem file instead
Brad
@bradtaniguchi
Jun 20 2018 18:21
create a what?
Christopher McCormack
@cmccormack
Jun 20 2018 18:22
I'm actually a bit confused by your pm2 script - does your app accept options, or is that something with node/express?
if you have the docs for that I'd love to read them
Jason Luboff
@JLuboff
Jun 20 2018 18:22
I'm just trying to get the ennvironment set to production
Brad
@bradtaniguchi
Jun 20 2018 18:23
whoa pm2 >.>
Christopher McCormack
@cmccormack
Jun 20 2018 18:24
@JLuboff don't you have a node script that works already? I still think you should just use crossenv and call your node script, personally :)
Jason Luboff
@JLuboff
Jun 20 2018 18:24
The reason I'm trying to use pm2 is so that my app will automatically start back up on server reboot ;)
Christopher McCormack
@cmccormack
Jun 20 2018 18:25
pm2 is great, not sure what @bradtaniguchi means
Brad
@bradtaniguchi
Jun 20 2018 18:25
I dont know much about it, looks cool. I mean nothing negative :D
Jason Luboff
@JLuboff
Jun 20 2018 18:25
The monitoring and log, etc is nice with pm2 as well
Christopher McCormack
@cmccormack
Jun 20 2018 18:26
>.> usually means devious or guilty or skeptical
Brad
@bradtaniguchi
Jun 20 2018 18:26
This is for when I have a linux box (not a container) right?
Maybe I'm just a devious person :P (My resting face looks like that, or what Ive been told. When I'm not a robot)
Christopher McCormack
@cmccormack
Jun 20 2018 18:29
haha
@bradtaniguchi it could probably work in a container, not sure why not.
But yeah what @JLuboff stated is a good use case, if the app crashes or server reboots you want your app to reload
Jason Luboff
@JLuboff
Jun 20 2018 18:31
Whooo figured it out

Still not sure why my script above didn't work..but using the ecosystem file.. you run

pm2 start ecosystem.config.js --env production

And it'll work

Christopher McCormack
@cmccormack
Jun 20 2018 18:34
and the path to your app is in that file?
Jason Luboff
@JLuboff
Jun 20 2018 18:35
Ya
Christopher McCormack
@cmccormack
Jun 20 2018 18:35
neat
still think crossenv would be easier :)
Jason Luboff
@JLuboff
Jun 20 2018 18:35
module.exports = {
  apps: [
    {
      name: 'MOCRequest',
      script: 'app.js',
      watch: true,
      env: {
        COMMON_VARIABLE: 'true',
      },
      env_production: {
        NODE_ENV: 'production',
      },
    },
  ],
};
So you can technically have multiple apps within that file. Also you can have deployment info but I'm not advanced enough for that lol
So env would be where I would set NODE_ENV to development
Christopher McCormack
@cmccormack
Jun 20 2018 18:41
That's pretty cool. What did you use in windows to load pm2 if it crashes
Jason Luboff
@JLuboff
Jun 20 2018 18:42
Haven't made it that far, but looks like there is https://www.npmjs.com/package/pm2-windows-service for creating the service easily (haven't finished reading it though)
Also another good reason for pm2... I have added a process to listen for uncaughtExceptions, which will send me an email when they occur and kill the app, which pm2 will then restart ;)
Christopher McCormack
@cmccormack
Jun 20 2018 18:44
that is pretty cool
Jason Luboff
@JLuboff
Jun 20 2018 18:44
I read that as a best practice, so boom!
Christopher McCormack
@cmccormack
Jun 20 2018 18:45
@JLuboff gets the Pro Developer Badge!
Jason Luboff
@JLuboff
Jun 20 2018 18:46
...in many moons from now perhaps
Christopher McCormack
@cmccormack
Jun 20 2018 18:47
Hey there's one every night most nights, many shouldn't take long!
Jason Luboff
@JLuboff
Jun 20 2018 18:47
Correction many full moons*
Christopher McCormack
@cmccormack
Jun 20 2018 18:48
boo
Simon Cordova
@gbsimon87
Jun 20 2018 19:00
I can't remember that last time I was so stuck with something fml
I know it'll be that more rewarding later but damn
Jason Luboff
@JLuboff
Jun 20 2018 19:05
It'll never be rewarding. You'll fall into a deep depression.
I kid I kid of course
Christopher McCormack
@cmccormack
Jun 20 2018 19:12
Haha it does get better. I was totally lost in React at first and now I was able to bust out that example I showed in about 4 minutes. It's just practice
Simon Cordova
@gbsimon87
Jun 20 2018 19:14

thanks @cmccormack

Some progress, I've been able to update the UI, however it sets the state, then when I click the component, it updates

any idea what may cause it?
Christopher McCormack
@cmccormack
Jun 20 2018 19:15
isn't that what you wanted?
Simon Cordova
@gbsimon87
Jun 20 2018 19:17
It's not updating right away, I have to do a follow-up click
Christopher McCormack
@cmccormack
Jun 20 2018 19:19
not sure, are you sure it's initially providing a value?
do you have a pen to share?
Jason Luboff
@JLuboff
Jun 20 2018 19:20
Any ideas on what status code I would want to send for a Database error? I was thinking 418, but people may not find that funny
Christopher McCormack
@cmccormack
Jun 20 2018 19:20
I don't get it
Simon Cordova
@gbsimon87
Jun 20 2018 19:20
teapot?
Jason Luboff
@JLuboff
Jun 20 2018 19:20
Status code 418 = 'I'm a teapot'
Simon Cordova
@gbsimon87
Jun 20 2018 19:20
just looked that up lol
Christopher McCormack
@cmccormack
Jun 20 2018 19:20
haha
Jason Luboff
@JLuboff
Jun 20 2018 19:20
I'm thinking of just going with 500
Christopher McCormack
@cmccormack
Jun 20 2018 19:21
wasn't it node or npm that actually had that error pop up recently?
Simon Cordova
@gbsimon87
Jun 20 2018 19:21
@cmccormack I don't have it in a pen no, I feel it would take a bit to generate in a pen daaaaamn me
nothing easy these days lolol
Christopher McCormack
@cmccormack
Jun 20 2018 19:21
@gbsimon87 no worries
@gbsimon87 it may be good to break out your logic into segments in a pen or another file just to test it out in a more simple environment
Simon Cordova
@gbsimon87
Jun 20 2018 19:22
@cmccormack great point tbh
Jason Luboff
@JLuboff
Jun 20 2018 19:23
Yup.. going with 500... seems the most logical. Anyways..gym time..see ya in a bit
Christopher McCormack
@cmccormack
Jun 20 2018 19:23
@JLuboff later
Simon Cordova
@gbsimon87
Jun 20 2018 19:25
cheers @JLuboff
Simon Cordova
@gbsimon87
Jun 20 2018 20:21
@cmccormack
I GOT IT!
Was missing a god DAMN parantheses
Jason Luboff
@JLuboff
Jun 20 2018 20:27
Don't forget your parenthesis dog
Christopher McCormack
@cmccormack
Jun 20 2018 20:34
@gbsimon87 a good error handler should help with that!
anthonygallina1
@anthonygallina1
Jun 20 2018 20:38
@JLuboff 418 :smile: is that the tea pot error?
Jason Luboff
@JLuboff
Jun 20 2018 20:38
@anthonygallina1 Yup!
anthonygallina1
@anthonygallina1
Jun 20 2018 20:38
LOL
:smile:
I have a coffe cup that has whos your data printed on it.
Jason Luboff
@JLuboff
Jun 20 2018 20:40
Heh
anthonygallina1
@anthonygallina1
Jun 20 2018 20:42
Ya my GF got it and gave it to me
How about all your bases belong to etc Like the saying
Or a catchy European saying?
anthonygallina1
@anthonygallina1
Jun 20 2018 20:49
I saw these n Maybe Drempel?
Jason Luboff
@JLuboff
Jun 20 2018 20:58
Yup thats the one
anthonygallina1
@anthonygallina1
Jun 20 2018 21:06
:smile:
@JLuboff Are you good with node?
Jason Luboff
@JLuboff
Jun 20 2018 21:07
I'm okay with it (more so express... )
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:08
@anthonygallina1 Don't! Come to the dark side! We have PHP!
anthonygallina1
@anthonygallina1
Jun 20 2018 21:08
I have been using a wild card for other routes
But wonder if that is bad practice? Like 404 other routes
Jason Luboff
@JLuboff
Jun 20 2018 21:09
I'm not positive best practice, but, as long as its your last route I don't see why it would be bad. Not sure there would be another way of catching bad routes
anthonygallina1
@anthonygallina1
Jun 20 2018 21:10
@bjorno43 I got my but kicked in here for mentioning PHP or Ruby for many years I am conditioned now :( Sorry
@JLuboff Thank you
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:11
@anthonygallina1 Meh. Everyone just joining the hipe train on PHP hate
anthonygallina1
@anthonygallina1
Jun 20 2018 21:11
@bjorno43 I still think you more tools you know the better you are
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:12
@anthonygallina1 Well look at like this: The more you learn, the more you know. The more you know, the more you forget. The more you forget, the less you know. So why should you learn? :trollface:
anthonygallina1
@anthonygallina1
Jun 20 2018 21:12
Soory to say I remember when mentioning either would put one close to troll status
Things have gotten much better
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:14
Ye it definitely has. PHP7 is on par with Node. But all the cool kids rather hate than educate :P
Brad
@bradtaniguchi
Jun 20 2018 21:14
@anthonygallina1 Well look at like this: The more you learn, the more you know. The more you know, the more you forget. The more you forget, the less you know. So why should you learn? :trollface:
mind blowing
now, at what point do we know the most then? hehe
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:16
No idea, lol
It's a Dutch saying mostly used in elementary school, ghehe
anthonygallina1
@anthonygallina1
Jun 20 2018 21:17
@bradtaniguchi :smile:
Brad
@bradtaniguchi
Jun 20 2018 21:18
damn dutch people blow my mind :P
anthonygallina1
@anthonygallina1
Jun 20 2018 21:18
@bradtaniguchi yup but i remember where to look it up at
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:18
Oh we have several of those, ghehe
Like one for the toilet: "If you have nothing to do, please don't do it here"
One of the best ones is: "Uw bezoek brengt ons altijd vreugde aan. Is het niet bij het komen, dan wel bij het gaan". Unfortunetely the English translation makes it less funny. It basicly translates to: "Your visit always makes us happy. If it's not when you arrive, it's when you leave"
anthonygallina1
@anthonygallina1
Jun 20 2018 21:22
@bradtaniguchi Oh and another reason is.
There are commonality s
So not like having to allways relearn everything
Brad
@bradtaniguchi
Jun 20 2018 21:27
haha those are pretty good XD
anthonygallina1
@anthonygallina1
Jun 20 2018 21:32
@bradtaniguchi I have a off the wall Example wana see?
From learning organization groups in windows 2000 (like ACL) I think. Helps with Linux admin also)) I have a better understanding of assigned rights in mongo db.
Brad
@bradtaniguchi
Jun 20 2018 21:36
example of what? More dutch puns?
anthonygallina1
@anthonygallina1
Jun 20 2018 21:37
And learning JS here helps tons too. Quincy suggested sticking to JS I think. And I think he was right for me.
Brad
@bradtaniguchi
Jun 20 2018 21:40
@anthonygallina1 Oh I see, I was commenting on the funny Dutch sayings, rather than actually asking for an answer to the question for "what point do we know the most then?" haha
anthonygallina1
@anthonygallina1
Jun 20 2018 21:41
:blush:
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:44
At what point you know the most? When you can recite every single wiki pedia page out there by head, ghehe
anthonygallina1
@anthonygallina1
Jun 20 2018 21:44
@bradtaniguchi I do worry about what I forget though.
Brad
@bradtaniguchi
Jun 20 2018 21:44
Ah but how do you know what you forgot :P
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:44
Or you just have a very good photographical memory xD
Ye that's kinda the thing. It's hard to know what you forgot xD
anthonygallina1
@anthonygallina1
Jun 20 2018 21:46
@bradtaniguchi :smile:
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:47
Honestly though.. What fears me the most is ever getting Alzheimer. I mean, imagine that you completely lose yourself and just spill all your most inner secrets to everyone simply because you have no idea what you're revealing..
anthonygallina1
@anthonygallina1
Jun 20 2018 21:47
That would be scary
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:50
Exactly. Or even worse, you're connecting the wrong dots. For example: I've worked in retail before. I've seen some pretty bad shit over the years. Imagine me telling everyone I've been looking at certain stuff but leaving out the context..
anthonygallina1
@anthonygallina1
Jun 20 2018 21:56
@bjorno43 in your opinion on PHP I have used bullet proof What do you think of it?
It modifys htacess file etc
Bjorn van de Peut
@bjorno43
Jun 20 2018 21:59
@anthonygallina1 For image uploads?
anthonygallina1
@anthonygallina1
Jun 20 2018 21:59
@bjorno43 Wp security And gdpr compliance
Kudzu
@czhower
Jun 20 2018 22:00
@bjorno43 The good news is that in the last year even there have been MAJOR advances on Alzheimer's - a cure is possibly in sight in next 10 years or so.
anthonygallina1
@anthonygallina1
Jun 20 2018 22:00
Not fond of plugins though It takes much time to do it manually But then you know it was done
Brad
@bradtaniguchi
Jun 20 2018 22:00
I don't have much fear of that sorta stuff. I just dont want any pain yo
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:00
@anthonygallina1 Can you link it? All I can find is some php image upload library called bulletproof
anthonygallina1
@anthonygallina1
Jun 20 2018 22:00
sure
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:01
@czhower That'd be great news!
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:02
Ah, no wonder I never heard of it. I don't work with Wordpress, ghehe
I'm not sure what to think of it. What I do know is that htaccess isn't 100% reliable though
anthonygallina1
@anthonygallina1
Jun 20 2018 22:03
@czhower cool a cure
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:06
Ye when I check it out, it basicly tries to filter all the data through all kinds of PHP code for security. Which is definitely better than nothing, but of course it has its limitations. Anything that bypasses it (ie scripts outside of WP) are unprotected. Except for the htaccess maybe
anthonygallina1
@anthonygallina1
Jun 20 2018 22:09
@bjorno43 thank you You recommend manual config?
On PHP scripts and file placement?
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:10
@anthonygallina1 If you really want to test your domain's security, I suggest you download OWASP ZAP. You can do full penitration tests on your domain and it'll give you a complete report of anything you've missed. Don't use it domains not owned by you without permission though. That's illegal :P
anthonygallina1
@anthonygallina1
Jun 20 2018 22:10
Thanks but I still thought that wasnt ok on a hosted
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:12
I honestly can't say. Depends on your local law. That program only tests for security issues with code on your domain. It doesn't try to penitrate the server itself
anthonygallina1
@anthonygallina1
Jun 20 2018 22:12
Oh
OWASP :thumbsup:
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:14
@anthonygallina1 But if you rather play it safe, I don't mind giving you some hosting on my server here. You can go ahead and try anything you want there
anthonygallina1
@anthonygallina1
Jun 20 2018 22:14
I been reading there stuff for a long time
@bjorno43 Much appreciated. Not now though. My hosting is comming up though in a few months
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:15
That server is sitting here at my home and 100% owned by me. So no chance of any legal issues as you've got my permission :P
anthonygallina1
@anthonygallina1
Jun 20 2018 22:15
I have been thinking of moving
@bjorno43 Thats the way to go. When it is local you can see much more.
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:16
Yup
Kudzu
@czhower
Jun 20 2018 22:16
To play, you can get hosts cheaply for about $3 a month.. they are slow for volume stuff.. but plenty to play with....
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:16
I've installed ISPConfig on it. Works like a charm!
Kudzu
@czhower
Jun 20 2018 22:16
or set up locall or use a VM
anthonygallina1
@anthonygallina1
Jun 20 2018 22:17
@czhower Thank you @bjorno43 Thank you
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:19
@anthonygallina1 What also might interest you is that FCC recently released a very long vid about PHP on youtube: https://www.youtube.com/watch?v=OK_JCtrrv-c&feature=youtu.be
anthonygallina1
@anthonygallina1
Jun 20 2018 22:19
I had a video on you tube years ago. I was using DYN and had even a mail server. On a thumb drive. I cant remember where the links is. But my voice and screen captures telling the config. When I did that friends of Apache I saw much more of the server.
@bjorno43 :thumbsup:
WOW!
Kudzu
@czhower
Jun 20 2018 22:21
A2 for example, but most hosts offer similar (I strongly recommend A2, and strongly recomend AGAINST BlueHost though)
image.png
anthonygallina1
@anthonygallina1
Jun 20 2018 22:21
Free Code Camp and PHP I never thought I would see the day :smile:
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:22
Well if you have a spare computer or laptop somewhere, or just some VM, I'd definitely recommend checking out ISPConfig @anthonygallina1 It's completely free and it'll guide you through installing Linux and everything else you need for your own server. Multiple domain support, control panel, mail server, dns server, etc etc
Kudzu
@czhower
Jun 20 2018 22:22
Cool thing about these cheap plans is you have everything you need to play, and can instantly upgrade to bigger stuff if you need to go public.
Yeah, local works too but harder to show others and the speed isn't realistic because its local host.
There are ready to boot VMs you can download too.
Jason Luboff
@JLuboff
Jun 20 2018 22:24
And some environment elements can be different when running localhost (unless you actually hit it from the outside)
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:28
Hmm, depending on where you're from, I'd suggest Strato hosting. You can hire a VPS with garantueed 8G RAM, 4 vCores, 400 GB SSD, unlimited traffic, domains, databases etc etc for about $7 / month
It's like close to the benefits of a dedicated server at the costs of cheap hosting :P
Unfortunetely it seems like they only operate in Germany, Netherlands, Spain, France and the UK though
Brad
@bradtaniguchi
Jun 20 2018 22:31
sounds like a good deal... but not in US :(
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:33
Ye. It seems they only recently discontinued support for the US though
Kudzu
@czhower
Jun 20 2018 22:34
Im sure there are plenty of good ones out there. I can say though that BH is a horrid nightmare. A2 has excellent support staffed by people who are responsive and know their stuff.
BH among other things has support via unknowledgable people using scripts to ask you questions.
BH should be "DMV Hosting"
Jason Luboff
@JLuboff
Jun 20 2018 22:35
Alright...think my code is production ready...or as production ready as I know how to make it
anthonygallina1
@anthonygallina1
Jun 20 2018 22:36
:thumbsup:
Jason Luboff
@JLuboff
Jun 20 2018 22:38
Think there's a few places for improvement, but overall I'm happy with it
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:38
@JLuboff Put it online. Give me permission and I'll do some penitration testing, ghehe :P
Jason Luboff
@JLuboff
Jun 20 2018 22:39
It's an internal app, so no need for that :smile:
anthonygallina1
@anthonygallina1
Jun 20 2018 22:39
yikes
:)
Bjorn van de Peut
@bjorno43
Jun 20 2018 22:39
lol
Megan Taylor
@megantaylor
Jun 20 2018 22:51
Is anyone else really confused by the ES6 challenges? I mean, I use quite a few of these on the daily, but the descriptions, examples and challenge problems are driving me 🥜.
Jason Luboff
@JLuboff
Jun 20 2018 22:55
@megantaylor I haven't gone through them except for a few during beta, don't know if they've changed at all since then, but yes, I did find them to be a bit confusing.
Brad
@bradtaniguchi
Jun 20 2018 22:58
@megantaylor Yea some of them are kinda confusing (the length one is ugly), and don't provide the best user feedback when your doing thins wrong
Megan Taylor
@megantaylor
Jun 20 2018 22:58
glad its not just me :D
Zebralight
@zebralight
Jun 20 2018 23:00
hello. I was struggling with implementing quicksort for the interview prep module and while I feel like I have a broad idea of what it does, my implementation is riddled with issues
Brad
@bradtaniguchi
Jun 20 2018 23:05
@zebralight Well if you understand the concept, the devil ends up in the details. Practice with your language of choice (or hell pure memorization) helps a lot here. Obviously you need to make sure you understand the concept correctly haha
Jason Luboff
@JLuboff
Jun 20 2018 23:44
Erg.. my error messages aren't bubbling up as I expected them too