This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function () { | |
var root = angular.element(document.getElementsByTagName('body')); | |
var watchers = []; | |
var f = function (element) { | |
angular.forEach(['$scope', '$isolateScope'], function (scopeProperty) { | |
if (element.data() && element.data().hasOwnProperty(scopeProperty)) { | |
angular.forEach(element.data()[scopeProperty].$$watchers, function (watcher) { | |
watchers.push(watcher); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// All unhandled exceptions in an AngularJS application are passed to a service $exceptionHandler, | |
// which logs the error message in the browser's console. In large business applications, you may want | |
// to log the error details on the server by calling an API. This can be done by decorating the $exceptionHandler service. | |
// #49 - http://www.dotnetcurry.com/showarticle.aspx?ID=1115 | |
app.config(function($provide) | |
{ | |
$provide.decorator('$exceptionHandler', ['$log', '$http', '$delegate', function ($log, $http, $delegate) | |
{ | |
return function (exception, cause) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################### | |
######## THERE ARE SECRETS IN THIS FILE | |
######## DO NOT COPY THIS OR DISTRIBUTE | |
######## IT PUBLICLY. BE CAREFUL. | |
############################################### | |
alias restart="source ~/.bash_profile" | |
alias updatedb='sudo /usr/libexec/locate.updatedb' | |
alias ppj='cat "$1" | python -mjson.tool' | |
alias work='~/work.sh $output' | |
alias idea='~/idea.sh $output' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("app").filter("customCurrency", ["$filter", function($filter) | |
{ | |
return function(amount, currencySymbol, fractionSize) | |
{ | |
var currency = $filter("currency"); | |
if (Math.abs(amount) > 1000) | |
{ | |
fractionSize = 0; | |
amount = Math.round(amount); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("hedge").filter("ensmallenNumber", function() | |
{ | |
return function(number) | |
{ | |
var billion = 1000000000; | |
var million = 1000000; | |
if (number >= billion) | |
{ | |
return number / billion + "B"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("app").filter("percentage", ["$filter", function($filter) | |
{ | |
return function(input, decimals, alreadyConverted) | |
{ | |
var number = (alreadyConverted) ? input : input * 100; | |
return $filter("number")(number, decimals) + "%"; | |
}; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module("theModuleName").directive("mustBeThirdFriday", function(timeService) | |
{ | |
return { | |
require: "ngModel", | |
link: function(scope, element, attrs, ngModel) | |
{ | |
ngModel.$validators.mustBeThirdFriday = function(modelValue) | |
{ | |
return timeService.isThirdFriday(new Date(modelValue + " 0:00")); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function yyyymmddhhmm(date) | |
{ | |
// Modified from http://stackoverflow.com/a/3067896/20595 | |
var yyyy = date.getFullYear().toString(); | |
var mm = (date.getMonth()+1).toString(); // getMonth() is zero-based | |
var dd = date.getDate().toString(); | |
var hh = date.getHours().toString(); | |
var min = date.getMinutes().toString(); | |
return yyyy + (mm[1]?mm:"0"+mm[0]) + (dd[1]?dd:"0"+dd[0]) + (hh[1]?hh:"0"+hh[0]) + (min[1]?min:"0"+min[0]); // padding | |
}; |