Skip to content

Instantly share code, notes, and snippets.

@mtomcal
mtomcal / index.js
Last active August 29, 2015 14:13
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Rebuild to run it on the right
var _ = require('highland');
var B = require('bluebird');
var asyncArray = [];
function generator() {
var randNum = Math.ceil(Math.random() * 10);
var randTime = Math.ceil(Math.random() * 100);
//Earlier
var H = require('highland');
//Later
/**
* Wrapper for fs.watch
* @param path
* @returns {*}
*/
//Earlier
var B = require('bluebird');
//Later
/**
* Promise wrapper for fs.watch
* @param path
* @returns {*}
*/
@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;
@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 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 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 / 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 / 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