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
/* eslint camelcase: 0 */ | |
import React from 'react'; | |
import compose from 'recompose/compose'; | |
import lifecycle from 'recompose/lifecycle'; | |
import { | |
getCountryNameByCode, | |
getCountryCodeByName, | |
validCountry, | |
} from 'utils'; |
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
import React, { Component } from 'react'; | |
import ReactDOM from 'react-dom'; | |
import { iconYouAreHere, iconPin } from 'icons'; | |
import styles from './styles.css'; | |
const loadScript = src => { | |
const ref = global.document.getElementsByTagName('script')[0]; | |
const script = global.document.createElement('script'); | |
script.src = src; |
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
import React from "react"; | |
import Todo from "./Todo"; | |
import useTodosLoading from "./useTodosLoading"; | |
import React from "react"; | |
const Loader = ({ isLoading, errorMessage, children }) => { | |
if (errorMessage) return <Error errrorMessage={errorMessage} />; | |
if (isLoading) return <Loading />; | |
return children; | |
}; |
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
import React from 'react'; | |
import withState from 'recompose/withState'; | |
import withHandlers from 'recompose/withHandlers'; | |
import compose from 'recompose/compose'; | |
import getContext from 'recompose/getContext'; | |
const withConfig = getContext({ config: React.PropTypes.object }); | |
const withEmailState = withState('email', 'setEmail', ''); | |
const withPasswordState = withState('password', 'setPassword', ''); | |
const withFetchState = withState('fetching', 'setFetching', false); |
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
#!/bin/bash | |
# Author: Joel Nothman | |
usage() { | |
echo Usage: $0 '[-m <commit msg>] <base>' | |
exit 1 | |
} | |
unset base | |
unset message |
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
[...Array(101)].map((_, i) => { | |
const divBy = num => i % num === 0; | |
const w = word => `${i}...${word}`; | |
const output = | |
divBy(5) && divBy(7) && w`fizzbuzz` || | |
divBy(5) && w`fizz` || | |
divBy(7) && w`buzz` || | |
w``; | |
output && console.log(output); | |
}) |
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
/** | |
* Use multiple filters on an array of object | |
* @param {Object[]} arr - the array to filter | |
* example: | |
* [ | |
* {fruit: 'apple', count: 1, id: 123}, | |
* {fruit: 'pear', count: 4, id: 234}, | |
* {fruit: 'orange', count: 4, id: 456} | |
* ] | |
* @param {Object.<Array>} filters - an object with the filter criteria as the property names |
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
import * as t from 'io-ts'; | |
import { PathReporter } from 'io-ts/lib/PathReporter'; | |
import * as tPromise from 'io-ts-promise'; | |
// [io-ts][https://github.com/gcanti/io-ts](https://github.com/gcanti/io-ts) | |
// [Take control of unexpected data at runtime with TypeScript](https://blog.logrocket.com/using-typescript-to-stop-unexpected-data-from-breaking-your-app/) | |
const fetchProduct = () => { | |
return Promise.resolve({ | |
id: '123', |
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
setTimeout(() => console.log('hi'), 1000) | |
setTimeout(() => console.log('hi'), 2000) | |
setTimeout(() => console.log('hi'), 3000) |
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
const asyncify = (generatorFn) => { | |
const myIterator = generatorFn(); | |
// recursive function that continue to feed itself | |
// yielded Promises until there are none left | |
const runNext = ({ value, done }) => { | |
if (done) return; | |
value.then(() => runNext(myIterator.next())) | |
} | |
runNext(myIterator.next()) | |
} |
NewerOlder