Skip to content

Instantly share code, notes, and snippets.

@pasdam
pasdam / otel-collector-config.yaml
Created September 5, 2023 15:40
Opentelemetry collector config to send telemetry to clickhouse
connectors:
spanmetrics:
histogram:
explicit:
buckets: [100us, 1ms, 2ms, 6ms, 10ms, 100ms, 250ms]
dimensions:
- name: http.method
default: GET
- name: http.status_code
exemplars:
@pasdam
pasdam / dcu.sh
Last active September 18, 2023 13:32
docker compose up wrapper to automatically restart containers for which read-only volumes have been changed on the host machine
#!/bin/sh
print_usage() {
SCRIPT_NAME=$(basename "$0")
echo "Simple wrapper of docker compose to add labels to force the container re-creation when config files are updated"
echo "Example: $SCRIPT_NAME -f compose.custom.yaml up -d"
exit "$1"
}
FILES_ARG=
@pasdam
pasdam / main.go
Last active July 27, 2023 14:32
Go - Print html to pdf
package main
import (
"errors"
"log"
"os"
"github.com/playwright-community/playwright-go"
)
#!/bin/bash
PATH_TO_WATCH=$1
COMMAND=$2
trap printout SIGINT
printout() {
echo ""
1>&2 echo "Watch path terminated forcefully"
exit
@pasdam
pasdam / cpr.sh
Last active March 4, 2024 10:26
Script to automatically create a PR to main
#!/bin/sh
set -e
REPO_DIR=$1
if [ -z "$REPO_DIR" ]; then
REPO_DIR="./"
fi
REPO_DIR=$(git rev-parse --show-toplevel)
if [ "$REPO_DIR" = ".git" ]; then
#!/usr/bin/env bash
DIR=$1
cd "$DIR"
for d in */ ; do
if [[ "$d" =~ .*\([0-9\-]+\).* ]]; then
date=$(echo $d | sed "s/.*(//" | sed "s/)\///")
new_name="$date - $(echo $d | sed "s/$date//" | sed "s/ ()//")"
if [ ! -d "$new_name" ]; then
mv "$d" "$new_name"
#!/bin/sh
DIR=$1
EXTENSIONS_LIST="(MOV|MP4|AVI)"
HANDBRAKE_CLI=HandBrakeCLI
find_files() {
find "$DIR" -type f 2> /dev/null | egrep -i "\.$EXTENSIONS_LIST" | egrep -i --invert-match ".*_s\.$EXTENSIONS_LIST" | egrep --invert-match "/\."
}
#!/bin/sh
DIR=$1
if [ -z "$DIR" ]; then
DIR=./
fi
if [ ! -d "$DIR" ]; then
1>&2 echo "Invalid dir: $DIR"
exit 1
fi
# source: https://alexwlchan.net/2019/05/finding-unused-variables-in-a-terraform-module/
# import os
# import sys
# import hcl
# def get_variables_in_file(path):
# try:
#!/usr/bin/env python
"""
sort terraform variables
it's easy to do, just follow these steps:
python sort_terraform_variables.py variables.tf > sorted_variables.tf
mv sorted_variables.tf variables.tf
"""
from __future__ import print_function
import sys