Skip to content

Instantly share code, notes, and snippets.

@JohnRoos
Last active August 29, 2015 14:24
Show Gist options
  • Select an option

  • Save JohnRoos/e6f5e63ae915216c05aa to your computer and use it in GitHub Desktop.

Select an option

Save JohnRoos/e6f5e63ae915216c05aa to your computer and use it in GitHub Desktop.
Show all gists
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<div id="placeholder"></div>
<script>
var username = 'johnbravo'
$.getJSON('https://api.github.com/users/' + username + '/gists', function (data) {
for (var i in data) {
var oldDocumentWrite = document.write
document.write = function (scr_content) {
for (var i in data) {
if ( $.trim( $("#" + data[i].id ).text() ).length == 0 ) {
$("#" + data[i].id ).append(scr_content);
return;
}
}
}
var scr = document.createElement('script');
scr.src = 'https://gist.github.com/JohnBravo/' + data[i].id + '.js';
$("#placeholder").append("<div><h2>" + data[i].description + "</h2></div>");
$("#placeholder").append(scr.outerHTML);
$("#placeholder").append('<div id="' + data[i].id + '"></div>');
}
document.write = oldDocumentWrite;
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment