yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash
Source and credit: http://stackoverflow.com/a/13612327
yes 'c=(╱ ╲);printf ${c[RANDOM%2]}'|bash
Source and credit: http://stackoverflow.com/a/13612327
I can't believe I've programmed for 15 years without knowing about this.
for (;;) { write-host -n (get-random ╱,╲) }
Obviously this requires a font supporting those characters. MS Mincho seems to serve well: http://www.microsoft.com/typography/fonts/font.aspx?FMID=206
for (;;) { write-host -n (get-random /,\) }
It's kind of nice with _ and | too : for (;;) { write-host -n (get-random '_','|') }wm/sh -c 'load std mpexpr;while{}{unicode -t ${expr 2571 1 rand +}}'
echo "# -*- coding: utf-8 -*-\\nfrom random import choice\\nwhile(True):\\n print(choice(\"╱╲\"), end='')" | python3
or python3 -c 'exec("from random import choice\nwhile(True):\n print(choice(\"╱╲\"), end='"''"')")'
(Oh, the fun of deeply nested quote escaping!)The exec/echo thing being required since we need multiple lines, because while ';' is the statement separator python barfs on "import foo; while (True): pass". Bug or spec?
Only simple statements may be separated by a ';', not compound statements.
This is a bit different than what you wrote. For example, "x=4" is a statement, and not an expression, but "x=4;y=5;z=6" is a valid Python line because assignment is a simple statement, and multiple simple statements may be separated by a ';'.
python3 -c "`echo -e 'import time\nwhile True:\n print(u"\u2571\u2572"[int(time.time() * 100)%2],end="")\n time.sleep(0.001)'`"
The neat thing about it is that the randomness comes from the inexactness of time.sleep python -c "while 1:import sys,random;sys.stdout.write(random.choice('\/'))"
and it's shorter too !echo 'loop do print ["\u2571","\u2572"].sample end'|ruby
echo 'loop do print ["\u2571","\u2572"].sample ; sleep 0.001 end'|ruby
ruby -e 'loop do print ["\u2571","\u2572"].sample ; sleep 0.001 end' ruby -e 'print %W{\u2571 \u2572}.sample while sleep 1e-3'
(Updated: Made 3 chars shorter.)And a shorter, but cheats, version:
yes|ruby -pe'$_=%W{\u2571 \u2572}.sample;sleep 1e-3'
My favorite overall balance of readability and shortness though is: ruby -e 'print %w{╱ ╲}.sample while sleep 0.01'The C64 had magic. I miss my old C64.
Lots of fun. Use it to make old stuff like this feel more authentic, or just run your builds in it and tell your housemates you're haxxing teh gibson.
TBH though the reason it doesn't feel the same is ultimately because you're not the person you were 20-30 years ago, whoever that was. Nothing to do with the code or its execution environment.
|| __ # (2 pipes, one space, 2 bars)
seems to work pretty well, tooperl6 -e 'loop { print <9585 9586>.roll.chr }'
In fact, perl6 -e 'loop { print <╱ ╲>.roll }' will work too if your terminal is set up properly.
I shortened it a bit:
Still not as elegant as the Basic version.
This is one of the big downsides of how javascript is implemented in the browsers these days. There is no simple way to redraw the screen. You have to turn your whole program into a state machine and work with timouts just to display something.
for(i=1;i<300;i++) document.write(i % 30 == 0 ? "<br>" : (Math.random()>0.5) ? '\u2571' : '\u2572');
A throttled run-forever version.
edit, slightly neater:
(function draw(i){ setTimeout(function (){ document.write(i%30==0 ? '<br>' : Math.random()>0.5 ? '\u2571':'\u2572'); draw(i+1); }, 100) }(1))
Beautiful statement. So much unintentional irony, and at the same time so very true in this context.
JS: for(i=0;i<1000;i++) document.write(['\u2571\u200B', '\u2572\u200B'][(Math.floor((Math.random()*2)))])
CSS: body {line-height: 1}
while true; do c=(╱ ╲);printf ${c[RANDOM%2]}; sleep .0001; done