aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Timber <dxdt@dev.snart.me>2024-11-11 23:43:40 +0100
committerDavid Timber <dxdt@dev.snart.me>2024-11-12 00:42:30 +0100
commitb52bb37f1446b8feb3934d1207da21ffd4fd637c (patch)
tree0399a4f64c620fcd7180d4cbfd252b73c4c57994
To the moooooon!
-rw-r--r--.github/workflows/scheduled-tasks.yml18
-rw-r--r--README.md5
-rwxr-xr-xviewcount-tothemoooon/vc-thm40
3 files changed, 63 insertions, 0 deletions
diff --git a/.github/workflows/scheduled-tasks.yml b/.github/workflows/scheduled-tasks.yml
new file mode 100644
index 0000000..e392992
--- /dev/null
+++ b/.github/workflows/scheduled-tasks.yml
@@ -0,0 +1,18 @@
+name: Shitcoding
+run-name: Running scheduled tasks
+on:
+ schedule:
+ - cron: '*/5 * * * *'
+ workflow_dispatch:
+jobs:
+ Do-snapshot:
+ name: "vc-thm"
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v3
+ - name: Run vc-thm
+ run: |
+ ./viewcount-tothemoooon/vc-thm 'https://okky.kr/articles/1519671' &
+ ./viewcount-tothemoooon/vc-thm 'https://okky.kr/articles/1519674' &
+ wait
+ wait
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0db3d7b
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
+# Shitcoding
+> "What do you do for fun?"<br>
+> "I shitcode."<br>
+> "... you mean shitposting?"<br>
+> "NO ...?"<br>
diff --git a/viewcount-tothemoooon/vc-thm b/viewcount-tothemoooon/vc-thm
new file mode 100755
index 0000000..d285edf
--- /dev/null
+++ b/viewcount-tothemoooon/vc-thm
@@ -0,0 +1,40 @@
+#!/bin/bash
+declare -r ARGV0='vc-thm'
+
+pull_url () {
+ local i=0
+
+ echo -n "$ARGV0: " >&2
+ while true
+ do
+ sleep 0.5 & # limit rate to one per 500 ms
+
+ curl -sSL "$1" > /dev/null
+ wait
+
+ let 'i += 1'
+ echo -n "$i " >&2
+ done
+}
+
+if [ -z "$1" ]; then
+ echo "Usage: $ARGV0 <URL> [TIMEOUT]" >& 2
+ exit 2
+fi
+
+# https://docs.github.com/en/actions/writing-workflows/choosing-when-your-workflow-runs/events-that-trigger-workflows#schedule
+# > The shortest interval you can run scheduled workflows is once every 5 minutes.
+[ -z "$2" ] && TIMEOUT=270 || TIMEOUT="$2"
+
+
+set -e
+pull_url "$1" &
+CHILD="$!"
+sleep "$TIMEOUT"
+set +e
+
+kill -TERM "$CHILD"
+wait
+echo >&2
+
+exit 0 # don't care about the exit code from pull_url