This file contains hidden or 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* bottlesOfBeer(howMany=99){ | |
let pluralizeBottles = count => count !== 1 ? "bottles" : "bottle"; | |
let takeNext = next => next >= 1 ? next.toString() : "No more"; | |
for (let i = howMany; i >= 0; i--) { | |
let bottle = pluralizeBottles(i); | |
let bottleNext = pluralizeBottles(i-1); | |
let left = takeNext(i); | |
let toTake = i > 1 ? "one" : (i == 1 ? "it" : "no more"); | |
let toTakeNext = takeNext(i-1); | |
let line1 = `${left} ${bottle} of beer on the wall, ${left.toLowerCase()} ${bottle} of beer.`; |
This file contains hidden or 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
// benchmark: http://jsperf.com/natural-compare | |
"use strict"; | |
function lexiSort(config) { | |
return function (a, b) { | |
if (typeof a === "number" && typeof b === "number") | |
return a - b; | |
if (a === null || b === null) | |
return NaN; | |
if (a === undefined || b === undefined) | |
return NaN; |
This file contains hidden or 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
// enabled when $rootScope.configHttpDelay == true | |
(function () { | |
"use strict"; | |
angular.module("app") | |
.config(function ($provide) { | |
function decorator($delegate) { | |
var proxy = function (method, url, data, callback, headers) { | |
var interceptor = function () { |
This file contains hidden or 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
/* | |
I've compiled a list of angular directives according to their priorities (from most priority to lesser priority). | |
Also, terminal property is included for each directive that asserts it | |
*/ | |
ng-switch 1200 | |
ng-repeat 1000 terminal | |
ng-if 600 terminal | |
ng-controller 500 | |
ng-init 450 |
NewerOlder