Skip to content

Instantly share code, notes, and snippets.

@creativetechnologist
Created November 6, 2012 15:43
Show Gist options
  • Save creativetechnologist/4025524 to your computer and use it in GitHub Desktop.
Save creativetechnologist/4025524 to your computer and use it in GitHub Desktop.
Simple ruby script to randomly show guitar chords on the terminal to assist with learning/practicing
# Simple Ruby script to dish out pre-defined guitar chords on the terminal to
# assist with learning
# Change these to the chords you want, notice some chords are in here twice;
# this is so it generates twice as many of them as I am/was finding them the
# hardest to navigate to on the fretboard.
trap("SIGINT") { throw :ctrl_c }
CHORDS = ["A","B","C","D","E","F","G","Am","Bm","Cm","Dm","Bm","Cm","Dm","B","Fmaj7"]
INTERVAL_BETWEEN_CHORDS = 3 # In seconds
PREPEND_STRING = "Play: " # What to stick on the front of the chord
def chordlooper
loop do
if RUBY_VERSION < "1.9"
puts "#{PREPEND_STRING}#{CHORDS.choice}"
else
puts "#{PREPEND_STRING}#{CHORDS.sample}"
end
# Wait a bit before the next chord comes up
sleep INTERVAL_BETWEEN_CHORDS
end
end
puts "Ready? #{CHORDS.size} randomly picked chords coming up ... Ctrl-C to exit"
catch :ctrl_c do
chordlooper
end
puts "\nHope that session went well"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment