Skip to content

Instantly share code, notes, and snippets.

View rjonczy's full-sized avatar
:octocat:
pushing commits

Robert Jonczy rjonczy

:octocat:
pushing commits
View GitHub Profile
@rjonczy
rjonczy / alertmanager_templates_howto.md
Created March 4, 2025 20:46 — forked from vi7/alertmanager_templates_howto.md
Alertmanager templates testing

Render Alertmanager templates locally

Normally to test Alertmanager templates you need to restart running Alertmanager and wait for alerts to arrive to Slack or email. To speed up this process parts of templates could be rendered locally using predefined alerts data without the need of the actual Alertmanager.

What you still need in this case is amtool which is a part of Alertmanager delivery which could be downloaded here https://github.com/prometheus/alertmanager/releases

Some examples of templates rendering:

# navigate to the templates dir
@rjonczy
rjonczy / kubectl-run-with-pvc.sh
Created September 9, 2022 06:57 — forked from yuanying/kubectl-run-with-pvc.sh
kubectl run with PVCs
#!/bin/bash
IMAGE="gcr.io/google-containers/ubuntu-slim:0.14"
COMMAND="/bin/bash"
SUFFIX=$(date +%s | shasum | base64 | fold -w 10 | head -1 | tr '[:upper:]' '[:lower:]')
usage_exit() {
echo "Usage: $0 [-c command] [-i image] PVC ..." 1>&2
exit 1
}

Certbot

Generate certs

Manually generate cert (without installing) (prefare: dns challenge)

$ certbot --manual -d my.domain.com --preferred-challenges dns certonly
@rjonczy
rjonczy / gcp-iam-serviceaccounts.md
Created August 30, 2022 08:56
GCP IAM service accounts management - quicknotes

GCP Service Accounts - management

export SA_NAME="my-sa-name"

Create

$ gcloud iam service-accounts create $SA_NAME
kind: Pod
apiVersion: v1
metadata:
name: apple-app
labels:
app: apple
spec:
containers:
- name: apple-app
image: hashicorp/http-echo
kind: Pod
apiVersion: v1
metadata:
name: apple-app
labels:
app: apple
spec:
containers:
- name: apple-app
image: hashicorp/http-echo
kind: Pod
apiVersion: v1
metadata:
name: apple-app
labels:
app: apple
spec:
containers:
- name: apple-app
image: hashicorp/http-echo
@rjonczy
rjonczy / sed_snippets.sh
Created May 29, 2017 09:18 — forked from r2k0/sed_snippets.sh
sed examples
##FILE SPACING:
# double space a file
sed G
# double space a file which already has blank lines in it. Output file
# should contain no more than one blank line between lines of text.
sed '/^$/d;G'
# triple space a file
@rjonczy
rjonczy / useful_pandas_snippets.py
Created April 21, 2017 12:46 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
# List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
# Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
# Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(valuelist)]