Skip to content

Instantly share code, notes, and snippets.

Avatar

John Hunter johnhunter

View GitHub Profile
@johnhunter
johnhunter / jQuery.reduce.js
Created Oct 27, 2010
jQuery.reduce - a jQuery plugin for functional programming
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 ($) {
@johnhunter
johnhunter / gist:1362075
Created Nov 13, 2011
Example JavaScript Pseudo-class
View gist:1362075
// Example Pseudo-class
var Animal = (function() {
function Animal(name) {
this.name = name;
}
Animal.prototype.getName = function () {
return this.name;
};
@johnhunter
johnhunter / app.js
Created Dec 10, 2011
Nodejs chat with socket.io
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;
@johnhunter
johnhunter / grid_mixins.scss
Last active Jan 29, 2019 — forked from ksenzee/grid_mixins.scss
Mixins that make it possible to use CSS Grid in IE 10/11 as well as in modern browsers. Based on mixins by Sascha Fuchs at https://medium.com/@gisugosu/css-grid-layout-spec-2-to-spec-1-transpiler-with-sass-415dff4dd31b.
View grid_mixins.scss
//
// Grid mixins to support IE11
// https://gist.github.com/johnhunter/1c7d332e7c2ed8351e36c40695b94d4f
//
/// Add Gap between the boxes
///
/// @author Sascha Fuchs
///
/// @group core - cssgrid
@johnhunter
johnhunter / Espresso Soda.tmTheme
Created Jun 16, 2012
Sublime Espresso Soda theme with added styles for sublime linter.
View Espresso Soda.tmTheme
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>Espresso Soda</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
@johnhunter
johnhunter / gist:3333533
Created Aug 12, 2012
Git configs for a submodule with sparse-checkout filtering
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 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);
};
@johnhunter
johnhunter / jQuery.equalHeights.js
Created Oct 27, 2010
jQuery plugin that ensures html elements share the same height
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
@johnhunter
johnhunter / jquery.minmax.js
Created Nov 3, 2011
Run min / max over a JQuery object to equalise heights etc.
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); };
@johnhunter
johnhunter / observer.js
Created May 15, 2012
An observable decorator
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 || {};
You can’t perform that action at this time.