Skip to content

Instantly share code, notes, and snippets.

@tophtucker
Last active May 19, 2016 17:05
Show Gist options
  • Save tophtucker/71b2711d245c98d56cc1f6899b260221 to your computer and use it in GitHub Desktop.
Save tophtucker/71b2711d245c98d56cc1f6899b260221 to your computer and use it in GitHub Desktop.
Mystery box
scrolling: yes
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
padding: 2em;
text-align: center;
}
</style>
<body>
<img src="box.jpg">
</body>
<script>
var user = 'tophtucker';
fetch('https://api.github.com/users/' + user + '/gists').then(function(response) {
return response.ok ? response.text() : Promise.reject(response.status);
}).then(function(text) {
var gists = JSON.parse(text);
window.location = 'http://bl.ocks.org/' + user + '/' + gists[Math.floor(Math.random() * gists.length)].id;
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment