Skip to content

Instantly share code, notes, and snippets.

@mdusher
Created July 19, 2018 03:24
Show Gist options
  • Save mdusher/f972b25331871e4feb7b3ae4adbd4ae7 to your computer and use it in GitHub Desktop.
Save mdusher/f972b25331871e4feb7b3ae4adbd4ae7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'twitter'
client = Twitter::REST::Client.new do |config|
config.consumer_key = ""
config.consumer_secret = ""
config.access_token = ""
config.access_token_secret = ""
end
lyrics = [
"Safety!",
"Safety-dance!",
"Ah we can dance if we want to, we can leave your friends behind",
"Cause your friends don't dance and if they don't dance",
"Well they're are no friends of mine",
"I say, we can go where we want to, a place where they will never find",
"And we can act like we come from out of this world",
"Leave the real one far behind,",
"And we can dance",
"We can dance if we want to, we can leave your friends behind",
"Cause your friends don't dance and if they don't dance",
"Well they are no friends of mine",
"I say, we can go where we want to a place where they will never find",
"And we can act like we come from out of this world",
"Leave the real one far behind",
"And we can dance.",
"Dances!",
"Ah we can go when we want to the night is young and so am I",
"And we can dress real neat from our hats to our feet",
"And surprise 'em with the victory cry",
"I say we can act if want to if we don't nobody will",
"And you can act real rude and totally removed",
"And I can act like an imbecile",
"I say we can dance, we can dance everything out control",
"We can dance, we can dance we're doing it wall to wall",
"We can dance, we can dance everybody look at your hands",
"We can dance, we can dance everybody takin' the chance",
"Safety dance",
"Oh well the safety dance",
"Ah yes the safety dance",
"Safety",
"Safety-dance",
"We can dance if we want to, we've got all your life and mine",
"As long as we abuse it, never gonna lose it",
"Everything'll work out right",
"I say, we can dance if we want to we can leave your friends behind",
"Cause your friends don't dance and if they don't dance",
"Well they're are no friends of mine",
"I say we can dance, we can dance everything out of control",
"We can dance, we can dance we're doing it wall to wall",
"We can dance, we can dance everybody look at your hands",
"We can dance, we can dance everybody's takin' the chance",
"Oh well the safety dance",
"Ah yes the safety dance",
"Oh well the safety dance",
"Oh well the safety dance",
"Oh yes the safety dance",
"Oh the safety dance yeah",
"Oh it's the safety dance",
"It's the safety dance",
"Well it's the safety dance",
"Oh it's the safety dance",
"Oh it's the safety dance",
"Oh it's the safety dance",
"Oh it's the safety dance"
]
def get_tracker_file
current_dir = File.dirname(__FILE__) # Working directory
tracker_file = File.join(current_dir, "safetydance.tracker") # File for storing last array key
File.new(tracker_file, "w") if !File.exists?(tracker_file)
tracker_file
end
def update_tracker(value=0)
file = get_tracker_file
File.open(file, "w+") { |f| f.write(value) }
end
def get_tracker
file = get_tracker_file
value = File.open(file) { |f| f.gets }
value = 0 if value.nil?
value.to_i
end
loop do
key = get_tracker
key = 0 if lyrics[key].nil?
line = lyrics[key]
client.update line
puts "Tweeted: #{line}"
update_tracker(key+1)
sleep 10800 # 3 hours
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment