Skip to content

Instantly share code, notes, and snippets.

View CosmicToast's full-sized avatar

Chloé Vulquin CosmicToast

View GitHub Profile
@CosmicToast
CosmicToast / log.sh
Last active February 14, 2024 21:53
POSIX sh stack-based logging system.
#!/bin/sh
# this file is licensed under any of the following SPDX licenses
# to be chosen by the user:
# * 0BSD (https://spdx.org/licenses/0BSD.html)
# * BlueOak-1.0.0 (https://blueoakcouncil.org/license/1.0.0)
# * CC0-1.0 (https://creativecommons.org/publicdomain/zero/1.0/)
# * Unlicense (https://unlicense.org/)
## log.sh - Bunker Log
# This is the bunker logging system for POSIX sh.
@CosmicToast
CosmicToast / set.go
Last active January 2, 2024 19:00
go-collect
package collect
// Set represents a generic set of comparable elements.
type Set[T comparable] map[T]struct{}
// Has checks whether the set holds a given value.
func (s Set[T]) Has(v T) bool {
_, ok := s[v]
return ok
}
@CosmicToast
CosmicToast / jamplate.janet
Created June 4, 2023 20:21
Proof of concept PHP-style templating mode for Janet
(def- opener "<?janet")
(def- closer "?>")
(def- file ~{:main (some (+ :code :text))
:text '(to (+ ,opener -1))
:code (/ :code* ,parse-all)
:code* (* ,opener '(to ,closer) ,closer)})
(defn template-string
[s]
(def out @"")
@CosmicToast
CosmicToast / README.md
Last active December 28, 2023 12:29
FirewallD Files

Helpful FirewallD Files

Services

Place these in /etc/firewalld/services/.

@CosmicToast
CosmicToast / fetch.sh
Created June 23, 2021 22:46
Fetching library for shell.
#!/bin/sh
# this file is licensed under any of the following SPDX licenses
# to be chosen by the user:
# * 0BSD (https://spdx.org/licenses/0BSD.html)
# * BlueOak-1.0.0 (https://blueoakcouncil.org/license/1.0.0)
# * CC0-1.0 (https://creativecommons.org/publicdomain/zero/1.0/)
# * Unlicense (https://unlicense.org/)
# this all works with toybox, busybox and coreutils
# everything except http_src and http_run is POSIXLY correct
@CosmicToast
CosmicToast / args.bash
Created March 16, 2021 00:48
A schemaless argument parser for bash.
#!/usr/bin/env bash
# a schemaless argument parser
# this file is licensed under any of the following SPDX licenses
# to be chosen by the user:
# * 0BSD (https://spdx.org/licenses/0BSD.html)
# * BlueOak-1.0.0 (https://blueoakcouncil.org/license/1.0.0)
# * CC0-1.0 (https://creativecommons.org/publicdomain/zero/1.0/)
# * Unlicense (https://unlicense.org/)
@CosmicToast
CosmicToast / README
Created August 13, 2020 13:54
Toast's Syntax Files
Toast's Syntax Files
Arbitrary syntax implementations for things I thought were missing.
The format is $PROG.$NAME.$EXT
For example, gedit.gemini.lang or micro.gemini.yaml.
All of these are written by me and available under the CC0.
Instructions based on prog (remove the $PROG. prefix first):
@CosmicToast
CosmicToast / README.md
Last active March 4, 2020 00:39
Useful plasma5 service menus

Some useful ServiceMenus for plasma5

A small collection, because reasons.

Installation

To apply these, place the .desktop file you're interested in in ~/.local/share/kservices5/ServiceMenus/, then run kbuildsycoca5 (failures are ok). For each of them, the binary in question (specified under TryExec=) must be in the systemwide $PATH. You can expand it in the plasma5 env files, or via PAM. Or just, you know, symlink it into /usr/local/bin.

Optionally, you can download/place a compliant icon into ~/.local/share/icons/.

@CosmicToast
CosmicToast / README.md
Created January 14, 2020 01:50
Useful MinIO policies

Some useful policies for MinIO

A small collection, because reasons.

User Policies

To apply these:

  1. Download the file.
  2. mcli admin policy add MYMINIO NAME NAME.json (replace MYMINIO with your configured instance and NAME with the filename).
  3. mcli admin policy set MYMINIO NAME user=USER (same as above, replace USER with the user you want to configure).
@CosmicToast
CosmicToast / fedimg
Last active January 12, 2020 04:41
Fediverse (mastodon-api compatible) image and file status uploader
#!/bin/zsh
# deps: curl, mkdir(1p), jq
# return codes:
# 1: regular error, see stdout
# 2: media upload error
# 3: status post error
local app=${0:t}
usage() {
echo "$app [-a|-A <token>] [-i|-I <instance>] [-n] [-N <spoiler>] [-s <status>] -f <file>..."