From b52bb37f1446b8feb3934d1207da21ffd4fd637c Mon Sep 17 00:00:00 2001 From: David Timber Date: Mon, 11 Nov 2024 23:43:40 +0100 Subject: To the moooooon! --- .github/workflows/scheduled-tasks.yml | 18 ++++++++++++++++ README.md | 5 +++++ viewcount-tothemoooon/vc-thm | 40 +++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 .github/workflows/scheduled-tasks.yml create mode 100644 README.md create mode 100755 viewcount-tothemoooon/vc-thm 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?"
+> "I shitcode."
+> "... you mean shitposting?"
+> "NO ...?"
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 [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 -- cgit