Skip to content

Instantly share code, notes, and snippets.

@peterc
Created January 24, 2018 00:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterc/03b3c036ac59992185ddd29062007978 to your computer and use it in GitHub Desktop.
Save peterc/03b3c036ac59992185ddd29062007978 to your computer and use it in GitHub Desktop.
random_giveaway.rb: Spin through some twitter handles and pick a winner
# Given a list of items in the 'entries' array, it'll spin through
# some random ones before settling on a "winner" which flashes.
# Yes, the code is terrible, I threw it together on the fly for a Twitter giveaway!
# See https://twitter.com/peterc/status/955955015126003712 for example
# Only dependency is curses, via "gem install curses"
require 'curses'
include Curses
init_screen
curs_set(0)
entries = %w{
put your
entries here
}
def write_person(user)
erase
setpos(5, 5)
addstr(user.center(16))
refresh
end
30.times do
write_person(entries.sample)
sleep 0.1
end
attron(A_REVERSE)
attron(A_BLINK)
write_person(entries.sample)
attroff(A_REVERSE)
attroff(A_BLINK)
getch
close_screen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment