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
// @desc Basic boilerplate for server.js file. app set up, set up middleware like dotenv and morgan.use of environment vars | |
const express = require('express'); | |
const dotenv = require('dotenv'); | |
const morgan = require('morgan'); | |
const bootcamps = require('./routes/bootcamps'); | |
// Load environment variables | |
dotenv.config({ path: './config/config.env' }); |
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
#Python Rot13 Encoder | |
password = input("Enter string to encrypt with Rot13:\n") | |
# Using the str.maketrans to make a translation key | |
# Could apply the rot13 encoding scheme | |
rot13 = str.maketrans( | |
"ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz", | |
"NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm") |
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
<header class="main-header"> | |
<nav class="transparent z-depth-0"> | |
<div class="nav-wrapper"> | |
<a | |
href="#" | |
data-activates="mobile-nav" | |
class="button-collapse show-on-large" | |
> | |
<i class="material-icons">menu</i> | |
</a> |
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
<html> | |
<body id="home" class="scrollspy"> ******** | |
<header class="main-header"> | |
<div class="primary-overlay"> | |
<div class="navbar-fixed"> | |
<nav class="transparent"> | |
<div class="container"> | |
<div class="nav-wrapper"> | |
<a href="#home" class="brand-logo">BizLand</a> ******** | |
<a href="#" data-activates="mobile-nav" class="button-collapse"> |
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
a Basic redux setup in a React application covering fundamental steps | |
#1 Create store (using 'redux'), we will pass the root reducer in here later (root reducer contains all other reducers) | |
#2 Wrap App root element in Provider (from 'react-redux') | |
#3 Create a root reducer file with reducer function with args of state & action and returning state. define init state | |
at top of file and feed as state arg | |
- We can create multiple reducers for different parts of our app to handle their own set of actions and then combine these reducers into one Root Reducer and pass it into the store. | |
- We can make reducers in their own files, then in the rootReducer file -> use the combineReducers method from 'redux' to combine all the reducers into the rootReducer |
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
We can map things from our Redux stores in App Components: | |
- State | |
- Dispatch |
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
/* We can map things from our Redux stores in App Components: | |
- State | |
- Dispatch | |
----------- */ | |
// reading Redux store state example: | |
const mapStateToProps = (state, ownProps) => { | |
let id = ownProps.match.params.post_id; | |
return { | |
post: state.posts.find(post => post.id === id) |
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
// initState defined beforehand in file or wherever and import it | |
const rootReducer = (state = initState, action) => { | |
if (action.type === 'DELETE_POST') { | |
let newPosts = state.posts.filter(post => action.id !== post.id); | |
return { | |
...state, | |
posts: newPosts | |
}; |
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
handleClick = () => { | |
this.props.deletePost(this.props.post.id); | |
this.props.history.push('/'); // Redirect Action | |
}; |
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
- Components | |
- Virtual DOM | |
- Lifecycle methods | |
- create-react-app | |
- HOCs | |
- Redux and Stores |
OlderNewer