(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
/** | |
* vainilla js simple slider | |
* source: http://cssdeck.com/labs/image-slider-1 | |
*/ | |
/** | |
css: | |
.image-slider-wrapper{ | |
overflow: hidden; | |
} |
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import datetime | |
import sys | |
def compare(dates): | |
if len(dates) < 2: |
function _noop() {} | |
function _constant(v) { return function() { return v; }; } | |
/** | |
* intercept <form> and submit it via XHR | |
* @param {String} formSelector | |
* @param {Function} successCallback | |
* @param {Function} errorCallback | |
* @param {Function} beforeSubmit | |
*/ |
/** | |
* Prefixes each array element with given | |
* @param {String} prefix | |
* @usage e.g var pfixed = ["one", "two", "three"].prefixEach("number: "); | |
*/ | |
Array.prototype.prefixEach = function(prefix) { | |
return this.map(_ary(String.prototype.concat.bind(prefix))); | |
}; | |
function _ary(fn, arity) { |
/** | |
* replaces variables in element innerHTML, e.g. | |
* DOM: <span id="fillMe">hey {{#}}, whats up {{#}}</span> | |
* Code: document.querySelector('#fillMe').fillWith('bro') | |
* Output: hey bro, whats up bro | |
* | |
* DOM: <span id="fillMe">the {{animal}} is sitting at the {{forniture}}</span> | |
* Code: document.querySelector('#fillMe').fillWith({'animal': 'cat', 'forniture': 'table'}); | |
* Output: the cat is sitting at the table | |
*/ |
function getData(uri, done, evt) { | |
var request = new XMLHttpRequest(); | |
request.open('GET', uri); | |
request.onreadystatechange = function() { | |
if(! (request.readyState == 4 && request.status === 200)) { | |
return; | |
} | |
return done(request); |
// both answers copied from challange posted at e-mail list of my former job | |
// not-so oneliner | |
var compose = function () { | |
var composableFunctions = Array.prototype.slice.call(arguments).reverse(); | |
return (x) => composableFunctions.reduce((result, composable) => composable(result), x); | |
/* | |
ES5: | |
return function(x) { | |
return composableFunctions.reduce(function(result, composable) { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Table of Contents generated with DocToc
// requires jQuery! | |
const noop = () => {}; | |
const constant = v => () => v; | |
const beTrue = constant(true); // () => true; | |
function $Ajaxify(form, ...callbacks) { | |
if (typeof callbacks[0] === 'object') { | |
var { | |
onSuccess = noop, onError = noop, beforeSend = beTrue |