diff --git a/README.md b/README.md index 620fca2..472cfe2 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,16 @@ # snippets -slonked up scripts and stuff to do stuff +slonked up scripts and little snippets to do stuff everything in this repository is licensed under CC0-1.0 unless specified -otherwise, use it for whatever purposes you want # quick navigation -| C | Bash | JS | -| ---------------------- | ----------------------------------------------------- | ----------------------- | -| [unlink.c](c/unlink.c) | [arshit](shell/bash/arshit) | [svged.js](js/svged.js) | -| [cecho.c](c/cecho.c) | [sshfs_mount_file.sh](shell/bash/sshfs_mount_file.sh) | | -| | [repo_build.sh](shell/bash/repo_build.sh) | | -| | [grabber.sh](shell/bash/grabber.sh) | | +| C | Bash | JS | +| -------------------- | ----------------------------------------------- | ----------------------- | +| [cecho.c](c/cecho.c) | [arshit](bash/arshit) | [svged.js](js/svged.js) | +| | [sshfs_mount_file.sh](bash/sshfs_mount_file.sh) | | +| | [repo_build.sh](bash/repo_build.sh) | | +| | [grabber.sh](bash/grabber.sh) | | +| | [frequented.sh](bash/frequented.sh) | | +| | [start.sh](bash/start.sh) | | diff --git a/shell/bash/arshit/README.md b/bash/arshit/README.md similarity index 100% rename from shell/bash/arshit/README.md rename to bash/arshit/README.md diff --git a/shell/bash/arshit/arshit.sh b/bash/arshit/arshit.sh similarity index 100% rename from shell/bash/arshit/arshit.sh rename to bash/arshit/arshit.sh diff --git a/bash/avt/README.md b/bash/avt/README.md new file mode 100644 index 0000000..964cdfc --- /dev/null +++ b/bash/avt/README.md @@ -0,0 +1 @@ +# Moved to [slonkazoid/avt](https://gitlab.com/alifurkany/avt) diff --git a/bash/frequented.sh b/bash/frequented.sh new file mode 100755 index 0000000..09dea2e --- /dev/null +++ b/bash/frequented.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# Usage: ./frequented.sh [number=5] +# Lists your top `number` most frequented channels +# Single threaded, still does 1.22 milliseconds per channel +# (on a 5600X with 2289 channels and 385952 messages) + +# set this to your id to not print your id in dms/group chats +SELF_ID="${SELF_ID:-276363003270791168}" + +n=$((${1:-5})) + +repeat() { + local n=${2?} + for ((i=0; i ${counts[$i]})); then + insert $count "$channel" $i + break + fi + done +done + +echo "total channels: $total_channels" +echo "total messages: $total_messages" +echo "most frequented $n channels:" +for ((i=0; i 2 then + "GC with " + else + "DM with " + end + (.recipients | map(select(. != "'"$SELF_ID"'")) | join(", ")) + ")" + else + if has("name") then + "#" + .name + " (" + .guild.name + ")" + else + .id + " (unknown guild)" + end + end' c"${channels[$i]}"/channel.json) + echo "$((i + 1)). messages: ${counts[$i]}, channel: $channel_text" +done diff --git a/shell/bash/grabber.sh b/bash/grabber.sh similarity index 100% rename from shell/bash/grabber.sh rename to bash/grabber.sh diff --git a/shell/bash/repo_build.sh b/bash/repo_build.sh similarity index 100% rename from shell/bash/repo_build.sh rename to bash/repo_build.sh diff --git a/shell/bash/sshfs_mount_file.sh b/bash/sshfs_mount_file.sh similarity index 100% rename from shell/bash/sshfs_mount_file.sh rename to bash/sshfs_mount_file.sh diff --git a/bash/start.sh b/bash/start.sh new file mode 100755 index 0000000..425c2a6 --- /dev/null +++ b/bash/start.sh @@ -0,0 +1,85 @@ +#!/usr/bin/env bash + +# Minecraft server start.sh +# for use in slapping in tmux and forgetting +# also rolls logs + +# --- CONFIGURATION + +# you can source an environment file like this: +#. .env + +# auto-restart +AUTO_RESTART=${AUTO_RESTART:-1} # 1 to enable +RESTART_DELAY=${RESTART_DELAY:-3} # seconds +DONT_RESTART_IF=${DONT_RESTART_IF:0} # exit code + +# java options +JAVA_BIN=${JAVA_BIN:-java} # full path to the java binary +#JVM_FLAGS= # Java flags +#NO_DEFAULT_JVM_FLAGS= # 1 to disable default flags +MEMORY_MIN=${MEMORY_MIN-4G} # Xms +MEMORY_MAX=${MEMORY_MAX:-4G} # Xmx +GC=${GC:-ZGC} # ShenandoahGC or ZGC +GC_PAR_THREADS=${GC_PAR_THREADS:-6} # "parallel" (runs while workers are stopped) thread count + # recommended to set to just below total thread count +GC_CONC_THREADS=${GC_CONC_THREADS:-"$(( half=GC_PAR_THREADS / 2, half == 0 ? 1 : half ))"} + # marker thread count, defaults to half of parallel + +# mc options +MC_FLAGS=${MC_FLAGS:nogui} # Minecraft flags +SERVER_JAR=${SERVER_JAR:-server.jar} # server JAR file + +# --- + +gcs=( + [zgc]="-XX:+UseZGC" + [shenandoahgc]="-XX:+UseShenandoahGC" +) + +java_args=() + +[[ "${MEMORY_MIN:+x}" == 'x' ]] && java_args+=(-Xms"${MEMORY_MIN}") +java_args+=(-Xmx"${MEMORY_MAX}") + +(( ! NO_DEFAULT_JVM_FLAGS )) && java_args+=(-XX:+ParallelRefProcEnabled -XX:+DisableExplicitGC -XX:+PerfDisableSharedMem -XX:MaxGCPauseMillis=10) +if [[ "${MEMORY_MIN,,}" == "${MEMORY_MAX,,}" ]]; then + java_args+=(-XX:+AlwaysPreTouch) + [[ "${GC,,}" == 'zgc' ]] && java_args+=(-XX:-ZUncommit) +fi +if (( $( 0 )); then + java_args+=(-XX:+UseLargePages) + [[ $(&1 + + +while true; do + "${JAVA_BIN}" "${java_args[@]}" 2>&1 | tee ./"$(date -I)".log + exitcode=$? + + echo "Process exited with code "$'\033'"[3$(( exitcode == 0 ? 2 : 1 ))m${exitcode}"$'\033'"[0m" >&2 + + #shellcheck disable=SC2076 + (( AUTO_RESTART != 1 || DONT_RESTART_IF == exitcode )) && + exit "${exitcode}" + + echo "Restarting after ${RESTART_DELAY} seconds" >&2 + sleep "${RESTART_DELAY?}" +done diff --git a/c/cecho.c b/c/cecho.c index 0ef0a2d..47b3f7f 100644 --- a/c/cecho.c +++ b/c/cecho.c @@ -1,5 +1,4 @@ #include -#include int main(int argc, char **argv) { for (int i = 1; i < argc; i++) { @@ -11,5 +10,4 @@ int main(int argc, char **argv) { } // Compilation: cc cecho.c -o cecho -// Usage: ./cecho [STRING]... -// License: Public Domain +// Usage: ./cecho ARG... diff --git a/c/unlink.c b/c/unlink.c deleted file mode 100644 index 33fe39e..0000000 --- a/c/unlink.c +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include -#include -#include -#include - -int main(int argc, char **argv) { - if (argc < 2) { - error(1, 0, "Not enough arguments."); - } - - short has_errored = 0; - - for (int i = 1; i < argc; i++) { - if (unlink(argv[i]) == -1) { - has_errored = 1; - error(0, errno, "%s", argv[i]); - } - } - - if (has_errored) { - exit(1); - } - - return 0; -} - -// Compilation: cc unlink.c -o unlink -// Usage: ./unlink FILES... -// License: Public Domain diff --git a/js/svged.js b/js/svged.js index cab1fab..465bdc9 100755 --- a/js/svged.js +++ b/js/svged.js @@ -11,6 +11,8 @@ const { writeFileSync, readFileSync } = require("fs"); * 4. Calculate Delta E00 between two LAB colour (Main purpose) * @author Ahmed Moussa * @version 2.0 + * @link https://github.com/hamada147/IsThisColourSimilar + * @license Apache-2.0 */ class Color { /** diff --git a/shell/bash/avt/README.md b/shell/bash/avt/README.md deleted file mode 100644 index 43e10cc..0000000 --- a/shell/bash/avt/README.md +++ /dev/null @@ -1 +0,0 @@ -# Moved to [alifurkany/avt](https://gitlab.com/alifurkany/avt)