Skip to content

Instantly share code, notes, and snippets.

View imyelo's full-sized avatar
🎯
Focusing

yelo imyelo

🎯
Focusing
  • 🧠 Nako, ex-☕ Gomo, ex-🐧 Tencent
  • Shenzhen, CN
View GitHub Profile
@imyelo
imyelo / String.prototype.format.js
Last active August 29, 2015 13:56
String.prototype.format like python
(function (String) {
String.prototype.format = function (args) {
var copy = this + '';
var i, len;
for (i = 0, len = arguments.length; i < len; i++) {
copy = copy.replace(new RegExp("\\{" + i + "\\}", 'g'), String(arguments[i]));
}
return copy;
};
})(String);
@imyelo
imyelo / waitLazyload.js
Last active August 29, 2015 13:56
wait lazyload for testing
(function () {
var count = 0;
var $lazy = $('.img-lazy-load');
var every = function () {
return _.every($lazy, function (elem) {
return elem.loaded;
});
};
$lazy.on('load', function () {
if (every()) {