Skip to content

Instantly share code, notes, and snippets.

View taikedz's full-sized avatar

Tai Kedzierski taikedz

View GitHub Profile
@taikedz
taikedz / Dockerfile
Last active October 26, 2017 15:35
Dockerfile for a go-cd server instance
FROM ubuntu:xenial
RUN apt-get update
RUN apt-get install -y vim git ca-certificates curl openjdk-8-jre
RUN apt-get install -y apt-transport-https
RUN echo "deb https://download.gocd.org /" > /etc/apt/sources.list.d/gocd.list
RUN curl https://download.gocd.org/GOCD-GPG-KEY.asc | apt-key add -
RUN apt-get update
@taikedz
taikedz / shelly.go
Last active March 29, 2018 14:52
Some go learning notes for calling external commands
package main
// Always declare main for the main init part of program
import (
"fmt" // For printing feedback
"os" // For getting args
"os/exec" // For calling external script
"strings" // Std string manipulation lib
)
@taikedz
taikedz / blocksfolder.py
Created February 8, 2018 12:38
Fold text blocks at nearest character before hardwrap limit. Created because I wanted to wrap mysql dumps (that "anonymous" one was mine)
#!/usr/bin/python3
import os
import sys
import re
DEBUG_ON = False
TRUNCATE = True
def printhelp():
@taikedz
taikedz / status-all.sh
Created March 29, 2018 14:33
Discover all non-clean git repos under the current directory (modified or untracked files)
#!/bin/bash
set -e
# Rather than use bare binary, use all ASCII
# for web and clipboard compatibility
c_nul="$(echo -e "\033[0m")"
c_red="$(echo -e "\033[31;1m")"
c_yel="$(echo -e "\033[33;1m")"
@taikedz
taikedz / extractor-git.sh
Created March 29, 2018 15:07
Extract the full contents of the files changed during a given commit
#!/bin/bash
### Extract the changed files of a commit Usage:help
#
# Given a commit, extract the full file contents of that commit, and write them to the destination directory (outside the repo)
#
# extractor-git.sh {copy|cat} COMMIT DESTDIR
#
# 'cat' simply cats the data, but no file metadata is preserved. No change is made to the repo state
#
@taikedz
taikedz / reconcile-swp.sh
Created April 23, 2018 17:02
Find mid-edit vim files after crash (yes it happens - especially if in a VM and the host is flaky)
cred="$(echo -e '\033[31;1m')"
cgrn="$(echo -e '\033[32;1m')"
cyel="$(echo -e '\033[33;1m')"
cblu="$(echo -e '\033[34;1m')"
cdef="$(echo -e '\033[0;m')"
do_reconcile() {
swapfile="$1"; shift
realfile="$(dirname "$swapfile")/$(basename "$swapfile"|sed -r 's/^\.(.+)\.swp$/\1/' )"
@taikedz
taikedz / dwat.sh
Created April 24, 2018 22:15
Troubleshoot a container instance
#!/bin/bash
printhelp() {
cat <<EOF
dwat CONTAINER [CMD ...]
EOF
}
@taikedz
taikedz / ckeystore.sh
Created May 4, 2018 13:33
View a java keystore contents with some colorization for easier reading.
#!/bin/bash
main() {
if [[ -z "$*" ]] || [[ "$*" =~ --help ]]; then
echo "Provide the path to a keystore to colorize its output"
else
keystore="$1"
dump_keystore | colorize_keystore_stream | c_less
fi
}
@taikedz
taikedz / wmax.sh
Created May 21, 2018 16:39
Script to maximize and minimize an X window from the command line
maxi() {
if [[ "$1" =~ ^0x[0-9a-f]+$ ]]; then
wmctrl -i -r "$1" -b toggle,maximized_vert,maximized_horz
# the window will be in the foreground, but not given focus
else
echo "No valid window supplied: got [$1]"
fi
}
die() {
@taikedz
taikedz / jks-manip.sh
Last active May 24, 2018 17:40
Manipulate a Java key store with a simple purpose-driven tool, rather than remember all those `keytool` options...
#!/bin/bash
# This tool has since been integrated to https://github.com/taikedz/CertMaker
set -euo pipefail
scr="$(basename "$0")"
printhelp() {
cat <<EOF