These are chat archives for MontCode/GeneralChat

22nd
Sep 2016
Lily Romano
@Lilyheart
Sep 22 2016 02:07
zzzzz
Keith
@keithdoyle9
Sep 22 2016 03:36
zzzzzzz....
Lily Romano
@Lilyheart
Sep 22 2016 12:41
Hey @keithdoyle9. What have you been up to?
Eric Phy
@SimplyPhy
Sep 22 2016 14:47
i don’t understand why this works:
onTick: function() {
    if (this.state.running) {
      var now = Date.now();
      this.setState({
        previousTime: now,
        elapsedTime: this.state.elapsedTime + (now - this.state.previousTime),
      });
    }
  },
David Castner
@davidjcastner
Sep 22 2016 14:47
java question: how would you pass a function as argument to another function/method? and is this acceptable to do in java?
Eric Phy
@SimplyPhy
Sep 22 2016 14:48
might it work because the function doesn’t actually set the values until after it finishes?
ha @davidjcastner what are the odds we’d both appear with a question at the same time
David Castner
@davidjcastner
Sep 22 2016 14:50
@SimplyPhy yes because the the setState function is looking for an argument of an object with values to set, so using previousTime: now doesn't change the value until after the object is created
does that make sense?
Eric Phy
@SimplyPhy
Sep 22 2016 14:51
@davidjcastner this or this might help
David Castner
@davidjcastner
Sep 22 2016 14:52
lol i was looking at the first link before, but the second one answers my question, thanks!
Eric Phy
@SimplyPhy
Sep 22 2016 14:52
:D
@davidjcastner but what about the fact that var now is set just prior to that function call?
ugh, i understand what must be happening, i just don’t understand how it’s happening
Eric Phy
@SimplyPhy
Sep 22 2016 14:58
oh wait, i think i get it
David Castner
@davidjcastner
Sep 22 2016 14:58
epiphany! yay!
Eric Phy
@SimplyPhy
Sep 22 2016 14:58
it’s still imperfect, but a bit more staring might do the trick
basically, like you said, it’s all about the fact that those values are a part of a function call, and not actually..expressions? something like that
David Castner
@davidjcastner
Sep 22 2016 14:59
yes
Eric Phy
@SimplyPhy
Sep 22 2016 15:00
i feel like i need a refresher of js OoOs :(
David Castner
@davidjcastner
Sep 22 2016 15:00
it's not setting the values when creating the argument for setState
Eric Phy
@SimplyPhy
Sep 22 2016 15:00
does it wait until the next ‘tick’ (running of the program file) to set them?
nevermind, i’ll figure it out
yeah i get it now
Lily Romano
@Lilyheart
Sep 22 2016 15:04
I posted a link of a page someone wrote that lets you watch javascript “run” through the program where you can watch the stack. Might that help @SimplyPhy ?
David Castner
@davidjcastner
Sep 22 2016 15:04
nope, the function setState sets the values, but its happens in this order
  1. var now = Data.now();
  2. creates an unnamed object with the properties previousTime and elapsedTime -> { previousTime: someValue, elapsedTime: someValue }
  3. the some value is calculated using the current state
  4. after this unnamed object is fully calculated it passes it to set setState
  5. setState using that object to set the new state
Eric Phy
@SimplyPhy
Sep 22 2016 15:08
yup i get it, thanks guys
whoops
Lily Romano
@Lilyheart
Sep 22 2016 15:09
all the thanks to @davidjcastner
MontBot
@MontBot
Sep 22 2016 15:09
lilyheart sends brownie points to @davidjcastner :sparkles: :thumbsup: :sparkles:
:cookie: 355 | @davidjcastner |http://www.freecodecamp.com/davidjcastner
Eric Phy
@SimplyPhy
Sep 22 2016 15:09
thanks @davidjcastner
MontBot
@MontBot
Sep 22 2016 15:09
simplyphy sends brownie points to @davidjcastner :sparkles: :thumbsup: :sparkles:
:cookie: 356 | @davidjcastner |http://www.freecodecamp.com/davidjcastner
Eric Phy
@SimplyPhy
Sep 22 2016 15:09
aww
Lily Romano
@Lilyheart
Sep 22 2016 15:09
ALL THE COOKIES FOR DAVID
Eric Phy
@SimplyPhy
Sep 22 2016 15:09
haha
David Castner
@davidjcastner
Sep 22 2016 15:09
yummy!
Eric Phy
@SimplyPhy
Sep 22 2016 15:09
@lily that link could be neat :D
you’re really stacking those cookies up
Lily Romano
@Lilyheart
Sep 22 2016 15:09
lemme find it. I’m not @ lily tho :p
Eric Phy
@SimplyPhy
Sep 22 2016 15:09
watevs :P
SimplyPhy @SimplyPhy @Lilyheart says waa
David Castner
@davidjcastner
Sep 22 2016 15:11
me
Lily Romano
@Lilyheart
Sep 22 2016 15:11
That’s kinda what I look like… As I shoved the last part of my sandwich in my mouth right when the pic loaded. Not attractive.
Finding the page that watches the stack. Here is the video that goes with it https://www.youtube.com/watch?v=8aGhZQkoFbQ
Eric Phy
@SimplyPhy
Sep 22 2016 15:12
rut roe
looks like a video
:sigh:
Lily Romano
@Lilyheart
Sep 22 2016 15:13
AMAZING video
Here is the page http://latentflip.com/loupe/
Eric Phy
@SimplyPhy
Sep 22 2016 15:13
fine…i’ll make a point of watching it :cry:
Lily Romano
@Lilyheart
Sep 22 2016 15:13
It might be the best 26 minutes you spend this week.
Eric Phy
@SimplyPhy
Sep 22 2016 15:13
i wouldn’t be surprised
in other news: react is weird xD
Lily Romano
@Lilyheart
Sep 22 2016 15:14
:shocker:
I need one of those containers that stores pringles in a way they don’t get all crunched up
Lily Romano
@Lilyheart
Sep 22 2016 15:20
If I had to pick one video for someone who is already familiar with JS but wants to be better at it, that video is the one. Hands down.
Eric Phy
@SimplyPhy
Sep 22 2016 15:54
good material, kind of distracting presentation
and really good program on that site
Lily Romano
@Lilyheart
Sep 22 2016 15:59
Heh, I enjoyed his presentation style. To each his own I suppose.
Eric Phy
@SimplyPhy
Sep 22 2016 16:07
is this equivalent to using the now variable?
if (this.state.running) {
      var now = Date.now();
      this.setState({
        previousTime: Date.now(),  // <— same as ‘now’ ?
        elapsedTime: this.state.elapsedTime + (now - this.state.previousTime),
      });
    }
Eric Phy
@SimplyPhy
Sep 22 2016 16:13
i’m guessing no
but as usual, i have no idea
i think i’m just dumb today
Lily Romano
@Lilyheart
Sep 22 2016 16:42
xD I think you caught me as I was loggin’ the laptop out. Don’t think they are the same. It’s gonna give you current time which if run back to back is going to be nearly identical.. but…..
Keith Doyle
@kdoylesei
Sep 22 2016 17:25
@Lilyheart same stuff different day. We finally hired someone for that front-end dev position. Dev kickoff is this week.
Lily Romano
@Lilyheart
Sep 22 2016 17:26
Awesome! I was just thinkin’ about that earlier today. I was gonna ask.
JBC944
@JBC944
Sep 22 2016 20:09
i got a question. For my new project in my web design class I have to make a resturant website with a menu has to be 2 html pages. Has to include hours and contact information and of course a menu on the 2nd page with images
and front page
any ideas on how to get started
Lily Romano
@Lilyheart
Sep 22 2016 20:11
I usually start a new web page with a physical drawing mock-up. I Try to draw out a rough design. Then I build up from there
JBC944
@JBC944
Sep 22 2016 20:13
i asked my web design teacher some and he said type it in the text editor and just get the structure part started and worry about the css later
Lily Romano
@Lilyheart
Sep 22 2016 20:14
Jason is right. Creating HTML first is a lot easier than the CSS. It's easy enough to move HTML blocks around to make the page look the way you want later
JBC944
@JBC944
Sep 22 2016 20:16
any ideas on how to start a home page for a resturant lol
Lily Romano
@Lilyheart
Sep 22 2016 20:28
Just start typing in the things you need. It may seem silly but like you said above, list the restaurant, hours and contact. You prob find once you get started, it's easy to keep going.
JBC944
@JBC944
Sep 22 2016 20:29
thanks for the advice
Lily Romano
@Lilyheart
Sep 22 2016 20:29
I find doodling on ppaper first helps. But by paper I mean a tablet and stylus xD
David Castner
@davidjcastner
Sep 22 2016 20:45
I think I've gone too far when I wrote a behavior driven development framework just do to my homework
someone save me from myself
Lily Romano
@Lilyheart
Sep 22 2016 20:56
Um, totally just told Jason about an hour ago that I was rewriting my driver to follow a more BDD style...
Eric Phy
@SimplyPhy
Sep 22 2016 20:56
okay, just finished react course fully 2 times
Lily Romano
@Lilyheart
Sep 22 2016 20:57
Jason said he used to teach UnitTesting as part of it.. but it took up too much classtime.
Eric Phy
@SimplyPhy
Sep 22 2016 20:57
time to make a little app with it
what’s dev kickoff?
Lily Romano
@Lilyheart
Sep 22 2016 20:57
One might even say it's time to .... React... to your lessons.
Eric Phy
@SimplyPhy
Sep 22 2016 20:58
that’s tender, that is tender (kung pow anyone :grin: )
also: i use tablet for mockups as well
Lily Romano
@Lilyheart
Sep 22 2016 20:58
@kdoylesei can you clarify what you meant by dev kickoff? I took it to mean that development (dev) starts this week (kickoff) but correct me if I'm wrong.
I really need these stickers to come back in stock as they need in my planner... like today... or maybe tomorrow.
JBC944
@JBC944
Sep 22 2016 21:05
Screenshot_2.png
i just did that in like 5 mins
Lily Romano
@Lilyheart
Sep 22 2016 21:05
That's a great start Jimmy!
Awesome :fireworks: :fireworks: :fireworks:
David Castner
@davidjcastner
Sep 22 2016 21:07
@Lilyheart here my driver, I can put it on github if you want to use it:
// David Castner

// TestDriver is an inferace that implements a behavior driven development testing framework
// inspired by mocha the js testing framework

public interface TestDriver {
    // replaces tabs with the amount of spaces
    void setTabsToSpaces(int amount);

    // decribe the subject of a test
    void describe(String describeSubjectOfTest);

    // creates a new test
    void it(String shouldDoSomething);

    // runs an assertion on a test expression
    void assertTest(boolean testExpression);

    // called after all tests are run
    void summarize();
}

public class BehaviorDrivenDevelopment implements TestDriver {
    int totalTests = 0;
    int totalFailed = 0;
    String singleTabString = "\t";
    String currentTestDescription = "";
    AssertionError currentTestException;
    // private variables representing state
    boolean isRunningTest = false;
    boolean hasCurrentTestFailed = false;

    // prints out a descriptions of the driver
    public BehaviorDrivenDevelopment(String driverDescription) {
        System.out.println(driverDescription);
    };

    // helper function for getting tab size
    String getTabString(int amountOfTabs) {
        String tabString = "";
        for (int i = 0; i < amountOfTabs; i++) {
            tabString += singleTabString;
        }
        return tabString;
    }

    // completes the current test
    void completeCurrentTest() {
        if (isRunningTest) {
            isRunningTest = false;
            // \u2713 is unicode for a check mark
            // \u2717 is unicode for a cross
            System.out.printf("%s%s %s\n", getTabString(2), hasCurrentTestFailed ? "\u2717" : "\u2713", currentTestDescription);
            if (hasCurrentTestFailed) {
                totalFailed++;
                currentTestException.printStackTrace();
            }
        }
    };

    // replaces tabs with the amount of spaces
    public void setTabsToSpaces(int amount) {
        String newSingleTabString = "";
        for (int i = 0; i < amount; i++) {
            newSingleTabString += " ";
        }
        this.singleTabString = newSingleTabString;
    };

    // decribe the subject of a test
    public void describe(String describeSubjectOfTest) {
        completeCurrentTest();
        System.out.printf("\n%s%s\n", getTabString(1), describeSubjectOfTest);
    };

    // creates a new test
    public void it(String shouldDoSomething) {
        completeCurrentTest();
        currentTestDescription = shouldDoSomething;
        totalTests++;
        isRunningTest = true;
        hasCurrentTestFailed = false;
    };

    // runs an assertion on a test statement
    public void assertTest(boolean testStatement) {
        if (!hasCurrentTestFailed && !testStatement) {
            hasCurrentTestFailed = true;
            currentTestException = new AssertionError(currentTestDescription);
        }
    };

    // called after all tests are run
    public void summarize() {
        completeCurrentTest();
        if (totalFailed == 0) {
            System.out.printf("\nAll %d test%s passed!\n", totalTests, totalTests != 1 ? "s" : "");
        } else {
            System.out.printf("\nSummary: %d total test%s ran\n", totalTests, totalTests != 1 ? "s" : "");
            System.out.printf("%s%d passed \u2713\n", getTabString(1), totalTests - totalFailed);
            System.out.printf("%s%d failed \u2717\n\n", getTabString(1), totalFailed);
            throw new RuntimeException("Did not pass all tests");
        }
    };
}
and here is an example of it in use:
public class BehaviorDrivenDevelopmentTest {
    public static void main(String[] args) {
        BehaviorDrivenDevelopment driver = new BehaviorDrivenDevelopment("testing the driver");
        driver.setTabsToSpaces(4);

        driver.describe("section 1");
            driver.it("should pass this test");
                driver.assertTest(true);
            driver.it("should fail this test");
                driver.assertTest(false);
            driver.it("should pass this test");
                driver.assertTest(true);

        driver.describe("section 2");
            driver.it("should fail this test");
                driver.assertTest(false);
            driver.it("should fail this test");
                driver.assertTest(false);
            driver.it("should pass this test");
                driver.assertTest(true);

        driver.summarize();
    }
}
Lily Romano
@Lilyheart
Sep 22 2016 21:08
awesome xD
David Castner
@davidjcastner
Sep 22 2016 21:09
outputs:
testing the driver

    section 1
        ✓ should pass this test
        ✗ should fail this test
java.lang.AssertionError: should fail this test
    at BehaviorDrivenDevelopment.assertTest(BehaviorDrivenDevelopment.java:69)
    at BehaviorDrivenDevelopmentTest.main(BehaviorDrivenDevelopmentTest.java:10)
        ✓ should pass this test

    section 2
        ✗ should fail this test
java.lang.AssertionError: should fail this test
    at BehaviorDrivenDevelopment.assertTest(BehaviorDrivenDevelopment.java:69)
    at BehaviorDrivenDevelopmentTest.main(BehaviorDrivenDevelopmentTest.java:16)
        ✗ should fail this test
java.lang.AssertionError: should fail this test
    at BehaviorDrivenDevelopment.assertTest(BehaviorDrivenDevelopment.java:69)
    at BehaviorDrivenDevelopmentTest.main(BehaviorDrivenDevelopmentTest.java:18)
        ✓ should pass this test

Summary: 6 total tests ran
    3 passed ✓
    3 failed ✗

Exception in thread "main" java.lang.RuntimeException: Did not pass all tests
    at BehaviorDrivenDevelopment.summarize(BehaviorDrivenDevelopment.java:82)
    at BehaviorDrivenDevelopmentTest.main(BehaviorDrivenDevelopmentTest.java:22)
Lily Romano
@Lilyheart
Sep 22 2016 21:09
I'll bookmark the code for later perusal. I have my little system nearly done but I have little knowledge about test environments so it's no where near as "offical" as yours. But gotta start somewhere right? :p
David Castner
@davidjcastner
Sep 22 2016 21:09
i'll put it on github
Lily Romano
@Lilyheart
Sep 22 2016 21:10
He was like "Yeah know, if the code is readable enough, I'll be honest, I might not even run the driver." heh. I was like, yeah, but I need more work on test stuff, so meh.
David Castner
@davidjcastner
Sep 22 2016 21:10
This message was deleted
This message was deleted
Lily Romano
@Lilyheart
Sep 22 2016 21:10
heh
David Castner
@davidjcastner
Sep 22 2016 21:11
This message was deleted
lol
Lily Romano
@Lilyheart
Sep 22 2016 21:11
This message was deleted
David Castner
@davidjcastner
Sep 22 2016 21:11
good idea
Lily Romano
@Lilyheart
Sep 22 2016 21:11
heh
secret conversation that no one knows!! mwhahahahhahahah
:smiling_imp:
Goin' dark for a bit. Gotta take my first Java Quiz.
David Castner
@davidjcastner
Sep 22 2016 21:12
have fun!
Lily Romano
@Lilyheart
Sep 22 2016 21:13
Then I'm attending the Coding Dojo online information session.
Lily Romano
@Lilyheart
Sep 22 2016 21:51
Test done. It's earlier then I thought. the other thing isn't for awhile so I'm around.
which is better
Screenshot_3.png
Lily Romano
@Lilyheart
Sep 22 2016 21:55
As far as what @JBC944 ? Information? Hard to make a general statement of better until your styling goes in.
JBC944
@JBC944
Sep 22 2016 22:02
i mean the layout
for instance for lee's hoagie house they have the hours listed near the title
Lily Romano
@Lilyheart
Sep 22 2016 22:05
You don't have much of a layout yet. That will come when you add in the styling. It's too early to say. When you start putting in margins and padding and such that will dramatically alter the appearance.
Lily Romano
@Lilyheart
Sep 22 2016 23:59
That feeling when: on Facebook you want to surround some text with double quotes so you highlight the words and press " but instead of adding quotes around it, the words all disappear! I <3 Atom