Skip to content

Instantly share code, notes, and snippets.

View alexcastillo's full-sized avatar
💭
Building an API to the brain

Alex Castillo alexcastillo

💭
Building an API to the brain
View GitHub Profile
@conorhastings
conorhastings / state-component.js
Last active March 30, 2017 20:36
you can enact most of the behavior of redux with a simple component
/* this lacks subscribe behavior or ability to dispatch from outside of component tree but that is generally not neccesary */
class State extends React.Component {
constructor(props) {
super(props);
this.state = YOUR_INITIAL_STATE;
}
reducer = (action, state, props) => {...newState};
/* setState takes an object of new state as first arg or a function of props and state that returns new state
* which we will use here
* we pass dispatch around and use it similarly to redux dispatch
@marcgg
marcgg / notevalues.json
Created November 1, 2016 10:56
note frequency value
var noteValues = {
'C0': 16.35,
'C#0': 17.32,
'Db0': 17.32,
'D0': 18.35,
'D#0': 19.45,
'Eb0': 19.45,
'E0': 20.60,
'F0': 21.83,
'F#0': 23.12,
@alexcastillo
alexcastillo / angular-hack.js
Last active March 3, 2016 02:10
Hacking AngularJS in oder to broadcast a custom event for directives
/**
* AngularJS hack - This way we can get and decorate all custom directives
* in order to broadcast a custom directive events: $directiveAdd
**/
// This is where all the custom directives will be stored
var $directives = [];
var originalModule = angular.module;
angular.module = function () {
var module = originalModule.apply(this, arguments);
var originalDirective = module.directive;