-
-
Save distributedlife/6723883 to your computer and use it in GitHub Desktop.
p2_i5_a1.js
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 my_awesome_function = function() { | |
| return true; | |
| }; | |
| my_awesome_function(); |
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 my_lesser_function = my_awesome_function; |
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 start_streaming = function(db, endpoint, params) { | |
| Twitter.stream(endpoint, params, function(stream) { | |
| stream.on('data', function(data) { | |
| if(data.user && data.text) { | |
| db.collection('tweets', function(err, tweets_collection) { | |
| tweets_collection.insert(data); | |
| }); | |
| db.collection('events', function(err, events_collection) { | |
| map_tweet_to_event(data, function(evt) { | |
| events_collection.insert(evt); | |
| }); | |
| }; | |
| }); | |
| }); | |
| }; |
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 stream_tweets = function(terms, callback) { | |
| endpoint = 'user' | |
| params = {'with': 'followings', 'track': terms}; | |
| Twitter.stream(endpoint, params, function(stream) { | |
| stream.on('data', function(data) { | |
| if(data.user && data.text) { | |
| callback(data); | |
| } | |
| }); | |
| }); | |
| }; | |
| var record_tweet = function(db) { | |
| return function(data) { | |
| db.collection('tweets', function(err, tweets_collection) { | |
| tweets_collection.insert(data); | |
| }); | |
| db.collection('events', function(err, events_collection) { | |
| events_collection.insert(map_tweet_to_event(data)); | |
| }); | |
| } | |
| }; |
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
| things.sort {|a,b| a.age <=> b.age && a.sort_name <=> b.sort_name } |
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
| sort_by_age_then_name = Proc.new do | a, b | | |
| a.age <=> b.age && a.sort_name <=> b.sort_name | |
| end | |
| things.sort(&sort_by_age_then_name) |
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
| words = [] | |
| file.readlines.each { |line| words << line.strip } |
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
| words = File.readlines('word_list').map(&:chomp) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment