-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgreen_squares.sh
executable file
·163 lines (140 loc) · 4.03 KB
/
green_squares.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/usr/bin/env bash
# automate a bunch of bogus commits and backdate them to turn all the squares green...
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
GRAFITTI_DESIGN=$(ruby -e " string_w_newlines = '99999900000033333366666699999900000033333366666699999999900000033333366666699999900000033333366666699999999900000033333366666699999900000033333366666699999999900000033333366666699999900000033333366666699999909900000033333366666699999900000033333366666699999900900000033333366666699999900000033333366666699999900000000033333366666699999900000033333366666699999000000'
height = 7 # days
width = 52 # weeks
in_string = string_w_newlines.gsub(/\n/, '')
out_string = in_string.clone
width.times do |ww|
height.times do |hh|
out_string[height * ww + hh] = in_string[width * hh + ww]
end
end
puts out_string += '1111111' # add a couple extra days for in progress week
")
if [[ "${#@}" -lt 2 ]]; then
echo " ##"
echo " # Please add at least 2 args"
echo " # 1 github username"
echo " # 2 repo name"
echo " # 3 (optional) dryrun - DON'T create repo and push to github "
echo " # "
echo " # usage:"
echo " # $ ./green_squares.sh <github username> <repo name> [dryrun]"
echo " ##"
exit
fi
USERNAME="$1"
REPONAME="$2"
DRYRUN="$3"
if [[ "$DRYRUN" ]]; then
echo "dryrun -- NOT creating repo on github"
UNIXTIME=1487739600 # Feb 22, 2018 I think; no particular reason for this default
else
echo "creating repo on github"
# create repo on github
DATA_OPTS="{ \"name\":\"$REPONAME\" }"
curl -i -X POST -u "$USERNAME" -d "$DATA_OPTS" https://api.github.com/user/repos > /dev/null
# scrape the date of last green square
ayearago=$(curl https://github.com/"$USERNAME" |grep -m1 data-date= |sed -e 's/^.*date="//p')
year="${ayearago:0:4}"
day="${ayearago:8:2}"
month="${ayearago:5:2}"
case $month in
01)
monthstr="Jan"
;;
02)
monthstr="Feb"
;;
03)
monthstr="Mar"
;;
04)
monthstr="Apr"
;;
05)
monthstr="May"
;;
06)
monthstr="Jun"
;;
07)
monthstr="Jul"
;;
08)
monthstr="Aug"
;;
09)
monthstr="Sep"
;;
10)
monthstr="Oct"
;;
11)
monthstr="Nov"
;;
12)
monthstr="Dec"
;;
esac
UNIXTIMEAYEARAGO=$(date -j -f "%b %d %Y %T" "${monthstr} ${day} ${year} 12:00:00" "+%s")
# #UNIXTIMERIGHTNOW=$(date -j -f "%a %b %d %T %Z %Y" "`date`" "+%s")
# # $ date -j -f "%b %d %Y %T" "Apr 05 2016 00:00:00" "+%s"
UNIXTIME=$UNIXTIMEAYEARAGO
echo "$UNIXTIMEAYEARAGO"
fi
mkdir ../"$REPONAME" || exit
cd ../"$REPONAME"
rm -rf unixtime
rm -rf .git
git init
git add .
git commit -m "initial commit of the script responsible for drawing pictures with green squares"
rewriteHistory() {
for i in $(seq 1 ${#GRAFITTI_DESIGN}); do
touch "$i-file"
done > /dev/null
WORKING=true
for i in $(seq 1 ${#GRAFITTI_DESIGN}); do
INNERLOOP="${GRAFITTI_DESIGN:i-1:1}"
for j in $( seq 1 $(($INNERLOOP * 4)) ); do
echo 'square $j' >> "$i-file"
git add .
git commit -m "commit number $i : $j"
COMMITTIME=$(($UNIXTIME + $j * 10))
git commit --amend --no-edit --date "$COMMITTIME"
wait
done
wait
# 86400 seconds in a day
UNIXTIME=$(($UNIXTIME + 86400))
done > /dev/null
WORKING=false
}
git commit --amend --no-edit --date "$(date -j -f "%b %d %Y %T" "Feb 28 2020 11:08:19" "+%s")"
UNIXTIMEAYEARAGO=$(date -j -f "%b %d %Y %T" "Feb 23 2020 12:00:00" "+%s")
# whistleWhileYouWork() {
# WORKCOUNT=1
# echo
# while $WORKING; do
# seq -s~ $WORKCOUNT|tr -d '[:digit:]'
# echo -ne "|\r"
# sleep 1
# ((WORKCOUNT+=1))
# done
# }
mkdir unixtime
cd unixtime || exit
touch something
rewriteHistory # & TODO: get the background process of this to work so that we can whistle while we work!
# whistleWhileYouWork
if [[ "$DRYRUN" ]]; then
git remote add origin [email protected]:"$USERNAME"/"$REPONAME".git
git push -u origin master
wait
open "https://github.com/$USERNAME"
fi
echo 'done'
# http://vipyne.tumblr.com/post/155636272150/insert-back-to-the-future-joke-here