Skip to content

Instantly share code, notes, and snippets.

@davekaro
Last active December 30, 2015 17:49
Show Gist options
  • Save davekaro/7863843 to your computer and use it in GitHub Desktop.
Save davekaro/7863843 to your computer and use it in GitHub Desktop.
timeline = client.user_timeline(@user_name, { count: 200, include_entities: true })
hashtag_list = timeline.map { |tweet| tweet.hashtags.collect(&:text) }
@hashtags = hashtag_list.uniq.map do |tag|
{ text: tag,
weight: hashtag_list.grep(tag).size,
link: { href: "https://twitter.com/search?q=%23#{tag}", target: '_blank', title: "#{tag}" } }
end
@hashtags = @hashtags.to_json
@davekaro
Copy link
Author

davekaro commented Dec 8, 2013

Oh and https://github.com/JamesChevalier/hashtagged/blob/master/app.rb#L18 should be

hashtag_list = timeline.flat_map { |tweet| tweet.hashtags.map(&:text) } instead of
hashtag_list = timeline.map { |tweet| tweet.hashtags.map(&:text) }.flatten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment