In your command-line run the following commands:
brew doctor
brew update
<!DOCTYPE HTML> | |
<html lang="en"> | |
<head> | |
<style> | |
.dot { | |
background-color: red; | |
border-radius: 50%; | |
width: 20px; | |
height: 20px; | |
display: block; |
/** | |
Using input object type for mutations | |
**/ | |
type Mutation { | |
register(input : createPersonInput!):RegisterUserResponse! | |
} | |
input createPersonInput{ | |
name: String! |
// Method 1: | |
class Parent extends Component { | |
state = { foo: '', bar: '', buzz: '' } | |
render() { | |
return ( | |
<Child | |
setParentState={this.setState} | |
> | |
) |
In your command-line run the following commands:
brew doctor
brew update
import React from 'react'; | |
export default class CheckboxWithLabel extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = {isChecked: false}; | |
// bind manually because React class components don't auto-bind | |
// http://facebook.github.io/react/blog/2015/01/27/react-v0.13.0-beta-1.html#autobinding | |
this.onChange = this.onChange.bind(this); |
const response = await fetch(`https://catappapi.herokuapp.com/users/${userId}`) | |
const data = await response.json() | |
return data.imageUrl | |
} |
/** | |
* Retries a function that returns a promise a given number of times and backs | |
* off each attempt exponentially. | |
* | |
* @param {Function} promiseGenerator The function to retry. | |
* @param {number} [attempts=5] Number of attempts to make. | |
* @param {number} [delay=1000] Initial delay between attempts in ms. | |
* @return {Promise} | |
*/ | |
function attemptWithRetry(promiseGenerator, attempts = 5, delay = 100) { |
The following are examples of the four types rate limiters discussed in the accompanying blog post. In the examples below I've used pseudocode-like Ruby, so if you're unfamiliar with Ruby you should be able to easily translate this approach to other languages. Complete examples in Ruby are also provided later in this gist.
In most cases you'll want all these examples to be classes, but I've used simple functions here to keep the code samples brief.
This uses a basic token bucket algorithm and relies on the fact that Redis scripts execute atomically. No other operations can run between fetching the count and writing the new count.
Just migrated it from Codepen.io to markdown. Credit goes to David Conner.
Working with DOM | Working with JS | Working With Functions |
---|---|---|
Accessing Dom Elements | Add/Remove Array Item | Add Default Arguments to Function |
Grab Children/Parent Node(s) | Add/Remove Object Properties | Throttle/Debounce Functions |
Create DOM Elements | Conditionals |