Skip to content

Instantly share code, notes, and snippets.

View Tzrlk's full-sized avatar

Peter Cummuskey Tzrlk

View GitHub Profile
@Tzrlk
Tzrlk / KeePassEncodingView.kps
Created January 30, 2024 00:38
A KeePass script to display entries in a database with different character encodings.
public static void Main() {
CommandLineArgs args = new CommandLineArgs(Environment.GetCommandLineArgs());
String infile = args["infile"];
if (String.IsNullOrEmpty(infile)) {
Console.WriteLine("No input file specified.");
throw new Exception("No input file specified.");
}
@Tzrlk
Tzrlk / project.build.ps1
Created November 28, 2023 02:31
Powershell Invoke-Build script to save Invoke-ScriptAnalyzer results to checkstyle.xml format
using namespace Microsoft.Windows.PowerShell.ScriptAnalyzer.Generic
# Synopsis: Statically analyses the codebase for badness.
Add-BuildTask lint -Inputs ${Sources} -Outputs "${PSScriptRoot}/checkstyle.xml" {
Import-Module PSScriptAnalyzer
# Run the linter, producing a list of result objects.
$Results = Invoke-ScriptAnalyzer `
-Path "${PSScriptRoot}" `
-CustomRulePath "${PSScriptRoot}/.lint-rules" `
@Tzrlk
Tzrlk / ducrpmbuild.sh
Last active January 22, 2020 00:13
Script to build an RPM for a version of the DUC tool via Docker
#!/usr/bin/env bash
DUC_VERSION=${1}
if [ -z "${DUC_VERSION}" ]; then
echo >&2 "You need to provide a valid release version to package."
exit 1
fi
if [ ! -f "duc-${DUC_VERSION}.tar.gz" ]; then
RELEASE_BASE=https://github.com/zevv/duc/releases/download
@Tzrlk
Tzrlk / IterableUtils.java
Last active August 9, 2018 05:01
A function for splitting an iterable into multiple filtered iterables.
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
public final class IterableUtils {
public static <T> Map<String, Iterable<T>> group(Iterable<T> input, Map<String, Predicate<T>> groupings) {
return Maps.transformValues(groupings, (predicate) -> Iterables.filter(input, predicate));
}
private IterableUtils() {}
@Tzrlk
Tzrlk / Dockerfile
Created July 11, 2018 02:53
Files related to ansible k8s module "Incorrect Padding" issue
FROM williamyeh/ansible:alpine3
RUN apk add --no-cache \
gcc \
musl-dev \
python2-dev
RUN pip install --upgrade \
pip
@Tzrlk
Tzrlk / ansible
Created December 27, 2017 02:45
This script makes sure an ansible container is perpetually running and lets you exec scripts on it.
#!/bin/bash -e
CONTAINER_NAME=ansible
function dpsgrep() {
pattern=${1} && shift
docker ps --format="{{ .Names }}" ${*} \
| grep -q ${pattern}
return ${?}
}
@Tzrlk
Tzrlk / ensure-file.kt
Created July 10, 2017 02:57
Scratchpad for file DSC functions.
// Should hash on file write, then save date written, hash value, etc.
// Source files should also have this data written on first read, so it can be quickly compared later.
// Only rehash if the date-written metadata field is before the last-modified.'
// https://docs.oracle.com/javase/tutorial/essential/io/fileAttr.html
fun ensureFile(source: Path, target: Path) {
when {
source.toFile().exists && target.toFile().exists -> {
@Tzrlk
Tzrlk / docker-fetch.sh
Created July 3, 2017 03:56
My bullshit script to fetch docker images when having trouble locally.
#!/usr/bin/env bash
IMAGE="${1}"
REMOTE_HOST=${2} # You may want to set a default for this
REMOTE_USER=${3} # and this
REMOTE_SSH="${REMOTE_USER}@${REMOTE_HOST}" # Add a fqdn to the end if it helps
REMOTE_FILE="/home/${REMOTE_USER}/export.tar"
LOCAL_FILE="$(pwd)/export.tar"
ssh "${REMOTE_SSH}" "docker pull ${IMAGE}" || exit 1
@Tzrlk
Tzrlk / pipeline.gdsl
Created May 11, 2017 22:53
The gdsl provided by jenkins
//The global script scope
def ctx = context(scope: scriptScope())
contributor(ctx) {
method(name: 'build', type: 'Object', params: [job:'java.lang.String'], doc: 'Build a job')
method(name: 'build', type: 'Object', namedParams: [parameter(name: 'job', type: 'java.lang.String'), parameter(name: 'parameters', type: 'Map'), parameter(name: 'propagate', type: 'boolean'), parameter(name: 'quietPeriod', type: 'java.lang.Integer'), parameter(name: 'wait', type: 'boolean'), ], doc: 'Build a job')
method(name: 'echo', type: 'Object', params: [message:'java.lang.String'], doc: 'Print Message')
method(name: 'error', type: 'Object', params: [message:'java.lang.String'], doc: 'Error signal')
method(name: 'input', type: 'Object', params: [message:'java.lang.String'], doc: 'Wait for interactive input')
method(name: 'input', type: 'Object', namedParams: [parameter(name: 'message', type: 'java.lang.String'), parameter(name: 'id', type: 'java.lang.String'), parameter(name: 'ok', type: 'java.lang.String'), parameter(name: 'par
@Tzrlk
Tzrlk / Equatable.java
Created October 30, 2016 23:13
equatable
public interface Equatable<T> {
Equatator<T> getEquatator();
}