Skip to content

Instantly share code, notes, and snippets.

View ronen-e's full-sized avatar

Ronen Elster ronen-e

  • Tel Aviv, Israel
View GitHub Profile
function delegate(element, eventName, selector, handler) {
var el = null;
element.addEventListener(eventName, function delegatedListener(e) {
el = e.target;
while (el !== element && el.parentNode) {
if (el.nodeType === 1 && selectorMatches(el, selector)) {
handler(e, el);
break;
}
@ronen-e
ronen-e / download-time.js
Last active June 10, 2016 21:42
Calculate resource download time
/**
* Returns download time from server
*
* @param {number} cwnd - Initial Congestion Window size
* @param {number} rtt - Roundtrip Time in Milliseconds
* @param {number} packetSize - Packet Size in Bytes
* @param {number} totalSize - Total Transfer Size in Bytes
* @return {number} time - Download Time in Milliseconds
*/
function downloadTime(cwnd, rtt, packetSize, totalSize) {
@ronen-e
ronen-e / 0_reuse_code.js
Created April 29, 2016 11:17
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console