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 October 29, 2024 18:11
Zis idea

Zis : a Zig-Inspired Scripting Language (idea)

These are notes for a Zig-inspired strongly-typed GC language, taking some aspects from Python, and retaining some smiilar simplicity as promised by Go.

Zig brings so several great ideas to the table, but a variant of its apporoach for application-space would be very welcome, so it would provide a similar experience to Zig with many of its characteristics:

  • error unions
  • optionals
  • defer
  • block scopes
@taikedz
taikedz / teepipe.py
Created September 2, 2024 10:13
TeePipe
""" Utility to behave like "tee"
Similar to the system "tee" program, attempts to write the same output to two different channels
In this present case, attempts to write to stdout/stderr , as well as retain for retrieval as string.
To do this, we wrap the pipe, direct the system pipe to write data to an interim temp file, and we read
that file content back into memory and write it through to the wrapped pipe ourselves.
"""
@taikedz
taikedz / README.md
Last active May 2, 2024 16:04
Periodic operations

Periodic Operations

A sched.scheduler wrapper to run continuously as a "service", to queue up one-time operations.

A PeriodicOperation based on native threading.Timer, runs as a "service".

Both can be stopped.

Timer could have been used in lieu of the scheduler, but the latter stands to have more precision.

@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