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 */
define(function () {
return requirejs.config({
paths: {
'text': './text',
'modernizr': './modernizr-2.6.2',
'jquery': './jquery-1.11.0',
'jquery-ui': './jquery-ui-1.10.3',
'jquery-unobtrusive': "./jquery.unobtrusive-ajax",
'jquery-val': "./jquery.validate",
'knockout': './knockout-3.0.0.debug',
@DrSammyD
DrSammyD / gruntfile.coffee
Created February 19, 2014 14:48
MVC4 Grunt setup
module.exports = (grunt) ->
grunt.initConfig
pkg: grunt.file.readJSON('package.json'),
sass: # Task
dist: # Target
files: # Dictionary of files
"Bitcadia.Web/Content/Site.css": "Bitcadia.Web/sass/Site.scss" # 'destination': 'source'
@DrSammyD
DrSammyD / kodash.js
Last active August 29, 2015 13:57
Knockout dependency detection in chained lodash or underscore calls.
(function (factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['knockout','lodash'], factory);
} else {
factory(ko,_);
}
})(function (ko, _) {
function isLodash(lodashCalls) {
return lodashCalls && typeof lodashCalls == 'object' && !_.isArray(lodashCalls) && hasOwnProperty.call(lodashCalls, '__wrapped__')

FilterExpressionComposer

This is a way of filtering an IQueryable using Dynamic Linq. It composes strings based on Strings retrieved from the database and static values and functions which return strings stored in a dictionary with a key of a columnName for the filter Criterion

Each filter criterion has on it an appColumn which contains the lookup name for the path of the properties on a queryable which it needs to filter on.

FuncVal

@DrSammyD
DrSammyD / resolveRelink.js
Last active August 29, 2015 14:09
Track using knockout es5 recursively
@DrSammyD
DrSammyD / repeat.js
Created December 8, 2014 23:19
function which repeats an id a set amount of times and then increments
var repeat= function(reps){
var repeatOrig=ko.repeat;
repeatOrig.uid=!repeatOrig.uid?1:repeatOrig.uid+1;
var times = reps-1;
var repetion= function(){
if(--times<=0)
ko.repeat=repeatOrig;
return repeatOrig.uid;
};
ko.repeat=repetion;
@DrSammyD
DrSammyD / ROA.c
Created October 22, 2015 15:05
Rivals of Aether gpc program
/* *
* GPC SCRIPT
*
* GPC is a scripting language with C-like syntax.
* To learn more access GPC Language Reference on Help menu.
* *********************************************************** */
define LP = XB360_X;
define LK = XB360_A;
define MP = XB360_Y;
@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
@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