Skip to content

Instantly share code, notes, and snippets.

View Tzrlk's full-sized avatar

Peter Cummuskey Tzrlk

View GitHub Profile
@Tzrlk
Tzrlk / README.md
Last active August 18, 2025 00:16
MS Teams ActiveCard webhook templates

ActiveCard templates

Issues/TODO

  • Markdown content for TextBlock or RichTextBlock doesn't render.
  • See if cards can be sent without wrapping in message first.
  • Convert dynatrace placeholders to template references.

Reference

@Tzrlk
Tzrlk / SmokeStack.cs
Created August 8, 2025 10:53
A stack with ephemeral history (in C#).
using System;
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// This is really meant to be "the history of a value", but with only a fixed number of versions being held onto before they transition to weak references.
/// An ephemeral stack.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value"></param>
@Tzrlk
Tzrlk / wslg-icon-fix.sh
Created July 1, 2025 00:24
Script to convert linux desktop icons from svg to ico
#!/usr/bin/env bash
# Finds all desktop .svg icons and renders them as .ico so wslg can use them,
# then updates the desktop files to point to the .ico files.
# This script assumes there are no colons in any of the paths.
# TODO: Add support for converting /usr/share/icons as well.
set -e
# Check if the 'convert' command from ImageMagick is available.
if ! builtin type -P convert &>/dev/null; then
echo >&2 "< ImageMagick is required to convert the svgs."
@Tzrlk
Tzrlk / spec_helper_mock.rb
Last active August 28, 2024 00:01
Mocking-out "include_recipe" when running chefspec unit tests
shared_context :chef_recipe do
# This ensures recipes can be tested in isolation.
before :each do
allow_any_instance_of(Chef::Recipe).to receive(:include_recipe) do |recipe, recipe_name|
Chef::Log.debug "Blocking #{recipe_name} from inclusion by #{recipe.cookbook_name}::#{recipe.recipe_name}"
# Ensure recipe is treated as loaded, allowing matchers to work properly.
cookbook_name, recipe_short_name = Chef::Recipe.parse_recipe_name(recipe_name)
recipe.run_context.loaded_recipe(cookbook_name, recipe_short_name)
recipe.run_context.node.loaded_recipe(cookbook_name, recipe_short_name)
@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 ${?}
}