Skip to content

Instantly share code, notes, and snippets.

View mrosata's full-sized avatar
🐣

Michael Rosata mrosata

🐣
  • Quincy, MA USA
View GitHub Profile
@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 April 22, 2024 07:16
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");
@mrosata
mrosata / csv_monster.py
Last active February 24, 2017 19:26
Improved CSV File merger/File splitter that I created to help with large amounts of .csv work I've been doing.
"""Created by Michael Rosata
Python 2.7
Merge together .csv files. I'm creating this because I have 30 .csv files which need to be concatenated.
I also have many files which need to be split, so I've added splitting functionality to this as well.
"""
import csv
import sys