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
// ----- Given this shader: | |
vec4 some_noise_fn() { | |
return vec4(1.0, 2.0, 3.0, 4.0); | |
} | |
void main() { | |
return some_noise_fn(); | |
} |
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
# ----- Given this shader | |
vec4 some_noise_fn() { | |
return vec4(1.0, 2.0, 3.0, 4.0); | |
} | |
void main() { | |
return some_noise_fn(); | |
} |
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
export class MyUserForm extends Component { | |
constructor() { | |
this.state = { myFormData: {} }; | |
} | |
render() { | |
const { myFormData } = this.state; | |
return ( | |
<MagicForm onChange={data => this.setState({ myFormData: data })}> |
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 { spy } from 'sinon'; | |
import { shallow } from 'enzyme'; | |
// Utility method to asynchronously wait for component's willMount function to | |
// complete. Requires the componentWillMount method *returns* its async promise | |
// to wait for | |
export const willMount = async unmountedComponent => { | |
// Spy on the willmount method | |
const lifecycleMethod = spy(unmountedComponent.type.prototype, 'componentWillMount'); | |
const wrapper = shallow(unmountedComponent); |
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
query UserWithAvatarWithoutFriend { | |
user(id: '1') { | |
name | |
avatarImage | |
} | |
} | |
query UserWithoutAvatar { | |
user(id: '1') { | |
name |
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 { baseUrl } = config; | |
getEndpoints(baseUrl).then(endpoints => { | |
const data = new Array(endpoints.length); | |
// Update the array as endpoints come in | |
endpoints.map((endpoint, index) => { | |
getEndpointData(endpoint, baseUrl).then(response => { | |
data[index] = {endpoint, response}; | |
this.setState({ data }); | |
}); |
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
class A extends Component { | |
componentDidMount() { | |
const { baseUrl } = config; | |
const data = []; | |
Promise.all(getEndpoints(baseUrl).then(endpoints => { | |
return Promise.all(endpoints.map(endpoint => { | |
return getEndpointData(endpoint, baseUrl).then(response => { | |
return {endpoint, response}; | |
}); | |
})); |
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
// generic ui component | |
class Panel { | |
render() { | |
return <div> | |
<b>{this.props.title}</b> | |
<p>{this.props.body}</p> | |
</div>; | |
} | |
} |
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 newStatus = { ...this.state.status }; // Copy the object | |
newStatus['Downloading the song'][1] = 'Info'; | |
this.setState({status : newStatus }); |
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 { status } = this.state.status; | |
const key = 'Downloading the song'; | |
const downloading = status[key]; | |
const newStatus = { | |
...status, | |
key: [ | |
downloading[0], | |
'Info', | |
...downloading.slice(2) | |
] |