Skip to content

Instantly share code, notes, and snippets.

@Zettt
Created November 11, 2011 12:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Zettt/1357853 to your computer and use it in GitHub Desktop.
Save Zettt/1357853 to your computer and use it in GitHub Desktop.
Show random idiom on desktop using GeekTool
srand # seed random
require 'csv'
wordArray = Array.new
definitionArray = Array.new
if File.exists?("/Users/zettt/Archive/Vocab/idioms.csv")
CSV.open('/Users/zettt/Archive/Vocab/idioms.csv', 'r') do |row|
# p row[1]
wordArray = wordArray.push(row[0])
definitionArray = definitionArray.push(row[1])
end
else
puts "csv file not found. Ending process."
Process.exit
end
randomLine = rand(wordArray.length)
puts "Idioms"
puts "Word: " + wordArray[randomLine]
puts "Definition: " + definitionArray[randomLine]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment