Skip to content

Instantly share code, notes, and snippets.

View iamdustan's full-sized avatar

Dustan Kasten iamdustan

View GitHub Profile
/** @flow */
declare type ExampleTuple = [string, string, string];
function concat(ex:ExampleTuple): string {
return ex.join(' ');
}
concat(['hello', 'world', 'golly']);
@iamdustan
iamdustan / button.js
Last active August 29, 2015 14:27
Random demos to test react-hardware against Johnny-5
var five = require('johnny-five');
var board = new five.Board();
board.on('ready', function() {
var led = new five.Led(13);
var button = new five.Button(2);
// "down" the button is pressed
button.on("down", function() {
led.on();
waitsFor(_ => shoddyAsync, 'Jasmine Async sucks', 1000);
/** @flow */
import React from '../ReactHardware';
import Board from '../components/Board';
const pinMapping = {
'A0': 14,
'A1': 15,
'A2': 16,
'A3': 17,
/* @flow weak */
var AppDispatcher = require('./Dispatcher');
var Constants = require('./Constants');
var find = require('../utils/find');
var __APP_SERVER__ = 'http://localhost:3500';
var Cache = {};
var Actions = {
/** @flow */
require('./styles.css')
var React = require('react');
var PureRenderMixin = require('react/lib/ReactComponentWithPureRenderMixin');
var {PropTypes} = React;
var {Link} = require('react-router');
var shape = function(props) {
var express = require('express');
var app = express();
app.use('/api', require('../api'));
app.get('*', function(req, res) {
var resolver = Resolver.create();
var router = Router.create({
routes: resolver.route(routes),
location: req.url,
@iamdustan
iamdustan / Button.js
Last active August 29, 2015 14:21
Some react-hardware internals.
import React from 'react';
import createReactHardwareComponentClass from '../createReactHardwareComponentClass';
import modes from './inputModes';
import HardwareManager from '../HardwareManager';
import ReactHardwareEventEmitter from '../ReactHardwareEventEmitter';
import findNodeHandle from '../findNodeHandle';
var {PropTypes} = React;
var DOWN_EVENT = 'topDown';
var UP_EVENT = 'topUp';
/*eslint-disable*/
require('./JSPolyfills');
/*eslint-enable*/
import EventPluginHub from 'react/lib/EventPluginHub';
import EventPluginUtils from 'react/lib/EventPluginUtils';
import HardwareDefaultEventPluginOrder from './HardwareDefaultEventPluginOrder';
import HardwareBridgeEventPlugin from './HardwareBridgeEventPlugin';
import ReactClass from 'react/lib/ReactClass';
import ReactComponentEnvironment from 'react/lib/ReactComponentEnvironment';
/*eslint no-console:0*/
import React from '../';
const {
Board,
Button,
Led,
} = React;
const HIGH = 255;