Skip to content

Instantly share code, notes, and snippets.

View michaeljacobdavis's full-sized avatar

Mike Davis michaeljacobdavis

View GitHub Profile
@michaeljacobdavis
michaeljacobdavis / Gruntfile.js
Created September 29, 2014 19:54
Grunt Clean Up
module.exports = function(grunt) {
'use strict';
var _ = require('lodash');
// Configuration
// -------------
// Load Tasks
// ----------
function($http, $q) {
var cache = {};
return {
get: function (force){
var deferred = $q.defer();
if(force || !cache['get']){
return $http.get('/path/to/data').then(function(result){
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
<link rel="stylesheet" href="http://localtodos.com/todos.css" />
</head>
<body>
function sortBy(sequence, sorters) {
return sequence.slice().sort(function (a, b) {
var comparison = 0;
for (var i = 0; i < sorters.length; ++i) {
comparison = sorters[i](a, b);
if (comparison !== 0) {
return comparison;
}
}
return comparison;
@michaeljacobdavis
michaeljacobdavis / Post-build event
Created February 9, 2013 06:20
R.js Minification on TFS build and Publish
cd "$(ProjectDir)Scripts"
node.exe r.js -o build.js
@michaeljacobdavis
michaeljacobdavis / inheritsFrom.js
Created December 13, 2012 00:33
inheritsFrom
Function.prototype.inheritsFrom = function (base) {
this.prototype = Object.create(base.prototype);
this.prototype.constructor = this;
this.prototype._super = base.prototype;
return this;
};
var Base = function () {
if (!(this instanceof Base))
throw ('Constructor called without "new"');
$.fn.autotab = function () {
var inputEvents = "input";
if (!("oninput" in document || "oninput" in $("<input>")[0])) {
inputEvents += " keypress";
}
return this.each(function () {
var $this = $(this);
$this.on(inputEvents, "input[maxlength]", function (e) {
var $this = $(this);
if ($this.attr("maxlength") <= $(this).val().length) {
(function ($) {
$.fn.formatfilename = function (options) {
var settings = $.extend({
'length': '40'
}, options);
return this.each(function () {
var $this = $(this);
@michaeljacobdavis
michaeljacobdavis / Adapter.js
Created August 7, 2012 05:19
NotEqual Fluent Validation validator with client side validation
(function ($) {
$.validator.addMethod("notequal", function (value, element, param) {
return this.optional(element) || value != $(param).val();
}, "This has to be different...");
$.validator.unobtrusive.adapters.add("notequal", ["field"], function (options) {
options.rules["notequal"] = options.params.field;
if (options.message) options.messages["notequal"] = options.message;
});
})(jQuery);
@michaeljacobdavis
michaeljacobdavis / Site.css
Created July 27, 2012 18:23
Adding groups (1 message for multiple properties) to MVC3's Validation
.input-validation-error
{
border: 1px solid #ff0000;
background-color: #ffeeee;
}
span.input-validation-error {
border: none;
}