Skip to content

Instantly share code, notes, and snippets.

@colrichie
Created August 25, 2012 10:55
Show Gist options
  • Save colrichie/3463663 to your computer and use it in GitHub Desktop.
Save colrichie/3463663 to your computer and use it in GitHub Desktop.
Yamanote Quine
#! /bin/sh
# This source code should be viewed and run with
# more than 58 chars width and more than 100 lines height.
# 10 20 30 40 50
# -------+---------+---------+---------+---------+-------|
#
# The original code is exposed at
# http://www.slideshare.net/mametter/ruby-2012
case "$1" in
[Rr][Ee][Vv]*)
opt='- rev'
;;
*)
opt='-'
;;
esac
num=0
tmp=/tmp/yamanote-quine.$$
trap "rm -f $tmp.$num $tmp.$((1-num));exit" EXIT 1 2 3 15
cat <<'RUBYCODE' | tee $tmp.$num > /dev/stdout
t="+,m-n./mAm0o1p23a4q56r7sBt89u-t-1:v;A<w4x=y1z>[?]A^@CD_
CD_EsF`GHmIJbKa*l";eval$s=%w{F=%q{ceY8#<DvO1=x&t9CSOqMYkzH
U.kCpz+Vo8hB.1AF&tq21+$/IrMY]U.aDd!-1y!4MMGQm6m?bYh($QMYpX
s4g,x1UlbNKH?>NzbisMn?sT@m3,F.Abb`xW!r%'%Ybee>xkUfjf[(*^Nd
Xo_"@hQh%Fx*q[iB7EM"suSG8GVOIzceg/O=4CL,d[-k]twgVP`&wcfaT`
2M)j8sFY?(HKzOrVCHO_694[Uq8g @i/i;tMBG#;-;B]rV[])`3'<os^.
OV(SA<=ok%m[iV#qt[&dJ7SIdB;/ VUnVIrH;hEJ*QWD"E+5)gfrmD"#E
XlNVv1j)^^ bCi_gw+s-V
J<?fWdtbnxRgJm4J.yHO_ay2e%rc Tj]ALVU'`V=]]W;x&9MP&g5zAVHR
?B,SZA+!_[0f!TUCv$Hin?-G7hAL BW6w1x+F#%@FZ<7!9;vNxsj6HW_O
Ao)H5cv`Ves-BQ"Z =K$_[o]Can(;1cJp
HV<:4x2,AnZgqvsy >VWDZdF-+^ 46Z^Z@<>1< cJ3E4GYSqGg7$ocX
88=*`RVO*WskDY-# uj$t3$XP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!YN!hK?1a,2UMJ^`IC)oc8Z/TipLWy(%p0qUZoO
;W#bB%8=9CZvoU$eG;kXt[hewZnV!(B(u-[L3)l,6C%3.?u?znQyMgw31s
[s4Ne+XNPNcpmuaJ<] Hd:/;va-yp4)mU.&Vr
Z@*N3mTZX)0]%^]0d6 a'@njg`2DJ;stf^WTr 3y%gWte5;+Q>ZbENlv
rK!4M=y6IQ27&IJm>n w57+;)s=Foy<4pdw5i lSDhJRyao%_Wx+[lx6
D8Goea3uRPpunFulWq 0*3GoGaJyAHF$#bJca 5&Z0K'r[o,K*"/^jv6
m08,PTZy$g?eX[aN4j J]AkXcV72;!};f=0;F .unpack("C*").map{
|c|f=f*89+((c-2)%9 0-1)};require'zlib
';t=t.split*"";$*[0]?(t[/([* -K]+.)([*-K]+.)$/];t=$2+$`+s
=$1):(s=t[/.+?[L-z]/];t=$'+s );f=Zlib::Inflate.inflate(Ma
rshal.dump(f)[7..-1] );S=%{ t="# {t}";eval$s=%w{#$s}*
"";%|}+F*9;P=proc{pu ts(S.s lice!(0, 58));P};P[][][][s.
upcase.unpack("C*" ).map{|c |c-=c>92?4 3:42;;P[][][20.t
imes{|n|puts(("% 029b"%("\0 "+f[60*c+3*n ,3]).unpack("N
")[0]).gsub( /./){$&<"1"? (S.slice!(0,2) ):(32.chr*2)
})}]}][];puts(*["+"+"-"* 25,"|,##,(c),Yusuke,Endoh,20
09".split(",").join(32.chr)].map{|l|S.slice!(0,32)+l})}*""
;%|ceY8#<DvO1=x&t9CSOqMYkzHU.kCpz+Vo8hB.1AF&tq21+$/IrMY]U.
aDd!-1y!4MMGQm6m?bYh($QMYpXs4g,x1UlbNKH?>NzbisMn?sT@m3,F.A
bb`xW!r%'%Ybee>xkUfjf[(*^NdXo_"@+-------------------------
hQh%Fx*q[iB7EM"suSG8GVOIzceg/O=4| ## (c) Yusuke Endoh 2009
RUBYCODE
while true; do
sleep 1
cat $tmp.$num |
ruby $opt |
tee $tmp.$((1-num)) > /dev/stdout
num=$((1-num))
done
#! /bin/sh
# This source code should be viewed and run
# with more than 164 chars width and more than 15 lines height.
# 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160
# -------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---|
#
# The original code is exposed at
# http://www.slideshare.net/mametter/ruby-2012
case "$1" in
[Rr][Ee][Vv]*)
opt='- rev'
;;
*)
opt='-'
;;
esac
num=0
tmp=/tmp/yamanote-quine.$$
trap "rm -f $tmp.$num $tmp.$((1-num));exit" EXIT 1 2 3 15
cat <<'RUBYCODE' | tee $tmp.$num > /dev/stdout
z=27;eval$s=%w!c,s=["H+{K}8k->dXNpv-cD~@?(zhAi~>JOv<-;A(]oH+MFKs*+KOB825i$%QX9~P=HC{iIlj*Sh#
v=3U62LhUXhtnCx^{F=nuTtGG}@85_(xVvIWQ|Vllp[Gt22x&`^K3*ui;IW@O9-(`Z6V_T.E]%WHXYGa{O9A#msMgV{5
R3XS/dxI8zM)XrbFom,$Msj8>=ca#i.yOqM-gtf2xH T#2VYW9Koq.)IjS:&n3f6$Q/@4-8m_[(HxaP>n*b]Ih/3`3T
uG-C~3Bn)d.PSdX8 uvtft?;j%bsM^v&h NcaFzv7)uyD=lkc+eYn5&dN/%.|o@pD|BPi+a`rJCgg>?AE;
W~){4l9}","_m?PM(N5L <',.ht}f8B|*o8|Qg?:v '(@LY'1^KvIm8twKZHvU@:&FS)r[N1?t9k26*=tiLQw<Tq$l
]V1@Z3hnQ:cQ'b)>])-p }r'U[8hN 7`j6SW r-ZW m2 3n<ZaJ %C%g @@+DABEERjKj5Yt~&>xL
~8BN`L#u?tE+CH$wM%*J px[D;A t%se'c waI. R; FIn( VUVq{0 6c Y]'1EV sqNd_V1yp8"].map{|
s|n=0;s.unpack("C*") .map{| c|n=n* 91+( c-1)%9 2};n}; e= "z=#{z =($*[i=0]?(z+1):z-
1)%29};eval$s=%w"<<3 3<<$s[ 0,903] *3;1 4. time s{|y|b =" ";n=f= proc{|w|b<<e[i,w];
i+=w};t=s;f[4];z.dow nto(0){| a|a<1& &6.t imes {|x| y>1&&y<12&&c[n*60+y*
6-x-67]>0?(b<<32<<32):f[2]}while(0<n=(t/=38)%38)};f[4];y>12& &b[-28,28]=""<<33<<"*''#..(c).
Yusuke.Endoh.2010";puts(b)}#c,s=["H+{K}8k->dXNpv-cD~@? (zhAi~>JOv<-;A(]oH+MFKs*+KOB825i
$%QX9~P=HC{iIlj*Sh#v=3U62LhUXhtnCx^{F=nuTtGG}@85_(xVvIWQ|Vllp[Gt22x&`^K3*ui;IW@O9-(`Z6V_T.E]
%WHXYGa{O9A#msMgV{5R3XS/dxI8zM)XrbFom,$Msj8>=ca#i.yOqM-gtf2xHT#2!*''#..(c).Yusuke.Endoh.2010
RUBYCODE
while true; do
sleep 1
cat $tmp.$num |
ruby $opt |
tee $tmp.$((1-num)) > /dev/stdout
num=$((1-num))
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment