These are chat archives for MontCode/GeneralChat

2nd
Aug 2016
Lily Romano
@Lilyheart
Aug 02 2016 20:26
What's everyone coding tonight? I'm continuing my revamp of some Home Control/Automation stuff.
Eric Phy
@SimplyPhy
Aug 02 2016 20:32
I'm building a huge object containing all of the courses, sections, and segments from udacity senior web dev nano ... So basically typing as fast as possible
@Lilyheart that's sounds neat
Lily Romano
@Lilyheart
Aug 02 2016 20:40
It's modest. It's so expensive to do everything I want xD so it grows slowly.
Jonathan Herman
@lantech19446
Aug 02 2016 20:44
I decided to try to do some more challenges, it's been FOREVER since I did any I thought I had this typed out right but it's unable to test can someone give me some insight?
function testSize(num) {
  // Only change code below this line
  if (num < 5) {
    return "tiny";
  }
  else if (num < 10){
    return "small";
  }
  else if (num < 15){
    return "medium";
  }
  else if (num < 20){
    return "large";
  }
  else if (num >= 20){
    return "huge";
  }
  return "Change Me";
  // Only change code above this line
}

// Change this value to test
testSize(7);
Owen Winkler
@ringmaster
Aug 02 2016 20:45
What’s it supposed to do?
Jonathan Herman
@lantech19446
Aug 02 2016 20:46
it runs multiple numbers through testSize to make sure it returns the right thing that's the only function of it they just want to know that you can write a proper if else statement chain
Owen Winkler
@ringmaster
Aug 02 2016 20:47
Yeah, but how are you supposed to know what numbers return “tiny”?
Lily Romano
@Lilyheart
Aug 02 2016 20:47
The code looks okay. What is the name of the challenge?
Owen Winkler
@ringmaster
Aug 02 2016 20:47
Maybe Lily's was the better question.
Jonathan Herman
@lantech19446
Aug 02 2016 20:48
chaining if else statements
Lily Romano
@Lilyheart
Aug 02 2016 20:48
Oh, I do see one change that would make it better. You can take out the last return "Change Me" and the last else if can just be an else without the logic test after it.
Jonathan Herman
@lantech19446
Aug 02 2016 20:48
I just noticed the error it's giving is that I'm missing a ( before the condition I don't see any missing though.
if I take out the last else it tells me I need at least 4
funny thing is it's working but it says it's not like I can manually change the numbers and get the right answer but it won't say it's the right answer
Owen Winkler
@ringmaster
Aug 02 2016 20:51
Check the cases of the return values.
Lily Romano
@Lilyheart
Aug 02 2016 20:51
This message was deleted
What owen said xD - It's the case.
function testSize(num) {
  // Only change code below this line
  if (num < 5) {
    return "Tiny";
  }
  else if (num < 10){
    return "Small";
  }
  else if (num < 15){
    return "Medium";
  }
  else if (num < 20){
    return "Large";
  }
  else {
    return "Huge";
  }
  // Only change code above this line
}

// Change this value to test
testSize(0);
Jonathan Herman
@lantech19446
Aug 02 2016 20:53
it doesn't like that either
like the code works but it won't accept it even if I reset the whole thing and try again
Lily Romano
@Lilyheart
Aug 02 2016 20:53
What is the error message?
Jonathan Herman
@lantech19446
Aug 02 2016 20:54
there is none
it works it just won't accept the result
Lily Romano
@Lilyheart
Aug 02 2016 20:54
Can you screenshot the page? Something is wonky.
Mostly need the bottom of the left bar of text
Owen Winkler
@ringmaster
Aug 02 2016 20:59
# In Elixir, for fun…
defmodule Test do
  def test_size(num) when num < 5, do: "Tiny"
  def test_size(num) when num < 10, do: "Small"
  def test_size(num) when num < 15, do: "Medium"
  def test_size(num) when num < 20, do: "Large"
  def test_size(_), do: "Huge"
end
Jonathan Herman
@lantech19446
Aug 02 2016 21:01
yea give me one sec
how do I send the screenshot?
Lily Romano
@Lilyheart
Aug 02 2016 21:03
if the image is on your clipboard, then you can just paste it in here.
otherwise i think drag and drop works.
Jonathan Herman
@lantech19446
Aug 02 2016 21:20
let me try again, it won't send by drag and drop
it won't connect to the upload server
Lily Romano
@Lilyheart
Aug 02 2016 21:21
that's weird. you can send to me on facebook if you can get there from work.
Jonathan Herman
@lantech19446
Aug 02 2016 21:21
yep, I'm the one who controls who gets to what :)
xD nice
Jonathan Herman
@lantech19446
Aug 02 2016 21:22
yep just sent it to you
Lily Romano
@Lilyheart
Aug 02 2016 21:25
See it's failing all the tests on the left? If you compare what you are getting (in the black box at the top left of the screenshoot and compare that with that the answer should be, you would be comparing tiny to Tiny. tiny != Tiny.
blob
Jonathan Herman
@lantech19446
Aug 02 2016 21:27
you've got to be kidding, that's what it was it's been mocking my lack of capitalization the whole time
Owen Winkler
@ringmaster
Aug 02 2016 21:27
Computers are unforgiving. :)
Lily Romano
@Lilyheart
Aug 02 2016 21:27
xD I originally posted, you aren't gonna like this. It's case. But then owen beat me to it and then I accidentally deleted my post when I meant to edit. >.<
Jonathan Herman
@lantech19446
Aug 02 2016 21:28
you'd think I'd be used to this using linux but other than camel case I don't remember fcc being this picky
thank you both for the help
Owen Winkler
@ringmaster
Aug 02 2016 21:28
// https://www.freecodecamp.com/challenges/check-for-palindromes
function palindrome(str) {
  str = str.toLowerCase().replace(/[^a-z]/g, '');
  front = str.substr(0, Math.floor(str.length / 2));
  back = str.substr(Math.ceil(str.length / 2)).split('').reverse().join('');
  return front == back;
}

palindrome("1 eye for of 1 eye.");
Ok, so why does the test think that should not be a palindrome?
Lily Romano
@Lilyheart
Aug 02 2016 21:29
I prefer snake_case I think it's easier to read.
It's one of the rules in the instructions. You'll need to remove all non-alphanumeric characters (punctuation, spaces and symbols) and turn everything lower case in order to check for palindromes.
Owen Winkler
@ringmaster
Aug 02 2016 21:30
I was pretty sure I did, but I’ll check again.
Lily Romano
@Lilyheart
Aug 02 2016 21:31
key part is non-alphanumeric
your regex is removing the numeric as well.
Owen Winkler
@ringmaster
Aug 02 2016 21:31
Bleh. Tricked by tests with numbers in them still passing.
Lily Romano
@Lilyheart
Aug 02 2016 21:32
quick 0-9 add in xD
Owen Winkler
@ringmaster
Aug 02 2016 21:32
Yeah, easy after I see what’s wrong with it. Thanks.
Lily Romano
@Lilyheart
Aug 02 2016 21:33
xD I like how everyone does things differently. I did a .match(/[a-z0-9]/gi)
Owen Winkler
@ringmaster
Aug 02 2016 21:34
How did you end up fixing the string? Or did you?
Lily Romano
@Lilyheart
Aug 02 2016 21:35
after stripping everything out, I just tested the front and back characters working my way in until I either failed or ran out things to test.
function palindrome(str) {
  // Good luck!
  var testCharArr = str.toLowerCase().match(/[a-z0-9]/gi);
  for (var i = 0; i < testCharArr.length / 2; i++) {
    if (testCharArr[i] !== testCharArr[testCharArr.length - i - 1]) {
      return false;
    }
  }

  return true;
}
you can see people's solutions on their profile page if you like seeing how other people do things.
Owen Winkler
@ringmaster
Aug 02 2016 21:36
Oh, weird. Ok. Interesting.
Lily Romano
@Lilyheart
Aug 02 2016 21:37
And then @davidjcastner did something completely different.
function palindrome(str) {
  // Good luck!
  if (str === "0_0 (: /-\ :) 0-0") { return true; }
  var clean = str.replace(/[ ,\./]/g, "");
  clean = clean.toLowerCase();
  console.log(clean);
  return clean == clean.split("").reverse().join("");
}

JavaScript: 100 ways to do things

Owen Winkler
@ringmaster
Aug 02 2016 21:39
Yeah, I suppose that’s more efficient.
Lily Romano
@Lilyheart
Aug 02 2016 21:42
I'm not sure. Someday I have to look into JavaScript tests for how efficient different methods are. I wrote mine the way I did because if the first and last char are not the same, then it shortcuts right away. I feel like reversing the entire string and then testing it is more steps, but, because .split et al are built in functions, maybe they are actually faster then stepping through a for loop. I dunno. I could see it going either way.
Owen Winkler
@ringmaster
Aug 02 2016 21:43
I’ve always thought there was some trick to palindromes that I wasn’t getting. It just never occurred to me that reversing the whole string would be the same as the original, even though that’s what a palindrome is. Reversing the whole string is syntactically easier and more readable.
David Castner
@davidjcastner
Aug 02 2016 21:43
lily's + mine combined = best in my opinion
function palindrome(str) {
  var clean = str.toLowerCase().match(/[a-z0-9]/gi);
  return clean.join("") === clean.reverse().join("");
}
Owen Winkler
@ringmaster
Aug 02 2016 21:43
Exactly.
Ultimately, though, I thought this was clever:
function palindrome(str) {
  str = str.toLowerCase().replace(/[^a-z0-9]/g, '').split('');
  while((front = str.shift()) && (back = str.pop())) {
    if(front != back) return false;
  }
  return true;
}

palindrome("1 eye for of 1 eye.");
Lily Romano
@Lilyheart
Aug 02 2016 21:45
But over a million iterations, which runs faster? .reverse().join() does steps that might not be necessary? Do you know what I'm tryin' to say because my brain is fuzzy today. Home Automation scripting always does that to me.
Owen Winkler
@ringmaster
Aug 02 2016 21:46
Yeah, I dunno about the chaining methods, but in most languages, I’d expect the single native string reverse function to be faster than all of the tests that go character by character.
David Castner
@davidjcastner
Aug 02 2016 21:47
I always go for the clearer approach for readability as long as the O(n) run time is same
Lily Romano
@Lilyheart
Aug 02 2016 21:47
I :heartbeat: explicit code
Owen Winkler
@ringmaster
Aug 02 2016 21:48
Yeah, that’s why that revelation about palindromes being palindromes is so useful.
My point, using PHP:
function palindrome($str) {
    $clean = preg_replace('#[^a-z0-9]#', '', strtolower($str));
    return $clean == strrev($clean);
}
If I was trying to compare this character by character, it would be monstrous in comparison.
Lily Romano
@Lilyheart
Aug 02 2016 21:53
xD I haven't touched PHP in over a decade. I can't remember it to save me life.
Owen Winkler
@ringmaster
Aug 02 2016 21:53
I initially forgot to use the $ there for the variable. Sheesh.
Owen Winkler
@ringmaster
Aug 02 2016 22:10
Guard clauses++
Lily Romano
@Lilyheart
Aug 02 2016 22:10
slacker!
Owen Winkler
@ringmaster
Aug 02 2016 22:10
Whaa? Me??!
Lilyheart @Lilyheart nods in the affirmative.
Owen Winkler
@ringmaster
Aug 02 2016 22:11
I thought you were a proponent of failing out fast. Huh...
Lily Romano
@Lilyheart
Aug 02 2016 22:15
I really need to learn how to do custom syntax highlighting in Atom. It's annoying using NP++ for these scripts.
I think I need a fourth monitor. I have a monitor addiction.
Lily Romano
@Lilyheart
Aug 02 2016 22:21
well, if you count other devices....
2016-08-02 18.21.16.jpg
Owen Winkler
@ringmaster
Aug 02 2016 22:22
Fancy. I’ve simply run out of desk space at this point.
Lily Romano
@Lilyheart
Aug 02 2016 22:24
The thin black bar on the top monitor on the right is a tail of the home automation log. That's the thing I'm missing. I could just stop being lazy and get a keyboard hooked to the pi and run the tail on it.
Owen Winkler
@ringmaster
Aug 02 2016 22:24
Heh. I think I’ve hit a problem with diminishing returns. I’m not sure I want to add any more. I think I’d rather reduce the amount of things I would need to keep on a screen at once.
Lily Romano
@Lilyheart
Aug 02 2016 22:25
xD it's only Tuesday's I have a problem. I need chat, the tail and two windows for coding. Other days I just leave the chat in the background.
Owen Winkler
@ringmaster
Aug 02 2016 22:25
You should look into MaxTo.
https://maxto.net/ I found it handy when I was using a Windows system.
Lily Romano
@Lilyheart
Aug 02 2016 22:28
I used to use a grid program for windows. But I'm getting old and the smaller windows were annoying.
Already have computer glasses in addition to my regular. They tried to give me bifocals... and I was like yeah.. that wouldn't work for my computer set up. My neck would be sore from moving to get the eye alignment perfect constantly.
CodingNerd32
@CodingNerd32
Aug 02 2016 22:29
hey having some issues with making a responsive slideshow. I tried using this site responsiveslides.com but it doesn't work
Lily Romano
@Lilyheart
Aug 02 2016 22:30
@CodingNerd32 I like reveal.js. There was one I found and send to @davidjcastner that was all in markdown if that is your thing. One of us could find it if so.
http://welcome.montcode.com is done with reveal.
CodingNerd32
@CodingNerd32
Aug 02 2016 22:31
oh that's kinda cool
I just need like a small slideshow I want to make as an <aside> section
I don't need it to take up the whole page
like all I did was created a UL and copied some CSS and some JavaScript
Lily Romano
@Lilyheart
Aug 02 2016 22:34
what didn't work with responsiveslides? Did you download the .js file and put it somewhere in the same place as the website and then link it up? Are there any console errors?
CodingNerd32
@CodingNerd32
Aug 02 2016 22:35
no it didn't tell me to download anything
just copy the code but I feel like you need to at least download the library
Lily Romano
@Lilyheart
Aug 02 2016 22:35
In the Link files section, the <script src="responsiveslides.min.js"></script> code is a link to a file stored in the same directory as the webpage.
CodingNerd32
@CodingNerd32
Aug 02 2016 22:36
yeah
Lily Romano
@Lilyheart
Aug 02 2016 22:36
They never explicitly said to download, but that's what the script tag is referencing. Silly doc writers.
CodingNerd32
@CodingNerd32
Aug 02 2016 22:37
oh okay so I do I download that
*how
Lily Romano
@Lilyheart
Aug 02 2016 22:38
After all the sections with code samples, there is a part that says That's all! Download the latest version, this demo and changelog from Github. For more examples about the usage go here or view a demo with captions.. There is a link in there.
CodingNerd32
@CodingNerd32
Aug 02 2016 22:38
yeah thats where i am
Lily Romano
@Lilyheart
Aug 02 2016 22:39
here you are here?
CodingNerd32
@CodingNerd32
Aug 02 2016 22:39
yes
Lily Romano
@Lilyheart
Aug 02 2016 22:40
the green button that says download.
or right click any file you want and save it.
CodingNerd32
@CodingNerd32
Aug 02 2016 22:40
ah ok haha
thanks
apparently i had it already :P
ok I'll try this again
Lily Romano
@Lilyheart
Aug 02 2016 22:48
Check the console log for errors. That will give you a clue about some issues.
@SimplyPhy you should come to the library tomorrow
Eric Phy
@SimplyPhy
Aug 02 2016 22:50
617 line javascript object sigh
Lily Romano
@Lilyheart
Aug 02 2016 22:51
wheeeeeeeeeeeeee
CodingNerd32
@CodingNerd32
Aug 02 2016 22:52
ok so it almost works the transitions are working but for some weird reason the images are getting really big and then fading
Eric Phy
@SimplyPhy
Aug 02 2016 22:53
@Lilyheart idk, it’s 45 min drive
i’ll think about it
Lily Romano
@Lilyheart
Aug 02 2016 22:54
I think a 1 hour drive is our further person.
I can get you that pi
It's an older B+ I don't use anymore.
Eric Phy
@SimplyPhy
Aug 02 2016 22:58
I still don’t know what that means xD
oh wait, it’s actually a computer component?
Lily Romano
@Lilyheart
Aug 02 2016 22:59
It's actually a computer. You give it power, linux installed on a micro SD card and hook it to something HDMI (If you want it to have a head, it can run headless) and it's a fully running computer.
Eric Phy
@SimplyPhy
Aug 02 2016 23:01
ha
that’s pretty cool
anyways, i’m still contemplating, but the chances are decent
Lily Romano
@Lilyheart
Aug 02 2016 23:01
It's great for learning linux and getting comfy with the Command Line. As if you botch it, just take out the micro SD card and format and reinstall.
I used to have one in a case velcro'd to the back of a monitor for running the home automation. I've upgraded with a 7" touch screen now.
Eric Phy
@SimplyPhy
Aug 02 2016 23:12
nice
G.courses = {
    "Welcome to the Nanodegree": {
      sections: {
        "Welcome to the Senior Web Developer Nanodegree": {
          segments: [
            "Welcome to the Nanodegree"
          ]
        }
  },
  “Here’s another course”: { … }, ….
is there a way to get just the G.courses, without pulling the sections, segments, etc?
Lily Romano
@Lilyheart
Aug 02 2016 23:17
Look into JSONPath
Eric Phy
@SimplyPhy
Aug 02 2016 23:18
okay, i think i might have an alternative as well…….
Lily Romano
@Lilyheart
Aug 02 2016 23:19
That data is arranged... weird. keys look like values.
regardless. JSONPath is a good tool to have in your bucket http://goessner.net/articles/JsonPath/index.html#e3
Lily Romano
@Lilyheart
Aug 02 2016 23:25
@ringmaster I randomly remembered finally what I used to use. GridMove. I have a Logitech gaming keyboard, G510, and I used to have some of the G keys programmed to move the mouse to different windows automatically to make it the "active" window so I could just hit a keyboard key and start typing (I also had a key programmed to move to the skip button of the music player, click it and then move the cursor back to where it was cuz I'm just that lazy.
Owen Winkler
@ringmaster
Aug 02 2016 23:46
That’s pretty darn lazy.