Skip to content

Instantly share code, notes, and snippets.

View mrosata's full-sized avatar
🦁
Roar

Michael Rosata mrosata

🦁
Roar
  • Quincy, MA USA
View GitHub Profile
@mrosata
mrosata / jsbin-functional-program.js
Created November 16, 2016 04:50
Functional Programming with IO, Maybe, Just, Nothing -- Touch of Reactive
console.clear()
// The Ramda Library functions you need to breathe.
const Maybe = iJustMetYouThisIsCrazyImAMonadSoCallMeMaybe()
const {
map, chain, compose, reduce, filter, prop, curry
} = R
// fromEvent :: Str -> Elem -> Obs
const fromEvent = curry((eventType, elem) => {
return Rx.Observable.fromEvent(elem, eventType)
@mrosata
mrosata / map-exercises.js
Last active November 15, 2016 14:48
These files accompany my "Map Filter Reduce" videos found at https://www.youtube.com/watch?v=qTeeVd8hOFY
console.clear();
/**
* Video: "JavaScript Array superpowers: Map, Filter, Reduce"
* URL: https://www.youtube.com/watch?v=qTeeVd8hOFY
*
* These 2 exercises test your knowledge and use of the map method.
* Remember, mapping creates a new array from an existing array with
* a 1 to 1 relationship in length.
*
* Map :: [a,a,a] -> [b,b,b]
@mrosata
mrosata / presentation-debug-statements.js
Last active October 8, 2016 18:34
Simple pretty logging functions used in my videos to display parts of the program as examples.
"use strict";
var presentationLogger = (function(window, undefined) {
// warn -> Message -> Warning
var warn = function _warning (val) {
console.warn( `%c${val}`, 'color:#ff3c41;font-weight:bold' );
};
// echo :: Message -> Echo message to console italized.
var echo = function _logging (val) {
@mrosata
mrosata / controllers.application.js
Last active August 22, 2016 16:38
Partial Application Get/Set
import Ember from 'ember';
import '../prism';
import getSetDecorator from '../ember-getsetter';
import exampleSlides from '../example-slides';
let {get, set} = getSetDecorator();
let examples = [];
exampleSlides.forEach(function(item) {
examples.push(item);
});
@mrosata
mrosata / ember-getsetter.js
Last active August 20, 2016 12:33
Ember partial getter and setter. A functional style get(this, 'prop') and set(this, 'prop', val) that also supports partial arguments by returning functions when supplied less arguments then required on the first call.
/**
* Ember
* (more functional style) Getter and Setter
*
* setup option 1 (modular):
* const {get, set} = getSetterDecorator();
* setup option 2 (global):
* getSetterDecorator( window );
*/
import Ember from 'ember';
@mrosata
mrosata / content-for-group.js
Created July 29, 2016 19:52 — forked from mrozema/content-for-group.js
Ember 2.0 compatible select box
import Ember from "ember";
export default Ember.Helper.helper(function([content, group, contentGroupKey]) {
return content.filterBy(contentGroupKey, group);
});
@mrosata
mrosata / fp-either-monad.js
Last active October 28, 2024 15:09
Functional JavaScript Monad Classes - (Maybe Just Nothing) - (Either Left Right) (IOMonad) and my type checking utils
import is from './is-util';
/**
* Either Monad class (from Functional Programming in JavaScript)
*/
class Either {
constructor(value) {
this._value = value;
}
get value () {
@mrosata
mrosata / controllers.application.js
Last active June 26, 2016 13:20
Disabled Button Example
import Ember from 'ember';
export default Ember.Controller.extend({
isDisabled: false,
pureBoolean: Em.computed('isDisabled', function() {
return !this.get('isDisabled');
}),
actions: {
makeDisabled() {
@mrosata
mrosata / components.signup-form.js
Created June 22, 2016 13:28
Integration | Component | signup form
import Em from 'ember';
const birthdayRE = /\d{4}-\d{2}-\d{2}/;
export default Em.Component.extend({
classNames: ['col-md-12', 'section-post-comment'],
title: 'Sign-up',
/**
@mrosata
mrosata / twitter-api-call.php
Created February 25, 2016 00:31
A Twitter API Call - Allows clientside to make 3 requests which each return the next query results
<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require '../vendor/autoload.php';
define("OAUTH_ACCESS_TOKEN", "the oauth here ya know");
define("OAUTH_ACCESS_TOKEN_SECRET", "put the secret here");
define("CONSUMER_KEY", "key key key key key key");