Load data on client and server:
async function * MyComponent() {
yield (<div>Loading...</div>);
const users = await fetch('/users');
yield () =>
<div>
<UserList users={users} />
{this.props.buttonLabel}| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"/> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"/> | |
| <title>Webpack Bundle Analyzer</title> | |
| <!-- viewer.js --> | |
| <script> |
| /* | |
| * Example how to preload HTML5 video on the iPad (iOS 3.2+) | |
| * @author Miller Medeiros | |
| * Released under WTFPL | |
| */ | |
| var vid = document.createElement('video'); | |
| vid.src = 'lol_catz.mp4'; | |
| document.getElementById('video-holder').appendChild(vid); |
| class Button extends Component { | |
| @css` | |
| background-color: #ff0000; | |
| width: 320px; | |
| padding: 20px; | |
| border-radius: 5px; | |
| border: none; | |
| outline: none; | |
| &:hover { |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"/> | |
| <title>For loop benchmark</title> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script> | |
| <script src="./suite.js"></script> | |
| </head> | |
| <body> | |
| <h1>Open the console to view the results</h1> |
| const React = require("react"); | |
| const Lifecycles = React.createLifecycleEvents({ | |
| didMount({ setState }) { | |
| setState({ | |
| disabled: false, | |
| }); | |
| }, | |
| didUpdate({ inputRef }) { | |
| if (document.activeElement !== inputRef.value) { |
Load data on client and server:
async function * MyComponent() {
yield (<div>Loading...</div>);
const users = await fetch('/users');
yield () =>
<div>
<UserList users={users} />
{this.props.buttonLabel}PubSub class like this:
class PubSub {
constructor () {
this.el = document.createElement('div');
}
subscribe (eventName, handler) {
this.el.addEventListener(eventName, handler);Smallest possible CSS-in-JS library.
| # Stop PostgreSQL from auto starting | |
| sudo launchctl unload -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist | |
| # Enable PostgreSQL to auto start | |
| sudo launchctl load -w /Library/LaunchDaemons/com.edb.launchd.postgresql-9.3.plist | |
| # Start postgres | |
| $ sudo su postgres | |
| Password: | |
| bash-3.2$ pg_ctl -D /Library/PostgreSQL/9.3/data/ start |
Specify required fields, rest will be optional.
export type Required<T, K extends keyof T> = Partial<T> & Pick<T, K>;Specify which fields to omit.
export type Omit = Pick>;