[Gllug] Hacker Attack, and a wild aside about version-controlled filesystems
ccooke
ccooke-gllug at gkhs.net
Sat Jan 28 11:46:47 UTC 2006
On Thu, Jan 26, 2006 at 09:16:45PM +0000, Tethys wrote:
>
> Nix writes:
>
> >> Z=$[(X=`tput cols`)*(Y=`tput lines`)];O=(X+1 X X-1 1);a(){ for((p=0;p<Z;p++));\
> >> do z=$[y=p/X+1,x=p%X+1,0];q=${B[p]};[ $i ]||B[p]=$[RANDOM%3];for e in ${O[@]} \
> >> ${O[@]//#/-};do(((j=p-e)>0))&&((0${B[j]}&&z++));done;c=\ ;((z==3))&&c=1;((z==2\
> >> ))&&c=$q;echo -ne "\E[$y;${x}H$c";A[p]=$c;done;i=1;B=("${A[@]}");a;};a # ccooke
> >
> >... but now i have to decrypt this.
>
> Interesting... it fills the screen semi-randomly, taking into
> account the contents of the 8 neighbouring character cells. A
It's Conway's Game of Life
> You can perform arithmetic expansion with $[blah] -- I've always used
> $((blah))
The $[] form is deprecated. But it's two bytes shorter, and I needed the
space. There's an interesting effect of $[], also - if you put multiple
expressions seperated by commas inside it, they all get eecuted but the
$[] only evaluates to the *last* expression. Which saves quite a few
bytes...
> You can use # and % as anchors in string substitution (c.f. ^ and $ in
> standard regular expressions)
Shell is actually one of the easiest languages to make self modifying
code in. For instance:
function hello
{
echo "hello world"
}
H="$( typeset -f hello )"
eval "${H//hello/goodbye}"
goodbye
(It's actually possible to use this to improve readability, even...)
(Damn, now I have to try to remember which ones I've already used)
--
for((P=10**8,Q=P/100,X=320*Q/(`tput cols`-1),Y=210*Q/`tput lines`,y=-105*Q,v=-2\
20*Q,x=v;y<105*Q;x=v,y+=Y));do for((;x<P;a=b=i=k=c=0,x+=X));do for((;a*a+b*b<2*\
P*P&&i++<99;a=((c=a)*a-b*b)/P+x,b=2*c*b/P+y));do :;done;(((j=(i<99?i%16:0)+30)>\
37?k=1,j-=8:0));echo -ne "\E[$k;$j"mE;done;echo -e \\E[0m;done # Charles Cooke
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list