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
# look for an .editorconfig file inside this project | |
root = true | |
[*] | |
charset = utf-8 | |
end_of_line = lf | |
indent_size = 2 | |
indent_style = space | |
# while saving | |
insert_final_newline = true |
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
https://github.com | |
https://codesandbox.io | |
https://codepen.io | |
https://medium.com | |
https://codementor.io | |
https://reddit.com | |
https://egghead.io | |
https://freecodecamp.com | |
https://facebook.github.io | |
https://www.vuemastery.com |
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' | |
export default function withRouter(WrappedComponent) { | |
const WithRouter = ({router}) => { | |
if (!router) { | |
return <WrappedComponent {...this.props} /> | |
} | |
const { params, location, routes } = router | |
const props = { ...this.props, router, params, location, routes } | |
return <WrappedComponent {...props} /> |
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 Loadable from 'react-loadable'; | |
const A = Loadable({ | |
loader: () => import('../A' /* webpackChunkName: "pc-r-A" */), | |
loading: () => null, | |
}); | |
const B = Loadable({ | |
loader: () => import('../B' /* webpackChunkName: "pc-r-B" */), | |
loading: () => 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
from collections import namedtuple | |
from math import sqrt | |
import random | |
from PIL import Image | |
Point = namedtuple('Point', ('coords', 'n', 'ct')) | |
Cluster = namedtuple('Cluster', ('points', 'center', 'n')) | |
def get_points(img): | |
points = [] |
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
from PIL import Image, ImageDraw | |
def get_colors(infile, outfile, resize=150): | |
image = Image.open(infile) | |
im = image.resize((resize, resize)) | |
im.save(outfile, "JPEG") | |
if __name__ == '__main__': | |
get_colors('abc.jpeg', 'outfile.jpeg') |
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
let TransformStreamPromise = Promise.resolve() | |
.then(() => { | |
if ('TransformStream' in self) { | |
return TransformStream; | |
} | |
const { TransformStream } = await import('./some-polyfill.js'); | |
return TransformStream; | |
}); | |
(async function () { |
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
// getComponent is a function that returns a promise for a component | |
// It will not be called until the first mount | |
function asyncComponent(getComponent) { | |
return class AsyncComponent extends React.Component { | |
static Component = null; | |
state = { Component: AsyncComponent.Component }; | |
componentWillMount() { | |
if (!this.state.Component) { | |
getComponent().then(Component => { |
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 withConnectionType(WrappedComponent, respondToChange = false) { | |
return class extends React.Component { | |
constructor(props) { | |
super(props) | |
this.state = { | |
connectionType: undefined | |
} | |
// Basic API Support Check. | |
this.hasNetworkInfoSupport = Boolean( | |
navigator.connection && navigator.connection.effectiveType |
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
// @flow | |
import React, { PureComponent } from 'react'; | |
import GalleryBoxWithIntersection from './GalleryBoxWithIntersection'; | |
import GalleryBoxWithoutIntersection from './GalleryBoxWithoutIntersection'; | |
type Image = { | |
url: string, | |
height: number, | |
width: number, |
OlderNewer