Skip to content

Instantly share code, notes, and snippets.

function curry$(f, bound){
var context,
_curry = function(args) {
return f.length > 1 ? function(){
var params = args ? args.concat() : [];
context = bound ? context || this : this;
return params.push.apply(params, arguments) <
f.length && arguments.length ?
_curry.call(context, params) : f.apply(context, params);
} : f;
@elclanrs
elclanrs / dom.ls
Last active August 29, 2015 13:57
Minimal library for functional DOM manipulation
{map, unique, flatten} = require \prelude-ls
# Helpers
#
joinF = (f, g) -->
->
(f ...) ++ g ...
maybe = (pred, f, x) -->
require('funcoffee').expose global
#- Monadic
unit = curry (x, a) -> new x.constructor a
mbind = curry (f, ma) -> ma.bind f
mjoin = (ma) -> ma.bind id
fmap = curry (f, ma) -> ma.bind (a) -> unit ma, f a
ap = curry (mf, ma) -> mf.bind (f) -> fmap f, ma
@elclanrs
elclanrs / _.js
Created June 4, 2014 02:08
Dynamic object key interpolation
var formatObj = function(data, obj) {
return Object.keys(obj).reduce(function(acc, k) {
acc[data[k.match(/#\{(\w+)\}/)[1]]] = obj[k]
return acc
},{})
}
formatObj({a:'foo', b:'baz'}, {'#{a}': 'this is foo'
,'#{b}': 'this is baz'})
//^
var add,all,andF,any,apply,builtin,capitalize,compact,compose,concat,concatF,countBy,curry,curryN,difference,div,drop,dups,each,even,extend,filter,find,first,flatMap,flatten,flip,flip3,flipN,fold,foldr,forOwn,gmatch,groupBy,gt,gte,has,id,inArray,initial,instanceOf,intersection,isF,isType,isntF,join,keys,last,lt,lte,map,match,max,memo,merge,min,mod,mul,nop,notF,odd,orF,pairs,partial,partition,pluck,pluckF,pluckR,reject,replace,rest,reverse,search,sequence,shuffle,size,slice,sort,sortBy,split,sub,substr,take,toArray,toLower,toObject,toUpper,trim,union,unique,unwords,unzipObject,values,variadic,where,withF,words,zip,zipObject,zipWith,_,__slice=[].slice,__indexOf=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++){if(t in this&&this[t]===e)return t}return-1},__hasProp={}.hasOwnProperty;_={};nop=function(){};id=function(e){return e};builtin=function(e){return nop.call.bind(e)};variadic=function(){var e;e=1<=arguments.length?__slice.call(arguments,0):[];return e};apply=function(){var e,t;t=arguments[0],e=2<=
\documentclass[oneside,12pt]{article}
%\usepackage[margin=1.55in]{geometry}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{
listings,titlesec,sectsty,setspace,
enumerate,tabularx,
graphicx,fancyhdr,framed,
\documentclass[oneside,12pt]{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{
listings,titlesec,sectsty,setspace,caption,
enumerate,tabularx,
graphicx,fancyhdr,framed,
microtype,ragged2e,
@elclanrs
elclanrs / toCustomFile.js
Created July 5, 2012 03:57
toCustomFile
$.fn.toCustomFile = function () {
return this.each(function () {
var
$file = $(this), // The file input
// Necessary markup
$wrap = $('<div class="wrap">'),
$input = $('<input type="text" class="filename" />'),
@elclanrs
elclanrs / jquery.idealforms.min.js
Created July 29, 2012 10:17
jquery.idealforms.min.js
/*--------------------------------------------------------------------------
jq-idealforms 2.0
* Author: Cedric Ruiz
* License: GPL or MIT
* Demo: http://elclanrs.github.com/jq-idealforms/
*
--------------------------------------------------------------------------*/(function(e){"use strict";e.idealforms={};var t={getMaxWidth:function(t){var n=0;return t.each(function(){e(this).outerWidth()>n&&(n=e(this).outerWidth())}),n},getLessVar:function(t,n){var r=e('<p class="'+t+'"></p>').hide().appendTo("body").css(n);return e("."+t).remove(),/^\d+/.test(r)?parseInt(r,10):r},getKeys:function(e){var t=[];for(var n in e)t.push(n);return t},isFunction:function(e){return typeof e=="function"},isRegex:function(e){return e instanceof RegExp},getByNameOrId:function(t){if(e('[name="'+t+'"]').length)return e('[name="'+t+'"]');if(e('[name="'+t+'"]').length)return e("#"+t);e.error('The field "'+t+"\" doesn't exist.")},getIdealType:function(e){var t=e.attr("type")||e[0].tagName.toLowerCase();return/(text|password|em
@elclanrs
elclanrs / idealselect.js
Created August 6, 2012 22:40
jQuery select menu replacement
/**
* A custom <select> menu jQuery plugin
* @example `$('select').idealSelect()`
*/
$.fn.idealSelect = function () {
return this.each(function () {
var