Skip to content

Instantly share code, notes, and snippets.

@mtomcal
mtomcal / cloudSettings
Last active November 7, 2017 21:21
Visual Studio Code Settings Sync Gist
{"lastUpload":"2017-11-07T21:21:29.582Z","extensionVersion":"v2.8.5"}
@mtomcal
mtomcal / HigherOrderComponents.jsx
Created September 14, 2017 22:13
Adapting HoC to RenderProps
////////////////////////////////////////////////////////////////////////////////
// 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 September 7, 2017 23:22
Select Controlled Compound Component
import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
import './styles.css'
const { func, any } = PropTypes
////////////////////////////////////////////////////////////////////////////////
// Requirements
@mtomcal
mtomcal / blockPropTypes.js
Created June 5, 2017 18:50
Block Prop Types
{
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 May 1, 2023 01:59
More gulpfile fun WIP
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 February 2, 2015 18:58
requirebin sketch
// 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 February 18, 2016 01:24
Great React + Browserify Gulpfile
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 January 23, 2015 18:56
requirebin sketch
// 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;
//Earlier
var B = require('bluebird');
//Later
/**
* Promise wrapper for fs.watch
* @param path
* @returns {*}
*/
//Earlier
var H = require('highland');
//Later
/**
* Wrapper for fs.watch
* @param path
* @returns {*}
*/