Skip to content

Instantly share code, notes, and snippets.

@esironal
Forked from derek/gist:674668
Last active February 18, 2016 12:10
Show Gist options
  • Save esironal/caced2b2e77a918437c1 to your computer and use it in GitHub Desktop.
Save esironal/caced2b2e77a918437c1 to your computer and use it in GitHub Desktop.
Snagging Github repos with YQL
// Create a JSONP wrapper
function executeYQL(yql, callbackFuncName) {
var url = "http://query.yahooapis.com/v1/public/yql?q=" + encodeURIComponent(yql) + "&env=store://datatables.org/alltableswithkeys&format=json&callback="+callbackFuncName;
var head = document.getElementsByTagName('head')[0];
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = url;
head.appendChild(script);
}
// Execute the query
executeYQL("select repository from github.user.repos where id='esironal | reverse()", "daCallback");
// Define the callback
function daCallback(data) {
var repositories = data.query.results.repositories;
var html = [];
for(i in repositories) {
var repo = repositories[i].repository;
html.push("<li><a href='" + repo.url + "'>" + repo.name + "</a> - " + repo.description + "</li>");
}
document.getElementById("repositories").innerHTML = html.join('');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment