Skip to content

Instantly share code, notes, and snippets.

View bbrown's full-sized avatar

Bill Brown bbrown

View GitHub Profile
@bbrown
bbrown / NEWID.sql
Created February 10, 2016 16:33
Create GUID, remove dashes, and lower case in T-SQL
SELECT LOWER(REPLACE(NEWID(),'-',''))
@bbrown
bbrown / validateDateGreaterThan.js
Created December 29, 2015 23:51
Angular directive to validate that one date is greater than another.
angular.module("app").directive("validateDateGreaterThan", function()
{
return {
require: "ngModel",
scope:
{
firstDate: "=validateDateGreaterThan"
},
link: function(scope, element, attrs, ngModel)
{
@bbrown
bbrown / gleebox.json
Last active December 2, 2015 23:45
Gleebox settings export
{"searchEngine":"http://www.google.com/search?q=","commandEngine":"yubnub","quixUrl":"http://quixapp.com/quix.txt","searchBookmarks":true,"scrollingSpeed":"500","outsideScrolling":false,"shortcutKey":"90","upScrollingKey":"87","downScrollingKey":"83","tabManager":true,"tabManagerShortcutKey":"190","hyper":false,"size":"medium","theme":"GleeThemeDefault","disabledUrls":["mail.google.com","wave.google.com","mail.yahoo.com"],"esp":true,"espVisions":[{"url":"google.com/search","selector":"h3:not(ol.nobr>li>h3),a:contains(Next)"},{"url":"bing.com/search","selector":"div.sb_tlst"},{"url":"pinboard.in","selector":"a.bookmark_title"},{"url":"instapaper.com","selector":"a.article_title"}],"scrapers":[{"command":"?","nullMessage":"Could not find any input elements on the page.","selector":"input:enabled:not(#gleeSearchField),textarea","cssStyle":"GleeReaped"},{"command":"img","nullMessage":"Could not find any linked images on the page.","selector":"a > img","cssStyle":"GleeReaped"},{"command":"h","nullMessage":"Could n
@bbrown
bbrown / expose.js
Last active December 2, 2015 23:23
Angular directive for Smart-Table to make its internal objects available
// FROM https://github.com/lorenzofox3/Smart-Table/issues/235#issuecomment-64878223
angular.module("app").directive("expose", function()
{
return {
require:"stTable",
link: function(scope, element, attr, ctrl)
{
if (attr["expose"].length > 0)
{
if (!scope.$parent.smartTable)
@bbrown
bbrown / fixed-header
Last active August 26, 2016 14:53
Angular directive that makes a table's thead fixed at top of screen on scrolling
angular.module("app").directive("fixedHeader", function($timeout, $window)
{
return {
restrict: "A",
scope: false,
link: function(scope, element, attrs)
{
var waitTime = attrs.fixedHeader || 0;
var collectionToWatch = attrs.fhCollection;
var tableTop, topPos, tableLeft;
@bbrown
bbrown / meta-filter
Created June 30, 2015 19:17
Angular filter that takes a string (including arguments) and applies it as a filter to a string
angular.module("app").filter("meta", function($filter)
{
return function()
{
var filterName = [].splice.call(arguments, 1, 1)[0] || "filter";
var filter = filterName.split(":");
if (filter.length > 1)
{
filterName = filter[0];
for (var i = 1, k = filter.length; i < k; i++)
@bbrown
bbrown / title-case
Last active March 3, 2016 22:11
Angular filter to do a naive title case of a string
angular.module("app").filter("titleCase", function()
{
return function(input)
{
return (input && input.charAt(0).toUpperCase() + input.substr(1).toLowerCase());
};
});
@bbrown
bbrown / toggle-class-singularly
Created June 30, 2015 19:13
Angular directive that toggles a class on an element and insures that no other elements have that class
angular.module("hedge").directive("toggleClassSingularly", function()
{
return {
restrict: "A",
link: function(scope, element, attrs)
{
scope.$root.$on("singular-class-toggled", function(event, args)
{
if (args.class === attrs.toggleClassSingularly && args.element !== element)
{
@bbrown
bbrown / toggle-class
Created June 30, 2015 19:12
Angular directive that toggles the specified class on click
angular.module("app").directive("toggleClass", function()
{
return {
restrict: "A",
link: function(scope, element, attrs)
{
element.bind("click", function()
{
element.toggleClass(attrs.toggleClass);
});
@bbrown
bbrown / focus-on
Created June 30, 2015 19:10
Angular directive to watch a model and focus (or blur) on its truth (or falsity)
// FROM http://stackoverflow.com/a/14837021/20595
angular.module("app").directive("focusOn", function($timeout, $parse)
{
return {
restrict: "A",
link: function(scope, element, attrs)
{
var model = $parse(attrs.focusOn);
var focusListener = scope.$watch(model, function(value)
{