Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
https://leanpub.com/composingsoftware

Eric Elliott ericelliott

💭
https://leanpub.com/composingsoftware
View GitHub Profile
@ericelliott
ericelliott / promise-monad-proof.js
Created Jun 28, 2017 — forked from briancavalier/promise-monad-proof.js
A proof that Promises/A is a Monad
View promise-monad-proof.js
//-------------------------------------------------------------
//
// Hypothesis:
//
// Promises/A is a Monad
//
// To be a Monad, it must provide at least:
// - A unit (aka return or mreturn) operation that creates a corresponding
// monadic value from a non-monadic value.
// - A bind operation that applies a function to a monadic value
@ericelliott
ericelliott / extend.js
Created Sep 6, 2012 — forked from gkatsev/extend.js
A simple and naive extend implementation
View extend.js
function extend(obj) {
var args = [].slice.call(arguments, 1);
args.forEach(function (source) {
var prop;
for (prop in source) {
if (source.hasOwnProperty(prop)) {
obj[prop] = source[prop];
}
}
});
@ericelliott
ericelliott / jsonp.js
Created Dec 15, 2011
//The U.S. President's latest tweet... var obamaTweets = "http://www.twitter.com/status/user_timeline/BARACKOBAMA.json?count=5&callback=JSONPCallback"; jsonp.fetch(obamaTweets, function(data) {console.log(data[0].text)}); /* console logs: From the O
View jsonp.js
var jsonp = {
callbackCounter: 0,
fetch: function(url, callback) {
var fn = 'JSONPCallback_' + this.callbackCounter++;
window[fn] = this.evalJSONP(callback);
url = url.replace('=JSONPCallback', '=' + fn);
var scriptTag = document.createElement('SCRIPT');
scriptTag.src = url;
You can’t perform that action at this time.