Skip to content

Instantly share code, notes, and snippets.

@briandoll
Created March 30, 2012 23:19

Revisions

  1. Brian Doll revised this gist Apr 2, 2012. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion loud.on.twitter.html
    Original file line number Diff line number Diff line change
    @@ -50,7 +50,6 @@
    </script>
    </head>
    <body>
    Loud tweets about @GitHub...
    <div id="loud-tweets"></div>
    </body>
    </html>
  2. Brian Doll revised this gist Apr 2, 2012. 1 changed file with 17 additions and 2 deletions.
    19 changes: 17 additions & 2 deletions loud.on.twitter.html
    Original file line number Diff line number Diff line change
    @@ -8,9 +8,24 @@
    .twitter-posts a {text-decoration:none; color: #FFF;}
    </style>
    <script type="text/javascript">

    var parseQuerystring = function(){
    var nvpair = {};
    var qs = window.location.search.replace('?', '');
    var pairs = qs.split('&');
    $.each(pairs, function(i, v){
    var pair = v.split('=');
    nvpair[pair[0]] = pair[1];
    });
    return nvpair;
    }

    $(function(){
    var qs = parseQuerystring();
    var q = qs['q'] || '@github';
    var c = qs['c'] || 2000;

    $.twitter({limit: 1000, retweets: false, q: '@github'}, function(tweets){
    $.twitter({limit: 1000, retweets: false, q: q}, function(tweets){
    var musings = tweets.results;
    var tweet_data = {};
    $.each(musings, function(num, tweet) {
    @@ -20,7 +35,7 @@
    var url = "http://api.twitter.com/1/users/lookup.json?callback=?&screen_name=";
    $.getJSON(url + authors.join(), function(profiles){
    $.each(profiles, function(count, author){
    if (author.followers_count > 2000){
    if (author.followers_count > c){
    tweet = tweet_data[author.screen_name];
    name = author.name;
    $('#loud-tweets').append($("<li>", {
  3. Brian Doll revised this gist Apr 2, 2012. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion loud.on.twitter.html
    Original file line number Diff line number Diff line change
    @@ -22,7 +22,6 @@
    $.each(profiles, function(count, author){
    if (author.followers_count > 2000){
    tweet = tweet_data[author.screen_name];
    console.log(author);
    name = author.name;
    $('#loud-tweets').append($("<li>", {
    "class": "twitter-posts",
  4. Brian Doll revised this gist Apr 2, 2012. 1 changed file with 16 additions and 48 deletions.
    64 changes: 16 additions & 48 deletions loud.on.twitter.html
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    <html>
    <head>
    <script src="http://code.jquery.com/jquery.js"></script>
    <!-- jQuery Twitter API plugin from https://github.com/boazsender/jQuery-Twitter-Plugin -->
    <script src="jquery.twitter.min.js"></script>
    <style type="text/css">
    body {background: #333; font-size: 64px; color: #999}
    @@ -11,58 +10,27 @@
    <script type="text/javascript">
    $(function(){

    // note: use mustache for this!
    var displayTweets = function(tweet_data, loud_authors){
    $.each(tweet_data, function(author, tweet){
    if (loud_authors.indexOf(author) >= 0){
    console.log(tweet);
    $('#loud-tweets').append($("<li>", {
    "class": "twitter-posts",
    html: "<div class='name'>" + name + "</div><a href='http://twitter.com/" + tweet.from_user + "' class='profile'>@" + tweet.from_user + "</a> says...<div class='tweet'><a href='http://twitter.com/" + tweet.from_user + "/status/" + tweet.id_str + "'>" + tweet.text + "</a></div>"}));
    };
    $.twitter({limit: 1000, retweets: false, q: '@github'}, function(tweets){
    var musings = tweets.results;
    var tweet_data = {};
    $.each(musings, function(num, tweet) {
    tweet_data[tweet.from_user] = tweet;
    });
    };

    var displayLoudTweets = function(){
    searchForTweets(buildTweetData);
    };

    var findLoudAuthors = function(tweet_data){
    loud_authors = [];
    authors = Object.keys(tweet_data);
    url = "http://api.twitter.com/1/users/lookup.json?callback=?&screen_name=";
    var authors = Object.keys(tweet_data);
    var url = "http://api.twitter.com/1/users/lookup.json?callback=?&screen_name=";
    $.getJSON(url + authors.join(), function(profiles){
    $.each(profiles, function(count, author){
    if (author.followers_count > 5000){
    loud_authors.push(author.screen_name);
    $.each(profiles, function(count, author){
    if (author.followers_count > 2000){
    tweet = tweet_data[author.screen_name];
    console.log(author);
    name = author.name;
    $('#loud-tweets').append($("<li>", {
    "class": "twitter-posts",
    html: name + " <a href='http://twitter.com/" + tweet.from_user + "' class='profile'>@" + tweet.from_user + "</a> (" + author.followers_count + ") says...<div class='tweet'><a href='http://twitter.com/" + tweet.from_user + "/status/" + tweet.id_str + "'>" + tweet.text + "</a></div>"}));
    };
    });
    displayTweets(tweet_data, loud_authors);
    });
    };

    var buildTweetData = function(tweets){
    tweet_data = {};
    $.each(tweets, function(num, tweet) {
    tweet_data[tweet.from_user] = tweet;
    });
    findLoudAuthors(tweet_data);
    };

    var searchForTweets = function(callback, filter){
    $.twitter({limit: 1000, retweets: false, q: '@github'}, function(tweets){
    var musings = tweets.results;
    var batches_of_tweets = [];
    while (musings.length) {
    batches_of_tweets.push(musings.splice(0,100));
    }
    $.each(batches_of_tweets, function(id, batch){
    callback(batch);
    });
    });
    };

    displayLoudTweets();
    });

    });
    </script>
  5. Brian Doll revised this gist Mar 31, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion loud.on.twitter.html
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@
    <script type="text/javascript">
    $(function(){

    // note: use mustache for this
    // note: use mustache for this!
    var displayTweets = function(tweet_data, loud_authors){
    $.each(tweet_data, function(author, tweet){
    if (loud_authors.indexOf(author) >= 0){
  6. Brian Doll revised this gist Mar 31, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion loud.on.twitter.html
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@

    <html>
    <head>
    <script src="http://code.jquery.com/jquery.js"></script>
    <!-- jQuery Twitter API plugin from https://github.com/boazsender/jQuery-Twitter-Plugin -->
    <script src="jquery.twitter.min.js"></script>
    <style type="text/css">
    body {background: #333; font-size: 64px; color: #999}
    @@ -11,6 +11,7 @@
    <script type="text/javascript">
    $(function(){

    // note: use mustache for this
    var displayTweets = function(tweet_data, loud_authors){
    $.each(tweet_data, function(author, tweet){
    if (loud_authors.indexOf(author) >= 0){
  7. Brian Doll created this gist Mar 30, 2012.
    73 changes: 73 additions & 0 deletions loud.on.twitter.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,73 @@

    <html>
    <head>
    <script src="http://code.jquery.com/jquery.js"></script>
    <script src="jquery.twitter.min.js"></script>
    <style type="text/css">
    body {background: #333; font-size: 64px; color: #999}
    .twitter-posts {padding: 10px; list-style-type:none; border-bottom: 1px solid #000;}
    .twitter-posts a {text-decoration:none; color: #FFF;}
    </style>
    <script type="text/javascript">
    $(function(){

    var displayTweets = function(tweet_data, loud_authors){
    $.each(tweet_data, function(author, tweet){
    if (loud_authors.indexOf(author) >= 0){
    console.log(tweet);
    $('#loud-tweets').append($("<li>", {
    "class": "twitter-posts",
    html: "<div class='name'>" + name + "</div><a href='http://twitter.com/" + tweet.from_user + "' class='profile'>@" + tweet.from_user + "</a> says...<div class='tweet'><a href='http://twitter.com/" + tweet.from_user + "/status/" + tweet.id_str + "'>" + tweet.text + "</a></div>"}));
    };
    });
    };

    var displayLoudTweets = function(){
    searchForTweets(buildTweetData);
    };

    var findLoudAuthors = function(tweet_data){
    loud_authors = [];
    authors = Object.keys(tweet_data);
    url = "http://api.twitter.com/1/users/lookup.json?callback=?&screen_name=";
    $.getJSON(url + authors.join(), function(profiles){
    $.each(profiles, function(count, author){
    if (author.followers_count > 5000){
    loud_authors.push(author.screen_name);
    };
    });
    displayTweets(tweet_data, loud_authors);
    });
    };

    var buildTweetData = function(tweets){
    tweet_data = {};
    $.each(tweets, function(num, tweet) {
    tweet_data[tweet.from_user] = tweet;
    });
    findLoudAuthors(tweet_data);
    };

    var searchForTweets = function(callback, filter){
    $.twitter({limit: 1000, retweets: false, q: '@github'}, function(tweets){
    var musings = tweets.results;
    var batches_of_tweets = [];
    while (musings.length) {
    batches_of_tweets.push(musings.splice(0,100));
    }
    $.each(batches_of_tweets, function(id, batch){
    callback(batch);
    });
    });
    };

    displayLoudTweets();

    });
    </script>
    </head>
    <body>
    Loud tweets about @GitHub...
    <div id="loud-tweets"></div>
    </body>
    </html>