Skip to content

Instantly share code, notes, and snippets.

Tai Kedzierski taikedz

Block or report user

Report or block taikedz

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@taikedz
taikedz / README.md
Created Jul 4, 2019
Controlled runner and argument parser
View README.md

A pair of python3 scripts for importing. I wrote these to facilitate writing wrappers external commands, when replacing some shell scripts. There might be better ways to do it (including checking for libraries in lieu of commands) but in absence of that possibility (looking at you, docker-compose!), these have made things much easier...!

The arguments.py script allows loading a parser with some defaults, as well as passing your own argparse definitions to it. It then returns a usable dicitonary in which to look up items.

The runner.sh script provides a convenience set of functions for runnning external commands, as well as a dry run mode predicated on use of --dry-run from the arguments.sh script. It also accepts a simple dict mapping extra environment variables into the existing environment

Example

import runner
@taikedz
taikedz / README.md
Last active Jul 4, 2019
Query JSON and nested dicts/lists easily
View README.md

This is a relatively simple JSON object traverser: feed it either a JSON string or a nested set of dicitonaries/lists and use a path notation to access individual items.

  • It supports paths separated with either / or any separator string you specify
  • It supports wildcards * to iterate over multiple values
  • Arrays/lists are accessed simply by number instaed of names e.g. name_with_array/0/property_of_zeroth_item
  • If a bad query token or data type is encountered, it will print the offending path

It is relatively naive, insomuch as it will create a new array in the output object for each wildcard used along the path. For example, here's an example of getting all subnet definitions on docker inspect <networks ...>:

@taikedz
taikedz / README.md
Created May 20, 2019
Get automatic settings for apt prompts
View README.md

Get APT prompt autoconfigurations

This script installs a package, and produces a debconf entries file that can be edited (see [the stack overflow answer this is based on][1])

Usage

1/ Run it normally

./agc mysql-server
@taikedz
taikedz / README.md
Created Apr 23, 2019
Reconcile vim swap files
View README.md

Vim creates temporary files with the *.swp extension when editing files; if the session is terminated or the computer reboots/crashes etc without cleanly exiting, these stick around.

This script seqarches for such files, and allows the user to use vim to check that the file actually has the latest changes from the swap, then offers to delete the swap file.

The script uses bash builder syntax and inclusions, and can be run directly in bbrun. It can also be

View README.md

Directory saver

Save directory data to a local data folder ; see differences ; restore data.

Originally a tool to save Joplin data in case the sync broke/was disastrously told to empty itself.

Can be generalized to a data sync tool.

"Compile" with bash-builder

@taikedz
taikedz / README.md
Last active Mar 20, 2019
Clean out docker images with `<none>` tags,. Removes leftover containers too.
View README.md

Remove docker <none> images

After rebuilding an image several times and retagging it the same, you can have a whole load of images with name/tag as <none>/<none>.

THis script removes all stopped containers referencing those images, and then removes the images themselves, cleaning up your image and container lists.

@taikedz
taikedz / README.md
Created Feb 28, 2019
Roundcube webmail
View README.md

Roundcube docker-compose definition

A simple docker compose definition for a roundcube mail server.

Remember to add definitions for your HTTPS reverse proxy to secure the browser connections.

@taikedz
taikedz / README.md
Last active Apr 22, 2019
Mail testing tool
View README.md

Mail server testing

A quick script and data file that allows a test of a non-secured mail server

Typically useful to check if a service is actually working, you'll need to activate non-login non-SSL on your server

For obvious reasons, do NOT leave your SMTP server in that state for too long on the open Internet!

Example use of command:

@taikedz
taikedz / unignore.sh
Last active Jan 11, 2019
Generate paths to un-ignore deeply nested directories for .gitignore
View unignore.sh
unignorepath() {
local super="$(dirname "$1")"
[[ "$super" =~ ^(.|/)$ ]] && return
unignorepath "$super" # process higher levels first so as to print in order
echo "$super/*"
echo '!'"$1"
}
@taikedz
taikedz / variables_test.sh
Created Oct 10, 2018
Some advanced variable manipulation investigation
View variables_test.sh
#!/bin/bash
printarr() {
echo "$msg"
local x
for x in "$@"; do
echo " $x"
done
}
You can’t perform that action at this time.