Open Side Menu Go to the Top
Register
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** ** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD **

10-17-2018 , 02:11 AM
People who do all their stuff on AWS - how do you create intranets, monitoring sites, dev/test environments and static sites that can only be accessed locally and you don't want to expose to the internet?

I can limit S3 to IP addresses. But I can't get HTTPS worknig with just S3 static webhosting.

Cloudfront->S3 handles the HTTPS part, but it seems to ignore static IP restriction. Also Cloudfront is sooo slow to update and it caches crap forever. Terrible for dev and testing.

I managed to get API Gateway to proxy to S3 over https. But I can't figure out anyway to restrict the actual S3 bucket. It still needs to be read access for everyone in the world for my API Gateway proxy to work. Whatever IP API Gateway is sending it's not my source IP. Also w/o a custom domain (CloudFront again) API Gateway adds /{stage} to all its urls - which is hacky to work around.

There has to be some way to do this.

I could proxy all the way to lambda I guess and then give lambda programmatic access to S3. Still have to deal with the path-appending in API gateway though - which screws with static sites. But maybe the Cloudfront custom domain would only act as a DNS pointer and not try to cash everything. Hmmm.

Last edited by suzzer99; 10-17-2018 at 02:23 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 03:14 PM
Ok well I got it working more or less the way I want.
  1. Restrict access to s3 bucket to only cloudfront
  2. Turn off caching in cloudfront by setting the TTLs to 0 - this made a gigantic difference
  3. Add in a WAF and restrict access to cloudfront by IP there.

No idea how much extra this is going to cost us just for dev/internal sites. But YOLO.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 03:17 PM
Quote:
Originally Posted by Craggoo
How would you guys read this situation:

A company that's been around for 14 years, been profitable for the last 10, and has 40 employees? Most companies are all about growth so it seems really weird to me that a company would stay that small for that long.


Probably a good place to work, but management probably lacks ambition or the product is really niche.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 03:54 PM
People make a big deal about companies like basecamp that are happy to stay small. I’m of the mind that those are anomalies, and that everything in the world is either growing or dying.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 04:43 PM
On a civilization timescale - sure. But on a human timescale I think there's something to be said for just carving out a niche and being comfortable there. If humans lived forever I might feel differently. But it's not too hard to live your lifetime in a comfy spot that isn't growing or dying.

I've always thought one of the nice things about Kansas City is that it doesn't seem to grow or shrink. So it's not always having growing pains, nor is it a depressing wasteland. I assume people in Tuscany or Provence feel the same. Not gonna die but they sure don't want to grow.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 10:04 PM
Is this a legit use case for var (in react)? let or const puts it out of scope. I want it to be null if I don't have any yet.

Code:
render () {

    if (this.state.signaturesValidated) {
      var validationResults = (
        <p>{this.state.idTokenSigValidMsg}</p>
      )
    }

    return (
      <div className="Main">
          {validationResults}
      </div>
    )
}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 10:12 PM
use let at the render() level? What do you want to return when !signaturesValidated?
let validationResults = whateverthatis
as the first line
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 10:24 PM
edit: as Rusty said

Idk seems like one would just use let above the if block to scope it suitably? (untested)
Code:
render () {
    let validationResults = null
    if (this.state.signaturesValidated) {
      validationResults = (
        <p>{this.state.idTokenSigValidMsg}</p>
      )
    }

    return (
      <div className="Main">
          {validationResults}
      </div>
    )
}
Though I think it can all be reduced to just this? (no variables, also untested)
Code:
render() {
    return <div className="Main">{this.state.signaturesValidated ? <p>{this.state.idTokenSigValidMsg}</p> : null}</div>
}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 10:27 PM
Quote:
Originally Posted by suzzer99
Is this a legit use case for var (in react)? let or const puts it out of scope. I want it to be null if I don't have any yet.

Code:
render () {

    if (this.state.signaturesValidated) {
      var validationResults = (
        <p>{this.state.idTokenSigValidMsg}</p>
      )
    }

    return (
      <div className="Main">
          {validationResults}
      </div>
    )
}
yikes

Code:
render() {

    return this.state.signaturesValidated ? <div className="Main"><p>{this.state.idTokenSigValidMsg}</p></div> : <div className="Main" />
}
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-17-2018 , 10:37 PM
^that
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-18-2018 , 12:37 AM
It's part of a larger template. I just simplified it.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-18-2018 , 12:39 AM
Quote:
Originally Posted by _dave_
edit: as Rusty said

Idk seems like one would just use let above the if block to scope it suitably? (untested)
Code:
render () {
    let validationResults = null
    if (this.state.signaturesValidated) {
      validationResults = (
        <p>{this.state.idTokenSigValidMsg}</p>
      )
    }

    return (
      <div className="Main">
          {validationResults}
      </div>
    )
}
Yeah that works and is obviously the way I'd normally code. But I think it's kinda cool how react will just show nothing and not barf for null/undefined. So why bother declaring it outside the if condition?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 02:00 AM
Work started a CTF since it’s security awareness month. And it has been soo fun and addicting. I shamelessly have been doing no work and instead working on the challenges.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 02:34 AM
I came up with a way to implement component-based architecture in react that similar to my OS node frameworks.

Key principles:
  1. Components should define their own routes internally (/signin, /cool/stuff, /, etc).
  2. Components are auto-discovered, if they're in the right folder they just work, no extra configuration.
  3. Components can be moved, renamed, or deleted w/o any extra configuration or breaking anything in the app (except for any links that point to them of course).
  4. All supporting files like CSS files, test files, JSX files, stubs, etc. - live with the component.

It just makes development more fun imo when you don't have to go and register your routes in 5 different places just for your components to work. And it removes all friction from reorganizing or renaming - which is a good thing.

Just copy a component that's similar and go. Need to rename? No problem. A group of components is growing too big and you want to put it in a subfolder? No problem. Just move stuff into a subfolder and everything still works w/o any extra configuration.

Last edited by suzzer99; 10-19-2018 at 02:42 AM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 10:43 AM
Not sure I understand how #3 would work, the rest of it sounds pretty standard

Like say I have 2 components, like, Person and Child. So my JSX for Person is like

Code:
<div>
{childlist.map((x) => <Child name={x}>)}
</div>
For this to work, Child needs to be imported into this JS file. If you move Child, then you have to change the import?

I guess I'd like to see a simple example of it if you have one (with routing, I feel like I am doing routing wrong because it does not work the way I'd like it to)
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 10:58 AM
Quote:
Originally Posted by RustyBrooks
Code:
<div>
{childlist.map((x) => <Child name={x}>)}
</div>
Can't unsee.

Spoiler:
Warning: Each child in an array or iterator should have a unique "key" prop.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 10:59 AM
Think I’m doing a cultural fit interview today. What are some nonstandard questions? I have a list of what I think are ones i genuinely want to know the answer to but I don’t want to get bull****ted. We’re one toxic person away from being unable to function.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 11:16 AM
Quote:
Originally Posted by Grue
Can't unsee.

Spoiler:
Warning: Each child in an array or iterator should have a unique "key" prop.
Can you hear my eyes rolling from here?
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 02:00 PM
Quote:
Originally Posted by jmakin
Think I’m doing a cultural fit interview today. What are some nonstandard questions? I have a list of what I think are ones i genuinely want to know the answer to but I don’t want to get bull****ted. We’re one toxic person away from being unable to function.
I honestly think you can learn a lot about how they approach answering "Tell me about yourself"
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 02:33 PM
I also like asking about actual situations they've had to deal with:

* Tell me about a time you had a disagreement with a co-worker and how you dealt with it
* Tell me about the best team you've ever worked on
* Tell me about a time you failed

Etc.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 02:43 PM
I've never asked those questions but when I've been asked them I feel like what I'm providing doesn't show any real insight or maybe doesn't have the possibility of showing any real insight.

I do like "tell me about yourself" though.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 02:53 PM
Quote:
Originally Posted by RustyBrooks
Not sure I understand how #3 would work, the rest of it sounds pretty standard

Like say I have 2 components, like, Person and Child. So my JSX for Person is like

Code:
<div>
{childlist.map((x) => <Child name={x}>)}
</div>
For this to work, Child needs to be imported into this JS file. If you move Child, then you have to change the import?

I guess I'd like to see a simple example of it if you have one (with routing, I feel like I am doing routing wrong because it does not work the way I'd like it to)
I'm talking about being able to move, renamed or delete stuff (currently only page-level components) w/o breaking import statements or component references off in other files. I know it seems like a little thing but I think that adds friction to good renaming, reorganizing and refactoring - which ultimately makes for crappier code. For example:



Once I got this system in place, I was able to move all the CustomUI stuff into a subfolder and nothing broke, no import statements had to be updated anywhere. I could also delete the whole folder and the only thing that would break are places the app is linking to or serving the pages.

So it's like the old days where you drop a JSP in a folder and it just works. Except better in that the route doesn't change.

The first step is an npm start script that creates a metadata file of everything in the /routes folder that matches - which is currently *.js but not *.test.js.

This script runs every time you call npm start:
Code:
const glob = require('glob');
const fs = require('fs');

loadRoutes('/src/routes', ['*.test.js']);

function loadRoutes(dir, excludes) {
  console.log('pre-start.js: loadRoutes called - dir: ' + dir + ', exclude: ' + excludes);

  const routes = [];
  glob.sync("**/*.js", { "ignore": excludes, cwd: './src/routes' })
    .forEach(function(file) { 
      console.log('pre-start.js: registered route: ' + file)
      routes.push(file); 
    });

  const file = {"IMPORTANT!": "GENERATED FILE - see pre-start.js", routes};

  fs.writeFile('src/route-metadata.json', JSON.stringify(file,0,2), function(err){
    if(err) console.error(err);
    else console.log('pre-start.js: src/route-metadata.json written')
  });
}
In my node version of this, that part was all done seamlessly because node has access to the file directory, which client-side JS does not. So the directory scan needs to be done when the react dev server starts. One issue I can see is that deciding whether to check in or just always generate route-metadata.json might get a little weird. I'll see how it plays out.

Here's how it dynamically loads the routes in the index.js file:
Code:
// dynamic routes are calculated by node on npm start - see ../pre-start.js
import routesMetadata from './route-metadata.json';

...

const App = () => {

  return (
    <BrowserRouter>

      <div className="sans-serif">
        <Switch>

          {routes.map((r) => {
            return <Route key={r.route} path={r.route} component={r.default}/>
          })}

         </Switch>
       </div>
    </BrowserRouter>
  )};

async function doRender () {
  routes = await utils.loadRoutes(routesMetadata);
  render(<App />, document.getElementById('root'));
}

doRender();
the files are dynamically imported in utils.js:
Code:
  loadRoutes: async routesMetadata => {
    const routes = [];
    for (let routeName of routesMetadata.routes) {
      const module = await import('./routes/' + routeName.substr(2));
      console.log("registering route: " + module.route);
      routes.push(module);
    };

    return routes.sort(compareRoutes);

    function compareRoutes(a, b) {
      const indexA = a.routeIndex || 0;
      const indexB = b.routeIndex || 0;

      // inverse sort
      if (indexA > indexB) return 1;
      else if (indexA < indexB) return -1;
      else return 0;
    }
  }
As you can see there's a convention that the component name and file name be the same. But we could always export an optional component name property if that couldn't be done for some reason.

I used BrowserRouter because it was the first router I stumbled across. It may be easier or harder with other types of routers. The routes also have optional routeIndex so they can be loaded in order if necessary ('/' has to come last, could be other wildcard matching routes if react supports that). If we get a bunch of routes, we will probably want to push sorting to the node step instead of the browser step. But that gets messy because node has to grep into the files to find out the route index. Currently this is just for my kitchen sink demo app that's basically a collection of stuff the devs can use.

And finally here's what a route component looks like:

Home.js:
Code:
import React, { Component } from 'react';
import { Auth } from 'aws-amplify';
import { withOAuth } from 'aws-amplify-react';
import { utils } from "util.js";
import './Main.css';

export const route = "/";
export const routeIndex = 1000; // optional - higher # indicates route is loaded last (like z-index)

class Home extends Component {

...

}

export default withOAuth(Home);
Most route components only have to export route and not routeIndex. At first I just added route as a static variable on the Home class. But in this case Home is wrapped in the higher-order-component withOAuth. There doesn't seem to be any way to get access to the wrapped class. So I had to add the extra export statement that the top.

Also by adding a .env file which points to the /src directory, the routes are able to use absolute path to import 'util.js' - this helps when reorganizing into subfolders.

This is all kinda hacky still - there are probably better ways to do some of the mechanics. But it works at least. I even tested on IE and everything's fine.

I will chip away at it as better ideas come for how to handle different pieces - as I did with the node OS framework over a couple years. By the end that app had some 200 routes, which were much easier to handle w/o import statements all over the place. The front end devs loved it because they could just create their node orchestration component to call our back end scala/play layer, w/o having to touch a bunch of other files.

The system that came after I left was more like a standard node app with a many to many service layer to route handler layer - and import statements scattered all over a router hierarchy. The same front end devs told me they wished they had yukon back. The new system pretty much required a full time node dev, whereas mine didn't.


tl;dr - suzzer likes component-based architecture combined with self-discovery and route handling done internally to the components - not orchestrated from central command.

Last edited by suzzer99; 10-19-2018 at 03:21 PM.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 03:38 PM
Quote:
Originally Posted by Grue
I've never asked those questions but when I've been asked them I feel like what I'm providing doesn't show any real insight or maybe doesn't have the possibility of showing any real insight.

I do like "tell me about yourself" though.
I have no idea how you answer them, but you can definitely tell a lot from someone when they have to tell you about a problem they've faced and how they've dealt with it.

Sometimes its even interesting hearing them give what they think "the right" answer is.

Edit: Although, sure, like any question its not going to be the make or break question for most candidates. But its useful for a significant percentage of candidates. Which is all you can really ask for of an interview question I think.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 03:46 PM
I just had an hour long meeting with someone from HR. I'm trying to hire someone and he set up the meeting so we could talk about our process (which is half-assed) and what kind of person we're looking for etc.

It was a very uncomfortable meeting for me, but I think probably really worth while. He made me lay out in very concrete terms what I liked about my team members and what I thought we were missing and *specifically* what personality traits we wanted team members to have, and what those traits really mean.

I am so not good at this stuff, but his point was "everyone wants to hire someone intelligent, but if you don't SAY you want to, and define what intelligence means to you, then you won't ask the right questions or interpret the answers properly in order to achieve it"

I am not sold on the idea that you CAN definitely make a procedure that properly selects employees but I guess at least he's trying.

We're also using a service that analyzes your job posting to, I dunno, try to see how it will be received. This sounds a bit like woo to me but I dunno. It's supposed to report how inclusive your job posting sounds, how likely people are to read past the first line, etc.

Personally I would love to have SOME kind of framework that the whole company uses, right now we just flail around, everyone doing something different.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote
10-19-2018 , 03:48 PM
Quote:
Originally Posted by suzzer99
I'm talking about being able to move, renamed or delete stuff...
I am going to have to look at this later and see if I can make sense of it.

Right now I am unhappy with how my routing is set up but I don't know how to do it better. I do know that I think I am going to ditch react-materials-ui because I feel like it works against me more than for me. It was nice having something that made consistent ui elements though. I am really not a front end developer or designer and all the stuff I make myself is ugly and awkward.
** UnhandledExceptionEventHandler :: OFFICIAL LC / CHATTER THREAD ** Quote

      
m