Skip to content

Instantly share code, notes, and snippets.

@CaffeinatedDave
Created May 5, 2016 12:18
Show Gist options
  • Save CaffeinatedDave/711460a08479db75bcc50368545373c6 to your computer and use it in GitHub Desktop.
Save CaffeinatedDave/711460a08479db75bcc50368545373c6 to your computer and use it in GitHub Desktop.
require 'yaml'
require 'twitter'
yaml = YAML.load_file('twitter.yaml')
$client = Twitter::REST::Client.new do |config|
config.consumer_key = yaml["consumer_key"]
config.consumer_secret = yaml["consumer_secret"]
config.access_token = yaml["token"]
config.access_token_secret = yaml["secret"]
end
time = Time.new
month = time.strftime("%B")
day = time.day.to_i
ord_day = if (11..13).include?(day)
"#{day}th"
else
case day % 10
when 1; "#{day}st"
when 2; "#{day}nd"
when 3; "#{day}rd"
else "#{day}th"
end
end
if month != "May" || day != 4
tweet = "#{month} the #{ord_day} be with you.."
$client.update(tweet)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment