Skip to content

Instantly share code, notes, and snippets.

View taikedz's full-sized avatar

Tai Kedzierski taikedz

View GitHub Profile
@taikedz
taikedz / README.md
Last active January 17, 2024 09:39
Fate chances

Roll Fate

This is a quick script to see the chances of outcome of rolling Fudge/FATE dice against opposition.

Mainly, I am interested in rolling at Good skill against Good opposition , and seeing what happens.

Adding a +1 skill modifier is akin to being +1 shift above the Good opposition (skill Great).

  • -2 and below is abject failure
  • -1 is failure
@taikedz
taikedz / json-select-where.py
Last active January 11, 2024 10:58
Extract data from matching entries in a JSON file
from argparse import ArgumentParser
import json
from typing import List
OPERATIONS = {
"starts": lambda value, data: data.startswith(value),
"!starts": lambda value, data: not data.startswith(value),
"ends": lambda value, data: data.endswith(value),
@taikedz
taikedz / README.md
Last active December 5, 2023 11:12
Mocker

Mocker

A versatile object mocking utility for unit testing.

For example, assuming a function that uses a connection utility:

def find_python_files_at(connection):
  try:
 status, stdout, stderr = connection.send_command("ls /my/path", shell=True)
@taikedz
taikedz / README.md
Created December 5, 2023 09:47
Basic attributes dictionary / namespacer

DictNamespace

A basic namespacing utility to provide "nicer" code.

It's a small snippet for a minor quality-of-life utility.

ns = DictNamesspace(a=1, b="hello")
assert ns.a == 1
assert ns.b == "hello"
@taikedz
taikedz / rustr
Created October 17, 2023 10:46
rustr - run rust source file as an executable script
#!/usr/bin/env bash
# Use this `rustr` script as a shebang target.
# put `rustr` somewhere on your PATH
filename="$1"; shift
temp="$(mktemp)"
rmtemp() { rm "$temp"; }
touch "$temp"
@taikedz
taikedz / goenv
Last active October 17, 2023 10:40
GoEnv - python virtualenv-like way to set GOPATH
#!/usr/bin/env bash
# Run `goenv ./env-dir` to create an isolated dependencies dir
# Source the resulting file to activate it in a local shell session
# . env-dir/go-activate
# This sets GOPATH and adds a PATH entry to the environment
# Run `go-deactivate` to deactivate it.
if [[ -z "$1" ]]; then
echo "No name specified"
@taikedz
taikedz / comprehension.groovy
Created October 16, 2023 12:33
Basic comprehensions in Groovy
// Some things
List<String> items = ["banana", "pear", "apple"]
// Filtering out
List<String> e_items = items.findAll { it.contains("e") }
println(e_items)
// List from list
List<String> fruity = items.collect { "Fruit: $it" }
println fruity
@taikedz
taikedz / README.md
Last active October 17, 2023 10:47
Rust-style Option objects in Python

Mimic Rust's Option type in Python

Commentary published in an article: https://dev.to/taikedz/rusts-option-type-in-python-547p

How to use this

Using this type allows the developer to express nullness and force the recipient of the Option to code for it. The Option does not stand in for the value, the value must be unpacked from it.

@taikedz
taikedz / oci-image-rm-remote.sh
Last active October 12, 2023 11:29
Delete a remote OCI image (if supported) (docker/podman registry)
#!/usr/bin/env bash
if [[ -z "$*" ]]; then
echo -e "Usage:\n\t$(basename "$0") \$SERVER/\$IMAGE:\$TAG [delete]"
echo "Omit the 'delete' argument to query the manifest for the image"
echo "Use 'delete' to actually perform deletion"
exit 0
fi
REGISTRY_SERVER="$(echo "$1" | cut -d/ -f1)"
@taikedz
taikedz / README.md
Last active September 6, 2023 07:07
pathctl

pathctl

A quick and dirty script for loading/appending to PATH

Oftentimes when I write install scripts i have to go looking for a path and its presence to avoid duplication, parsing the .bashrc and .profile scripts .

This is tedious, and prone to issues.

If we could have a basic utility that already took care of this as a default item in the system, it would be handy.