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
// NOTE: $q.all will reject if one of the promises is bad, so we can't use it here | |
// and have instead replicateed $Q.allResolved | |
function allResolved(promises) { | |
var deferred = $q.defer(), // our aggregate promise | |
counter = 0, // know when to resolve our deferred | |
results = []; // where we collect the ordered results of each promise | |
angular.forEach(promises, function(promise, key) { | |
counter++; | |
// might be a value, wrap it up to be safe |
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
var options = [ | |
["red", "blue", "green", "yellow"], // color | |
["small", "medium", "large"], // size | |
["heavy", "light"], // thickness | |
]; | |
scope.inventory = findPermutations(options); | |
////////////////////// | |
function findPermutations(options) { |
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
// http://play.golang.org/p/KNhgeuU5sT | |
package main | |
import ( | |
"fmt" | |
"math" | |
) | |
// truncate a float to two levels of precision | |
func Truncate(some float64) float64 { |
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
angular.module('configModule') | |
.factory('timezoneService', ['configApiService', '$q', | |
function(configApiService, $q) { | |
var tzPromise = false; | |
var service = { | |
get: getTz, | |
}; |
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
/** | |
* Simple template rendering | |
* + double curly brace syntax {{id}} or {{ id }} | |
* + only supports rendering, no conditions or expressions | |
* + no error checking | |
* | |
* @param {string} tmpl Your template string | |
* @param {obj} data The data to inject | |
* @return {string} | |
*/ |
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
<html> | |
<head> | |
<link data-require="bootstrap@*" data-semver="3.3.2" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" /> | |
<script data-require="bootstrap@*" data-semver="3.3.2" src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script> | |
<script data-require="[email protected]" data-semver="2.1.3" src="http://code.jquery.com/jquery-2.1.3.min.js"></script> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.js"></script> | |
<style> | |
body { | |
padding: 20px 0; |
NewerOlder