This file contains 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 throttle(fn, threshhold, scope) { | |
threshhold || (threshhold = 250); | |
var last, | |
deferTimer; | |
return function () { | |
var context = scope || this; | |
var now = +new Date, | |
args = arguments; | |
if (last && now < last + threshhold) { |
This file contains 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
/* | |
* Types for React Router V4 | |
* Example Usage: | |
* type PropsT = { | |
* myProp: string, | |
* } & ContextRouterT<{ | |
* routeParam: string, | |
* anotherRouteParam: ?string, | |
* }> | |
*/ |
This file contains 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
git config --global alias.ci 'commit'; | |
git config --global alias.st 'status'; | |
git config --global alias.br 'branch'; | |
git config --global alias.unstage 'reset HEAD --'; | |
git config --global alias.hist 'log --pretty=format:"%h %ad | %s%d [%an]" --graph --date=short'; | |
git config --global alias.type 'cat-file -t'; | |
git config --global alias.dump 'cat-file -p'; | |
git config --global alias.tree 'log --all --graph --decorate --oneline --simplify-by-decoration'; | |
git config --global alias.als 'config --get-regexp alias'; | |
git config --global alias.clog 'log --pretty=oneline --abbrev-commit'; |
This file contains 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
// Returns a function, that, as long as it continues to be invoked, will not | |
// be triggered. The function will be called after it stops being called for | |
// N milliseconds. If `immediate` is passed, trigger the function on the | |
// leading edge, instead of the trailing. | |
function debounce(func, wait, immediate) { | |
var timeout; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; |
This file contains 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
/* General Statement: To convert values to a particular datatype use type coercsion instead of explicit conversion. */ | |
/* To Number */ | |
var val = "123"; | |
// 1. using Exclusing Type conversion. | |
console.log(Number(val)); | |
// 2. using Type Coercion (unary plus operator) | |
console.log(+val); | |
// among these methods the Type Coercion is fast. (http://jsperf.com/number-vs-unary-plus) |
This file contains 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
/* defintion */ | |
const createErrorClass = (name, customConstructor = () => {}) => { | |
const ctx = { | |
[name]: class extends Error { | |
constructor(...args) { | |
super(name); | |
customConstructor(this, ...args); | |
Error.captureStackTrace(this, ctx[name]); | |
} | |
} |
This file contains 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
// Available variables: | |
// - Machine | |
// - interpret | |
// - assign | |
// - send | |
// - sendParent | |
// - spawn | |
// - raise | |
// - actions |
This file contains 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 SimpleTextInput extend Component { | |
state = { | |
value: this.props.value, | |
}; | |
componentWillReceiveProps(nextProps) { | |
if (this.props.value !== nextProps.value) { | |
this.setState({value: nextProps.value}); | |
} | |
} | |
render() { |
This file contains 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
_.mixin({ | |
enzyme: reactWrapper => ( | |
new Proxy(reactWrapper, { | |
get: (wrapper, prop) => { | |
const isSymbol = typeof prop === 'symbol'; | |
const isNumber = !isSymbol && !isNaN(Number(prop)); | |
return isNumber ? wrapper.at(prop) : wrapper[prop]; | |
}, | |
}) |
This file contains 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
// AppContainer.js | |
import {withRefreshedStore} from 'react-store-manager'; | |
const HomeRoute = Loadable({ | |
loader: withRefreshedStore(import('./HomePageContainer')), | |
loading: () => <div>Loading...</div> | |
}); | |
const ProductListRoute = Loadable({ | |
loader: withRefreshedStore(import('./ProductListPageContainer')), |
NewerOlder