Created
December 20, 2012 09:04
-
-
Save artm/4344001 to your computer and use it in GitHub Desktop.
remake with uglified ruby oneliner (ruby 1.8.x and 1.9.x compatible)
This file contains hidden or 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
# reverse engineering gawk code | |
{ | |
rnd_column = $3; # comes from bash $(($RANDOM%$COLUMNS)) | |
snow = $4; # comes from bash $(printf "\u2743\n") | |
snow_progress[ rnd_column ] = 0; | |
for(row in snow_progress) { | |
old_col = snow_progress[row]; | |
snow_progress[row] = snow_progress[row] + 1; | |
# erase snowflake at previous position | |
printf "\033[%s;%sH ",old_col,row; | |
# draw snowflake at new position | |
printf "\033[%s;%sH%s \033[0;0H",snow_progress[row],row, snow; | |
} | |
} |
This file contains hidden or 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
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} |
This file contains hidden or 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
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}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cool rework!
and just to mention the original: http://climagic.org/coolstuff/let-it-snow.html