$(".box").on("webkitTransitionEnd transitionend oTransitionEnd", function (event) {
if (event.originalEvent.propertyName == "width") {
// bla-bla
}
if (event.originalEvent.propertyName == "height") {
// bla-bla
}
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 _missExecutionIfAnotherIsProcessing(action) { | |
return function () { | |
if (action.busy) { | |
logger.debug("Missing new execution. Another instance is processing now."); | |
return Q.when(action.waiting); | |
} | |
action.busy = true; | |
action.waiting = action.apply(undefined, Array.prototype.slice.call(arguments)).then(function (res) { | |
action.busy = false; |
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 encodeAndSerializeJson(obj) { | |
if (typeof obj === 'string') { | |
return encodeURIComponent(obj); | |
} else if (Array.isArray(obj)) { | |
for (var i = obj.length; i--;) { | |
obj[i] = encodeAndSerializeJson(obj[i]); | |
} | |
} else { | |
var keys = Object.keys(obj); | |
for (var i = keys.length; 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
/** | |
* Performance reporting for Knockout binding handlers | |
* | |
* Usage: Include after all bindings are declared, view console for results. | |
*/ | |
(function () { | |
var report = []; | |
var lastReport = 0; | |
var debounceWait = 500; |
When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.
-
Raw Attribute Strings
<div my-directive="some string" another-param="another string"></div>
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 startOnce(callback, delay) { | |
var delayed = Q.delay(delay); | |
var deferred = Q.defer(); | |
delayed.then(deferred.resolve); | |
var promise = deferred.promise.then(function () { | |
_handleDeferred(deferred, callback()); | |
}, function (res) { | |
if (!res.cancelled) throw res; |
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 hash = crypto.createHash('md5'), | |
stream = fs.createReadStream('mybigfile.dat'); | |
stream.on('data', function (data) { | |
hash.update(data, 'utf8') | |
}) | |
stream.on('end', function () { | |
hash.digest('hex'); // 34f7a3113803f8ed3b8fd7ce5656ebec | |
}) |
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 start = new Date(); | |
var hrstart = process.hrtime(); | |
setTimeout(function (argument) { | |
// execution time simulated with setTimeout function | |
var end = new Date() - start, | |
hrend = process.hrtime(hrstart); | |
console.info("Execution time: %dms", end); | |
console.info("Execution time (hr): %ds %dms", hrend[0], hrend[1]/1000000); |
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
Add-Type -AssemblyName System.IO.Compression.FileSystem | |
function Unzip | |
{ | |
param( | |
[string]$archive, | |
[string]$out | |
) | |
[System.IO.Compression.ZipFile]::ExtractToDirectory($archive, $out) | |
} |