Skip to content

Instantly share code, notes, and snippets.

View DrSammyD's full-sized avatar

Sam Armstrong DrSammyD

View GitHub Profile
@DrSammyD
DrSammyD / text.export.js
Last active August 29, 2015 13:56
Allows you to define individual modules inside an html module using Comments
/**
* @license RequireJS text 2.0.10 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/text for details
*/
/*jslint regexp: true */
/*global require, XMLHttpRequest, ActiveXObject,
define, window, process, Packages,
java, location, Components, FileUtils */
@DrSammyD
DrSammyD / underscore.resolveRelink.js
Last active April 23, 2018 11:49
A lodash mixin which will create an object that links and unlinks circular references based on the way json.net handles reference loops. Based on this Stackoverflow answer http://stackoverflow.com/a/21687071/364282
@DrSammyD
DrSammyD / jq.domcallback.coffee
Created March 1, 2013 02:08
jquery plugin that provides a way to notify parents of different types of callbacks defined by the plugin user
(($, window) ->
hasArgs = () -> arguments.length > 0
noArgs = () -> arguments.length == 0
class DomCallbacks
###*
* Defines the jQuery functions to create callbacks for, and which type of callback they contain
* @type {defaults}
* @properties {array of jQuery function names, and test to determine if the callback
* should be run based on input to the jQuery function, passed the same arguments that the jQuery
* function is}
@DrSammyD
DrSammyD / ko.jqhtml.coffee
Created March 1, 2013 02:07
knockout binding handler using custom jquery domcallback plugin
ko.bindingHandlers.jqHtml =
init: (element, valueAccessor) ->
$(element).preMutate (options, el) ->
if ko.isObservable valueAccessor()
valueAccessor().valueWillMutate()
$(element).onMutate _.debounce (argsCollection) =>
@argsCollection = argsCollection
if ko.isObservable valueAccessor()
valueAccessor().valueHasMutated()
, 100
@DrSammyD
DrSammyD / underscore.debounce
Created March 1, 2013 02:03
underscore debounce wich gives all the arguments called against the function to the function
_.debounceAll = (func, wait, immediate) ->
timeout = undefined
result = undefined
results = []
->
results.push
context: this
args: for val in arguments
val