· 8 years ago · Feb 20, 2018, 11:13 PM
1# mkxmas.rb
2
3template = <<EOF
4s="*****************************************
5********************************************
6**** * * * * ****
7**** * * ** * * ****
8**** * * **** * * ****
9**** * * ****** * * ****
10**** * ******** * ****
11**** * * ********** * * ****
12**** * ************ * ****
13**** * ************** * * ****
14**** * **************** * ****
15**** * ****************** * ****
16**** * ********** * ****
17**** * * ************ * * ****
18**** * ************** * ****
19**** * **************** * ****
20**** * ****************** * ****
21**** * ******************** * ****
22**** ********************** * ****
23**** * ************************ * ****
24**** * **************** * ****
25**** * ****************** * ****
26**** * ******************** * ****
27**** * ********************** * ****
28**** ************************ ****
29**** * ************************** * ****
30**** **************************** ****
31**** ****************************** * ****
32**** ******************************* ****
33**** * * ****** * * ****
34**** * ****** * * ****
35**** * * ****** * * ****
36**** * ****** * * ****
37**** * * ****** * * ****
38**** * * * * ****
39******************************************##
40### Copyright (C) 2004 Christian Neukirchen
41EOF
42
43code = <<'EOF'
44# Thanks for looking at my code.
45#
46# Copyright (C) 2002, 2004 Christian Neukirchen <chneukirchen / gmail.com>
47#
48# This program is free software; you can redistribute it and/or
49# modify it under the terms of the GNU General Public License.
50
51STDOUT.sync = true
52d1, d2 = 0.15, 0.06
53s = "Merry christmas, ... and a happy new year"
54m = %w{, . : ! + * 0 O @}
55u = " " * s.size
56
57print "\r #{u}\r";
58
59(0..(s.size-1)).to_a.sort_by { rand }.each { |r|
60 sleep d1
61 next if s[r] == " "[0]
62 m.each { |k|
63 u[r] = k
64 print " #{u}\r"
65 sleep d2
66 }
67 u[r] = s[r]
68 print " #{u}\r"
69}
70
71sleep d2
72print " #{u}!\r";
73sleep 3
74print " #{u}! --chris2\n";
75
76# filler space ########################
77EOF
78
79hexcode = [code].pack("m*").delete("\n")
80
81footer = '";eval s.delete!(" \\n").unpack("m*")[0]'
82
83hexcode += footer
84
85hcnt = 0
860.upto(template.size) { |tcnt|
87 if template[tcnt] == ?* && hcnt < hexcode.size
88 template[tcnt] = hexcode[hcnt]
89 hcnt += 1
90 end
91}
92
93puts template