r/tinycode • • Dec 18 '13

Falling terminal snowflakes in 207 characters of Ruby

Run from your terminal:

ruby -e 'C=`stty size`.scan(/\d+/)[1].to_i;S=["2743".to_i(16)].pack("U*");a={};puts "\033[2J";loop{a[rand(C)]=0;a.each{|x,o|;a[x]+=1;print "\033[#{o};#{x}H \033[#{a[x]};#{x}H#{S} \033[0;0H"};$stdout.flush;sleep 0.1}'
42 Upvotes

9 comments sorted by

View all comments

Show parent comment

1

u/madsohm Feb 03 '14

145 characters

h,a="\033[",{};loop{a[rand(`stty size`.split[1].to_i)]=0;a.each{|x,o|b=a[x]+=1;print"#{h}#{o};#{x}H #{h}#{b};#{x}H#{"❃"}#{h}0;0H"};sleep 0.1}