Skip to content

Instantly share code, notes, and snippets.

View mariosanchez's full-sized avatar

Mario Sánchez mariosanchez

View GitHub Profile
@mariosanchez
mariosanchez / parallel-fetch.js
Created April 13, 2020 07:59 — forked from ericelliott/parallel-fetch.js
Parallel requests example
// setup
const wait = value => new Promise(resolve => {
setTimeout(() => resolve(value), 3000);
});
const fetchFoo = () => wait('foo');
const fetchBar = () => wait('bar');
const fetchBaz = () => wait('baz');
const fetchDataSlowly = async time => {
// ensure the keys being passed is an array of key paths
// example: 'a.b' becomes ['a', 'b'] unless it was already ['a', 'b']
const keys = ks => Array.isArray(ks) ? ks : ks.split('.')
// traverse the set of keys left to right,
// returning the current value in each iteration.
// if at any point the value for the current key does not exist,
// return the default value
const deepGet = (o, kp, d) => keys(kp).reduce((o, k) => o && o[k] || d, o)
@mariosanchez
mariosanchez / react.md
Last active October 27, 2017 12:17 — forked from monicao/react.md
React Lifecycle Cheatsheet

React Component Lifecycle

  • getInitialState
  • getDefaultProps
  • componentWillMount
  • componentDidMount
  • shouldComponentUpdate (Update only)
  • componentWillUpdate (Update only)
  • componentWillReceiveProps (Update only)
  • render
@mariosanchez
mariosanchez / git_aliases.txt
Last active December 27, 2018 15:17 — forked from jaumecapdevila/git_aliases.txt
Basic git aliases and configs
[user]
email = <your email>
name = <yout name>
[alias]
ci = commit
st = status
s = status
a = !git add -A && git status
co = checkout