Skip to content

Instantly share code, notes, and snippets.

@remydagostino
remydagostino / sql-intersect-helper.php
Created September 13, 2013 00:36
A helper class to perform various kinds of intersections across related tables.
<?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
@remydagostino
remydagostino / include-ko-templates.php
Created September 12, 2013 00:26
Create Include all files within a directory
<?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);
@remydagostino
remydagostino / intercept-bindings.js
Created September 9, 2013 07:22
Find duplicate ko.applyBindings
(function() {
var boundElements = [];
ko.applyBindings = function(vm, el) {
if (boundElements.indexOf(el) > -1) {
console.log("dupe", el);
}
boundElements.push(el);
};
@remydagostino
remydagostino / gist:6348814
Last active December 21, 2015 18:39
Calculate the width of the browser scrollbars. Credit: http://davidwalsh.name/detect-scrollbar-width
var getScrollbarWidth = function() {
var scrollbarWidth;
return (function() {
if (scrollbarWidth) {
return scrollbarWidth;
}
// Create the measurement node
var scrollDiv = document.createElement("div");