Tested under webpack-dev-server 1.7.0.
- Clone this gist
npm install
npm start
- Visit http://localhost:8080 (or http://192.168.x.x:8080) on multiple devices
- Edit entry.js and hit save
import React, {Component} from 'react' | |
export default DecoratedComponent => | |
class extends Component { | |
state = { | |
hover: false, | |
} | |
toggleHover = () => | |
this.setState({hover: !this.state.hover}) | |
render() { |
Tested under webpack-dev-server 1.7.0.
npm install
npm start
const readFile = (file) => { | |
let reader = new global.FileReader(); | |
return new Promise((resolve, reject) => { | |
reader.onload = (event) => { | |
file.data = event.target. result; | |
resolve(file); | |
}; | |
reader.onerror = () => { |
const Button = forwardRef<CoralButton, ButtonProps>((props, ref) => { | |
const { children, onClick, title, ...coralButtonProps } = props; | |
const buttonRef = useRef<CoralButton>(null); | |
useLayoutEffect(() => { | |
if (ref) { | |
if (isFunction(ref)) { | |
ref(buttonRef.current); | |
} else { |
const crypto = require('crypto') | |
const { promisify } = require('util') | |
const pbkdf2 = promisify(crypto.pbkdf2) | |
module.exports = { createHashPasswordFn, isPasswordCorrect } | |
/** | |
* @typedef {Object} HashPassword | |
* @property {String} hash | |
* @property {String} salt |
function youtubeDurationToSeconds(duration) { | |
var hours = 0; | |
var minutes = 0; | |
var seconds = 0; | |
// Remove PT from string ref: https://developers.google.com/youtube/v3/docs/videos#contentDetails.duration | |
duration = duration.replace('PT',''); | |
// If the string contains hours parse it and remove it from our duration string | |
if (duration.indexOf('H') > -1) { |
import { useState, useCallback, useRef } from "react"; | |
// Usage | |
function App() { | |
const [hoverRef, isHovered] = useHover(); | |
return ( | |
<div ref={hoverRef}> | |
{isHovered ? '😁' : '☹️'} | |
</div> |
@relayRoot | |
@relayContainer({ | |
client: () => Relay.QL` | |
fragment on Client { | |
id, | |
menuitems(first: 50) { | |
} | |
} | |
` | |
}) |
Interesting part (unmounting & API) is at the end if you're not interested in the rest =).
This animation proposal is just an attempt. In case it doesn't work out, I've gathered a few examples that can test the power of a future animation system.
Parent is an infinitely spinning ball, and has a child ball that is also spinning. Clicking on the parent causes child to reverse spinning direction. This tests the ability of the animation system to compose animation, not in the sense of applying multiple interpolations to one or more variables passed onto the child (this should be trivial), but in the sense that the parent's constantly updating at the same time as the child, and has to ensure that it passes the animation commands correctly to it. This also tests that we can still intercept these animations (the clicking) and immediately change their configuration instead of queueing them.
Typing letters and let them fly in concurrently. This tests concurrency, coordination of an array of ch
import requests | |
import base64 | |
from tqdm import tqdm | |
master_json_url = 'https://178skyfiregce-a.akamaihd.net/exp=1474107106~acl=%2F142089577%2F%2A~hmac=0d9becc441fc5385462d53bf59cf019c0184690862f49b414e9a2f1c5bafbe0d/142089577/video/426274424,426274425,426274423,426274422/master.json?base64_init=1' | |
base_url = master_json_url[:master_json_url.rfind('/', 0, -26) + 1] | |
resp = requests.get(master_json_url) | |
content = resp.json() |