View curry es5 example.js
exports.default = function (socket) {
return function (store) {
return function (next) {
return function (action) {
if (action.meta && action.meta.remote) {
var clientId = store.getState().get('clientId');
socket.emit('action', objectAssign({}, action, { clientId: clientId }));
}
return next(action);
};
View gist:3333533
Assuming you have created a submodule 'mysub' in repo 'myrepo'
Set the sparse checkout config property in the submodule
myrepo/.git/modules/mysub/config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
View jQuery.reduce.js
/*
jQuery.reduce - a jQuery plugin for functional programming
@author John Hunter
created 2010-09-17
use: $.reduce(arr, fnReduce, valueInitial);
fnReduce is called with arguments: [valueInitial, value, i, arr]
reduce will never be jQuery core - its not prototype :p (http://dev.jquery.com/ticket/1886)
*/
(function ($) {
View jQuery.equalHeights.js
/*
jQuery.equalHeights Plugin
@author John Hunter
@dependency jQuery 1.4.x
EqualHeights version 2.0 (2010-09-07 johnhunter.info)
Based on an idea copyright (c) 2008 Rob Glazebrook (cssnewbie.com)
use: $('#selector').equalHeights({minHeight: 200});
see defaults object for options
View jquery.minmax.js
/*
min, max - jQuery plugins which set css properties to min/max value for the collection
@author John Hunter
created 2011-11-03
use: $('li.tabs').max('height');
*/
(function ($) {
$.fn.max = function (prop) { return foldProp(this, Math.max, prop); };
$.fn.min = function (prop) { return foldProp(this, Math.min, prop); };
View app.js
/*
Websockets using http://socket.io/
Also with express web mvc framework http://expressjs.com/
*/
var app = require('express').createServer(),
io = require('socket.io').listen(app),
port = 88;
View observer.js
/**
* Creates or decorates an object with observable behavior.
* @param {[type]} o object to decorate
* @return {[type]} the observable object
*/
function makeObservable (o) {
var undef;
o = o || {};
View function.inherit.js
/**
* Nice implementation of Crockford's beget / object.create
* @param {Function} base - the base constructor
* @return undefined
* example: Dog.inherit(Animal);
*/
Function.prototype.inherit = function (base) {
function Inheriter() { }
Inheriter.prototype = base.prototype;
this.prototype = new Inheriter();
View promise-example.js
// using a promise
$.when(doStuff('eat'), doStuff('sleep')).then(function(a, b){
console.log(a + ' and ' + b +' are done');
});
// define the function that returns a promise
function doStuff (subject) {
var defer = new $.Deferred();
View Gruntfile.js
/* jshint node: true */
module.exports = function(grunt) {
grunt.registerTask('default', ['concat:test']);
grunt.loadNpmTasks('grunt-contrib-concat');
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {