Club PA 2.0 has arrived! If you'd like to access some extra PA content and help support the forums, check it out at patreon.com/ClubPA
The image size limit has been raised to 1mb! Anything larger than that should be linked to. This is a HARD limit, please do not abuse it.
Our new Indie Games subforum is now open for business in G&T. Go and check it out, you might land a code for a free game. If you're developing an indie game and want to post about it, follow these directions. If you don't, he'll break your legs! Hahaha! Seriously though.
Our rules have been updated and given their own forum. Go and look at them! They are nice, and there may be new ones that you didn't know about! Hooray for rules! Hooray for The System! Hooray for Conforming!

[Programming] Mirror, mirror, on the wall, show the git diff for them all

194959799100

Posts

  • SaerisSaeris Borb Enthusiast flapflapflapflapRegistered User regular
    :+1: for derived state.

    borb_sig.png
    Echo
  • EchoEcho Moderator mod
    edited May 2016
    Infidel wrote: »
    You will have some problems though with your onFilterChange, since you call setState more than once in the tick. This can lead to lost updates since depending on ticks and the event loop, you'll overwrite/lose the change.

    Yeah, I refactored that bit just before pushing it. Marvel at how jsbeautify formats ternaries!
    onFilterChange: function(e) {
        var textFilter = e.target.value;
        var isDisabled = (textFilter.length > 0)
          ? false
          : true;
    
        this.setState({textFilter: textFilter, resetIsDisabled: isDisabled});
        this.props.onFilterChange(textFilter);
      },
    
    Infidel wrote: »
    but what I would do is get rid of resetIsDisabled, because it is entirely derived from state you already have. Try to keep only the state that is necessary. You would just write this in your render:
    disabled={this.state.textFilter.length === 0}
    

    Yeah, I like that. *fixes*

    Echo on
    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
  • Alistair HuttonAlistair Hutton Dr EdinburghRegistered User regular
    I've picked up my static site generator project again. Doing some refactoring, finally got the MDL styles to look decent in my templates.

    Writing a static site generator is fun, everyone should do it.

    I have a thoughtful and infrequently updated blog about games http://whatithinkaboutwhenithinkaboutgames.wordpress.com/

    I made a game, it has penguins in it. It's pay what you like on Gumroad.

    Currently Ebaying Nothing at all but I might do in the future.
  • EchoEcho Moderator mod
    edited May 2016
    Alright, more React stuff. I want to change a tooltip based on whether a different overlay is open or not. This was originally just the one OverlayTrigger on a button for a popover, so I stuck the tooltip OverlayTrigger inside that.

    Does OverlayTrigger not have onEnter/Exit events? I'm trying to figure out where to detect if the popover is open or not. Or do I need a custom Overlay for that?

    edit: I did this just to see when stuff fires. And... it all fires when the OverlayTrigger is mounting, and nothing whatsoever when toggling the actual overlay.
    <OverlayTrigger trigger="click" placement="bottom"
      onEnter={console.log("Enter")}
      onEntering={console.log("Entering")}
      onEntered={console.log("Entered")}
      onExit={console.log("Exit")}
      onExiting={console.log("Exiting")}
      onExited={console.log("Exited")}
      overlay={overlay}>
      <OverlayTrigger placement="top" overlay={tooltip}>
        {historyButton}
      </OverlayTrigger>
    </OverlayTrigger>
    

    edit: and for whatever reason the events started firing properly now. :rotate:

    Echo on
    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
  • InfidelInfidel Heretic Registered User regular
    Echo wrote: »
    Alright, more React stuff. I want to change a tooltip based on whether a different overlay is open or not. This was originally just the one OverlayTrigger on a button for a popover, so I stuck the tooltip OverlayTrigger inside that.

    Does OverlayTrigger not have onEnter/Exit events? I'm trying to figure out where to detect if the popover is open or not. Or do I need a custom Overlay for that?

    edit: I did this just to see when stuff fires. And... it all fires when the OverlayTrigger is mounting, and nothing whatsoever when toggling the actual overlay.
    <OverlayTrigger trigger="click" placement="bottom"
      onEnter={console.log("Enter")}
      onEntering={console.log("Entering")}
      onEntered={console.log("Entered")}
      onExit={console.log("Exit")}
      onExiting={console.log("Exiting")}
      onExited={console.log("Exited")}
      overlay={overlay}>
      <OverlayTrigger placement="top" overlay={tooltip}>
        {historyButton}
      </OverlayTrigger>
    </OverlayTrigger>
    

    edit: and for whatever reason the events started firing properly now. :rotate:

    When you have attr={expression} it is evaluating that expression and assigning it.

    So if you call a function, it will do that while mounting, and use the result of that function as the assignment.

    If you passed it just {console.log} then it would call it with whatever arguments, since the expression evaluates to a function.

    What you want with your intention here is a wrapper function, {() => console.log('Enter')} and so on. That technically returns the result of console.log (which you don't care about) but the return doesn't do anything anyway.

    OrokosPA.png
    Play D&D 4e? :: Check out Orokos and upload your Character Builder sheet! :: Orokos Dice Roller
    The PhalLounge :: Chat board for Critical Failures IRC! :: #CriticalFailures and #mafia on irc.slashnet.org
  • EchoEcho Moderator mod
    Yeah, that's one of those JS things I just haven't quite gotten used to yet. Getting better at not tripping on it though.

    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
  • TraceTrace GNU Terry Pratchett; GNU Gus; GNU Carrie Fisher; GNU Adam We Registered User regular
    http://groups.csail.mit.edu/uid/mass-edit/

    Ran across this site about half a week ago. Holy shit is it ever useful.

  • EchoEcho Moderator mod
    It feels weird to use anonymous types in C#, but damn if it isn't handy for making quick JSON objects.

    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
  • bowenbowen How you doin'? Registered User regular
    Echo wrote: »
    It feels weird to use anonymous types in C#, but damn if it isn't handy for making quick JSON objects.

    Got example code? I think I could use this actually.

    Ladies.
  • EchoEcho Moderator mod
    edited May 2016
    var response = new
    {
      LoginStatus = "challenge",
      Authentication = new
      {
        Email = user.IsEmailAuthenticationEnabled,
        App = user.IsGoogleAuthenticatorEnabled,
        Phone = user.PhoneNumberConfirmed
      }						
    };
    
    return Json(response);
    

    Echo on
    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
    bowenadmanbecco the dolphinInfidelironsizideDelmainTofystedeth
  • bowenbowen How you doin'? Registered User regular
    Interesting, I haven't used that yet, but it seems right up my alley.

    Can you generate an anon type from the Json on the other end?

    Ladies.
  • EchoEcho Moderator mod
    edited May 2016
    I've been using [FromBody] for that.
    [HttpPost]
    public async Task<IActionResult> LoginAjax([FromBody] LoginViewModel model, Guid clientGuid, string returnUrl = null)
    {
    

    It grabs properties from the POST (I think it requires JSON, actually) and sticks matching properties into whatever you give the [FromBody] attribute.

    Echo on
    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
  • bowenbowen How you doin'? Registered User regular
    hmm I'm using nancy, looks like you're using MCF or something like that?

    Ladies.
  • bowenbowen How you doin'? Registered User regular
    http://www.newtonsoft.com/json/help/html/QueryJsonDynamic.htm

    though that looks pretty close to what I want

    Ladies.
  • LD50LD50 Registered User regular
    At some point you might as well start using Rails :P.

  • bowenbowen How you doin'? Registered User regular
    Langauges that need their runtimes installed can go fuck themselves.

    Ladies.
    amnesiasoft
  • EchoEcho Moderator mod
    http://stackoverflow.com/a/6905037/2075613 has some stuff about deserializing JSON to an anonymous type.

    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
  • LD50LD50 Registered User regular
    bowen wrote: »
    Langauges that need their runtimes installed can go fuck themselves.

    Like c#?

  • bowenbowen How you doin'? Registered User regular
    LD50 wrote: »
    bowen wrote: »
    Langauges that need their runtimes installed can go fuck themselves.

    Like c#?

    Not since like 2002.

    Ladies.
  • LD50LD50 Registered User regular
    bowen wrote: »
    LD50 wrote: »
    bowen wrote: »
    Langauges that need their runtimes installed can go fuck themselves.

    Like c#?

    Not since like 2002.

    You can package ruby into standalone executables too, it's just not normally done because most ruby use is server-side where people want more control over the environment.

  • bowenbowen How you doin'? Registered User regular
    your momma wants more control over the environment!

    Ladies.
    LD50urahonkyDisruptedCapitalist
  • NogsNogs Crap, crap, mega crap. Registered User regular
    Holy butts: https://hyperdev.com

    rotate.jpg
    PARKER, YOU'RE FIRED! <-- My comic book podcast! Satan look here!
    urahonkyironsizideDisruptedCapitalist
  • urahonkyurahonky Registered User regular
    Nogs wrote: »

    Very cool stuff!

  • EchoEcho Moderator mod
    edited June 2016
    Anyone know how I can get the base URL for the site in MVC 6? All the googlin' only gives me old stuff that's changed in MVC 6.

    Echo on
    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
  • NogsNogs Crap, crap, mega crap. Registered User regular
    react europe is going on right now for those interested, here is live stream:

    rotate.jpg
    PARKER, YOU'RE FIRED! <-- My comic book podcast! Satan look here!
    urahonky
  • zerzhulzerzhul Registered User, Moderator mod
  • DelmainDelmain Registered User regular
    @skippydumptruck is a frogram now, please welcome him

    syndalis wrote: »
    Apple is a terrible company.
    ecco the dolphinthatassemblyguy
  • skippydumptruckskippydumptruck (♡°◡°) Registered User regular
    Delmain wrote: »
    @skippydumptruck is a frogram now, please welcome him

    merging this thread into my usual forum browsing

    urahonkyInfidelecco the dolphinthatassemblyguyGrape ApeTofystedeth
  • urahonkyurahonky Registered User regular
  • EchoEcho Moderator mod
    zerzhul wrote: »

    So today I spent nearly two hours looking for a bug in all the wrong places.

    I'm working on the login page for this web app. The backend has all the code necessary for 2FA via app, phone and email, but it's not implemented on the frontend yet. My job is to wire that up and use ajax stuff so it's all a single page for the login.

    I write JS stuff that sends some JSON with login credentials, and a method in the controller that accepts that and validates it and returns some JSON with the login state. That works just fine, and if the account doesn't have 2FA enabled it logs in properly.

    Then I start on the bits to handle 2FA. I write the JSON receiver in the controller first, and I can log in with 2FA by just posting the auth code in a regular form. Great, now to hook that up to the jQuery bits. I write a new function for the ajax call, but realize it's identical to the bit for the first auth, so I change that to a single function that takes an additional URL argument.

    Now the login bit works, but not the 2FA. The only different thing is the URL. In hindsight this was the obvious warning bell, but for some reason I decide it's the javascript bits that are wrong, because the 2FA validation method apparently gets no data whatsoever from the ajax call.

    90 minutes later: oh look, I forgot the [FromBody] that populates the input model from the JSON in the request.

    Echo wrote: »
    Let they who have not posted about their balls in the wrong thread cast the first stone.
    ecco the dolphinzerzhuladmanbBarrakketh
  • SarksusSarksus Registered User regular
    edited June 2016
    I am two weeks into my first internship and it is a mixture of joy and misery.

    I am using internal libraries to bring shit in COBOL files to the database, and the code for that was like the SMALLEST part of the actual task. Most of my time was spent being abused by the build system, SVN, build path fuckery, deploying* to Tomcat, talking to the REST API, and testing. And I have to use Eclipse.

    I still have to figure out how to better test the code I wrote. I'd like to do more than eyeball a few entries and make sure nothing was mangled. I miss Python's zip function from itertools.

    But it was really cool making a request to the API and seeing the database fill up with everything. One step closer to leaving COBOL behind! And I am gonna write hella documentation in the internal wiki about the stuff I figured out.

    *copying the .war file to the test server

    Sarksus on
    Mahnmutecco the dolphin
  • ecco the dolphinecco the dolphin Registered User regular
    Sarksus wrote: »
    ... the code for that was like the SMALLEST part of the actual task.

    I hate to break it to you, but... this is actually quite normal...

    Penny Arcade Developers at PADev.net.
    DelmainbowenthatassemblyguymightyjongyoironsizidegavindelDisruptedCapitalistTzyrGrape Ape
  • hippofanthippofant ティンク Registered User regular
    Sarksus wrote: »
    ... the code for that was like the SMALLEST part of the actual task.

    I hate to break it to you, but... this is actually quite normal...

    Most programs work perfectly... at doing something other than what you need them for.

    ecco the dolphin
  • SpawnbrokerSpawnbroker Registered User regular
    Had my third (and hopefully final) interview with a company I'm pretty excited for today.

    I feel like I'm not exactly what they're looking for, but also that the person they're looking for doesn't exist, if that makes sense.

    They want someone who knows SharePoint inside and out, can write custom C# SharePoint code, modify CSS/master pages, and also knows how to plan and architect a server farm for a global company from an administration standpoint.

    There are maybe 10 people in the world that fit this job description I think. That being said, I think I'm doing pretty well and hope I get an offer. But I won't be upset if I don't, it just won't be a surprise.

    Battle.net: Spawnbroker#1471
    Steam: Spawnbroker
    Final Fantasy XIV: Spawn Broken
    ecco the dolphin
  • ecco the dolphinecco the dolphin Registered User regular
    Had my third (and hopefully final) interview with a company I'm pretty excited for today.

    I feel like I'm not exactly what they're looking for, but also that the person they're looking for doesn't exist, if that makes sense.

    They want someone who knows SharePoint inside and out, can write custom C# SharePoint code, modify CSS/master pages, and also knows how to plan and architect a server farm for a global company from an administration standpoint.

    There are maybe 10 people in the world that fit this job description I think. That being said, I think I'm doing pretty well and hope I get an offer. But I won't be upset if I don't, it just won't be a surprise.

    Yeah

    When I'm looking for jobs, I like to keep in mind that the list of skills that they put forth is their "ideal" candidate. And just like your "perfect" partner, they only exist in your dreams.

    Our job is to let them down gently, and bring them back to reality =P

    Penny Arcade Developers at PADev.net.
  • SarksusSarksus Registered User regular
    Sarksus wrote: »
    ... the code for that was like the SMALLEST part of the actual task.

    I hate to break it to you, but... this is actually quite normal...

    Yeah it's a big change from school where 94% of the work was code with the remaining 6% being the one semester we had to use makefiles.

  • RendRend Registered User regular
    Sarksus wrote: »
    Sarksus wrote: »
    ... the code for that was like the SMALLEST part of the actual task.

    I hate to break it to you, but... this is actually quite normal...

    Yeah it's a big change from school where 94% of the work was code with the remaining 6% being the one semester we had to use makefiles.

    In school they tell you what to write and how to write it though, which eliminates the most massive portion of work: thinking

    ecco the dolphinGrape Ape
  • PhyphorPhyphor Building Planet Busters Tasting FruitRegistered User regular
    hippofant wrote: »
    Sarksus wrote: »
    ... the code for that was like the SMALLEST part of the actual task.

    I hate to break it to you, but... this is actually quite normal...

    Most programs work perfectly... at doing something other than what you need them for.

    Crashing. Most programs are good at crashing

    Magic Box
    Academician Prokhor "Phyphor" Zakharov, Chief Scientist of China, Provost of the University of Planet - SE++ Megagame
    ecco the dolphin
  • DehumanizedDehumanized Registered User regular
    edited June 2016
    Dehumanized on
    ecco the dolphin
  • LD50LD50 Registered User regular


    I've edited code on a tablet before. It was not an enjoyable experience, and now swiftkey's user dictionary has a bunch of method calls in it.

This discussion has been closed.