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
site breakpoint: <span class="my-site-breakpoint"></span> | |
<div class="my-div"> | |
my div breakpoint: <span class="my-div-breakpoint"></span> | |
</div> | |
<div class="my-color-div"></div> |
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 (spread, base) { | |
return Math.floor(Math.random() * spread + (isNaN(base) ? 0: base)); | |
} |
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
// requires https://gist.github.com/toddzebert/b4465de41b0f8d317d7a685604983c36 | |
function asyncSim (res, data, onDone) { | |
var result = (typeof res === "function") ? res(data) : res; | |
setTimeout(function () { onDone(result); } | |
, randInt(400, 200)); | |
}; |
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
// requires https://gist.github.com/toddzebert/95bcc9b50febad0bb9680d3eab897797 | |
// requires https://gist.github.com/toddzebert/b4465de41b0f8d317d7a685604983c36 | |
var getAuth = asyncSim.bind(null, 'Authorized'); | |
var getProfile = asyncSim.bind(null, 'Profile'); | |
var getFeed = asyncSim.bind(null, function(data) { | |
for (var a = [], i = randInt(4, 2); i; i--) { | |
a.push(randInt(90, 1)); | |
} | |
return a; | |
}); |
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
// requires https://gist.github.com/toddzebert/ca9b735f1fbcd627ddfead4a87378adb | |
var data = { id: 4 }; | |
getAuth(data, function (res) { | |
data.auth = res; | |
getProfile(data, function (res) { | |
data.profile = res; | |
getFeed(data, function (res) { | |
data.feed = res; | |
console.log(data); // callback hell | |
}); |
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
// requires https://gist.github.com/toddzebert/95bcc9b50febad0bb9680d3eab897797 | |
// requires https://gist.github.com/toddzebert/b4465de41b0f8d317d7a685604983c36 | |
var getAuth = asyncSim.bind(null, 'Authorized'); | |
var getProfile = asyncSim.bind(null, 'Profile'); | |
var getFeed = asyncSim.bind(null, function(data) { | |
for (var a = [], i = randInt(4, 2); i; i--) { | |
a.push(randInt(90, 1)); | |
} | |
return a; | |
}); |
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 all = function (entries, cb) { | |
var finishers = entries.length; | |
var allCB = (function(cb) { | |
return function (res) { | |
if (res) { | |
if (--finishers === 0) cb(res); | |
} else { | |
cb(false); | |
} |
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
// requires https://gist.github.com/toddzebert/7c0aa1f1ee3be2d39d301bd875fead25 | |
// requires https://gist.github.com/toddzebert/ef155ae58efb5a3788a7b143b0f7d215 | |
var posts = [], data = { id: 4 }; | |
getAuth(data, function (res) { | |
data.auth = res; | |
getProfile(data, function (res) { | |
data.profile = res; | |
getFeed(data, function (res) { | |
data.feed = res; | |
var getPosts = data.feed.map(post => getPost(post)); |
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
// requires https://gist.github.com/toddzebert/95bcc9b50febad0bb9680d3eab897797 | |
// requires https://gist.github.com/toddzebert/b4465de41b0f8d317d7a685604983c36 | |
var getAuth = asyncSim.bind(null, 'Authorized'); | |
var getProfile = asyncSim.bind(null, 'Profile'); | |
var getFeed = asyncSim.bind(null, function(data) { | |
for (var a = [], i = randInt(4, 2); i; i--) { | |
a.push(randInt(90, 1)); | |
} | |
return a; | |
}); |
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 once = function (func) { | |
var done = false; | |
return function (res) { | |
if (done) return; | |
if (res) { | |
func.apply(this, arguments); | |
} else { | |
func.apply(this, false); | |
} | |
done = true; |