Skip to content

Instantly share code, notes, and snippets.

Created June 30, 2014 03:50
Show Gist options
  • Save anonymous/217cd6addcd412f5419e to your computer and use it in GitHub Desktop.
Save anonymous/217cd6addcd412f5419e to your computer and use it in GitHub Desktop.

Revisions

  1. @invalid-email-address Anonymous created this gist Jun 30, 2014.
    11 changes: 11 additions & 0 deletions jsbin.labotiri.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    <!DOCTYPE html>
    <html>
    <head>
    <script src="http://code.jquery.com/jquery-2.1.0.min.js"></script>
    <meta charset="utf-8">
    <title>JS Bin</title>
    </head>
    <body>

    </body>
    </html>
    39 changes: 39 additions & 0 deletions jsbin.labotiri.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    $(document).ready(function(){
    $.ajax({
    type: "get",
    url: "https://api.github.com/users/achalv/repos?type=public&sort=updated&direction=desc",
    dataType: "json",
    success: function(returnedData){
    console.log(returnedData);
    var contribs = [];
    returnedData.forEach(function(obj) {

    //console.log(obj.fork);
    var isFork = obj.fork;
    var createdAt = obj.created_at;
    var lastPushedAt = obj.pushed_at;
    if((isFork)&&lastPushedAt>createdAt){
    contribs.push(obj);
    }
    //contribs.forEach(function(result))

    });

    //console.log(contribs);
    function sortByKey(array, key) {
    return array.sort(function(a, b) {
    var x = a[key]; var y = b[key];
    return ((x < y) ? -1 : ((x > y) ? 1 : 0));
    });
    }

    var sContribs = sortByKey(contribs, 'size');
    console.log(sContribs);
    for(var i=0; i<sContribs.length;i++){
    var subObj = sContribs[i];
    console.log(subObj.name);
    }

    }
    });
    });