Skip to content

Instantly share code, notes, and snippets.

View lukewestby's full-sized avatar

Luke Westby lukewestby

View GitHub Profile
@lukewestby
lukewestby / findMidiDevices.js
Created October 11, 2015 20:40
Get MIDI input and output devices from the Web MIDI API by name
function findMidiDevices(name) {
return navigator
.requestMIDIAccess()
.then((midiAccess) => {
let input, output;
midiAccess.inputs.forEach((currentInput) => {
if(currentInput.name === name) input = currentInput;
});
midiAccess.outputs.forEach((currentOutput) => {
if(currentOutput.name === name) output = currentOutput;
import React from 'react';
import { MidiDevice } from 'hypothetical-react-midi';
import { render } from 'react-dom';
function App({ input, output }) {
return (
<MidiDevice input={input} output={output}>
// ...
</MidiDevice>
);
import React from 'react';
import { MidiNote, MidiDevice } from 'hypothetical-react-midi';
import partial from 'lodash.partial';
export default function App({ input, output, noteStates, dispatch }) {
function onMessage(note, { command, velocity }) {
dispatch({
type: 'MESSAGE_RECIEVED',
payload: { command, velocity, note }
@lukewestby
lukewestby / Main.elm
Created June 14, 2016 14:07
Elm hardware demo
module Main exposing (..)
import Time
import Launchpad exposing (Node, button, group, Color, green, red)
type alias Model =
{ color : Color }
@lukewestby
lukewestby / JortSort.elm
Created June 15, 2016 14:57
JortSort Elm Port
module JortSort exposing (jortSort)
jortSort : List comparable -> Bool
jortSort list =
let
-- sort the list
sortedList =
List.sort list
in
-- compare to see if it was originally sorted
@lukewestby
lukewestby / Main.elm
Last active November 23, 2016 19:00
Using Worker to send model and receive messages
port module Main exposing (..)
import Worker
{-| We'll receive messages from the world in the form of strings here -}
port messagesIn : (String -> msg) -> Sub msg
{-| This port will send our counter back out to the world -}
port modelOut : Model -> Cmd msg
@lukewestby
lukewestby / Main.elm
Last active August 5, 2016 23:29
OAuth 1.0a (3-legged flow) with Elm and Node
port module Main exposing (..)
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (..)
type LoginState
= Waiting
#! env/bin/python
import subprocess
import json
from typing import Any, Optional, List, TypeVar, Tuple, Callable, Set
import os
import sys
T = TypeVar('T')
U = TypeVar('U')
@lukewestby
lukewestby / .zshrc
Last active July 3, 2017 22:03 — forked from xfanwu/xxf.zsh-theme
oh-my-zsh theme
export ZSH=/Users/$(whoami)/.oh-my-zsh
ZSH_THEME="luke"
CASE_SENSITIVE="true"
HYPHEN_INSENSITIVE="true"
ENABLE_CORRECTION="true"
COMPLETION_WAITING_DOTS="true"
DISABLE_UNTRACKED_FILES_DIRTY="true"
plugins=(rails git ruby zeus bundler)
@lukewestby
lukewestby / ellie-cla.md
Last active October 10, 2017 15:10
Ellie Contributor License Agreement

Contributor License Agreement

The following terms are used throughout this agreement:

You - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any entity that controls or is controlled by the legal entity, or is under common control with it.

Project - is an umbrella term that refers to any project owned by the Ellie maintainers that serves the operation of https://ellie-app.com.

Contribution - any type of work that is submitted to a Project, including any modifications or additions to existing work.