-
Notifications
You must be signed in to change notification settings - Fork 0
/
pixelart.rb
executable file
·63 lines (49 loc) · 1.53 KB
/
pixelart.rb
1
2
3
4
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env ruby
require 'date'
require 'securerandom'
SUBVERSIVE_MESSAGE = "
#### ### ### ## ## #### ##### #### # #### #
# # # # # # # # # # # # # # # # #
### ##### # # # # # ### # # # # # #
# # # # # # # # # # # # # #
### # # ### # # #### # # # # #### #
"
def main
Dir.chdir(File.dirname(__FILE__))
root_commit = `git rev-list HEAD --reverse | head -1`.chomp
system("git", "reset", "--hard", root_commit)
start = Date.today - 365
while start.wday > 0
start -= 1
end
# light flood fill
# (start..Date.today).each do |day|
# (rand(5) + 1).times do
# nonce = SecureRandom.hex
# File.write(File.join(File.dirname(__FILE__), "README.txt"),
# nonce)
# system("git", "add", "README.txt")
# system("git", "commit", "-m", nonce, "--date", day.strftime)
# end
# end
# subversive message
grid = SUBVERSIVE_MESSAGE.chomp.split("\n").drop(1).map {|r| r.split("")}
rows = 7
cols = 51
day = start
cols.times do |col|
rows.times do |row|
if grid[row][col] == '#'
45.times do
nonce = SecureRandom.hex
File.write(File.join(File.dirname(__FILE__), "README.txt"),
nonce)
system("git", "add", "README.txt")
system("git", "commit", "-m", nonce, "--date", day.strftime)
end
end
day += 1
end
end
end
main