Skip to content

Instantly share code, notes, and snippets.

# Get weekly top tracks
albums = WeeklyAnniversaryQuery.new.find_all
# Schedule tweets
# Create task that runs once a week at the beginning to schedule track tweets
albums.each do |album|
# Get Random Datetime
random_day_of_week = (0..6).to_a.sample
random_hour_in_day = (8..20).to_a.sample
random_scheduled_at = Week.current.start + random_day_of_week.days + random_hour_in_day.hours
@rsnorman
rsnorman / tweet-popular-track.rb
Last active December 5, 2016 14:54
Get Album Most Popular Track
@rsnorman
rsnorman / fav-artist-mentioned-tweets.rb
Last active November 30, 2016 14:11
Favorite Artist Mentioned Tweets
# HighlightedAlbumRelatedTweets
last_album_highlighted = HighlightedAlbum.last.album
artist_hashtag = "##{album.artist.name.gsub(/[^a-zA-Z]*/, '')}"
artist_mentioned_tweets = client.search("#{artist_hashtag} -rt")
related_tweets = artist_mentioned_tweets.select { |t| t.user.id != 704175249202540544 }
# TweetsFavoriter
related_tweets.each { |t| client.favorite(t) }
@rsnorman
rsnorman / follow-recent-tweet-interactors.rb
Last active November 30, 2016 14:11
Follow Recent Tweet Interactors
# RecentInteractors
client = WistfulIndie::Twitter::Client.client
page = Nokogiri::HTML(open('https://favstar.fm/users/wistfulindie/recent'))
interactor_screen_names = page.css('a.fs-avatar').map { |el| el.attr('title').tr('@', '') }.select { |sn| !sn.empty? }.uniq
# RecentInteractorFollower
interactor_screen_names = interactor_screen_names - TwitterFollow.pluck(:screen_name)
interactor_screen_names.each do |screen_name|jk
begin
@rsnorman
rsnorman / wistful-indie-creates-follows.rb
Last active November 26, 2016 19:04
Creates follows
# Create Twitter followers
# Class: NewTwitterFriendAccumulator
File.open(Rails.root.join('db/follower_ids.txt'), 'wb') {|f| WistfulIndie::Twitter::Client.client.follower_ids.each { |fid| f << "#{fid}\n" } }
File.open(Rails.root.join('db/friend_ids.txt'), 'wb') {|f| WistfulIndie::Twitter::Client.client.friend_ids.each { |fid| f << "#{fid}\n" } }
# Class: TwitterFriendsFollower
File.read(Rails.root.join('db/friend_ids.txt')).split("\n").each { |id| TwitterFollow.create(twitter_id: id) }
# Class: TwitterFollowCreator
@rsnorman
rsnorman / gist:329ea67d58776b46566b
Last active August 29, 2015 14:17
SpeaQ To Do List
  • Update Facebook app to reflect new name and log (InterAppt vs SpeaQ)
  • Create new logo for SpeaQ
  • Figure out why Facebook login fails sometimes
  • When initial location search fails and user retries, it should work if if location is found
  • Questions
    • Better layout for questions view, maybe resemble login screen
    • Smoother transition of question text view when location is pulled up. Had a nice swing in animation but was lost in an update somewhere. Might not be needed if layout is changed in above item.
    • Need better feedback when question is answered
    • Stats on percentages of answer picked, right vs wrong, etc
  • Show text explaining answer, e.g., for running back one, state how many yards he earned over career
@rsnorman
rsnorman / gist:a28806f6f53718d41d54
Created January 15, 2015 04:02
centresource contact
Hello, hello! It was suggested to me by some Nashville colleagues to check out your site. I can tell from looking at some of the case studies that your work is high quality. I especially enjoyed the track and field one having run myself in college (I wasn't very good). I also see that you are hiring front-end and Rails developers and am interested since my contract with Onlife Health will be ending soon. I would love to see if I would be a good fit for your company if you have time.
@rsnorman
rsnorman / gist:284518cc80fc6872ca1a
Created December 23, 2014 18:53
Delete merged branches
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d