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
<!-- place at ~/.config/sublime-text-3/Packages/User/$any.sublime-snippet --> | |
<snippet> | |
<content><![CDATA[ | |
{ | |
\$any: { | |
\$alias: '${1:this}', | |
\$expr: { | |
${1:this}: { | |
}, | |
}, |
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 debounceWithResult (func, wait, immediate) { | |
function newDeferred () { | |
var deferred = {}; | |
deferred.promise = new Promise(function (resolve, reject) { | |
deferred.resolve = resolve; | |
deferred.reject = reject; | |
}); | |
return deferred; | |
} |
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 () { | |
"use strict"; | |
window.appNamespace = window.appNamespace || {}; | |
appNamespace.appManager = appNamespace.appManager || new AppManager(); | |
function AppManager() { | |
this.currentAppName = ''; | |
this.currentApp = null; |
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
/* | |
Implemented by katowulf at: | |
https://jsfiddle.net/katowulf/1dfyz2rq/ | |
Discussed in: | |
https://github.com/firebase/angularfire/issues/687 | |
https://github.com/angular-ui/ui-sortable/issues/421 | |
*/ | |
angular.module('firebase.checkpointArray', ['firebase']) | |
.factory('firebaseCheckpointArray', function($firebaseArray) { |
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
// iterate till first success | |
new Promise((resolve) => { | |
runGeneratorOnce(myPromiseGenerator, initialValue); | |
function runGeneratorOnce(pg, result) { var status = pg.next(result); | |
if (status.done) { reject(); return; } | |
status.value.then(resolve).catch(value => { | |
return runGeneratorOnce(pg, value); |
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
async function setDriver(driverNames) { | |
for (var driverName of driverNames) { | |
if (this.supports(driverName) { | |
try { | |
let driver = await this.getDriver(driverName).then(driver => driver._initDriver()); | |
if (driver) { | |
return Promise.resolve(driver); | |
} | |
} catch (e) { } | |
} |
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 getParam(x) { } | |
function myFunc(argument) { } | |
function myAsyncFunc(argument) { return new Promise(function(resolve, reject) { /* ... */ }); } | |
//========== sync loop over | |
for (var i = 0; i < l; i++) { | |
try { | |
var result = myFunc(getParam(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
var crossGetProviders = { | |
whateverorigin: function crossGet(url) { | |
var promise = $.getJSON('http://whateverorigin.org/get?url=' + encodeURIComponent(url) + | |
'&callback=?'); | |
var piped = promise.then(function (response) { | |
return response.contents; | |
}); | |
return piped; | |
}, | |
corsproxy: function corsproxy(url) { |
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($, undefined) { | |
function findCenter(elem) { | |
var offset, | |
document = $(elem.ownerDocument); | |
elem = $(elem); | |
offset = elem.offset(); | |
return { | |
x: offset.left + elem.outerWidth() / 2 - document.scrollLeft(), | |
y: offset.top + elem.outerHeight() / 2 - document.scrollTop() |
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() { | |
"use strict"; | |
angular.module('gen.genericDirectives', []) | |
.directive('genDynamicDirective', ['$compile', | |
function($compile) { | |
return { | |
restrict: "E", | |
require: '^ngModel', | |
scope: true, |
NewerOlder