Skip to content

Instantly share code, notes, and snippets.

@Saladressing
Created September 29, 2016 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Saladressing/36476db10b502d4dbc2c3fb2b56fe53a to your computer and use it in GitHub Desktop.
Save Saladressing/36476db10b502d4dbc2c3fb2b56fe53a to your computer and use it in GitHub Desktop.
var stats = {"updatedAt":1474997057,"packages":{"asset":{"releasedAt":"2015-02-10","total":548249,"perDay":1523.5,"perSecond":0.017633101851852},"assetic-bundle":{"releasedAt":"2012-04-13","total":11071584,"perDay":13492.7,"perSecond":0.15616550925926},"browser-kit":{"releasedAt":"2012-04-13","total":11119615,"perDay":15034.1,"perSecond":0.17400578703704},"cache":{"releasedAt":"2016-01-19","total":71133,"perDay":648.6,"perSecond":0.0075069444444444},"class-loader":{"releasedAt":"2012-04-13","total":5975899,"perDay":13641.066666667,"perSecond":0.15788271604938},"config":{"releasedAt":"2012-04-13","total":11601093,"perDay":22491.4,"perSecond":0.26031712962963},"console":{"releasedAt":"2012-04-13","total":31908522,"perDay":62525.766666667,"perSecond":0.72367785493827},"css-selector":{"releasedAt":"2012-04-13","total":17984302,"perDay":36953.866666667,"perSecond":0.42770679012346},"debug":{"releasedAt":"2013-04-07","total":19754360,"perDay":40667.6,"perSecond":0.47068981481481},"debug-bundle":{"releasedAt":"2014-09-26","total":37912,"perDay":164.43333333333,"perSecond":0.0019031635802469},"dependency-injection":{"releasedAt":"2012-04-13","total":8277048,"perDay":16803.166666667,"perSecond":0.19448109567901},"doctrine-bridge":{"releasedAt":"2012-04-13","total":623632,"perDay":917.36666666667,"perSecond":0.010617669753086},"dom-crawler":{"releasedAt":"2012-04-13","total":18036723,"perDay":35980.233333333,"perSecond":0.41643788580247},"event-dispatcher":{"releasedAt":"2012-04-13","total":33749740,"perDay":62932.966666667,"perSecond":0.72839081790123},"expression-language":{"releasedAt":"2013-09-20","total":1177646,"perDay":2358,"perSecond":0.027291666666667},"filesystem":{"releasedAt":"2012-04-13","total":19645810,"perDay":29872.366666667,"perSecond":0.3457449845679},"finder":{"releasedAt":"2012-04-13","total":25140779,"perDay":51049.7,"perSecond":0.59085300925926},"form":{"releasedAt":"2012-04-13","total":1506077,"perDay":1995.9,"perSecond":0.023100694444444},"framework-bundle":{"releasedAt":"2012-04-13","total":1242696,"perDay":1541.9,"perSecond":0.017846064814815},"framework-standard-edition":{"releasedAt":"2012-04-13","total":1057019,"perDay":637.26666666667,"perSecond":0.0073757716049383},"http-foundation":{"releasedAt":"2012-04-13","total":21629102,"perDay":42800.933333333,"perSecond":0.49538117283951},"http-kernel":{"releasedAt":"2012-04-13","total":19903689,"perDay":39323.866666667,"perSecond":0.45513734567901},"icu":{"releasedAt":"2013-03-09","total":4980898,"perDay":2583,"perSecond":0.029895833333333},"inflector":{"releasedAt":"2016-03-31","total":146044,"perDay":1480.6666666667,"perSecond":0.017137345679012},"intl":{"releasedAt":"2013-04-22","total":1823194,"perDay":2867.1666666667,"perSecond":0.033184799382716},"ldap":{"releasedAt":"2015-09-30","total":15261,"perDay":61.266666666667,"perSecond":0.0007091049382716},"locale":{"releasedAt":"2012-04-13","total":458337,"perDay":380.4,"perSecond":0.0044027777777778},"monolog-bridge":{"releasedAt":"2012-04-13","total":917724,"perDay":1536.6666666667,"perSecond":0.01778549382716},"monolog-bundle":{"releasedAt":"2012-04-13","total":13069316,"perDay":20491.1,"perSecond":0.23716550925926},"options-resolver":{"releasedAt":"2012-05-16","total":2784573,"perDay":5825.2666666667,"perSecond":0.067422067901235},"phpunit-bridge":{"releasedAt":"2015-02-21","total":1559095,"perDay":7995.6666666667,"perSecond":0.092542438271605},"polyfill":{"releasedAt":"2015-11-04","total":25915,"perDay":166.16666666667,"perSecond":0.001923225308642},"polyfill-apcu":{"releasedAt":"2016-01-14","total":2745955,"perDay":16402.933333333,"perSecond":0.1898487654321},"polyfill-iconv":{"releasedAt":"2015-10-25","total":346839,"perDay":2292.8666666667,"perSecond":0.026537808641975},"polyfill-intl-grapheme":{"releasedAt":"2015-10-25","total":577,"perDay":4.5666666666667,"perSecond":5.2854938271605e-5},"polyfill-intl-icu":{"releasedAt":"2015-10-25","total":3283868,"perDay":15615.633333333,"perSecond":0.18073649691358},"polyfill-intl-normalizer":{"releasedAt":"2015-10-25","total":2058,"perDay":16.6,"perSecond":0.00019212962962963},"polyfill-mbstring":{"releasedAt":"2015-10-25","total":15069002,"perDay":69329.433333333,"perSecond":0.80242399691358},"polyfill-php54":{"releasedAt":"2015-10-25","total":3191279,"perDay":13828.133333333,"perSecond":0.16004783950617},"polyfill-php55":{"releasedAt":"2015-10-25","total":3223333,"perDay":14205.266666667,"perSecond":0.16441280864198},"polyfill-php56":{"releasedAt":"2015-10-25","total":8920063,"perDay":40304.466666667,"perSecond":0.46648688271605},"polyfill-php70":{"releasedAt":"2015-10-25","total":3453942,"perDay":16805.566666667,"perSecond":0.19450887345679},"polyfill-util":{"releasedAt":"2015-10-25","total":8917011,"perDay":40244.5,"perSecond":0.46579282407407},"polyfill-xml":{"releasedAt":"2015-10-25","total":1164,"perDay":10.066666666667,"perSecond":0.00011651234567901},"process":{"releasedAt":"2012-04-13","total":24673554,"perDay":50178.466666667,"perSecond":0.58076929012346},"propel1-bridge":{"releasedAt":"2012-04-24","total":56386,"perDay":66.333333333333,"perSecond":0.00076774691358025},"property-access":{"releasedAt":"2013-01-14","total":2392529,"perDay":4127.0333333333,"perSecond":0.047766589506173},"property-info":{"releasedAt":"2015-09-26","total":14536,"perDay":115.36666666667,"perSecond":0.001335262345679},"proxy-manager-bridge":{"releasedAt":"2013-05-08","total":267823,"perDay":526.1,"perSecond":0.0060891203703704},"psr-http-message-bridge":{"releasedAt":"2015-05-29","total":453633,"perDay":2965.7,"perSecond":0.034325231481481},"routing":{"releasedAt":"2012-04-13","total":19290995,"perDay":37945.5,"perSecond":0.43918402777778},"security":{"releasedAt":"2012-04-13","total":1616272,"perDay":1904.7,"perSecond":0.022045138888889},"security-acl":{"releasedAt":"2013-09-18","total":2238020,"perDay":10003.933333333,"perSecond":0.1157862654321},"security-bundle":{"releasedAt":"2012-04-13","total":230693,"perDay":341.56666666667,"perSecond":0.0039533179012346},"security-core":{"releasedAt":"2013-09-18","total":7299648,"perDay":5806.9666666667,"perSecond":0.067210262345679},"security-csrf":{"releasedAt":"2013-11-14","total":1237550,"perDay":1586.4,"perSecond":0.018361111111111},"security-guard":{"releasedAt":"2015-09-24","total":3416,"perDay":8.9333333333333,"perSecond":0.0001033950617284},"security-http":{"releasedAt":"2013-09-18","total":18948,"perDay":47.066666666667,"perSecond":0.00054475308641975},"serializer":{"releasedAt":"2012-04-13","total":1534737,"perDay":4705.8,"perSecond":0.054465277777778},"stopwatch":{"releasedAt":"2012-11-10","total":4619919,"perDay":9142.2666666667,"perSecond":0.10581327160494},"swiftmailer-bridge":{"releasedAt":"2012-04-13","total":84416,"perDay":30.466666666667,"perSecond":0.00035262345679012},"swiftmailer-bundle":{"releasedAt":"2012-04-13","total":11843371,"perDay":18073.8,"perSecond":0.2091875},"symfony":{"releasedAt":"2012-04-13","total":14905562,"perDay":22769.066666667,"perSecond":0.26353086419753},"symfony-installer":{"releasedAt":"2014-10-16","total":1538,"perDay":0.9,"perSecond":1.0416666666667e-5},"templating":{"releasedAt":"2012-04-13","total":1359951,"perDay":1671.1666666667,"perSecond":0.019342206790123},"translation":{"releasedAt":"2012-04-13","total":21952626,"perDay":44955.466666667,"perSecond":0.52031790123457},"twig-bridge":{"releasedAt":"2012-04-13","total":1915831,"perDay":2833.2666666667,"perSecond":0.032792438271605},"twig-bundle":{"releasedAt":"2012-04-13","total":309609,"perDay":436.7,"perSecond":0.0050543981481481},"validator":{"releasedAt":"2012-04-13","total":3604962,"perDay":7183.4666666667,"perSecond":0.083141975308642},"var-dumper":{"releasedAt":"2014-09-26","total":12386285,"perDay":35357.8,"perSecond":0.4092337962963},"web-profiler-bundle":{"releasedAt":"2012-04-13","total":532349,"perDay":768.2,"perSecond":0.0088912037037037},"workflow":{"releasedAt":"2016-06-27","total":3436,"perDay":50.133333333333,"perSecond":0.00058024691358025},"yaml":{"releasedAt":"2012-04-13","total":29708771,"perDay":62862.433333333,"perSecond":0.72757445987654}},"total":{"downloads":501555444,"perSecond":12.642003472222}};
var numFormatter = window.Intl !== undefined
? new Intl.NumberFormat('en', { maximumFractionDigits: 0 })
: { format: function (number) { return number.toFixed(0).toString().replace(/(.)(?=(\d{3})+$)/g, '$1,') } }
;
var updatesPerSecond = 2;
var secondsElapsedSinceStatsWereUpdated = getCurrentTimeStamp() - stats['updatedAt'];
var downloads = stats['total']['downloads'] + secondsElapsedSinceStatsWereUpdated * stats['total']['perSecond'];
window.setInterval(function(){ updateStats() }, 1000 / updatesPerSecond);
// update the stats interpolating the historic data to simulate real-time
function updateStats() {
downloads += (stats['total']['perSecond'] / updatesPerSecond);
document.getElementById('total').innerHTML = numFormatter.format(downloads);
}
// This avoids displaying different stats when the local computer clock is not in sync
function getCurrentTimeStamp()
{
var request = new XMLHttpRequest();
request.open('GET', '/500million/timestamp', false); // false = sync request
request.setRequestHeader('Content-Type', 'application/json');
request.send();
if (request.status === 200) {
var response = JSON.parse(request.responseText);
return response['now'];
} else {
return (Date.now() / 1000);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment