Skip to content

Instantly share code, notes, and snippets.

View calebdwilliams's full-sized avatar
🫠

Caleb Williams calebdwilliams

🫠
View GitHub Profile
@calebdwilliams
calebdwilliams / binarySearch.js
Last active March 22, 2016 20:55
Basic binary search demonstration.
function generateArray() {
'use strict';
let length = Math.floor(Math.random() * 100000),
remove = Math.floor(Math.random() * length),
array = [];
for (let counter = 0; counter <= length; counter += 1) {
array.push(counter);
}
(function() {
angular.module('myApp.directives')
.directive('validateClass', [function() {
return {
restrict: 'A',
link: function validateClassLink(scope, element, attributes, ngForm) {
var fieldObj = ngForm[attributes.validateClass],
className = attributes.errorClass || 'has-error';
scope.$watch(function() {
@calebdwilliams
calebdwilliams / evalMethod.filter.js
Created September 18, 2015 19:30
Defines a filter on the $filter provider that will call a method to filter objects inside of ngRepeat.
angular.module('myApp.filters', [])
/**
* Defines a filter on the $filter provider that will call a method
* to filter objects inside of ngRepeat.
*
* @return {Function}
* @param {Array} - the array to loop through
* @param {String} - the Object method name
* @param {Any} - the value to match against
* @return {Array} - the resultant array
describe('GridController', function() {
beforeEach(module('GridApp'));
var GridApp, controller, scope, ctrl;
beforeEach(inject(function($rootScope, $controller) {
scope = $rootScope.$new();
controller = $controller;
ctrl = controller('GridController', {