-
Notifications
You must be signed in to change notification settings - Fork 3
/
update_leaderboard.sh
executable file
·123 lines (95 loc) · 4.47 KB
/
update_leaderboard.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
#!/bin/bash
rm README.md
########
# 2023 #
########
cat << EOF >> README.md
# 🎄 AoC - 2023
Here you can find some solutions to Advent of Code 2023.
| ☃️ | 🧰 | ⭐ |
| :--: | :--: | :-: |
EOF
curl --cookie "session=$COOKIE" -XGET https://adventofcode.com/2023/leaderboard/private/view/1065002.json 2>/dev/null > leaderboard2023.json
data=$(jq '.members | flatten | sort_by(.stars) | reverse | .[] | {name: .name, stars: .stars}' leaderboard2023.json | sed 's/Uri/Adrian-Uri/' | sed 's/calvo111979/anatxiki/' | sed 's/Jesús Arellano/jesusarell/' | sed 's/0rb3/i97orbegozo/')
echo $data | jq -j '.name," ",.stars,"\n"' | \
awk 'BEGIN{
langs["lassa97"] ="*"
langs["vLabayen"] ="Python"
langs["anatxiki"] ="Python"
langs["jartigag"] ="Python"
langs["mariaove"] ="*"
langs["jesusarell"] ="*"
langs["i97orbegozo"]="*"
langs["rubenmate"] ="*"
langs["Adrian-Uri"] ="*"
langs["clarriu97"] ="Python"
}
{print" | [@"$1"](https://github.com/"$1")| ["langs[$1]"](https://github.com/TLMn00bs/advent-of-code/tree/master/"$1") | "$2" |"}' >> README.md
########
# 2022 #
########
cat << EOF >> README.md
# 🎄 AoC - 2022
Here you can find some solutions to Advent of Code 2022.
| ☃️ | 🧰 | ⭐ |
| :--: | :--: | :-: |
EOF
curl --cookie "session=$COOKIE" -XGET https://adventofcode.com/2022/leaderboard/private/view/1065002.json 2>/dev/null > leaderboard2022.json
data=$(jq '.members | flatten | sort_by(.stars) | reverse | .[] | {name: .name, stars: .stars}' leaderboard2022.json | sed 's/Uri/Adrian-Uri/' | sed 's/calvo111979/anatxiki/' | sed 's/Jesús Arellano/jesusarell/' | sed 's/0rb3/i97orbegozo/')
echo $data | jq -j '.name," ",.stars,"\n"' | \
awk 'BEGIN{
langs["lassa97"] ="*"
langs["vLabayen"] ="Python"
langs["anatxiki"] ="*"
langs["jartigag"] ="*"
langs["mariaove"] ="*"
langs["jesusarell"] ="*"
langs["i97orbegozo"]="*"
}
{print" | [@"$1"](https://github.com/"$1")| ["langs[$1]"](https://github.com/TLMn00bs/advent-of-code/tree/master/"$1") | "$2" |"}' >> README.md
########
# 2021 #
########
cat << EOF >> README.md
# 🎄 AoC - 2021
Here you can find some solutions to Advent of Code 2021.
| ☃️ | 🧰 | ⭐ |
| :--: | :--: | :-: |
EOF
curl --cookie "session=$COOKIE" -XGET https://adventofcode.com/2021/leaderboard/private/view/1065002.json 2>/dev/null > leaderboard2021.json
data=$(jq '.members | flatten | sort_by(.stars) | reverse | .[] | {name: .name, stars: .stars}' leaderboard2021.json | sed 's/Uri/Adrian-Uri/' | sed 's/calvo111979/anatxiki/' | sed 's/Jesús Arellano/jesusarell/' | sed 's/0rb3/i97orbegozo/')
echo $data | jq -j '.name," ",.stars,"\n"' | \
awk 'BEGIN{
langs["lassa97"] ="Python (after day 3, using grinch.py to grab solutions from other people)"
langs["vLabayen"] ="Python (Rust a few days later)"
langs["anatxiki"] ="Python (Rust a few days later)"
langs["jartigag"] ="Typescript"
langs["mariaove"] ="Java"
langs["jesusarell"] ="Python"
langs["i97orbegozo"]="Python"
}
{print" | [@"$1"](https://github.com/"$1")| ["langs[$1]"](https://github.com/TLMn00bs/advent-of-code/tree/master/"$1") | "$2" |"}' >> README.md
########
# 2020 #
########
cat << EOF >> README.md
# 🎄 AoC - 2020
Here you can find some solutions to Advent of Code 2020.
| ☃️ | 🧰 | ⭐ |
| :--: | :--: | :-: |
EOF
curl --cookie "session=$COOKIE" -XGET https://adventofcode.com/2020/leaderboard/private/view/1065002.json 2>/dev/null > leaderboard2020.json
data=$(jq '.members | flatten | sort_by(.stars) | reverse | .[] | {name: .name, stars: .stars}' leaderboard2020.json | sed 's/Uri/Adrian-Uri/' | sed 's/calvo111979/anatxiki/' | sed 's/Jesús Arellano/jesusarell/' | sed 's/0rb3/i97orbegozo/')
# fix order:
data=$(echo $data | sed 's/{ "name": "lassa97", "stars": 50 } { "name": "vLabayen", "stars": 50 }/{ "name": "vLabayen", "stars": 50 } { "name": "lassa97", "stars": 50 }/')
echo $data | jq -j '.name," ",.stars,"\n"' | \
awk 'BEGIN{
langs["lassa97"] ="Python"
langs["vLabayen"] ="Python"
langs["anatxiki"] ="Python"
langs["jartigag"] ="Python"
langs["mariaove"] ="Java"
langs["jesusarell"] ="Python"
}
{print" | [@"$1"](https://github.com/"$1")| ["langs[$1]"](https://github.com/TLMn00bs/advent-of-code/tree/master/"$1") | "$2" |"}' >> README.md
rm leaderboard*.json