Skip to content

Instantly share code, notes, and snippets.

@nitschmann
Created October 17, 2013 09:19
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 nitschmann/7021786 to your computer and use it in GitHub Desktop.
Save nitschmann/7021786 to your computer and use it in GitHub Desktop.
This is a sample for an endless matrix output in green for your console in Ruby
class String
# Print a String in a specfic color
def colorize(text, color_code)
"#{color_code}#{text}\e[0m"
end
# Green String
def green
colorize(self, "\e[1m\e[32m")
end
end
require "matrix"
while true
matrix_array = []
for i in 1..5
m = Matrix.build(1) { rand }
matrix_array << m.first
end
puts "#{matrix_array.join("\t")}".green
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment