These are chat archives for FreeCodeCamp/HelpJavaScript

5th
Jun 2018
Daniel Simeonov
@dbsimeonov
Jun 05 2018 10:37
Guys is there any reason that my function runs without even calling it? I have a function that is assigned to click event and on load runs automatically? Anything I should keep on mind
Pieter Stokkink
@forkerino
Jun 05 2018 11:01

@dbsimeonov make sure that when you add the eventhandler, you just reference the function and not call it:

x.addEventListener('click', fn)

not

x.addEventListener('click', fn())
if that's not it, show some code.
Daniel Simeonov
@dbsimeonov
Jun 05 2018 11:02
What if I need to pass parameter inside it?
David Young
@dayvidwhy
Jun 05 2018 11:02
then you’ve got some fun heading your way
have you got a code snippet?
Daniel Simeonov
@dbsimeonov
Jun 05 2018 11:03
https://codepen.io/DSimeonov/pen/JZXBrw?editors=1111
I tried to make it as readable as possible :D Any critics are welcome
The issue is that my currentIndex does not change...
Pieter Stokkink
@forkerino
Jun 05 2018 11:04
@dbsimeonov you create a closure:
x.addEventListener('click', function(event) {
  fn(event, param) // or whatever
})
Daniel Simeonov
@dbsimeonov
Jun 05 2018 11:06
From last night been trying to do it and feel that I'm close but missing something with this index..
Pieter Stokkink
@forkerino
Jun 05 2018 11:09
@dbsimeonov I think the problem is in your verifyIndex function
}else if(target = arrLength){
what does = do?
Daniel Simeonov
@dbsimeonov
Jun 05 2018 11:12
So the array starts from 0 and if the index is the length of the arr need to go back to 0? Or at least that s the way I understand it
Pieter Stokkink
@forkerino
Jun 05 2018 11:12
= is assignment
== or === is comparison
you set target to 8 (which is always true), so then it is set to 0
Daniel Simeonov
@dbsimeonov
Jun 05 2018 11:13
:shipit:
I knew its something so simple.
Thanks a lot!
Pieter Stokkink
@forkerino
Jun 05 2018 11:14
:+1:
Diego Mayer
@Chrono79
Jun 05 2018 13:01
:wave:
So, new FCC is broken (at least for me and several others)
Nate Mallison
@NJM8
Jun 05 2018 13:53
@JLuboff @cmccormack Finally got it......
    db.Polls.findOneAndUpdate({ 
        _id: req.body.id, 
        // options: { 
        //   $elemMatch: { 
        //     optionName: req.body.selection } 
        //   } 
        // }, 
        'options.optionName': req.body.selection
      },
      { $inc: { 
        'options.$.details.optionNumVotes' : 1 
      }, 
        $push: { 
          voters: req.body.voter 
        } 
      }).then(poll => {
        res.status(200).send('Vote Successful');
    })
the commented out section is what you could use if you had multiple matching conditions, the $ in options.$.details.optionNumVotes gets filled with what is found from 'options.optionName': req.body.selection
Jason Luboff
@JLuboff
Jun 05 2018 15:04
@Chrono79 How so?
@NJM8 Good job :+1:
Diego Mayer
@Chrono79
Jun 05 2018 15:05
@JLuboff Settings page not working
Jason Luboff
@JLuboff
Jun 05 2018 15:05
@Chrono79 Really? Huh. Did you change over from a github login?
Diego Mayer
@Chrono79
Jun 05 2018 15:06
Can't claim certificates, changes won't work, etc. The rest of the site works tho
I used it to login once, maybe that screwed it up
Jason Luboff
@JLuboff
Jun 05 2018 15:07
Tried closing your browser and reopening? I had an issue where it wouldn't keep me logged in until I closed and reopened my browser
Diego Mayer
@Chrono79
Jun 05 2018 15:07
The good thing is I'm not alone ;)
Tried different computers, no luck
It does give an error on React
Jason Luboff
@JLuboff
Jun 05 2018 15:08
oh..huh
Diego Mayer
@Chrono79
Jun 05 2018 15:08
freeCodeCamp/freeCodeCamp#17278
So, I'll wait till it's fixed (no rush to get certificates)
I think this new challenge is wrong
Why use a ternary operator to return true or false?, returning strings wouldn't teach bad habits like that
Jason Luboff
@JLuboff
Jun 05 2018 15:10
While its not wrong in the sense of how to answer, I agree that is a bad habit
Instead of this being the answer const checkEqual = (a, b) => a === b ? true : false
It should be const checkEqual = (a, b) => a === b
Diego Mayer
@Chrono79
Jun 05 2018 15:11
Yes, either that or return strings and not booleans
Jason Luboff
@JLuboff
Jun 05 2018 15:11
Ya that would be better
The next challenge after that one is chaining multiple ternarys...which while I do it from time to time, my understanding is thats not best practice either?
Readability can become difficult
Diego Mayer
@Chrono79
Jun 05 2018 15:12
Yes, not the best idea, but it's nice to see it at least once
Have you used CW recently?
Jason Luboff
@JLuboff
Jun 05 2018 15:15
Nah... no time to
You?
Diego Mayer
@Chrono79
Jun 05 2018 15:16
Yes, normally I hang around there on a daily base ;)
I'm reaching a plateau it seems, solved almost all the katas I could
Jason Luboff
@JLuboff
Jun 05 2018 15:19
Thats cool
Ugh... Have to figure out this time authentication issue I'm having
Jason Luboff
@JLuboff
Jun 05 2018 15:25
I'm using this module that interacts with Active Directory. Works fine in FF. But in Chrome, it returns undefined twice before returning the username which makes it so that the rest of my route doesn't work properly due to needing that user info. Edge does the same but only one undefined. Really wierd.
Diego Mayer
@Chrono79
Jun 05 2018 15:27
The only suggestion I can do is force your users to use FF :P
I have no idea about AD
Jason Luboff
@JLuboff
Jun 05 2018 15:28
Well its not an AD issue as far as I'm aware. Its more along the lines of an async and/or browser issue.
Diego Mayer
@Chrono79
Jun 05 2018 15:28
I hate when a browser doesn't work as you'd expect
Jason Luboff
@JLuboff
Jun 05 2018 15:29
Ya its frustrating. It was working before...but I think it was more so that the routes I was hitting with it didn't necessarily need the user info :worried:
Nate Mallison
@NJM8
Jun 05 2018 15:33
@Chrono79 What's your CW username?
Diego Mayer
@Chrono79
Jun 05 2018 15:34
The same as here, Chrono79
Nate Mallison
@NJM8
Jun 05 2018 15:35
oh, I forgot you can't really search users
found it, 2 kyu, nice
Diego Mayer
@Chrono79
Jun 05 2018 15:37
Eternal 2 kyu, :(
Jason Luboff
@JLuboff
Jun 05 2018 15:37

I must still not be awake.. but.. Im struggling with something...

  nodeSSPIObj.authenticate(req, res, (err) => {
    if (err) throw err;
    console.log(success(`Checking for user in authenticate: ${util.inspect(req.connection.user)}`));
    return res.finished || next();
  });

I have this. I'm thinking of trying to include some recursion so that it doesn't hit next() until req.connection.user is not undefined. For some reason.. I'm blanking on how to make it into a reusable function lol

Nate Mallison
@NJM8
Jun 05 2018 15:42
@JLuboff use async await to wait to call next()?
Jason Luboff
@JLuboff
Jun 05 2018 15:43
@NJM8 Haven't used async await...care to show an example?
Nate Mallison
@NJM8
Jun 05 2018 15:45
function getData(title) {
    return new Promise(function(resolve, reject){
        request(`http://www.omdbapi.com/?${title}&apikey=bb5f0ed2`, function(err, res, body){
            if (err) {
                reject(err);
            }
            resolve(body);
        });
    });
}

async function showDataWithAsync(title){
    let data = await getData(title);

    let plotIds = JSON.parse(data).Episodes.reduce((array, item) => {
        array.push(item.imdbID);
        return array;
    }, []);

    let plots = [];
    for (let i = 0; i < plotIds.length; i++) {
        let thisEpisode = JSON.parse(await getData(`i=${plotIds[i]}`));
        plots.push(`Episode: ${thisEpisode.Episode}, Plot: ${thisEpisode.Plot}`);
    }
    console.log(plots);
}
so define your function to return a promise, then the async function awaits the promise function, inside the async function nothing happens till let data = await getData(title); returns
Jason Luboff
@JLuboff
Jun 05 2018 15:47
Hmmm.. not sure that'll work for me. I'm using a specific module that doesn't return a promise. But I can try playing with things and see
Nate Mallison
@NJM8
Jun 05 2018 15:51
but could you still wrap it in a promise to allow you to wait until it returns? might be too complex
Jason Luboff
@JLuboff
Jun 05 2018 15:52
@NJM8 Not positive. I'm trying a few things with modifying the module albeit I don't fully understand the code as it is so... we'll see what happens. May end up posting an issue on the github page
Nate Mallison
@NJM8
Jun 05 2018 16:06
@revisualize nice link
Pieter Stokkink
@forkerino
Jun 05 2018 16:12
@Chrono79 :wave: Still 2 kyu?!? Getting closer to 1 kyu?
Jason Luboff
@JLuboff
Jun 05 2018 16:13
@forkerino Want to try helping me? :smile:
Pieter Stokkink
@forkerino
Jun 05 2018 16:15
@JLuboff having a look, but not sure what's what. Haven't used node in a while.
Jason Luboff
@JLuboff
Jun 05 2018 16:15
@forkerino Let me give you the full function, might make things slightly clearer

I have this as middleware (i.e in the routes that need it I have app.route('/').get(authUser, (req, res =>....

const authUser = (req, res, next) => {
  const nodeSSPIObj = new NodeSSPI({
    domain: '******',
  });

  nodeSSPIObj.authenticate(req, res, (err) => {
    if (err) throw err;
    console.log(success(`Checking for user in authenticate: ${util.inspect(req.connection.user)}`));
    return res.finished || next();
  });
};

So In the second portion there, where authenticate method is being called, it doesn't return the user on the first call depending on the browser. I'm thinking recursion may fix my issue if I can keep next() being called until I get the user but can't think of how to turn it into a proper function

I don't need to recall authUser I don't think?
Pieter Stokkink
@forkerino
Jun 05 2018 16:18
I don't think recursion is the way to go here.
Jason Luboff
@JLuboff
Jun 05 2018 16:19
I've never been good at recursion/knowing when to use it :joy:
Pieter Stokkink
@forkerino
Jun 05 2018 16:20
so somehwere you have app.use(authUser) ?
assuming you use express
Jason Luboff
@JLuboff
Jun 05 2018 16:20
@forkerino No, using it directly in the routes that need it.
  app.route('/adminPortal').get(authUser, (req, res) => {
But using it via app.use gives the same issue
Pieter Stokkink
@forkerino
Jun 05 2018 16:21
ok
Moisés Man
@moigithub
Jun 05 2018 16:21
NodeSSPI is some library/package ?
Jason Luboff
@JLuboff
Jun 05 2018 16:21
@moigithub Yes for authenticating with Active Directory
Pieter Stokkink
@forkerino
Jun 05 2018 16:21
I'm assuming the authenticate callback will only run when the request has been processed.
Do you see anything weird if you log the res/req ?
I don't even know what Active Directory is.
:joy:
ah MS
Jason Luboff
@JLuboff
Jun 05 2018 16:22
Active Directory is Windows user directory system (used in business)
The only wierd thing is that req.connection.user gets populated at different points depending on the browser. FF right away, Edge returns undefined then the user, Chrome returns undefined twice than the user..
If there's no logic in the route,. its fine. But whats happening is my logic starts before it gets the user info which it needs and results in unexpected/unwanted behavior
so alternatively if there is a way to wait until I get the user (which eventually it gets) I'd be fine with that, but not sure how to implement that
Christopher McCormack
@cmccormack
Jun 05 2018 16:26
@JLuboff can you wrap it in a promise?
Jason Luboff
@JLuboff
Jun 05 2018 16:26

So..

  app.route('/').get(authUser, (req, res) => {
    let user = req.connection.user;

    res.send(user);
  });

This works fine

  app.route('/adminPortal').get(authUser, (req, res) => {
    let user = req.connection.user.substring(4).toLowerCase();
    console.log(user);

    read.getUserInfo(user)

This does not. It errors on the user as its undefined thus can use substring/tolowercase etc etc

Pieter Stokkink
@forkerino
Jun 05 2018 16:27
@JLuboff maybe add another piece of middleware that checks to see if a user is logged in.
?
Jason Luboff
@JLuboff
Jun 05 2018 16:27
@cmccormack Honestly not sure how I would
@forkerino Maybe? if the user isn't authenticated, don't call next? or..
Christopher McCormack
@cmccormack
Jun 05 2018 16:27
@JLuboff is req.connection a buffer?
Pieter Stokkink
@forkerino
Jun 05 2018 16:27
indeed

something like:

function isAuthenticated(req, res, next) {
  // do any checks you want to in here

  // CHECK THE USER STORED IN SESSION FOR A CUSTOM VARIABLE
  // you can do this however you want with whatever variables you set up
  if (req.user.authenticated)
      return next();

  // IF A USER ISN'T LOGGED IN, THEN REDIRECT THEM SOMEWHERE
  res.redirect('/');
}

(copied from https://scotch.io/tutorials/route-middleware-to-check-if-a-user-is-authenticated-in-node-js)

Jason Luboff
@JLuboff
Jun 05 2018 16:28
@cmccormack Not sure. I haven't been able to find in the module's code where req.connection gets created :worried:
Christopher McCormack
@cmccormack
Jun 05 2018 16:28
if it's a buffer I think you have to treat it as async, but not 100%
Pieter Stokkink
@forkerino
Jun 05 2018 16:29
but a callback is also async, no?
Shubham soni
@shubhamsoni2617
Jun 05 2018 16:29
const LOCAL_FORECAST = {
  today: { min: 72, max: 83 },
  tomorrow: { min: 73.3, max: 84.6 }
};

function getMaxOfTmrw(forecast) {
  "use strict";
  // change code below this line
  const {tomorrow: {max:maxOfTomorrow}} = LOCAL_FORECAST; // change this line
  // change code above this line
  return maxOfTomorrow;
}

console.log(getMaxOfTmrw(LOCAL_FORECAST)); // should be 84.6
says nested destructuring is not being used.
https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/use-destructuring-assignment-to-assign-variables-from-nested-objects
Christopher McCormack
@cmccormack
Jun 05 2018 16:29
yeah but if the callback is invoked before the stream has parsed I could see it running into issues
Jason Luboff
@JLuboff
Jun 05 2018 16:30
@forkerino The only thing is the redirect... there's no actual login page for the user to go through. node-sspi will pop up a login window or auto-passthrough depending on the browser
Thats why I was thinking recurssion...but recurssion did not work (atleast how I implemented it) lol
Moisés Man
@moigithub
Jun 05 2018 16:30

what's this

perRequestAuth: false|true
default to false. Whether authentication should be performed at per request level or per connection level. Per connection level is preferred to reduce overhead.

Jason Luboff
@JLuboff
Jun 05 2018 16:31
@moigithub I've tried both with no change. (I used to have it true and currently it is false)
Pieter Stokkink
@forkerino
Jun 05 2018 16:31
@JLuboff no need to redirect, I believe, it will not go to the route as long as there is no authenticated user there
Jason Luboff
@JLuboff
Jun 05 2018 16:31
I actually didn't notice any difference between the two
@forkerino Ok, let me try
Pieter Stokkink
@forkerino
Jun 05 2018 16:32
@JLuboff But it will probably not wait for the user to be present, you could try wrapping it in a setInterval or something
might be a bit ugly compared to promisifying it
Christopher McCormack
@cmccormack
Jun 05 2018 16:32
@shubhamsoni2617 const {tomorrow: {max:maxOfTomorrow}} = LOCAL_FORECAST shouldn't be LOCAL_FORECAST, use your function parameter
This message was deleted
Shubham soni
@shubhamsoni2617
Jun 05 2018 16:34
@cmccormack Ahh!! Thanks.
This is just because of scope or anything else?
Christopher McCormack
@cmccormack
Jun 05 2018 16:34
@JLuboff maybe
app.route('/adminPortal').get(authUser, async (req, res) => {
    let user = await req.connection.user
    console.log(user);

    read.getUserInfo(user)
}
not 100% sure if that's the proper syntax though @JLuboff :D
Jason Luboff
@JLuboff
Jun 05 2018 16:34
@forkerino ...that worked it looks like!
Jesus fuck. Thank you @forkerino @cmccormack @moigithub
Christopher McCormack
@cmccormack
Jun 05 2018 16:35
@shubhamsoni2617 possibly due to a regex running on your line of code to make sure it looks as it should
@shubhamsoni2617 that would normally work fine the way you had it but you shouldn't use global scope if you can avoid it
especially within a function
Shubham soni
@shubhamsoni2617
Jun 05 2018 16:36
@cmccormack Thank you for the explanation.
Christopher McCormack
@cmccormack
Jun 05 2018 16:36
@JLuboff what exactly was changed to make it work?
Jason Luboff
@JLuboff
Jun 05 2018 16:37
@cmccormack Added that isAuthenticated function
const isAuthenticated = (req, res, next) => {
  console.log(`Inside isAuthenticated: ${req.connection.user}`);
  if (req.connection.user) {
    return next();
  }
};
  app.route('/adminPortal').get(authUser, isAuthenticated, (req, res) => {
    let user = req.connection.user.substring(4).toLowerCase();
    console.log(user);

    read.getUserInfo(user)
Christopher McCormack
@cmccormack
Jun 05 2018 16:38
hmm not sure how this solved your issue
Jason Luboff
@JLuboff
Jun 05 2018 16:38
@forkerino Next time you're in California (if ever) or I'm in Europe... I owe you a beer or.. something
@cmccormack Becuase it doesn't proceed to the route until user is defined
Christopher McCormack
@cmccormack
Jun 05 2018 16:38
but it's not going to wait for it is it?
Jason Luboff
@JLuboff
Jun 05 2018 16:40
It appears to be as I'm not having the issue any longer..
Pieter Stokkink
@forkerino
Jun 05 2018 16:40
@JLuboff :+1: :beer:
If it works it works
c-bot still dead?
Jason Luboff
@JLuboff
Jun 05 2018 16:41
Exactly!
He is currently
Apparently with the new curriculm Quincy is updating c-bot
Pieter Stokkink
@forkerino
Jun 05 2018 16:41
we should have a bot that checks c-bot
Jason Luboff
@JLuboff
Jun 05 2018 16:43
@cmccormack The module is wierd that it will keep running until user is defined not really sure why (it's built mainly in C++ so I think most of the logic is in there). Try it out when you get a minute if you'd like node-sspi https://www.npmjs.com/package/node-sspi
Christopher McCormack
@cmccormack
Jun 05 2018 16:45
@JLuboff ah so it will keep hitting the endpoint over and over?
Jason Luboff
@JLuboff
Jun 05 2018 16:45
Thats what it seems like. Its really odd how each browser is different lol
Christopher McCormack
@cmccormack
Jun 05 2018 16:45
Do you see your log statement appearing multiple times?
yeah that doesn't make a lot of sense to me
Jason Luboff
@JLuboff
Jun 05 2018 16:46
Yes
When hitting a route in Chrome
Checking for user in authenticate: undefined
Inside isAuthenticated: undefined
Checking for user in authenticate: undefined
Inside isAuthenticated: undefined
Checking for user in authenticate: '****\\JLuboff'
Inside isAuthenticated: ****\JLuboff
jluboff
Roiute in FF
Checking for user in authenticate: '***\\jluboff'
Inside isAuthenticated: ****\jluboff
jluboff
And Edge is normally one undefined cycle but this time I tried it, it was two
Christopher McCormack
@cmccormack
Jun 05 2018 16:48
may have everything to do with how req.connection is created/passed/whatever
well glad it's working!
Jason Luboff
@JLuboff
Jun 05 2018 16:49
Yes... I am very glad too lol
Christopher McCormack
@cmccormack
Jun 05 2018 16:49
I would still suggest testing out a promise and see if that works, or use async await
not sure if your tool will timeout and try again or if it tries again if it doesn't get a response it expects
Jason Luboff
@JLuboff
Jun 05 2018 16:49
I'm going to create an issue on the github page with my solution and see if anything comes of it
Christopher McCormack
@cmccormack
Jun 05 2018 16:51
@JLuboff good idea - looking at their npm code it looks just like yours and you're running into an issue I expect many others would as well
Jason Luboff
@JLuboff
Jun 05 2018 16:52
Ya I tried looking through the issues but didn't see one corresponding to this
Jason Luboff
@JLuboff
Jun 05 2018 16:59
Alright! Opened my first module issue! How exciting haha
Christopher McCormack
@cmccormack
Jun 05 2018 16:59
@JLuboff maybe you can even create a pull request for their readme!
I did that a few times because of grammar haha
Jason Luboff
@JLuboff
Jun 05 2018 17:01
We'll see if the author responds and if so, I'd be up for doing that!
Christopher McCormack
@cmccormack
Jun 05 2018 17:01
Would that officially make you an Open Source Contributer?
or are you already?
Jason Luboff
@JLuboff
Jun 05 2018 17:04
I have not contributed to anything...so... yes? lol
Christopher McCormack
@cmccormack
Jun 05 2018 17:07
@JLuboff well it's about time! now you can start creating medium blogs and posting constantly on twitter :D
Jason Luboff
@JLuboff
Jun 05 2018 17:08
haha
Bjorn van de Peut
@bjorno43
Jun 05 2018 21:27
How would you change the value of a textarea inside the DOM? Not like simply set its value with ele.value = '';, but actually change the DOM from <textarea></textarea> to <textarea>something</textarea>
Never mind, appearently you do that with textContent :)
Christopher McCormack
@cmccormack
Jun 05 2018 23:07
@bjorno43 yup that's what I would use - I believe that's what jquery uses for .text as well
Jason Luboff
@JLuboff
Jun 05 2018 23:07
@cmccormack Would you really..?
Christopher McCormack
@cmccormack
Jun 05 2018 23:08
@JLuboff no, I would use React and populate the element with a child of type String
Jason Luboff
@JLuboff
Jun 05 2018 23:08
Aha! The truth comes out
Christopher McCormack
@cmccormack
Jun 05 2018 23:08
haha
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:08
lol
Christopher McCormack
@cmccormack
Jun 05 2018 23:08
You got me!
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:08
Nah, I'm just messing around with Mutation Observers, ghehe
Jason Luboff
@JLuboff
Jun 05 2018 23:09
Welp. Got less than an hour of work left. Feel like it's been fairly productive day
Christopher McCormack
@cmccormack
Jun 05 2018 23:09
@JLuboff I finally got my twitter passport strategy working for my nightlife app - as much as I like these tools, troubleshooting issues can be very difficult sometimes...
@JLuboff still working??
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:10
Basicly I'm writing a Greasemonkey script that uses a Mutation Observer on some Dutch chatsite to watch for incoming private messages and send an auto-reply
Jason Luboff
@JLuboff
Jun 05 2018 23:10
@cmccormack Didn't know you were having issues :smile: I found getting passport working was easy after the initial time but I believe it's a bit more difficult with react?
And ya, I work until 5
Christopher McCormack
@cmccormack
Jun 05 2018 23:11
@JLuboff nah it was dumb stuff like having an extra done(...) outside my user check and getting the Can't set headers after they are sent. error without having a clue where it was coming from
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:11
And now that I'm messing around with that, I actually figured out I can write complete chatbots with that :smile:
Christopher McCormack
@cmccormack
Jun 05 2018 23:12
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:12
lol
Jason Luboff
@JLuboff
Jun 05 2018 23:12
@cmccormack Haha.. thats the issue I was having with my auth (can't set headers)
Christopher McCormack
@cmccormack
Jun 05 2018 23:15
@bjorno43 that's pretty cool. I've yet to write a chatbot as it seems like it would be a lot of work
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:16
@cmccormack I think it depends on your approach. With the observer it rly isn't that much code. The only hard part is figuring out where the DOM changes and what to use as a selector
Christopher McCormack
@cmccormack
Jun 05 2018 23:17
@bjorno43 I meant the part where you actually had to respond to the user :)
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:20
That's the easy part. First you put the observer on the chat DOM. Have it return the newly added node (the message by a user). You can filter out the username and the message from that object if you want. Then just set the input textarea with a text string response using the username if you want and simulate a Enter keypress or click on the send button
Christopher McCormack
@cmccormack
Jun 05 2018 23:20
@bjorno43 haha no sir, I mean the part where the response actually makes sense, processing the input to provide some meaningful output
the actual bot part
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:21
Ahhhh, now I see :P
Christopher McCormack
@cmccormack
Jun 05 2018 23:21
thanks for the tip on how to inject it though :D
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:22
Well, again, that depends. You basicly just convert the message to an array containing each word and use those as keywords to formulate the best possible response
Jason Luboff
@JLuboff
Jun 05 2018 23:22
I'll agree...that sounds complicated
Christopher McCormack
@cmccormack
Jun 05 2018 23:24
@bjorno43 Just like drawing an owl
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:24
It's like the same as a search engine. Use each word as a keyword. But bots will always be limited. Even the best AI out there would eventually fail at some point
Christopher McCormack
@cmccormack
Jun 05 2018 23:25
Yeah I imagine you would process the grammar, eliminate types of words that aren't necessary and use other words to give emphasis/weight to key words then use that like a hash to the best response
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:25
Ghehe ye well, explaining how to do it is easy. Explaining how to do it properly would take many, many days :smile:
But I wouldn't want to write a complicated bot. I'd probably just write some eightball script that gives responses like "My sources say yes, username" or "The outcome doesn't look good, username" :laughing:
Christopher McCormack
@cmccormack
Jun 05 2018 23:27
"Send me bitcoin, username"
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:28
Exactly!
Christopher McCormack
@cmccormack
Jun 05 2018 23:28
haha
Jason Luboff
@JLuboff
Jun 05 2018 23:29
Man... I shouldn't have bought bitcoin when it was so pricey :cry: lol Oh well. Wasn't very much and I'll just hold until it's either worth more or becomes nothing
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:29
"!eightball Will I be rich?" - "My sources say a good investment is sending bitcoin to ... , username" :laughing:
Christopher McCormack
@cmccormack
Jun 05 2018 23:32
I got 0.05btc for free when they were handing it out, hoping it's much higher in the future
Brad
@bradtaniguchi
Jun 05 2018 23:32

Does anyone have an idea what this JS does?? I found it in a spec file on googles angular repo, I understand the assignment, but wtf is the !; at the end?

afterEach(() => { fixture = null !; });

Jason Luboff
@JLuboff
Jun 05 2018 23:33
@cmccormack Damn. More than I own. I have .00358369 :joy:
Christopher McCormack
@cmccormack
Jun 05 2018 23:35
@bradtaniguchi does angular add it's own syntaxes then transpile?
Brad
@bradtaniguchi
Jun 05 2018 23:36
@cmccormack everything is just typescript as far as I know, Ive never seen "custom-angular-syntax" in the controller code
Christopher McCormack
@cmccormack
Jun 05 2018 23:37
could just be a typo
Those keys are pretty close on the keyboard... :p
Bjorn van de Peut
@bjorno43
Jun 05 2018 23:37
Anyway, 1:30 am here. Gn8 guys
Jason Luboff
@JLuboff
Jun 05 2018 23:38
Night
Christopher McCormack
@cmccormack
Jun 05 2018 23:38
@bjorno43 seeya
Brad
@bradtaniguchi
Jun 05 2018 23:39
shrugs I'm going to ask in the angular form to see whats going on haha
Christopher McCormack
@cmccormack
Jun 05 2018 23:41
@JLuboff did you use twitter strategy?
Jason Luboff
@JLuboff
Jun 05 2018 23:41
@cmccormack I did for Pinterest clone, ya
Brad
@bradtaniguchi
Jun 05 2018 23:41
Ah its typescript's nullability stuff (no idea what it is but its a typescript thing)
Christopher McCormack
@cmccormack
Jun 05 2018 23:42
How did you form your callbackURL? Did you set it manually for dev vs prod or did you build it dynamically based on the host/originalUrl?
@bradtaniguchi typescript seems ugly from what I've seen, does it get nicer after using for a while?
Jason Luboff
@JLuboff
Jun 05 2018 23:43
@cmccormack Is that the URL to set on Twitter's page?
Brad
@bradtaniguchi
Jun 05 2018 23:43
If your using it for straight forward things yes, but I heard it starts getting ridiculous in some cases when taking a functional approach
Christopher McCormack
@cmccormack
Jun 05 2018 23:43
yeah the one they will redirect back to after auth @JLuboff
Jason Luboff
@JLuboff
Jun 05 2018 23:43
Hmmmmm.. let me see if I can log into my twitter account and see. Can't fully remember
Christopher McCormack
@cmccormack
Jun 05 2018 23:44
@bradtaniguchi to be fair purely functional would look very confusing to most even without typescript :)
@JLuboff nevermind
I just looked at your github page :)
callbackURL: process.env.CALLBACKURL
Brad
@bradtaniguchi
Jun 05 2018 23:44
Yea, but for most common use-cases its pretty useful, especially if your project is large. Nothing beats renaming 1 word and 50 things break in compile time. Saves a huge amount of time, and allows you to refactor really easiluy
Jason Luboff
@JLuboff
Jun 05 2018 23:45
Ya I saw that too lol but I was thinking that in the twitter page I had to either make two different apps or change it depending on localhost vs glitch
Christopher McCormack
@cmccormack
Jun 05 2018 23:45
@bradtaniguchi I may implement it in my next project just to get an idea of how it works, thanks for the info
@JLuboff You do have to manually add the callback urls maybe that's what you're thinking of
Jason Luboff
@JLuboff
Jun 05 2018 23:46
Huh.. I'm bummed that FCC didn't add any new algorithms (I think there was one)
Christopher McCormack
@cmccormack
Jun 05 2018 23:46
@JLuboff they did... look at the bottom at the project euler problems among a bunch of others
that's where nightlife and several others got moved as well
I think that's how it jumped from 300 or so to over 1000
Jason Luboff
@JLuboff
Jun 05 2018 23:48
Project Euler? I see under coding interview prep there are some (implements different sort methods)
Christopher McCormack
@cmccormack
Jun 05 2018 23:48
There are 480 project euler algorithms alone
Jason Luboff
@JLuboff
Jun 05 2018 23:48
Ooooh there it is
Christopher McCormack
@cmccormack
Jun 05 2018 23:48
I've actually done a ton of these on project euler so I'm just going to refactor my code from python :)
Jason Luboff
@JLuboff
Jun 05 2018 23:50
Sneaky sneaky
Christopher McCormack
@cmccormack
Jun 05 2018 23:53
man so many though
keep your streak going strong!
Jason Luboff
@JLuboff
Jun 05 2018 23:53
Yup! Going through everything. Probably 15-20 minutes a day
Christopher McCormack
@cmccormack
Jun 05 2018 23:54
alright I'm off to make dinner, ttyl!
Jason Luboff
@JLuboff
Jun 05 2018 23:58
See ya