Skip to content

Instantly share code, notes, and snippets.

Cory House coryhouse

Block or report user

Report or block coryhouse

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
coryhouse / cloudSettings
Last active Jul 1, 2018
Visual Studio Code Settings Sync Gist
View cloudSettings
View gist:22ce129d5b2fe8f878f2759ca7c5b9e9
"JavaScript languished from 2009 - 2015 without a single release. But in 2015, rapid innovation became the new normal. JavaScript and its technical committee, the TC39, has committed to annual releases every June, as well as the assurance of ongoing backward compatibility. Innovative projects like Babel mean you need not wait for these features to be broadly supported to put them to use. You can transpile experimental features and use them today. If plain JavaScript isn't to your team's taste, there are literally dozens of mature languages that compile down to JavaScript today such as TypeScript from Microsoft.
JavaScript's de facto package manager, npm, is the largest and fastest growing package manager in the world. There are over half a million packages in npm today. Thanks to innovative projects like Node.js, Electron, and React Native, you can write web apps, native mobile apps, web APIs, server-side processes, and even desktop apps using JavaScript. They say software is eating the world. For all these
coryhouse / userApi.js
Last active Mar 9, 2019
API Wrapper example
View userApi.js
/* This API wrapper is useful because it:
1. Centralizes our Axios default configuration.
2. Abstracts away the logic for determining the baseURL.
3. Provides a clear, easily consumable list of JavaScript functions
for interacting with the API. This keeps API calls short and consistent.
import axios from 'axios';
let api = null;
View UserDetails.js
UserDetails.propTypes = {
user: PropTypes.shape({
id: PropTypes.number.isRequired,
firstName: PropTypes.string.isRequired,
lastName: PropTypes.string.isRequired,
role: PropTypes.oneOf(['user','admin'])
coryhouse / UserDetails.js
Last active Jul 1, 2018
UserDetails component consuming a centralized PropType
View UserDetails.js
import React from 'react';
import {userType} from './types';
function User({ user }) {
return (
<h1>{user.firstName} {user.lastName}</h1>
coryhouse / index.js
Last active Nov 17, 2017
Centralized propTypes declaration
View index.js
// types/index.js
import { shape, number, string, oneOf } from 'prop-types';
export const userType = shape({
id: number,
firstName: string.isRequired,
lastName: string.isRequired,
company: string,
role: oneOf(['user', 'author']),
address: shape({
View propTypeWithShape.js
MyComponent.PropTypes = {
customer: PropTypes.shape({
id: PropTypes.number,
firstName: PropTypes.string.isRequired,
middleName: PropTypes.string.isRequired,
lastName: PropTypes.string.isRequired
coryhouse / CustomerInfo.js
Created Oct 26, 2017
Example of consuming a centralized propType
View CustomerInfo.js
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import {Customer} from '../../../propTypes';
function CustomerInfo({customer}) {
return (
coryhouse / propTypes.js
Created Oct 26, 2017
Example of centralizing propTypes
View propTypes.js
// You could centralize all your object shape definitions here
import PropTypes from 'prop-types';
export const Customer = PropTypes.shape({
id: PropTypes.number,
photo: PropTypes.string.isRequired,
firstName: PropTypes.string.isRequired,
middleName: PropTypes.string.isRequired,
lastName: PropTypes.string.isRequired,
isCompany: PropTypes.bool.isRequired,
coryhouse / callback.js
Last active Oct 15, 2017
Callback example
View callback.js
getPosts(function(error, posts) {
if (error) {
} else {
function getPosts(callback) {
const xhr = new XMLHttpRequest();
You can’t perform that action at this time.