Skip to content

Instantly share code, notes, and snippets.

View hypersoft's full-sized avatar

Triston J. Taylor hypersoft

View GitHub Profile
@hypersoft
hypersoft / MicroMachine.java
Last active May 2, 2018 02:48
Virtual: MicroMachine
package com.hypersoft.systems.usa.bleeding.edge;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@hypersoft
hypersoft / throttle.sh
Last active May 27, 2020 08:12
User-Level: Process IO, CPU and Memory throttling using systemd-run, in a convenient shell script.
#!/usr/bin/bash
function throttle.help() { cat<<EOF
throttle [OPTIONS] COMMAND
OPTIONS:
-- Stop options processing and execute COMMAND using systemd-run.
@hypersoft
hypersoft / git-checkout-unmodified-binaries
Created December 12, 2017 00:15
Git: Auto-Generated Binary Synchronization: Zap unmodified binary files
#!/usr/bin/env bash
# This is a Git tool which zaps-auto-generated-binaries, which have not
# been modified from the previous version.
# This tool is designed to help keep commit history clean and concise.
GITROOT="`realpath $1`"; shift;
MD5FILES="$@";
@hypersoft
hypersoft / globlines
Last active August 29, 2015 13:56
Path Tools
#!/bin/sh
pipe=cat;
ifilter=./ifilter; [ -e "$ifilter" ] || ifilter=ifilter;
if [ "${1:0:1}" == '-' ]; then
pipe="$ifilter $1";
shift;
fi;
@hypersoft
hypersoft / buildnum.sh
Last active December 19, 2015 13:19
Build No. Automated build number tracking utility
#!/bin/bash
declare -i MAJOR="0"
declare -i MINOR="0"
declare -i MINORMAX="99"
declare -i REVISION="0"
declare -i REVISIONMAX="9999"
buildnum ()
{
@hypersoft
hypersoft / bin2inc.sh
Created June 24, 2013 01:45
Translate binary/text file to single zero terminated char * buffer with content length.
#!/bin/bash
hash sed fold || {
printf "%s\n" "bin2inc: error: missing program dependencies";
exit 1; # if you don't have sed or fold, get them.
} >&2;
[[ -n $2 ]] && {
[[ -f "$2" && -r "$2" ]] || {
printf "%s\n" "bin2inc: error: argument 2 is not a valid file: $2";
@hypersoft
hypersoft / file.cache.sh
Last active December 18, 2015 03:18
Some line thingy
# file.cache.sh;
# selective broadcast
file.cache.stream() { # heading alias
eval printf %s \"\${$2[@]:$1}\";
}
# selective width broadcast
file.cache.stream.block () { # heading distance alias
eval printf %s \"\${$3[@]:$1:$2}\";
@hypersoft
hypersoft / parse.nested.block.sh
Last active December 14, 2015 09:09
Hand me your stream beginning with the first TOKEN, and I will return to you, the content of your first TOKEN, the data that lies between the first TOKEN, and the matching closing TOKEN or, I will return detailed data fields on What Went Wrong, along with full content of the buffer I have searched through.
parse.nested.block() # char start, char end[, buffer]
{ declare \
_Usage="
USAGE: $FUNCNAME [-u|-h|--help|-c|--chained] START END [BUFFER]
" \
_Help="
My name is \`$FUNCNAME' I was constructed by Triston J. Taylor (pc.wiz.tt)
as a generic method to parse nested blocks at my standard input on the
@hypersoft
hypersoft / libcore.sh
Last active June 4, 2022 00:53
libcore.sh Generated from auto chained library using lib.cache.
lib.array.count ()
{
eval echo \${#$1[@]};
}
lib.array.dump ()
{
@hypersoft
hypersoft / lib.read.for.sh
Last active December 13, 2015 19:18
I/O function callback shell.
lib.read.for ()
{
# Usage: lib.read.for [line|char|record delimiter "char"] [do command] [in file ...]
declare -A env[line]=0 env[delimited]=0 env[binary]=0; declare -i EOF;
if [[ "$1" == char ]]; then env[binary]=1; shift;
elif [[ "$1" == line ]]; then env[line]=1; shift;
elif [[ "$1$2" == recorddelimiter ]]; then env[delimited]=1 env[delimiter]="$3";
shift 2; shift; fi;