Created
January 24, 2018 00:11
-
-
Save peterc/03b3c036ac59992185ddd29062007978 to your computer and use it in GitHub Desktop.
random_giveaway.rb: Spin through some twitter handles and pick a winner
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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