Skip to content

Instantly share code, notes, and snippets.

@ryaninvents
Last active April 20, 2017 03:36
Show Gist options
  • Save ryaninvents/ed5cc1618471240475272b79742136a5 to your computer and use it in GitHub Desktop.
Save ryaninvents/ed5cc1618471240475272b79742136a5 to your computer and use it in GitHub Desktop.

Solutions to problems or quirks I shouldn't have.

Web dev

Stack overflow in React (`Maximum call stack size exceeded`) Triggered this one a week ago with something like the following (pseudocode):
class MyComponent extends React.Component {
  static propTypes = {
    thing: PropTypes.shape({
      foo: PropTypes.string,
      bar: PropTypes.string,
    }).isRequired,
    onThingChange: PropTypes.func.isRequired,
  }
  componentWillReceiveProps({ thing }) {
    if (thing.foo !== this.props.thing.foo) {
      // perhaps validate foo, or maybe convert it to some "canonical" form
      const newFoo = validateAndMakeCanonical(thing.foo)
      this.handleFooChange(newFoo)
    }
  }
  handleFooChange(newFoo) {
    this.props.onThingChange({
      ...this.props.thing,
      foo: newFoo
    })
  }
  render() {
    return (
      <button onClick={() => this.handleFooChange('bar')}>
        Click me
      </button>
  }
}

Spot the issue.

_(click for spoiler)_ `handleFooChange` works fine for the button click, but when it's called from `componentWillReceiveProps` it will pass the old value of `bar`. This will trigger another update, which will call `componentWillReceiveProps` to get called again... eventually this overflows the stack.
Cannot assume role using AWS STS Even if you are running on a user or role with full admin privileges, you still need to add a trust relationship from the role you're trying to assume to the user/role you're currently using.

Uncategorized

rvm gives a `Regenerating ruby-2.0.0-p451 wrappers.........` message at every terminal open Run `rvm get head` to update.
Need to install Docker on a new Linux box `curl -L https://get.docker.com | sudo sh`
Connecting CUPS to my HP LaserJet See [instructions](http://askubuntu.com/questions/575547/how-can-i-install-hp-laserjet-p1102w-on-ubuntu).
sudo -i
apt-get update
apt-get install --reinstall hplip
hp-setup -i

Installing DisplayLink drivers on Ubuntu

Not sure yet if this is the fix, but there is a driver you can download here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment