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 March 6, 2023 00:00
Little UDP test

UDP test

(Note: taken further in a proper repo: https://github.com/taikedz/udp_test)

This is a quick thing I put together for testing UDP packet sending behaviours.

Interestingly, if a message is delayed by the server and sent after the client times out, the message is still received client side. An actual client would need to proactively manage response validity.

I did try randomly generating multiple identical repsonses from the server, that only caused confusion for this simple client.

@taikedz
taikedz / split_array_str.sh
Created February 15, 2023 12:48
Shell: Array split in quoted string
#!/usr/bin/env bash
QUOTED_ARRAY="-Djava=\"one 'and' two\" -Djavax=\"three four\""
while IFS= read -r -d '' item; do echo "$item"; done < <(xargs printf '%s\0' <<< "$QUOTED_ARRAY")
# Output:
# -Djava=one 'and' two
# -Djavax=three four
@taikedz
taikedz / datatable.py
Last active December 4, 2023 10:56
DataTable
# (C) Tai Kedzierski
# LGPLv3
from collections import OrderedDict
from typing import Any, Union, List
class DataTable(list):
def __init__(self, data:List[List[Any]]):
""" Builds a table, after popping the first line which provides headers
@taikedz
taikedz / install-anbox.sh
Created December 28, 2022 21:42
Anbox installer
#!/usr/bin/env bbrun
# Steps obtained from:
# https://ubuntuhandbook.org/index.php/2021/10/anbox-run-android-apps-ubuntu/
#%include std/out.sh
#%include std/askuser.sh
set -euo pipefail
@taikedz
taikedz / VSCODE_README.md
Last active June 23, 2023 08:32
Visual Stodio Code (VS Code) settings

VS Code Settings Adjustments

Plugins to install

  • pylance
  • git lens

Switch between the terminal and editor

Open the preferences via Ctrl Shift P

@taikedz
taikedz / enable-firefox-scroll-touchscreen.sh
Created November 8, 2022 10:18
Enable firefox touchscreen scrolling
sudo sed -i "s|Exec=|Exec=env MOZ_USE_XINPUT2=1 |g" /usr/share/applications/firefox.desktop
xdg-desktop-menu forceupdate
@taikedz
taikedz / README.md
Last active September 21, 2023 15:35
Genericised setup.py file for re-use

Generic setup.py

Specifically aimed at re-use

@taikedz
taikedz / pyodide-example.html
Last active May 20, 2022 14:39
Example of using python directly in a HTML page with DOM access
<!DOCTYPE html>
<html><head>
<style>
python { display: none; }
</style>
<script src="https://cdn.jsdelivr.net/pyodide/v0.20.0/full/pyodide.js"></script>
<script>
// https://pyodide.org/en/stable/usage/quickstart.html
pyscripts = document.getElementsByTagName("python");
let pyodide = null
@taikedz
taikedz / .bashrc
Last active May 12, 2022 16:37
Turn off Groovy Java Reflection Warnings
# ... add this to your bashrc to turn off those pesky warnings when running Groovy
# From https://github.com/apache/groovy/commit/a7f7cdd352a40dd7acd2def999eb560c2b76904e
# Via https://dev.to/erichelgeson/removing-illegal-reflective-access-warnings-in-grails-4-393o
_java_opens=(
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.annotation=ALL-UNNAMED
--add-opens=java.base/java.lang.invoke=ALL-UNNAMED
--add-opens=java.base/java.lang.module=ALL-UNNAMED

Easy Custom Logger

The default setup for the logging utility is a little unwieldy to set up for every project - though once done, it is likely to seldom change.

This snippet provides a pre-configured global logging utility allowing for a log level to be set via environment variable, as well as a pretty-print dump() log function that writes when level is set to DEBUG.

By default, logging goes to stdout, but can be redirected to a file.