Skip to content

Instantly share code, notes, and snippets.

@brock
Last active August 29, 2015 14:18
Show Gist options
  • Save brock/79d58230e9048d8cb9a9 to your computer and use it in GitHub Desktop.
Save brock/79d58230e9048d8cb9a9 to your computer and use it in GitHub Desktop.
The Button

The Button

Data analysis on how long until the button runs out.

Reddit unleashed the button this week and it has quickly become my all-time favorite April Fools campaign. The rules are simple, click the button (or don't) so long as your reddit account was created before April 1, 2015. Smart, they've effectively limited their pool of potential users, and guaranteed that this experiment won't go on forever. Clicking the button resets a 60 second timer.

Since this was started, the timer hasn't ever gotten below 30 seconds, to my knowledge.


Let's look at what might have been:

  • 1,638,409 Number of registered users as of April 1, 2015

Assuming that right out of the gate, all reddit users were aware of what was going on, and could somehow coordinate fast enough, this could have been the longest running gag of all time:

With 1,638,409 users, all waiting until the timer got down to 1 second, we would have had a 59 second average between clicks. At that rate, unless my math is off, the button could have theoretically been running for over 3 years.

(59 seconds  * 1638409 users) = 96,666,131 seconds until the timer runs out
each day contains 60 seconds * 60 minutes * 24 hours = 86,400 seconds
96,666,131 seconds / 86,400 seconds = 1118.820960648 days (3.065262906 years)

Let's look at what is happening:

This entire experiment depends on one key variable: 
the length of time between clicks.

If you connect to the WebSocket server (see code below), and listen to the events, you can calculate the milliseconds between each click, then find a running average. What does this tell us? It tells us that we are losing a logged in user, on average, every 4.282 seconds, or roughly 20,177 users click the button each day. And those are considerably different numbers:

(4.282 seconds  * 1638409 users) = 7,015,667 seconds until the timer runs out
each day contains 60 seconds * 60 minutes * 24 hours = 86,400 seconds
7,015,667 seconds / 86,400 seconds = 81.199849537 days (June 25th, 2015)

All of that changes though once things slow down and our averages get larger and larger.

Parting Thoughts

If there is one thing that I worry about most with this whole button thing, it is that nothing will happen. Remember "Lost"? There were a lot of folks who said, "just stop clicking the button..." I hope for reddit's sake, they have a plan for when this eventually runs out. Some thoughts:

  • You can't just call out "April Fools!!" in the middle of June. Lame.
  • I suppose you COULD donate all the ad revenue from that subreddit to a charity... Nice, but not exactly up to the level of Lost-caliber, in my opinion.
  • Catastrophic changes???

I was able to identify that this is what the button will look like once we reach the end:
expired

Let's just hope it is more than that...

var count, avg;
var last = {count: undefined, timeStamp: undefined}
var diffs = [];
var c = new WebSocket('wss://wss.redditmedia.com/thebutton?h=45018a4432715aa3f659cf5114896ced70678021&e=1428335153');
c.onmessage = function(d) {
var pj = JSON.parse(d.data);
count = pj.payload.participants_text.replace(',','');
if (!last.count || !last.timeStamp) {
console.log('setting last values')
last.count = +count;
last.timeStamp = d.timeStamp;
}
if (+count > last.count) {
diffs.push(d.timeStamp - last.timeStamp);
last = {count: count, timeStamp : d.timeStamp}
var sum = diffs.reduce(function(a,b) {return a + b});
avg = sum / diffs.length;
console.log('new data:')
console.log('diffs: ' + diffs.toString())
console.log('diffs.length: ' + diffs.length)
console.log('sum: ' + sum)
console.log('avg: ' + avg)
} else {
console.log('waiting on data')
console.log(last)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment