Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@bzon
bzon / gcrgc.sh
Created May 19, 2021 08:34 — forked from ahmetb/gcrgc.sh
Script to clean up Google Container Registry images pushed before a particular date
#!/bin/bash
# Copyright © 2017 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
@bzon
bzon / flux.alerts.yaml
Created May 12, 2020 18:24
Prometheus Flux alerts
apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
labels:
app: prometheus-operator
release: prometheus
name: alertmanager-flux
namespace: monitoring
spec:
groups:
@bzon
bzon / jaeger_es_fix.md
Created December 13, 2019 23:07
Fix Jaeger ES Forbidden error
curl -X PUT -H 'Content-Type: application/json' localhost:9200/jaeger-span-*/_settings -d '    {
    "index": {
    "blocks": {
    "read_only_allow_delete": "false"
    }
    }
    }'
@bzon
bzon / go_graceful_shutdown.md
Last active October 5, 2021 18:29
Golang gracefull shutdown with Context

Version 1.

package main

import (
	"context"
	"fmt"
	"os"
	"os/signal"
@bzon
bzon / printStructFieldNameAndValue.md
Last active March 22, 2019 12:09
Print struct field names and values using Reflection

At some point in your day to day hacking life, getting the Struct fields and values may come in handy.

package main

import (
	"fmt"
	"reflect"
)
@bzon
bzon / bootstrap.sh
Created October 8, 2018 23:43
EKS Bootstrap script
#!/usr/bin/env bash
set -o pipefail
set -o nounset
set -o errexit
IFS=$'\n\t'
function print_help {
echo "usage: $0 [options] <cluster-name>"
@bzon
bzon / bash_maxretries.md
Last active May 20, 2018 06:53
Max retries with counter in bash!
ctr=0
max_retries=10
while [ {{condition}} ]; do
  ctr=`expr $ctr + 1`
  sleep 5
  if [ $ctr == $max_retries ]; then
    echo "max retries ($max_retries) reached"
    exit 1
 fi
hello
world
dog
cat
fish
car
golang
@bzon
bzon / LIFERAY_ALIAS.md
Last active November 2, 2017 07:50
LIFERAY_ALIAS.md
alias clear-dns-cache='sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache;say MacOS DNS cache has been cleared, Sir JB'

# Liferay Hacks
export LR_DATE=${LR_DATE:-$(date +%Y-%m-%d)}
export LR_HOME=/Users/john.bryan.j.sazon/Servers/liferay/liferay-dxp-digital-enterprise-7.0-sp4
export LR_TOMCAT_HOME=/Users/john.bryan.j.sazon/Servers/liferay/liferay-dxp-digital-enterprise-7.0-sp4/tomcat-8.0.32