Created
          June 14, 2014 08:53 
        
      - 
      
- 
        Save JAlexoid/405f09fc53c75718beb4 to your computer and use it in GitHub Desktop. 
    A simple Twitter feed consumer that calculates the velocity of a hash tag. Using Node.JS and Twitter module
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | var util = require('util'), | |
| twitter = require('twitter'), | |
| sys = require('sys'); | |
| var twit = new twitter({ | |
| consumer_key: '', | |
| consumer_secret: '', | |
| access_token_key: '', | |
| access_token_secret: '' | |
| }); | |
| var aceleration = 0.0; | |
| x = twit.stream('statuses/filter', {track:'#nowplaying'}, function(stream) { | |
| stream.on('data', function (data) { | |
| //sys.puts(sys.inspect(data)); | |
| aceleration = aceleration + 1.0; | |
| console.log("Current acceleration: "+aceleration); | |
| }); | |
| stream.on('error', function (error) { | |
| sys.puts('Connection error '+sys.inspect(error)); | |
| }); | |
| stream.on('end', function (response) { | |
| sys.puts('Connection ended'); | |
| }); | |
| // Disconnect stream after five seconds | |
| //setTimeout(stream.destroy, 5000); | |
| }); | |
| setInterval(function(){ | |
| aceleration = aceleration - 0.1; | |
| } , 50); | |
| console.log(sys.inspect(x)); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment