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('scope.glance', []) | |
.factory('attach$glance', ['$q', function ($q) { | |
function $glance(watchExpression, checkFunction, objectEquality) { | |
var scope = this; | |
var dfd = $q.defer(), | |
clearWatch; | |
checkFunction = checkFunction || function (newVal, oldVal, scope) { |
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('fireUtil', ['firebase']) | |
.provider('fireUtil', function () { | |
var util, $get; | |
util = { | |
rootUrl: null, | |
$get: ['Firebase', function (Firebase) { | |
var _rootRef = util.rootUrl ? new Firebase(util.rootUrl) : null; |
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 Promise = require('bluebird'); | |
// log the error | |
Promise.onPossiblyUnhandledRejection(function(error){ | |
// this will be called even though there is a catch | |
console.log('uncaught error here', error); | |
}); | |
var toCall = Promise.coroutine(function* () { | |
console.log('going to explode'); |
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
// async version of timedChunk plus queued by robin | |
function asyncChunkQueued(items, process, context, callback) { | |
var todo = items.concat(), //create a clone of the original | |
i = 0, // index counter | |
dfd = $.Deferred(), | |
routine = function () { | |
process.call(context, todo.shift(), i++) | |
.then(function () { | |
if (todo.length > 0) { | |
_setImmediate(routine); |
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
/** | |
* Context and arguments proxy function | |
* | |
* @param {function} func the function | |
* @param {object} context the context | |
* @param {array} args arguments | |
* @return {function} proxied function | |
*/ | |
function proxy(func, context, args) { | |
return 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
app.directive('autoFillSync', function($timeout) { | |
return { | |
require: 'ngModel', | |
link: function(scope, elem, attrs) { | |
var origVal = elem.val(); | |
$timeout(function () { | |
var newVal = elem.val(); | |
if(ngModel.$pristine && origVal !== newVal) { | |
ngModel.$setViewValue(newVal); | |
} |
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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
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
Here is a list of scopes to use in Sublime Text 2 snippets - | |
ActionScript: source.actionscript.2 | |
AppleScript: source.applescript | |
ASP: source.asp | |
Batch FIle: source.dosbatch | |
C#: source.cs | |
C++: source.c++ | |
Clojure: source.clojure | |
CSS: source.css |
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 randInt(min,max){ | |
var range = max - min; | |
// it actually does work the other way... | |
// if (range < 0) { throw new RangeError("min must be less than max"); } | |
var rand = Math.floor(Math.random() * (range + 1)); | |
return min + rand; | |
} |
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('submitIt', []) | |
/** | |
* @ngdoc directive | |
* @description form submission trigger | |
* | |
* @param {boolean} submit-it submit form on `true` | |
* @param {string} si-action submit action(optional) | |
* @param {string} si-method submit method(optional) | |
*/ |