Skip to content

Instantly share code, notes, and snippets.

Avatar

Reza Sadr wintorez

View GitHub Profile
View eslintrc.json
{
"parser": "babel-eslint",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"impliedStrict": true,
"experimentalObjectRestSpread": true
}
@wintorez
wintorez / auth.js
Created Apr 20, 2018
redux auth HOCs using redux-auth-wrapper
View auth.js
import { connectedRouterRedirect } from 'redux-auth-wrapper/history4/redirect';
import { routerActions } from 'react-router-redux';
import connectedAuthWrapper from 'redux-auth-wrapper/connectedAuthWrapper';
import locationHelperBuilder from 'redux-auth-wrapper/history4/locationHelper';
const locationHelper = locationHelperBuilder({});
export const requireAuth = connectedRouterRedirect({
redirectPath: '/login',
allowRedirectBack: false,
@wintorez
wintorez / webpack.config.js
Created Dec 8, 2017
Sample webpack.config.js for creating react production bundles
View webpack.config.js
var webpack = require('webpack');
var CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
// Don't attempt to continue if there are any errors.
bail: true,
// We generate sourcemaps in production. This is slow but gives good results.
// You can exclude the *.map files from the build during deployment.
devtool: 'hidden-source-map',
entry: [
@wintorez
wintorez / configureStore
Created Nov 29, 2017
Pick the correct Redux store configuration depending on the environment
View configureStore
if (process.env.NODE_ENV === 'production') {
module.exports = require('./configureStore.prod');
} else {
module.exports = require('./configureStore.dev');
}
@wintorez
wintorez / configureStore.dev.js
Created Nov 29, 2017
My default Redux configureStore file for production environment
View configureStore.dev.js
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import rootReducer from '../reducers';
import { createLogger } from 'redux-logger';
const configureStore = preloadedState => createStore(
rootReducer,
preloadedState,
applyMiddleware(
thunk,
@wintorez
wintorez / configureStore.dev.js
Created Nov 29, 2017
My default Redux configureStore file for development environment
View configureStore.dev.js
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';
import { createLogger } from 'redux-logger';
import rootReducer from '../reducers';
import { composeWithDevTools } from 'redux-devtools-extension';
import reduxUnhandledAction from 'redux-unhandled-action';
const configureStore = (preloadedState) => {
const store = createStore(
rootReducer,
@wintorez
wintorez / polyfills.js
Created Nov 29, 2017
My default polyfills file for React/Redux project
View polyfills.js
// Object.assign() is commonly used with React.
Object.assign = require('object-assign');
// requestAnimationFrame polyfill
require('raf/polyfill');
// console.* polyfill for old browsers
require('console-polyfill');
// smooth scroll support for scrollIntoView
View memoize_react.jsx
import React from 'react';
import memoize from 'lodash/memoize';
const Heading = memoize((props) => (
<div className="heading">
<div className="App-header">
<h2>{props.title}</h2>
</div>
</div>
), (props) => {
@wintorez
wintorez / git_prune.bash
Last active Nov 17, 2017
Delete untracked local git branches
View git_prune.bash
git fetch -p && for branch in `git branch -vv | grep ': gone]' | awk '{print $1}'`; do git branch -D $branch; done
@wintorez
wintorez / hosts
Created Nov 1, 2017
my /etc/hosts file
View hosts
0.0.0.0 assets.adobedtm.com
0.0.0.0 cdn.clicktale.net
0.0.0.0 cdnssl.clicktale.net
0.0.0.0 pagead2.googlesyndication.com
0.0.0.0 tags.crwdcntrl.net
0.0.0.0 c.amazon-adsystem.com
0.0.0.0 pixel.quantserve.com
0.0.0.0 cdn.taboola.com
0.0.0.0 ad.doubleclick.net
0.0.0.0 widget.perfectmarket.com