Skip to content

Instantly share code, notes, and snippets.

@distributedlife
Last active December 24, 2015 01:29
Show Gist options
  • Select an option

  • Save distributedlife/6723883 to your computer and use it in GitHub Desktop.

Select an option

Save distributedlife/6723883 to your computer and use it in GitHub Desktop.
p2_i5_a1.js
var my_awesome_function = function() {
return true;
};
my_awesome_function();
var my_lesser_function = my_awesome_function;
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);
});
};
});
});
};
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));
});
}
};
things.sort {|a,b| a.age <=> b.age && a.sort_name <=> b.sort_name }
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)
words = []
file.readlines.each { |line| words << line.strip }
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