Permalink
Browse files

switch over to the garden hose and add analytics

  • Loading branch information...
1 parent a68b091 commit 6ee141e0cafe2302ce31a9bececa4d5af42901ec Todd Fisher committed Aug 25, 2010
Showing with 42 additions and 2 deletions.
  1. +3 −0 .gitmodules
  2. +23 −1 lib/tweet_track.js
  3. +1 −0 mongoose
  4. +14 −0 public/index.html
  5. +1 −1 server.js
View
@@ -0,0 +1,3 @@
+[submodule "mongoose"]
+ path = mongoose
+ url = git://github.com/LearnBoost/mongoose.git
View
@@ -49,7 +49,29 @@ function track_tweets(keywords,tweetReady) {
request.end();
}
- trackKeywords(keywords);
+ function gardenhoseTweets() {
+ var twitter_basic_auth = process.env['TWITTER_BASIC'];
+ var twitter = http.createClient(80, 'stream.twitter.com');
+ var request = twitter.request('GET','/1/statuses/sample.json',
+ {
+ 'Host': 'stream.twitter.com',
+ 'Authorization': 'Basic ' + twitter_basic_auth,
+ });
+
+ request.on('response', function (response) {
+ //response.setEncoding('utf8');
+ response.on('data', parseTweets);
+ response.on('end', function() {
+ sys.puts("connection dropped restart in 3 seconds...");
+ setTimeout(gardenhoseTweets,3000); // restart the connection to twitter after 3 seconds?
+ });
+ });
+ request.end();
+ }
+
+ gardenhoseTweets();
+
+ //trackKeywords(keywords);
}
exports.watch=track_tweets;
Submodule mongoose added at 779f3a
View
@@ -16,5 +16,19 @@ <h1>Real time Tracking the mood on twitter</h1>
<div id="tweet-avg"></div>
<div id="mood-graph" style="width:850px;height:250px"></div>
<div id="tweets"></div>
+
+<script type="text/javascript">
+
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-246931-53']);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+
+</script>
</body>
</html>
View
@@ -7,7 +7,7 @@ var Sentiment = require(__dirname + "/lib/sentiment");
// keep an in memory array of incoming tweets
var TWEETS = [];
-var MAX_TWEETS = 200; // limit how many tweets we keep
+var MAX_TWEETS = 60; // limit how many tweets we keep
//var TWITTER_TRACK = "basketball,football,baseball,footy,soccer";
var TWITTER_TRACK = "#oilspill";

0 comments on commit 6ee141e

Please sign in to comment.