Skip to content

Instantly share code, notes, and snippets.

View markodayan's full-sized avatar
🍑

Mark Odayan markodayan

🍑
View GitHub Profile
// @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' });
@markodayan
markodayan / rot13.py
Created November 4, 2019 13:15
Rot13 Encoder
#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")
@markodayan
markodayan / index.html
Created January 9, 2020 10:34
Materialize Header Navbar Template (With Sass)
<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>
@markodayan
markodayan / index.html
Last active January 9, 2020 15:28
Scrollspy Implementation
<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">
@markodayan
markodayan / reduxSetup.txt
Last active February 20, 2022 07:52
Redux setup and explanations (General and React setup)
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
@markodayan
markodayan / redux-info.txt
Created February 14, 2020 13:22
Some Information around Redux Store Containers
We can map things from our Redux stores in App Components:
- State
- Dispatch
@markodayan
markodayan / redux-info.js
Last active February 14, 2020 13:36
Some Information around Redux Store Containers
/* 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)
@markodayan
markodayan / rootReducer.js
Created February 14, 2020 13:39
Basic Reducer Functionality (Dispatching Actions sent from components)
// 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
};
@markodayan
markodayan / redirect.js
Created February 14, 2020 13:41
Redirecting to URL using props.history
handleClick = () => {
this.props.deletePost(this.props.post.id);
this.props.history.push('/'); // Redirect Action
};
@markodayan
markodayan / react-fundamentals
Created February 14, 2020 13:50
Key React Principles
- Components
- Virtual DOM
- Lifecycle methods
- create-react-app
- HOCs
- Redux and Stores