Skip to content

Instantly share code, notes, and snippets.

View dkrichards86's full-sized avatar

Keith Richards dkrichards86

View GitHub Profile
@dkrichards86
dkrichards86 / install_python3_6_on_C9.md
Last active March 13, 2019 23:27 — forked from espozbob/install_python3_6_on_C9.md
Install Python3.6 on the C9
$ wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz

$ tar xvf Python-3.6.3.tgz

$ cd Python-3.6.3

$ ./configure --enable-optimizations

$ make -j8
@dkrichards86
dkrichards86 / SCP_CHEATSHEET.md
Created December 13, 2017 14:11
SCP cheatsheet!

SCP is a great resource for copying files from server to server. Unfortunately, I use it infrequently enough that I never remember the syntax.


Local to Remote

Copy file from the local host to a remote host

scp /path/to/myfile.txt username@remotehost:/some/remote/directory

Copy files from from the local host to your home directory on the remote host

@dkrichards86
dkrichards86 / docker_cleanup.md
Last active July 4, 2023 00:59
Docker cleanup commands

Docker Cleanup

Remove exited containers: docker rm $(docker ps -q --filter status=exited)

Remove old images: docker rmi $(docker images | grep "<none>" | awk '{print $3}')

Remove orphaned volumnes: docker volume rm $(docker volume ls -qf dangling=true)

Remove all unused containers, volumes, networks and images (both dangling and unreferenced): docker system prune

@dkrichards86
dkrichards86 / INSTALLING_NVM.md
Last active April 1, 2017 22:48
Down and dirty guide to installing NVM

Installing NVM

Because I always forget...

  • Head over to the NVM repository and follow the outlined steps. NVM
  • Run nvm install x.xx to grab a specific version of Node.
  • Run 'nvm alias default x.xx` to set that specific version as your default
  • ...
  • Profit!
@dkrichards86
dkrichards86 / PROPS_STATE.md
Created March 17, 2017 20:45
Some background information on React's this.props and this.state

Props and state

React has two primary sources of data, props and state. Superficially, these attributes are very similar. Both props and state are JavaScript objects, both are treated as immutable, and both will trigger a rerender. However, they serve different purposes.

props

props, short for properties, are, as the name suggests, a component's properties. These are set upstream and passed down to a component. They should be considered immutable, as changing them in a downstream component won't propagate back upstream. They can be thought of as configuration or options associated with a component.

Since props are used to modify a component, they often require validation to ensure proper behavior. React looks for helper attributes to determine the shape of props. These attributes are propTypes and defaultProps.

propTypes

propTypes describe the shape of the props object.

Redux

What exactly is Redux?

Simply put, Redux is a giant Javascript object containing all state information associated with a particular application. This object is known as the store.

It serves as a "single source of truth", allowing the developer to update data in a single location and have that update propagate everywhere.

Why does Redux exist?

When Facebook first launched React, they relied on a network of callbacks and references to keep application state in sync. While this approach can work on small applications, it doesn't behave well in large apps. React has tens of thousands of components, making a callback network impossible to maintain. Enter Flux.

React's Component Lifecycle

React has a built-in hook system useful for updating your component based on changes in data, both local and inherited. This is known as the Component Lifecycle.

constructor()

React's lifecycle starts with constructor(). Here, you initialize state and bind class methods.

Why bind class methods?

Anonymous functions are created as needed, which can be a costly exercise. If you

@dkrichards86
dkrichards86 / ReactErrors.md
Last active May 23, 2017 09:18
React Minified Error Codes - Decoded
Code Message
0 React.addons.createFragment(...): Encountered an invalid child; DOM elements are not valid children of React components.
1 update(): expected target of %s to be an array; got %s.
2 update(): expected spec of %s to be an array; got %s. Did you forget to wrap your parameter in an array?
3 update(): You provided a key path to update() that did not contain one of %s. Did you forget to include {%s: ...}?
4 Cannot have more than one key in an object with %s
5 update(): %s expects a spec of type 'object'; got %s
6 update(): %s expects a target of type 'object'; got %s
7 Expected %s target to be an array; got %s