Skip to content

Instantly share code, notes, and snippets.

View taikedz's full-sized avatar

Tai Kedzierski taikedz

View GitHub Profile
@taikedz
taikedz / variables_test.sh
Created October 10, 2018 10:51
Some advanced variable manipulation investigation
#!/bin/bash
printarr() {
echo "$msg"
local x
for x in "$@"; do
echo " $x"
done
}
@taikedz
taikedz / unignore.sh
Last active January 11, 2019 10:30
Generate paths to un-ignore deeply nested directories for .gitignore
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 / README.md
Last active April 22, 2019 17:13
Mail testing tool

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 / README.md
Created February 28, 2019 14:46
Roundcube webmail

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 March 20, 2019 10:25
Clean out docker images with `<none>` tags,. Removes leftover containers too.

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 March 27, 2019 11:54
Joplin store

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
Created April 23, 2019 09:51
Reconcile vim swap files

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

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

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
Last active July 4, 2019 15:18
Query JSON and nested dicts/lists easily

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 July 4, 2019 17:50
Controlled runner and argument parser

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