This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getScrollbarWidth = function() { | |
var scrollbarWidth; | |
return (function() { | |
if (scrollbarWidth) { | |
return scrollbarWidth; | |
} | |
// Create the measurement node | |
var scrollDiv = document.createElement("div"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var boundElements = []; | |
ko.applyBindings = function(vm, el) { | |
if (boundElements.indexOf(el) > -1) { | |
console.log("dupe", el); | |
} | |
boundElements.push(el); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function IncludeKoTemplates($path) { | |
$files = scandir(dirname(__FILE__).$path); | |
foreach($files as $file_name){ | |
if( in_array($file_name,array(".","..")) ) continue; | |
$template_id = basename($file_name, ".html"); | |
$contents = file_get_contents(dirname(__FILE__). $path . $file_name); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* External logic for a complex search helper - keeps main files cleaner | |
*/ | |
class SqlIntersectHelper{ | |
// Outersects are the same as intersects but data lists without any entries will always be included in the result | |
// Any - Any value from the criterion list must exist at least once in the data list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var app = (function() { | |
var self = {}; | |
self.storage = { | |
get: function(key) { | |
return localStorage.getItem(key); | |
}, | |
set: function(key, value) { | |
if (typeof value == "undefined") { | |
return localStorage.removeItem(key); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var haskellFunction = hs.create( | |
hs.when('[]', function() { | |
}), | |
hs.when('(x:xs)', | |
// | |
hs.gaurd(hs.gte(5), function(self, a, x, xs, b) { | |
}), | |
hs.gaurd(hs.lte(2), function(self, a, x, xs, b) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// curry :: ((a, b) -> c) -> a -> b -> c | |
function curry(fn) { | |
return function() { | |
if (arguments.length < fn.length) { | |
return curry(fn.bind.apply(fn, [this].concat(Array.prototype.slice.call(arguments)))); | |
} | |
else { | |
return fn.apply(this, arguments); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// PureObj is an object wrapper for fantasy land | |
// which is pure, every change is cloned into | |
// a new object | |
// - Semigroup (concat) | |
// - monoid (empty) | |
// - functor (map) | |
// When a pure obj is created, the original values are cloned | |
// deeply into a new object | |
var myObj = PureObj({ a: 'hello' }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Functional Programming makes you look like a mad man | |
* Exhibit A. | |
* I define 23 helper functions so that I can write my solution point-free style | |
* - Remy D'Agostino | |
*/ | |
// :: a -> b -> bool | |
var eq = autocurry(function(a, b) { return a === b; }); | |
// :: a -> b -> bool |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 654 + 59 = 713 | |
* addArrayNumbers([6, 5, 4], [5, 9]) // [7, 1, 3]; | |
* | |
* @param {Array} first | |
* @param {Array} second | |
* @return {Array} | |
*/ | |
function addArrayNumbers(first, second) { | |
var result = [], |
OlderNewer