aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rwxr-xr-xaoc35
-rwxr-xr-xaocd13
3 files changed, 36 insertions, 14 deletions
diff --git a/Makefile b/Makefile
index f97e502..af98d4b 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
1PREFIX = /usr/local 1PREFIX = /usr/local
2 2
3SCRIPTS = 2fa \ 3SCRIPTS = 2fa \
4 aocd \ 4 aoc \
5 battery-checknow \ 5 battery-checknow \
6 battery-status \ 6 battery-status \
7 clip \ 7 clip \
diff --git a/aoc b/aoc
new file mode 100755
index 0000000..56da404
--- /dev/null
+++ b/aoc
@@ -0,0 +1,35 @@
1#!/bin/sh
2
3# Set up a working environment for Advent of Code (https://adventofcode.com/).
4# Requires tmux, lynx, curl and a valid AOC_SESSION_COOKIE session cookie.
5
6# usage: aoc [yyyy nn]
7# If yyyy (year) and nn (day, with leading zero if single digit) are not
8# specified, the current year and day are used.
9
10editor="vi a.py"
11basedir="$HOME/src/aoc"
12lynx_cookie_file="$(mktemp)"
13clibrowser="lynx -cookie_file=$lynx_cookie_file"
14
15year="${1:-$(date +'%Y')}"
16day="${2:-$(date +'%d')}"
17daynozero="$(echo "$day" | sed 's/^0//')"
18
19cd "$basedir/$year/$day"
20
21# Download the puzzle input and save it to input.txt
22url="https://adventofcode.com/$year/day/$daynozero/input"
23curl "$url" -H "cookie: session=$AOC_SESSION_COOKIE" -o input.txt
24
25# Open a tmux session with lynx in its own windows, and an editor and a
26# terminal in split view.
27printf 'adventofcode.com\tFALSE\t/\tTRUE\t2079722976\tsession\t%s' \
28 "$AOC_SESSION_COOKIE" > "$lynx_cookie_file"
29url="https://adventofcode.com/$year/day/$daynozero"
30tmux new-session \; \
31 send-keys "$editor" C-m \; \
32 split-window -h \; \
33 select-pane -t 0 \; \
34 new-window \; \
35 send-keys "$clibrowser $url" C-m \;
diff --git a/aocd b/aocd
deleted file mode 100755
index cab4060..0000000
--- a/aocd
+++ /dev/null
@@ -1,13 +0,0 @@
1#!/bin/sh
2
3# Download input from the Advent of Code website (https://adventofcode.com/).
4# Requires setting an AOC_SESSION_COOKIE variable with a valid session cookie.
5
6# usage: aocd [year n]
7# If year and n are not specified, the current year and day are used.
8
9YEAR="${1:-$(date +'%Y')}"
10DAY="${2:-$(date +'%d' | sed 's/^0//')}"
11URL="https://adventofcode.com/$YEAR/day/$DAY/input"
12
13curl "$URL" -H "cookie: session=$AOC_SESSION_COOKIE" -o input.txt

Generated with cgit - Back to sebastiano.tronto.net