Skip to content

Instantly share code, notes, and snippets.

View jeffschwartz's full-sized avatar

Jeff Schwartz jeffschwartz

View GitHub Profile
@jeffschwartz
jeffschwartz / curry.js
Last active August 29, 2015 13:56
A JavaScript implementation of curry.
(function(){
"use strict";
/**
* A factory for creating curry functions that
* are tied to the arrity of the function f.
*/
function makeArrityBasedCurry(n) {
var curry = function(f){
var args = [].slice.call(arguments, 1);
@jeffschwartz
jeffschwartz / partial.js
Created February 26, 2014 18:34
A JavaScript implementation of partial.
(function(){
"use strict";
/**
* Creating a partial the hard way.
*/
(function(){
function add(x){
return function(y){
@jeffschwartz
jeffschwartz / classicalinheritance.js
Last active August 29, 2015 14:03
Emulates classical inheritance and results in a prototype chain (nested prototypes) of base classes.
/*
* Emulates classical inheritance and results in a
* prototype chain (nested prototypes) of baseclasses.
*/
(function(){
/*
* Extend childObj from parentObj and apply childPrototype to the childObj.
* @param {Objectl} childObj The child object. Required.
* @param {Objectl} parentObj The parent object. Required.
@jeffschwartz
jeffschwartz / datevalidation.js
Created November 28, 2014 17:29
Date validation
/* Date Validation by Jeffrey Schwartz */
(function(w){
'use strict';
var dv;
//define the project module's name space
w.ejr = w.ejr || {};
//define this module's name space
dv = w.ejr.dateValidation = {};
dv.isYearValid = function isYearValid(y){
return typeof(y) === 'number';
@jeffschwartz
jeffschwartz / snippets.cson
Created April 18, 2015 14:35
Atom snippets for Preamble
'Preamble describe':
'prefix': 'describe'
'body': """
describe('$1', function(){
$2
});
"""
'Preamble it':
'prefix': 'it'
'body': """
@jeffschwartz
jeffschwartz / createPrototype.js
Last active August 29, 2015 14:20
Create a prototype
/**
* Creates a new object that can be used as a protype for a ctor.
* @param api object The object whose own properties are to be copied to
* the new prototype object.
* @param ctr function The constructor function which will be set as the
* value of the new prototype's contructor property.
* @returns an object that can be uses as a protytpe.
*/
function createPrototype(api, ctr){
var ownProps = Object.getOwnPropertyNames(api),
@jeffschwartz
jeffschwartz / Preamble Atom snippets
Created July 12, 2015 21:50
Preamble snippets for the fabulous Atom editor
'.source.js':
'Preamble configure':
'prefix': 'configure'
'body': """
configure({
$1: $2,
});
"""
'Preamble describe':
'prefix': 'describe'
@jeffschwartz
jeffschwartz / starter-template.html
Created September 25, 2012 03:02
Twitter Bootstrap Navigation Bars - nav-tabs
<!DOCTYPE html>
<html lang="en">
<!--
Notes :
#1. change all link and script urls to match project
#2. you do not need any additional javascript to make nav-tabs work. just include
the bootstrap.js file as per the script tag at the bottom of the page.
-->
@jeffschwartz
jeffschwartz / nav-list.html
Created September 26, 2012 14:09
Twitter Bootstrap Navigation Bars - nav-list
<!DOCTYPE html>
<html lang="en">
<!--
Notes :
#1. change all link and script urls to match project
#2. you do not need any additional javascript to make nav-tabs work. just include
the bootstrap.js file as per the script tag at the bottom of the page.
-->
@jeffschwartz
jeffschwartz / .gvimrc
Last active October 11, 2015 15:58
My vim configuration files
"Currently Empty