This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const fetchUser = () => async dispatch => { | |
| const res = await axios.get("/api/current_user"); | |
| dispatch({ type: FETCH_USER, payload: res }); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const fetchUser = () => { | |
| return function(dispatch) { | |
| axios | |
| .get("/api/current_user") | |
| .then(res => dispatch({ type: FETCH_USER, payload: res })); | |
| }; | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import axios from 'axios'; | |
| const ROOT_URL = 'http://localhost:3090'; | |
| export function signinUser({ email, password }, callback) { | |
| return function(dispatch) { | |
| axios.post(`${ROOT_URL}/signin`, { email, password }) | |
| // If request is good... | |
| .then(response => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Signin extends Component { | |
| handleFormSubmit({ email, password }) { | |
| this.props.signinUser({ email, password }, () => { | |
| this.props.history.push('/feature'); | |
| }); | |
| } | |
| ... | |
| render() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function mapStateToProps({ products }) { | |
| return { products }; | |
| } | |
| function mapDispatchToProps(dispatch) { | |
| return bindActionCreators({ fetchProducts }, dispatch); | |
| } | |
| export default connect(mapStateToProps, mapDispatchToProps)(ProductList); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from datetime import datetime | |
| from datetime import date | |
| import numpy as np | |
| import pandas as pd | |
| data = { | |
| 'date': ['2014-05-01', '2014-05-01', '2014-05-02', '2014-05-02', '2014-05-02', '2014-05-03', '2014-05-03', '2014-05-04', '2014-05-04', '2014-05-08'], | |
| 'score': [34, 25, 26, 15, 15, 14, 26, 25, 62, 41] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ docker inspect containerid | |
| ... | |
| "Mounts": [ | |
| { | |
| "Type": "bind", | |
| "Source": "/var/mysql", | |
| "Destination": "/mysql_data", | |
| "Mode": "rw", | |
| "RW": true, | |
| "Propagation": "rprivate" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Restore from Docker repo | |
| $ docker run mysql | |
| # Restore from Docker tarball | |
| $ docker load -i mysql.tar | |
| $ docker images # To confirm that it has been loaded locally | |
| $ docker run mysql |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # First get ID of running container | |
| $ docker ps | |
| CONTAINER ID ... | |
| 5776d1849024 ... | |
| # Next we take a snapshot of the docker container by first pausing (-p) the container | |
| $ docker commit -p 5776d1849024 mysql | |
| e09f9ac65c8b3... | |
| # The commit arg saves the entire snapshot as a docker image with a name mysql: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Backup database Globals | |
| su - postgres -c "pg_dumpall -g --file=/tmp/globals.sql;" | |
| # Backup all databases | |
| su - postgres -c 'psql -At -c "SELECT datname FROM pg_database WHERE NOT datistemplate"' | \ | |
| while read f; | |
| do su - postgres -c "pg_dump --format=c --file=/tmp/$f.sqlc $f"; | |
| done; |