Skip to content

Instantly share code, notes, and snippets.

View trietsch's full-sized avatar
💻

Robin Trietsch trietsch

💻
View GitHub Profile
@trietsch
trietsch / cli-telemetry.md
Created January 9, 2024 16:03
CLI Telemetry Collection System Blog Post

How can CLI usage be measured, while respecting end-user's privacy?

The CLI is a critical part of the developer experience. Often, it's the first interface for developers to interact with your product. However, with Open Source products, it's difficult to know if and how end-users are using your product. Even though telemetry data might be very interesting for the product team, it's important to respect the end-user's privacy; we need to ensure that no sensitive data is collected.

Only collect data on how end-users use the CLI to interact with your product, and stay inside those boundaries.

@trietsch
trietsch / git-remove-remote-merged.sh
Last active August 14, 2024 11:12
Remove local branches that have been merged in the remote (with confirmation)
#!/usr/bin/env bash
# Protip! You can add this to your gitconfig as a custom git command:
# 1. open `~/.gitconfig`
# 2. if the [alias] block doesn't exist, create it
# 3. add the following line:
# remove-remote-merged = !git-remove-remote-merged
# 4. Save the file, now you can do:
# git remove-remote-merged
// ==UserScript==
// @name Auto Enable Show Dependencies
// @version 1.0.2
// @description Automatically enables show dependencies in Gitlab CI pipelines
// @author Robin Trietsch
// @match https://gitlab*/*/-/pipelines/*
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// @updateURL https://gist.github.com/trietsch/9c8701445a3ab5b2033ac2f615b2d2c1/raw/3b69af9ab266e0af438459337409387ec567d6db/auto-redirect.user.js
// @downloadURL https://gist.github.com/trietsch/9c8701445a3ab5b2033ac2f615b2d2c1/raw/3b69af9ab266e0af438459337409387ec567d6db/auto-redirect.user.js
@trietsch
trietsch / auto-edit-commit-message.user.js
Last active December 14, 2022 15:55
Automatically enable the edit commit message checkbox on GitLab MRs
// ==UserScript==
// @name Auto Edit Commit Message
// @version 1.0.1
// @description Automatically enables the 'edit commit message' box
// @author Robin Trietsch
// @match https://gitlab.com/*/merge_requests/*
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// @updateURL https://gist.github.com/trietsch/9c8701445a3ab5b2033ac2f615b2d2c1/raw/d36b94d822b1b2cb7a669dc29da58af0b226ea0e/auto-edit-commit-message.user.js
// @downloadURL https://gist.github.com/trietsch/9c8701445a3ab5b2033ac2f615b2d2c1/raw/d36b94d822b1b2cb7a669dc29da58af0b226ea0e/auto-edit-commit-message.user.js
@trietsch
trietsch / auto-redirect.user.js
Last active July 26, 2022 11:35
Automatically skip the redirect notice from Google
// ==UserScript==
// @name Skip redirect notice
// @version 1.0.0
// @description Immediately redirects when presented a redirect notice from Google.
// @author Robin Trietsch
// @include https://www.google.com/url?*
// @grant none
// @updateURL https://gist.github.com/trietsch/1665db6cc6bcc5a290ef6370ca503d73/raw/3b69af9ab266e0af438459337409387ec567d6db/auto-redirect.user.js
// @downloadURL https://gist.github.com/trietsch/1665db6cc6bcc5a290ef6370ca503d73/raw/3b69af9ab266e0af438459337409387ec567d6db/auto-redirect.user.js
// ==/UserScript==
@trietsch
trietsch / gitlab_group_cluster.tf
Last active December 11, 2022 01:04
Gitlab (Group) Kubernetes Cluster with minimal RBAC (NO cluster-admin!)
/*
Gitlab offers the option to configure Kubernetes clusters (either on group level or project level) to be able to view pods
logs, and more all from the web UI. However, they advise to configure cluster-admin as a Cluster Role for the Serviceaccount
that you use to set up access from Gitlab to your cluster.
IMO, these permissions are too wide, as I'm not using Gitlab to manage deployments, that is done through Terraform in my case.
This should have been documented somewhere in the Gitlab documentation, especially since Gitlab acknowledges that many users
find the permissions too wide: https://about.gitlab.com/blog/2021/02/22/gitlab-kubernetes-agent-on-gitlab-com/
The Terraform code below includes all RBAC permissions required to view your clusters in Gitlab, as well as view the
deployment, including the number of pods. Furthermore, it allows for log viewing in Gitlab as well. Permissions are mainly
@trietsch
trietsch / s3-parallel
Last active November 10, 2019 16:02
Parallelize s3 copy / move actions by using screens and forked processes (usage: ./s3-parallel <from> <to> <files_to_copy_per_screen>
#!/bin/bash
action=${1:?Please specify whether to mv or cp.}
from=${2:?Specify the full s3 path to move or copy from.}
to=${3:?Specify the full s3 path to move or copy to.}
number_of_screens=${4:-10}
case $action in
mv)
echo "Going to MOVE data from '$from' to '$to'."