Skip to content

Instantly share code, notes, and snippets.

Avatar

Michael A Tomcal mtomcal

View GitHub Profile
@mtomcal
mtomcal / cloudSettings
Last active Nov 7, 2017
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2017-11-07T21:21:29.582Z","extensionVersion":"v2.8.5"}
@mtomcal
mtomcal / HigherOrderComponents.jsx
Created Sep 14, 2017
Adapting HoC to RenderProps
View HigherOrderComponents.jsx
////////////////////////////////////////////////////////////////////////////////
// Exercise:
//
// Make `withMouse` a "higher-order component" that sends the mouse position
// to the component as props.
//
// Hint: use `event.clientX` and `event.clientY`
//
// Got extra time?
//
@mtomcal
mtomcal / Select.js
Created Sep 7, 2017
Select Controlled Compound Component
View Select.js
import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
import './styles.css'
const { func, any } = PropTypes
////////////////////////////////////////////////////////////////////////////////
// Requirements
View blockPropTypes.js
{
const { string, object, arrayOf, func } = PropTypes;
Component.propTypes = {
value: string,
starships: arrayOf(object).isRequired,
name: string,
onChange: func.isRequired,
};
}
@mtomcal
mtomcal / Gulpfile.js
Last active Sep 22, 2015
More gulpfile fun WIP
View Gulpfile.js
var gulp = require('gulp');
var streamify = require('gulp-streamify');
var uglify = require('gulp-uglify');
var notify = require('gulp-notify');
var gutil = require('gulp-util');
var less = require('gulp-less');
var rename = require('gulp-rename');
var nodemon = require('gulp-nodemon');
var jshint = require('gulp-jshint');
var react = require('gulp-react');
@mtomcal
mtomcal / index.js
Created Feb 2, 2015
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var B = require('bluebird');
function throwError() {
var deferred = B.defer();
if (true) {
return B.reject(new Error('Exception'));
}
(function () {
@mtomcal
mtomcal / gulpfile.js
Last active Feb 18, 2016
Great React + Browserify Gulpfile
View gulpfile.js
var gulp = require('gulp');
var browserify = require('browserify');
var watchify = require('watchify');
var streamify = require('gulp-streamify');
var cssMin = require('gulp-css');
var uglify = require('gulp-uglify');
var notify = require('gulp-notify');
var to5ify = require('6to5ify');
var source = require('vinyl-source-stream');
var webserver = require('gulp-webserver');
@mtomcal
mtomcal / index.js
Created Jan 23, 2015
requirebin sketch
View index.js
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var B = require('bluebird');
function throwError() {
var deferred = B.defer();
(function () {
throw new Error('Exception');
})()
return deferred.promise;
View bluebird_example_1.js
//Earlier
var B = require('bluebird');
//Later
/**
* Promise wrapper for fs.watch
* @param path
* @returns {*}
*/
View highland_example_1.js
//Earlier
var H = require('highland');
//Later
/**
* Wrapper for fs.watch
* @param path
* @returns {*}
*/
You can’t perform that action at this time.