scripts

+1
scripts/README.md
···
+
For want of a better place, and as they often rely on system configutration, e.g. `/etc/hosts/`/`~/.ssh/`.
+3
scripts/gitlab_proxy.sh
···
+
#!/bin/sh
+
+
ssh -D 8123 -f -C -q -N rtg2@rtg2.host.cs.st-andrews.ac.uk
+12
scripts/socs_mc/process_signups.sh
···
+
infile=${1:-$(dirname $0)/signups.xlsx}
+
outfile=$(dirname $0)/signups.csv
+
remote_file='~/allowlist_management/signups.csv'
+
remote_command='~/allowlist_management/update_allowlist.sh'
+
+
echo "Converting to CSV..."
+
sudo ssconvert "$infile" "$outfile"
+
echo "Copying to remote..."
+
scp -J rtg2@rtg2.host.cs.st-andrews.ac.uk "$outfile" minecraft@mcse.cs.st-andrews.ac.uk:"$remote_file"
+
echo "Updating allowlist..."
+
ssh -J rtg2@rtg2.host.cs.st-andrews.ac.uk minecraft@mcse.cs.st-andrews.ac.uk "$remote_command"
+
echo "Done"
+3
scripts/socs_mc/proxy.sh
···
+
#!/bin/sh
+
+
ssh rtg2@rtg2.host.cs.st-andrews.ac.uk -L 25565:mcse.cs.st-andrews.ac.uk:25565 -N
+8
scripts/switch_nw.sh
···
+
#!/bin/bash
+
+
nmcli con up "$1"
+
+
sleep 60
+
+
systemctl restart ddclient
+
+50
scripts/wordcount_progress.sh
···
+
#!/usr/bin/env bash
+
+
cd "$1"
+
+
log="$(git log --pretty=format:'%h %ad' --date=iso-strict)"
+
+
prev_hash="$(git status | head -1 | awk '{print($NF) }')"
+
+
echo "wordcount,timestamp" > wordcounts.csv
+
while IFS= read -r line; do
+
hash="$(echo "$line" | awk '{print $1}')"
+
time="$(echo "$line" | awk '{print $2}')"
+
git checkout "$hash" || exit 1
+
wordcount="$(texcount -merge -sum -q -1 ${3:-main.tex})"
+
if [ ! -z $wordcount ]; then
+
echo "$wordcount,$time" >> wordcounts.csv
+
fi
+
if [ "$hash" == "$2" ]; then break; fi
+
done <<< "$log"
+
+
git checkout "$prev_hash" | exit 1
+
+
echo "
+
import csv
+
from datetime import datetime
+
import numpy as np
+
import matplotlib.pyplot as plt
+
import matplotlib.dates as dates
+
+
with open('wordcounts.csv') as file:
+
data = [row for row in csv.reader(file)][1:]
+
+
timestamps=[datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S%z') for wordcount, timestamp in data]
+
wordcounts=[int(wordcount) for wordcount, timestamp in data]
+
+
start=datetime.combine(datetime.date(min(timestamps)), datetime.min.time()).timestamp()
+
end=max(timestamps).timestamp() + 60*60*24
+
increment=60*60*6
+
+
plt.figure(figsize=(12, 4))
+
#plt.xticks([datetime.fromtimestamp(t) for t in np.arange(start, end, increment)])
+
#plt.gca().xaxis.set_major_formatter(dates.DateFormatter('%Y-%m-%d %H:%M'))
+
#plt.gcf().autofmt_xdate()
+
#plt.gcf().subplots_adjust(bottom=0.25)
+
plt.plot(timestamps, wordcounts)
+
+
#plt.xticks(rotation=45)
+
plt.xlabel('timestamp')
+
plt.ylabel('wordcount')
+
plt.savefig('wordcounts.pdf')" | python3