Skip to content

Instantly share code, notes, and snippets.

View amethystlei's full-sized avatar

Lei Q amethystlei

View GitHub Profile
arena.mockLeaderboard({mockCount:1200,mockScoreChangeTime:2000});
app.filter('bytes', function() {
return function(bytes, precision) {
if (isNaN(parseFloat(bytes)) || !isFinite(bytes)) return '-';
if (typeof precision === 'undefined') precision = 1;
if (bytes === 0) return '0kb'
var units = ['bytes', 'kb', 'mb', 'gb', 'tb', 'pb'],
number = Math.floor(Math.log(bytes) / Math.log(1024));
return (bytes / Math.pow(1024, Math.floor(number))).toFixed(precision) + ' ' + units[number];
}
});