Skip to content

Instantly share code, notes, and snippets.

@dragonfax
Created May 1, 2013 22:12
Show Gist options
  • Save dragonfax/5498799 to your computer and use it in GitHub Desktop.
Save dragonfax/5498799 to your computer and use it in GitHub Desktop.
quick ruby one liner to rotate banner'ed text
rotated = []
y = 0
`banner -w 30 W T F`.split("\n").each { |line|
x = 0
line.each_char { |char|
rotated[x] ||= []
rotated[x][y] = char
x += 1
}
y += 1
}
puts rotated.reverse.map { |line|
line.map!{ |char| char || ' '}
line.join('')
}.join("\n")
Some version of banner will rotate the text for you. The version provided by osx doesn't. So I whipped this up. I've made no attempt to simplify, optimize, or make it pretty. Its one-time use.
But you should really be using figlets.
[31] pry(main)> rotated = []; y = 0; `banner -w 30 W T F`.split("\n").each { |line| x = 0; line.each_char { |char| rotated[x] ||= []; rotated[x][y] = char; x += 1 }; y += 1}; puts rotated.reverse.map { |line| line.map!{ |char| char || ' '}; line.join('') }.join("\n")
#### ### ########## ##########
## # ## ## # ## ##
## ## ## # ## #
## # # ## # ## #
## # ## ##
### # ## ##
## # ## ##
## # ## ## #
## # # ## #######
## # # ## ## ##
### ## # ## ## #
## ### ## ##
## #### ## ##
## #### ## ##
### ### ## ##
## ### ## ##
## ## ## ##
## # ## ##
# # ## ##
# # ## ##
# #### ####
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment