Skip to content

Instantly share code, notes, and snippets.

View charly-palencia's full-sized avatar

charly palencia charly-palencia

View GitHub Profile
export default function fetchAPI(options, dispatch) {
const {types, url, payload = {}, headers = {}, method, body} = options;
const defaultHeaders = {
// Accept: "application/vnd.api+json",
// "Content-Type": "application/json",
};
const authenticationHeader = {
Plugin 'challenger-deep-theme/vim', { 'as': 'challenger-deep' }
Plugin 'ryanoasis/vim-devicons'
Plugin 'sheerun/vim-polyglot'
Plugin 'itchyny/lightline.vim'
Plugin 'janko-m/vim-test'
Plugin 'tell-k/vim-autopep8'
Plugin 'benmills/vimux'
Plugin 'matze/vim-move'
Plugin 'rhysd/vim-grammarous'
set encoding=UTF-8
colorscheme challenger_deep
set clipboard=unnamed
" set spell spelllang=en_us
" set exrc
let g:autopep8_disable_show_diff=1
@charly-palencia
charly-palencia / basic example.js
Created November 29, 2019 20:36
JS Template Literals: Tagged templates
const styled;
const myTag = (strings, ...args) => {
const emojiFruits= {
"bannana": "🍌",
"pear": "🍎",
"apple": "🍐",
};
// input: ["Let's make some mix juice with ", ' in the ', '' ]
const [str0, str1] = strings;
import React from "react";
import logo from "./logo.svg";
import { AppContainer, Logo, Header, StyledLink } from "./components";
function App({ fetchColor, color }) {
return (
<AppContainer>
<Header color={color} onClick={fetchColor}>
<Logo src={logo} alt="logo" />
import React from "react";
import { connect } from "react-redux";
...
import {fetchColor} from "./actions";
...
function App({fetchColor, color}) {
return (
<AppContainer>
import { combineReducers } from "redux";
import { connectRouter } from "connected-react-router";
import history from "../history";
import color from "reducers/color";
export default combineReducers({
color,
router: connectRouter(history),
});
import {
UPDATE_COLOR,
} from "../actionTypes";
const initialState = {
color: "#282c34",
}
export default function authReducer(
state = initialState,
{type, color}
) {
import { UPDATE_COLOR } from "../actionTypes";
const successFetchColor = (colorResponse) => {
return {
type: UPDATE_COLOR,
color: `#${colorResponse["new_color"]}`
};
}
export const fetchColor = () => (
dispatch => {
fetch("http://www.colr.org/json/color/random")
import React from "react";
import ReactDOM from "react-dom";
import { ConnectedRouter } from "connected-react-router";
import { Provider } from "react-redux";
import "redux-thunk";
import "@csstools/normalize.css";
import "reset-css";
import App from "./App";
import store from "./store";
import history from "./history";